From b325ad991be9327215e21d38075dc16dbc54ad2f Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Thu, 4 Sep 2025 10:12:13 +0900 Subject: [PATCH] mruby-compiler: complete NODE_ALIAS codegen cleanup Removed traditional NODE_ALIAS case from main codegen() switch and inlined codegen_alias() logic directly into gen_alias_var(). This eliminates the hybrid approach that created temporary stack structures and provides direct access to variable-sized node fields. Co-authored-by: Claude --- mrbgems/mruby-compiler/core/codegen.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c index 491f3063b..9661e0d0a 100644 --- a/mrbgems/mruby-compiler/core/codegen.c +++ b/mrbgems/mruby-compiler/core/codegen.c @@ -4626,15 +4626,6 @@ codegen_sclass(codegen_scope *s, node *tree, int val) } } -static void -codegen_alias(codegen_scope *s, node *tree, int val) -{ - int a = new_sym(s, node_to_sym(tree->car)); - int b = new_sym(s, node_to_sym(tree->cdr)); - - genop_2(s, OP_ALIAS, a, b); - gen_load_nil(s, val); -} static void codegen_undef(codegen_scope *s, node *tree, int val) @@ -5951,12 +5942,11 @@ gen_alias_var(codegen_scope *s, const node *varnode, int val) { struct mrb_ast_alias_node *alias = alias_node(varnode); - // Create stack-allocated traditional node structure - node alias_node_stack; - alias_node_stack.car = (node*)(intptr_t)alias->new_name; - alias_node_stack.cdr = (node*)(intptr_t)alias->old_name; + int a = new_sym(s, alias->new_name); + int b = new_sym(s, alias->old_name); - codegen_alias(s, &alias_node_stack, val); + genop_2(s, OP_ALIAS, a, b); + gen_load_nil(s, val); } static void @@ -6553,9 +6543,6 @@ codegen(codegen_scope *s, node *tree, int val) codegen_nil(s, tree, val); break; - case NODE_ALIAS: - codegen_alias(s, tree, val); - break; case NODE_UNDEF: codegen_undef(s, tree, val);