Skip to content

Commit 4b5d805

Browse files
committed
Remove unused argument for findLocalVarNode()
1 parent cded038 commit 4b5d805

File tree

4 files changed

+48
-49
lines changed

4 files changed

+48
-49
lines changed

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

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ public RubyNode visitCaseNode(CaseParseNode node) {
853853
// Evaluate the case expression and store it in a local
854854

855855
final String tempName = environment.allocateLocalTemp("case");
856-
final ReadLocalNode readTemp = environment.findLocalVarNode(tempName, source, sourceSection);
856+
final ReadLocalNode readTemp = environment.findLocalVarNode(tempName, sourceSection);
857857
final RubyNode assignTemp = readTemp.makeWriteNode(node.getCaseNode().accept(this));
858858

859859
/*
@@ -1218,7 +1218,7 @@ private RubyNode translateInterpolatedString(SourceIndexLength sourceSection, Pa
12181218
@Override
12191219
public RubyNode visitDVarNode(DVarParseNode node) {
12201220
final String name = node.getName();
1221-
RubyNode readNode = environment.findLocalVarNode(name, source, node.getPosition());
1221+
RubyNode readNode = environment.findLocalVarNode(name, node.getPosition());
12221222

12231223
if (readNode == null) {
12241224
// If we haven't seen this dvar before it's possible that it's a block local variable
@@ -1237,7 +1237,7 @@ public RubyNode visitDVarNode(DVarParseNode node) {
12371237
// the variable should be declared in a parent frame descriptor. This is so the search can determine
12381238
// whether to return a ReadLocalVariableNode or a ReadDeclarationVariableNode and potentially record the
12391239
// fact that a declaration frame is needed.
1240-
readNode = environment.findLocalVarNode(name, source, node.getPosition());
1240+
readNode = environment.findLocalVarNode(name, node.getPosition());
12411241
}
12421242

12431243
return addNewlineIfNeeded(node, readNode);
@@ -1795,7 +1795,7 @@ public RubyNode visitLocalAsgnNode(LocalAsgnParseNode node) {
17951795
environment.declareVar(name);
17961796
}
17971797

1798-
ReadLocalNode lhs = environment.findLocalVarNode(name, source, sourceSection);
1798+
ReadLocalNode lhs = environment.findLocalVarNode(name, sourceSection);
17991799

18001800
if (lhs == null) {
18011801
TranslatorEnvironment environmentToDeclareIn = environment;
@@ -1804,7 +1804,7 @@ public RubyNode visitLocalAsgnNode(LocalAsgnParseNode node) {
18041804
}
18051805
environmentToDeclareIn.declareVar(name);
18061806

1807-
lhs = environment.findLocalVarNode(name, source, sourceSection);
1807+
lhs = environment.findLocalVarNode(name, sourceSection);
18081808

18091809
if (lhs == null) {
18101810
throw new RuntimeException("shouldn't be here");
@@ -1831,7 +1831,7 @@ public RubyNode visitLocalVarNode(LocalVarParseNode node) {
18311831

18321832
final String name = node.getName();
18331833

1834-
RubyNode readNode = environment.findLocalVarNode(name, source, sourceSection);
1834+
RubyNode readNode = environment.findLocalVarNode(name, sourceSection);
18351835

18361836
if (readNode == null) {
18371837
/*
@@ -1846,7 +1846,7 @@ def destructure4r((*c,d))
18461846
*/
18471847

18481848
environment.declareVar(name);
1849-
readNode = environment.findLocalVarNode(name, source, sourceSection);
1849+
readNode = environment.findLocalVarNode(name, sourceSection);
18501850
}
18511851

18521852
return addNewlineIfNeeded(node, readNode);
@@ -1897,7 +1897,7 @@ public RubyNode visitMatch2Node(Match2ParseNode node) {
18971897
setters[n] = match2NonNilSetter(node, name, tempVar);
18981898
}
18991899
final RubyNode readNode = ReadGlobalVariableNodeGen.create("$~");
1900-
ReadLocalNode tempVarReadNode = environment.findLocalVarNode(tempVar, source, node.getPosition());
1900+
ReadLocalNode tempVarReadNode = environment.findLocalVarNode(tempVar, node.getPosition());
19011901
RubyNode readMatchNode = tempVarReadNode.makeWriteNode(readNode);
19021902
ret = new ReadMatchReferenceNodes.SetNamedVariablesMatchNode(ret, readMatchNode, setters, nilSetters);
19031903
}
@@ -1907,12 +1907,12 @@ public RubyNode visitMatch2Node(Match2ParseNode node) {
19071907
}
19081908

