diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/interpreter/IrInterpreter.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/interpreter/IrInterpreter.kt index cca691cefbd..b8419ef476e 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/interpreter/IrInterpreter.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/interpreter/IrInterpreter.kt @@ -59,6 +59,7 @@ class IrInterpreter(private val irBuiltIns: IrBuiltIns) { is IrWhileLoop -> interpretWhile(this, data) is IrWhen -> interpretWhen(this, data) is IrBreak -> interpretBreak(this, data) + is IrContinue -> interpretContinue(this, data) else -> TODO("${this.javaClass} not supported") } @@ -76,7 +77,10 @@ class IrInterpreter(private val irBuiltIns: IrBuiltIns) { is IrWhileLoop -> if ((this.label ?: "") == code.info) Code.NEXT else code else -> code } - Code.CONTINUE -> TODO("Code.CONTINUE not implemented") + Code.CONTINUE -> when (this) { + is IrWhileLoop -> if ((this.label ?: "") == code.info) this.interpret(data) else code + else -> code + } Code.EXCEPTION -> TODO("Code.EXCEPTION not implemented") Code.NEXT -> Code.NEXT } @@ -334,6 +338,10 @@ class IrInterpreter(private val irBuiltIns: IrBuiltIns) { return Code.BREAK_LOOP.apply { info = breakStatement.label ?: "" } } + private fun interpretContinue(continueStatement: IrContinue, data: Frame): Code { + return Code.CONTINUE.apply { info = continueStatement.label ?: "" } + } + private fun interpretSetField(expression: IrSetField, data: Frame): Code { val code = expression.value.interpret(data) if (code != Code.NEXT) return code