ruby-changes:54449
From: nobu <ko1@a...>
Date: Mon, 31 Dec 2018 23:59:34 +0900 (JST)
Subject: [ruby-changes:54449] nobu:r66664 (trunk): use a local variable
nobu 2018-12-31 23:59:27 +0900 (Mon, 31 Dec 2018) New Revision: 66664 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=66664 Log: use a local variable Modified files: trunk/compile.c Index: compile.c =================================================================== --- compile.c (revision 66663) +++ compile.c (revision 66664) @@ -4491,6 +4491,7 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCH https://github.com/ruby/ruby/blob/trunk/compile.c#L4491 { enum defined_type expr_type = DEFINED_NOT_DEFINED; enum node_type type; + const int line = nd_line(node); switch (type = nd_type(node)) { @@ -4515,9 +4516,9 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCH https://github.com/ruby/ruby/blob/trunk/compile.c#L4516 defined_expr0(iseq, ret, vals->nd_head, lfinish, Qfalse); if (!lfinish[1]) { - lfinish[1] = NEW_LABEL(nd_line(node)); + lfinish[1] = NEW_LABEL(line); } - ADD_INSNL(ret, nd_line(node), branchunless, lfinish[1]); + ADD_INSNL(ret, line, branchunless, lfinish[1]); } while ((vals = vals->nd_next) != NULL); } case NODE_STR: @@ -4536,44 +4537,44 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCH https://github.com/ruby/ruby/blob/trunk/compile.c#L4537 break; case NODE_IVAR: - ADD_INSN(ret, nd_line(node), putnil); - ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_IVAR), + ADD_INSN(ret, line, putnil); + ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_IVAR), ID2SYM(node->nd_vid), needstr); return 1; case NODE_GVAR: - ADD_INSN(ret, nd_line(node), putnil); - ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_GVAR), + ADD_INSN(ret, line, putnil); + ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_GVAR), ID2SYM(node->nd_entry->id), needstr); return 1; case NODE_CVAR: - ADD_INSN(ret, nd_line(node), putnil); - ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_CVAR), + ADD_INSN(ret, line, putnil); + ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_CVAR), ID2SYM(node->nd_vid), needstr); return 1; case NODE_CONST: - ADD_INSN(ret, nd_line(node), putnil); - ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_CONST), + ADD_INSN(ret, line, putnil); + ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_CONST), ID2SYM(node->nd_vid), needstr); return 1; case NODE_COLON2: if (!lfinish[1]) { - lfinish[1] = NEW_LABEL(nd_line(node)); + lfinish[1] = NEW_LABEL(line); } defined_expr0(iseq, ret, node->nd_head, lfinish, Qfalse); - ADD_INSNL(ret, nd_line(node), branchunless, lfinish[1]); + ADD_INSNL(ret, line, branchunless, lfinish[1]); COMPILE(ret, "defined/colon2#nd_head", node->nd_head); - ADD_INSN3(ret, nd_line(node), defined, + ADD_INSN3(ret, line, defined, (rb_is_const_id(node->nd_mid) ? INT2FIX(DEFINED_CONST) : INT2FIX(DEFINED_METHOD)), ID2SYM(node->nd_mid), needstr); return 1; case NODE_COLON3: - ADD_INSN1(ret, nd_line(node), putobject, rb_cObject); - ADD_INSN3(ret, nd_line(node), defined, + ADD_INSN1(ret, line, putobject, rb_cObject); + ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_CONST), ID2SYM(node->nd_mid), needstr); return 1; @@ -4588,45 +4589,45 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCH https://github.com/ruby/ruby/blob/trunk/compile.c#L4589 (type == NODE_ATTRASGN && !private_recv_p(node))); if (!lfinish[1] && (node->nd_args || explicit_receiver)) { - lfinish[1] = NEW_LABEL(nd_line(node)); + lfinish[1] = NEW_LABEL(line); } if (node->nd_args) { defined_expr0(iseq, ret, node->nd_args, lfinish, Qfalse); - ADD_INSNL(ret, nd_line(node), branchunless, lfinish[1]); + ADD_INSNL(ret, line, branchunless, lfinish[1]); } if (explicit_receiver) { defined_expr0(iseq, ret, node->nd_recv, lfinish, Qfalse); - ADD_INSNL(ret, nd_line(node), branchunless, lfinish[1]); + ADD_INSNL(ret, line, branchunless, lfinish[1]); COMPILE(ret, "defined/recv", node->nd_recv); - ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_METHOD), + ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_METHOD), ID2SYM(node->nd_mid), needstr); } else { - ADD_INSN(ret, nd_line(node), putself); - ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_FUNC), + ADD_INSN(ret, line, putself); + ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_FUNC), ID2SYM(node->nd_mid), needstr); } return 1; } case NODE_YIELD: - ADD_INSN(ret, nd_line(node), putnil); - ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_YIELD), 0, + ADD_INSN(ret, line, putnil); + ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_YIELD), 0, needstr); return 1; case NODE_BACK_REF: case NODE_NTH_REF: - ADD_INSN(ret, nd_line(node), putnil); - ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_REF), + ADD_INSN(ret, line, putnil); + ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_REF), INT2FIX((node->nd_nth << 1) | (type == NODE_BACK_REF)), needstr); return 1; case NODE_SUPER: case NODE_ZSUPER: - ADD_INSN(ret, nd_line(node), putnil); - ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_ZSUPER), 0, + ADD_INSN(ret, line, putnil); + ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_ZSUPER), 0, needstr); return 1; @@ -4649,10 +4650,10 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCH https://github.com/ruby/ruby/blob/trunk/compile.c#L4650 if (expr_type) { if (needstr != Qfalse) { VALUE str = rb_iseq_defined_string(expr_type); - ADD_INSN1(ret, nd_line(node), putobject, str); + ADD_INSN1(ret, line, putobject, str); } else { - ADD_INSN1(ret, nd_line(node), putobject, Qtrue); + ADD_INSN1(ret, line, putobject, Qtrue); } return 1; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/