Fix number of interop issues

This commit is contained in:
Svyatoslav Scherbina
2017-03-31 13:53:39 +03:00
committed by SvyatoslavScherbina
parent 89552fa2c8
commit 7f0b8a6778
8 changed files with 172 additions and 92 deletions
@@ -79,12 +79,16 @@ internal class InteropBuiltIns(builtIns: KonanBuiltIns) {
val interpretCPointer = packageScope.getContributedFunctions("interpretCPointer").single()
val variableClass = packageScope.getContributedClassifier("CVariable") as ClassDescriptor
val arrayGetByIntIndex = packageScope.getContributedFunctions("get").single {
KotlinBuiltIns.isInt(it.valueParameters.single().type) && it.isInline
KotlinBuiltIns.isInt(it.valueParameters.single().type) &&
it.typeParameters.single().upperBounds.single() == variableClass.defaultType
}
val arrayGetByLongIndex = packageScope.getContributedFunctions("get").single {
KotlinBuiltIns.isLong(it.valueParameters.single().type) && it.isInline
KotlinBuiltIns.isLong(it.valueParameters.single().type) &&
it.typeParameters.single().upperBounds.single() == variableClass.defaultType
}
val allocUninitializedArrayWithIntLength = packageScope.getContributedFunctions("allocArray").single {
@@ -101,8 +105,6 @@ internal class InteropBuiltIns(builtIns: KonanBuiltIns) {
val typeOf = packageScope.getContributedFunctions("typeOf").single()
val variableClass = packageScope.getContributedClassifier("CVariable") as ClassDescriptor
val variableTypeClass =
variableClass.unsubstitutedInnerClassesScope.getContributedClassifier("Type") as ClassDescriptor
@@ -172,7 +172,7 @@ internal fun RuntimeAware.isObjectType(type: LLVMTypeRef): Boolean {
* Reads [size] bytes contained in this array.
*/
internal fun CArrayPointer<ByteVar>.getBytes(size: Long) =
(0 .. size-1).map { this[it].value }.toByteArray()
(0 .. size-1).map { this[it] }.toByteArray()
internal fun getFunctionType(ptrToFunction: LLVMValueRef): LLVMTypeRef {
return getGlobalType(ptrToFunction)