summaryrefslogtreecommitdiff
path: root/iseq.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 /iseq.c
parenta9512e80b01c8085c1bb8a1e30497541c844a6c1 (diff)
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 'iseq.c')
-rw-r--r--iseq.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/iseq.c b/iseq.c
index 1c7bafc5a2..1513f0c2d4 100644
--- a/iseq.c
+++ b/iseq.c
@@ -941,10 +941,10 @@ rb_iseq_new_with_opt(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE rea
return iseq_translate(iseq);
}
-VALUE rb_iseq_compile_prism_node(rb_iseq_t * iseq, const pm_node_t *node, pm_parser_t *parser);
+VALUE rb_iseq_compile_prism_node(rb_iseq_t * iseq, pm_scope_node_t scope_node, pm_parser_t *parser);
rb_iseq_t *
-pm_iseq_new_with_opt(pm_node_t *node, pm_parser_t *parser, VALUE name, VALUE path, VALUE realpath,
+pm_iseq_new_with_opt(pm_scope_node_t scope_node, pm_parser_t *parser, VALUE name, VALUE path, VALUE realpath,
int first_lineno, const rb_iseq_t *parent, int isolated_depth,
enum rb_iseq_type type, const rb_compile_option_t *option)
{
@@ -954,28 +954,26 @@ pm_iseq_new_with_opt(pm_node_t *node, pm_parser_t *parser, VALUE name, VALUE pat
if (!option) option = &COMPILE_OPTION_DEFAULT;
- if (node) {
- pm_line_column_t start_line_col = pm_newline_list_line_column(&parser->newline_list, node->location.start);
- pm_line_column_t end_line_col = pm_newline_list_line_column(&parser->newline_list, node->location.end);
-
- code_loc = (rb_code_location_t) {
- .beg_pos = {
- .lineno = (int) start_line_col.line,
- .column = (int) start_line_col.column
- },
- .end_pos = {
- .lineno = (int) end_line_col.line,
- .column = (int) end_line_col.column
- },
- };
- }
+ pm_line_column_t start_line_col = pm_newline_list_line_column(&parser->newline_list, scope_node.base.location.start);
+ pm_line_column_t end_line_col = pm_newline_list_line_column(&parser->newline_list, scope_node.base.location.end);
+
+ code_loc = (rb_code_location_t) {
+ .beg_pos = {
+ .lineno = (int) start_line_col.line,
+ .column = (int) start_line_col.column
+ },
+ .end_pos = {
+ .lineno = (int) end_line_col.line,
+ .column = (int) end_line_col.column
+ },
+ };
// TODO: node_id
int node_id = -1;
prepare_iseq_build(iseq, name, path, realpath, first_lineno, &code_loc, node_id,
parent, isolated_depth, type, script_lines, option);
- rb_iseq_compile_prism_node(iseq, node, parser);
+ rb_iseq_compile_prism_node(iseq, scope_node, parser);
finish_iseq_build(iseq);
@@ -1446,7 +1444,9 @@ iseqw_s_compile_prism(int argc, VALUE *argv, VALUE self)
prepare_iseq_build(iseq, name, file, path, first_lineno, &node_location, node_id,
parent, 0, (enum rb_iseq_type)iseq_type, Qnil, &option);
- rb_iseq_compile_prism_node(iseq, node, &parser);
+ pm_scope_node_t scope_node;
+ pm_scope_node_init(node, &scope_node, NULL, &parser);
+ rb_iseq_compile_prism_node(iseq, scope_node, &parser);
finish_iseq_build(iseq);
pm_node_destroy(&parser, node);