aboutsummaryrefslogtreecommitdiffstats
path: root/compile.c
diff options
context:
space:
mode:
authorJemma Issroff <jemmaissroff@gmail.com>2023-10-16 15:36:25 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2023-10-18 17:16:11 -0700
commitba3a99acaf4e024e4d17823f655665bc28f72e0a (patch)
tree6c9b1bb93ec09d672f8a68263f129d96c78cb1a5 /compile.c
parenta9512e80b01c8085c1bb8a1e30497541c844a6c1 (diff)
downloadruby-ba3a99acaf4e024e4d17823f655665bc28f72e0a.tar.gz
Remove pm_compile_context_t, move the context onto ScopeNode
We changed ScopeNodes to point to their parent (previous) ScopeNodes. Accordingly, we can remove pm_compile_context_t, and store all necessary context in ScopeNodes, allowing us to access locals from outer scopes.
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/compile.c b/compile.c
index 12fe347f5b..a097c29a0e 100644
--- a/compile.c
+++ b/compile.c
@@ -968,17 +968,10 @@ rb_iseq_compile_node(rb_iseq_t *iseq, const NODE *node)
return iseq_setup(iseq, ret);
}
-typedef struct pm_compile_context {
- pm_parser_t *parser;
- struct pm_compile_context *previous;
- ID *constants;
- st_table *index_lookup_table;
-} pm_compile_context_t;
-
-static VALUE rb_translate_prism(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret, pm_compile_context_t *compile_context);
+static VALUE rb_translate_prism(rb_iseq_t *iseq, const pm_scope_node_t node, LINK_ANCHOR *const ret);
VALUE
-rb_iseq_compile_prism_node(rb_iseq_t * iseq, const pm_node_t *node, pm_parser_t *parser)
+rb_iseq_compile_prism_node(rb_iseq_t * iseq, pm_scope_node_t scope_node, pm_parser_t *parser)
{
DECL_ANCHOR(ret);
INIT_ANCHOR(ret);
@@ -991,13 +984,9 @@ rb_iseq_compile_prism_node(rb_iseq_t * iseq, const pm_node_t *node, pm_parser_t
constants[index] = rb_intern3((const char *) constant->start, constant->length, encoding);
}
- pm_compile_context_t compile_context = {
- .parser = parser,
- .previous = NULL,
- .constants = constants
- };
+ scope_node.constants = (void *)constants;
- CHECK(rb_translate_prism(iseq, node, ret, &compile_context));
+ CHECK(rb_translate_prism(iseq, scope_node, ret));
free(constants);
CHECK(iseq_setup_insn(iseq, ret));