Skip to content

Commit 60e3ec4

Browse files
committed
Add parsing fixtures for +=
1 parent 087a279 commit 60e3ec4

File tree

11 files changed

+665
-2
lines changed

11 files changed

+665
-2
lines changed

spec/tags/truffle/parsing/parsing_tags.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,8 @@ fails:Parsing a Yield (yield operator with splat operator with multiple precedin
5656
fails:Parsing a Yield (yield operator with splat operator with a single following positional argument (yield *a, b)) case is parsed correctly
5757
fails:Parsing a Yield (yield operator with splat operator with a single preceding and following positional argument (yield a, *b, c)) case is parsed correctly
5858
fails:Parsing a Method call (super / outside a method body without explicit arguments) case is parsed correctly
59+
fails:Parsing a += (Assign an attribute local variable (a.b += c)) case is parsed correctly
60+
fails:Parsing a += (Assign an referenced element (a[b] += c)) case is parsed correctly
61+
fails:Parsing a += (Assign an element referenced with multiple indexes (a[b, c, d] += e)) case is parsed correctly
62+
fails:Parsing a += (Variable assignment/constant (A += b)) case is parsed correctly
63+
fails:Parsing a += (Variable assignment/fully qualified constant (::A += b)) case is parsed correctly
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
subject: "+="
2+
description: "Assign an attribute local variable (a.b += c)"
3+
notes: >
4+
`a.b += c` is translated into `a.b = a.b + c` in the following way:
5+
6+
```ruby
7+
temp_receiver = a
8+
temp_receiver.b = temp_receiver.b + c
9+
```
10+
focused_on_node: "org.truffleruby.language.control.SequenceNode"
11+
ruby: |
12+
a.foo += 42
13+
ast: |
14+
SequenceNode
15+
attributes:
16+
flags = 12
17+
children:
18+
body = [
19+
WriteLocalVariableNode
20+
attributes:
21+
flags = 0
22+
frameSlot = 0 # (self)
23+
children:
24+
valueNode =
25+
ProfileArgumentNodeGen
26+
attributes:
27+
flags = 0
28+
children:
29+
childNode_ =
30+
ReadSelfNode
31+
attributes:
32+
flags = 0
33+
WriteLocalVariableNode
34+
attributes:
35+
flags = 0
36+
frameSlot = 2 # %value_0
37+
children:
38+
valueNode =
39+
RubyCallNode
40+
attributes:
41+
descriptor = org.truffleruby.language.arguments.NoKeywordArgumentsDescriptor@...
42+
dispatchConfig = PRIVATE
43+
emptyKeywordsProfile = false
44+
flags = 0
45+
isAttrAssign = false
46+
isSafeNavigation = false
47+
isSplatted = false
48+
isVCall = true
49+
lastArgIsNotHashProfile = false
50+
methodName = "a"
51+
notEmptyKeywordsProfile = false
52+
notRuby2KeywordsHashProfile = false
53+
children:
54+
receiver =
55+
SelfNode
56+
attributes:
57+
flags = 0
58+
RubyCallNode
59+
attributes:
60+
descriptor = org.truffleruby.language.arguments.NoKeywordArgumentsDescriptor@...
61+
dispatchConfig = PROTECTED
62+
emptyKeywordsProfile = false
63+
flags = 0
64+
isAttrAssign = false
65+
isSafeNavigation = false
66+
isSplatted = false
67+
isVCall = false
68+
lastArgIsNotHashProfile = false
69+
methodName = "foo="
70+
notEmptyKeywordsProfile = false
71+
notRuby2KeywordsHashProfile = false
72+
children:
73+
arguments = [
74+
InlinedAddNodeGen
75+
attributes:
76+
assumptions = [Assumption(valid, name=set_trace_func is not used), Assumption(valid, name=inlined Integer#+), Assumption(valid, name=inlined Float#+)]
77+
flags = 0
78+
parameters = org.truffleruby.language.dispatch.RubyCallNodeParameters@...
79+
children:
80+
leftNode_ =
81+
RubyCallNode
82+
attributes:
83+
descriptor = org.truffleruby.language.arguments.NoKeywordArgumentsDescriptor@...
84+
dispatchConfig = PROTECTED
85+
emptyKeywordsProfile = false
86+
flags = 0
87+
isAttrAssign = false
88+
isSafeNavigation = false
89+
isSplatted = false
90+
isVCall = false
91+
lastArgIsNotHashProfile = false
92+
methodName = "foo"
93+
notEmptyKeywordsProfile = false
94+
notRuby2KeywordsHashProfile = false
95+
children:
96+
receiver =
97+
ReadLocalVariableNode
98+
attributes:
99+
flags = 0
100+
frameSlot = 2 # %value_0
101+
type = FRAME_LOCAL
102+
rightNode_ =
103+
IntegerFixnumLiteralNode
104+
attributes:
105+
flags = 0
106+
value = 42
107+
]
108+
receiver =
109+
ReadLocalVariableNode
110+
attributes:
111+
flags = 0
112+
frameSlot = 2 # %value_0
113+
type = FRAME_LOCAL
114+
]
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
subject: "+="
2+
description: "Assign an referenced element (a[b] += c)"
3+
notes: >
4+
`a[b] += c` is translated into `a[b] = a[b] + c` in the following way:
5+
6+
```ruby
7+
temp_arg1 = b
8+
temp_receiver = a
9+
10+
temp_receiver[temp_arg1] = temp_receiver[temp_arg1] + c
11+
```
12+
focused_on_node: "org.truffleruby.language.control.SequenceNode"
13+
ruby: |
14+
foo[42] += 100500
15+
ast: |
16+
SequenceNode
17+
attributes:
18+
flags = 12
19+
children:
20+
body = [
21+
WriteLocalVariableNode
22+
attributes:
23+
flags = 0
24+
frameSlot = 0 # (self)
25+
children:
26+
valueNode =
27+
ProfileArgumentNodeGen
28+
attributes:
29+
flags = 0
30+
children:
31+
childNode_ =
32+
ReadSelfNode
33+
attributes:
34+
flags = 0
35+
WriteLocalVariableNode
36+
attributes:
37+
flags = 0
38+
frameSlot = 3 # %value_1
39+
children:
40+
valueNode =
41+
IntegerFixnumLiteralNode
42+
attributes:
43+
flags = 0
44+
value = 42
45+
WriteLocalVariableNode
46+
attributes:
47+
flags = 0
48+
frameSlot = 2 # %opelementassign_0
49+
children:
50+
valueNode =
51+
RubyCallNode
52+
attributes:
53+
descriptor = org.truffleruby.language.arguments.NoKeywordArgumentsDescriptor@...
54+
dispatchConfig = PRIVATE
55+
emptyKeywordsProfile = false
56+
flags = 0
57+
isAttrAssign = false
58+
isSafeNavigation = false
59+
isSplatted = false
60+
isVCall = true
61+
lastArgIsNotHashProfile = false
62+
methodName = "foo"
63+
notEmptyKeywordsProfile = false
64+
notRuby2KeywordsHashProfile = false
65+
children:
66+
receiver =
67+
SelfNode
68+
attributes:
69+
flags = 0
70+
InlinedIndexSetNodeGen
71+
attributes:
72+
assumptions = [Assumption(valid, name=set_trace_func is not used)]
73+
flags = 0
74+
parameters = org.truffleruby.language.dispatch.RubyCallNodeParameters@...
75+
children:
76+
operand1Node_ =
77+
ReadLocalVariableNode
78+
attributes:
79+
flags = 0
80+
frameSlot = 3 # %value_1
81+
type = FRAME_LOCAL
82+
operand2Node_ =
83+
InlinedAddNodeGen
84+
attributes:
85+
assumptions = [Assumption(valid, name=set_trace_func is not used), Assumption(valid, name=inlined Integer#+), Assumption(valid, name=inlined Float#+)]
86+
flags = 1
87+
parameters = org.truffleruby.language.dispatch.RubyCallNodeParameters@...
88+
children:
89+
leftNode_ =
90+
InlinedIndexGetNodeGen
91+
attributes:
92+
assumptions = [Assumption(valid, name=set_trace_func is not used)]
93+
flags = 0
94+
parameters = org.truffleruby.language.dispatch.RubyCallNodeParameters@...
95+
children:
96+
leftNode_ =
97+
ReadLocalVariableNode
98+
attributes:
99+
flags = 0
100+
frameSlot = 2 # %opelementassign_0
101+
type = FRAME_LOCAL
102+
rightNode_ =
103+
ReadLocalVariableNode
104+
attributes:
105+
flags = 0
106+
frameSlot = 3 # %value_1
107+
type = FRAME_LOCAL
108+
rightNode_ =
109+
IntegerFixnumLiteralNode
110+
attributes:
111+
flags = 0
112+
value = 100500
113+
receiver_ =
114+
ReadLocalVariableNode
115+
attributes:
116+
flags = 0
117+
frameSlot = 2 # %opelementassign_0
118+
type = FRAME_LOCAL
119+
]

0 commit comments

Comments
 (0)