aboutsummaryrefslogtreecommitdiffstats
path: root/ruby.c
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-27 16:02:34 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-27 16:02:34 +0000
commit45add937f0fe3637fb48403e6990e0eb5322d5ee (patch)
treec92ea58175ec5f1d4efad17cebe45f334f8c2ba2 /ruby.c
parent1bd40a61900d166126b6b6dbe7c06449207d456e (diff)
downloadruby-45add937f0fe3637fb48403e6990e0eb5322d5ee.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 'ruby.c')
-rw-r--r--ruby.c35
1 files changed, 14 insertions, 21 deletions
diff --git a/ruby.c b/ruby.c
index 75f2837d23..94464ab2b9 100644
--- a/ruby.c
+++ b/ruby.c
@@ -177,7 +177,7 @@ cmdline_options_init(ruby_cmdline_options_t *opt)
return opt;
}
-static ast_t *load_file(VALUE parser, VALUE fname, VALUE f, int script,
+static NODE *load_file(VALUE parser, VALUE fname, VALUE f, int script,
ruby_cmdline_options_t *opt);
static VALUE open_load_file(VALUE fname_v, int *xflag);
static void forbid_setid(const char *, const ruby_cmdline_options_t *);
@@ -1461,7 +1461,7 @@ rb_f_chomp(int argc, VALUE *argv)
static VALUE
process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
{
- ast_t *ast = 0;
+ NODE *tree = 0;
VALUE parser;
VALUE script_name;
const rb_iseq_t *iseq;
@@ -1674,12 +1674,12 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
ruby_set_script_name(progname);
rb_parser_set_options(parser, opt->do_print, opt->do_loop,
opt->do_line, opt->do_split);
- ast = rb_parser_compile_string(parser, opt->script, opt->e_script, 1);
+ tree = rb_parser_compile_string(parser, opt->script, opt->e_script, 1);
}
else {
VALUE f;
f = open_load_file(script_name, &opt->xflag);
- ast = load_file(parser, opt->script_name, f, 1, opt);
+ tree = load_file(parser, opt->script_name, f, 1, opt);
}
ruby_set_script_name(opt->script_name);
if (dump & DUMP_BIT(yydebug)) {
@@ -1704,10 +1704,7 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
rb_enc_set_default_internal(Qnil);
rb_stdio_set_default_encoding();
- if (!ast->root) {
- rb_ast_dispose(ast);
- return Qfalse;
- }
+ if (!tree) return Qfalse;
process_sflag(&opt->sflag);
opt->xflag = 0;
@@ -1726,13 +1723,10 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
}
if (dump & (DUMP_BIT(parsetree)|DUMP_BIT(parsetree_with_comment))) {
- rb_io_write(rb_stdout, rb_parser_dump_tree(ast->root, dump & DUMP_BIT(parsetree_with_comment)));
+ rb_io_write(rb_stdout, rb_parser_dump_tree(tree, dump & DUMP_BIT(parsetree_with_comment)));
rb_io_flush(rb_stdout);
dump &= ~DUMP_BIT(parsetree)&~DUMP_BIT(parsetree_with_comment);
- if (!dump) {
- rb_ast_dispose(ast);
- return Qtrue;
- }
+ if (!dump) return Qtrue;
}
{
@@ -1746,8 +1740,7 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
#endif
}
base_block = toplevel_context(toplevel_binding);
- iseq = rb_iseq_new_main(ast->root, opt->script_name, path, vm_block_iseq(base_block));
- rb_ast_dispose(ast);
+ iseq = rb_iseq_new_main(tree, opt->script_name, path, vm_block_iseq(base_block));
}
if (dump & DUMP_BIT(insns)) {
@@ -1797,7 +1790,7 @@ load_file_internal(VALUE argp_v)
ruby_cmdline_options_t *opt = argp->opt;
VALUE f = argp->f;
int line_start = 1;
- ast_t *ast = 0;
+ NODE *tree = 0;
rb_encoding *enc;
ID set_encoding;
@@ -1901,7 +1894,7 @@ load_file_internal(VALUE argp_v)
return (VALUE)rb_parser_compile_string_path(parser, orig_fname, f, line_start);
}
rb_funcall(f, set_encoding, 2, rb_enc_from_encoding(enc), rb_str_new_cstr("-"));
- ast = rb_parser_compile_file_path(parser, orig_fname, f, line_start);
+ tree = rb_parser_compile_file_path(parser, orig_fname, f, line_start);
rb_funcall(f, set_encoding, 1, rb_parser_encoding(parser));
if (script && rb_parser_end_seen_p(parser)) {
/*
@@ -1919,7 +1912,7 @@ load_file_internal(VALUE argp_v)
rb_define_global_const("DATA", f);
argp->f = Qnil;
}
- return (VALUE)ast;
+ return (VALUE)tree;
}
static VALUE
@@ -2011,7 +2004,7 @@ restore_load_file(VALUE arg)
return Qnil;
}
-static ast_t *
+static NODE *
load_file(VALUE parser, VALUE fname, VALUE f, int script, ruby_cmdline_options_t *opt)
{
struct load_file_arg arg;
@@ -2020,8 +2013,8 @@ load_file(VALUE parser, VALUE fname, VALUE f, int script, ruby_cmdline_options_t
arg.script = script;
arg.opt = opt;
arg.f = f;
- return (ast_t *)rb_ensure(load_file_internal, (VALUE)&arg,
- restore_load_file, (VALUE)&arg);
+ return (NODE *)rb_ensure(load_file_internal, (VALUE)&arg,
+ restore_load_file, (VALUE)&arg);
}
void *