diff --git a/.idea/dictionaries/abreslav.xml b/.idea/dictionaries/abreslav.xml index 5a2eeed92c5..033e9a75f07 100644 --- a/.idea/dictionaries/abreslav.xml +++ b/.idea/dictionaries/abreslav.xml @@ -3,7 +3,9 @@ accessor inferrer + nondeterministic nullable + pseudocode substitutor subtyping supertype diff --git a/idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java b/idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java index 67e66415370..9c2c2ebdae4 100644 --- a/idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java +++ b/idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java @@ -149,9 +149,9 @@ public class ExpressionCodegen extends JetVisitor { @Override public void visitBreakExpression(JetBreakExpression expression) { - String labelName = expression.getLabelName(); + JetSimpleNameExpression labelElement = expression.getTargetLabel(); - Label label = labelName == null ? myLoopEnds.peek() : null; // TODO: + Label label = labelElement == null ? myLoopEnds.peek() : null; // TODO: v.goTo(label); } diff --git a/idea/src/org/jetbrains/jet/lang/annotations/LabelsAnnotator.java b/idea/src/org/jetbrains/jet/lang/annotations/LabelsAnnotator.java index 7a0b0748282..3c2ef490239 100644 --- a/idea/src/org/jetbrains/jet/lang/annotations/LabelsAnnotator.java +++ b/idea/src/org/jetbrains/jet/lang/annotations/LabelsAnnotator.java @@ -3,13 +3,15 @@ */ package org.jetbrains.jet.lang.annotations; -import com.intellij.lang.ASTNode; import com.intellij.lang.annotation.AnnotationHolder; import com.intellij.lang.annotation.Annotator; import com.intellij.psi.PsiElement; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.JetHighlighter; -import org.jetbrains.jet.lang.psi.*; +import org.jetbrains.jet.lang.psi.JetLabelQualifiedExpression; +import org.jetbrains.jet.lang.psi.JetPrefixExpression; +import org.jetbrains.jet.lang.psi.JetSimpleNameExpression; +import org.jetbrains.jet.lang.psi.JetVisitor; import org.jetbrains.jet.lexer.JetTokens; public class LabelsAnnotator implements Annotator { @@ -25,9 +27,9 @@ public class LabelsAnnotator implements Annotator { @Override public void visitLabelQualifiedExpression(JetLabelQualifiedExpression expression) { - ASTNode targetLabelNode = expression.getTargetLabelNode(); - if (targetLabelNode != null) { - holder.createInfoAnnotation(targetLabelNode, null).setTextAttributes(JetHighlighter.JET_LABEL_IDENTIFIER); + JetSimpleNameExpression targetLabel = expression.getTargetLabel(); + if (targetLabel != null) { + holder.createInfoAnnotation(targetLabel, null).setTextAttributes(JetHighlighter.JET_LABEL_IDENTIFIER); } } diff --git a/idea/src/org/jetbrains/jet/lang/cfg/JetControlFlowBuilder.java b/idea/src/org/jetbrains/jet/lang/cfg/JetControlFlowBuilder.java new file mode 100644 index 00000000000..59ad4dd31f5 --- /dev/null +++ b/idea/src/org/jetbrains/jet/lang/cfg/JetControlFlowBuilder.java @@ -0,0 +1,54 @@ +package org.jetbrains.jet.lang.cfg; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.psi.JetBlockExpression; +import org.jetbrains.jet.lang.psi.JetElement; +import org.jetbrains.jet.lang.psi.JetExpression; + +/** + * @author abreslav + */ +public interface JetControlFlowBuilder { + void readNode(@NotNull JetExpression expression); + + // General label management + @NotNull + 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 + + // 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 pushFinally(@NotNull JetBlockExpression expression); + void popFinally(); + + // Subroutines + void enterSubroutine(@NotNull JetElement subroutine); + void exitSubroutine(@NotNull JetElement subroutine); + + @Nullable + JetElement getCurrentSubroutine(); + + void returnValue(@NotNull JetElement subroutine); + void returnNoValue(@NotNull JetElement subroutine); + + // Other + void unsupported(JetElement element); +} diff --git a/idea/src/org/jetbrains/jet/lang/cfg/JetControlFlowGraphBuilder.java b/idea/src/org/jetbrains/jet/lang/cfg/JetControlFlowGraphBuilder.java new file mode 100644 index 00000000000..fe5239a42eb --- /dev/null +++ b/idea/src/org/jetbrains/jet/lang/cfg/JetControlFlowGraphBuilder.java @@ -0,0 +1,348 @@ +package org.jetbrains.jet.lang.cfg; + +/** + * @author abreslav + */ +//public class JetControlFlowGraphBuilder extends AbstractControlFlowBuilder { +// +// private final List nodes = new ArrayList(); +// +// private final List edges = new ArrayList(); +// private final Map labelsToNodes = new HashMap(); +// // toLabel -> edge +// private final Map> pendingEdges = new HashMap>(); +// +// private List