Skip to content

Commit

Permalink
issue #35 enhance the lua_variable_symbol structure to hold a referen…
Browse files Browse the repository at this point in the history
…ce to the _ENV symbol
  • Loading branch information
dibyendumajumdar committed Oct 3, 2020
1 parent 123703e commit 66d35a1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,9 @@ static struct ast_node *new_symbol_reference(struct parser_state *parser, const
// resolved by _ENV[name] - we leave that to the code generator to decide.
// However adding an upvalue later is hard so we do it here.
add_upvalue_for_ENV(parser);
bool is_local;
global->variable.env = search_for_variable(parser, parser->container->_ENV, &is_local);
assert(global->variable.env);
}
struct ast_node *symbol_expr = allocate_expr_ast_node(parser, EXPR_SYMBOL);
symbol_expr->symbol_expr.type = symbol->variable.value_type;
Expand Down
1 change: 1 addition & 0 deletions src/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ struct lua_variable_symbol {
struct var_type value_type;
const struct string_object *var_name; /* name of the variable */
struct block_scope *block; /* NULL if global symbol, as globals are never added to a scope */
struct lua_symbol *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 */
struct pseudo *pseudo; /* backend data for the symbol */
Expand Down

0 comments on commit 66d35a1

Please sign in to comment.