Skip to content

Commit

Permalink
Cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
eregon committed Apr 18, 2023
1 parent fcbbe3e commit 29f96f5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 17 deletions.
18 changes: 2 additions & 16 deletions src/main/java/org/truffleruby/parser/BodyTranslator.java
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,13 @@
import org.truffleruby.parser.ast.EvStrParseNode;
import org.truffleruby.parser.ast.FCallParseNode;
import org.truffleruby.parser.ast.FalseParseNode;
import org.truffleruby.parser.ast.FindPatternParseNode;
import org.truffleruby.parser.ast.FixnumParseNode;
import org.truffleruby.parser.ast.FlipParseNode;
import org.truffleruby.parser.ast.FloatParseNode;
import org.truffleruby.parser.ast.ForParseNode;
import org.truffleruby.parser.ast.GlobalAsgnParseNode;
import org.truffleruby.parser.ast.GlobalVarParseNode;
import org.truffleruby.parser.ast.HashParseNode;
import org.truffleruby.parser.ast.HashPatternParseNode;
import org.truffleruby.parser.ast.IArgumentNode;
import org.truffleruby.parser.ast.IfParseNode;
import org.truffleruby.parser.ast.InParseNode;
Expand Down Expand Up @@ -843,11 +841,9 @@ public RubyNode visitCaseInNode(CaseInParseNode node) {
currentNode, node.getCases(), environment, this);

// Evaluate the case expression and store it in a local

final RubyNode caseExprValue = node.getCaseNode().accept(this);
final int tempSlot = environment.declareLocalTemp("case in value");
final ReadLocalNode readTemp = environment.readNode(tempSlot, sourceSection);
final RubyNode assignTemp = readTemp.makeWriteNode(caseExprValue);
final RubyNode assignTemp = readTemp.makeWriteNode(node.getCaseNode().accept(this));

/* Build an if expression from the ins and else. Work backwards because the first if contains all the others in
* its else clause. */
Expand All @@ -856,7 +852,7 @@ public RubyNode visitCaseInNode(CaseInParseNode node) {
if (node.getElseNode() == null) {
elseNode = NoMatchingPatternNodeGen.create(readTemp);
} else {
elseNode = translateNodeOrNil(sourceSection, node.getElseNode());
elseNode = node.getElseNode().accept(this);
}

for (int n = node.getCases().size() - 1; n >= 0; n--) {
Expand Down Expand Up @@ -1492,11 +1488,6 @@ public RubyNode visitFalseNode(FalseParseNode node) {
return addNewlineIfNeeded(node, ret);
}

@Override
public RubyNode visitFindPatternNode(FindPatternParseNode node) {
throw CompilerDirectives.shouldNotReachHere("TODO");
}

@Override
public RubyNode visitFixnumNode(FixnumParseNode node) {
final SourceIndexLength sourceSection = node.getPosition();
Expand Down Expand Up @@ -1812,11 +1803,6 @@ public RubyNode visitHashNode(HashParseNode node) {
return addNewlineIfNeeded(node, ret);
}

@Override
public RubyNode visitHashPatternNode(HashPatternParseNode node) {
throw CompilerDirectives.shouldNotReachHere("TODO");
}

@Override
public RubyNode visitIfNode(IfParseNode node) {
final SourceIndexLength sourceSection = node.getPosition();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -608,5 +608,4 @@ protected RubyNode loadArray(SourceIndexLength sourceSection) {
return node;
}


}

0 comments on commit 29f96f5

Please sign in to comment.