BreakableBlockInfo : converted to Kotlin

(cherry picked from commit 22c7ee5)
This commit is contained in:
Mikhail Glukhikh
2016-08-23 15:09:26 +03:00
committed by Mikhail Glukhikh
parent d4c40d9db0
commit d33745b646
2 changed files with 11 additions and 39 deletions
@@ -14,44 +14,20 @@
* limitations under the License. * limitations under the License.
*/ */
package org.jetbrains.kotlin.cfg; package org.jetbrains.kotlin.cfg
import com.google.common.collect.Sets; import org.jetbrains.kotlin.psi.KtElement
import org.jetbrains.kotlin.psi.KtElement;
import java.util.Collections; import java.util.Collections
import java.util.Set;
public abstract class BreakableBlockInfo extends BlockInfo { abstract class BreakableBlockInfo(open val element: KtElement, val entryPoint: Label, val exitPoint: Label) : BlockInfo() {
private final KtElement element; val referablePoints: MutableSet<Label> = hashSetOf()
private final Label entryPoint;
private final Label exitPoint;
private final Set<Label> referablePoints = Sets.newHashSet();
public BreakableBlockInfo(KtElement element, Label entryPoint, Label exitPoint) { init {
this.element = element; markReferablePoints(entryPoint, exitPoint)
this.entryPoint = entryPoint;
this.exitPoint = exitPoint;
markReferablePoints(entryPoint, exitPoint);
} }
protected void markReferablePoints(Label... labels) { protected fun markReferablePoints(vararg labels: Label) {
Collections.addAll(referablePoints, labels); Collections.addAll(referablePoints, *labels)
}
public KtElement getElement() {
return element;
}
public Label getEntryPoint() {
return entryPoint;
}
public Label getExitPoint() {
return exitPoint;
}
public Set<Label> getReferablePoints() {
return referablePoints;
} }
} }
@@ -19,19 +19,15 @@ package org.jetbrains.kotlin.cfg
import org.jetbrains.kotlin.psi.KtLoopExpression import org.jetbrains.kotlin.psi.KtLoopExpression
class LoopInfo( class LoopInfo(
loopExpression: KtLoopExpression, override val element: KtLoopExpression,
entryPoint: Label, entryPoint: Label,
exitPoint: Label, exitPoint: Label,
val bodyEntryPoint: Label, val bodyEntryPoint: Label,
val bodyExitPoint: Label, val bodyExitPoint: Label,
val conditionEntryPoint: Label val conditionEntryPoint: Label
) : BreakableBlockInfo(loopExpression, entryPoint, exitPoint) { ) : BreakableBlockInfo(element, entryPoint, exitPoint) {
init { init {
markReferablePoints(bodyEntryPoint, bodyExitPoint, conditionEntryPoint) markReferablePoints(bodyEntryPoint, bodyExitPoint, conditionEntryPoint)
} }
override fun getElement(): KtLoopExpression {
return super.getElement() as KtLoopExpression
}
} }