зеркало из https://github.com/github/ruby.git
Stash tmpbuffer inside internal structs
I guess those AST node were actually used for something, so we'd better not touch them. Instead this commit just puts the tmpbuffer inside a different internal struct so that we can mark them.
This commit is contained in:
Родитель
8cd845aa5b
Коммит
8f096226e1
12
node.c
12
node.c
|
@ -1265,6 +1265,16 @@ mark_ast_value(void *ctx, NODE * node)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case NODE_ARYPTN:
|
||||||
|
{
|
||||||
|
struct rb_ary_pattern_info *apinfo = node->nd_apinfo;
|
||||||
|
rb_gc_mark(apinfo->imemo);
|
||||||
|
}
|
||||||
|
case NODE_ARGS:
|
||||||
|
{
|
||||||
|
struct rb_args_info *args = node->nd_ainfo;
|
||||||
|
rb_gc_mark(args->imemo);
|
||||||
|
}
|
||||||
case NODE_LIT:
|
case NODE_LIT:
|
||||||
case NODE_STR:
|
case NODE_STR:
|
||||||
case NODE_XSTR:
|
case NODE_XSTR:
|
||||||
|
@ -1272,8 +1282,6 @@ mark_ast_value(void *ctx, NODE * node)
|
||||||
case NODE_DXSTR:
|
case NODE_DXSTR:
|
||||||
case NODE_DREGX:
|
case NODE_DREGX:
|
||||||
case NODE_DSYM:
|
case NODE_DSYM:
|
||||||
case NODE_ARGS:
|
|
||||||
case NODE_ARYPTN:
|
|
||||||
rb_gc_mark(node->nd_lit);
|
rb_gc_mark(node->nd_lit);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
2
node.h
2
node.h
|
@ -452,12 +452,14 @@ struct rb_args_info {
|
||||||
|
|
||||||
NODE *opt_args;
|
NODE *opt_args;
|
||||||
int no_kwarg;
|
int no_kwarg;
|
||||||
|
VALUE imemo;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct rb_ary_pattern_info {
|
struct rb_ary_pattern_info {
|
||||||
NODE *pre_args;
|
NODE *pre_args;
|
||||||
NODE *rest_arg;
|
NODE *rest_arg;
|
||||||
NODE *post_args;
|
NODE *post_args;
|
||||||
|
VALUE imemo;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct parser_params;
|
struct parser_params;
|
||||||
|
|
6
parse.y
6
parse.y
|
@ -11128,8 +11128,9 @@ new_args_tail(struct parser_params *p, NODE *kw_args, ID kw_rest_arg, ID block,
|
||||||
|
|
||||||
args = ZALLOC(struct rb_args_info);
|
args = ZALLOC(struct rb_args_info);
|
||||||
VALUE tmpbuf = rb_imemo_tmpbuf_auto_free_pointer(args);
|
VALUE tmpbuf = rb_imemo_tmpbuf_auto_free_pointer(args);
|
||||||
|
args->imemo = tmpbuf;
|
||||||
RB_OBJ_WRITTEN(p->ast, Qnil, tmpbuf);
|
RB_OBJ_WRITTEN(p->ast, Qnil, tmpbuf);
|
||||||
node = NEW_NODE(NODE_ARGS, tmpbuf, 0, args, &NULL_LOC);
|
node = NEW_NODE(NODE_ARGS, 0, 0, args, &NULL_LOC);
|
||||||
if (p->error_p) return node;
|
if (p->error_p) return node;
|
||||||
|
|
||||||
args->block_arg = block;
|
args->block_arg = block;
|
||||||
|
@ -11237,7 +11238,8 @@ new_array_pattern_tail(struct parser_params *p, NODE *pre_args, int has_rest, ID
|
||||||
|
|
||||||
apinfo = ZALLOC(struct rb_ary_pattern_info);
|
apinfo = ZALLOC(struct rb_ary_pattern_info);
|
||||||
VALUE tmpbuf = rb_imemo_tmpbuf_auto_free_pointer(apinfo);
|
VALUE tmpbuf = rb_imemo_tmpbuf_auto_free_pointer(apinfo);
|
||||||
node = NEW_NODE(NODE_ARYPTN, tmpbuf, 0, apinfo, loc);
|
node = NEW_NODE(NODE_ARYPTN, 0, 0, apinfo, loc);
|
||||||
|
apinfo->imemo = tmpbuf;
|
||||||
RB_OBJ_WRITTEN(p->ast, Qnil, tmpbuf);
|
RB_OBJ_WRITTEN(p->ast, Qnil, tmpbuf);
|
||||||
|
|
||||||
apinfo->pre_args = pre_args;
|
apinfo->pre_args = pre_args;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче