mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
mruby-compiler: complete NODE_BACK_REF migration to variable-sized nodes
Remove traditional NODE_BACK_REF case and inline codegen_back_ref logic into gen_back_ref_var. NODE_BACK_REF now exclusively uses variable-sized nodes, directly accessing the type field from the node structure instead of converting through int_to_node/node_to_char. Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -4162,14 +4162,6 @@ codegen_undef(codegen_scope *s, node *tree, int val)
|
||||
gen_load_nil(s, val);
|
||||
}
|
||||
|
||||
static void
|
||||
codegen_back_ref(codegen_scope *s, node *tree, int val)
|
||||
{
|
||||
char buf[] = {'$', node_to_char(tree)};
|
||||
int sym = new_sym(s, mrb_intern(s->mrb, buf, sizeof(buf)));
|
||||
gen_load_op2(s, OP_GETGV, sym, val);
|
||||
}
|
||||
|
||||
static void
|
||||
codegen_block_arg(codegen_scope *s, node *tree, int val)
|
||||
{
|
||||
@@ -5598,7 +5590,9 @@ static void
|
||||
gen_back_ref_var(codegen_scope *s, node *varnode, int val)
|
||||
{
|
||||
struct mrb_ast_back_ref_node *n = (struct mrb_ast_back_ref_node*)varnode;
|
||||
codegen_back_ref(s, int_to_node(n->type), val);
|
||||
char buf[] = {'$', (char)n->type};
|
||||
int sym = new_sym(s, mrb_intern(s->mrb, buf, sizeof(buf)));
|
||||
gen_load_op2(s, OP_GETGV, sym, val);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -6397,10 +6391,6 @@ codegen(codegen_scope *s, node *tree, int val)
|
||||
codegen_const(s, node_to_sym(tree), val);
|
||||
break;
|
||||
|
||||
case NODE_BACK_REF:
|
||||
codegen_back_ref(s, tree, val);
|
||||
break;
|
||||
|
||||
case NODE_ARG:
|
||||
/* should not happen */
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user