[PRISM] Fix deconstruct index for posts
This commit is contained in:
parent
300dee1fe8
commit
d77172b79b
@ -6673,10 +6673,6 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
|
|||||||
// those anonymous items temporary names (as below)
|
// those anonymous items temporary names (as below)
|
||||||
int local_index = 0;
|
int local_index = 0;
|
||||||
|
|
||||||
// We will assign these values now, if applicable, and use them for
|
|
||||||
// the ISEQs on these multis
|
|
||||||
int post_multis_hidden_index = 0;
|
|
||||||
|
|
||||||
// Here we figure out local table indices and insert them in to the
|
// Here we figure out local table indices and insert them in to the
|
||||||
// index lookup table and local tables.
|
// index lookup table and local tables.
|
||||||
//
|
//
|
||||||
@ -6787,15 +6783,16 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
|
|||||||
|
|
||||||
for (size_t i = 0; i < posts_list->size; i++, local_index++) {
|
for (size_t i = 0; i < posts_list->size; i++, local_index++) {
|
||||||
ID local;
|
ID local;
|
||||||
// For each MultiTargetNode, we're going to have one
|
|
||||||
// additional anonymous local not represented in the locals table
|
// For each MultiTargetNode, we're going to have one additional
|
||||||
// We want to account for this in our table size
|
// anonymous local not represented in the locals table. We want
|
||||||
pm_node_t *post_node = posts_list->nodes[i];
|
// to account for this in our table size.
|
||||||
|
const pm_node_t *post_node = posts_list->nodes[i];
|
||||||
|
|
||||||
switch (PM_NODE_TYPE(post_node)) {
|
switch (PM_NODE_TYPE(post_node)) {
|
||||||
// def foo(a, (b, *c, d), e = 1, *f, g, (h, *i, j), k:, l: 1, **m, &n)
|
// def foo(a, (b, *c, d), e = 1, *f, g, (h, *i, j), k:, l: 1, **m, &n)
|
||||||
// ^^^^^^^^^^
|
// ^^^^^^^^^^
|
||||||
case PM_MULTI_TARGET_NODE: {
|
case PM_MULTI_TARGET_NODE: {
|
||||||
post_multis_hidden_index = local_index;
|
|
||||||
local = rb_make_temporary_id(local_index);
|
local = rb_make_temporary_id(local_index);
|
||||||
local_table_for_iseq->ids[local_index] = local;
|
local_table_for_iseq->ids[local_index] = local;
|
||||||
break;
|
break;
|
||||||
@ -6803,7 +6800,7 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
|
|||||||
// def foo(a, (b, *c, d), e = 1, *f, g, (h, *i, j), k:, l: 1, **m, &n)
|
// def foo(a, (b, *c, d), e = 1, *f, g, (h, *i, j), k:, l: 1, **m, &n)
|
||||||
// ^
|
// ^
|
||||||
case PM_REQUIRED_PARAMETER_NODE: {
|
case PM_REQUIRED_PARAMETER_NODE: {
|
||||||
pm_required_parameter_node_t * param = (pm_required_parameter_node_t *)post_node;
|
const pm_required_parameter_node_t *param = (const pm_required_parameter_node_t *) post_node;
|
||||||
|
|
||||||
if (PM_NODE_FLAG_P(param, PM_PARAMETER_FLAGS_REPEATED_PARAMETER)) {
|
if (PM_NODE_FLAG_P(param, PM_PARAMETER_FLAGS_REPEATED_PARAMETER)) {
|
||||||
ID local = pm_constant_id_lookup(scope_node, param->name);
|
ID local = pm_constant_id_lookup(scope_node, param->name);
|
||||||
@ -6934,7 +6931,7 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
|
|||||||
// def foo(a, (b, *c, d), e = 1, *f, g, (h, *i, j), k:, l: 1, **m, &n)
|
// def foo(a, (b, *c, d), e = 1, *f, g, (h, *i, j), k:, l: 1, **m, &n)
|
||||||
// ^^^
|
// ^^^
|
||||||
case PM_KEYWORD_REST_PARAMETER_NODE: {
|
case PM_KEYWORD_REST_PARAMETER_NODE: {
|
||||||
pm_keyword_rest_parameter_node_t *kw_rest_node = (pm_keyword_rest_parameter_node_t *)parameters_node->keyword_rest;
|
const pm_keyword_rest_parameter_node_t *kw_rest_node = (const pm_keyword_rest_parameter_node_t *) parameters_node->keyword_rest;
|
||||||
if (!body->param.flags.has_kw) {
|
if (!body->param.flags.has_kw) {
|
||||||
body->param.keyword = keyword = ZALLOC_N(struct rb_iseq_param_keyword, 1);
|
body->param.keyword = keyword = ZALLOC_N(struct rb_iseq_param_keyword, 1);
|
||||||
}
|
}
|
||||||
@ -7036,9 +7033,10 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
|
|||||||
// For each MultiTargetNode, we're going to have one
|
// For each MultiTargetNode, we're going to have one
|
||||||
// additional anonymous local not represented in the locals table
|
// additional anonymous local not represented in the locals table
|
||||||
// We want to account for this in our table size
|
// We want to account for this in our table size
|
||||||
pm_node_t *required = requireds_list->nodes[i];
|
const pm_node_t *required = requireds_list->nodes[i];
|
||||||
|
|
||||||
if (PM_NODE_TYPE_P(required, PM_MULTI_TARGET_NODE)) {
|
if (PM_NODE_TYPE_P(required, PM_MULTI_TARGET_NODE)) {
|
||||||
local_index = pm_compile_destructured_param_locals((pm_multi_target_node_t *)required, index_lookup_table, local_table_for_iseq, scope_node, local_index);
|
local_index = pm_compile_destructured_param_locals((const pm_multi_target_node_t *) required, index_lookup_table, local_table_for_iseq, scope_node, local_index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7049,9 +7047,10 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
|
|||||||
// For each MultiTargetNode, we're going to have one
|
// For each MultiTargetNode, we're going to have one
|
||||||
// additional anonymous local not represented in the locals table
|
// additional anonymous local not represented in the locals table
|
||||||
// We want to account for this in our table size
|
// We want to account for this in our table size
|
||||||
pm_node_t *post= posts_list->nodes[i];
|
const pm_node_t *post = posts_list->nodes[i];
|
||||||
|
|
||||||
if (PM_NODE_TYPE_P(post, PM_MULTI_TARGET_NODE)) {
|
if (PM_NODE_TYPE_P(post, PM_MULTI_TARGET_NODE)) {
|
||||||
local_index = pm_compile_destructured_param_locals((pm_multi_target_node_t *)post, index_lookup_table, local_table_for_iseq, scope_node, local_index);
|
local_index = pm_compile_destructured_param_locals((const pm_multi_target_node_t *) post, index_lookup_table, local_table_for_iseq, scope_node, local_index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7220,7 +7219,7 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
|
|||||||
const pm_node_t *post = posts_list->nodes[i];
|
const pm_node_t *post = posts_list->nodes[i];
|
||||||
|
|
||||||
if (PM_NODE_TYPE_P(post, PM_MULTI_TARGET_NODE)) {
|
if (PM_NODE_TYPE_P(post, PM_MULTI_TARGET_NODE)) {
|
||||||
ADD_GETLOCAL(ret, &dummy_line_node, table_size - post_multis_hidden_index, 0);
|
ADD_GETLOCAL(ret, &dummy_line_node, table_size - body->param.post_start - (int) i, 0);
|
||||||
pm_compile_destructured_param_writes(iseq, (const pm_multi_target_node_t *) post, ret, scope_node);
|
pm_compile_destructured_param_writes(iseq, (const pm_multi_target_node_t *) post, ret, scope_node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user