mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
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:
@@ -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;
|
||||
|
||||
@@ -88,7 +88,6 @@ enum node_type {
|
||||
NODE_POSTEXE,
|
||||
NODE_DSYM,
|
||||
NODE_HEREDOC,
|
||||
NODE_LITERAL_DELIM,
|
||||
NODE_WORDS,
|
||||
NODE_SYMBOLS,
|
||||
NODE_VARIABLE,
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user