diff --git a/annotations/com/google/common/collect/annotations.xml b/annotations/com/google/common/collect/annotations.xml
index 0250409ed73..f10679364a2 100644
--- a/annotations/com/google/common/collect/annotations.xml
+++ b/annotations/com/google/common/collect/annotations.xml
@@ -1,4 +1,13 @@
+
+
+
+
+
+
+
+
+
@@ -9,4 +18,7 @@
name='com.google.common.collect.Sets com.google.common.collect.Sets.SetView<E> intersection(java.util.Set<E>, java.util.Set<?>)'>
+
+
+
\ No newline at end of file
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/Label.java b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/Label.java
index ca606338dab..f84085b4a4a 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/Label.java
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/Label.java
@@ -16,6 +16,9 @@
package org.jetbrains.jet.lang.cfg;
+import org.jetbrains.annotations.NotNull;
+
public interface Label {
+ @NotNull
String getName();
}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/PseudocodeTraverser.kt b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/PseudocodeTraverser.kt
index d36fead7af4..14ad372507e 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/PseudocodeTraverser.kt
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/PseudocodeTraverser.kt
@@ -27,7 +27,7 @@ fun Pseudocode.traverse(
val instructions = getInstructions(traversalOrder)
for (instruction in instructions) {
if (instruction is LocalFunctionDeclarationInstruction) {
- instruction.getBody().traverse(traversalOrder, analyzeInstruction)
+ instruction.body.traverse(traversalOrder, analyzeInstruction)
}
analyzeInstruction(instruction)
}
@@ -41,7 +41,7 @@ fun Pseudocode.traverse(
val instructions = getInstructions(traversalOrder)
for (instruction in instructions) {
if (instruction is LocalFunctionDeclarationInstruction) {
- instruction.getBody().traverse(traversalOrder, edgesMap, analyzeInstruction)
+ instruction.body.traverse(traversalOrder, edgesMap, analyzeInstruction)
}
val edges = edgesMap.get(instruction)
if (edges != null) {
@@ -81,7 +81,7 @@ private fun Pseudocode.initializeEdgesMap(
for (instruction in instructions) {
edgesMap.put(instruction, initialEdge)
if (instruction is LocalFunctionDeclarationInstruction) {
- instruction.getBody().initializeEdgesMap(edgesMap, initialDataValue)
+ instruction.body.initializeEdgesMap(edgesMap, initialDataValue)
}
}
}
@@ -126,7 +126,7 @@ private fun Pseudocode.collectDataFromSubgraph(
}
if (instruction is LocalFunctionDeclarationInstruction) {
- val subroutinePseudocode = instruction.getBody()
+ val subroutinePseudocode = instruction.body
val previous = if (mergeDataWithLocalDeclarations) previousInstructions else Collections.emptyList()
subroutinePseudocode.collectDataFromSubgraph(
traversalOrder, mergeDataWithLocalDeclarations,
@@ -208,10 +208,10 @@ fun Pseudocode.getInstructions(traversalOrder: TraversalOrder): MutableList =
- if (traversalOrder == FORWARD) getNextInstructions() else getPreviousInstructions()
+ if (traversalOrder == FORWARD) nextInstructions else previousInstructions
fun Instruction.getPreviousInstructions(traversalOrder: TraversalOrder): Collection =
- if (traversalOrder == FORWARD) getPreviousInstructions() else getNextInstructions()
+ if (traversalOrder == FORWARD) previousInstructions else nextInstructions
fun Instruction.isStartInstruction(traversalOrder: TraversalOrder): Boolean =
if (traversalOrder == FORWARD) this is SubroutineEnterInstruction else this is SubroutineSinkInstruction
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/PseudocodeVariableDataCollector.kt b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/PseudocodeVariableDataCollector.kt
index dead27ae36f..cd111645a8f 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/PseudocodeVariableDataCollector.kt
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/PseudocodeVariableDataCollector.kt
@@ -60,8 +60,8 @@ public class PseudocodeVariableDataCollector(
data: Map
): Map {
// If an edge goes from deeper lexical scope to a less deep one, this means that it points outside of the deeper scope.
- val toDepth = to.getLexicalScope().depth
- if (toDepth >= from.getLexicalScope().depth) return data
+ val toDepth = to.lexicalScope.depth
+ if (toDepth >= from.lexicalScope.depth) return data
// Variables declared in an inner (deeper) scope can't be accessed from an outer scope.
// Thus they can be filtered out upon leaving the inner scope.
@@ -77,14 +77,14 @@ public class PseudocodeVariableDataCollector(
val lexicalScopeVariableInfo = LexicalScopeVariableInfoImpl()
pseudocode.traverse(TraversalOrder.FORWARD, { instruction ->
if (instruction is VariableDeclarationInstruction) {
- val variableDeclarationElement = instruction.getVariableDeclarationElement()
+ val variableDeclarationElement = instruction.variableDeclarationElement
val descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, variableDeclarationElement)
if (descriptor != null) {
assert(descriptor is VariableDescriptor,
- "Variable descriptor should correspond to the instruction for ${instruction.getElement().getText()}.\n" +
+ "Variable descriptor should correspond to the instruction for ${instruction.element.getText()}.\n" +
"Descriptor : $descriptor")
lexicalScopeVariableInfo.registerVariableDeclaredInScope(
- descriptor as VariableDescriptor, instruction.getLexicalScope())
+ descriptor as VariableDescriptor, instruction.lexicalScope)
}
}
})
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/TailRecursionDetector.java b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/TailRecursionDetector.java
index afd6dd3dd36..d7f9a71ab8b 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/TailRecursionDetector.java
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/TailRecursionDetector.java
@@ -36,37 +36,37 @@ public class TailRecursionDetector extends InstructionVisitorWithResult
}
@Override
- public Boolean visitInstruction(Instruction instruction) {
+ public Boolean visitInstruction(@NotNull Instruction instruction) {
return false;
}
@Override
- public Boolean visitSubroutineExit(SubroutineExitInstruction instruction) {
- return !instruction.isError() && instruction.getSubroutine() == subroutine;
+ public Boolean visitSubroutineExit(@NotNull SubroutineExitInstruction instruction) {
+ return !instruction.getIsError() && instruction.getSubroutine() == subroutine;
}
@Override
- public Boolean visitSubroutineSink(SubroutineSinkInstruction instruction) {
+ public Boolean visitSubroutineSink(@NotNull SubroutineSinkInstruction instruction) {
return instruction.getSubroutine() == subroutine;
}
@Override
- public Boolean visitJump(AbstractJumpInstruction instruction) {
+ public Boolean visitJump(@NotNull AbstractJumpInstruction instruction) {
return true;
}
@Override
- public Boolean visitThrowExceptionInstruction(ThrowExceptionInstruction instruction) {
+ public Boolean visitThrowExceptionInstruction(@NotNull ThrowExceptionInstruction instruction) {
return false;
}
@Override
- public Boolean visitMarkInstruction(MarkInstruction instruction) {
+ public Boolean visitMarkInstruction(@NotNull MarkInstruction instruction) {
return true;
}
@Override
- public Boolean visitMagic(MagicInstruction instruction) {
+ public Boolean visitMagic(@NotNull MagicInstruction instruction) {
return instruction.getSynthetic();
}
}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/AbstractJumpInstruction.java b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/AbstractJumpInstruction.java
deleted file mode 100644
index 7d0ba094fa8..00000000000
--- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/AbstractJumpInstruction.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2010-2013 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;
-
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.jet.lang.cfg.Label;
-import org.jetbrains.jet.lang.psi.JetElement;
-
-import java.util.Collection;
-import java.util.Collections;
-
-public abstract class AbstractJumpInstruction extends JetElementInstructionImpl implements JumpInstruction {
- private final Label targetLabel;
- private Instruction resolvedTarget;
-
- public AbstractJumpInstruction(@NotNull JetElement element, Label targetLabel, LexicalScope lexicalScope) {
- super(element, lexicalScope);
- this.targetLabel = targetLabel;
- }
-
- public Label getTargetLabel() {
- return targetLabel;
- }
-
- public Instruction getResolvedTarget() {
- return resolvedTarget;
- }
-
- @NotNull
- @Override
- public Collection getNextInstructions() {
- return Collections.singleton(getResolvedTarget());
- }
-
- public void setResolvedTarget(Instruction resolvedTarget) {
- this.resolvedTarget = outgoingEdgeTo(resolvedTarget);
- }
-
- protected abstract AbstractJumpInstruction createCopy(@NotNull Label newLabel, @NotNull LexicalScope lexicalScope);
-
- final public Instruction copy(@NotNull Label newLabel) {
- return updateCopyInfo(createCopy(newLabel, lexicalScope));
- }
-
- @NotNull
- @Override
- protected Instruction createCopy() {
- return createCopy(targetLabel, lexicalScope);
- }
-}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/AbstractJumpInstruction.kt b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/AbstractJumpInstruction.kt
new file mode 100644
index 00000000000..55add4e3ad7
--- /dev/null
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/AbstractJumpInstruction.kt
@@ -0,0 +1,44 @@
+/*
+ * 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
+
+import org.jetbrains.jet.lang.cfg.Label
+import org.jetbrains.jet.lang.psi.JetElement
+import java.util.Collections
+
+public abstract class AbstractJumpInstruction(
+ element: JetElement,
+ public val targetLabel: Label,
+ lexicalScope: LexicalScope
+) : JetElementInstructionImpl(element, lexicalScope), JumpInstruction {
+ public var resolvedTarget: Instruction? = null
+ set(value: Instruction?) {
+ $resolvedTarget = outgoingEdgeTo(value)
+ }
+
+ protected abstract fun createCopy(newLabel: Label, lexicalScope: LexicalScope): AbstractJumpInstruction
+
+ public fun copy(newLabel: Label): Instruction {
+ return updateCopyInfo(createCopy(newLabel, lexicalScope))
+ }
+
+ override fun createCopy(): InstructionImpl {
+ return createCopy(targetLabel, lexicalScope)
+ }
+
+ override val nextInstructions: Collection get() = Collections.singleton(resolvedTarget)
+}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/CompilationErrorInstruction.kt b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/CompilationErrorInstruction.kt
new file mode 100644
index 00000000000..3571941bbcf
--- /dev/null
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/CompilationErrorInstruction.kt
@@ -0,0 +1,38 @@
+/*
+ * 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
+
+import org.jetbrains.jet.lang.psi.JetElement
+
+public class CompilationErrorInstruction(
+ element: JetElement,
+ lexicalScope: LexicalScope,
+ val message: String
+) : InstructionWithNext(element, lexicalScope) {
+
+ override fun accept(visitor: InstructionVisitor) {
+ visitor.visitCompilationErrorInstruction(this)
+ }
+
+ override fun accept(visitor: InstructionVisitorWithResult): R {
+ return visitor.visitCompilationErrorInstruction(this)
+ }
+
+ override fun createCopy() = CompilationErrorInstruction(element, lexicalScope, message)
+
+ override fun toString() = "error(${render(element)}, $message)"
+}
\ No newline at end of file
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/ConditionalJumpInstruction.java b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/ConditionalJumpInstruction.java
deleted file mode 100644
index 6674f7aebed..00000000000
--- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/ConditionalJumpInstruction.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright 2010-2013 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;
-
-import com.intellij.util.containers.ContainerUtil;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.jet.lang.cfg.Label;
-import org.jetbrains.jet.lang.psi.JetElement;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-
-public class ConditionalJumpInstruction extends AbstractJumpInstruction {
- private final boolean onTrue;
- private Instruction nextOnTrue;
- private Instruction nextOnFalse;
- private final PseudoValue conditionValue;
-
- public ConditionalJumpInstruction(
- @NotNull JetElement element,
- boolean onTrue,
- LexicalScope lexicalScope,
- Label targetLabel,
- PseudoValue conditionValue) {
- super(element, targetLabel, lexicalScope);
- this.onTrue = onTrue;
- this.conditionValue = conditionValue;
- }
-
- @NotNull
- @Override
- public List getInputValues() {
- return ContainerUtil.createMaybeSingletonList(conditionValue);
- }
-
- public boolean onTrue() {
- return onTrue;
- }
-
- public Instruction getNextOnTrue() {
- return nextOnTrue;
- }
-
- public void setNextOnTrue(Instruction nextOnTrue) {
- this.nextOnTrue = outgoingEdgeTo(nextOnTrue);
- }
-
- public Instruction getNextOnFalse() {
- return nextOnFalse;
- }
-
- public void setNextOnFalse(Instruction nextOnFalse) {
- this.nextOnFalse = outgoingEdgeTo(nextOnFalse);
- }
-
- @NotNull
- @Override
- public Collection getNextInstructions() {
- return Arrays.asList(getNextOnFalse(), getNextOnTrue());
- }
-
- @Override
- public void accept(@NotNull InstructionVisitor visitor) {
- visitor.visitConditionalJump(this);
- }
-
- @Override
- public R accept(@NotNull InstructionVisitorWithResult visitor) {
- return visitor.visitConditionalJump(this);
- }
-
- @Override
- public String toString() {
- String instr = onTrue ? "jt" : "jf";
- String inValue = conditionValue != null ? "|" + conditionValue : "";
- return instr + "(" + getTargetLabel().getName() + inValue + ")";
- }
-
- @Override
- protected AbstractJumpInstruction createCopy(@NotNull Label newLabel, @NotNull LexicalScope lexicalScope) {
- return new ConditionalJumpInstruction(element, onTrue, lexicalScope, newLabel, conditionValue);
- }
-}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/ConditionalJumpInstruction.kt b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/ConditionalJumpInstruction.kt
new file mode 100644
index 00000000000..a1db150a334
--- /dev/null
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/ConditionalJumpInstruction.kt
@@ -0,0 +1,67 @@
+/*
+ * 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
+
+import com.intellij.util.containers.ContainerUtil
+import org.jetbrains.jet.lang.cfg.Label
+import org.jetbrains.jet.lang.psi.JetElement
+import java.util.Arrays
+
+public class ConditionalJumpInstruction(
+ element: JetElement,
+ public val onTrue: Boolean,
+ lexicalScope: LexicalScope,
+ targetLabel: Label,
+ public val conditionValue: PseudoValue?) : AbstractJumpInstruction(element, targetLabel, lexicalScope) {
+ private var _nextOnTrue: Instruction? = null
+ private var _nextOnFalse: Instruction? = null
+
+ public var nextOnTrue: Instruction
+ get() = _nextOnTrue!!
+ set(value: Instruction) {
+ _nextOnTrue = outgoingEdgeTo(value)
+ }
+
+ public var nextOnFalse: Instruction
+ get() = _nextOnFalse!!
+ set(value: Instruction) {
+ _nextOnFalse = outgoingEdgeTo(value)
+ }
+
+ override val nextInstructions: Collection
+ get() = Arrays.asList(nextOnFalse, nextOnTrue)
+
+ override val inputValues: List
+ get() = ContainerUtil.createMaybeSingletonList(conditionValue)
+
+ override fun accept(visitor: InstructionVisitor) {
+ visitor.visitConditionalJump(this)
+ }
+
+ override fun accept(visitor: InstructionVisitorWithResult): R {
+ return visitor.visitConditionalJump(this)
+ }
+
+ override fun toString(): String {
+ val instr = if (onTrue) "jt" else "jf"
+ val inValue = conditionValue?.let { "|" + it } ?: ""
+ return "$instr(${targetLabel.getName()}$inValue)"
+ }
+
+ override fun createCopy(newLabel: Label, lexicalScope: LexicalScope): AbstractJumpInstruction =
+ ConditionalJumpInstruction(element, onTrue, lexicalScope, newLabel, conditionValue)
+}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/Instruction.java b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/Instruction.java
deleted file mode 100644
index 8542743517d..00000000000
--- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/Instruction.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2010-2013 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;
-
-import kotlin.jvm.KotlinSignature;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import org.jetbrains.annotations.ReadOnly;
-
-import java.util.Collection;
-import java.util.List;
-
-public interface Instruction {
- @NotNull
- Pseudocode getOwner();
-
- void setOwner(@NotNull Pseudocode owner);
-
- @NotNull
- Collection getPreviousInstructions();
-
- @NotNull
- Collection getNextInstructions();
-
- void accept(@NotNull InstructionVisitor visitor);
- R accept(@NotNull InstructionVisitorWithResult visitor);
-
- @NotNull
- Collection getCopies();
-
- @NotNull
- LexicalScope getLexicalScope();
-
- @ReadOnly
- @NotNull
- List getInputValues();
-
- @Nullable
- PseudoValue getOutputValue();
-}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/Instruction.kt b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/Instruction.kt
new file mode 100644
index 00000000000..a063fc7c66c
--- /dev/null
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/Instruction.kt
@@ -0,0 +1,38 @@
+/*
+ * 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
+
+import kotlin.jvm.KotlinSignature
+import org.jetbrains.annotations.Nullable
+import org.jetbrains.annotations.ReadOnly
+
+public trait Instruction {
+ public var owner: Pseudocode
+
+ public val previousInstructions: MutableCollection
+ public val nextInstructions: Collection
+
+ public val lexicalScope: LexicalScope
+
+ public val inputValues: List
+ public val outputValue: PseudoValue?
+
+ public fun getCopies(): Collection
+
+ public fun accept(visitor: InstructionVisitor)
+ public fun accept(visitor: InstructionVisitorWithResult): R
+}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/InstructionImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/InstructionImpl.java
deleted file mode 100644
index 2e3ea71e9ce..00000000000
--- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/InstructionImpl.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright 2010-2013 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;
-
-import com.google.common.collect.Sets;
-import kotlin.jvm.KotlinSignature;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedHashSet;
-import java.util.List;
-
-public abstract class InstructionImpl implements Instruction {
- private Pseudocode owner;
- private final Collection previousInstructions = new LinkedHashSet();
- private final Collection copies = Sets.newHashSet();
- @NotNull
- protected final LexicalScope lexicalScope;
- private Instruction original;
- protected boolean isDead = false;
-
- protected InstructionImpl(@NotNull LexicalScope lexicalScope) {
- this.lexicalScope = lexicalScope;
- }
-
- @Override
- @NotNull
- public Pseudocode getOwner() {
- return owner;
- }
-
- @Override
- public void setOwner(@NotNull Pseudocode owner) {
- assert this.owner == null || this.owner == owner;
- this.owner = owner;
- }
-
- @NotNull
- @Override
- public Collection getPreviousInstructions() {
- return previousInstructions;
- }
-
- @Nullable
- protected Instruction outgoingEdgeTo(@Nullable Instruction target) {
- if (target != null) {
- target.getPreviousInstructions().add(this);
- }
- return target;
- }
-
- public void die() {
- isDead = true;
- }
-
- public boolean isDead() {
- return isDead;
- }
-
- public final Instruction copy() {
- return updateCopyInfo(createCopy());
- }
-
- @NotNull
- protected abstract Instruction createCopy();
-
- @NotNull
- @Override
- public Collection getCopies() {
- if (original != null) {
- Collection originalCopies = Sets.newHashSet(original.getCopies());
- originalCopies.remove(this);
- originalCopies.add(original);
- return originalCopies;
- }
- return copies;
- }
-
- private void addCopy(@NotNull Instruction instruction) {
- copies.add(instruction);
- }
-
- private void setOriginal(@NotNull Instruction original) {
- assert this.original == null :
- "Instruction can't have two originals: this.original = " + this.original + "; new original = " + original;
- this.original = original;
- }
-
- @NotNull
- @Override
- public LexicalScope getLexicalScope() {
- return lexicalScope;
- }
-
- protected Instruction updateCopyInfo(@NotNull Instruction instruction) {
- addCopy(instruction);
- ((InstructionImpl)instruction).setOriginal(this);
- return instruction;
- }
-
- @NotNull
- @Override
- public List getInputValues() {
- return Collections.emptyList();
- }
-
- @Nullable
- @Override
- public PseudoValue getOutputValue() {
- return null;
- }
-}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/InstructionImpl.kt b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/InstructionImpl.kt
new file mode 100644
index 00000000000..522a7e08d67
--- /dev/null
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/InstructionImpl.kt
@@ -0,0 +1,80 @@
+/*
+ * 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
+
+import java.util.Collections
+import java.util.LinkedHashSet
+import java.util.HashSet
+import com.google.common.collect.Sets
+
+public abstract class InstructionImpl(public override val lexicalScope: LexicalScope): Instruction {
+ private var _owner: Pseudocode? = null
+ private val _copies = HashSet()
+ private var original: Instruction? = null
+ protected var _dead: Boolean = false
+
+ private fun setOriginalInstruction(value: Instruction?) {
+ assert(original == null) { "Instruction can't have two originals: this.original = ${original}; new original = $this" }
+ original = value
+ }
+
+ protected fun outgoingEdgeTo(target: Instruction?): Instruction? {
+ if (target != null) {
+ target.previousInstructions.add(this)
+ }
+ return target
+ }
+
+ protected fun updateCopyInfo(instruction: InstructionImpl): Instruction {
+ _copies.add(instruction)
+ instruction.setOriginalInstruction(this)
+ return instruction
+ }
+
+ protected abstract fun createCopy(): InstructionImpl
+
+ public fun die() {
+ _dead = true
+ }
+
+ public val dead: Boolean get() = _dead
+
+ public fun copy(): Instruction {
+ return updateCopyInfo(createCopy())
+ }
+
+ override var owner: Pseudocode
+ get() = _owner!!
+ set(value: Pseudocode) {
+ assert(_owner == null || _owner == value)
+ _owner = value
+ }
+
+ override val previousInstructions: MutableCollection = LinkedHashSet()
+
+ override val inputValues: List = Collections.emptyList()
+ override val outputValue: PseudoValue? = null
+
+ override fun getCopies(): Collection {
+ return original?.let { original ->
+ val originalCopies = Sets.newHashSet(original.getCopies())
+ originalCopies.remove(this)
+ originalCopies.add(original)
+ originalCopies
+ } ?: _copies
+ }
+}
\ No newline at end of file
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/InstructionVisitor.java b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/InstructionVisitor.java
deleted file mode 100644
index 206c5abc4d5..00000000000
--- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/InstructionVisitor.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright 2010-2013 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;
-
-public class InstructionVisitor {
- public void visitInstructionWithReceiver(InstructionWithReceiver instruction) {
- visitInstructionWithNext(instruction);
- }
-
- public void visitReadValue(ReadValueInstruction instruction) {
- visitInstructionWithReceiver(instruction);
- }
-
- public void visitLocalFunctionDeclarationInstruction(LocalFunctionDeclarationInstruction instruction) {
- visitInstructionWithNext(instruction);
- }
-
- public void visitVariableDeclarationInstruction(VariableDeclarationInstruction instruction) {
- visitInstructionWithNext(instruction);
- }
-
- public void visitUnconditionalJump(UnconditionalJumpInstruction instruction) {
- visitJump(instruction);
- }
-
- public void visitConditionalJump(ConditionalJumpInstruction instruction) {
- visitJump(instruction);
- }
-
- public void visitReturnValue(ReturnValueInstruction instruction) {
- visitJump(instruction);
- }
-
- public void visitReturnNoValue(ReturnNoValueInstruction instruction) {
- visitJump(instruction);
- }
-
- public void visitThrowExceptionInstruction(ThrowExceptionInstruction instruction) {
- visitJump(instruction);
- }
-
- public void visitNondeterministicJump(NondeterministicJumpInstruction instruction) {
- visitInstruction(instruction);
- }
-
- public void visitUnsupportedElementInstruction(UnsupportedElementInstruction instruction) {
- visitInstructionWithNext(instruction);
- }
-
- public void visitSubroutineExit(SubroutineExitInstruction instruction) {
- visitInstruction(instruction);
- }
-
- public void visitSubroutineSink(SubroutineSinkInstruction instruction) {
- visitInstruction(instruction);
- }
-
- public void visitJump(AbstractJumpInstruction instruction) {
- visitInstruction(instruction);
- }
-
- public void visitInstructionWithNext(InstructionWithNext instruction) {
- visitInstruction(instruction);
- }
-
- public void visitInstruction(Instruction instruction) {
- }
-
- public void visitSubroutineEnter(SubroutineEnterInstruction instruction) {
- visitInstructionWithNext(instruction);
- }
-
- public void visitWriteValue(WriteValueInstruction instruction) {
- visitInstructionWithReceiver(instruction);
- }
-
- public void visitLoadUnitValue(LoadUnitValueInstruction instruction) {
- visitInstructionWithNext(instruction);
- }
-
- public void visitOperation(OperationInstruction instruction) {
- visitInstructionWithNext(instruction);
- }
-
- public void visitCallInstruction(CallInstruction instruction) {
- visitOperation(instruction);
- }
-
- public void visitCompilationErrorInstruction(CompilationErrorInstruction instruction) {
- visitInstructionWithNext(instruction);
- }
-
- public void visitMarkInstruction(MarkInstruction instruction) {
- visitInstructionWithNext(instruction);
- }
-
- public void visitMagic(MagicInstruction instruction) {
- visitOperation(instruction);
- }
-}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/InstructionVisitor.kt b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/InstructionVisitor.kt
new file mode 100644
index 00000000000..97be10a594a
--- /dev/null
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/InstructionVisitor.kt
@@ -0,0 +1,114 @@
+/*
+ * 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
+
+public open class InstructionVisitor() {
+ public open fun visitInstructionWithReceiver(instruction: InstructionWithReceiver) {
+ visitInstructionWithNext(instruction)
+ }
+
+ public open fun visitReadValue(instruction: ReadValueInstruction) {
+ visitInstructionWithReceiver(instruction)
+ }
+
+ public open fun visitLocalFunctionDeclarationInstruction(instruction: LocalFunctionDeclarationInstruction) {
+ visitInstructionWithNext(instruction)
+ }
+
+ public open fun visitVariableDeclarationInstruction(instruction: VariableDeclarationInstruction) {
+ visitInstructionWithNext(instruction)
+ }
+
+ public open fun visitUnconditionalJump(instruction: UnconditionalJumpInstruction) {
+ visitJump(instruction)
+ }
+
+ public open fun visitConditionalJump(instruction: ConditionalJumpInstruction) {
+ visitJump(instruction)
+ }
+
+ public open fun visitReturnValue(instruction: ReturnValueInstruction) {
+ visitJump(instruction)
+ }
+
+ public open fun visitReturnNoValue(instruction: ReturnNoValueInstruction) {
+ visitJump(instruction)
+ }
+
+ public open fun visitThrowExceptionInstruction(instruction: ThrowExceptionInstruction) {
+ visitJump(instruction)
+ }
+
+ public open fun visitNondeterministicJump(instruction: NondeterministicJumpInstruction) {
+ visitInstruction(instruction)
+ }
+
+ public open fun visitUnsupportedElementInstruction(instruction: UnsupportedElementInstruction) {
+ visitInstructionWithNext(instruction)
+ }
+
+ public open fun visitSubroutineExit(instruction: SubroutineExitInstruction) {
+ visitInstruction(instruction)
+ }
+
+ public open fun visitSubroutineSink(instruction: SubroutineSinkInstruction) {
+ visitInstruction(instruction)
+ }
+
+ public open fun visitJump(instruction: AbstractJumpInstruction) {
+ visitInstruction(instruction)
+ }
+
+ public open fun visitInstructionWithNext(instruction: InstructionWithNext) {
+ visitInstruction(instruction)
+ }
+
+ public open fun visitInstruction(instruction: Instruction) {
+ }
+
+ public open fun visitSubroutineEnter(instruction: SubroutineEnterInstruction) {
+ visitInstructionWithNext(instruction)
+ }
+
+ public open fun visitWriteValue(instruction: WriteValueInstruction) {
+ visitInstructionWithReceiver(instruction)
+ }
+
+ public open fun visitLoadUnitValue(instruction: LoadUnitValueInstruction) {
+ visitInstructionWithNext(instruction)
+ }
+
+ public open fun visitOperation(instruction: OperationInstruction) {
+ visitInstructionWithNext(instruction)
+ }
+
+ public open fun visitCallInstruction(instruction: CallInstruction) {
+ visitOperation(instruction)
+ }
+
+ public open fun visitCompilationErrorInstruction(instruction: CompilationErrorInstruction) {
+ visitInstructionWithNext(instruction)
+ }
+
+ public open fun visitMarkInstruction(instruction: MarkInstruction) {
+ visitInstructionWithNext(instruction)
+ }
+
+ public open fun visitMagic(instruction: MagicInstruction) {
+ visitOperation(instruction)
+ }
+}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/InstructionVisitorWithResult.java b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/InstructionVisitorWithResult.java
deleted file mode 100644
index 2f40805daf7..00000000000
--- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/InstructionVisitorWithResult.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright 2010-2013 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;
-
-public abstract class InstructionVisitorWithResult {
- public abstract R visitInstruction(Instruction instruction);
-
- public R visitInstructionWithReceiver(InstructionWithReceiver instruction) {
- return visitInstructionWithNext(instruction);
- }
-
- public R visitReadValue(ReadValueInstruction instruction) {
- return visitInstructionWithReceiver(instruction);
- }
-
- public R visitLocalFunctionDeclarationInstruction(LocalFunctionDeclarationInstruction instruction) {
- return visitInstructionWithNext(instruction);
- }
-
- public R visitVariableDeclarationInstruction(VariableDeclarationInstruction instruction) {
- return visitInstructionWithNext(instruction);
- }
-
- public R visitUnconditionalJump(UnconditionalJumpInstruction instruction) {
- return visitJump(instruction);
- }
-
- public R visitConditionalJump(ConditionalJumpInstruction instruction) {
- return visitJump(instruction);
- }
-
- public R visitReturnValue(ReturnValueInstruction instruction) {
- return visitJump(instruction);
- }
-
- public R visitReturnNoValue(ReturnNoValueInstruction instruction) {
- return visitJump(instruction);
- }
-
- public R visitThrowExceptionInstruction(ThrowExceptionInstruction instruction) {
- return visitJump(instruction);
- }
-
- public R visitNondeterministicJump(NondeterministicJumpInstruction instruction) {
- return visitInstruction(instruction);
- }
-
- public R visitUnsupportedElementInstruction(UnsupportedElementInstruction instruction) {
- return visitInstructionWithNext(instruction);
- }
-
- public R visitSubroutineExit(SubroutineExitInstruction instruction) {
- return visitInstruction(instruction);
- }
-
- public R visitSubroutineSink(SubroutineSinkInstruction instruction) {
- return visitInstruction(instruction);
- }
-
- public R visitJump(AbstractJumpInstruction instruction) {
- return visitInstruction(instruction);
- }
-
- public R visitInstructionWithNext(InstructionWithNext instruction) {
- return visitInstruction(instruction);
- }
-
- public R visitSubroutineEnter(SubroutineEnterInstruction instruction) {
- return visitInstructionWithNext(instruction);
- }
-
- public R visitWriteValue(WriteValueInstruction instruction) {
- return visitInstructionWithReceiver(instruction);
- }
-
- public R visitLoadUnitValue(LoadUnitValueInstruction instruction) {
- return visitInstructionWithNext(instruction);
- }
-
- public R visitOperation(OperationInstruction instruction) {
- return visitInstructionWithNext(instruction);
- }
-
- public R visitCallInstruction(CallInstruction instruction) {
- return visitOperation(instruction);
- }
-
- public R visitCompilationErrorInstruction(CompilationErrorInstruction instruction) {
- return visitInstructionWithNext(instruction);
- }
-
- public R visitMarkInstruction(MarkInstruction instruction) {
- return visitInstructionWithNext(instruction);
- }
-
- public R visitMagic(MagicInstruction instruction) {
- return visitOperation(instruction);
- }
-}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/InstructionVisitorWithResult.kt b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/InstructionVisitorWithResult.kt
new file mode 100644
index 00000000000..f2f4d298b8c
--- /dev/null
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/InstructionVisitorWithResult.kt
@@ -0,0 +1,113 @@
+/*
+ * 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
+
+public abstract class InstructionVisitorWithResult() {
+ public abstract fun visitInstruction(instruction: Instruction): R
+
+ public open fun visitInstructionWithReceiver(instruction: InstructionWithReceiver): R {
+ return visitInstructionWithNext(instruction)
+ }
+
+ public open fun visitReadValue(instruction: ReadValueInstruction): R {
+ return visitInstructionWithReceiver(instruction)
+ }
+
+ public open fun visitLocalFunctionDeclarationInstruction(instruction: LocalFunctionDeclarationInstruction): R {
+ return visitInstructionWithNext(instruction)
+ }
+
+ public open fun visitVariableDeclarationInstruction(instruction: VariableDeclarationInstruction): R {
+ return visitInstructionWithNext(instruction)
+ }
+
+ public open fun visitUnconditionalJump(instruction: UnconditionalJumpInstruction): R {
+ return visitJump(instruction)
+ }
+
+ public open fun visitConditionalJump(instruction: ConditionalJumpInstruction): R {
+ return visitJump(instruction)
+ }
+
+ public open fun visitReturnValue(instruction: ReturnValueInstruction): R {
+ return visitJump(instruction)
+ }
+
+ public open fun visitReturnNoValue(instruction: ReturnNoValueInstruction): R {
+ return visitJump(instruction)
+ }
+
+ public open fun visitThrowExceptionInstruction(instruction: ThrowExceptionInstruction): R {
+ return visitJump(instruction)
+ }
+
+ public open fun visitNondeterministicJump(instruction: NondeterministicJumpInstruction): R {
+ return visitInstruction(instruction)
+ }
+
+ public open fun visitUnsupportedElementInstruction(instruction: UnsupportedElementInstruction): R {
+ return visitInstructionWithNext(instruction)
+ }
+
+ public open fun visitSubroutineExit(instruction: SubroutineExitInstruction): R {
+ return visitInstruction(instruction)
+ }
+
+ public open fun visitSubroutineSink(instruction: SubroutineSinkInstruction): R {
+ return visitInstruction(instruction)
+ }
+
+ public open fun visitJump(instruction: AbstractJumpInstruction): R {
+ return visitInstruction(instruction)
+ }
+
+ public open fun visitInstructionWithNext(instruction: InstructionWithNext): R {
+ return visitInstruction(instruction)
+ }
+
+ public open fun visitSubroutineEnter(instruction: SubroutineEnterInstruction): R {
+ return visitInstructionWithNext(instruction)
+ }
+
+ public open fun visitWriteValue(instruction: WriteValueInstruction): R {
+ return visitInstructionWithReceiver(instruction)
+ }
+
+ public open fun visitLoadUnitValue(instruction: LoadUnitValueInstruction): R {
+ return visitInstructionWithNext(instruction)
+ }
+
+ public open fun visitOperation(instruction: OperationInstruction): R {
+ return visitInstructionWithNext(instruction)
+ }
+
+ public open fun visitCallInstruction(instruction: CallInstruction): R {
+ return visitOperation(instruction)
+ }
+
+ public open fun visitCompilationErrorInstruction(instruction: CompilationErrorInstruction): R {
+ return visitInstructionWithNext(instruction)
+ }
+
+ public open fun visitMarkInstruction(instruction: MarkInstruction): R {
+ return visitInstructionWithNext(instruction)
+ }
+
+ public open fun visitMagic(instruction: MagicInstruction): R {
+ return visitOperation(instruction)
+ }
+}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/InstructionWithNext.java b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/InstructionWithNext.java
deleted file mode 100644
index b7f7eed227d..00000000000
--- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/InstructionWithNext.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2010-2013 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;
-
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.jet.lang.psi.JetElement;
-
-import java.util.Collection;
-import java.util.Collections;
-
-public abstract class InstructionWithNext extends JetElementInstructionImpl {
- private Instruction next;
-
- protected InstructionWithNext(@NotNull JetElement element, @NotNull LexicalScope lexicalScope) {
- super(element, lexicalScope);
- }
-
- public Instruction getNext() {
- return next;
- }
-
- @NotNull
- @Override
- public Collection getNextInstructions() {
- return Collections.singleton(next);
- }
-
- public void setNext(Instruction next) {
- this.next = outgoingEdgeTo(next);
- }
-}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/InstructionWithNext.kt b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/InstructionWithNext.kt
new file mode 100644
index 00000000000..dcf1757d50f
--- /dev/null
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/InstructionWithNext.kt
@@ -0,0 +1,34 @@
+/*
+ * 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
+
+import org.jetbrains.jet.lang.psi.JetElement
+import java.util.Collections
+import com.intellij.util.containers.ContainerUtil
+
+public abstract class InstructionWithNext(
+ element: JetElement,
+ lexicalScope: LexicalScope
+) : JetElementInstructionImpl(element, lexicalScope) {
+ public var next: Instruction? = null
+ set(value: Instruction?) {
+ $next = outgoingEdgeTo(value)
+ }
+
+ override val nextInstructions: Collection
+ get() = ContainerUtil.createMaybeSingletonList(next)
+}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/InstructionWithReceiver.java b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/InstructionWithReceiver.java
deleted file mode 100644
index f7ee90afa2d..00000000000
--- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/InstructionWithReceiver.java
+++ /dev/null
@@ -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;/**/
-
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import org.jetbrains.jet.lang.psi.JetElement;
-
-import java.util.Collections;
-import java.util.List;
-
-public abstract class InstructionWithReceiver extends InstructionWithNext {
- protected final PseudoValue receiverValue;
-
- public InstructionWithReceiver(
- @NotNull JetElement element,
- @NotNull LexicalScope lexicalScope,
- @Nullable PseudoValue receiverValue) {
- super(element, lexicalScope);
- this.receiverValue = receiverValue;
- }
-
- @NotNull
- @Override
- public List getInputValues() {
- return receiverValue != null ? Collections.singletonList(receiverValue) : Collections.emptyList();
- }
-}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/InstructionWithReceiver.kt b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/InstructionWithReceiver.kt
new file mode 100644
index 00000000000..f79b40e2437
--- /dev/null
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/InstructionWithReceiver.kt
@@ -0,0 +1,28 @@
+/*
+ * 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
+
+import org.jetbrains.jet.lang.psi.JetElement
+import com.intellij.util.containers.ContainerUtil
+
+public abstract class InstructionWithReceiver(
+ element: JetElement,
+ lexicalScope: LexicalScope,
+ protected val receiverValue: PseudoValue?
+) : InstructionWithNext(element, lexicalScope) {
+ override val inputValues: List = ContainerUtil.createMaybeSingletonList(receiverValue)
+}
\ No newline at end of file
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/JetControlFlowInstructionsGenerator.java b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/JetControlFlowInstructionsGenerator.java
index 1ec4f62a45e..b2cdba1147d 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/JetControlFlowInstructionsGenerator.java
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/JetControlFlowInstructionsGenerator.java
@@ -28,10 +28,7 @@ import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAdapter {
private JetControlFlowBuilder builder = null;
@@ -352,7 +349,7 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
@Override
public void nondeterministicJump(@NotNull Label label, @NotNull JetElement element, @Nullable PseudoValue inputValue) {
handleJumpInsideTryFinally(label);
- add(new NondeterministicJumpInstruction(element, label, getCurrentScope(), inputValue));
+ add(new NondeterministicJumpInstruction(element, Collections.singletonList(label), getCurrentScope(), inputValue));
}
@Override
@@ -485,7 +482,8 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
@NotNull
private PseudoValue read(@NotNull JetExpression expression, @Nullable PseudoValue receiverValue) {
- ReadValueInstruction instruction = new ReadValueInstruction(expression, getCurrentScope(), receiverValue, valueFactory);
+ ReadValueInstruction instruction =
+ ReadValueInstruction.object$.create(expression, getCurrentScope(), receiverValue, valueFactory);
add(instruction);
return instruction.getOutputValue();
}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/JetElementInstruction.java b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/JetElementInstruction.kt
similarity index 67%
rename from compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/JetElementInstruction.java
rename to compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/JetElementInstruction.kt
index e35c99112d9..8457a90b189 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/JetElementInstruction.java
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/JetElementInstruction.kt
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2013 JetBrains s.r.o.
+ * 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.
@@ -14,12 +14,10 @@
* limitations under the License.
*/
-package org.jetbrains.jet.lang.cfg.pseudocode;
+package org.jetbrains.jet.lang.cfg.pseudocode
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.jet.lang.psi.JetElement;
+import org.jetbrains.jet.lang.psi.JetElement
-public interface JetElementInstruction extends Instruction {
- @NotNull
- JetElement getElement();
+public trait JetElementInstruction : Instruction {
+ public val element: JetElement
}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/JetElementInstructionImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/JetElementInstructionImpl.java
deleted file mode 100644
index c0ffeb11c33..00000000000
--- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/JetElementInstructionImpl.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2010-2013 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;
-
-import com.intellij.psi.PsiElement;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.jet.lang.psi.JetElement;
-
-public abstract class JetElementInstructionImpl extends InstructionImpl implements JetElementInstruction {
- @NotNull
- protected final JetElement element;
-
- public JetElementInstructionImpl(@NotNull JetElement element, LexicalScope lexicalScope) {
- super(lexicalScope);
- this.element = element;
- }
-
- @NotNull
- @Override
- public JetElement getElement() {
- return element;
- }
-
- @NotNull
- protected String render(PsiElement element) {
- return element.getText().replaceAll("\\s+", " ");
- }
-}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/JetElementInstructionImpl.kt b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/JetElementInstructionImpl.kt
new file mode 100644
index 00000000000..0be12a3ef17
--- /dev/null
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/JetElementInstructionImpl.kt
@@ -0,0 +1,28 @@
+/*
+ * 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
+
+import com.intellij.psi.PsiElement
+import org.jetbrains.jet.lang.psi.JetElement
+
+public abstract class JetElementInstructionImpl(
+ public override val element: JetElement,
+ lexicalScope: LexicalScope
+) : InstructionImpl(lexicalScope), JetElementInstruction {
+ protected fun render(element: PsiElement): String =
+ element.getText()?.replaceAll("\\s+", " ") ?: ""
+}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/JumpInstruction.java b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/JumpInstruction.kt
similarity index 84%
rename from compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/JumpInstruction.java
rename to compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/JumpInstruction.kt
index 7c4e1c60e0b..55cb198d9ec 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/JumpInstruction.java
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/JumpInstruction.kt
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-package org.jetbrains.jet.lang.cfg.pseudocode;/**/
+package org.jetbrains.jet.lang.cfg.pseudocode
-public interface JumpInstruction extends Instruction {
-}
+public trait JumpInstruction : Instruction
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/LoadUnitValueInstruction.java b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/LoadUnitValueInstruction.java
deleted file mode 100644
index 5e2e8389473..00000000000
--- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/LoadUnitValueInstruction.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 2010-2013 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;
-
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.jet.lang.psi.JetExpression;
-
-public class LoadUnitValueInstruction extends InstructionWithNext {
-
- public LoadUnitValueInstruction(@NotNull JetExpression expression, LexicalScope lexicalScope) {
- super(expression, lexicalScope);
- }
-
- @Override
- public void accept(InstructionVisitor visitor) {
- visitor.visitLoadUnitValue(this);
- }
-
- @Override
- public R accept(@NotNull InstructionVisitorWithResult visitor) {
- return visitor.visitLoadUnitValue(this);
- }
-
- @Override
- public String toString() {
- return "read (Unit)";
- }
-
- @NotNull
- @Override
- protected Instruction createCopy() {
- return new LoadUnitValueInstruction((JetExpression) element, lexicalScope);
- }
-}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/LoadUnitValueInstruction.kt b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/LoadUnitValueInstruction.kt
new file mode 100644
index 00000000000..07ae36c789a
--- /dev/null
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/LoadUnitValueInstruction.kt
@@ -0,0 +1,38 @@
+/*
+ * 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
+
+import org.jetbrains.jet.lang.psi.JetExpression
+
+public class LoadUnitValueInstruction(
+ expression: JetExpression,
+ lexicalScope: LexicalScope
+) : InstructionWithNext(expression, lexicalScope) {
+ override fun accept(visitor: InstructionVisitor) {
+ visitor.visitLoadUnitValue(this)
+ }
+
+ override fun accept(visitor: InstructionVisitorWithResult): R {
+ return visitor.visitLoadUnitValue(this)
+ }
+
+ override fun toString(): String =
+ "read (Unit)"
+
+ override fun createCopy(): InstructionImpl =
+ LoadUnitValueInstruction(element as JetExpression, lexicalScope)
+}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/LocalFunctionDeclarationInstruction.java b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/LocalFunctionDeclarationInstruction.java
deleted file mode 100644
index 954914bab9c..00000000000
--- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/LocalFunctionDeclarationInstruction.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright 2010-2013 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;
-
-import com.google.common.collect.Lists;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.jet.lang.psi.JetElement;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-public class LocalFunctionDeclarationInstruction extends InstructionWithNext {
-
- private final Pseudocode body;
- private Instruction sink;
-
- public LocalFunctionDeclarationInstruction(@NotNull JetElement element, @NotNull Pseudocode body, LexicalScope lexicalScope) {
- super(element, lexicalScope);
- this.body = body;
- }
-
- @NotNull
- public Pseudocode getBody() {
- return body;
- }
-
- @NotNull
- @Override
- public Collection getNextInstructions() {
- if (sink != null) {
- ArrayList instructions = Lists.newArrayList(sink);
- instructions.addAll(super.getNextInstructions());
- return instructions;
- }
- return super.getNextInstructions();
- }
-
- public void setSink(SubroutineSinkInstruction sink) {
- this.sink = outgoingEdgeTo(sink);
- }
-
- @Override
- public void accept(@NotNull InstructionVisitor visitor) {
- visitor.visitLocalFunctionDeclarationInstruction(this);
- }
-
- @Override
- public R accept(@NotNull InstructionVisitorWithResult visitor) {
- return visitor.visitLocalFunctionDeclarationInstruction(this);
- }
-
- @Override
- public String toString() {
- return "d" + "(" + render(element) + ")";
- }
-
- @NotNull
- @Override
- protected Instruction createCopy() {
- return new LocalFunctionDeclarationInstruction(element, body, lexicalScope);
- }
-}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/LocalFunctionDeclarationInstruction.kt b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/LocalFunctionDeclarationInstruction.kt
new file mode 100644
index 00000000000..df468cf6bda
--- /dev/null
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/LocalFunctionDeclarationInstruction.kt
@@ -0,0 +1,55 @@
+/*
+ * 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
+
+import com.google.common.collect.Lists
+import org.jetbrains.jet.lang.psi.JetElement
+import java.util.ArrayList
+
+public class LocalFunctionDeclarationInstruction(
+ element: JetElement,
+ public val body: Pseudocode,
+ lexicalScope: LexicalScope
+) : InstructionWithNext(element, lexicalScope) {
+ public var sink: SubroutineSinkInstruction? = null
+ set(value: SubroutineSinkInstruction?) {
+ $sink = outgoingEdgeTo(value) as SubroutineSinkInstruction?
+ }
+
+ override val nextInstructions: Collection
+ get() {
+ if (sink != null) {
+ val instructions = Lists.newArrayList(sink)
+ instructions.addAll(super.nextInstructions)
+ return instructions
+ }
+ return super.nextInstructions
+ }
+
+ override fun accept(visitor: InstructionVisitor) {
+ visitor.visitLocalFunctionDeclarationInstruction(this)
+ }
+
+ override fun accept(visitor: InstructionVisitorWithResult): R {
+ return visitor.visitLocalFunctionDeclarationInstruction(this)
+ }
+
+ override fun toString(): String = "d(${render(element)})"
+
+ override fun createCopy(): InstructionImpl =
+ LocalFunctionDeclarationInstruction(element, body, lexicalScope)
+}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/MarkInstruction.kt b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/MarkInstruction.kt
new file mode 100644
index 00000000000..e13e6086be8
--- /dev/null
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/MarkInstruction.kt
@@ -0,0 +1,40 @@
+/*
+ * 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
+
+import org.jetbrains.jet.lang.psi.JetElement
+
+// This instruciton is used to let the dead code detector know the syntactic structure of unreachable code
+// otherwise only individual parts of expression would be reported as unreachable
+// e.g. for (i in foo) {} -- only i and foo would be marked unreachable
+public class MarkInstruction(
+ element: JetElement,
+ lexicalScope: LexicalScope
+) : InstructionWithNext(element, lexicalScope) {
+
+ override fun accept(visitor: InstructionVisitor) {
+ visitor.visitMarkInstruction(this)
+ }
+
+ override fun accept(visitor: InstructionVisitorWithResult): R {
+ return visitor.visitMarkInstruction(this)
+ }
+
+ override fun createCopy() = MarkInstruction(element, lexicalScope)
+
+ override fun toString() = "mark(${render(element)})"
+}
\ No newline at end of file
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/NondeterministicJumpInstruction.java b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/NondeterministicJumpInstruction.java
deleted file mode 100644
index 92046b408ab..00000000000
--- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/NondeterministicJumpInstruction.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright 2010-2013 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;
-
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import org.jetbrains.jet.lang.cfg.Label;
-import org.jetbrains.jet.lang.psi.JetElement;
-
-import java.util.*;
-
-public class NondeterministicJumpInstruction extends JetElementInstructionImpl implements JumpInstruction {
- private Instruction next;
- private final List