Add suspend modifier to getNextLabel method in Label interface
This commit is contained in:
+1
-1
@@ -105,7 +105,7 @@ class IrInterpreter(irModule: IrModuleFragment) {
|
|||||||
else -> TODO("${this.javaClass} not supported")
|
else -> TODO("${this.javaClass} not supported")
|
||||||
}
|
}
|
||||||
|
|
||||||
return executionResult.getNextLabel(this, data) { runBlocking { this@getNextLabel.interpret(it) } }
|
return executionResult.getNextLabel(this, data) { this@getNextLabel.interpret(it) }
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
// catch exception from JVM such as: ArithmeticException, StackOverflowError and others
|
// catch exception from JVM such as: ArithmeticException, StackOverflowError and others
|
||||||
val exceptionName = e::class.java.simpleName
|
val exceptionName = e::class.java.simpleName
|
||||||
|
|||||||
+9
-5
@@ -20,7 +20,7 @@ enum class ReturnLabel {
|
|||||||
interface ExecutionResult {
|
interface ExecutionResult {
|
||||||
val returnLabel: ReturnLabel
|
val returnLabel: ReturnLabel
|
||||||
|
|
||||||
fun getNextLabel(irElement: IrElement, data: Frame, interpret: IrElement.(Frame) -> ExecutionResult): ExecutionResult
|
suspend fun getNextLabel(irElement: IrElement, data: Frame, interpret: suspend IrElement.(Frame) -> ExecutionResult): ExecutionResult
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fun ExecutionResult.check(toCheckLabel: ReturnLabel = ReturnLabel.NEXT, returnBlock: (ExecutionResult) -> Unit): ExecutionResult {
|
inline fun ExecutionResult.check(toCheckLabel: ReturnLabel = ReturnLabel.NEXT, returnBlock: (ExecutionResult) -> Unit): ExecutionResult {
|
||||||
@@ -38,8 +38,10 @@ inline fun ExecutionResult.checkForReturn(newFrame: Frame, oldFrame: Frame, retu
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
open class ExecutionResultWithoutInfo(override val returnLabel: ReturnLabel): ExecutionResult {
|
open class ExecutionResultWithoutInfo(override val returnLabel: ReturnLabel) : ExecutionResult {
|
||||||
override fun getNextLabel(irElement: IrElement, data: Frame, interpret: IrElement.(Frame) -> ExecutionResult): ExecutionResult {
|
override suspend fun getNextLabel(
|
||||||
|
irElement: IrElement, data: Frame, interpret: suspend IrElement.(Frame) -> ExecutionResult
|
||||||
|
): ExecutionResult {
|
||||||
return when (returnLabel) {
|
return when (returnLabel) {
|
||||||
ReturnLabel.RETURN -> this
|
ReturnLabel.RETURN -> this
|
||||||
ReturnLabel.BREAK_WHEN -> when (irElement) {
|
ReturnLabel.BREAK_WHEN -> when (irElement) {
|
||||||
@@ -58,8 +60,10 @@ open class ExecutionResultWithoutInfo(override val returnLabel: ReturnLabel): Ex
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ExecutionResultWithInfo(override val returnLabel: ReturnLabel, val info: String): ExecutionResultWithoutInfo(returnLabel) {
|
class ExecutionResultWithInfo(override val returnLabel: ReturnLabel, val info: String) : ExecutionResultWithoutInfo(returnLabel) {
|
||||||
override fun getNextLabel(irElement: IrElement, data: Frame, interpret: IrElement.(Frame) -> ExecutionResult): ExecutionResult {
|
override suspend fun getNextLabel(
|
||||||
|
irElement: IrElement, data: Frame, interpret: suspend IrElement.(Frame) -> ExecutionResult
|
||||||
|
): ExecutionResult {
|
||||||
return when (returnLabel) {
|
return when (returnLabel) {
|
||||||
ReturnLabel.RETURN -> when (irElement) {
|
ReturnLabel.RETURN -> when (irElement) {
|
||||||
is IrCall -> if (info == irElement.symbol.descriptor.toString()) Next else this
|
is IrCall -> if (info == irElement.symbol.descriptor.toString()) Next else this
|
||||||
|
|||||||
Reference in New Issue
Block a user