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

Refactoring out the direct accesses of NODE's u1, u2, and u3

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60812 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
mame 2017-11-16 11:03:37 +00:00
parent 22c8cc44a2
commit ec3a906bb6
4 changed files with 19 additions and 16 deletions

View file

@ -6675,8 +6675,8 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
case NODE_ALIAS:{
ADD_INSN1(ret, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
ADD_INSN1(ret, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_CBASE));
CHECK(COMPILE(ret, "alias arg1", node->u1.node));
CHECK(COMPILE(ret, "alias arg2", node->u2.node));
CHECK(COMPILE(ret, "alias arg1", node->nd_1st));
CHECK(COMPILE(ret, "alias arg2", node->nd_2nd));
ADD_SEND(ret, line, id_core_set_method_alias, INT2FIX(3));
if (popped) {
@ -6686,8 +6686,8 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
}
case NODE_VALIAS:{
ADD_INSN1(ret, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
ADD_INSN1(ret, line, putobject, ID2SYM(node->u1.id));
ADD_INSN1(ret, line, putobject, ID2SYM(node->u2.id));
ADD_INSN1(ret, line, putobject, ID2SYM(node->nd_alias));
ADD_INSN1(ret, line, putobject, ID2SYM(node->nd_orig));
ADD_SEND(ret, line, id_core_set_variable_alias, INT2FIX(2));
if (popped) {
@ -6698,7 +6698,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
case NODE_UNDEF:{
ADD_INSN1(ret, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
ADD_INSN1(ret, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_CBASE));
CHECK(COMPILE(ret, "undef arg", node->u2.node));
CHECK(COMPILE(ret, "undef arg", node->nd_undef));
ADD_SEND(ret, line, id_core_undef_method, INT2FIX(2));
if (popped) {
@ -7058,8 +7058,8 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
const rb_compile_option_t *orig_opt = ISEQ_COMPILE_DATA(iseq)->option;
VALUE orig_cov = ISEQ_COVERAGE(iseq);
rb_compile_option_t new_opt = *orig_opt;
if (node->nd_orig) {
rb_iseq_make_compile_option(&new_opt, node->nd_orig);
if (node->nd_compile_option) {
rb_iseq_make_compile_option(&new_opt, node->nd_compile_option);
ISEQ_COMPILE_DATA(iseq)->option = &new_opt;
}
if (!new_opt.coverage_enabled) ISEQ_COVERAGE_SET(iseq, Qfalse);

11
node.c
View file

@ -802,17 +802,17 @@ dump_node(VALUE buf, VALUE indent, int comment, NODE *node)
ANN("method alias statement");
ANN("format: alias [u1.node] [u2.node]");
ANN("example: alias bar foo");
F_NODE(u1.node, "new name");
F_NODE(nd_1st, "new name");
LAST_NODE;
F_NODE(u2.node, "old name");
F_NODE(nd_2nd, "old name");
return;
case NODE_VALIAS:
ANN("global variable alias statement");
ANN("format: alias [u1.id](gvar) [u2.id](gvar)");
ANN("example: alias $y $x");
F_ID(u1.id, "new name");
F_ID(u2.id, "old name");
F_ID(nd_alias, "new name");
F_ID(nd_orig, "old name");
return;
case NODE_UNDEF:
@ -820,7 +820,7 @@ dump_node(VALUE buf, VALUE indent, int comment, NODE *node)
ANN("format: undef [u2.node]");
ANN("example: undef foo");
LAST_NODE;
F_NODE(u2.node, "old name");
F_NODE(nd_undef, "old name");
return;
case NODE_CLASS:
@ -951,7 +951,6 @@ dump_node(VALUE buf, VALUE indent, int comment, NODE *node)
ANN("pre-execution");
ANN("format: BEGIN { [nd_head] }; [nd_body]");
ANN("example: bar; BEGIN { foo }");
#define nd_compile_option u3.value
F_NODE(nd_head, "prelude");
if (!node->nd_compile_option) LAST_NODE;
F_NODE(nd_body, "body");

8
node.h
View file

@ -299,8 +299,6 @@ typedef struct RNode {
#define nd_body u2.node
#define nd_else u3.node
#define nd_orig u3.value
#define nd_resq u2.node
#define nd_ensr u3.node
@ -361,6 +359,12 @@ typedef struct RNode {
#define nd_visi_ u2.argc
#define nd_alias u1.id
#define nd_orig u2.id
#define nd_undef u2.node
#define nd_compile_option u3.value
#define NEW_NODE(t,a0,a1,a2) rb_node_newnode((t),(VALUE)(a0),(VALUE)(a1),(VALUE)(a2))
#define NEW_DEFN(i,a,d,p) NEW_NODE(NODE_DEFN,0,i,NEW_SCOPE(a,d))

2
vm.c
View file

@ -950,7 +950,7 @@ rb_binding_add_dynavars(VALUE bindval, rb_binding_t *bind, int dyncount, const I
VALUE tempstr = rb_fstring_cstr("<temp>");
iseq = rb_iseq_new_top(node, tempstr, tempstr, tempstr, NULL);
}
node->u1.tbl = 0; /* reset table */
node->nd_tbl = 0; /* reset table */
ALLOCV_END(idtmp);
vm_set_eval_stack(ec, iseq, 0, base_block);