From e2ac7b3d8b58816813ad1d05ed86fec8c80973d6 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 22 Oct 2015 06:30:12 +0000 Subject: Safe navigation operator * compile.c (iseq_peephole_optimize): peephole optimization for branchnil jumps. * compile.c (iseq_compile_each): generate save navigation operator code. * insns.def (branchnil): new opcode to pop the tos and branch if it is nil. * parse.y (NEW_QCALL, call_op, parser_yylex): parse token '.?'. [Feature #11537] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- node.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'node.c') diff --git a/node.c b/node.c index db9aa775f3..320e5d3bd4 100644 --- a/node.c +++ b/node.c @@ -357,7 +357,10 @@ dump_node(VALUE buf, VALUE indent, int comment, NODE *node) ANN(" where [attr]: [nd_next->nd_vid]"); ANN("example: struct.field += foo"); F_NODE(nd_recv, "receiver"); - F_ID(nd_next->nd_vid, "attr"); + F_CUSTOM1(nd_next->nd_vid, "attr") { + if (node->nd_next->nd_aid) A("? "); + A_ID(node->nd_next->nd_vid); + } F_CUSTOM1(nd_next->nd_mid, "operator") { switch (node->nd_next->nd_mid) { case 0: A("0 (||)"); break; -- cgit v1.2.3