diff options
author | Kevin Newton <[email protected]> | 2024-10-17 13:44:15 -0400 |
---|---|---|
committer | Kevin Newton <[email protected]> | 2024-10-18 14:16:02 -0400 |
commit | e17243d3254387ae95b73d9bc6454db36b8e8a43 (patch) | |
tree | 1381a0540593bd546217d9a9546d37c44cc87971 /prism_compile.c | |
parent | f370a31578fa2545514af15f753309aa826d0ae8 (diff) |
Point keyword->table into iseq local table
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/11912
Diffstat (limited to 'prism_compile.c')
-rw-r--r-- | prism_compile.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/prism_compile.c b/prism_compile.c index 04fc96e990..d5b764cd89 100644 --- a/prism_compile.c +++ b/prism_compile.c @@ -6062,17 +6062,12 @@ pm_compile_scope_node(rb_iseq_t *iseq, pm_scope_node_t *scope_node, const pm_nod // ^^^^^^^^ // Keywords create an internal variable on the parse tree if (keywords_list && keywords_list->size) { - body->param.keyword = keyword = ZALLOC_N(struct rb_iseq_param_keyword, 1); + keyword = ZALLOC_N(struct rb_iseq_param_keyword, 1); keyword->num = (int) keywords_list->size; - body->param.flags.has_kw = true; const VALUE default_values = rb_ary_hidden_new(1); const VALUE complex_mark = rb_str_tmp_new(0); - ID *ids = xcalloc(keywords_list->size, sizeof(ID)); - - size_t kw_index = 0; - for (size_t i = 0; i < keywords_list->size; i++) { pm_node_t *keyword_parameter_node = keywords_list->nodes[i]; pm_constant_id_t name; @@ -6091,7 +6086,6 @@ pm_compile_scope_node(rb_iseq_t *iseq, pm_scope_node_t *scope_node, const pm_nod pm_insert_local_index(name, local_index, index_lookup_table, local_table_for_iseq, scope_node); } local_index++; - ids[kw_index++] = local; } } @@ -6121,15 +6115,11 @@ pm_compile_scope_node(rb_iseq_t *iseq, pm_scope_node_t *scope_node, const pm_nod else { pm_insert_local_index(name, local_index, index_lookup_table, local_table_for_iseq, scope_node); } - ids[kw_index++] = local; local_index++; } } - keyword->bits_start = local_index; - keyword->table = ids; - if (RARRAY_LEN(default_values)) { VALUE *dvs = ALLOC_N(VALUE, RARRAY_LEN(default_values)); @@ -6143,9 +6133,13 @@ pm_compile_scope_node(rb_iseq_t *iseq, pm_scope_node_t *scope_node, const pm_nod } // Hidden local for keyword arguments + keyword->bits_start = local_index; ID local = rb_make_temporary_id(local_index); local_table_for_iseq->ids[local_index] = local; local_index++; + + body->param.keyword = keyword; + body->param.flags.has_kw = true; } if (body->type == ISEQ_TYPE_BLOCK && local_index == 1 && requireds_list && requireds_list->size == 1 && !trailing_comma) { @@ -6372,6 +6366,11 @@ pm_compile_scope_node(rb_iseq_t *iseq, pm_scope_node_t *scope_node, const pm_nod iseq_set_local_table(iseq, local_table_for_iseq, 0); scope_node->local_table_for_iseq_size = local_table_for_iseq->size; + if (keyword != NULL) { + size_t keyword_start_index = keyword->bits_start - keyword->num; + keyword->table = (ID *)&ISEQ_BODY(iseq)->local_table[keyword_start_index]; + } + //********STEP 5************ // Goal: compile anything that needed to be compiled if (optionals_list && optionals_list->size) { |