aboutsummaryrefslogtreecommitdiffstats
path: root/iseq.c
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-27 16:44:57 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-27 16:44:57 +0000
commit6dd10a11da3fcfecf0e41bafa3c05ff76f1769e4 (patch)
treed4346b34db86ab7c09ccb2db3f0e2803664e9421 /iseq.c
parent6743ba2093da68d47929b16d0c6cf15bfdf285ad (diff)
downloadruby-6dd10a11da3fcfecf0e41bafa3c05ff76f1769e4.tar.gz
Revert "Revert "Manage AST NODEs out of GC""
This re-introduces r60485. This reverts commit 5a176b75b1187cbd3861c387bde65ff66396a07c. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60488 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'iseq.c')
-rw-r--r--iseq.c35
1 files changed, 21 insertions, 14 deletions
diff --git a/iseq.c b/iseq.c
index 6047d0017d..0de58c4086 100644
--- a/iseq.c
+++ b/iseq.c
@@ -641,9 +641,9 @@ rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE realpath, VALUE line, c
#else
# define INITIALIZED /* volatile */
#endif
- NODE *(*parse)(VALUE vparser, VALUE fname, VALUE file, int start);
+ ast_t *(*parse)(VALUE vparser, VALUE fname, VALUE file, int start);
int ln;
- NODE *INITIALIZED node;
+ ast_t *INITIALIZED ast;
/* safe results first */
make_compile_option(&option, opt);
@@ -659,18 +659,20 @@ rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE realpath, VALUE line, c
{
const VALUE parser = rb_parser_new();
rb_parser_set_context(parser, base_block, FALSE);
- node = (*parse)(parser, file, src, ln);
+ ast = (*parse)(parser, file, src, ln);
}
- if (!node) {
+ if (!ast->root) {
+ rb_ast_dispose(ast);
rb_exc_raise(th->ec->errinfo);
}
else {
INITIALIZED VALUE label = parent ?
parent->body->location.label :
rb_fstring_cstr("<compiled>");
- iseq = rb_iseq_new_with_opt(node, label, file, realpath, line,
+ iseq = rb_iseq_new_with_opt(ast->root, label, file, realpath, line,
parent, type, &option);
+ rb_ast_dispose(ast);
}
return iseq;
@@ -851,8 +853,8 @@ static VALUE
iseqw_s_compile_file(int argc, VALUE *argv, VALUE self)
{
VALUE file, line = INT2FIX(1), opt = Qnil;
- VALUE parser, f, exc = Qnil;
- const NODE *node;
+ VALUE parser, f, exc = Qnil, ret;
+ ast_t *ast;
rb_compile_option_t option;
int i;
@@ -869,18 +871,23 @@ iseqw_s_compile_file(int argc, VALUE *argv, VALUE self)
parser = rb_parser_new();
rb_parser_set_context(parser, NULL, FALSE);
- node = rb_parser_compile_file_path(parser, file, f, NUM2INT(line));
- if (!node) exc = GET_EC()->errinfo;
+ ast = rb_parser_compile_file_path(parser, file, f, NUM2INT(line));
+ if (!ast->root) exc = GET_EC()->errinfo;
rb_io_close(f);
- if (!node) rb_exc_raise(exc);
+ if (!ast->root) {
+ rb_ast_dispose(ast);
+ rb_exc_raise(exc);
+ }
make_compile_option(&option, opt);
- return iseqw_new(rb_iseq_new_with_opt(node, rb_fstring_cstr("<main>"),
- file,
- rb_realpath_internal(Qnil, file, 1),
- line, NULL, ISEQ_TYPE_TOP, &option));
+ ret = iseqw_new(rb_iseq_new_with_opt(ast->root, rb_fstring_cstr("<main>"),
+ file,
+ rb_realpath_internal(Qnil, file, 1),
+ line, NULL, ISEQ_TYPE_TOP, &option));
+ rb_ast_dispose(ast);
+ return ret;
}
/*