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 useCompareTo: Boolean
|
||||
val isNumericRange: Boolean
|
||||
val additionalNotEmptyCondition: IrExpression?
|
||||
val additionalStatements = mutableListOf<IrStatement>()
|
||||
|
||||
when (headerInfo) {
|
||||
@@ -181,7 +180,6 @@ private class Transformer(
|
||||
useCompareTo = headerInfo.progressionType is UnsignedProgressionType
|
||||
isUpperInclusive = headerInfo.isLastInclusive
|
||||
isNumericRange = true
|
||||
additionalNotEmptyCondition = headerInfo.additionalNotEmptyCondition
|
||||
}
|
||||
is FloatingPointRangeHeaderInfo -> {
|
||||
lower = headerInfo.start
|
||||
@@ -190,7 +188,6 @@ private class Transformer(
|
||||
shouldUpperComeFirst = false
|
||||
useCompareTo = false
|
||||
isNumericRange = true
|
||||
additionalNotEmptyCondition = null
|
||||
}
|
||||
is ComparableRangeInfo -> {
|
||||
lower = headerInfo.start
|
||||
@@ -199,7 +196,6 @@ private class Transformer(
|
||||
shouldUpperComeFirst = false
|
||||
useCompareTo = true
|
||||
isNumericRange = false
|
||||
additionalNotEmptyCondition = null
|
||||
}
|
||||
else -> return null
|
||||
}
|
||||
@@ -342,16 +338,7 @@ private class Transformer(
|
||||
if (useLowerClauseOnLeftSide) lowerClause else upperClause,
|
||||
if (useLowerClauseOnLeftSide) upperClause else lowerClause,
|
||||
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()) {
|
||||
contains
|
||||
} else {
|
||||
|
||||
+3
-8
@@ -70,8 +70,7 @@ internal sealed class NumericHeaderInfo(
|
||||
val isLastInclusive: Boolean,
|
||||
val canCacheLast: Boolean,
|
||||
val isReversed: Boolean,
|
||||
val direction: ProgressionDirection,
|
||||
val additionalNotEmptyCondition: IrExpression?
|
||||
val direction: ProgressionDirection
|
||||
) : HeaderInfo()
|
||||
|
||||
/** Information about a for-loop over a progression. */
|
||||
@@ -84,14 +83,12 @@ internal class ProgressionHeaderInfo(
|
||||
isReversed: Boolean = false,
|
||||
canOverflow: Boolean? = null,
|
||||
direction: ProgressionDirection,
|
||||
additionalNotEmptyCondition: IrExpression? = null,
|
||||
val additionalStatements: List<IrStatement> = listOf()
|
||||
) : NumericHeaderInfo(
|
||||
progressionType, first, last, step, isLastInclusive,
|
||||
canCacheLast = true,
|
||||
isReversed = isReversed,
|
||||
direction = direction,
|
||||
additionalNotEmptyCondition = additionalNotEmptyCondition
|
||||
direction = direction
|
||||
) {
|
||||
|
||||
val canOverflow: Boolean by lazy {
|
||||
@@ -162,7 +159,6 @@ internal class ProgressionHeaderInfo(
|
||||
step = step.negate(),
|
||||
isReversed = !isReversed,
|
||||
direction = direction.asReversed(),
|
||||
additionalNotEmptyCondition = additionalNotEmptyCondition,
|
||||
additionalStatements = additionalStatements
|
||||
)
|
||||
} else {
|
||||
@@ -189,8 +185,7 @@ internal class IndexedGetHeaderInfo(
|
||||
isLastInclusive = false,
|
||||
canCacheLast = canCacheLast,
|
||||
isReversed = false,
|
||||
direction = ProgressionDirection.INCREASING,
|
||||
additionalNotEmptyCondition = null
|
||||
direction = ProgressionDirection.INCREASING
|
||||
) {
|
||||
// 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
|
||||
|
||||
+1
-4
@@ -346,10 +346,7 @@ internal class ProgressionLoopHeader(
|
||||
}
|
||||
|
||||
val loopCondition = buildLoopCondition(this@with)
|
||||
// Combine with the additional "not empty" condition, if any.
|
||||
val notEmptyCheck =
|
||||
irIfThen(headerInfo.additionalNotEmptyCondition?.let { context.andand(it, loopCondition) } ?: loopCondition, newLoop)
|
||||
LoopReplacement(newLoop, notEmptyCheck)
|
||||
LoopReplacement(newLoop, irIfThen(loopCondition, newLoop))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-1
@@ -277,7 +277,6 @@ internal class StepHandler(
|
||||
step = finalStepExpression,
|
||||
isReversed = nestedInfo.isReversed,
|
||||
additionalStatements = additionalStatements,
|
||||
additionalNotEmptyCondition = nestedInfo.additionalNotEmptyCondition,
|
||||
direction = nestedInfo.direction
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user