[IR] KotlinLikeDumper.kt: move branch support to corresponding visit* methods
This commit is contained in:
committed by
teamcityserver
parent
8f155c23a0
commit
14dabed85a
@@ -1189,16 +1189,7 @@ private class KotlinLikeDumper(val p: Printer, val options: KotlinLikeDumpOption
|
|||||||
p.printlnWithNoIndent("when {")
|
p.printlnWithNoIndent("when {")
|
||||||
p.pushIndent()
|
p.pushIndent()
|
||||||
|
|
||||||
for (b in expression.branches) {
|
expression.branches.forEach { it.accept(this, data) }
|
||||||
p.printIndent()
|
|
||||||
b.condition.accept(this, data)
|
|
||||||
|
|
||||||
p.printWithNoIndent(" -> ")
|
|
||||||
|
|
||||||
b.result.accept(this, data)
|
|
||||||
|
|
||||||
p.println()
|
|
||||||
}
|
|
||||||
|
|
||||||
p.popIndent()
|
p.popIndent()
|
||||||
p.print("}")
|
p.print("}")
|
||||||
@@ -1382,11 +1373,19 @@ private class KotlinLikeDumper(val p: Printer, val options: KotlinLikeDumpOption
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun visitBranch(branch: IrBranch, data: IrDeclaration?) {
|
override fun visitBranch(branch: IrBranch, data: IrDeclaration?) {
|
||||||
super.visitBranch(branch, data)
|
p.printIndent()
|
||||||
|
branch.condition.accept(this, data)
|
||||||
|
p.printWithNoIndent(" -> ")
|
||||||
|
branch.result.accept(this, data)
|
||||||
|
p.println()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitElseBranch(branch: IrElseBranch, data: IrDeclaration?) {
|
override fun visitElseBranch(branch: IrElseBranch, data: IrDeclaration?) {
|
||||||
super.visitElseBranch(branch, data)
|
p.printIndent()
|
||||||
|
// TODO assert that condition is `true`
|
||||||
|
p.printWithNoIndent("else -> ")
|
||||||
|
branch.result.accept(this, data)
|
||||||
|
p.println()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun commentBlock(text: String) = "/* $text */"
|
private fun commentBlock(text: String) = "/* $text */"
|
||||||
|
|||||||
Reference in New Issue
Block a user