diff options
| author | yui-knk <spiketeika@gmail.com> | 2023-09-20 23:51:39 +0900 |
|---|---|---|
| committer | Yuichiro Kaneko <spiketeika@gmail.com> | 2023-09-22 11:25:53 +0900 |
| commit | fb7a2ddb4be21a6d0def8286f341b1b4ee368fe0 (patch) | |
| tree | fb69e8ada6e1d86695eb323732ce6577079f3c29 /parse.y | |
| parent | bf129370d32da9b673d242bb3c9661f2188b3ad0 (diff) | |
Directly free structure managed by imemo tmpbuf
NODE_ARGS, NODE_ARYPTN, NODE_FNDPTN manage memory of their
structure by imemo tmpbuf Object.
However rb_ast_struct has reference to NODE. Then these
memory can be freed directly when rb_ast_struct is freed.
This commit reduces parser's dependency on CRuby functions.
Diffstat (limited to 'parse.y')
| -rw-r--r-- | parse.y | 22 |
1 files changed, 6 insertions, 16 deletions
@@ -12721,13 +12721,9 @@ static NODE* new_args_tail(struct parser_params *p, NODE *kw_args, ID kw_rest_arg, ID block, const YYLTYPE *kw_rest_loc) { int saved_line = p->ruby_sourceline; - NODE *node; - VALUE tmpbuf = rb_imemo_tmpbuf_auto_free_pointer(); + NODE *node = NEW_NODE(NODE_ARGS, 0, 0, 0, &NULL_LOC); struct rb_args_info *args = ZALLOC(struct rb_args_info); - rb_imemo_tmpbuf_set_ptr(tmpbuf, args); - args->imemo = tmpbuf; - node = NEW_NODE(NODE_ARGS, 0, 0, args, &NULL_LOC); - RB_OBJ_WRITTEN(p->ast, Qnil, tmpbuf); + node->nd_ainfo = args; if (p->error_p) return node; args->block_arg = block; @@ -12818,12 +12814,9 @@ static NODE* new_array_pattern_tail(struct parser_params *p, NODE *pre_args, int has_rest, NODE *rest_arg, NODE *post_args, const YYLTYPE *loc) { int saved_line = p->ruby_sourceline; - NODE *node; - VALUE tmpbuf = rb_imemo_tmpbuf_auto_free_pointer(); + NODE *node = NEW_NODE(NODE_ARYPTN, 0, 0, 0, loc); struct rb_ary_pattern_info *apinfo = ZALLOC(struct rb_ary_pattern_info); - rb_imemo_tmpbuf_set_ptr(tmpbuf, apinfo); - node = NEW_NODE(NODE_ARYPTN, 0, tmpbuf, apinfo, loc); - RB_OBJ_WRITTEN(p->ast, Qnil, tmpbuf); + node->nd_apinfo = apinfo; apinfo->pre_args = pre_args; @@ -12852,12 +12845,9 @@ static NODE* new_find_pattern_tail(struct parser_params *p, NODE *pre_rest_arg, NODE *args, NODE *post_rest_arg, const YYLTYPE *loc) { int saved_line = p->ruby_sourceline; - NODE *node; - VALUE tmpbuf = rb_imemo_tmpbuf_auto_free_pointer(); + NODE *node = NEW_NODE(NODE_FNDPTN, 0, 0, 0, loc); struct rb_fnd_pattern_info *fpinfo = ZALLOC(struct rb_fnd_pattern_info); - rb_imemo_tmpbuf_set_ptr(tmpbuf, fpinfo); - node = NEW_NODE(NODE_FNDPTN, 0, tmpbuf, fpinfo, loc); - RB_OBJ_WRITTEN(p->ast, Qnil, tmpbuf); + node->nd_fpinfo = fpinfo; fpinfo->pre_rest_arg = pre_rest_arg ? pre_rest_arg : NODE_SPECIAL_NO_NAME_REST; fpinfo->args = args; |
