Implement arrayOf symbols interpretation

This commit is contained in:
Ivan Kylchik
2020-06-10 19:13:49 +03:00
parent 4dc1e587b4
commit 9555497d5d
2 changed files with 11 additions and 6 deletions
@@ -82,7 +82,7 @@ class IrInterpreter(irModule: IrModuleFragment) {
return when (code) {
Code.RETURN -> when (this) {
is IrCall -> Code.NEXT
is IrCall, is IrReturnableBlock -> Code.NEXT
else -> Code.RETURN
}
Code.BREAK_WHEN -> when (this) {
@@ -419,7 +419,7 @@ class IrInterpreter(irModule: IrModuleFragment) {
IrTypeOperator.IMPLICIT_COERCION_TO_UNIT -> {
expression.argument.interpret(data)
}
IrTypeOperator.CAST -> {
IrTypeOperator.CAST, IrTypeOperator.IMPLICIT_DYNAMIC_CAST -> {
expression.argument.interpret(data) //todo check cast correctness
}
else -> TODO("${expression.operator} not implemented")
@@ -82,10 +82,15 @@ fun IrFunction.isFakeOverridden(): Boolean {
fun State.toIrExpression(expression: IrExpression): IrExpression {
return when (this) {
is Primitive<*> -> this.value.toIrConst( // this is necessary to replace ir offsets
this.type, expression.startOffset, expression.endOffset
)
else -> TODO("not supported")
is Primitive<*> ->
when (this.value) {
// toIrConst call is necessary to replace ir offsets
is Boolean, is Char, is Byte, is Short, is Int, is Long, is String, is Float, is Double ->
this.value.toIrConst(this.type, expression.startOffset, expression.endOffset)
null -> this.value.toIrConst(this.type, expression.startOffset, expression.endOffset)
else -> expression // TODO support for arrays
}
else -> expression // TODO support
}
}