ruby-changes:49494
From: mame <ko1@a...>
Date: Fri, 5 Jan 2018 17:59:26 +0900 (JST)
Subject: [ruby-changes:49494] mame:r61609 (trunk): make rb_iseq_new* accept rb_ast_body_t instead of NODE*
mame 2018-01-05 17:59:22 +0900 (Fri, 05 Jan 2018) New Revision: 61609 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61609 Log: make rb_iseq_new* accept rb_ast_body_t instead of NODE* Modified files: trunk/compile.c trunk/iseq.c trunk/load.c trunk/ruby.c trunk/template/prelude.c.tmpl trunk/vm.c trunk/vm_core.h trunk/vm_eval.c Index: compile.c =================================================================== --- compile.c (revision 61608) +++ compile.c (revision 61609) @@ -1224,9 +1224,13 @@ new_child_iseq(rb_iseq_t *iseq, const NO https://github.com/ruby/ruby/blob/trunk/compile.c#L1224 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"); Index: vm_eval.c =================================================================== --- vm_eval.c (revision 61608) +++ vm_eval.c (revision 61609) @@ -1273,7 +1273,7 @@ eval_make_iseq(VALUE src, VALUE fname, i https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1273 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); Index: ruby.c =================================================================== --- ruby.c (revision 61608) +++ ruby.c (revision 61609) @@ -1749,7 +1749,7 @@ process_options(int argc, char **argv, r https://github.com/ruby/ruby/blob/trunk/ruby.c#L1749 } } 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); } Index: vm.c =================================================================== --- vm.c (revision 61608) +++ vm.c (revision 61609) @@ -937,7 +937,8 @@ rb_binding_add_dynavars(VALUE bindval, r https://github.com/ruby/ruby/blob/trunk/vm.c#L937 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, r https://github.com/ruby/ruby/blob/trunk/vm.c#L951 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); Index: iseq.c =================================================================== --- iseq.c (revision 61608) +++ iseq.c (revision 61609) @@ -476,24 +476,24 @@ make_compile_option_value(rb_compile_opt https://github.com/ruby/ruby/blob/trunk/iseq.c#L476 } 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) https://github.com/ruby/ruby/blob/trunk/iseq.c#L513 } 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, V https://github.com/ruby/ruby/blob/trunk/iseq.c#L717 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 *ar https://github.com/ruby/ruby/blob/trunk/iseq.c#L938 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)); Index: load.c =================================================================== --- load.c (revision 61608) +++ load.c (revision 61609) @@ -604,7 +604,7 @@ rb_load_internal0(rb_execution_context_t https://github.com/ruby/ruby/blob/trunk/load.c#L604 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); } Index: template/prelude.c.tmpl =================================================================== --- template/prelude.c.tmpl (revision 61608) +++ template/prelude.c.tmpl (revision 61609) @@ -165,7 +165,7 @@ prelude_eval(VALUE code, VALUE name, int https://github.com/ruby/ruby/blob/trunk/template/prelude.c.tmpl#L165 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); } Index: vm_core.h =================================================================== --- vm_core.h (revision 61608) +++ vm_core.h (revision 61609) @@ -884,10 +884,10 @@ typedef enum { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L884 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*); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/