Mostly avoid using ArrayHeader* in generated code. (#116)
This commit is contained in:
+2
-1
@@ -6,6 +6,8 @@ import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
internal fun ContextUtils.getLLVMType(type: KotlinType): LLVMTypeRef {
|
||||
return when {
|
||||
// Nullable types must be represented as objects for boxing.
|
||||
type.isMarkedNullable -> this.kObjHeaderPtr
|
||||
KotlinBuiltIns.isBoolean(type) -> LLVMInt1Type()
|
||||
KotlinBuiltIns.isByte(type) -> LLVMInt8Type()
|
||||
KotlinBuiltIns.isShort(type) || KotlinBuiltIns.isChar(type) -> LLVMInt16Type()
|
||||
@@ -14,7 +16,6 @@ internal fun ContextUtils.getLLVMType(type: KotlinType): LLVMTypeRef {
|
||||
KotlinBuiltIns.isUnit(type) -> LLVMVoidType() // TODO: handle Unit parameter case
|
||||
KotlinBuiltIns.isFloat(type) -> LLVMFloatType()
|
||||
KotlinBuiltIns.isDouble(type) -> LLVMDoubleType()
|
||||
KotlinBuiltIns.isArray(type) || KotlinBuiltIns.isPrimitiveArray(type)-> this.kArrayHeaderPtr
|
||||
!KotlinBuiltIns.isPrimitiveType(type) -> this.kObjHeaderPtr
|
||||
else -> throw NotImplementedError(type.toString() + " is not supported")
|
||||
}!!
|
||||
|
||||
-7
@@ -112,10 +112,6 @@ internal val ContextUtils.kObjHeaderPtr: LLVMTypeRef
|
||||
get() = pointerType(kObjHeader)
|
||||
internal val ContextUtils.kObjHeaderPtrPtr: LLVMTypeRef
|
||||
get() = pointerType(kObjHeaderPtr)
|
||||
internal val ContextUtils.kArrayHeader: LLVMTypeRef
|
||||
get() = LLVMGetTypeByName(context.llvmModule, "struct.ArrayHeader")!!
|
||||
internal val ContextUtils.kArrayHeaderPtr: LLVMTypeRef
|
||||
get() = pointerType(kArrayHeader)
|
||||
internal val ContextUtils.kTypeInfoPtr: LLVMTypeRef
|
||||
get() = pointerType(kTypeInfo)
|
||||
internal val kInt1 = LLVMInt1Type()!!
|
||||
@@ -124,9 +120,6 @@ internal val kInt8PtrPtr = pointerType(kInt8Ptr)
|
||||
internal val kImmInt32One = Int32(1).llvm
|
||||
internal val ContextUtils.kNullObjHeaderPtr: LLVMValueRef
|
||||
get() = LLVMConstNull(this.kObjHeaderPtr)!!
|
||||
internal val ContextUtils.kNullArrayHeaderPtr: LLVMValueRef
|
||||
get() = LLVMConstNull(this.kArrayHeaderPtr)!!
|
||||
|
||||
|
||||
internal fun pointerType(pointeeType: LLVMTypeRef) = LLVMPointerType(pointeeType, 0)!!
|
||||
|
||||
|
||||
Reference in New Issue
Block a user