mruby-compiler: complete NODE_HASH and NODE_KW_HASH migration to variable-sized nodes

Remove traditional NODE_HASH and NODE_KW_HASH cases from switch statement.
Inline codegen_hash logic into gen_kw_hash_var and remove unused codegen_hash function.

Parser already creates variable-sized nodes exclusively, so all hash operations
now route through gen_hash_var() and gen_kw_hash_var() respectively.

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Yukihiro "Matz" Matsumoto
2025-09-09 17:22:07 +09:00
parent ad9c130169
commit 626c17d20b
+7 -22
View File
@@ -3779,17 +3779,6 @@ gen_hash_var(codegen_scope *s, node *varnode, int val)
}
}
static void
codegen_hash(codegen_scope *s, node *tree, int val)
{
int nk = gen_hash(s, tree, val, GEN_LIT_ARY_MAX);
if (val && nk >= 0) {
pop_n(nk*2);
genop_2(s, OP_HASH, cursp(), nk);
push();
}
}
static void
codegen_splat(codegen_scope *s, node *tree, int val)
{
@@ -5812,11 +5801,13 @@ static void
gen_kw_hash_var(codegen_scope *s, node *varnode, int val)
{
struct mrb_ast_kw_hash_node *n = kw_hash_node(varnode);
// Create stack-allocated node structure for traditional codegen
struct mrb_ast_node stack_node;
stack_node.car = (node*)NODE_KW_HASH;
stack_node.cdr = n->args;
codegen_hash(s, &stack_node, val);
int nk = gen_hash(s, n->args, val, GEN_LIT_ARY_MAX);
if (val && nk >= 0) {
pop_n(nk*2);
genop_2(s, OP_HASH, cursp(), nk);
push();
}
}
static void
@@ -5870,7 +5861,6 @@ gen_begin_var(codegen_scope *s, node *varnode, int val)
struct mrb_ast_begin_node *begin = begin_node(varnode);
node *body = begin->body;
/* Inline codegen_begin logic - just generate code for the body */
codegen(s, body, val);
}
@@ -6385,11 +6375,6 @@ codegen(codegen_scope *s, node *tree, int val)
codegen_scall(s, tree, val);
break;
case NODE_HASH:
case NODE_KW_HASH:
codegen_hash(s, tree, val);
break;
case NODE_SPLAT:
codegen_splat(s, tree, val);
break;