diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-12-31 14:59:27 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-12-31 14:59:27 +0000 |
commit | 705941a4925e6721fe300d263de11179010d02d5 (patch) | |
tree | 33ac5c818cfbbc406374c7ce59e989fe6f3c4ec2 | |
parent | 271c8f5d06bc92d3d3382fbddae616019555ed91 (diff) | |
download | ruby-705941a4925e6721fe300d263de11179010d02d5.tar.gz |
use a local variable
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66664 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | compile.c | 59 |
1 files changed, 30 insertions, 29 deletions
@@ -4491,6 +4491,7 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, { 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_ANCHOR *const ret, 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_ANCHOR *const ret, 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_ANCHOR *const ret, (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_ANCHOR *const ret, 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; } |