mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
mruby-compiler: complete NODE_NTH_REF migration to variable-sized nodes
Remove traditional NODE_NTH_REF case and inline codegen_nth_ref logic into gen_nth_ref_var. NODE_NTH_REF now exclusively uses variable-sized nodes, directly accessing the nth value from the node structure instead of converting through int_to_node/node_to_int. Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -4170,18 +4170,6 @@ codegen_back_ref(codegen_scope *s, node *tree, int val)
|
||||
gen_load_op2(s, OP_GETGV, sym, val);
|
||||
}
|
||||
|
||||
static void
|
||||
codegen_nth_ref(codegen_scope *s, node *tree, int val)
|
||||
{
|
||||
mrb_state *mrb = s->mrb;
|
||||
mrb_value str;
|
||||
int sym;
|
||||
|
||||
str = mrb_format(mrb, "$%d", node_to_int(tree));
|
||||
sym = new_sym(s, mrb_intern_str(mrb, str));
|
||||
gen_load_op2(s, OP_GETGV, sym, val);
|
||||
}
|
||||
|
||||
static void
|
||||
codegen_block_arg(codegen_scope *s, node *tree, int val)
|
||||
{
|
||||
@@ -5597,7 +5585,13 @@ static void
|
||||
gen_nth_ref_var(codegen_scope *s, node *varnode, int val)
|
||||
{
|
||||
struct mrb_ast_nth_ref_node *n = (struct mrb_ast_nth_ref_node*)varnode;
|
||||
codegen_nth_ref(s, int_to_node(n->nth), val);
|
||||
mrb_state *mrb = s->mrb;
|
||||
mrb_value str;
|
||||
int sym;
|
||||
|
||||
str = mrb_format(mrb, "$%d", n->nth);
|
||||
sym = new_sym(s, mrb_intern_str(mrb, str));
|
||||
gen_load_op2(s, OP_GETGV, sym, val);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -6407,10 +6401,6 @@ codegen(codegen_scope *s, node *tree, int val)
|
||||
codegen_back_ref(s, tree, val);
|
||||
break;
|
||||
|
||||
case NODE_NTH_REF:
|
||||
codegen_nth_ref(s, tree, val);
|
||||
break;
|
||||
|
||||
case NODE_ARG:
|
||||
/* should not happen */
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user