Boolean type fix
This commit is contained in:
committed by
Sergey Bogolepov
parent
762284359c
commit
ebbf86b42d
+7
-1
@@ -757,7 +757,13 @@ internal class CAdapterGenerator(
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif""".trimIndent())
|
||||
output("typedef unsigned char ${prefix}_KBoolean;")
|
||||
output("""
|
||||
#ifdef __cplusplus
|
||||
typedef bool ${prefix}_KBoolean;
|
||||
#else
|
||||
typedef _Bool ${prefix}_KBoolean;
|
||||
#endif
|
||||
""".trimIndent())
|
||||
output("typedef char ${prefix}_KByte;")
|
||||
output("typedef unsigned short ${prefix}_KChar;")
|
||||
output("typedef short ${prefix}_KShort;")
|
||||
|
||||
+1
-1
@@ -54,12 +54,12 @@ internal class DebugInfo internal constructor(override val context: Context):Con
|
||||
var types = mutableMapOf<KotlinType, DITypeOpaqueRef>()
|
||||
|
||||
val llvmTypes = mapOf<KotlinType, LLVMTypeRef>(
|
||||
context.builtIns.booleanType to LLVMInt8Type()!!,
|
||||
context.builtIns.byteType to LLVMInt8Type()!!,
|
||||
context.builtIns.charType to LLVMInt8Type()!!,
|
||||
context.builtIns.shortType to LLVMInt16Type()!!,
|
||||
context.builtIns.intType to LLVMInt32Type()!!,
|
||||
context.builtIns.longType to LLVMInt64Type()!!,
|
||||
context.builtIns.booleanType to LLVMInt1Type()!!,
|
||||
context.builtIns.floatType to LLVMFloatType()!!,
|
||||
context.builtIns.doubleType to LLVMDoubleType()!!)
|
||||
val intTypes = listOf<KotlinType>(context.builtIns.byteType, context.builtIns.shortType, context.builtIns.intType, context.builtIns.longType)
|
||||
|
||||
+4
-5
@@ -1332,8 +1332,7 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
|
||||
val srcObjInfoPtr = functionGenerationContext.bitcast(codegen.kObjHeaderPtr, obj) // Cast src to ObjInfoPtr.
|
||||
val args = listOf(srcObjInfoPtr, dstTypeInfo) // Create arg list.
|
||||
|
||||
val result = call(context.llvm.isInstanceFunction, args) // Check if dst is subclass of src.
|
||||
return LLVMBuildTrunc(functionGenerationContext.builder, result, kInt1, "")!! // Truncate result to boolean
|
||||
return call(context.llvm.isInstanceFunction, args) // Check if dst is subclass of src.
|
||||
}
|
||||
|
||||
private fun genInstanceOfObjC(obj: LLVMValueRef, dstClass: IrClass): LLVMValueRef {
|
||||
@@ -1345,13 +1344,13 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
|
||||
|
||||
return if (dstClass.isObjCClass()) {
|
||||
if (dstClass.isInterface) {
|
||||
val isMeta = if (dstClass.isObjCMetaClass()) Int8(1) else Int8(0)
|
||||
val isMeta = if (dstClass.isObjCMetaClass()) kTrue else kFalse
|
||||
call(
|
||||
context.llvm.Kotlin_Interop_DoesObjectConformToProtocol,
|
||||
listOf(
|
||||
objCObject,
|
||||
genGetObjCProtocol(dstClass),
|
||||
isMeta.llvm
|
||||
isMeta
|
||||
)
|
||||
)
|
||||
} else {
|
||||
@@ -1360,7 +1359,7 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
|
||||
listOf(objCObject, genGetObjCClass(dstClass))
|
||||
)
|
||||
}.let {
|
||||
functionGenerationContext.icmpNe(it, Int8(0).llvm)
|
||||
functionGenerationContext.icmpNe(it, kFalse)
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
-2
@@ -35,7 +35,6 @@ class LldbTests {
|
||||
[..] at main.kt:5
|
||||
""")
|
||||
|
||||
//FIXME: Boolean and Int are wrong
|
||||
@Test
|
||||
fun `can inspect values of primitive types`() = lldbTest("""
|
||||
fun main(args: Array<String>) {
|
||||
@@ -54,7 +53,7 @@ class LldbTests {
|
||||
(int) b = 2
|
||||
(long) c = -3
|
||||
(unsigned char) d = 'c'
|
||||
(void) e = <Unable to determine byte size.>
|
||||
(bool) e = true
|
||||
""")
|
||||
|
||||
@Test
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include "TypeInfo.h"
|
||||
|
||||
// Note that almost all types are signed.
|
||||
typedef uint8_t KBoolean;
|
||||
typedef bool KBoolean;
|
||||
typedef int8_t KByte;
|
||||
typedef uint16_t KChar;
|
||||
typedef int16_t KShort;
|
||||
|
||||
Reference in New Issue
Block a user