mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
node.h: define rb_ast_body_t and restructure rb_ast_t
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61608 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a6794c4b01
commit
503b858cef
8 changed files with 20 additions and 17 deletions
10
iseq.c
10
iseq.c
|
@ -708,7 +708,7 @@ rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE realpath, VALUE line, c
|
|||
ast = (*parse)(parser, file, src, ln);
|
||||
}
|
||||
|
||||
if (!ast->root) {
|
||||
if (!ast->body.root) {
|
||||
rb_ast_dispose(ast);
|
||||
rb_exc_raise(GET_EC()->errinfo);
|
||||
}
|
||||
|
@ -716,7 +716,7 @@ rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE realpath, VALUE line, c
|
|||
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(ast->body.root, label, file, realpath, line,
|
||||
parent, type, &option);
|
||||
rb_ast_dispose(ast);
|
||||
}
|
||||
|
@ -927,17 +927,17 @@ 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;
|
||||
if (!ast->body.root) exc = GET_EC()->errinfo;
|
||||
|
||||
rb_io_close(f);
|
||||
if (!ast->root) {
|
||||
if (!ast->body.root) {
|
||||
rb_ast_dispose(ast);
|
||||
rb_exc_raise(exc);
|
||||
}
|
||||
|
||||
make_compile_option(&option, opt);
|
||||
|
||||
ret = iseqw_new(rb_iseq_new_with_opt(ast->root, rb_fstring_cstr("<main>"),
|
||||
ret = iseqw_new(rb_iseq_new_with_opt(ast->body.root, rb_fstring_cstr("<main>"),
|
||||
file,
|
||||
rb_realpath_internal(Qnil, file, 1),
|
||||
line, NULL, ISEQ_TYPE_TOP, &option));
|
||||
|
|
2
load.c
2
load.c
|
@ -604,7 +604,7 @@ rb_load_internal0(rb_execution_context_t *ec, VALUE fname, int wrap)
|
|||
VALUE parser = rb_parser_new();
|
||||
rb_parser_set_context(parser, NULL, FALSE);
|
||||
ast = (rb_ast_t *)rb_parser_load_file(parser, fname);
|
||||
iseq = rb_iseq_new_top(ast->root, rb_fstring_cstr("<top (required)>"),
|
||||
iseq = rb_iseq_new_top(ast->body.root, rb_fstring_cstr("<top (required)>"),
|
||||
fname, rb_realpath_internal(Qnil, fname, 1), NULL);
|
||||
rb_ast_dispose(ast);
|
||||
}
|
||||
|
|
2
node.c
2
node.c
|
@ -1150,7 +1150,7 @@ rb_ast_delete_node(rb_ast_t *ast, NODE *n)
|
|||
rb_ast_t *
|
||||
rb_ast_new(void)
|
||||
{
|
||||
return (rb_ast_t *)rb_imemo_new(imemo_ast, 0, (VALUE)rb_node_buffer_new(), rb_ary_tmp_new(0), 0);
|
||||
return (rb_ast_t *)rb_imemo_new(imemo_ast, rb_ary_tmp_new(0), 0, 0, (VALUE)rb_node_buffer_new());
|
||||
}
|
||||
|
||||
void
|
||||
|
|
7
node.h
7
node.h
|
@ -467,12 +467,15 @@ RUBY_SYMBOL_EXPORT_BEGIN
|
|||
|
||||
typedef struct node_buffer_struct node_buffer_t;
|
||||
/* T_IMEMO/ast */
|
||||
typedef struct rb_ast_body_struct {
|
||||
const NODE *root;
|
||||
VALUE reserved;
|
||||
} rb_ast_body_t;
|
||||
typedef struct rb_ast_struct {
|
||||
VALUE flags;
|
||||
VALUE reserved1;
|
||||
const NODE *root;
|
||||
node_buffer_t *node_buffer;
|
||||
VALUE mark_ary;
|
||||
rb_ast_body_t body;
|
||||
} rb_ast_t;
|
||||
rb_ast_t *rb_ast_new();
|
||||
void rb_ast_mark(rb_ast_t*);
|
||||
|
|
2
parse.y
2
parse.y
|
@ -5675,7 +5675,7 @@ yycompile(VALUE vparser, struct parser_params *parser, VALUE fname, int line)
|
|||
ruby_sourceline = line - 1;
|
||||
|
||||
parser->ast = ast = rb_ast_new();
|
||||
ast->root = (NODE *)rb_suppress_tracing(yycompile0, (VALUE)parser);
|
||||
ast->body.root = (NODE *)rb_suppress_tracing(yycompile0, (VALUE)parser);
|
||||
parser->ast = 0;
|
||||
RB_GC_GUARD(vparser); /* prohibit tail call optimization */
|
||||
|
||||
|
|
6
ruby.c
6
ruby.c
|
@ -1704,7 +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) {
|
||||
if (!ast->body.root) {
|
||||
rb_ast_dispose(ast);
|
||||
return Qfalse;
|
||||
}
|
||||
|
@ -1726,7 +1726,7 @@ 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(ast->body.root, dump & DUMP_BIT(parsetree_with_comment)));
|
||||
rb_io_flush(rb_stdout);
|
||||
dump &= ~DUMP_BIT(parsetree)&~DUMP_BIT(parsetree_with_comment);
|
||||
if (!dump) {
|
||||
|
@ -1749,7 +1749,7 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
|
|||
}
|
||||
}
|
||||
base_block = toplevel_context(toplevel_binding);
|
||||
iseq = rb_iseq_new_main(ast->root, opt->script_name, path, vm_block_iseq(base_block));
|
||||
iseq = rb_iseq_new_main(ast->body.root, opt->script_name, path, vm_block_iseq(base_block));
|
||||
rb_ast_dispose(ast);
|
||||
}
|
||||
|
||||
|
|
|
@ -161,11 +161,11 @@ prelude_eval(VALUE code, VALUE name, int line)
|
|||
};
|
||||
|
||||
rb_ast_t *ast = rb_parser_compile_string_path(rb_parser_new(), name, code, line);
|
||||
if (!ast->root) {
|
||||
if (!ast->body.root) {
|
||||
rb_ast_dispose(ast);
|
||||
rb_exc_raise(rb_errinfo());
|
||||
}
|
||||
rb_iseq_eval(rb_iseq_new_with_opt(ast->root, name, name, Qnil, INT2FIX(line),
|
||||
rb_iseq_eval(rb_iseq_new_with_opt(ast->body.root, name, name, Qnil, INT2FIX(line),
|
||||
NULL, ISEQ_TYPE_TOP, &optimization));
|
||||
rb_ast_dispose(ast);
|
||||
}
|
||||
|
|
|
@ -1272,8 +1272,8 @@ eval_make_iseq(VALUE src, VALUE fname, int line, const rb_binding_t *bind,
|
|||
|
||||
rb_parser_set_context(parser, base_block, FALSE);
|
||||
ast = rb_parser_compile_string_path(parser, fname, src, line);
|
||||
if (ast->root) {
|
||||
iseq = rb_iseq_new_with_opt(ast->root,
|
||||
if (ast->body.root) {
|
||||
iseq = rb_iseq_new_with_opt(ast->body.root,
|
||||
parent->body->location.label,
|
||||
fname, realpath, INT2FIX(line),
|
||||
parent, ISEQ_TYPE_EVAL, NULL);
|
||||
|
|
Loading…
Add table
Reference in a new issue