From 0d7e3aee959ae74560021bb5a7dee786533afcee Mon Sep 17 00:00:00 2001 From: dibyendumajumdar Date: Sat, 19 Mar 2022 12:57:59 +0000 Subject: [PATCH] #77 local symbol contains a link the literal initializer expression --- src/parser.c | 4 +++- src/parser.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/parser.c b/src/parser.c index 84f3643..119ee05 100644 --- a/src/parser.c +++ b/src/parser.c @@ -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; } @@ -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; } } } diff --git a/src/parser.h b/src/parser.h index d34a6f0..6b48bc1 100644 --- a/src/parser.h +++ b/src/parser.h @@ -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;