mirror of
https://github.com/aNNiMON/Own-Programming-Language-Tutorial.git
synced 2024-09-20 08:44:20 +03:00
Обход TuplePattern
This commit is contained in:
parent
4ac0943805
commit
839f571b2c
@ -266,6 +266,28 @@ public abstract class OptimizationVisitor<T> implements ResultVisitor<Node, T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pattern instanceof MatchExpression.TuplePattern) {
|
||||||
|
final MatchExpression.TuplePattern tuple = (MatchExpression.TuplePattern) pattern;
|
||||||
|
final List<Expression> newValues = new ArrayList<>(tuple.values.size());
|
||||||
|
boolean valuesChanged = false;
|
||||||
|
for (Expression value : tuple.values) {
|
||||||
|
final Node node = value.accept(this, t);
|
||||||
|
if (node != value) {
|
||||||
|
valuesChanged = true;
|
||||||
|
value = (Expression) node;
|
||||||
|
}
|
||||||
|
newValues.add(value);
|
||||||
|
}
|
||||||
|
if (valuesChanged) {
|
||||||
|
changed = true;
|
||||||
|
final Expression optCondition = pattern.optCondition;
|
||||||
|
final Statement result = pattern.result;
|
||||||
|
pattern = new MatchExpression.TuplePattern(newValues);
|
||||||
|
pattern.optCondition = optCondition;
|
||||||
|
pattern.result = result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final Node patternResult = pattern.result.accept(this, t);
|
final Node patternResult = pattern.result.accept(this, t);
|
||||||
if (patternResult != pattern.result) {
|
if (patternResult != pattern.result) {
|
||||||
changed = true;
|
changed = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user