Pseudocode: Drop CompilationErrorInstruction
This commit is contained in:
@@ -157,8 +157,6 @@ public interface JetControlFlowBuilder {
|
|||||||
@NotNull List<PseudoValue> inputValues
|
@NotNull List<PseudoValue> inputValues
|
||||||
);
|
);
|
||||||
|
|
||||||
void compilationError(@NotNull JetElement element, @NotNull String message);
|
|
||||||
|
|
||||||
void write(
|
void write(
|
||||||
@NotNull JetElement assignment,
|
@NotNull JetElement assignment,
|
||||||
@NotNull JetElement lValue,
|
@NotNull JetElement lValue,
|
||||||
|
|||||||
@@ -114,11 +114,6 @@ public abstract class JetControlFlowBuilderAdapter implements JetControlFlowBuil
|
|||||||
return getDelegateBuilder().predefinedOperation(expression, operation, inputValues);
|
return getDelegateBuilder().predefinedOperation(expression, operation, inputValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void compilationError(@NotNull JetElement element, @NotNull String message) {
|
|
||||||
getDelegateBuilder().compilationError(element, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public Label createUnboundLabel() {
|
public Label createUnboundLabel() {
|
||||||
|
|||||||
@@ -457,7 +457,8 @@ public class JetControlFlowProcessor {
|
|||||||
) {
|
) {
|
||||||
JetExpression left = JetPsiUtil.deparenthesize(lhs);
|
JetExpression left = JetPsiUtil.deparenthesize(lhs);
|
||||||
if (left == null) {
|
if (left == null) {
|
||||||
builder.compilationError(lhs, "No lValue in assignment");
|
List<PseudoValue> arguments = Collections.singletonList(rhsDeferredValue.invoke());
|
||||||
|
builder.magic(parentExpression, parentExpression, arguments, defaultTypeMap(arguments), MagicKind.UNSUPPORTED_ELEMENT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -576,7 +577,7 @@ public class JetControlFlowProcessor {
|
|||||||
private void generateArrayAccess(JetArrayAccessExpression arrayAccessExpression, @Nullable ResolvedCall<?> resolvedCall) {
|
private void generateArrayAccess(JetArrayAccessExpression arrayAccessExpression, @Nullable ResolvedCall<?> resolvedCall) {
|
||||||
if (builder.getBoundValue(arrayAccessExpression) != null) return;
|
if (builder.getBoundValue(arrayAccessExpression) != null) return;
|
||||||
mark(arrayAccessExpression);
|
mark(arrayAccessExpression);
|
||||||
if (!checkAndGenerateCall(arrayAccessExpression, resolvedCall)) {
|
if (!checkAndGenerateCall(resolvedCall)) {
|
||||||
generateArrayAccessWithoutCall(arrayAccessExpression);
|
generateArrayAccessWithoutCall(arrayAccessExpression);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1480,14 +1481,11 @@ public class JetControlFlowProcessor {
|
|||||||
|
|
||||||
private boolean generateCall(@Nullable JetElement callElement) {
|
private boolean generateCall(@Nullable JetElement callElement) {
|
||||||
if (callElement == null) return false;
|
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) {
|
private boolean checkAndGenerateCall(@Nullable ResolvedCall<?> resolvedCall) {
|
||||||
if (resolvedCall == null) {
|
if (resolvedCall == null) return false;
|
||||||
builder.compilationError(callElement, "No resolved call");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
generateCall(resolvedCall);
|
generateCall(resolvedCall);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
-5
@@ -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
|
@NotNull
|
||||||
private ReadValueInstruction read(
|
private ReadValueInstruction read(
|
||||||
@NotNull JetExpression expression,
|
@NotNull JetExpression expression,
|
||||||
|
|||||||
-4
@@ -105,10 +105,6 @@ public open class InstructionVisitor() {
|
|||||||
visitOperation(instruction)
|
visitOperation(instruction)
|
||||||
}
|
}
|
||||||
|
|
||||||
public open fun visitCompilationErrorInstruction(instruction: CompilationErrorInstruction) {
|
|
||||||
visitInstructionWithNext(instruction)
|
|
||||||
}
|
|
||||||
|
|
||||||
public open fun visitMarkInstruction(instruction: MarkInstruction) {
|
public open fun visitMarkInstruction(instruction: MarkInstruction) {
|
||||||
visitInstructionWithNext(instruction)
|
visitInstructionWithNext(instruction)
|
||||||
}
|
}
|
||||||
|
|||||||
-4
@@ -104,10 +104,6 @@ public abstract class InstructionVisitorWithResult<R>() {
|
|||||||
return visitOperation(instruction)
|
return visitOperation(instruction)
|
||||||
}
|
}
|
||||||
|
|
||||||
public open fun visitCompilationErrorInstruction(instruction: CompilationErrorInstruction): R {
|
|
||||||
return visitInstructionWithNext(instruction)
|
|
||||||
}
|
|
||||||
|
|
||||||
public open fun visitMarkInstruction(instruction: MarkInstruction): R {
|
public open fun visitMarkInstruction(instruction: MarkInstruction): R {
|
||||||
return visitInstructionWithNext(instruction)
|
return visitInstructionWithNext(instruction)
|
||||||
}
|
}
|
||||||
|
|||||||
-42
@@ -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 <R> accept(visitor: InstructionVisitorWithResult<R>): R {
|
|
||||||
return visitor.visitCompilationErrorInstruction(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun createCopy() = CompilationErrorInstruction(element, lexicalScope, message)
|
|
||||||
|
|
||||||
override fun toString() = "error(${render(element)}, $message)"
|
|
||||||
}
|
|
||||||
@@ -29,10 +29,8 @@ L2 [else branch]:
|
|||||||
r(true) -> <v5> USE: in: {b=WRITTEN_AFTER_READ} out: {b=WRITTEN_AFTER_READ}
|
r(true) -> <v5> USE: in: {b=WRITTEN_AFTER_READ} out: {b=WRITTEN_AFTER_READ}
|
||||||
w(b|<v5>) INIT: in: {b=D} out: {b=ID} USE: in: {b=READ} out: {b=WRITTEN_AFTER_READ}
|
w(b|<v5>) INIT: in: {b=D} out: {b=ID} USE: in: {b=READ} out: {b=WRITTEN_AFTER_READ}
|
||||||
L3 ['if' expression result]:
|
L3 ['if' expression result]:
|
||||||
2 merge(if (1 < 2) { b = false } else { b = true }|!<v4>, !<v6>) -> <v7> INIT: in: {b=ID} out: {b=ID}
|
2 merge(if (1 < 2) { b = false } else { b = true }|!<v4>, !<v6>) -> <v7> INIT: in: {b=ID} out: {b=ID} USE: in: {b=READ} out: {b=READ}
|
||||||
error(use(b), No resolved call) USE: in: {b=READ} out: {b=READ}
|
|
||||||
r(b) -> <v8> USE: in: {} out: {b=READ}
|
r(b) -> <v8> USE: in: {} out: {b=READ}
|
||||||
error(use, No resolved call)
|
|
||||||
mark(use(b))
|
mark(use(b))
|
||||||
magic[UNRESOLVED_CALL](use(b)|<v8>, !<v9>) -> <v10>
|
magic[UNRESOLVED_CALL](use(b)|<v8>, !<v9>) -> <v10>
|
||||||
L1:
|
L1:
|
||||||
@@ -41,4 +39,4 @@ error:
|
|||||||
<ERROR>
|
<ERROR>
|
||||||
sink:
|
sink:
|
||||||
<SINK> USE: in: {} out: {}
|
<SINK> USE: in: {} out: {}
|
||||||
=====================
|
=====================
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ L0:
|
|||||||
w(a|<v0>)
|
w(a|<v0>)
|
||||||
2 mark({ a[0]++ })
|
2 mark({ a[0]++ })
|
||||||
mark(a[0])
|
mark(a[0])
|
||||||
error(a[0], No resolved call)
|
|
||||||
r(a) -> <v1>
|
r(a) -> <v1>
|
||||||
r(0) -> <v2>
|
r(0) -> <v2>
|
||||||
magic[UNRESOLVED_CALL](a[0]|<v1>, <v2>) -> <v3>
|
magic[UNRESOLVED_CALL](a[0]|<v1>, <v2>) -> <v3>
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ L0:
|
|||||||
w(a|<v0>)
|
w(a|<v0>)
|
||||||
2 mark({ a[0] += 1 })
|
2 mark({ a[0] += 1 })
|
||||||
mark(a[0])
|
mark(a[0])
|
||||||
error(a[0], No resolved call)
|
|
||||||
r(a) -> <v1>
|
r(a) -> <v1>
|
||||||
r(0) -> <v2>
|
r(0) -> <v2>
|
||||||
magic[UNRESOLVED_CALL](a[0]|<v1>, <v2>) -> <v3>
|
magic[UNRESOLVED_CALL](a[0]|<v1>, <v2>) -> <v3>
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ L0:
|
|||||||
w(a|<v0>)
|
w(a|<v0>)
|
||||||
2 mark({ a[1] = 2 })
|
2 mark({ a[1] = 2 })
|
||||||
mark(a[1])
|
mark(a[1])
|
||||||
error(a[1], No resolved call)
|
|
||||||
r(a) -> <v1>
|
r(a) -> <v1>
|
||||||
r(1) -> <v2>
|
r(1) -> <v2>
|
||||||
magic[UNRESOLVED_CALL](a[1]|<v1>, <v2>) -> <v3>
|
magic[UNRESOLVED_CALL](a[1]|<v1>, <v2>) -> <v3>
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ fun <T> foo() {
|
|||||||
L0:
|
L0:
|
||||||
1 <START>
|
1 <START>
|
||||||
2 mark({ T })
|
2 mark({ T })
|
||||||
error(T, No resolved call)
|
|
||||||
magic[UNRESOLVED_CALL](T) -> <v0>
|
magic[UNRESOLVED_CALL](T) -> <v0>
|
||||||
L1:
|
L1:
|
||||||
1 <END> NEXT:[<SINK>]
|
1 <END> NEXT:[<SINK>]
|
||||||
@@ -14,4 +13,4 @@ error:
|
|||||||
<ERROR> PREV:[]
|
<ERROR> PREV:[]
|
||||||
sink:
|
sink:
|
||||||
<SINK> PREV:[<ERROR>, <END>]
|
<SINK> PREV:[<ERROR>, <END>]
|
||||||
=====================
|
=====================
|
||||||
|
|||||||
@@ -212,7 +212,6 @@ L0:
|
|||||||
mark(add(OUT_KEYWORD, inTopLevel))
|
mark(add(OUT_KEYWORD, inTopLevel))
|
||||||
call(add(OUT_KEYWORD, inTopLevel), add|<v99>, <v100>, <v101>) -> <v102>
|
call(add(OUT_KEYWORD, inTopLevel), add|<v99>, <v100>, <v101>) -> <v102>
|
||||||
r(OBJECT_KEYWORD) -> <v103>
|
r(OBJECT_KEYWORD) -> <v103>
|
||||||
error(unresolvedCode, No resolved call)
|
|
||||||
magic[UNRESOLVED_CALL](unresolvedCode) -> <v104>
|
magic[UNRESOLVED_CALL](unresolvedCode) -> <v104>
|
||||||
mark(add(OBJECT_KEYWORD, unresolvedCode))
|
mark(add(OBJECT_KEYWORD, unresolvedCode))
|
||||||
call(add(OBJECT_KEYWORD, unresolvedCode), add|<v102>, <v103>, <v104>) -> <v105>
|
call(add(OBJECT_KEYWORD, unresolvedCode), add|<v102>, <v103>, <v104>) -> <v105>
|
||||||
|
|||||||
@@ -10,8 +10,6 @@ L0:
|
|||||||
w(a|<v0>)
|
w(a|<v0>)
|
||||||
2 mark({ a.foo() })
|
2 mark({ a.foo() })
|
||||||
mark(a.foo())
|
mark(a.foo())
|
||||||
error(foo(), No resolved call)
|
|
||||||
error(foo, No resolved call)
|
|
||||||
r(a) -> <v1>
|
r(a) -> <v1>
|
||||||
mark(foo())
|
mark(foo())
|
||||||
magic[UNRESOLVED_CALL](foo()|!<v2>, <v1>) -> <v3>
|
magic[UNRESOLVED_CALL](foo()|!<v2>, <v1>) -> <v3>
|
||||||
@@ -21,4 +19,4 @@ error:
|
|||||||
<ERROR> PREV:[]
|
<ERROR> PREV:[]
|
||||||
sink:
|
sink:
|
||||||
<SINK> PREV:[<ERROR>, <END>]
|
<SINK> PREV:[<ERROR>, <END>]
|
||||||
=====================
|
=====================
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ L0:
|
|||||||
w(a|<v0>)
|
w(a|<v0>)
|
||||||
2 mark({ a.foo })
|
2 mark({ a.foo })
|
||||||
mark(a.foo)
|
mark(a.foo)
|
||||||
error(foo, No resolved call)
|
|
||||||
r(a) -> <v1>
|
r(a) -> <v1>
|
||||||
magic[UNRESOLVED_CALL](foo|<v1>) -> <v2>
|
magic[UNRESOLVED_CALL](foo|<v1>) -> <v2>
|
||||||
L1:
|
L1:
|
||||||
@@ -19,4 +18,4 @@ error:
|
|||||||
<ERROR> PREV:[]
|
<ERROR> PREV:[]
|
||||||
sink:
|
sink:
|
||||||
<SINK> PREV:[<ERROR>, <END>]
|
<SINK> PREV:[<ERROR>, <END>]
|
||||||
=====================
|
=====================
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ L0:
|
|||||||
magic[FAKE_INITIALIZER](arg : Array<String>) -> <v0>
|
magic[FAKE_INITIALIZER](arg : Array<String>) -> <v0>
|
||||||
w(arg|<v0>)
|
w(arg|<v0>)
|
||||||
2 mark({ a })
|
2 mark({ a })
|
||||||
error(a, No resolved call)
|
|
||||||
magic[UNRESOLVED_CALL](a) -> <v1>
|
magic[UNRESOLVED_CALL](a) -> <v1>
|
||||||
L1:
|
L1:
|
||||||
1 <END> NEXT:[<SINK>]
|
1 <END> NEXT:[<SINK>]
|
||||||
@@ -17,4 +16,4 @@ error:
|
|||||||
<ERROR> PREV:[]
|
<ERROR> PREV:[]
|
||||||
sink:
|
sink:
|
||||||
<SINK> PREV:[<ERROR>, <END>]
|
<SINK> PREV:[<ERROR>, <END>]
|
||||||
=====================
|
=====================
|
||||||
|
|||||||
Reference in New Issue
Block a user