More primitive types for constants.
This commit is contained in:
committed by
alexander-gorshenev
parent
b3bbd96bce
commit
3f625ce1b2
+23
-15
@@ -32,6 +32,7 @@ import org.jetbrains.kotlin.ir.declarations.impl.*
|
|||||||
import org.jetbrains.kotlin.ir.expressions.*
|
import org.jetbrains.kotlin.ir.expressions.*
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.*
|
import org.jetbrains.kotlin.ir.expressions.impl.*
|
||||||
import org.jetbrains.kotlin.serialization.KonanIr
|
import org.jetbrains.kotlin.serialization.KonanIr
|
||||||
|
import org.jetbrains.kotlin.serialization.KonanIr.IrConst.ValueCase.*
|
||||||
import org.jetbrains.kotlin.serialization.KonanLinkData
|
import org.jetbrains.kotlin.serialization.KonanLinkData
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedSimpleFunctionDescriptor
|
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedSimpleFunctionDescriptor
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
@@ -208,6 +209,7 @@ internal class IrSerializer(val context: Context,
|
|||||||
IrConstKind.Null -> proto.setNull(true)
|
IrConstKind.Null -> proto.setNull(true)
|
||||||
IrConstKind.Boolean -> proto.setBoolean(value.value as Boolean)
|
IrConstKind.Boolean -> proto.setBoolean(value.value as Boolean)
|
||||||
IrConstKind.Byte -> proto.setByte((value.value as Byte).toInt())
|
IrConstKind.Byte -> proto.setByte((value.value as Byte).toInt())
|
||||||
|
IrConstKind.Short -> proto.setShort((value.value as Short).toInt())
|
||||||
IrConstKind.Int -> proto.setInt(value.value as Int)
|
IrConstKind.Int -> proto.setInt(value.value as Int)
|
||||||
IrConstKind.Long -> proto.setLong(value.value as Long)
|
IrConstKind.Long -> proto.setLong(value.value as Long)
|
||||||
IrConstKind.String -> proto.setString(value.value as String)
|
IrConstKind.String -> proto.setString(value.value as String)
|
||||||
@@ -633,7 +635,7 @@ internal class IrDeserializer(val context: Context,
|
|||||||
proto.hasExpression()
|
proto.hasExpression()
|
||||||
-> deserializeExpression(proto.getExpression())
|
-> deserializeExpression(proto.getExpression())
|
||||||
else -> {
|
else -> {
|
||||||
TODO("Statement deserialization not implemented}")
|
TODO("Statement deserialization not implemented")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -866,24 +868,30 @@ internal class IrDeserializer(val context: Context,
|
|||||||
return irContinue
|
return irContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
fun deserializeConst(proto: KonanIr.IrConst, start: Int, end: Int, type: KotlinType): IrExpression {
|
fun deserializeConst(proto: KonanIr.IrConst, start: Int, end: Int, type: KotlinType): IrExpression =
|
||||||
|
when(proto.valueCase) {
|
||||||
when {
|
NULL
|
||||||
proto.hasNull()
|
-> IrConstImpl.constNull(start, end, type)
|
||||||
-> return IrConstImpl.constNull(start, end, type)
|
BOOLEAN
|
||||||
proto.hasBoolean()
|
-> IrConstImpl.boolean(start, end, type, proto.getBoolean())
|
||||||
-> return IrConstImpl.boolean(start, end, type, proto.getBoolean())
|
BYTE
|
||||||
proto.hasInt()
|
-> IrConstImpl.byte(start, end, type, proto.getByte().toByte())
|
||||||
-> return IrConstImpl.int(start, end, type, proto.getInt())
|
SHORT
|
||||||
proto.hasString()
|
-> IrConstImpl.short(start, end, type, proto.getShort().toShort())
|
||||||
-> return IrConstImpl.string(start, end, type, proto.getString())
|
INT
|
||||||
proto.hasDouble()
|
-> IrConstImpl.int(start, end, type, proto.getInt())
|
||||||
-> return IrConstImpl.double(start, end, type, proto.getDouble())
|
LONG
|
||||||
|
-> IrConstImpl.long(start, end, type, proto.getLong())
|
||||||
|
STRING
|
||||||
|
-> IrConstImpl.string(start, end, type, proto.getString())
|
||||||
|
FLOAT
|
||||||
|
-> IrConstImpl.float(start, end, type, proto.getFloat())
|
||||||
|
DOUBLE
|
||||||
|
-> IrConstImpl.double(start, end, type, proto.getDouble())
|
||||||
else -> {
|
else -> {
|
||||||
TODO("Not all const types have been implemented")
|
TODO("Not all const types have been implemented")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fun deserializeOperation(proto: KonanIr.IrOperation, start: Int, end: Int, type: KotlinType): IrExpression {
|
fun deserializeOperation(proto: KonanIr.IrOperation, start: Int, end: Int, type: KotlinType): IrExpression {
|
||||||
when {
|
when {
|
||||||
|
|||||||
Reference in New Issue
Block a user