[IR] KotlinLikeDumper: support labels on loops, break & continue
This commit is contained in:
committed by
teamcityserver
parent
21da2b0350
commit
9daa86c1a2
@@ -1139,16 +1139,26 @@ private class KotlinLikeDumper(val p: Printer, val options: KotlinLikeDumpOption
|
|||||||
p.print("}")
|
p.print("}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun IrLoop.printLabel() {
|
||||||
|
label?.let {
|
||||||
|
p.printWithNoIndent(it)
|
||||||
|
p.printWithNoIndent("@ ")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun visitWhileLoop(loop: IrWhileLoop, data: IrDeclaration?) {
|
override fun visitWhileLoop(loop: IrWhileLoop, data: IrDeclaration?) {
|
||||||
|
loop.printLabel()
|
||||||
|
|
||||||
p.printWithNoIndent("while (")
|
p.printWithNoIndent("while (")
|
||||||
loop.condition.accept(this, data)
|
loop.condition.accept(this, data)
|
||||||
|
|
||||||
p.printWithNoIndent(") ")
|
p.printWithNoIndent(") ")
|
||||||
|
|
||||||
loop.body?.accept(this, data)
|
loop.body?.accept(this, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitDoWhileLoop(loop: IrDoWhileLoop, data: IrDeclaration?) {
|
override fun visitDoWhileLoop(loop: IrDoWhileLoop, data: IrDeclaration?) {
|
||||||
|
loop.printLabel()
|
||||||
|
|
||||||
p.printWithNoIndent("do")
|
p.printWithNoIndent("do")
|
||||||
|
|
||||||
loop.body?.accept(this, data)
|
loop.body?.accept(this, data)
|
||||||
@@ -1178,14 +1188,21 @@ private class KotlinLikeDumper(val p: Printer, val options: KotlinLikeDumpOption
|
|||||||
p.printlnWithNoIndent()
|
p.printlnWithNoIndent()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun IrBreakContinue.printLabel() {
|
||||||
|
label?.let {
|
||||||
|
p.printWithNoIndent("@")
|
||||||
|
p.printWithNoIndent(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun visitBreak(jump: IrBreak, data: IrDeclaration?) {
|
override fun visitBreak(jump: IrBreak, data: IrDeclaration?) {
|
||||||
// TODO label
|
|
||||||
p.printWithNoIndent("break")
|
p.printWithNoIndent("break")
|
||||||
|
jump.printLabel()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitContinue(jump: IrContinue, data: IrDeclaration?) {
|
override fun visitContinue(jump: IrContinue, data: IrDeclaration?) {
|
||||||
// TODO label
|
|
||||||
p.printWithNoIndent("continue")
|
p.printWithNoIndent("continue")
|
||||||
|
jump.printLabel()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitErrorDeclaration(declaration: IrErrorDeclaration, data: IrDeclaration?) {
|
override fun visitErrorDeclaration(declaration: IrErrorDeclaration, data: IrDeclaration?) {
|
||||||
|
|||||||
Reference in New Issue
Block a user