From a3a0edca5880ac31fbb1076b783ad4bf294940db Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Tue, 7 Oct 2014 18:26:58 +0400 Subject: [PATCH] Pseudocode: Drop CompilationErrorInstruction --- .../jet/lang/cfg/JetControlFlowBuilder.java | 2 - .../cfg/JetControlFlowBuilderAdapter.java | 5 --- .../jet/lang/cfg/JetControlFlowProcessor.java | 14 +++---- .../JetControlFlowInstructionsGenerator.java | 5 --- .../instructions/InstructionVisitor.kt | 4 -- .../InstructionVisitorWithResult.kt | 4 -- .../special/CompilationErrorInstruction.kt | 42 ------------------- .../bugs/varInitializationInIf.instructions | 6 +-- .../arrays/arrayIncUnresolved.instructions | 1 - .../arraySetPlusAssignUnresolved.instructions | 1 - .../arrays/arraySetUnresolved.instructions | 1 - .../functions/typeParameter.instructions | 3 +- .../chainedQualifiedExpression.instructions | 1 - .../expressions/unresolvedCall.instructions | 4 +- .../unresolvedProperty.instructions | 3 +- .../unusedExpressionSimpleName.instructions | 3 +- 16 files changed, 12 insertions(+), 87 deletions(-) delete mode 100644 compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/instructions/special/CompilationErrorInstruction.kt diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowBuilder.java b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowBuilder.java index 311fa83708c..32b0ed7eb4d 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowBuilder.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowBuilder.java @@ -157,8 +157,6 @@ public interface JetControlFlowBuilder { @NotNull List inputValues ); - void compilationError(@NotNull JetElement element, @NotNull String message); - void write( @NotNull JetElement assignment, @NotNull JetElement lValue, diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowBuilderAdapter.java b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowBuilderAdapter.java index 5f79f07564a..fe533019be0 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowBuilderAdapter.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowBuilderAdapter.java @@ -114,11 +114,6 @@ public abstract class JetControlFlowBuilderAdapter implements JetControlFlowBuil return getDelegateBuilder().predefinedOperation(expression, operation, inputValues); } - @Override - public void compilationError(@NotNull JetElement element, @NotNull String message) { - getDelegateBuilder().compilationError(element, message); - } - @Override @NotNull public Label createUnboundLabel() { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor.java b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor.java index 7aefc030a9d..3a0d4179e7b 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor.java @@ -457,7 +457,8 @@ public class JetControlFlowProcessor { ) { JetExpression left = JetPsiUtil.deparenthesize(lhs); if (left == null) { - builder.compilationError(lhs, "No lValue in assignment"); + List arguments = Collections.singletonList(rhsDeferredValue.invoke()); + builder.magic(parentExpression, parentExpression, arguments, defaultTypeMap(arguments), MagicKind.UNSUPPORTED_ELEMENT); return; } @@ -576,7 +577,7 @@ public class JetControlFlowProcessor { private void generateArrayAccess(JetArrayAccessExpression arrayAccessExpression, @Nullable ResolvedCall resolvedCall) { if (builder.getBoundValue(arrayAccessExpression) != null) return; mark(arrayAccessExpression); - if (!checkAndGenerateCall(arrayAccessExpression, resolvedCall)) { + if (!checkAndGenerateCall(resolvedCall)) { generateArrayAccessWithoutCall(arrayAccessExpression); } } @@ -1480,14 +1481,11 @@ public class JetControlFlowProcessor { private boolean generateCall(@Nullable JetElement callElement) { if (callElement == null) return false; - return checkAndGenerateCall(callElement, getResolvedCall(callElement, trace.getBindingContext())); + return checkAndGenerateCall(getResolvedCall(callElement, trace.getBindingContext())); } - private boolean checkAndGenerateCall(@NotNull JetElement callElement, @Nullable ResolvedCall resolvedCall) { - if (resolvedCall == null) { - builder.compilationError(callElement, "No resolved call"); - return false; - } + private boolean checkAndGenerateCall(@Nullable ResolvedCall resolvedCall) { + if (resolvedCall == null) return false; generateCall(resolvedCall); return true; } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/JetControlFlowInstructionsGenerator.java b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/JetControlFlowInstructionsGenerator.java index 3b3ef24a9b4..1c7dfeeb3c6 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/JetControlFlowInstructionsGenerator.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/JetControlFlowInstructionsGenerator.java @@ -530,11 +530,6 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd } } - @Override - public void compilationError(@NotNull JetElement element, @NotNull String message) { - add(new CompilationErrorInstruction(element, getCurrentScope(), message)); - } - @NotNull private ReadValueInstruction read( @NotNull JetExpression expression, diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/instructions/InstructionVisitor.kt b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/instructions/InstructionVisitor.kt index 3f1966200cf..5370144db57 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/instructions/InstructionVisitor.kt +++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/instructions/InstructionVisitor.kt @@ -105,10 +105,6 @@ public open class InstructionVisitor() { visitOperation(instruction) } - public open fun visitCompilationErrorInstruction(instruction: CompilationErrorInstruction) { - visitInstructionWithNext(instruction) - } - public open fun visitMarkInstruction(instruction: MarkInstruction) { visitInstructionWithNext(instruction) } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/instructions/InstructionVisitorWithResult.kt b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/instructions/InstructionVisitorWithResult.kt index 023cf6f85f8..a3706e09d0a 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/instructions/InstructionVisitorWithResult.kt +++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/instructions/InstructionVisitorWithResult.kt @@ -104,10 +104,6 @@ public abstract class InstructionVisitorWithResult() { return visitOperation(instruction) } - public open fun visitCompilationErrorInstruction(instruction: CompilationErrorInstruction): R { - return visitInstructionWithNext(instruction) - } - public open fun visitMarkInstruction(instruction: MarkInstruction): R { return visitInstructionWithNext(instruction) } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/instructions/special/CompilationErrorInstruction.kt b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/instructions/special/CompilationErrorInstruction.kt deleted file mode 100644 index 9ce457f5ae6..00000000000 --- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/instructions/special/CompilationErrorInstruction.kt +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2010-2014 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.jet.lang.cfg.pseudocode.instructions.special - -import org.jetbrains.jet.lang.psi.JetElement -import org.jetbrains.jet.lang.cfg.pseudocode.instructions.LexicalScope -import org.jetbrains.jet.lang.cfg.pseudocode.instructions.InstructionWithNext -import org.jetbrains.jet.lang.cfg.pseudocode.instructions.InstructionVisitor -import org.jetbrains.jet.lang.cfg.pseudocode.instructions.InstructionVisitorWithResult - -public class CompilationErrorInstruction( - element: JetElement, - lexicalScope: LexicalScope, - val message: String -) : InstructionWithNext(element, lexicalScope) { - - override fun accept(visitor: InstructionVisitor) { - visitor.visitCompilationErrorInstruction(this) - } - - override fun accept(visitor: InstructionVisitorWithResult): R { - return visitor.visitCompilationErrorInstruction(this) - } - - override fun createCopy() = CompilationErrorInstruction(element, lexicalScope, message) - - override fun toString() = "error(${render(element)}, $message)" -} \ No newline at end of file diff --git a/compiler/testData/cfg-variables/bugs/varInitializationInIf.instructions b/compiler/testData/cfg-variables/bugs/varInitializationInIf.instructions index ab95855399b..5f1f1e645fa 100644 --- a/compiler/testData/cfg-variables/bugs/varInitializationInIf.instructions +++ b/compiler/testData/cfg-variables/bugs/varInitializationInIf.instructions @@ -29,10 +29,8 @@ L2 [else branch]: r(true) -> USE: in: {b=WRITTEN_AFTER_READ} out: {b=WRITTEN_AFTER_READ} w(b|) INIT: in: {b=D} out: {b=ID} USE: in: {b=READ} out: {b=WRITTEN_AFTER_READ} L3 ['if' expression result]: - 2 merge(if (1 < 2) { b = false } else { b = true }|!, !) -> INIT: in: {b=ID} out: {b=ID} - error(use(b), No resolved call) USE: in: {b=READ} out: {b=READ} + 2 merge(if (1 < 2) { b = false } else { b = true }|!, !) -> INIT: in: {b=ID} out: {b=ID} USE: in: {b=READ} out: {b=READ} r(b) -> USE: in: {} out: {b=READ} - error(use, No resolved call) mark(use(b)) magic[UNRESOLVED_CALL](use(b)|, !) -> L1: @@ -41,4 +39,4 @@ error: sink: USE: in: {} out: {} -===================== \ No newline at end of file +===================== diff --git a/compiler/testData/cfg/arrays/arrayIncUnresolved.instructions b/compiler/testData/cfg/arrays/arrayIncUnresolved.instructions index 178b8ade7d5..db3e101c3a3 100644 --- a/compiler/testData/cfg/arrays/arrayIncUnresolved.instructions +++ b/compiler/testData/cfg/arrays/arrayIncUnresolved.instructions @@ -22,7 +22,6 @@ L0: w(a|) 2 mark({ a[0]++ }) mark(a[0]) - error(a[0], No resolved call) r(a) -> r(0) -> magic[UNRESOLVED_CALL](a[0]|, ) -> diff --git a/compiler/testData/cfg/arrays/arraySetPlusAssignUnresolved.instructions b/compiler/testData/cfg/arrays/arraySetPlusAssignUnresolved.instructions index 3a3bb2b7c3b..29a1c4d70a7 100644 --- a/compiler/testData/cfg/arrays/arraySetPlusAssignUnresolved.instructions +++ b/compiler/testData/cfg/arrays/arraySetPlusAssignUnresolved.instructions @@ -22,7 +22,6 @@ L0: w(a|) 2 mark({ a[0] += 1 }) mark(a[0]) - error(a[0], No resolved call) r(a) -> r(0) -> magic[UNRESOLVED_CALL](a[0]|, ) -> diff --git a/compiler/testData/cfg/arrays/arraySetUnresolved.instructions b/compiler/testData/cfg/arrays/arraySetUnresolved.instructions index 2895db09f26..e208424e107 100644 --- a/compiler/testData/cfg/arrays/arraySetUnresolved.instructions +++ b/compiler/testData/cfg/arrays/arraySetUnresolved.instructions @@ -22,7 +22,6 @@ L0: w(a|) 2 mark({ a[1] = 2 }) mark(a[1]) - error(a[1], No resolved call) r(a) -> r(1) -> magic[UNRESOLVED_CALL](a[1]|, ) -> diff --git a/compiler/testData/cfg/declarations/functions/typeParameter.instructions b/compiler/testData/cfg/declarations/functions/typeParameter.instructions index 3193e8e3b10..14fb0eb9303 100644 --- a/compiler/testData/cfg/declarations/functions/typeParameter.instructions +++ b/compiler/testData/cfg/declarations/functions/typeParameter.instructions @@ -6,7 +6,6 @@ fun foo() { L0: 1 2 mark({ T }) - error(T, No resolved call) magic[UNRESOLVED_CALL](T) -> L1: 1 NEXT:[] @@ -14,4 +13,4 @@ error: PREV:[] sink: PREV:[, ] -===================== \ No newline at end of file +===================== diff --git a/compiler/testData/cfg/expressions/chainedQualifiedExpression.instructions b/compiler/testData/cfg/expressions/chainedQualifiedExpression.instructions index 52ef716fd77..91600c55f86 100644 --- a/compiler/testData/cfg/expressions/chainedQualifiedExpression.instructions +++ b/compiler/testData/cfg/expressions/chainedQualifiedExpression.instructions @@ -212,7 +212,6 @@ L0: mark(add(OUT_KEYWORD, inTopLevel)) call(add(OUT_KEYWORD, inTopLevel), add|, , ) -> r(OBJECT_KEYWORD) -> - error(unresolvedCode, No resolved call) magic[UNRESOLVED_CALL](unresolvedCode) -> mark(add(OBJECT_KEYWORD, unresolvedCode)) call(add(OBJECT_KEYWORD, unresolvedCode), add|, , ) -> diff --git a/compiler/testData/cfg/expressions/unresolvedCall.instructions b/compiler/testData/cfg/expressions/unresolvedCall.instructions index 720df77239b..375c9f29b6d 100644 --- a/compiler/testData/cfg/expressions/unresolvedCall.instructions +++ b/compiler/testData/cfg/expressions/unresolvedCall.instructions @@ -10,8 +10,6 @@ L0: w(a|) 2 mark({ a.foo() }) mark(a.foo()) - error(foo(), No resolved call) - error(foo, No resolved call) r(a) -> mark(foo()) magic[UNRESOLVED_CALL](foo()|!, ) -> @@ -21,4 +19,4 @@ error: PREV:[] sink: PREV:[, ] -===================== \ No newline at end of file +===================== diff --git a/compiler/testData/cfg/expressions/unresolvedProperty.instructions b/compiler/testData/cfg/expressions/unresolvedProperty.instructions index 7ebe5f55591..ea4c1061f0c 100644 --- a/compiler/testData/cfg/expressions/unresolvedProperty.instructions +++ b/compiler/testData/cfg/expressions/unresolvedProperty.instructions @@ -10,7 +10,6 @@ L0: w(a|) 2 mark({ a.foo }) mark(a.foo) - error(foo, No resolved call) r(a) -> magic[UNRESOLVED_CALL](foo|) -> L1: @@ -19,4 +18,4 @@ error: PREV:[] sink: PREV:[, ] -===================== \ No newline at end of file +===================== diff --git a/compiler/testData/cfg/expressions/unusedExpressionSimpleName.instructions b/compiler/testData/cfg/expressions/unusedExpressionSimpleName.instructions index 2eaf5af0244..e78640c0a8a 100644 --- a/compiler/testData/cfg/expressions/unusedExpressionSimpleName.instructions +++ b/compiler/testData/cfg/expressions/unusedExpressionSimpleName.instructions @@ -9,7 +9,6 @@ L0: magic[FAKE_INITIALIZER](arg : Array) -> w(arg|) 2 mark({ a }) - error(a, No resolved call) magic[UNRESOLVED_CALL](a) -> L1: 1 NEXT:[] @@ -17,4 +16,4 @@ error: PREV:[] sink: PREV:[, ] -===================== \ No newline at end of file +=====================