Skip to content

Commit

Permalink
#77 set a flag on local symbols to indicate that the local was initia…
Browse files Browse the repository at this point in the history
…lized with a literal value.
  • Loading branch information
dibyendumajumdar committed Mar 19, 2022
1 parent ac42b0a commit 3f81e74
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1540,11 +1540,15 @@ static void limit_function_call_results(ParserState *parser, int num_lhs, AstNod
}
}

static inline int min_int(int a, int b) {
return a <= b ? a: b;
}

/**
* Marks locals that have an initializer with literal value
*/
static void detect_constant_assignments(LocalStatement *local_statement) {
int maxele = min(raviX_ptrlist_size((const PtrList *)local_statement->var_list), raviX_ptrlist_size((const PtrList *)local_statement->expr_list));
int maxele = min_int(raviX_ptrlist_size((const PtrList *)local_statement->var_list), raviX_ptrlist_size((const PtrList *)local_statement->expr_list));
for (int i = 0; i < maxele; i++) {
LuaSymbol *symbol = (LuaSymbol *) raviX_ptrlist_nth_entry((PtrList *)local_statement->var_list, i);
AstNode *expr = (AstNode *) raviX_ptrlist_nth_entry((PtrList *)local_statement->expr_list, i);
Expand Down

0 comments on commit 3f81e74

Please sign in to comment.