Fix methods inherited from Any in interop value types

This commit is contained in:
Svyatoslav Scherbina
2017-03-15 16:48:39 +07:00
committed by SvyatoslavScherbina
parent d1859dd280
commit c9b04bc0bb
7 changed files with 32 additions and 3 deletions
@@ -112,6 +112,8 @@ internal class InteropBuiltIns(builtIns: KonanBuiltIns) {
val nativePtrPlusLong = nativePtr.unsubstitutedMemberScope.getContributedFunctions("plus").single()
val nativePtrToLong = nativePtr.unsubstitutedMemberScope.getContributedFunctions("toLong").single()
val bitsToFloat = packageScope.getContributedFunctions("bitsToFloat").single()
val bitsToDouble = packageScope.getContributedFunctions("bitsToDouble").single()
@@ -24,7 +24,7 @@ internal class CodeGenerator(override val context: Context) : ContextUtils {
private var localAllocs = 0
private var arenaSlot: LLVMValueRef? = null
private val intPtrType = LLVMIntPtrType(llvmTargetData)!!
val intPtrType = LLVMIntPtrType(llvmTargetData)!!
private val immOneIntPtrType = LLVMConstInt(intPtrType, 1, 1)!!
fun prologue(descriptor: FunctionDescriptor) {
@@ -1711,6 +1711,16 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid
interop.nativePtrPlusLong -> codegen.gep(args[0], args[1])
interop.getNativeNullPtr -> kNullInt8Ptr
interop.getPointerSize -> Int32(LLVMPointerSize(codegen.llvmTargetData)).llvm
interop.nativePtrToLong -> {
val intPtrValue = codegen.ptrToInt(args.single(), codegen.intPtrType)
val resultType = codegen.getLLVMType(descriptor.returnType!!)
if (resultType == intPtrValue.type) {
intPtrValue
} else {
LLVMBuildSExt(codegen.builder, intPtrValue, resultType, "")!!
}
}
else -> TODO(callee.descriptor.original.toString())
}
}
@@ -324,6 +324,10 @@ private class DeclarationsGeneratorVisitor(override val context: Context) :
val llvmFunctionType = getLlvmFunctionType(descriptor)
val llvmFunction = if (descriptor.isExternal) {
if (descriptor.isIntrinsic) {
return
}
context.llvm.externalFunction(descriptor.symbolName, llvmFunctionType)
} else {
val symbolName = if (descriptor.isExported()) {