From bb3f03633677b19814954da77975ec3f485eb490 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 6 Jun 2014 06:05:19 +0000 Subject: node.h: NODE_PRIVATE_RECV * node.h (NODE_PRIVATE_RECV): name a magic number, `self` as the receiver of a setter method call. * compile.c (private_recv_p), parse.y (attr_receiver): use the named macro. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46361 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- parse.y | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'parse.y') diff --git a/parse.y b/parse.y index 2e73d64401..61251b9309 100644 --- a/parse.y +++ b/parse.y @@ -8895,11 +8895,18 @@ rb_id_attrget(ID id) return attrsetname_to_attr(rb_id2str(id)); } +static inline NODE * +attr_receiver(NODE *recv) +{ + if (recv && nd_type(recv) == NODE_SELF) + recv = NODE_PRIVATE_RECV; + return recv; +} + static NODE * attrset_gen(struct parser_params *parser, NODE *recv, ID id) { - if (recv && nd_type(recv) == NODE_SELF) - recv = (NODE *)1; + recv = attr_receiver(recv); return NEW_ATTRASGN(recv, rb_id_attrset(id), 0); } -- cgit v1.2.3