call of void function

(cherry picked from commit feeacab2bb6e1789e91075dc1b519340cd4f4172)
This commit is contained in:
Vasily Levchenko
2016-11-17 14:44:26 +03:00
parent e4c384e99a
commit 4495c86c2c
@@ -652,7 +652,7 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid
fun callDirect(descriptor: FunctionDescriptor, args: List<LLVMOpaqueValue?>, result: String?): LLVMOpaqueValue? {
val llvmFunction = codegen.functionLlvmValue(descriptor)
return codegen.call(llvmFunction, args, result)
return call(descriptor, llvmFunction, args, result)
}
//-------------------------------------------------------------------------//
@@ -680,7 +680,13 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid
val functionPtrType = pointerType(getLlvmFunctionType(descriptor)) // Construct type of the method to be invoked
val function = codegen.bitcast(functionPtrType, llvmMethod!!, codegen.newVar()) // Cast method address to the type
return codegen.call(function, args, result) // Invoke the method
return call(descriptor, function, args, result) // Invoke the method
}
//-------------------------------------------------------------------------//
private fun call(descriptor: FunctionDescriptor, function: LLVMOpaqueValue?, args: List<LLVMOpaqueValue?>, result: String?): LLVMOpaqueValue? {
return codegen.call(function, args, if (KotlinBuiltIns.isUnit(descriptor.returnType!!)) "" else result)
}
//-------------------------------------------------------------------------//