Skip to content

Commit

Permalink
#77 local symbol contains a link the literal initializer expression
Browse files Browse the repository at this point in the history
  • Loading branch information
dibyendumajumdar committed Mar 19, 2022
1 parent 3f81e74 commit 0d7e3ae
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ LuaSymbol *raviX_new_local_symbol(CompilerState *compiler_state, Scope *scope, c
symbol->variable.var_name = name;
symbol->variable.pseudo = NULL;
symbol->variable.escaped = 0;
symbol->variable.modified = 0;
symbol->variable.literal_initializer = NULL;
return symbol;
}

Expand Down Expand Up @@ -1554,7 +1556,7 @@ static void detect_constant_assignments(LocalStatement *local_statement) {
AstNode *expr = (AstNode *) raviX_ptrlist_nth_entry((PtrList *)local_statement->expr_list, i);
if (expr->type == EXPR_LITERAL) {
assert(symbol->symbol_type == SYM_LOCAL);
symbol->variable.literal_initializer = 1;
symbol->variable.literal_initializer = expr;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,9 @@ struct LuaVariableSymbol {
LuaSymbol *env; /* Only applicable for global symbols - this should point to _ENV */
unsigned escaped : 1, /* Has one or more up-value references */
function_parameter : 1, /* Is a function parameter */
literal_initializer : 1, /* Was initialized with literal */
modified : 1; /*There is an update to the variable post initialization */
Pseudo *pseudo; /* backend data for the symbol */
AstNode *literal_initializer; /* Was initialized with literal */
};
struct LuaLabelSymbol {
const StringObject *label_name;
Expand Down

0 comments on commit 0d7e3ae

Please sign in to comment.