Skip to content
This repository has been archived by the owner on Jun 7, 2020. It is now read-only.

Commit

Permalink
Variables in main scope is now stored in GF #74
Browse files Browse the repository at this point in the history
  • Loading branch information
thejoeejoee committed Nov 24, 2017
1 parent 42c1db8 commit 46ca0c4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 13 deletions.
10 changes: 0 additions & 10 deletions src/code_constructor.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,6 @@ void code_constructor_free(CodeConstructor** constructor) {
void code_constructor_scope_start(CodeConstructor* constructor) {
NULL_POINTER_CHECK(constructor,);

if(constructor->scope_depth == 0) {
// main program scope, generate label for jump from start of this file

GENERATE_CODE(I_CREATE_FRAME);
GENERATE_CODE(I_PUSH_FRAME);
}

constructor->scope_depth++;
}

Expand Down Expand Up @@ -505,9 +498,6 @@ void code_constructor_scope_end(CodeConstructor* constructor) {
NULL_POINTER_CHECK(constructor,);

constructor->scope_depth--;
if(constructor->scope_depth == 0) {
GENERATE_CODE(I_POP_FRAME);
}
}

void code_constructor_stack_type_conversion(CodeConstructor* constructor, DataType current_type, DataType target_type) {
Expand Down
5 changes: 3 additions & 2 deletions src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,9 @@ bool parser_parse_variable_declaration(Parser* parser) {
);
CODE_GENERATION(
{

parser->parser_semantic->actual_variable->frame = VARIABLE_FRAME_LOCAL;
parser->parser_semantic->actual_variable->frame =
parser->parser_semantic->actual_function == NULL ? VARIABLE_FRAME_GLOBAL
: VARIABLE_FRAME_LOCAL;
code_constructor_variable_declaration(
parser->code_constructor,
parser->parser_semantic->actual_variable
Expand Down
2 changes: 1 addition & 1 deletion src/symbol_register.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void symbol_register_push_variables_table(SymbolRegister* register_) {
SymbolTableSymbolVariableStackItem* item = memory_alloc(sizeof(SymbolTableSymbolVariableStackItem));
item->symbol_table = symbol_table_variable_init(16);
item->parent = register_->variables;
item->scope_identifier = register_->variables_table_counter++;
item->scope_identifier = ++register_->variables_table_counter;
item->scope_alias = NULL;
register_->variables = item;
}
Expand Down

0 comments on commit 46ca0c4

Please sign in to comment.