CF/DF for '+='
This commit is contained in:
@@ -6,6 +6,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.JetSemanticServices;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.types.BindingTrace;
|
||||
import org.jetbrains.jet.lang.types.JetTypeInferrer;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
import java.util.*;
|
||||
@@ -179,6 +180,19 @@ public class JetControlFlowProcessor {
|
||||
builder.unsupported(expression);
|
||||
}
|
||||
}
|
||||
else if (JetTypeInferrer.assignmentOperationNames.containsKey(operationType)) {
|
||||
JetExpression left = expression.getLeft();
|
||||
value(left, false);
|
||||
if (right != null) {
|
||||
value(right, false);
|
||||
}
|
||||
if (left instanceof JetSimpleNameExpression) {
|
||||
builder.writeNode(expression, left);
|
||||
}
|
||||
else {
|
||||
builder.unsupported(expression);
|
||||
}
|
||||
}
|
||||
else {
|
||||
value(expression.getLeft(), false);
|
||||
if (right != null) {
|
||||
|
||||
@@ -25,8 +25,8 @@ public class WriteValueInstruction extends InstructionWithNext {
|
||||
public String toString() {
|
||||
if (lValue instanceof JetNamedDeclaration) {
|
||||
JetNamedDeclaration value = (JetNamedDeclaration) lValue;
|
||||
return value.getName() + " <- ";
|
||||
return "w(" + value.getName() + ")";
|
||||
}
|
||||
return lValue.getText() + " <-";
|
||||
return "w(" + lValue.getText() + ")";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class JetTypeInferrer {
|
||||
private static final Set<IElementType> equalsOperations = new HashSet<IElementType>(Arrays.asList(JetTokens.EQEQ, JetTokens.EXCLEQ));
|
||||
private static final Set<IElementType> inOperations = new HashSet<IElementType>(Arrays.asList(JetTokens.IN_KEYWORD, JetTokens.NOT_IN));
|
||||
|
||||
private static final Map<IElementType, String> assignmentOperationNames = new HashMap<IElementType, String>();
|
||||
public static final Map<IElementType, String> assignmentOperationNames = new HashMap<IElementType, String>();
|
||||
static {
|
||||
assignmentOperationNames.put(JetTokens.MULTEQ, "timesAssign");
|
||||
assignmentOperationNames.put(JetTokens.DIVEQ, "divAssign");
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
fun assignments() : Unit {
|
||||
var x = 1
|
||||
x = 2
|
||||
x += 2
|
||||
|
||||
x = if (true) 1 else 2
|
||||
|
||||
@@ -12,9 +13,12 @@ fun assignments() : Unit {
|
||||
l0:
|
||||
<START>
|
||||
r(1)
|
||||
x <-
|
||||
w(x)
|
||||
r(2)
|
||||
x <-
|
||||
w(x)
|
||||
r(x)
|
||||
r(2)
|
||||
w(x)
|
||||
r(true)
|
||||
jf(l2)
|
||||
r(1)
|
||||
@@ -22,17 +26,17 @@ l0:
|
||||
l2:
|
||||
r(2)
|
||||
l3:
|
||||
x <-
|
||||
w(x)
|
||||
r(true)
|
||||
jf(l4)
|
||||
r(false)
|
||||
l4:
|
||||
y <-
|
||||
w(y)
|
||||
r(false)
|
||||
jf(l5)
|
||||
r(true)
|
||||
l5:
|
||||
z <-
|
||||
w(z)
|
||||
l1:
|
||||
<END>
|
||||
=====================
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
fun assignments() : Unit {
|
||||
var x = 1
|
||||
x = 2
|
||||
x += 2
|
||||
|
||||
x = if (true) 1 else 2
|
||||
|
||||
|
||||
Reference in New Issue
Block a user