CFG: break and continue are now handled in the same (safe) way EA-85060 Fixed
(cherry picked from commit eec4b1b)
This commit is contained in:
committed by
Mikhail Glukhikh
parent
d33745b646
commit
ea041661fb
@@ -40,7 +40,7 @@ interface ControlFlowBuilder {
|
|||||||
fun exitBlockScope(block: KtElement)
|
fun exitBlockScope(block: KtElement)
|
||||||
|
|
||||||
fun getSubroutineExitPoint(labelElement: KtElement): Label?
|
fun getSubroutineExitPoint(labelElement: KtElement): Label?
|
||||||
fun getLoopConditionEntryPoint(loop: KtLoopExpression): Label
|
fun getLoopConditionEntryPoint(loop: KtLoopExpression): Label?
|
||||||
fun getLoopExitPoint(loop: KtLoopExpression): Label?
|
fun getLoopExitPoint(loop: KtLoopExpression): Label?
|
||||||
|
|
||||||
// Declarations
|
// Declarations
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ abstract class ControlFlowBuilderAdapter : ControlFlowBuilder {
|
|||||||
return delegateBuilder.getSubroutineExitPoint(labelElement)
|
return delegateBuilder.getSubroutineExitPoint(labelElement)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getLoopConditionEntryPoint(loop: KtLoopExpression): Label {
|
override fun getLoopConditionEntryPoint(loop: KtLoopExpression): Label? {
|
||||||
return delegateBuilder.getLoopConditionEntryPoint(loop)
|
return delegateBuilder.getLoopConditionEntryPoint(loop)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -806,7 +806,7 @@ class ControlFlowProcessor(private val trace: BindingTrace) {
|
|||||||
val loop = getCorrespondingLoop(expression)
|
val loop = getCorrespondingLoop(expression)
|
||||||
if (loop != null) {
|
if (loop != null) {
|
||||||
if (jumpDoesNotCrossFunctionBoundary(expression, loop)) {
|
if (jumpDoesNotCrossFunctionBoundary(expression, loop)) {
|
||||||
builder.jump(builder.getLoopConditionEntryPoint(loop), expression)
|
builder.getLoopConditionEntryPoint(loop)?.let { builder.jump(it, expression) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-3
@@ -166,9 +166,8 @@ class ControlFlowInstructionsGenerator : ControlFlowBuilderAdapter() {
|
|||||||
override val currentSubroutine: KtElement
|
override val currentSubroutine: KtElement
|
||||||
get() = pseudocode.correspondingElement
|
get() = pseudocode.correspondingElement
|
||||||
|
|
||||||
override fun getLoopConditionEntryPoint(loop: KtLoopExpression): Label {
|
override fun getLoopConditionEntryPoint(loop: KtLoopExpression): Label? {
|
||||||
val blockInfo = elementToLoopInfo[loop] ?: error("expected LoopInfo for ${loop.text}")
|
return elementToLoopInfo[loop]?.conditionEntryPoint
|
||||||
return blockInfo.conditionEntryPoint
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getLoopExitPoint(loop: KtLoopExpression): Label? {
|
override fun getLoopExitPoint(loop: KtLoopExpression): Label? {
|
||||||
|
|||||||
Reference in New Issue
Block a user