CF for try's
This commit is contained in:
@@ -6,6 +6,7 @@ import org.jetbrains.jet.lang.psi.*;
|
|||||||
import org.jetbrains.jet.lexer.JetTokens;
|
import org.jetbrains.jet.lexer.JetTokens;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -140,9 +141,12 @@ public class JetControlFlowProcessor {
|
|||||||
builder.jump(afterCatches);
|
builder.jump(afterCatches);
|
||||||
|
|
||||||
builder.bindLabel(catchBlock);
|
builder.bindLabel(catchBlock);
|
||||||
for (JetCatchClause catchClause : catchClauses) {
|
for (Iterator<JetCatchClause> iterator = catchClauses.iterator(); iterator.hasNext(); ) {
|
||||||
|
JetCatchClause catchClause = iterator.next();
|
||||||
value(catchClause.getCatchBody(), true);
|
value(catchClause.getCatchBody(), true);
|
||||||
builder.nondeterministicJump(afterCatches);
|
if (iterator.hasNext()) {
|
||||||
|
builder.nondeterministicJump(afterCatches);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.bindLabel(afterCatches);
|
builder.bindLabel(afterCatches);
|
||||||
|
|||||||
@@ -34,4 +34,8 @@ public class InstructionVisitor {
|
|||||||
|
|
||||||
public void visitInstruction(Instruction instruction) {
|
public void visitInstruction(Instruction instruction) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void visitNondeterministicJump(NondeterministicJumpInstruction instruction) {
|
||||||
|
visitJump(instruction);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -154,7 +154,7 @@ public class JetControlFlowInstructionsGenerator implements JetControlFlowBuilde
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void nondeterministicJump(Label label) {
|
public void nondeterministicJump(Label label) {
|
||||||
throw new UnsupportedOperationException(); // TODO
|
add(new NondeterministicJumpInstruction(label));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package org.jetbrains.jet.lang.cfg.pseudocode;
|
||||||
|
|
||||||
|
import org.jetbrains.jet.lang.cfg.Label;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author abreslav
|
||||||
|
*/
|
||||||
|
public class NondeterministicJumpInstruction extends AbstractJumpInstruction {
|
||||||
|
|
||||||
|
private Instruction next;
|
||||||
|
|
||||||
|
public NondeterministicJumpInstruction(Label targetLabel) {
|
||||||
|
super(targetLabel);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void accept(InstructionVisitor visitor) {
|
||||||
|
visitor.visitNondeterministicJump(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Instruction getNext() {
|
||||||
|
return next;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNext(Instruction next) {
|
||||||
|
this.next = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "jmp?(" + getTargetLabel().getName() + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -36,6 +36,12 @@ public class Pseudocode {
|
|||||||
instruction.setResolvedTarget(getJumpTarget(instruction.getTargetLabel()));
|
instruction.setResolvedTarget(getJumpTarget(instruction.getTargetLabel()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void visitNondeterministicJump(NondeterministicJumpInstruction instruction) {
|
||||||
|
instruction.setNext(getNextPosition(currentPosition));
|
||||||
|
visitJump(instruction);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitConditionalJump(ConditionalJumpInstruction instruction) {
|
public void visitConditionalJump(ConditionalJumpInstruction instruction) {
|
||||||
Instruction nextInstruction = getNextPosition(currentPosition);
|
Instruction nextInstruction = getNextPosition(currentPosition);
|
||||||
@@ -120,7 +126,13 @@ public class Pseudocode {
|
|||||||
if (newline >= 0) {
|
if (newline >= 0) {
|
||||||
text = text.substring(0, newline);
|
text = text.substring(0, newline);
|
||||||
}
|
}
|
||||||
String shape = node instanceof ConditionalJumpInstruction ? "diamond" : "box";
|
String shape = "box";
|
||||||
|
if (node instanceof ConditionalJumpInstruction) {
|
||||||
|
shape = "diamond";
|
||||||
|
}
|
||||||
|
else if (node instanceof NondeterministicJumpInstruction) {
|
||||||
|
shape = "Mdiamond";
|
||||||
|
}
|
||||||
out.println(name + "[label=\"" + text + "\", shape=" + shape + "];");
|
out.println(name + "[label=\"" + text + "\", shape=" + shape + "];");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,6 +148,12 @@ public class Pseudocode {
|
|||||||
writeEdge(out, nodeToName.get(instruction), nodeToName.get(instruction.getResolvedTarget()), null);
|
writeEdge(out, nodeToName.get(instruction), nodeToName.get(instruction.getResolvedTarget()), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void visitNondeterministicJump(NondeterministicJumpInstruction instruction) {
|
||||||
|
visitJump(instruction);
|
||||||
|
writeEdge(out, nodeToName.get(instruction), nodeToName.get(instruction.getNext()), null);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitReturnValue(ReturnValueInstruction instruction) {
|
public void visitReturnValue(ReturnValueInstruction instruction) {
|
||||||
super.visitReturnValue(instruction);
|
super.visitReturnValue(instruction);
|
||||||
|
|||||||
Reference in New Issue
Block a user