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.JetSemanticServices;
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.*;
|
||||||
import org.jetbrains.jet.lang.types.BindingTrace;
|
import org.jetbrains.jet.lang.types.BindingTrace;
|
||||||
|
import org.jetbrains.jet.lang.types.JetTypeInferrer;
|
||||||
import org.jetbrains.jet.lexer.JetTokens;
|
import org.jetbrains.jet.lexer.JetTokens;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -179,6 +180,19 @@ public class JetControlFlowProcessor {
|
|||||||
builder.unsupported(expression);
|
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 {
|
else {
|
||||||
value(expression.getLeft(), false);
|
value(expression.getLeft(), false);
|
||||||
if (right != null) {
|
if (right != null) {
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ public class WriteValueInstruction extends InstructionWithNext {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
if (lValue instanceof JetNamedDeclaration) {
|
if (lValue instanceof JetNamedDeclaration) {
|
||||||
JetNamedDeclaration value = (JetNamedDeclaration) lValue;
|
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> 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 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 {
|
static {
|
||||||
assignmentOperationNames.put(JetTokens.MULTEQ, "timesAssign");
|
assignmentOperationNames.put(JetTokens.MULTEQ, "timesAssign");
|
||||||
assignmentOperationNames.put(JetTokens.DIVEQ, "divAssign");
|
assignmentOperationNames.put(JetTokens.DIVEQ, "divAssign");
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
fun assignments() : Unit {
|
fun assignments() : Unit {
|
||||||
var x = 1
|
var x = 1
|
||||||
x = 2
|
x = 2
|
||||||
|
x += 2
|
||||||
|
|
||||||
x = if (true) 1 else 2
|
x = if (true) 1 else 2
|
||||||
|
|
||||||
@@ -12,9 +13,12 @@ fun assignments() : Unit {
|
|||||||
l0:
|
l0:
|
||||||
<START>
|
<START>
|
||||||
r(1)
|
r(1)
|
||||||
x <-
|
w(x)
|
||||||
r(2)
|
r(2)
|
||||||
x <-
|
w(x)
|
||||||
|
r(x)
|
||||||
|
r(2)
|
||||||
|
w(x)
|
||||||
r(true)
|
r(true)
|
||||||
jf(l2)
|
jf(l2)
|
||||||
r(1)
|
r(1)
|
||||||
@@ -22,17 +26,17 @@ l0:
|
|||||||
l2:
|
l2:
|
||||||
r(2)
|
r(2)
|
||||||
l3:
|
l3:
|
||||||
x <-
|
w(x)
|
||||||
r(true)
|
r(true)
|
||||||
jf(l4)
|
jf(l4)
|
||||||
r(false)
|
r(false)
|
||||||
l4:
|
l4:
|
||||||
y <-
|
w(y)
|
||||||
r(false)
|
r(false)
|
||||||
jf(l5)
|
jf(l5)
|
||||||
r(true)
|
r(true)
|
||||||
l5:
|
l5:
|
||||||
z <-
|
w(z)
|
||||||
l1:
|
l1:
|
||||||
<END>
|
<END>
|
||||||
=====================
|
=====================
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
fun assignments() : Unit {
|
fun assignments() : Unit {
|
||||||
var x = 1
|
var x = 1
|
||||||
x = 2
|
x = 2
|
||||||
|
x += 2
|
||||||
|
|
||||||
x = if (true) 1 else 2
|
x = if (true) 1 else 2
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user