Skip to content

Commit 63bcd37

Browse files
committed
Remove dead code
1 parent 42e9625 commit 63bcd37

File tree

1 file changed

+0
-117
lines changed

1 file changed

+0
-117
lines changed

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

Lines changed: 0 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@
219219
import org.truffleruby.parser.ast.NilImplicitParseNode;
220220
import org.truffleruby.parser.ast.NilParseNode;
221221
import org.truffleruby.parser.ast.NilRestArgParseNode;
222-
import org.truffleruby.parser.ast.NodeType;
223222
import org.truffleruby.parser.ast.NthRefParseNode;
224223
import org.truffleruby.parser.ast.OpAsgnAndParseNode;
225224
import org.truffleruby.parser.ast.OpAsgnConstDeclParseNode;
@@ -883,122 +882,6 @@ public RubyNode visitCaseInNode(CaseInParseNode node) {
883882
return addNewlineIfNeeded(node, ret);
884883
}
885884

886-
// probably remove this later.
887-
private RubyNode caseInPatternMatch(ParseNode patternNode, ParseNode expressionNode, RubyNode expressionValue,
888-
SourceIndexLength sourceSection) {
889-
final RubyCallNodeParameters deconstructCallParameters;
890-
final RubyCallNodeParameters matcherCallParameters;
891-
final RubyNode receiver;
892-
final RubyNode deconstructed;
893-
894-
switch (patternNode.getNodeType()) {
895-
case ARRAYNODE:
896-
// Pattern-match element-wise recursively if possible.
897-
final int size = ((ArrayParseNode) patternNode).size();
898-
if (expressionNode.getNodeType() == NodeType.ARRAYNODE &&
899-
((ArrayParseNode) expressionNode).size() == size) {
900-
final ParseNode[] patternElements = ((ArrayParseNode) patternNode).children();
901-
final ParseNode[] expressionElements = ((ArrayParseNode) expressionNode).children();
902-
903-
final RubyNode[] matches = new RubyNode[size];
904-
905-
// For each element of the case expression, evaluate and assign it, then run the pattern-matching
906-
// on the element
907-
for (int n = 0; n < size; n++) {
908-
final int tempSlot = environment.declareLocalTemp("caseElem" + n);
909-
final ReadLocalNode readTemp = environment.readNode(tempSlot, sourceSection);
910-
final RubyNode assignTemp = readTemp.makeWriteNode(expressionElements[n].accept(this));
911-
matches[n] = sequence(sourceSection, Arrays.asList(
912-
assignTemp,
913-
caseInPatternMatch(
914-
patternElements[n],
915-
expressionElements[n],
916-
readTemp,
917-
sourceSection)));
918-
}
919-
920-
// Incorporate the element-wise pattern-matching into the AST, with the longer right leg since
921-
// AndNode is visited left to right
922-
RubyNode match = matches[size - 1];
923-
for (int n = size - 2; n >= 0; n--) {
924-
match = new AndNode(matches[n], match);
925-
}
926-
return match;
927-
}
928-
929-
deconstructCallParameters = new RubyCallNodeParameters(
930-
expressionValue,
931-
"deconstruct",
932-
null,
933-
EmptyArgumentsDescriptor.INSTANCE,
934-
RubyNode.EMPTY_ARRAY,
935-
false,
936-
true);
937-
deconstructed = language.coreMethodAssumptions
938-
.createCallNode(deconstructCallParameters);
939-
940-
receiver = new TruffleInternalModuleLiteralNode();
941-
receiver.unsafeSetSourceSection(sourceSection);
942-
943-
matcherCallParameters = new RubyCallNodeParameters(
944-
receiver,
945-
"array_pattern_matches?",
946-
null,
947-
EmptyArgumentsDescriptor.INSTANCE,
948-
new RubyNode[]{ patternNode.accept(this), NodeUtil.cloneNode(deconstructed) },
949-
false,
950-
true);
951-
return language.coreMethodAssumptions
952-
.createCallNode(matcherCallParameters);
953-
case HASHNODE:
954-
deconstructCallParameters = new RubyCallNodeParameters(
955-
expressionValue,
956-
"deconstruct_keys",
957-
null,
958-
EmptyArgumentsDescriptor.INSTANCE,
959-
new RubyNode[]{ new NilLiteralNode(true) },
960-
false,
961-
true);
962-
deconstructed = language.coreMethodAssumptions
963-
.createCallNode(deconstructCallParameters);
964-
965-
receiver = new TruffleInternalModuleLiteralNode();
966-
receiver.unsafeSetSourceSection(sourceSection);
967-
968-
matcherCallParameters = new RubyCallNodeParameters(
969-
receiver,
970-
"hash_pattern_matches?",
971-
null,
972-
EmptyArgumentsDescriptor.INSTANCE,
973-
new RubyNode[]{ patternNode.accept(this), NodeUtil.cloneNode(deconstructed) },
974-
false,
975-
true);
976-
return language.coreMethodAssumptions
977-
.createCallNode(matcherCallParameters);
978-
case LOCALVARNODE:
979-
// Assigns the value of an existing variable pattern as the value of the expression.
980-
// May need to add a case with same/similar logic for new variables.
981-
final RubyNode assignmentNode = new LocalAsgnParseNode(
982-
patternNode.getPosition(),
983-
((LocalVarParseNode) patternNode).getName(),
984-
((LocalVarParseNode) patternNode).getDepth(),
985-
expressionNode).accept(this);
986-
return new OrNode(assignmentNode, new BooleanLiteralNode(true)); // TODO refactor to remove "|| true"
987-
default:
988-
matcherCallParameters = new RubyCallNodeParameters(
989-
patternNode.accept(this),
990-
"===",
991-
null,
992-
EmptyArgumentsDescriptor.INSTANCE,
993-
new RubyNode[]{ NodeUtil.cloneNode(expressionValue) },
994-
false,
995-
true);
996-
return language.coreMethodAssumptions
997-
.createCallNode(matcherCallParameters);
998-
}
999-
}
1000-
1001-
1002885
private RubyNode openModule(SourceIndexLength sourceSection, RubyNode defineOrGetNode, String moduleName,
1003886
ParseNode bodyNode, OpenModule type, boolean dynamicConstantLookup) {
1004887
final SourceSection fullSourceSection = sourceSection.toSourceSection(source);

0 commit comments

Comments
 (0)