Skip to content

Commit 426b1ca

Browse files
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.
1 parent d57363e commit 426b1ca

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

include/prism/node.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ PRISM_EXPORTED_FUNCTION const char * pm_node_type_to_str(pm_node_type_t node_typ
3333
// declare them here to avoid generating them.
3434
typedef struct pm_scope_node {
3535
pm_node_t base;
36+
pm_node_t *ast_node;
3637
struct pm_parameters_node *parameters;
3738
pm_node_t *body;
3839
pm_constant_id_list_t locals;

src/prism.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,7 @@ pm_scope_node_init(pm_node_t *node, pm_scope_node_t *scope) {
669669
scope->base.location.start = node->location.start;
670670
scope->base.location.end = node->location.end;
671671

672+
scope->ast_node = node;
672673
scope->parameters = NULL;
673674
scope->body = NULL;
674675
pm_constant_id_list_init(&scope->locals);

0 commit comments

Comments
 (0)