Fix for returning new
This commit is contained in:
@@ -4,6 +4,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.psi.JetElement;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetThrowExpression;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
@@ -17,28 +18,29 @@ public interface JetControlFlowBuilder {
|
||||
Label createUnboundLabel();
|
||||
|
||||
void bindLabel(@NotNull Label label);
|
||||
|
||||
// Jumps
|
||||
void jump(@NotNull Label label);
|
||||
void jumpOnFalse(@NotNull Label label);
|
||||
|
||||
void jumpOnTrue(@NotNull Label label);
|
||||
|
||||
void nondeterministicJump(Label label); // Maybe, jump to label
|
||||
void jumpToError(@NotNull JetThrowExpression expression);
|
||||
|
||||
// Entry/exit points
|
||||
Label getEntryPoint(@NotNull JetElement labelElement);
|
||||
|
||||
Label getExitPoint(@NotNull JetElement labelElement);
|
||||
|
||||
// Loops
|
||||
Label enterLoop(@NotNull JetExpression expression, Label loopExitPoint);
|
||||
|
||||
void exitLoop(@NotNull JetExpression expression);
|
||||
|
||||
@Nullable
|
||||
JetElement getCurrentLoop();
|
||||
|
||||
// Finally
|
||||
void enterTryFinally(@NotNull GenerationTrigger trigger);
|
||||
|
||||
void exitTryFinally();
|
||||
|
||||
// Subroutines
|
||||
void enterSubroutine(@NotNull JetElement subroutine, boolean isFunctionLiteral);
|
||||
|
||||
@@ -46,8 +48,8 @@ public interface JetControlFlowBuilder {
|
||||
|
||||
@Nullable
|
||||
JetElement getCurrentSubroutine();
|
||||
|
||||
void returnValue(@NotNull JetExpression returnExpression, @NotNull JetElement subroutine);
|
||||
|
||||
void returnNoValue(@NotNull JetElement returnExpression, @NotNull JetElement subroutine);
|
||||
|
||||
void writeNode(@NotNull JetElement assignment, @NotNull JetElement lValue);
|
||||
|
||||
@@ -4,6 +4,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.psi.JetElement;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetThrowExpression;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
@@ -56,6 +57,11 @@ public class JetControlFlowBuilderAdapter implements JetControlFlowBuilder {
|
||||
builder.nondeterministicJump(label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jumpToError(@NotNull JetThrowExpression expression) {
|
||||
builder.jumpToError(expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Label getEntryPoint(@NotNull JetElement labelElement) {
|
||||
return builder.getEntryPoint(labelElement);
|
||||
|
||||
@@ -505,6 +505,7 @@ public class JetControlFlowProcessor {
|
||||
// TODO : Instantiated class is loaded
|
||||
// TODO : type arguments?
|
||||
visitCall(expression);
|
||||
builder.readNode(expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -540,6 +541,15 @@ public class JetControlFlowProcessor {
|
||||
// TODO : Support Type Arguments. Class object may be initialized at this point");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitThrowExpression(JetThrowExpression expression) {
|
||||
JetExpression thrownExpression = expression.getThrownExpression();
|
||||
if (thrownExpression != null) {
|
||||
value(thrownExpression, false, false);
|
||||
}
|
||||
builder.jumpToError(expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitJetElement(JetElement elem) {
|
||||
builder.unsupported(elem);
|
||||
|
||||
@@ -24,6 +24,7 @@ public abstract class InstructionImpl implements Instruction {
|
||||
|
||||
@Override
|
||||
public void setOwner(@NotNull Pseudocode owner) {
|
||||
assert this.owner == null || this.owner == owner;
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
|
||||
+6
-1
@@ -8,6 +8,7 @@ import org.jetbrains.jet.lang.cfg.Label;
|
||||
import org.jetbrains.jet.lang.psi.JetElement;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetFunctionLiteralExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetThrowExpression;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -85,7 +86,6 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
||||
|
||||
private void add(@NotNull Instruction instruction) {
|
||||
pseudocode.addInstruction(instruction);
|
||||
instruction.setOwner(pseudocode);
|
||||
if (instruction instanceof JetElementInstruction) {
|
||||
JetElementInstruction elementInstruction = (JetElementInstruction) instruction;
|
||||
trace.recordRepresentativeInstruction(elementInstruction.getElement(), instruction);
|
||||
@@ -239,6 +239,11 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
||||
add(new NondeterministicJumpInstruction(label));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jumpToError(@NotNull JetThrowExpression expression) {
|
||||
// add(new UnconditionalJumpInstruction(error));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterTryFinally(@NotNull GenerationTrigger generationTrigger) {
|
||||
allBlocks.push(new TryFinallyBlockInfo(generationTrigger));
|
||||
|
||||
@@ -76,6 +76,7 @@ public class Pseudocode {
|
||||
|
||||
public void addInstruction(Instruction instruction) {
|
||||
instructions.add(instruction);
|
||||
instruction.setOwner(this);
|
||||
if (instruction instanceof SubroutineExitInstruction) {
|
||||
SubroutineExitInstruction exitInstruction = (SubroutineExitInstruction) instruction;
|
||||
assert this.exitInstruction == null;
|
||||
|
||||
Reference in New Issue
Block a user