19091909
private RubyNode match2NilSetter(ParseNode node, String name) {
1910-
return environment.findLocalVarNode(name, source, node.getPosition()).makeWriteNode(new NilLiteralNode(true));
1910+
return environment.findLocalVarNode(name, node.getPosition()).makeWriteNode(new NilLiteralNode(true));
19111911
}
19121912

19131913
private RubyNode match2NonNilSetter(ParseNode node, String name, String tempVar) {
1914-
ReadLocalNode varNode = environment.findLocalVarNode(name, source, node.getPosition());
1915-
ReadLocalNode tempVarNode = environment.findLocalVarNode(tempVar, source, node.getPosition());
1914+
ReadLocalNode varNode = environment.findLocalVarNode(name, node.getPosition());
1915+
ReadLocalNode tempVarNode = environment.findLocalVarNode(tempVar, node.getPosition());
19161916
ObjectLiteralNode symbolNode = new ObjectLiteralNode(context.getSymbolTable().getSymbol(name));
19171917
GetIndexNode getIndexNode = GetIndexNode.create(tempVarNode, symbolNode, new ObjectLiteralNode(NotProvided.INSTANCE));
19181918
return varNode.makeWriteNode(getIndexNode);
@@ -1996,7 +1996,7 @@ public RubyNode visitMultipleAsgnNode(MultipleAsgnParseNode node) {
19961996

19971997
for (int n = 0; n < assignedValuesCount; n++) {
19981998
final String tempName = environment.allocateLocalTemp("multi");
1999-
final ReadLocalNode readTemp = environment.findLocalVarNode(tempName, source, sourceSection);
1999+
final ReadLocalNode readTemp = environment.findLocalVarNode(tempName, sourceSection);
20002000
final RubyNode assignTemp = readTemp.makeWriteNode(rhsArrayLiteral.stealNode(n));
20012001
final RubyNode assignFinalValue = translateDummyAssignment(preArray.get(n), NodeUtil.cloneNode(readTemp));
20022002

@@ -2041,7 +2041,7 @@ public RubyNode visitMultipleAsgnNode(MultipleAsgnParseNode node) {
20412041
*/
20422042

20432043
final String tempRHSName = environment.allocateLocalTemp("rhs");
2044-
final RubyNode writeTempRHS = environment.findLocalVarNode(tempRHSName, source, sourceSection).makeWriteNode(rhsTranslated);
2044+
final RubyNode writeTempRHS = environment.findLocalVarNode(tempRHSName, sourceSection).makeWriteNode(rhsTranslated);
20452045
sequence.add(writeTempRHS);
20462046

20472047
/*
@@ -2055,10 +2055,10 @@ public RubyNode visitMultipleAsgnNode(MultipleAsgnParseNode node) {
20552055
* the temp.
20562056
*/
20572057

2058-
final RubyNode splatCastNode = SplatCastNodeGen.create(translatingNextExpression ? SplatCastNode.NilBehavior.EMPTY_ARRAY : SplatCastNode.NilBehavior.ARRAY_WITH_NIL, true, environment.findLocalVarNode(tempRHSName, source, sourceSection));
2058+
final RubyNode splatCastNode = SplatCastNodeGen.create(translatingNextExpression ? SplatCastNode.NilBehavior.EMPTY_ARRAY : SplatCastNode.NilBehavior.ARRAY_WITH_NIL, true, environment.findLocalVarNode(tempRHSName, sourceSection));
20592059
splatCastNode.unsafeSetSourceSection(sourceSection);
20602060

2061-
final RubyNode writeTemp = environment.findLocalVarNode(tempName, source, sourceSection).makeWriteNode(splatCastNode);
2061+
final RubyNode writeTemp = environment.findLocalVarNode(tempName, sourceSection).makeWriteNode(splatCastNode);
20622062

20632063
sequence.add(writeTemp);
20642064

@@ -2067,13 +2067,13 @@ public RubyNode visitMultipleAsgnNode(MultipleAsgnParseNode node) {
20672067
*/
20682068

20692069
for (int n = 0; n < preArray.size(); n++) {
2070-
final RubyNode assignedValue = PrimitiveArrayNodeFactory.read(environment.findLocalVarNode(tempName, source, sourceSection), n);
2070+
final RubyNode assignedValue = PrimitiveArrayNodeFactory.read(environment.findLocalVarNode(tempName, sourceSection), n);
20712071

20722072
sequence.add(translateDummyAssignment(preArray.get(n), assignedValue));
20732073
}
20742074

20752075
if (node.getRest() != null) {
2076-
RubyNode assignedValue = ArrayGetTailNodeGen.create(preArray.size(), environment.findLocalVarNode(tempName, source, sourceSection));
2076+
RubyNode assignedValue = ArrayGetTailNodeGen.create(preArray.size(), environment.findLocalVarNode(tempName, sourceSection));
20772077

20782078
if (postArray != null) {
20792079
assignedValue = ArrayDropTailNodeGen.create(postArray.size(), assignedValue);
@@ -2086,7 +2086,7 @@ public RubyNode visitMultipleAsgnNode(MultipleAsgnParseNode node) {
20862086
final List<RubyNode> smallerSequence = new ArrayList<>();
20872087

20882088
for (int n = 0; n < postArray.size(); n++) {
2089-
final RubyNode assignedValue = PrimitiveArrayNodeFactory.read(environment.findLocalVarNode(tempName, source, sourceSection), node.getPreCount() + n);
2089+
final RubyNode assignedValue = PrimitiveArrayNodeFactory.read(environment.findLocalVarNode(tempName, sourceSection), node.getPreCount() + n);
20902090
smallerSequence.add(translateDummyAssignment(postArray.get(n), assignedValue));
20912091
}
20922092

@@ -2095,7 +2095,7 @@ public RubyNode visitMultipleAsgnNode(MultipleAsgnParseNode node) {
20952095
final List<RubyNode> atLeastAsLargeSequence = new ArrayList<>();
20962096

20972097
for (int n = 0; n < postArray.size(); n++) {
2098-
final RubyNode assignedValue = PrimitiveArrayNodeFactory.read(environment.findLocalVarNode(tempName, source, sourceSection), -(postArray.size() - n));
2098+
final RubyNode assignedValue = PrimitiveArrayNodeFactory.read(environment.findLocalVarNode(tempName, sourceSection), -(postArray.size() - n));
20992099

21002100
atLeastAsLargeSequence.add(translateDummyAssignment(postArray.get(n), assignedValue));
21012101
}
@@ -2104,14 +2104,14 @@ public RubyNode visitMultipleAsgnNode(MultipleAsgnParseNode node) {
21042104

21052105
final RubyNode assignPost =
21062106
new IfElseNode(
2107-
new ArrayIsAtLeastAsLargeAsNode(node.getPreCount() + node.getPostCount(), environment.findLocalVarNode(tempName, source, sourceSection)),
2107+
new ArrayIsAtLeastAsLargeAsNode(node.getPreCount() + node.getPostCount(), environment.findLocalVarNode(tempName, sourceSection)),
21082108
atLeastAsLarge,
21092109
smaller);
21102110

21112111
sequence.add(assignPost);
21122112
}
21132113

2114-
result = new ElidableResultNode(sequence(sourceSection, sequence), environment.findLocalVarNode(tempRHSName, source, sourceSection));
2114+
result = new ElidableResultNode(sequence(sourceSection, sequence), environment.findLocalVarNode(tempRHSName, sourceSection));
21152115
} else if (node.getPre() == null
21162116
&& node.getPost() == null
21172117
&& node.getRest() instanceof StarParseNode) {
@@ -2145,27 +2145,27 @@ public RubyNode visitMultipleAsgnNode(MultipleAsgnParseNode node) {
21452145
}
21462146

21472147
final String tempRHSName = environment.allocateLocalTemp("rhs");
2148-
final RubyNode writeTempRHS = environment.findLocalVarNode(tempRHSName, source, sourceSection).makeWriteNode(rhsTranslated);
2148+
final RubyNode writeTempRHS = environment.findLocalVarNode(tempRHSName, sourceSection).makeWriteNode(rhsTranslated);
21492149
sequence.add(writeTempRHS);
21502150

21512151
final SplatCastNode rhsSplatCast = SplatCastNodeGen.create(
21522152
nilBehavior,
2153-
true, environment.findLocalVarNode(tempRHSName, source, sourceSection));
2153+
true, environment.findLocalVarNode(tempRHSName, sourceSection));
21542154

21552155
rhsSplatCast.unsafeSetSourceSection(sourceSection);
21562156

21572157
final String tempRHSSplattedName = environment.allocateLocalTemp("rhs");
2158-
final RubyNode writeTempSplattedRHS = environment.findLocalVarNode(tempRHSSplattedName, source, sourceSection).makeWriteNode(rhsSplatCast);
2158+
final RubyNode writeTempSplattedRHS = environment.findLocalVarNode(tempRHSSplattedName, sourceSection).makeWriteNode(rhsSplatCast);
21592159
sequence.add(writeTempSplattedRHS);
21602160

2161-
sequence.add(translateDummyAssignment(node.getRest(), environment.findLocalVarNode(tempRHSSplattedName, source, sourceSection)));
2161+
sequence.add(translateDummyAssignment(node.getRest(), environment.findLocalVarNode(tempRHSSplattedName, sourceSection)));
21622162

21632163
final RubyNode assignmentResult;
21642164

21652165
if (nilBehavior == SplatCastNode.NilBehavior.CONVERT) {
2166-
assignmentResult = environment.findLocalVarNode(tempRHSSplattedName, source, sourceSection);
2166+
assignmentResult = environment.findLocalVarNode(tempRHSSplattedName, sourceSection);
21672167
} else {
2168-
assignmentResult = environment.findLocalVarNode(tempRHSName, source, sourceSection);
2168+
assignmentResult = environment.findLocalVarNode(tempRHSName, sourceSection);
21692169
}
21702170

21712171
result = new ElidableResultNode(sequence(sourceSection, sequence), assignmentResult);
@@ -2194,7 +2194,7 @@ public RubyNode visitMultipleAsgnNode(MultipleAsgnParseNode node) {
21942194
final List<RubyNode> sequence = new ArrayList<>();
21952195

21962196
final String tempRHSName = environment.allocateLocalTemp("rhs");
2197-
final RubyNode writeTempRHS = environment.findLocalVarNode(tempRHSName, source, sourceSection).makeWriteNode(rhsTranslated);
2197+
final RubyNode writeTempRHS = environment.findLocalVarNode(tempRHSName, sourceSection).makeWriteNode(rhsTranslated);
21982198
sequence.add(writeTempRHS);
21992199

22002200
/*
@@ -2209,10 +2209,10 @@ public RubyNode visitMultipleAsgnNode(MultipleAsgnParseNode node) {
22092209
*/
22102210

22112211

2212-
final RubyNode splatCastNode = SplatCastNodeGen.create(translatingNextExpression ? SplatCastNode.NilBehavior.EMPTY_ARRAY : SplatCastNode.NilBehavior.ARRAY_WITH_NIL, false, environment.findLocalVarNode(tempRHSName, source, sourceSection));
2212+
final RubyNode splatCastNode = SplatCastNodeGen.create(translatingNextExpression ? SplatCastNode.NilBehavior.EMPTY_ARRAY : SplatCastNode.NilBehavior.ARRAY_WITH_NIL, false, environment.findLocalVarNode(tempRHSName, sourceSection));
22132213
splatCastNode.unsafeSetSourceSection(sourceSection);
22142214

2215-
final RubyNode writeTemp = environment.findLocalVarNode(tempName, source, sourceSection).makeWriteNode(splatCastNode);
2215+
final RubyNode writeTemp = environment.findLocalVarNode(tempName, sourceSection).makeWriteNode(splatCastNode);
22162216

22172217
sequence.add(writeTemp);
22182218

@@ -2221,15 +2221,15 @@ public RubyNode visitMultipleAsgnNode(MultipleAsgnParseNode node) {
22212221
*/
22222222

22232223
if (node.getRest() != null) {
2224-
final ArrayDropTailNode assignedValue = ArrayDropTailNodeGen.create(postArray.size(), environment.findLocalVarNode(tempName, source, sourceSection));
2224+
final ArrayDropTailNode assignedValue = ArrayDropTailNodeGen.create(postArray.size(), environment.findLocalVarNode(tempName, sourceSection));
22252225

22262226
sequence.add(translateDummyAssignment(node.getRest(), assignedValue));
22272227
}
22282228

22292229
final List<RubyNode> smallerSequence = new ArrayList<>();
22302230

22312231
for (int n = 0; n < postArray.size(); n++) {
2232-
final RubyNode assignedValue = PrimitiveArrayNodeFactory.read(environment.findLocalVarNode(tempName, source, sourceSection), node.getPreCount() + n);
2232+
final RubyNode assignedValue = PrimitiveArrayNodeFactory.read(environment.findLocalVarNode(tempName, sourceSection), node.getPreCount() + n);
22332233
smallerSequence.add(translateDummyAssignment(postArray.get(n), assignedValue));
22342234
}
22352235

@@ -2238,7 +2238,7 @@ public RubyNode visitMultipleAsgnNode(MultipleAsgnParseNode node) {
22382238
final List<RubyNode> atLeastAsLargeSequence = new ArrayList<>();
22392239

22402240
for (int n = 0; n < postArray.size(); n++) {
2241-
final RubyNode assignedValue = PrimitiveArrayNodeFactory.read(environment.findLocalVarNode(tempName, source, sourceSection), -(postArray.size() - n));
2241+
final RubyNode assignedValue = PrimitiveArrayNodeFactory.read(environment.findLocalVarNode(tempName, sourceSection), -(postArray.size() - n));
22422242

22432243
atLeastAsLargeSequence.add(translateDummyAssignment(postArray.get(n), assignedValue));
22442244
}
@@ -2247,13 +2247,13 @@ public RubyNode visitMultipleAsgnNode(MultipleAsgnParseNode node) {
22472247

22482248
final RubyNode assignPost =
22492249
new IfElseNode(
2250-
new ArrayIsAtLeastAsLargeAsNode(node.getPreCount() + node.getPostCount(), environment.findLocalVarNode(tempName, source, sourceSection)),
2250+
new ArrayIsAtLeastAsLargeAsNode(node.getPreCount() + node.getPostCount(), environment.findLocalVarNode(tempName, sourceSection)),
22512251
atLeastAsLarge,
22522252
smaller);
22532253

22542254
sequence.add(assignPost);
22552255

2256-
result = new ElidableResultNode(sequence(sourceSection, sequence), environment.findLocalVarNode(tempRHSName, source, sourceSection));
2256+
result = new ElidableResultNode(sequence(sourceSection, sequence), environment.findLocalVarNode(tempRHSName, sourceSection));
22572257
} else {
22582258
throw new UnsupportedOperationException();
22592259
}
@@ -2427,7 +2427,7 @@ public RubyNode visitOpAsgnNode(OpAsgnParseNode node) {
24272427
final SourceIndexLength sourceSection = pos;
24282428

24292429
if (node.isLazy()) {
2430-
ReadLocalNode readLocal = environment.findLocalVarNode(temp, source, sourceSection);
2430+
ReadLocalNode readLocal = environment.findLocalVarNode(temp, sourceSection);
24312431
body = new IfNode(
24322432
new NotNode(new IsNilNode(readLocal)),
24332433
body);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -522,10 +522,10 @@ public RubyNode visitMultipleAsgnNode(MultipleAsgnParseNode node) {
522522
final String name = ((INameNode) node.getRest()).getName();
523523

524524
if (node.getPreCount() == 0 && node.getPostCount() == 0) {
525-
nilSequence.add(methodBodyTranslator.getEnvironment().findOrAddLocalVarNodeDangerous(name, source, sourceSection)
525+
nilSequence.add(methodBodyTranslator.getEnvironment().findOrAddLocalVarNodeDangerous(name, sourceSection)
526526
.makeWriteNode(ArrayLiteralNode.create(new RubyNode[] { new NilLiteralNode(true) })));
527527
} else {
528-
nilSequence.add(methodBodyTranslator.getEnvironment().findOrAddLocalVarNodeDangerous(name, source, sourceSection)
528+
nilSequence.add(methodBodyTranslator.getEnvironment().findOrAddLocalVarNodeDangerous(name, sourceSection)
529529
.makeWriteNode(ArrayLiteralNode.create(null)));
530530
}
531531
} else if (node.getRest() instanceof StarParseNode) {
@@ -542,7 +542,7 @@ public RubyNode visitMultipleAsgnNode(MultipleAsgnParseNode node) {
542542
}
543543

544544
for (String parameterToClear : parametersToClearCollector.getParameters()) {
545-
nilSequence.add(methodBodyTranslator.getEnvironment().findOrAddLocalVarNodeDangerous(parameterToClear, source, sourceSection).makeWriteNode(nilNode(sourceSection)));
545+
nilSequence.add(methodBodyTranslator.getEnvironment().findOrAddLocalVarNodeDangerous(parameterToClear, sourceSection).makeWriteNode(nilNode(sourceSection)));
546546
}
547547

548548
if (node.getPre() != null) {

0 commit comments

Comments
 (0)