зеркало из https://github.com/github/ruby.git
[ruby/prism] Attach the ast node to the scope
So when building instruction sequences for a scope we can reference items from the ast node that requires the scope. This is useful for for loops, where the local variable tables from the parent scope will need to be referenced. https://github.com/ruby/prism/commit/426b1ca094
This commit is contained in:
Родитель
8c2a493233
Коммит
0fdee133fc
|
@ -33,6 +33,7 @@ PRISM_EXPORTED_FUNCTION const char * pm_node_type_to_str(pm_node_type_t node_typ
|
|||
// declare them here to avoid generating them.
|
||||
typedef struct pm_scope_node {
|
||||
pm_node_t base;
|
||||
pm_node_t *ast_node;
|
||||
struct pm_parameters_node *parameters;
|
||||
pm_node_t *body;
|
||||
pm_constant_id_list_t locals;
|
||||
|
|
|
@ -669,6 +669,7 @@ pm_scope_node_init(pm_node_t *node, pm_scope_node_t *scope) {
|
|||
scope->base.location.start = node->location.start;
|
||||
scope->base.location.end = node->location.end;
|
||||
|
||||
scope->ast_node = node;
|
||||
scope->parameters = NULL;
|
||||
scope->body = NULL;
|
||||
pm_constant_id_list_init(&scope->locals);
|
||||
|
|
Загрузка…
Ссылка в новой задаче