mruby-compiler: convert new_nvar to always use variable-sized nodes

Remove var_nodes_enabled conditional from new_nvar() and traditional
NODE_NVAR case from codegen. All numbered parameter operations now use
unified variable-sized node handling.

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Yukihiro "Matz" Matsumoto
2025-09-11 13:00:14 +09:00
parent 0ca48e24f0
commit 7792280ff3
3 changed files with 1084 additions and 1110 deletions
+4 -22
View File
@@ -2940,11 +2940,6 @@ gen_assignment(codegen_scope *s, node *tree, node *rhs, int sp, int val)
/* keep evaluation order */
break;
case NODE_NVAR:
/* never happens; should have already checked in the parser */
codegen_error(s, "Can't assign to numbered parameter");
break;
case NODE_VARIABLE:
/* Handle variable-sized nodes completely here */
{
@@ -3614,7 +3609,6 @@ codegen_masgn(codegen_scope *s, node *tree, int val)
}
}
static void
codegen_lvar(codegen_scope *s, mrb_sym sym, int val)
{
@@ -3630,17 +3624,6 @@ codegen_lvar(codegen_scope *s, mrb_sym sym, int val)
push();
}
static void
codegen_nvar(codegen_scope *s, node *tree, int val)
{
if (!val) return;
int idx = node_to_int(tree);
gen_move(s, cursp(), idx, val);
push();
}
static void
codegen_const(codegen_scope *s, mrb_sym sym, int val)
{
@@ -5418,8 +5401,11 @@ gen_back_ref_var(codegen_scope *s, node *varnode, int val)
static void
gen_nvar_var(codegen_scope *s, node *varnode, int val)
{
if (!val) return;
struct mrb_ast_nvar_node *n = (struct mrb_ast_nvar_node*)varnode;
codegen_nvar(s, int_to_node(n->num), val);
gen_move(s, cursp(), n->num, val);
push();
}
static void
@@ -6259,10 +6245,6 @@ codegen(codegen_scope *s, node *tree, int val)
codegen_lvar(s, node_to_sym(tree), val);
break;
case NODE_NVAR:
codegen_nvar(s, tree, val);
break;
case NODE_CONST:
codegen_const(s, node_to_sym(tree), val);
break;
-4
View File
@@ -1349,10 +1349,6 @@ new_nvar(parser_state *p, int num)
p->nvars->car = int_to_node(nvar > num ? nvar : num);
}
if (!p->var_nodes_enabled) {
return cons_head((node*)NODE_NVAR, int_to_node(num));
}
size_t total_size = sizeof(struct mrb_ast_nvar_node);
enum mrb_ast_size_class class = size_to_class(total_size);
struct mrb_ast_nvar_node *n = (struct mrb_ast_nvar_node*)parser_alloc_var(p, total_size, class);
File diff suppressed because it is too large Load Diff