Skip to content

Commit

Permalink
#77 simple optimization phase to replace upvalues that reference lite…
Browse files Browse the repository at this point in the history
…rals with those literals
  • Loading branch information
dibyendumajumdar committed Mar 20, 2022
1 parent 508334f commit 3f47036
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1253,17 +1253,22 @@ static AstNode *parse_embedded_C(ParserState *parser, bool is_decl) {
const StringObject *varname = ls->t.seminfo.ts;
bool is_local = 0;
LuaSymbol *symbol = search_for_variable(parser, varname, &is_local);
if (symbol && is_local)
if (symbol && is_local) {
raviX_add_symbol(parser->compiler_state, &node->embedded_C_stmt.symbols, symbol);
symbol->variable.modified = 1; // assume local will be modified
}
else {
raviX_syntaxerror(ls, "Argument to C__unsafe() must be a local variable");
}
raviX_next(ls);
while (testnext(ls, ',')) {
varname = check_name_and_next(ls);
symbol = search_for_variable(parser, varname, &is_local);
if (symbol && is_local)
raviX_add_symbol(parser->compiler_state, &node->embedded_C_stmt.symbols, symbol);
if (symbol && is_local) {
raviX_add_symbol(parser->compiler_state, &node->embedded_C_stmt.symbols,
symbol);
symbol->variable.modified = 1; // assume local will be modified
}
else {
raviX_syntaxerror(ls, "Argument to C__unsafe() must be a local variable");
}
Expand Down

0 comments on commit 3f47036

Please sign in to comment.