Support lateinit var interpretation
This commit is contained in:
committed by
TeamCityServer
parent
b45df06680
commit
ad6ba0cf11
@@ -570,19 +570,17 @@ class IrInterpreter(private val irBuiltIns: IrBuiltIns, private val bodyMap: Map
|
||||
}
|
||||
|
||||
private fun interpretVariable(expression: IrVariable): ExecutionResult {
|
||||
expression.initializer?.interpret()?.check { return it } ?: return Next
|
||||
if (expression.initializer == null) {
|
||||
return Next.apply { stack.addVar(Variable(expression.symbol)) }
|
||||
}
|
||||
expression.initializer?.interpret()?.check { return it } //?: return Next
|
||||
stack.addVar(Variable(expression.symbol, stack.popReturnValue()))
|
||||
return Next
|
||||
}
|
||||
|
||||
private fun interpretSetVariable(expression: IrSetValue): ExecutionResult {
|
||||
expression.value.interpret().check { return it }
|
||||
|
||||
if (stack.contains(expression.symbol)) {
|
||||
stack.getVariable(expression.symbol).apply { this.state = stack.popReturnValue() }
|
||||
} else {
|
||||
stack.addVar(Variable(expression.symbol, stack.popReturnValue()))
|
||||
}
|
||||
stack.getVariable(expression.symbol).apply { this.state = stack.popReturnValue() }
|
||||
return Next
|
||||
}
|
||||
|
||||
|
||||
+7
-1
@@ -9,4 +9,10 @@ import org.jetbrains.kotlin.ir.interpreter.state.State
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||
|
||||
// TODO maybe switch to typealias and use map instead of list
|
||||
internal data class Variable(val symbol: IrSymbol, var state: State)
|
||||
internal data class Variable(val symbol: IrSymbol) {
|
||||
lateinit var state: State
|
||||
|
||||
constructor(symbol: IrSymbol, state: State) : this(symbol) {
|
||||
this.state = state
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user