mruby-compiler: migrate NODE_ENSURE dump to variable-sized nodes

Replace direct cons-list access (tree->car, tree->cdr->cdr) with
proper accessor macros (ENSURE_NODE_BODY, ENSURE_NODE_ENSURE_CLAUSE)
to support variable-sized node structures. Adds null checks for
improved safety and follows the same pattern as other migrated nodes.

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Yukihiro "Matz" Matsumoto
2025-09-26 22:32:36 +09:00
parent 6f5d2d19cb
commit 1dcf59b372
2 changed files with 20 additions and 12 deletions
+10 -6
View File
@@ -7962,12 +7962,16 @@ dump_node(mrb_state *mrb, node *tree, int offset)
case NODE_ENSURE:
printf("NODE_ENSURE:\n");
dump_prefix(offset+1, lineno);
printf("body:\n");
dump_node(mrb, tree->car, offset+2);
dump_prefix(offset+1, lineno);
printf("ensure:\n");
dump_node(mrb, tree->cdr->cdr, offset+2);
if (ENSURE_NODE_BODY(tree)) {
dump_prefix(offset+1, lineno);
printf("body:\n");
dump_node(mrb, ENSURE_NODE_BODY(tree), offset+2);
}
if (ENSURE_NODE_ENSURE_CLAUSE(tree)) {
dump_prefix(offset+1, lineno);
printf("ensure:\n");
dump_node(mrb, ENSURE_NODE_ENSURE_CLAUSE(tree), offset+2);
}
break;
case NODE_LAMBDA:
+10 -6
View File
@@ -14791,12 +14791,16 @@ dump_node(mrb_state *mrb, node *tree, int offset)
case NODE_ENSURE:
printf("NODE_ENSURE:\n");
dump_prefix(offset+1, lineno);
printf("body:\n");
dump_node(mrb, tree->car, offset+2);
dump_prefix(offset+1, lineno);
printf("ensure:\n");
dump_node(mrb, tree->cdr->cdr, offset+2);
if (ENSURE_NODE_BODY(tree)) {
dump_prefix(offset+1, lineno);
printf("body:\n");
dump_node(mrb, ENSURE_NODE_BODY(tree), offset+2);
}
if (ENSURE_NODE_ENSURE_CLAUSE(tree)) {
dump_prefix(offset+1, lineno);
printf("ensure:\n");
dump_node(mrb, ENSURE_NODE_ENSURE_CLAUSE(tree), offset+2);
}
break;
case NODE_LAMBDA: