Skip to content

Commit d65c80c

Browse files
committed
global varibales as externs
1 parent cc2e9a0 commit d65c80c

File tree

10 files changed

+26
-10
lines changed

10 files changed

+26
-10
lines changed

c7/src/c7

-984 Bytes
Binary file not shown.

c7/src/core/ast.c

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
#include "ast.h"
55

66

7+
ast_list* ast_root;
8+
int global_register;
9+
710
char* nodetype2str(int node_type) {
811
if (node_type == INTEGER_TYPE)
912
return "int";

c7/src/core/ast.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ typedef struct exps {
6666
struct exps* next;
6767
} ast_list;
6868

69-
ast_list* ast_root;
70-
int global_register;
69+
extern ast_list* ast_root;
70+
extern int global_register;
7171

7272
int len_st();
7373
char* nodetype2str(int node_type);

c7/src/core/main.c

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
#include "parser.h"
88
#include "builder.h"
99

10+
int LEX_VERBOSE, PARSER_VERBOSE, MAIN_VERBOSE, SEMANTIC_VERBOSE,
11+
TAC_VERBOSE, parser_line, parser_column, parser_error,
12+
semantic_error, lex_line, lex_column, lex_error, newline_counter;
1013

1114
void init_vars() {
1215
int verbose = 0;

c7/src/core/main.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#ifndef __MAIN_H__
22
#define __MAIN_H__
33

4-
int LEX_VERBOSE, PARSER_VERBOSE, MAIN_VERBOSE, SEMANTIC_VERBOSE, TAC_VERBOSE,
5-
parser_line, parser_column, parser_error, semantic_error,
6-
lex_line, lex_column, lex_error, newline_counter;
4+
extern int LEX_VERBOSE, PARSER_VERBOSE, MAIN_VERBOSE, SEMANTIC_VERBOSE,
5+
TAC_VERBOSE, parser_line, parser_column, parser_error,
6+
semantic_error, lex_line, lex_column, lex_error, newline_counter;
77

88
int handle_token(int token);
99

c7/src/core/scope.c

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
#include "scope.h"
33

44

5+
lookup_detail *global_lookup_detail;
6+
scope *scope_stack;
7+
int top_lvl, insert_result, arity_counter,
8+
global_var_data_type, global_func_data_type;
9+
10+
511
void print_stack_st() {
612
scope *aux_scope;
713
int count_stack;

c7/src/core/scope.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ typedef struct lookup_detail {
1616
scope *ctx_scope;
1717
} lookup_detail;
1818

19-
lookup_detail *global_lookup_detail;
20-
scope *scope_stack;
21-
int top_lvl, insert_result, arity_counter,
22-
global_var_data_type, global_func_data_type;
19+
extern lookup_detail *global_lookup_detail;
20+
extern scope *scope_stack;
21+
extern int top_lvl, insert_result, arity_counter,
22+
global_var_data_type, global_func_data_type;
2323

2424
void start_root_scope();
2525
void start_root_lookup();

c7/src/core/sym_tab.c

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
#include "sym_tab.h"
33

44

5+
word* global_symbol_table;
6+
7+
58
void set_register(int key, int tac_register) {
69
word *s = find_word(key);
710
s->tac_register = tac_register;

c7/src/core/sym_tab.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ typedef struct word_pos {
3232
UT_hash_handle hh; /* makes this structure hashable */
3333
} word;
3434

35-
word* global_symbol_table;
35+
extern word* global_symbol_table;
3636

3737
int len_st();
3838
void print_aux_st();

c7/src/tac/builder.h

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "sym_tab.h"
66

77
FILE *create_tac();
8+
89
void close_tac(FILE *fp_tac);
910

1011
void write_table(FILE *fp_tac);

0 commit comments

Comments
 (0)