1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

make rb_iseq_new* accept rb_ast_body_t instead of NODE*

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61609 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
mame 2018-01-05 08:59:22 +00:00
parent 503b858cef
commit 92b81dc597
8 changed files with 31 additions and 24 deletions

View file

@ -1224,9 +1224,13 @@ new_child_iseq(rb_iseq_t *iseq, const NODE *const node,
VALUE name, const rb_iseq_t *parent, enum iseq_type type, int line_no)
{
rb_iseq_t *ret_iseq;
rb_ast_body_t ast;
ast.root = node;
ast.reserved = 0;
debugs("[new_child_iseq]> ---------------------------------------\n");
ret_iseq = rb_iseq_new_with_opt(node, name,
ret_iseq = rb_iseq_new_with_opt(&ast, name,
rb_iseq_path(iseq), rb_iseq_realpath(iseq),
INT2FIX(line_no), parent, type, ISEQ_COMPILE_DATA(iseq)->option);
debugs("[new_child_iseq]< ---------------------------------------\n");

19
iseq.c
View file

@ -476,24 +476,24 @@ make_compile_option_value(rb_compile_option_t *option)
}
rb_iseq_t *
rb_iseq_new(const NODE *node, VALUE name, VALUE path, VALUE realpath,
rb_iseq_new(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath,
const rb_iseq_t *parent, enum iseq_type type)
{
return rb_iseq_new_with_opt(node, name, path, realpath, INT2FIX(0), parent, type,
return rb_iseq_new_with_opt(ast, name, path, realpath, INT2FIX(0), parent, type,
&COMPILE_OPTION_DEFAULT);
}
rb_iseq_t *
rb_iseq_new_top(const NODE *node, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent)
rb_iseq_new_top(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent)
{
return rb_iseq_new_with_opt(node, name, path, realpath, INT2FIX(0), parent, ISEQ_TYPE_TOP,
return rb_iseq_new_with_opt(ast, name, path, realpath, INT2FIX(0), parent, ISEQ_TYPE_TOP,
&COMPILE_OPTION_DEFAULT);
}
rb_iseq_t *
rb_iseq_new_main(const NODE *node, VALUE path, VALUE realpath, const rb_iseq_t *parent)
rb_iseq_new_main(const rb_ast_body_t *ast, VALUE path, VALUE realpath, const rb_iseq_t *parent)
{
return rb_iseq_new_with_opt(node, rb_fstring_cstr("<main>"),
return rb_iseq_new_with_opt(ast, rb_fstring_cstr("<main>"),
path, realpath, INT2FIX(0),
parent, ISEQ_TYPE_MAIN, &COMPILE_OPTION_DEFAULT);
}
@ -513,10 +513,11 @@ iseq_translate(rb_iseq_t *iseq)
}
rb_iseq_t *
rb_iseq_new_with_opt(const NODE *node, VALUE name, VALUE path, VALUE realpath,
rb_iseq_new_with_opt(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath,
VALUE first_lineno, const rb_iseq_t *parent,
enum iseq_type type, const rb_compile_option_t *option)
{
const NODE *node = ast ? ast->root : 0;
/* TODO: argument check */
rb_iseq_t *iseq = iseq_alloc();
@ -716,7 +717,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->body.root, label, file, realpath, line,
iseq = rb_iseq_new_with_opt(&ast->body, label, file, realpath, line,
parent, type, &option);
rb_ast_dispose(ast);
}
@ -937,7 +938,7 @@ iseqw_s_compile_file(int argc, VALUE *argv, VALUE self)
make_compile_option(&option, opt);
ret = iseqw_new(rb_iseq_new_with_opt(ast->body.root, rb_fstring_cstr("<main>"),
ret = iseqw_new(rb_iseq_new_with_opt(&ast->body, rb_fstring_cstr("<main>"),
file,
rb_realpath_internal(Qnil, file, 1),
line, NULL, ISEQ_TYPE_TOP, &option));

2
load.c
View file

@ -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->body.root, rb_fstring_cstr("<top (required)>"),
iseq = rb_iseq_new_top(&ast->body, rb_fstring_cstr("<top (required)>"),
fname, rb_realpath_internal(Qnil, fname, 1), NULL);
rb_ast_dispose(ast);
}

2
ruby.c
View file

@ -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->body.root, opt->script_name, path, vm_block_iseq(base_block));
iseq = rb_iseq_new_main(&ast->body, opt->script_name, path, vm_block_iseq(base_block));
rb_ast_dispose(ast);
}

View file

@ -165,7 +165,7 @@ prelude_eval(VALUE code, VALUE name, int line)
rb_ast_dispose(ast);
rb_exc_raise(rb_errinfo());
}
rb_iseq_eval(rb_iseq_new_with_opt(ast->body.root, name, name, Qnil, INT2FIX(line),
rb_iseq_eval(rb_iseq_new_with_opt(&ast->body, name, name, Qnil, INT2FIX(line),
NULL, ISEQ_TYPE_TOP, &optimization));
rb_ast_dispose(ast);
}

14
vm.c
View file

@ -937,7 +937,8 @@ rb_binding_add_dynavars(VALUE bindval, rb_binding_t *bind, int dyncount, const I
const rb_env_t *env;
rb_execution_context_t *ec = GET_EC();
const rb_iseq_t *base_iseq, *iseq;
NODE *node = 0, tmp_node;
rb_ast_body_t ast;
NODE tmp_node;
ID minibuf[4], *dyns = minibuf;
VALUE idtmp = 0;
@ -950,17 +951,18 @@ rb_binding_add_dynavars(VALUE bindval, rb_binding_t *bind, int dyncount, const I
dyns[0] = dyncount;
MEMCPY(dyns + 1, dynvars, ID, dyncount);
node = &tmp_node;
rb_node_init(node, NODE_SCOPE, (VALUE)dyns, 0, 0);
rb_node_init(&tmp_node, NODE_SCOPE, (VALUE)dyns, 0, 0);
ast.root = &tmp_node;
ast.reserved = 0;
if (base_iseq) {
iseq = rb_iseq_new(node, base_iseq->body->location.label, path, realpath, base_iseq, ISEQ_TYPE_EVAL);
iseq = rb_iseq_new(&ast, base_iseq->body->location.label, path, realpath, base_iseq, ISEQ_TYPE_EVAL);
}
else {
VALUE tempstr = rb_fstring_cstr("<temp>");
iseq = rb_iseq_new_top(node, tempstr, tempstr, tempstr, NULL);
iseq = rb_iseq_new_top(&ast, tempstr, tempstr, tempstr, NULL);
}
node->nd_tbl = 0; /* reset table */
tmp_node.nd_tbl = 0; /* reset table */
ALLOCV_END(idtmp);
vm_set_eval_stack(ec, iseq, 0, base_block);

View file

@ -884,10 +884,10 @@ typedef enum {
RUBY_SYMBOL_EXPORT_BEGIN
/* node -> iseq */
rb_iseq_t *rb_iseq_new (const NODE *node, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent, enum iseq_type);
rb_iseq_t *rb_iseq_new_top (const NODE *node, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent);
rb_iseq_t *rb_iseq_new_main (const NODE *node, VALUE path, VALUE realpath, const rb_iseq_t *parent);
rb_iseq_t *rb_iseq_new_with_opt(const NODE *node, VALUE name, VALUE path, VALUE realpath, VALUE first_lineno,
rb_iseq_t *rb_iseq_new (const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent, enum iseq_type);
rb_iseq_t *rb_iseq_new_top (const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent);
rb_iseq_t *rb_iseq_new_main (const rb_ast_body_t *ast, VALUE path, VALUE realpath, const rb_iseq_t *parent);
rb_iseq_t *rb_iseq_new_with_opt(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath, VALUE first_lineno,
const rb_iseq_t *parent, enum iseq_type, const rb_compile_option_t*);
rb_iseq_t *rb_iseq_new_ifunc(const struct vm_ifunc *ifunc, VALUE name, VALUE path, VALUE realpath, VALUE first_lineno,
const rb_iseq_t *parent, enum iseq_type, const rb_compile_option_t*);

View file

@ -1273,7 +1273,7 @@ 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->body.root) {
iseq = rb_iseq_new_with_opt(ast->body.root,
iseq = rb_iseq_new_with_opt(&ast->body,
parent->body->location.label,
fname, realpath, INT2FIX(line),
parent, ISEQ_TYPE_EVAL, NULL);