Skip to content

Commit

Permalink
[GR-45043] Integrate YARP parser [Part 7]
Browse files Browse the repository at this point in the history
PullRequest: truffleruby/4094
  • Loading branch information
andrykonchin committed Jan 12, 2024
2 parents f34ca0c + 5b1dd31 commit 2e95271
Show file tree
Hide file tree
Showing 71 changed files with 8,822 additions and 2,247 deletions.
7 changes: 4 additions & 3 deletions spec/tags/truffle/parsing/parsing_tags.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
fails:Parsing a BEGIN block (BEGIN { ... }) case is parsed correctly
fails:Parsing a END block (END { ... }) case is parsed correctly
fails:Parsing a For operator (for ... in ... operator) case is parsed correctly
# Not supported yet by Prism
# See https://github.com/ruby/prism/issues/1997
fails:Parsing a Regexp (encoding / when there are non-ASCII characters in a literal) case is parsed correctly
fails:Parsing a Regexp (encoding in boolean context / when there are non-ASCII characters in a literal) case is parsed correctly
44 changes: 0 additions & 44 deletions spec/truffle/parsing/fixtures/BEGIN.yaml

This file was deleted.

95 changes: 95 additions & 0 deletions spec/truffle/parsing/fixtures/BEGIN/BEGIN.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
subject: "BEGIN block"
description: "BEGIN { ... }"
notes: >
Put content of the BEGIN block at the beginning of the program.
So actual sequence of expressions is:
```ruby
a
b
```
focused_on_node: "org.truffleruby.language.RubyTopLevelRootNode"
ruby: |
b
BEGIN {
a
}
ast: |
RubyTopLevelRootNode
attributes:
arityForCheck = Arity{preRequired = 0, optional = 0, hasRest = true, isImplicitRest = false, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = false}
callTarget = <top (required)>
checkArityProfile = false
frameDescriptor = FrameDescriptor@...{#0:(self), #1:%$~_}
instrumentationBits = 0
keywordArguments = false
localReturnProfile = false
lock = java.util.concurrent.locks.ReentrantLock@...[Unlocked]
matchingReturnProfile = false
nextProfile = false
nonMatchingReturnProfile = false
polyglotRef = org.truffleruby.RubyLanguage@...
retryProfile = false
returnID = org.truffleruby.language.control.ReturnID@...
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)
split = HEURISTIC
children:
body =
SequenceNode
attributes:
flags = 12
children:
body = [
WriteLocalVariableNode
attributes:
flags = 0
frameSlot = 0 # (self)
children:
valueNode =
ProfileArgumentNodeGen
attributes:
flags = 0
children:
childNode_ =
ReadSelfNode
attributes:
flags = 0
RubyCallNode
attributes:
descriptor = NoKeywordArgumentsDescriptor
dispatchConfig = PRIVATE
emptyKeywordsProfile = false
flags = 1
isAttrAssign = false
isSafeNavigation = false
isSplatted = false
isVCall = true
lastArgIsNotHashProfile = false
methodName = "a"
notEmptyKeywordsProfile = false
notRuby2KeywordsHashProfile = false
children:
receiver =
SelfNode
attributes:
flags = 0
RubyCallNode
attributes:
descriptor = NoKeywordArgumentsDescriptor
dispatchConfig = PRIVATE
emptyKeywordsProfile = false
flags = 1
isAttrAssign = false
isSafeNavigation = false
isSplatted = false
isVCall = true
lastArgIsNotHashProfile = false
methodName = "b"
notEmptyKeywordsProfile = false
notRuby2KeywordsHashProfile = false
children:
receiver =
SelfNode
attributes:
flags = 0
]
125 changes: 125 additions & 0 deletions spec/truffle/parsing/fixtures/BEGIN/when_multiple_occurrences.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
subject: "BEGIN block"
description: "when multiple occurrences in a program"
notes: >
Put content of the BEGIN blocks in order they are located in a program.
So sequence of expressions is:
```ruby
a
b
c
```
focused_on_node: "org.truffleruby.language.RubyTopLevelRootNode"
ruby: |
BEGIN {
a
}
BEGIN {
b
}
BEGIN {
c
}
ast: |
RubyTopLevelRootNode
attributes:
arityForCheck = Arity{preRequired = 0, optional = 0, hasRest = true, isImplicitRest = false, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = false}
callTarget = <top (required)>
checkArityProfile = false
frameDescriptor = FrameDescriptor@...{#0:(self), #1:%$~_}
instrumentationBits = 0
keywordArguments = false
localReturnProfile = false
lock = java.util.concurrent.locks.ReentrantLock@...[Unlocked]
matchingReturnProfile = false
nextProfile = false
nonMatchingReturnProfile = false
polyglotRef = org.truffleruby.RubyLanguage@...
retryProfile = false
returnID = org.truffleruby.language.control.ReturnID@...
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)
split = HEURISTIC
children:
body =
SequenceNode
attributes:
flags = 12
children:
body = [
WriteLocalVariableNode
attributes:
flags = 0
frameSlot = 0 # (self)
children:
valueNode =
ProfileArgumentNodeGen
attributes:
flags = 0
children:
childNode_ =
ReadSelfNode
attributes:
flags = 0
RubyCallNode
attributes:
descriptor = NoKeywordArgumentsDescriptor
dispatchConfig = PRIVATE
emptyKeywordsProfile = false
flags = 1
isAttrAssign = false
isSafeNavigation = false
isSplatted = false
isVCall = true
lastArgIsNotHashProfile = false
methodName = "a"
notEmptyKeywordsProfile = false
notRuby2KeywordsHashProfile = false
children:
receiver =
SelfNode
attributes:
flags = 0
RubyCallNode
attributes:
descriptor = NoKeywordArgumentsDescriptor
dispatchConfig = PRIVATE
emptyKeywordsProfile = false
flags = 1
isAttrAssign = false
isSafeNavigation = false
isSplatted = false
isVCall = true
lastArgIsNotHashProfile = false
methodName = "b"
notEmptyKeywordsProfile = false
notRuby2KeywordsHashProfile = false
children:
receiver =
SelfNode
attributes:
flags = 0
RubyCallNode
attributes:
descriptor = NoKeywordArgumentsDescriptor
dispatchConfig = PRIVATE
emptyKeywordsProfile = false
flags = 1
isAttrAssign = false
isSafeNavigation = false
isSplatted = false
isVCall = true
lastArgIsNotHashProfile = false
methodName = "c"
notEmptyKeywordsProfile = false
notRuby2KeywordsHashProfile = false
children:
receiver =
SelfNode
attributes:
flags = 0
NilLiteralNode
attributes:
flags = 0
]
24 changes: 18 additions & 6 deletions spec/truffle/parsing/fixtures/END.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
subject: "END block"
description: "END { ... }"
notes: >
Is trasnalted into a `Truffle::KernelOperations.at_exit(false) { ... }` call.
Is translated into a `Truffle::KernelOperations.at_exit(false) { ... }` call.
yarp_specific: true # don't optimize reading KernelOperations constant
# with TruffleKernelOperationsModuleLiteralNode
focused_on_node: "org.truffleruby.language.control.OnceNode"
ruby: |
END {
Expand All @@ -11,7 +13,7 @@ ruby: |
ast: |
OnceNode
attributes:
flags = 0
flags = 1
holder = org.truffleruby.language.control.OnceNode$Holder@...
children:
child =
Expand Down Expand Up @@ -56,7 +58,7 @@ ast: |
callTargets = ProcCallTargets(callTargetForProc = block in <top (required)>, callTargetForLambda = null, altCallTargetCompiler = ...$$Lambda$.../0x...@...)
flags = 0
frameOnStackMarkerSlot = 2
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 = [])
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 = [])
type = PROC
call targets:
RubyProcRootNode
Expand All @@ -70,7 +72,7 @@ ast: |
redoProfile = false
retryProfile = false
returnID = org.truffleruby.language.control.ReturnID@...
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 = [])
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 = [])
split = HEURISTIC
children:
body =
Expand Down Expand Up @@ -103,6 +105,16 @@ ast: |
value = 2
]
receiver =
TruffleKernelOperationsModuleLiteralNode
ReadConstantWithLexicalScopeNode
attributes:
flags = 0
flags = 0
lexicalScope = :: Object
name = "KernelOperations"
children:
getConstantNode =
GetConstantNodeGen
lookupConstantNode =
LookupConstantWithLexicalScopeNodeGen
attributes:
lexicalScope = :: Object
name = "KernelOperations"
Loading

0 comments on commit 2e95271

Please sign in to comment.