diff options
author | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-10-27 16:02:34 +0000 |
---|---|---|
committer | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-10-27 16:02:34 +0000 |
commit | 5a176b75b1187cbd3861c387bde65ff66396a07c (patch) | |
tree | c92ea58175ec5f1d4efad17cebe45f334f8c2ba2 /iseq.c | |
parent | 620ba74778bfdbdc34ffbb142d49ce84a0ef58e9 (diff) | |
download | ruby-5a176b75b1187cbd3861c387bde65ff66396a07c.tar.gz |
Revert "Manage AST NODEs out of GC"
This reverts commit 620ba74778bfdbdc34ffbb142d49ce84a0ef58e9.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60486 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'iseq.c')
-rw-r--r-- | iseq.c | 35 |
1 files changed, 14 insertions, 21 deletions
@@ -641,9 +641,9 @@ rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE realpath, VALUE line, c #else # define INITIALIZED /* volatile */ #endif - ast_t *(*parse)(VALUE vparser, VALUE fname, VALUE file, int start); + NODE *(*parse)(VALUE vparser, VALUE fname, VALUE file, int start); int ln; - ast_t *INITIALIZED ast; + NODE *INITIALIZED node; /* safe results first */ make_compile_option(&option, opt); @@ -659,20 +659,18 @@ 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); - ast = (*parse)(parser, file, src, ln); + node = (*parse)(parser, file, src, ln); } - if (!ast->root) { - rb_ast_dispose(ast); + if (!node) { 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(ast->root, label, file, realpath, line, + iseq = rb_iseq_new_with_opt(node, label, file, realpath, line, parent, type, &option); - rb_ast_dispose(ast); } return iseq; @@ -853,8 +851,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, ret; - ast_t *ast; + VALUE parser, f, exc = Qnil; + const NODE *node; rb_compile_option_t option; int i; @@ -871,23 +869,18 @@ iseqw_s_compile_file(int argc, VALUE *argv, VALUE self) parser = rb_parser_new(); rb_parser_set_context(parser, NULL, FALSE); - ast = rb_parser_compile_file_path(parser, file, f, NUM2INT(line)); - if (!ast->root) exc = GET_EC()->errinfo; + node = rb_parser_compile_file_path(parser, file, f, NUM2INT(line)); + if (!node) exc = GET_EC()->errinfo; rb_io_close(f); - if (!ast->root) { - rb_ast_dispose(ast); - rb_exc_raise(exc); - } + if (!node) rb_exc_raise(exc); make_compile_option(&option, opt); - 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; + 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)); } /* |