ForLoopsLowering: Remove additionalNotEmptyCondition as it is no
longer used in UntilHandler.
This commit is contained in:
committed by
Alexander Udalov
parent
ccbf7cc2ee
commit
14137cb013
+1
-14
@@ -128,7 +128,6 @@ private class Transformer(
|
|||||||
val shouldUpperComeFirst: Boolean
|
val shouldUpperComeFirst: Boolean
|
||||||
val useCompareTo: Boolean
|
val useCompareTo: Boolean
|
||||||
val isNumericRange: Boolean
|
val isNumericRange: Boolean
|
||||||
val additionalNotEmptyCondition: IrExpression?
|
|
||||||
val additionalStatements = mutableListOf<IrStatement>()
|
val additionalStatements = mutableListOf<IrStatement>()
|
||||||
|
|
||||||
when (headerInfo) {
|
when (headerInfo) {
|
||||||
@@ -181,7 +180,6 @@ private class Transformer(
|
|||||||
useCompareTo = headerInfo.progressionType is UnsignedProgressionType
|
useCompareTo = headerInfo.progressionType is UnsignedProgressionType
|
||||||
isUpperInclusive = headerInfo.isLastInclusive
|
isUpperInclusive = headerInfo.isLastInclusive
|
||||||
isNumericRange = true
|
isNumericRange = true
|
||||||
additionalNotEmptyCondition = headerInfo.additionalNotEmptyCondition
|
|
||||||
}
|
}
|
||||||
is FloatingPointRangeHeaderInfo -> {
|
is FloatingPointRangeHeaderInfo -> {
|
||||||
lower = headerInfo.start
|
lower = headerInfo.start
|
||||||
@@ -190,7 +188,6 @@ private class Transformer(
|
|||||||
shouldUpperComeFirst = false
|
shouldUpperComeFirst = false
|
||||||
useCompareTo = false
|
useCompareTo = false
|
||||||
isNumericRange = true
|
isNumericRange = true
|
||||||
additionalNotEmptyCondition = null
|
|
||||||
}
|
}
|
||||||
is ComparableRangeInfo -> {
|
is ComparableRangeInfo -> {
|
||||||
lower = headerInfo.start
|
lower = headerInfo.start
|
||||||
@@ -199,7 +196,6 @@ private class Transformer(
|
|||||||
shouldUpperComeFirst = false
|
shouldUpperComeFirst = false
|
||||||
useCompareTo = true
|
useCompareTo = true
|
||||||
isNumericRange = false
|
isNumericRange = false
|
||||||
additionalNotEmptyCondition = null
|
|
||||||
}
|
}
|
||||||
else -> return null
|
else -> return null
|
||||||
}
|
}
|
||||||
@@ -342,16 +338,7 @@ private class Transformer(
|
|||||||
if (useLowerClauseOnLeftSide) lowerClause else upperClause,
|
if (useLowerClauseOnLeftSide) lowerClause else upperClause,
|
||||||
if (useLowerClauseOnLeftSide) upperClause else lowerClause,
|
if (useLowerClauseOnLeftSide) upperClause else lowerClause,
|
||||||
origin
|
origin
|
||||||
).let {
|
)
|
||||||
if (additionalNotEmptyCondition != null) {
|
|
||||||
// Add additional condition, currently used in `until` ranges (see UntilHandler.kt).
|
|
||||||
// NOTE: The additional condition must be on the RIGHT side of the &&, to guarantee that the expressions for the bounds
|
|
||||||
// and argument are evaluated as designed. (See big comment above on expressions with side effects and temp variables.)
|
|
||||||
context.andand(it, additionalNotEmptyCondition)
|
|
||||||
} else {
|
|
||||||
it
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return if (additionalStatements.isEmpty()) {
|
return if (additionalStatements.isEmpty()) {
|
||||||
contains
|
contains
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+3
-8
@@ -70,8 +70,7 @@ internal sealed class NumericHeaderInfo(
|
|||||||
val isLastInclusive: Boolean,
|
val isLastInclusive: Boolean,
|
||||||
val canCacheLast: Boolean,
|
val canCacheLast: Boolean,
|
||||||
val isReversed: Boolean,
|
val isReversed: Boolean,
|
||||||
val direction: ProgressionDirection,
|
val direction: ProgressionDirection
|
||||||
val additionalNotEmptyCondition: IrExpression?
|
|
||||||
) : HeaderInfo()
|
) : HeaderInfo()
|
||||||
|
|
||||||
/** Information about a for-loop over a progression. */
|
/** Information about a for-loop over a progression. */
|
||||||
@@ -84,14 +83,12 @@ internal class ProgressionHeaderInfo(
|
|||||||
isReversed: Boolean = false,
|
isReversed: Boolean = false,
|
||||||
canOverflow: Boolean? = null,
|
canOverflow: Boolean? = null,
|
||||||
direction: ProgressionDirection,
|
direction: ProgressionDirection,
|
||||||
additionalNotEmptyCondition: IrExpression? = null,
|
|
||||||
val additionalStatements: List<IrStatement> = listOf()
|
val additionalStatements: List<IrStatement> = listOf()
|
||||||
) : NumericHeaderInfo(
|
) : NumericHeaderInfo(
|
||||||
progressionType, first, last, step, isLastInclusive,
|
progressionType, first, last, step, isLastInclusive,
|
||||||
canCacheLast = true,
|
canCacheLast = true,
|
||||||
isReversed = isReversed,
|
isReversed = isReversed,
|
||||||
direction = direction,
|
direction = direction
|
||||||
additionalNotEmptyCondition = additionalNotEmptyCondition
|
|
||||||
) {
|
) {
|
||||||
|
|
||||||
val canOverflow: Boolean by lazy {
|
val canOverflow: Boolean by lazy {
|
||||||
@@ -162,7 +159,6 @@ internal class ProgressionHeaderInfo(
|
|||||||
step = step.negate(),
|
step = step.negate(),
|
||||||
isReversed = !isReversed,
|
isReversed = !isReversed,
|
||||||
direction = direction.asReversed(),
|
direction = direction.asReversed(),
|
||||||
additionalNotEmptyCondition = additionalNotEmptyCondition,
|
|
||||||
additionalStatements = additionalStatements
|
additionalStatements = additionalStatements
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
@@ -189,8 +185,7 @@ internal class IndexedGetHeaderInfo(
|
|||||||
isLastInclusive = false,
|
isLastInclusive = false,
|
||||||
canCacheLast = canCacheLast,
|
canCacheLast = canCacheLast,
|
||||||
isReversed = false,
|
isReversed = false,
|
||||||
direction = ProgressionDirection.INCREASING,
|
direction = ProgressionDirection.INCREASING
|
||||||
additionalNotEmptyCondition = null
|
|
||||||
) {
|
) {
|
||||||
// Technically one can easily iterate over an array in reverse by swapping first/last and
|
// Technically one can easily iterate over an array in reverse by swapping first/last and
|
||||||
// negating the step. However, Array.reversed() and Array.reversedArray() return a collection
|
// negating the step. However, Array.reversed() and Array.reversedArray() return a collection
|
||||||
|
|||||||
+1
-4
@@ -346,10 +346,7 @@ internal class ProgressionLoopHeader(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val loopCondition = buildLoopCondition(this@with)
|
val loopCondition = buildLoopCondition(this@with)
|
||||||
// Combine with the additional "not empty" condition, if any.
|
LoopReplacement(newLoop, irIfThen(loopCondition, newLoop))
|
||||||
val notEmptyCheck =
|
|
||||||
irIfThen(headerInfo.additionalNotEmptyCondition?.let { context.andand(it, loopCondition) } ?: loopCondition, newLoop)
|
|
||||||
LoopReplacement(newLoop, notEmptyCheck)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
-1
@@ -277,7 +277,6 @@ internal class StepHandler(
|
|||||||
step = finalStepExpression,
|
step = finalStepExpression,
|
||||||
isReversed = nestedInfo.isReversed,
|
isReversed = nestedInfo.isReversed,
|
||||||
additionalStatements = additionalStatements,
|
additionalStatements = additionalStatements,
|
||||||
additionalNotEmptyCondition = nestedInfo.additionalNotEmptyCondition,
|
|
||||||
direction = nestedInfo.direction
|
direction = nestedInfo.direction
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user