While loop implementation && first loop test

This commit is contained in:
Mikhail Glukhikh
2016-09-23 13:39:46 +03:00
committed by Dmitry Petrov
parent 979f2231a1
commit bcf2b410ba
4 changed files with 79 additions and 0 deletions
@@ -126,6 +126,23 @@ class FunctionGenerator(val function: IrFunction) {
return whenExit
}
override fun visitWhileLoop(loop: IrWhileLoop, data: Boolean): IrElement? {
if (data) {
builder.add(loop)
}
val entry = MergeCfgElement(loop, "While entry")
builder.jump(entry)
val condition = loop.condition
condition.process(includeSelf = false)
builder.jump(condition)
val body = loop.body
if (!body?.process().isNothing()) {
builder.jump(entry)
}
builder.move(condition)
return condition
}
override fun visitElement(element: IrElement, data: Boolean): IrElement? {
TODO("not implemented")
}