Skip to content

Commit 0502c3e

Browse files
committed
Translate nodes (DefNode) - support ... parameter
1 parent e1404f0 commit 0502c3e

File tree

6 files changed

+358
-9
lines changed

6 files changed

+358
-9
lines changed
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
subject: "Def"
2+
description: "Argument descriptors / with forwarding operator (...)"
3+
notes: >
4+
Method parameters are described (as ArgumentDescriptor[]) in the following way:
5+
- ArgumentDescriptor(name = %forward_rest, type = rest)
6+
- ArgumentDescriptor(name = %forward_kwrest, type = keyrest)
7+
- ArgumentDescriptor(name = %forward_block, type = block)
8+
9+
So the ... operator is described as a combination of *, ** and & parameters.
10+
focused_on_node: "org.truffleruby.language.methods.LiteralMethodDefinitionNode"
11+
ruby: |
12+
def foo(...)
13+
end
14+
ast: |
15+
LiteralMethodDefinitionNode
16+
attributes:
17+
callTargetSupplier = org.truffleruby.language.methods.CachedLazyCallTargetSupplier@...
18+
flags = 1
19+
isDefSingleton = false
20+
name = "foo"
21+
sharedMethodInfo = SharedMethodInfo(staticLexicalScope = :: Object, arity = Arity{preRequired = 0, optional = 0, hasRest = true, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = true}, originName = foo, blockDepth = 0, parseName = Object#foo, notes = null, argumentDescriptors = [ArgumentDescriptor(name = %forward_rest, type = rest), ArgumentDescriptor(name = %forward_kwrest, type = keyrest), ArgumentDescriptor(name = %forward_block, type = block)])
22+
call targets:
23+
RubyMethodRootNode
24+
attributes:
25+
arityForCheck = Arity{preRequired = 0, optional = 0, hasRest = true, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = true}
26+
callTarget = Object#foo
27+
checkArityProfile = false
28+
frameDescriptor = FrameDescriptor@...{#0:(self), #1:%$~_, #2:%forward_rest, #3:%forward_kwrest, #4:%forward_block, #5:%method_block_arg}
29+
instrumentationBits = 0
30+
keywordArguments = true
31+
localReturnProfile = false
32+
lock = java.util.concurrent.locks.ReentrantLock@...[Unlocked]
33+
matchingReturnProfile = false
34+
nonMatchingReturnProfile = false
35+
polyglotRef = org.truffleruby.RubyLanguage@...
36+
retryProfile = false
37+
returnID = org.truffleruby.language.control.ReturnID@...
38+
sharedMethodInfo = SharedMethodInfo(staticLexicalScope = :: Object, arity = Arity{preRequired = 0, optional = 0, hasRest = true, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = true}, originName = foo, blockDepth = 0, parseName = Object#foo, notes = null, argumentDescriptors = [ArgumentDescriptor(name = %forward_rest, type = rest), ArgumentDescriptor(name = %forward_kwrest, type = keyrest), ArgumentDescriptor(name = %forward_block, type = block)])
39+
split = HEURISTIC
40+
children:
41+
body =
42+
SequenceNode
43+
attributes:
44+
flags = 12
45+
children:
46+
body = [
47+
WriteLocalVariableNode
48+
attributes:
49+
flags = 0
50+
frameSlot = 0
51+
children:
52+
valueNode =
53+
ProfileArgumentNodeGen
54+
attributes:
55+
flags = 0
56+
children:
57+
childNode_ =
58+
ReadSelfNode
59+
attributes:
60+
flags = 0
61+
SaveMethodBlockNode
62+
attributes:
63+
flags = 0
64+
slot = 5
65+
WriteLocalVariableNode
66+
attributes:
67+
flags = 0
68+
frameSlot = 2
69+
children:
70+
valueNode =
71+
ReadRestArgumentNode
72+
attributes:
73+
flags = 0
74+
keywordArguments = true
75+
markKeywordHashWithFlag = false
76+
postArgumentsCount = 0
77+
startIndex = 0
78+
WriteLocalVariableNode
79+
attributes:
80+
flags = 0
81+
frameSlot = 3
82+
children:
83+
valueNode =
84+
ReadKeywordRestArgumentNode
85+
attributes:
86+
excludedKeywords = []
87+
flags = 0
88+
children:
89+
hashes =
90+
HashStoreLibraryGen$CachedDispatchFirst
91+
attributes:
92+
limit_ = 3
93+
readUserKeywordsHashNode =
94+
ReadUserKeywordsHashNode
95+
SaveMethodBlockNode
96+
attributes:
97+
flags = 0
98+
slot = 4
99+
NilLiteralNode
100+
attributes:
101+
flags = 0
102+
]
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
subject: "Def"
2+
description: "Arity / with forwarding operator (...)"
3+
notes: >
4+
Method parameters are described (as Arity object) in the following way:
5+
- preRequired=0
6+
- optional=0
7+
- hasRest=true
8+
- postRequired=0
9+
- keywordArguments=[]
10+
- requiredKeywordArgumentsCount=0
11+
- hasKeywordsRest=true
12+
13+
So there are only * and ** parameters;
14+
focused_on_node: "org.truffleruby.language.methods.LiteralMethodDefinitionNode"
15+
ruby: |
16+
def foo(...)
17+
end
18+
ast: |
19+
LiteralMethodDefinitionNode
20+
attributes:
21+
callTargetSupplier = org.truffleruby.language.methods.CachedLazyCallTargetSupplier@...
22+
flags = 1
23+
isDefSingleton = false
24+
name = "foo"
25+
sharedMethodInfo = SharedMethodInfo(staticLexicalScope = :: Object, arity = Arity{preRequired = 0, optional = 0, hasRest = true, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = true}, originName = foo, blockDepth = 0, parseName = Object#foo, notes = null, argumentDescriptors = [ArgumentDescriptor(name = %forward_rest, type = rest), ArgumentDescriptor(name = %forward_kwrest, type = keyrest), ArgumentDescriptor(name = %forward_block, type = block)])
26+
call targets:
27+
RubyMethodRootNode
28+
attributes:
29+
arityForCheck = Arity{preRequired = 0, optional = 0, hasRest = true, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = true}
30+
callTarget = Object#foo
31+
checkArityProfile = false
32+
frameDescriptor = FrameDescriptor@...{#0:(self), #1:%$~_, #2:%forward_rest, #3:%forward_kwrest, #4:%forward_block, #5:%method_block_arg}
33+
instrumentationBits = 0
34+
keywordArguments = true
35+
localReturnProfile = false
36+
lock = java.util.concurrent.locks.ReentrantLock@...[Unlocked]
37+
matchingReturnProfile = 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 = true, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = true}, originName = foo, blockDepth = 0, parseName = Object#foo, notes = null, argumentDescriptors = [ArgumentDescriptor(name = %forward_rest, type = rest), ArgumentDescriptor(name = %forward_kwrest, type = keyrest), ArgumentDescriptor(name = %forward_block, type = block)])
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
55+
children:
56+
valueNode =
57+
ProfileArgumentNodeGen
58+
attributes:
59+
flags = 0
60+
children:
61+
childNode_ =
62+
ReadSelfNode
63+
attributes:
64+
flags = 0
65+
SaveMethodBlockNode
66+
attributes:
67+
flags = 0
68+
slot = 5
69+
WriteLocalVariableNode
70+
attributes:
71+
flags = 0
72+
frameSlot = 2
73+
children:
74+
valueNode =
75+
ReadRestArgumentNode
76+
attributes:
77+
flags = 0
78+
keywordArguments = true
79+
markKeywordHashWithFlag = false
80+
postArgumentsCount = 0
81+
startIndex = 0
82+
WriteLocalVariableNode
83+
attributes:
84+
flags = 0
85+
frameSlot = 3
86+
children:
87+
valueNode =
88+
ReadKeywordRestArgumentNode
89+
attributes:
90+
excludedKeywords = []
91+
flags = 0
92+
children:
93+
hashes =
94+
HashStoreLibraryGen$CachedDispatchFirst
95+
attributes:
96+
limit_ = 3
97+
readUserKeywordsHashNode =
98+
ReadUserKeywordsHashNode
99+
SaveMethodBlockNode
100+
attributes:
101+
flags = 0
102+
slot = 4
103+
NilLiteralNode
104+
attributes:
105+
flags = 0
106+
]
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
subject: "Def"
2+
description: "Parameters to local variables / with forwarding operator (...)"
3+
notes: >
4+
A rest and a keyword rest parameters are assigned to local variables only:
5+
6+
(WriteLocalVariableNode frameSlot = 2
7+
(ReadRestArgumentNode))
8+
(WriteLocalVariableNode frameSlot = 3
9+
(ReadKeywordRestArgumentNode))
10+
(SaveMethodBlockNode slot = 4)
11+
focused_on_node: "org.truffleruby.language.methods.LiteralMethodDefinitionNode"
12+
ruby: |
13+
def foo(...)
14+
end
15+
ast: |
16+
LiteralMethodDefinitionNode
17+
attributes:
18+
callTargetSupplier = org.truffleruby.language.methods.CachedLazyCallTargetSupplier@...
19+
flags = 1
20+
isDefSingleton = false
21+
name = "foo"
22+
sharedMethodInfo = SharedMethodInfo(staticLexicalScope = :: Object, arity = Arity{preRequired = 0, optional = 0, hasRest = true, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = true}, originName = foo, blockDepth = 0, parseName = Object#foo, notes = null, argumentDescriptors = [ArgumentDescriptor(name = %forward_rest, type = rest), ArgumentDescriptor(name = %forward_kwrest, type = keyrest), ArgumentDescriptor(name = %forward_block, type = block)])
23+
call targets:
24+
RubyMethodRootNode
25+
attributes:
26+
arityForCheck = Arity{preRequired = 0, optional = 0, hasRest = true, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = true}
27+
callTarget = Object#foo
28+
checkArityProfile = false
29+
frameDescriptor = FrameDescriptor@...{#0:(self), #1:%$~_, #2:%forward_rest, #3:%forward_kwrest, #4:%forward_block, #5:%method_block_arg}
30+
instrumentationBits = 0
31+
keywordArguments = true
32+
localReturnProfile = false
33+
lock = java.util.concurrent.locks.ReentrantLock@...[Unlocked]
34+
matchingReturnProfile = false
35+
nonMatchingReturnProfile = false
36+
polyglotRef = org.truffleruby.RubyLanguage@...
37+
retryProfile = false
38+
returnID = org.truffleruby.language.control.ReturnID@...
39+
sharedMethodInfo = SharedMethodInfo(staticLexicalScope = :: Object, arity = Arity{preRequired = 0, optional = 0, hasRest = true, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = true}, originName = foo, blockDepth = 0, parseName = Object#foo, notes = null, argumentDescriptors = [ArgumentDescriptor(name = %forward_rest, type = rest), ArgumentDescriptor(name = %forward_kwrest, type = keyrest), ArgumentDescriptor(name = %forward_block, type = block)])
40+
split = HEURISTIC
41+
children:
42+
body =
43+
SequenceNode
44+
attributes:
45+
flags = 12
46+
children:
47+
body = [
48+
WriteLocalVariableNode
49+
attributes:
50+
flags = 0
51+
frameSlot = 0
52+
children:
53+
valueNode =
54+
ProfileArgumentNodeGen
55+
attributes:
56+
flags = 0
57+
children:
58+
childNode_ =
59+
ReadSelfNode
60+
attributes:
61+
flags = 0
62+
SaveMethodBlockNode
63+
attributes:
64+
flags = 0
65+
slot = 5
66+
WriteLocalVariableNode
67+
attributes:
68+
flags = 0
69+
frameSlot = 2
70+
children:
71+
valueNode =
72+
ReadRestArgumentNode
73+
attributes:
74+
flags = 0
75+
keywordArguments = true
76+
markKeywordHashWithFlag = false
77+
postArgumentsCount = 0
78+
startIndex = 0
79+
WriteLocalVariableNode
80+
attributes:
81+
flags = 0
82+
frameSlot = 3
83+
children:
84+
valueNode =
85+
ReadKeywordRestArgumentNode
86+
attributes:
87+
excludedKeywords = []
88+
flags = 0
89+
children:
90+
hashes =
91+
HashStoreLibraryGen$CachedDispatchFirst
92+
attributes:
93+
limit_ = 3
94+
readUserKeywordsHashNode =
95+
ReadUserKeywordsHashNode
96+
SaveMethodBlockNode
97+
attributes:
98+
flags = 0
99+
slot = 4
100+
NilLiteralNode
101+
attributes:
102+
flags = 0
103+
]

0 commit comments

Comments
 (0)