Pseudocode: Generate read instructions on call expression (instead of
callee)
This commit is contained in:
@@ -1499,12 +1499,12 @@ public class JetControlFlowProcessor {
|
|||||||
if (resultingDescriptor instanceof VariableDescriptor) {
|
if (resultingDescriptor instanceof VariableDescriptor) {
|
||||||
// If a callee of the call is just a variable (without 'invoke'), 'read variable' is generated.
|
// If a callee of the call is just a variable (without 'invoke'), 'read variable' is generated.
|
||||||
// todo : process arguments for such a case (KT-5387)
|
// todo : process arguments for such a case (KT-5387)
|
||||||
JetExpression calleeExpression = PsiUtilPackage.getCalleeExpressionIfAny(callElement);
|
JetExpression callExpression = callElement instanceof JetExpression ? (JetExpression) callElement : null;
|
||||||
assert calleeExpression != null
|
assert callExpression != null
|
||||||
: "Variable-based call without callee expression: " + callElement.getText();
|
: "Variable-based call without callee expression: " + callElement.getText();
|
||||||
assert parameterValues.isEmpty()
|
assert parameterValues.isEmpty()
|
||||||
: "Variable-based call with non-empty argument list: " + callElement.getText();
|
: "Variable-based call with non-empty argument list: " + callElement.getText();
|
||||||
return builder.readVariable(calleeExpression, resolvedCall, receivers);
|
return builder.readVariable(callExpression, resolvedCall, receivers);
|
||||||
}
|
}
|
||||||
mark(resolvedCall.getCall().getCallElement());
|
mark(resolvedCall.getCall().getCallElement());
|
||||||
return builder.call(callElement, resolvedCall, receivers, parameterValues);
|
return builder.call(callElement, resolvedCall, receivers, parameterValues);
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
== foo ==
|
||||||
|
fun foo(i: Int) {
|
||||||
|
i()
|
||||||
|
}
|
||||||
|
---------------------
|
||||||
|
L0:
|
||||||
|
1 <START>
|
||||||
|
v(i: Int)
|
||||||
|
magic[FAKE_INITIALIZER](i: Int) -> <v0>
|
||||||
|
w(i|<v0>)
|
||||||
|
2 mark({ i() })
|
||||||
|
r(i) -> <v1>
|
||||||
|
L1:
|
||||||
|
1 <END> NEXT:[<SINK>]
|
||||||
|
error:
|
||||||
|
<ERROR> PREV:[]
|
||||||
|
sink:
|
||||||
|
<SINK> PREV:[<ERROR>, <END>]
|
||||||
|
=====================
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun foo(i: Int) {
|
||||||
|
i()
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
== foo ==
|
||||||
|
fun foo(i: Int) {
|
||||||
|
i()
|
||||||
|
}
|
||||||
|
---------------------
|
||||||
|
<v0>: Int NEW: magic[FAKE_INITIALIZER](i: Int) -> <v0>
|
||||||
|
i <v1>: * NEW: r(i) -> <v1>
|
||||||
|
i() !<v2>: *
|
||||||
|
{ i() } !<v2>: * COPY
|
||||||
|
=====================
|
||||||
@@ -368,7 +368,7 @@ public class ControlFlowTestGenerated extends AbstractControlFlowTest {
|
|||||||
public void testAssignments() throws Exception {
|
public void testAssignments() throws Exception {
|
||||||
doTest("compiler/testData/cfg/expressions/Assignments.kt");
|
doTest("compiler/testData/cfg/expressions/Assignments.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("callableReferences.kt")
|
@TestMetadata("callableReferences.kt")
|
||||||
public void testCallableReferences() throws Exception {
|
public void testCallableReferences() throws Exception {
|
||||||
doTest("compiler/testData/cfg/expressions/callableReferences.kt");
|
doTest("compiler/testData/cfg/expressions/callableReferences.kt");
|
||||||
@@ -394,6 +394,11 @@ public class ControlFlowTestGenerated extends AbstractControlFlowTest {
|
|||||||
doTest("compiler/testData/cfg/expressions/incdec.kt");
|
doTest("compiler/testData/cfg/expressions/incdec.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("invalidVariableCall.kt")
|
||||||
|
public void testInvalidVariableCall() throws Exception {
|
||||||
|
doTest("compiler/testData/cfg/expressions/invalidVariableCall.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("LazyBooleans.kt")
|
@TestMetadata("LazyBooleans.kt")
|
||||||
public void testLazyBooleans() throws Exception {
|
public void testLazyBooleans() throws Exception {
|
||||||
doTest("compiler/testData/cfg/expressions/LazyBooleans.kt");
|
doTest("compiler/testData/cfg/expressions/LazyBooleans.kt");
|
||||||
|
|||||||
@@ -358,9 +358,7 @@ public class PseudoValueTestGenerated extends AbstractPseudoValueTest {
|
|||||||
@TestMetadata("compiler/testData/cfg/expressions")
|
@TestMetadata("compiler/testData/cfg/expressions")
|
||||||
public static class Expressions extends AbstractPseudoValueTest {
|
public static class Expressions extends AbstractPseudoValueTest {
|
||||||
public void testAllFilesPresentInExpressions() throws Exception {
|
public void testAllFilesPresentInExpressions() throws Exception {
|
||||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage",
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/cfg/expressions"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||||
new File("compiler/testData/cfg/expressions"), Pattern.compile("^(.+)\\.kt$"),
|
|
||||||
true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("assignmentToThis.kt")
|
@TestMetadata("assignmentToThis.kt")
|
||||||
@@ -372,7 +370,7 @@ public class PseudoValueTestGenerated extends AbstractPseudoValueTest {
|
|||||||
public void testAssignments() throws Exception {
|
public void testAssignments() throws Exception {
|
||||||
doTest("compiler/testData/cfg/expressions/Assignments.kt");
|
doTest("compiler/testData/cfg/expressions/Assignments.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("callableReferences.kt")
|
@TestMetadata("callableReferences.kt")
|
||||||
public void testCallableReferences() throws Exception {
|
public void testCallableReferences() throws Exception {
|
||||||
doTest("compiler/testData/cfg/expressions/callableReferences.kt");
|
doTest("compiler/testData/cfg/expressions/callableReferences.kt");
|
||||||
@@ -398,6 +396,11 @@ public class PseudoValueTestGenerated extends AbstractPseudoValueTest {
|
|||||||
doTest("compiler/testData/cfg/expressions/incdec.kt");
|
doTest("compiler/testData/cfg/expressions/incdec.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("invalidVariableCall.kt")
|
||||||
|
public void testInvalidVariableCall() throws Exception {
|
||||||
|
doTest("compiler/testData/cfg/expressions/invalidVariableCall.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("LazyBooleans.kt")
|
@TestMetadata("LazyBooleans.kt")
|
||||||
public void testLazyBooleans() throws Exception {
|
public void testLazyBooleans() throws Exception {
|
||||||
doTest("compiler/testData/cfg/expressions/LazyBooleans.kt");
|
doTest("compiler/testData/cfg/expressions/LazyBooleans.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user