8000 [PRISM] Insert all locals in the locals index table by tenderlove · Pull Request #9663 · ruby/ruby · GitHub
[go: up one dir, main page]

Skip to content

[PRISM] Insert all locals in the locals index table #9663

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 24, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Move filling in the rest of the locals to the end
  • Loading branch information
tenderlove committed Jan 24, 2024
commit 556d046356cc97fef482db53b88a62b450ef5cfd
25 changes: 13 additions & 12 deletions prism_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -6732,6 +6732,17 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
//********STEP 4**********
// Goal: fill in the method body locals
// To be explicit, these are the non-parameter locals
// We fill in the block_locals, if they exist
// lambda { |x; y| y }
// ^
if (block_locals && block_locals->size) {
for (size_t i = 0; i < block_locals->size; i++, local_index++) {
pm_constant_id_t constant_id = ((pm_block_local_variable_node_t *)block_locals->nodes[i])->name;
pm_insert_local_index(constant_id, local_index, index_lookup_table, local_table_for_iseq, scope_node);
}
}

// Fill in any locals we missed
if (scope_node->locals.size) {
for (size_t i = 0; i < scope_node->locals.size; i++) {
pm_constant_id_t constant_id = locals->ids[i];
Expand All @@ -6748,16 +6759,6 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
}
}

// We fill in the block_locals, if they exist
// lambda { |x; y| y }
// ^
if (block_locals && block_locals->size) {
for (size_t i = 0; i < block_locals->size; i++, local_index++) {
pm_constant_id_t constant_id = ((pm_block_local_variable_node_t *)block_locals->nodes[i])->name;
pm_insert_local_index(constant_id, local_index, index_lookup_table, local_table_for_iseq, scope_node);
}
}

//********END OF STEP 4**********

// We set the index_lookup_table on the scope node so we can
Expand All @@ -6774,7 +6775,7 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
// Goal: compile anything that needed to be compiled
if (keywords_list && keywords_list->size) {
size_t optional_index = 0;
for (size_t i = 0; i < keywords_list->size; i++, local_index++) {
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;

Expand Down Expand Up @@ -6825,7 +6826,7 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
// a pointer to the label it should fill out? We already
// have a list of labels allocated above so it seems wasteful
// to do the copies.
for (size_t i = 0; i < optionals_list->size; i++, local_index++) {
for (size_t i = 0; i < optionals_list->size; i++) {
label = NEW_LABEL(lineno);
opt_table[i] = label;
ADD_LABEL(ret, label);
Expand Down
0