Assume deserialization failure if we could not deserialize a KotlinType.
Various exceptions for IR deserialization.
This commit is contained in:
committed by
alexander-gorshenev
parent
a7b6d1e8ea
commit
9b4a1f1569
+6
@@ -20,3 +20,9 @@ package org.jetbrains.kotlin.backend.konan
|
||||
* Represents a compilation error caused by mistakes in an input file, e.g. undefined reference.
|
||||
*/
|
||||
class KonanCompilationException(message: String = "", cause: Throwable? = null) : Exception(message, cause) {}
|
||||
|
||||
/**
|
||||
* Internal compiler error: could not deserialize IR for inline function body.
|
||||
*/
|
||||
class KonanIrDeserializationException(message: String = "", cause: Throwable? = null) : Exception(message, cause)
|
||||
|
||||
|
||||
+5
-4
@@ -87,6 +87,7 @@ internal class IrDescriptorDeserializer(val context: Context,
|
||||
val text = proto.getDebugText()
|
||||
val typeProto = localDeserializer.typeTable[index]
|
||||
val type = localDeserializer.deserializeInlineType(typeProto)
|
||||
if (type.isError) throw KonanIrDeserializationException("Could not deserialize KotlinType: $text $type")
|
||||
context.log("### deserialized Kotlin Type index=$index, text=$text:\t$type")
|
||||
|
||||
return type
|
||||
@@ -111,7 +112,7 @@ internal class IrDescriptorDeserializer(val context: Context,
|
||||
}
|
||||
// TODO
|
||||
// proto.hasClazz() ->
|
||||
else -> error("Unexpected descriptor kind")
|
||||
else -> TODO("Unexpected descriptor kind")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,7 +273,7 @@ internal class IrDescriptorDeserializer(val context: Context,
|
||||
newPropertyDescriptor.getter
|
||||
is PropertySetterDescriptor ->
|
||||
newPropertyDescriptor.setter
|
||||
else -> error("Unexpected accessor kind")
|
||||
else -> TODO("Unexpected accessor kind")
|
||||
}
|
||||
|
||||
descriptorIndex.put(proto.index, newDescriptor!!)
|
||||
@@ -312,7 +313,7 @@ internal class IrDescriptorDeserializer(val context: Context,
|
||||
is ClassDescriptor -> parent.getUnsubstitutedMemberScope()
|
||||
is PackageFragmentDescriptor -> parent.getMemberScope()
|
||||
is PackageViewDescriptor -> parent.memberScope
|
||||
else -> error("could not get a member scope")
|
||||
else -> TODO("could not get a member scope")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -450,7 +451,7 @@ internal class IrDescriptorDeserializer(val context: Context,
|
||||
// class descriptors here?
|
||||
//substituteClass(proto, originalDescriptor)
|
||||
originalDescriptor
|
||||
else -> error("unexpected type of public function")
|
||||
else -> TODO("unexpected type of public function")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -72,7 +72,7 @@ class LocalDeclarationDeserializer(val rootFunction: FunctionDescriptor, val mod
|
||||
return module.findClassAcrossModuleDependencies(nameResolver.getClassId(fqNameIndex))!!
|
||||
QualifiedName.Kind.PACKAGE ->
|
||||
return module.getPackage(packageName)
|
||||
else -> error("Unexpected descriptor kind.")
|
||||
else -> TODO("Unexpected descriptor kind.")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
-4
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.backend.konan.Context
|
||||
import org.jetbrains.kotlin.backend.konan.descriptors.getMemberScope
|
||||
import org.jetbrains.kotlin.backend.konan.ir.ir2string
|
||||
import org.jetbrains.kotlin.backend.konan.ir.ir2stringWhole
|
||||
import org.jetbrains.kotlin.backend.konan.KonanIrDeserializationException
|
||||
import org.jetbrains.kotlin.backend.konan.llvm.base64Decode
|
||||
import org.jetbrains.kotlin.backend.konan.llvm.base64Encode
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
@@ -313,7 +314,7 @@ internal class IrSerializer(val context: Context,
|
||||
-> return KonanIr.IrTypeOperator.INSTANCEOF
|
||||
IrTypeOperator.NOT_INSTANCEOF
|
||||
-> return KonanIr.IrTypeOperator.NOT_INSTANCEOF
|
||||
else -> error("Unknown type operator")
|
||||
else -> TODO("Unknown type operator")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -689,7 +690,7 @@ internal class IrDeserializer(val context: Context,
|
||||
IrUnaryPrimitiveImpl(start, end, null, descriptor)
|
||||
KonanIr.IrCall.Primitive.BINARY ->
|
||||
IrBinaryPrimitiveImpl(start, end, null, descriptor)
|
||||
else -> error("Unexpected primitive IrCall.")
|
||||
else -> TODO("Unexpected primitive IrCall.")
|
||||
}
|
||||
deserializeMemberAccessCommon(call, proto.memberAccess)
|
||||
return call
|
||||
@@ -802,7 +803,7 @@ internal class IrDeserializer(val context: Context,
|
||||
-> return IrTypeOperator.INSTANCEOF
|
||||
KonanIr.IrTypeOperator.NOT_INSTANCEOF
|
||||
-> return IrTypeOperator.NOT_INSTANCEOF
|
||||
else -> error("Unknown type operator")
|
||||
else -> TODO("Unknown type operator")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1037,7 +1038,7 @@ internal class IrDeserializer(val context: Context,
|
||||
val proto = (rootFunction as DeserializedSimpleFunctionDescriptor).proto
|
||||
|
||||
if (!proto.hasExtension(KonanLinkData.inlineIrBody)) {
|
||||
error("$rootFunction doesn't have ir serialized.")
|
||||
throw KonanIrDeserializationException("$rootFunction doesn't have ir serialized.")
|
||||
}
|
||||
|
||||
val inlineProto = proto.getExtension(KonanLinkData.inlineIrBody)
|
||||
|
||||
Reference in New Issue
Block a user