IR: Set when.origin for IrIfElseImpl

Change-Id: I38510b59e3dc936baadbfe3ef2702990493815e5
This commit is contained in:
Ting-Yuan Huang
2019-03-01 23:57:28 -08:00
committed by max-kammerer
parent 18198987a3
commit 6bbb0269b1
29 changed files with 98 additions and 86 deletions
@@ -77,7 +77,7 @@ class BranchingExpressionGenerator(statementGenerator: StatementGenerator) : Sta
if (irBranches.size == 1) {
val irBranch0 = irBranches[0]
return buildStatement(ktIf.startOffsetSkippingComments, ktIf.endOffset) {
irIfThenMaybeElse(resultType, irBranch0.condition, irBranch0.result, irElseResult)
irIfThenMaybeElse(resultType, irBranch0.condition, irBranch0.result, irElseResult, IrStatementOrigin.IF)
}
}
@@ -117,22 +117,34 @@ fun IrBuilderWithScope.irBranch(condition: IrExpression, result: IrExpression) =
fun IrBuilderWithScope.irElseBranch(expression: IrExpression) =
IrElseBranchImpl(startOffset, endOffset, irTrue(), expression)
fun IrBuilderWithScope.irIfThen(type: IrType, condition: IrExpression, thenPart: IrExpression) =
IrIfThenElseImpl(startOffset, endOffset, type).apply {
fun IrBuilderWithScope.irIfThen(type: IrType, condition: IrExpression, thenPart: IrExpression, origin: IrStatementOrigin? = null) =
IrIfThenElseImpl(startOffset, endOffset, type, origin).apply {
branches.add(IrBranchImpl(startOffset, endOffset, condition, thenPart))
}
fun IrBuilderWithScope.irIfThenElse(type: IrType, condition: IrExpression, thenPart: IrExpression, elsePart: IrExpression) =
IrIfThenElseImpl(startOffset, endOffset, type).apply {
fun IrBuilderWithScope.irIfThenElse(
type: IrType,
condition: IrExpression,
thenPart: IrExpression,
elsePart: IrExpression,
origin: IrStatementOrigin? = null
) =
IrIfThenElseImpl(startOffset, endOffset, type, origin).apply {
branches.add(IrBranchImpl(startOffset, endOffset, condition, thenPart))
branches.add(irElseBranch(elsePart))
}
fun IrBuilderWithScope.irIfThenMaybeElse(type: IrType, condition: IrExpression, thenPart: IrExpression, elsePart: IrExpression?) =
fun IrBuilderWithScope.irIfThenMaybeElse(
type: IrType,
condition: IrExpression,
thenPart: IrExpression,
elsePart: IrExpression?,
origin: IrStatementOrigin? = null
) =
if (elsePart != null)
irIfThenElse(type, condition, thenPart, elsePart)
irIfThenElse(type, condition, thenPart, elsePart, origin)
else
irIfThen(type, condition, thenPart)
irIfThen(type, condition, thenPart, origin)
fun IrBuilderWithScope.irIfNull(type: IrType, subject: IrExpression, thenPart: IrExpression, elsePart: IrExpression) =
irIfThenElse(type, irEqualsNull(subject), thenPart, elsePart)