summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-06-06 06:05:19 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-06-06 06:05:19 +0000
commitbb3f03633677b19814954da77975ec3f485eb490 (patch)
treee0f25e0a11e312d1af9e71a55a98057f746dbe1f /parse.y
parent71a3cb13eb588abca4833b2a34d48681de90b9fe (diff)
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
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y11
1 files changed, 9 insertions, 2 deletions
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);
}