BreakableBlockInfo : converted to Kotlin
(cherry picked from commit 22c7ee5)
This commit is contained in:
committed by
Mikhail Glukhikh
parent
d4c40d9db0
commit
d33745b646
@@ -14,44 +14,20 @@
|
||||
* 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.Set;
|
||||
import java.util.Collections
|
||||
|
||||
public abstract class BreakableBlockInfo extends BlockInfo {
|
||||
private final KtElement element;
|
||||
private final Label entryPoint;
|
||||
private final Label exitPoint;
|
||||
private final Set<Label> referablePoints = Sets.newHashSet();
|
||||
abstract class BreakableBlockInfo(open val element: KtElement, val entryPoint: Label, val exitPoint: Label) : BlockInfo() {
|
||||
val referablePoints: MutableSet<Label> = hashSetOf()
|
||||
|
||||
public BreakableBlockInfo(KtElement element, Label entryPoint, Label exitPoint) {
|
||||
this.element = element;
|
||||
this.entryPoint = entryPoint;
|
||||
this.exitPoint = exitPoint;
|
||||
markReferablePoints(entryPoint, exitPoint);
|
||||
init {
|
||||
markReferablePoints(entryPoint, exitPoint)
|
||||
}
|
||||
|
||||
protected void markReferablePoints(Label... 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;
|
||||
protected fun markReferablePoints(vararg labels: Label) {
|
||||
Collections.addAll(referablePoints, *labels)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,19 +19,15 @@ package org.jetbrains.kotlin.cfg
|
||||
import org.jetbrains.kotlin.psi.KtLoopExpression
|
||||
|
||||
class LoopInfo(
|
||||
loopExpression: KtLoopExpression,
|
||||
override val element: KtLoopExpression,
|
||||
entryPoint: Label,
|
||||
exitPoint: Label,
|
||||
val bodyEntryPoint: Label,
|
||||
val bodyExitPoint: Label,
|
||||
val conditionEntryPoint: Label
|
||||
) : BreakableBlockInfo(loopExpression, entryPoint, exitPoint) {
|
||||
) : BreakableBlockInfo(element, entryPoint, exitPoint) {
|
||||
|
||||
init {
|
||||
markReferablePoints(bodyEntryPoint, bodyExitPoint, conditionEntryPoint)
|
||||
}
|
||||
|
||||
override fun getElement(): KtLoopExpression {
|
||||
return super.getElement() as KtLoopExpression
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user