Skip to content

Commit 2e95271

Browse files
committed
[GR-45043] Integrate YARP parser [Part 7]
PullRequest: truffleruby/4094
2 parents f34ca0c + 5b1dd31 commit 2e95271

File tree

71 files changed

+8822
-2247
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+8822
-2247
lines changed
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
fails:Parsing a BEGIN block (BEGIN { ... }) case is parsed correctly
2-
fails:Parsing a END block (END { ... }) case is parsed correctly
3-
fails:Parsing a For operator (for ... in ... operator) case is parsed correctly
1+
# Not supported yet by Prism
2+
# See https://github.com/ruby/prism/issues/1997
3+
fails:Parsing a Regexp (encoding / when there are non-ASCII characters in a literal) case is parsed correctly
4+
fails:Parsing a Regexp (encoding in boolean context / when there are non-ASCII characters in a literal) case is parsed correctly

spec/truffle/parsing/fixtures/BEGIN.yaml

Lines changed: 0 additions & 44 deletions
This file was deleted.
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
subject: "BEGIN block"
2+
description: "BEGIN { ... }"
3+
notes: >
4+
Put content of the BEGIN block at the beginning of the program.
5+
So actual sequence of expressions is:
6+
7+
```ruby
8+
a
9+
b
10+
```
11+
focused_on_node: "org.truffleruby.language.RubyTopLevelRootNode"
12+
ruby: |
13+
b
14+
BEGIN {
15+
a
16+
}
17+
ast: |
18+
RubyTopLevelRootNode
19+
attributes:
20+
arityForCheck = Arity{preRequired = 0, optional = 0, hasRest = true, isImplicitRest = false, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = false}
21+
callTarget = <top (required)>
22+
checkArityProfile = false
23+
frameDescriptor = FrameDescriptor@...{#0:(self), #1:%$~_}
24+
instrumentationBits = 0
25+
keywordArguments = false
26+
localReturnProfile = false
27+
lock = java.util.concurrent.locks.ReentrantLock@...[Unlocked]
28+
matchingReturnProfile = false
29+
nextProfile = false
30+
nonMatchingReturnProfile = false
31+
polyglotRef = org.truffleruby.RubyLanguage@...
32+
retryProfile = false
33+
returnID = org.truffleruby.language.control.ReturnID@...
34+
sharedMethodInfo = SharedMethodInfo(staticLexicalScope = :: Object, arity = Arity{preRequired = 0, optional = 0, hasRest = false, isImplicitRest = false, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = false}, originName = <top (required)>, blockDepth = 0, parseName = <top (required)>, notes = null, argumentDescriptors = null)
35+
split = HEURISTIC
36+
children:
37+
body =
38+
SequenceNode
39+
attributes:
40+
flags = 12
41+
children:
42+
body = [
43+
WriteLocalVariableNode
44+
attributes:
45+
flags = 0
46+
frameSlot = 0 # (self)
47+
children:
48+
valueNode =
49+
ProfileArgumentNodeGen
50+
attributes:
51+
flags = 0
52+
children:
53+
childNode_ =
54+
ReadSelfNode
55+
attributes:
56+
flags = 0
57+
RubyCallNode
58+
attributes:
59+
descriptor = NoKeywordArgumentsDescriptor
60+
dispatchConfig = PRIVATE
61+
emptyKeywordsProfile = false
62+
flags = 1
63+
isAttrAssign = false
64+
isSafeNavigation = false
65+
isSplatted = false
66+
isVCall = true
67+
lastArgIsNotHashProfile = false
68+
methodName = "a"
69+
notEmptyKeywordsProfile = false
70+
notRuby2KeywordsHashProfile = false
71+
children:
72+
receiver =
73+
SelfNode
74+
attributes:
75+
flags = 0
76+
RubyCallNode
77+
attributes:
78+
descriptor = NoKeywordArgumentsDescriptor
79+
dispatchConfig = PRIVATE
80+
emptyKeywordsProfile = false
81+
flags = 1
82+
isAttrAssign = false
83+
isSafeNavigation = false
84+
isSplatted = false
85+
isVCall = true
86+
lastArgIsNotHashProfile = false
87+
methodName = "b"
88+
notEmptyKeywordsProfile = false
89+
notRuby2KeywordsHashProfile = false
90+
children:
91+
receiver =
92+
SelfNode
93+
attributes:
94+
flags = 0
95+
]
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
subject: "BEGIN block"
2+
description: "when multiple occurrences in a program"
3+
notes: >
4+
Put content of the BEGIN blocks in order they are located in a program.
5+
So sequence of expressions is:
6+
7+
```ruby
8+
a
9+
b
10+
c
11+
```
12+
focused_on_node: "org.truffleruby.language.RubyTopLevelRootNode"
13+
ruby: |
14+
BEGIN {
15+
a
16+
}
17+
18+
BEGIN {
19+
b
20+
}
21+
22+
BEGIN {
23+
c
24+
}
25+
ast: |
26+
RubyTopLevelRootNode
27+
attributes:
28+
arityForCheck = Arity{preRequired = 0, optional = 0, hasRest = true, isImplicitRest = false, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = false}
29+
callTarget = <top (required)>
30+
checkArityProfile = false
31+
frameDescriptor = FrameDescriptor@...{#0:(self), #1:%$~_}
32+
instrumentationBits = 0
33+
keywordArguments = false
34+
localReturnProfile = false
35+
lock = java.util.concurrent.locks.ReentrantLock@...[Unlocked]
36+
matchingReturnProfile = false
37+
nextProfile = false
38+
nonMatchingReturnProfile = false
39+
polyglotRef = org.truffleruby.RubyLanguage@...
40+
retryProfile = false
41+
returnID = org.truffleruby.language.control.ReturnID@...
42+
sharedMethodInfo = SharedMethodInfo(staticLexicalScope = :: Object, arity = Arity{preRequired = 0, optional = 0, hasRest = false, isImplicitRest = false, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = false}, originName = <top (required)>, blockDepth = 0, parseName = <top (required)>, notes = null, argumentDescriptors = null)
43+
split = HEURISTIC
44+
children:
45+
body =
46+
SequenceNode
47+
attributes:
48+
flags = 12
49+
children:
50+
body = [
51+
WriteLocalVariableNode
52+
attributes:
53+
flags = 0
54+
frameSlot = 0 # (self)
55+
children:
56+
valueNode =
57+
ProfileArgumentNodeGen
58+
attributes:
59+
flags = 0
60+
children:
61+
childNode_ =
62+
ReadSelfNode
63+
attributes:
64+
flags = 0
65+
RubyCallNode
66+
attributes:
67+
descriptor = NoKeywordArgumentsDescriptor
68+
dispatchConfig = PRIVATE
69+
emptyKeywordsProfile = false
70+
flags = 1
71+
isAttrAssign = false
72+
isSafeNavigation = false
73+
isSplatted = false
74+
isVCall = true
75+
lastArgIsNotHashProfile = false
76+
methodName = "a"
77+
notEmptyKeywordsProfile = false
78+
notRuby2KeywordsHashProfile = false
79+
children:
80+
receiver =
81+
SelfNode
82+
attributes:
83+
flags = 0
84+
RubyCallNode
85+
attributes:
86+
descriptor = NoKeywordArgumentsDescriptor
87+
dispatchConfig = PRIVATE
88+
emptyKeywordsProfile = false
89+
flags = 1
90+
isAttrAssign = false
91+
isSafeNavigation = false
92+
isSplatted = false
93+
isVCall = true
94+
lastArgIsNotHashProfile = false
95+
methodName = "b"
96+
notEmptyKeywordsProfile = false
97+
notRuby2KeywordsHashProfile = false
98+
children:
99+
receiver =
100+
SelfNode
101+
attributes:
102+
flags = 0
103+
RubyCallNode
104+
attributes:
105+
descriptor = NoKeywordArgumentsDescriptor
106+
dispatchConfig = PRIVATE
107+
emptyKeywordsProfile = false
108+
flags = 1
109+
isAttrAssign = false
110+
isSafeNavigation = false
111+
isSplatted = false
112+
isVCall = true
113+
lastArgIsNotHashProfile = false
114+
methodName = "c"
115+
notEmptyKeywordsProfile = false
116+
notRuby2KeywordsHashProfile = false
117+
children:
118+
receiver =
119+
SelfNode
120+
attributes:
121+
flags = 0
122+
NilLiteralNode
123+
attributes:
124+
flags = 0
125+
]

spec/truffle/parsing/fixtures/END.yaml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
subject: "END block"
22
description: "END { ... }"
33
notes: >
4-
Is trasnalted into a `Truffle::KernelOperations.at_exit(false) { ... }` call.
4+
Is translated into a `Truffle::KernelOperations.at_exit(false) { ... }` call.
5+
yarp_specific: true # don't optimize reading KernelOperations constant
6+
# with TruffleKernelOperationsModuleLiteralNode
57
focused_on_node: "org.truffleruby.language.control.OnceNode"
68
ruby: |
79
END {
@@ -11,7 +13,7 @@ ruby: |
1113
ast: |
1214
OnceNode
1315
attributes:
14-
flags = 0
16+
flags = 1
1517
holder = org.truffleruby.language.control.OnceNode$Holder@...
1618
children:
1719
child =
@@ -56,7 +58,7 @@ ast: |
5658
callTargets = ProcCallTargets(callTargetForProc = block in <top (required)>, callTargetForLambda = null, altCallTargetCompiler = ...$$Lambda$.../0x...@...)
5759
flags = 0
5860
frameOnStackMarkerSlot = 2
59-
sharedMethodInfo = SharedMethodInfo(staticLexicalScope = :: Object, arity = Arity{preRequired = 0, optional = 0, hasRest = false, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = false}, originName = block in <top (required)>, blockDepth = 1, parseName = block in <top (required)>, notes = <top (required)>, argumentDescriptors = [])
61+
sharedMethodInfo = SharedMethodInfo(staticLexicalScope = :: Object, arity = Arity{preRequired = 0, optional = 0, hasRest = false, isImplicitRest = false, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = false}, originName = block in <top (required)>, blockDepth = 1, parseName = block in <top (required)>, notes = <top (required)>, argumentDescriptors = [])
6062
type = PROC
6163
call targets:
6264
RubyProcRootNode
@@ -70,7 +72,7 @@ ast: |
7072
redoProfile = false
7173
retryProfile = false
7274
returnID = org.truffleruby.language.control.ReturnID@...
73-
sharedMethodInfo = SharedMethodInfo(staticLexicalScope = :: Object, arity = Arity{preRequired = 0, optional = 0, hasRest = false, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = false}, originName = block in <top (required)>, blockDepth = 1, parseName = block in <top (required)>, notes = <top (required)>, argumentDescriptors = [])
75+
sharedMethodInfo = SharedMethodInfo(staticLexicalScope = :: Object, arity = Arity{preRequired = 0, optional = 0, hasRest = false, isImplicitRest = false, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = false}, originName = block in <top (required)>, blockDepth = 1, parseName = block in <top (required)>, notes = <top (required)>, argumentDescriptors = [])
7476
split = HEURISTIC
7577
children:
7678
body =
@@ -103,6 +105,16 @@ ast: |
103105
value = 2
104106
]
105107
receiver =
106-
TruffleKernelOperationsModuleLiteralNode
108+
ReadConstantWithLexicalScopeNode
107109
attributes:
108-
flags = 0
110+
flags = 0
111+
lexicalScope = :: Object
112+
name = "KernelOperations"
113+
children:
114+
getConstantNode =
115+
GetConstantNodeGen
116+
lookupConstantNode =
117+
LookupConstantWithLexicalScopeNodeGen
118+
attributes:
119+
lexicalScope = :: Object
120+
name = "KernelOperations"

0 commit comments

Comments
 (0)