mruby-compiler: convert dynamic symbols to always use variable-sized nodes

Remove var_nodes_enabled condition from new_dsym function, completing the
transition to variable-sized nodes for dynamic symbol processing.

Fix gen_dsym_var function to properly extract the dsym node using the
dsym_node() macro and simplify the codegen pattern to match traditional
codegen_dsym behavior.

Remove unused codegen_dsym function and its corresponding NODE_DSYM case
from the main codegen switch, cleaning up dead traditional codegen paths.

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Yukihiro "Matz" Matsumoto
2025-09-03 13:24:18 +09:00
parent 62a16c7a04
commit 1e52b3d421
3 changed files with 1084 additions and 1102 deletions
+4 -14
View File
@@ -3998,13 +3998,6 @@ codegen_sym(codegen_scope *s, mrb_sym sym, int val)
gen_load_op2(s, OP_LOADSYM, i, val);
}
static void
codegen_dsym(codegen_scope *s, node *tree, int val)
{
codegen(s, tree, val);
if (!val) return;
gen_intern(s);
}
static void
codegen_array(codegen_scope *s, node *tree, int val)
@@ -5801,11 +5794,11 @@ gen_heredoc_var(codegen_scope *s, node *varnode, int val)
static void
gen_dsym_var(codegen_scope *s, node *varnode, int val)
{
struct mrb_ast_dsym_node *n = (struct mrb_ast_dsym_node*)varnode;
// Generate str first, then convert to symbol
struct mrb_ast_dsym_node *n = dsym_node(varnode);
// Generate the list content, then intern to symbol
codegen(s, n->list, val);
if (val) {
codegen_heredoc_str(s, n->list, VAL);
genop_1(s, OP_INTERN, cursp());
gen_intern(s);
}
}
@@ -6680,9 +6673,6 @@ codegen(codegen_scope *s, node *tree, int val)
codegen_sym(s, node_to_sym(tree), val);
break;
case NODE_DSYM:
codegen_dsym(s, tree, val);
break;
case NODE_SELF:
codegen_self(s, tree, val);
-4
View File
@@ -2196,10 +2196,6 @@ new_xstr(parser_state *p, node *a)
static node*
new_dsym(parser_state *p, node *a)
{
if (!p->var_nodes_enabled) {
return cons_head((node*)NODE_DSYM, a);
}
size_t total_size = sizeof(struct mrb_ast_dsym_node);
enum mrb_ast_size_class class = size_to_class(total_size);
struct mrb_ast_dsym_node *n = (struct mrb_ast_dsym_node*)parser_alloc_var(p, total_size, class);
File diff suppressed because it is too large Load Diff