Skip to content

Commit caf818c

Browse files
committed
Use ArrayList instead of ArrayDeque
1 parent 36de88c commit caf818c

File tree

3 files changed

+128
-3
lines changed

3 files changed

+128
-3
lines changed
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+
]

src/main/java/org/truffleruby/parser/YARPTranslator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public class YARPTranslator extends AbstractNodeVisitor<RubyNode> {
216216
};
217217

218218
// all the encountered BEGIN {} blocks
219-
private final ArrayDeque<Nodes.PreExecutionNode> beginBlocksQueue = new ArrayDeque<>();
219+
private final ArrayList<Nodes.PreExecutionNode> beginBlocks = new ArrayList<>();
220220

221221
public YARPTranslator(
222222
RubyLanguage language,
@@ -2577,7 +2577,7 @@ public RubyNode visitPostExecutionNode(Nodes.PostExecutionNode node) {
25772577

25782578
@Override
25792579
public RubyNode visitPreExecutionNode(Nodes.PreExecutionNode node) {
2580-
beginBlocksQueue.add(node);
2580+
beginBlocks.add(node);
25812581
return null;
25822582
}
25832583

@@ -2587,7 +2587,7 @@ public RubyNode visitProgramNode(Nodes.ProgramNode node) {
25872587

25882588
// add BEGIN {} blocks at the very beginning of the program
25892589
ArrayList<RubyNode> nodes = new ArrayList<>();
2590-
for (var begin : beginBlocksQueue) {
2590+
for (var begin : beginBlocks) {
25912591
nodes.add(begin.statements.accept(this));
25922592
}
25932593

0 commit comments

Comments
 (0)