Skip to content

Commit

Permalink
Remove DataFlowInfo.CompositionOperator
Browse files Browse the repository at this point in the history
It was used only in one place, which wouldn't suffer without it
  • Loading branch information
udalov committed Nov 16, 2012
1 parent 4ec95ff commit ed02c6c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 29 deletions.
Expand Up @@ -26,30 +26,7 @@

import static org.jetbrains.jet.lang.resolve.calls.autocasts.Nullability.NOT_NULL;

/**
* @author abreslav
*/

public class DataFlowInfo {

public static abstract class CompositionOperator {
public abstract DataFlowInfo compose(DataFlowInfo a, DataFlowInfo b);
}

public static final CompositionOperator AND = new CompositionOperator() {
@Override
public DataFlowInfo compose(DataFlowInfo a, DataFlowInfo b) {
return a.and(b);
}
};

public static final CompositionOperator OR = new CompositionOperator() {
@Override
public DataFlowInfo compose(DataFlowInfo a, DataFlowInfo b) {
return a.or(b);
}
};

public static DataFlowInfo EMPTY = new DataFlowInfo(
ImmutableMap.<DataFlowValue, Nullability>of(),
Multimaps.newListMultimap(Collections.<DataFlowValue, Collection<JetType>>emptyMap(), CommonSuppliers.<JetType>getArrayListSupplier()));
Expand Down
Expand Up @@ -59,19 +59,17 @@ public void visitIsExpression(JetIsExpression expression) {
public void visitBinaryExpression(JetBinaryExpression expression) {
IElementType operationToken = expression.getOperationToken();
if (OperatorConventions.BOOLEAN_OPERATIONS.containsKey(operationToken)) {

DataFlowInfo dataFlowInfo = extractDataFlowInfoFromCondition(expression.getLeft(), conditionValue, context);
JetExpression expressionRight = expression.getRight();
if (expressionRight != null) {
DataFlowInfo rightInfo = extractDataFlowInfoFromCondition(expressionRight, conditionValue, context);
DataFlowInfo.CompositionOperator operator;
if (operationToken == JetTokens.ANDAND) {
operator = conditionValue ? DataFlowInfo.AND : DataFlowInfo.OR;
boolean and = operationToken == JetTokens.ANDAND;
if (and == conditionValue) { // this means: and && conditionValue || !and && !conditionValue
dataFlowInfo = dataFlowInfo.and(rightInfo);
}
else {
operator = conditionValue ? DataFlowInfo.OR : DataFlowInfo.AND;
dataFlowInfo = dataFlowInfo.or(rightInfo);
}
dataFlowInfo = operator.compose(dataFlowInfo, rightInfo);
}
result.set(dataFlowInfo);
}
Expand Down

0 comments on commit ed02c6c

Please sign in to comment.