mruby-compiler: replace NODE_LITERAL_DELIM with (0 . 0) pattern

NODE_LITERAL_DELIM was only used as a marker in literal arrays.
Replace it with a (0 . 0) pattern which cannot conflict with
empty strings (which would be (0 . ptr) with non-NULL ptr).
This allows removing NODE_LITERAL_DELIM from the node type enum.

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Yukihiro "Matz" Matsumoto
2025-09-02 22:53:21 +09:00
parent 5447e2005c
commit 8034f71a5e
3 changed files with 3 additions and 8 deletions
+2 -2
View File
@@ -68,10 +68,10 @@
/* Maximum number of arguments for some opcodes like OP_SUPER or OP_ARGARY. */
#define MAXARG_S (1<<16)
/* Macro to detect NODE_LITERAL_DELIM separators in literal arrays */
/* Macro to detect (0 . 0) separators in literal arrays */
#define IS_LITERAL_DELIM(node) \
((node) && (node)->car && \
node_to_int((node)->car->car) == NODE_LITERAL_DELIM && \
(node)->car->car == NULL && \
(node)->car->cdr == NULL)
typedef mrb_ast_node node;
-1
View File
@@ -88,7 +88,6 @@ enum node_type {
NODE_POSTEXE,
NODE_DSYM,
NODE_HEREDOC,
NODE_LITERAL_DELIM,
NODE_WORDS,
NODE_SYMBOLS,
NODE_VARIABLE,
+1 -5
View File
@@ -2270,7 +2270,7 @@ new_bv(parser_state *p, mrb_sym id)
static node*
new_literal_delim(parser_state *p)
{
return cons_head((node*)NODE_LITERAL_DELIM, 0);
return cons((node*)0, (node*)0);
}
/* (:words . a) */
@@ -8781,10 +8781,6 @@ mrb_parser_dump(mrb_state *mrb, node *tree, int offset)
dump_recur(mrb, tree, offset+1);
break;
case NODE_LITERAL_DELIM:
printf("NODE_LITERAL_DELIM\n");
break;
case NODE_SELF:
printf("NODE_SELF\n");
break;