Do..while loop implementation and first test

This commit is contained in:
Mikhail Glukhikh
2016-09-23 15:04:42 +03:00
committed by Dmitry Petrov
parent bcf2b410ba
commit e03e13af43
4 changed files with 86 additions and 0 deletions
@@ -143,6 +143,23 @@ class FunctionGenerator(val function: IrFunction) {
return condition
}
override fun visitDoWhileLoop(loop: IrDoWhileLoop, data: Boolean): IrElement? {
if (data) {
builder.add(loop)
}
val entry = MergeCfgElement(loop, "Do..while entry")
builder.jump(entry)
val body = loop.body
val condition = loop.condition
if (body?.process() !is IrReturn) {
condition.process(includeSelf = false)
builder.jump(condition)
builder.jump(entry)
builder.move(condition)
}
return condition
}
override fun visitElement(element: IrElement, data: Boolean): IrElement? {
TODO("not implemented")
}