Pseudocode: Drop CompilationErrorInstruction

This commit is contained in:
Alexey Sedunov
2014-10-07 18:26:58 +04:00
parent a56c54371e
commit a3a0edca58
16 changed files with 12 additions and 87 deletions
@@ -157,8 +157,6 @@ public interface JetControlFlowBuilder {
@NotNull List<PseudoValue> inputValues
);
void compilationError(@NotNull JetElement element, @NotNull String message);
void write(
@NotNull JetElement assignment,
@NotNull JetElement lValue,
@@ -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() {
@@ -457,7 +457,8 @@ public class JetControlFlowProcessor {
) {
JetExpression left = JetPsiUtil.deparenthesize(lhs);
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;
}
@@ -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;
}
@@ -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,
@@ -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)
}
@@ -104,10 +104,6 @@ public abstract class InstructionVisitorWithResult<R>() {
return visitOperation(instruction)
}
public open fun visitCompilationErrorInstruction(instruction: CompilationErrorInstruction): R {
return visitInstructionWithNext(instruction)
}
public open fun visitMarkInstruction(instruction: MarkInstruction): R {
return visitInstructionWithNext(instruction)
}
@@ -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)"
}