Improve object arrays support. (#182)
Also fix the way how symbol names are being generated. Before arrays2.kt was not linking.
This commit is contained in:
+1
-1
@@ -1671,7 +1671,7 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid
|
||||
val typeInfo = codegen.typeInfoValue(containingClass)
|
||||
val allocHint = Int32(1).llvm
|
||||
val thisValue = if (containingClass.isArray) {
|
||||
assert(args.size == 1 && args[0].type == int32Type)
|
||||
assert(args.size >= 1 && args[0].type == int32Type)
|
||||
val allocArrayInstanceArgs = listOf(typeInfo, allocHint, args[0])
|
||||
call(context.llvm.allocArrayFunction, allocArrayInstanceArgs)
|
||||
} else {
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ private val exportForCppRuntimeAnnotation = FqName("konan.internal.ExportForCppR
|
||||
fun typeToHashString(type: KotlinType): String {
|
||||
if (TypeUtils.isTypeParameter(type)) return "GENERIC"
|
||||
|
||||
var hashString = type.constructor.toString()
|
||||
var hashString = TypeUtils.getClassDescriptor(type)!!.fqNameSafe.asString()
|
||||
if (!type.arguments.isEmpty()) {
|
||||
hashString += "<${type.arguments.map {
|
||||
typeToHashString(it.type)
|
||||
|
||||
@@ -301,6 +301,11 @@ task array1(type: RunKonanTest) {
|
||||
source = "runtime/collections/array1.kt"
|
||||
}
|
||||
|
||||
task array2(type: RunKonanTest) {
|
||||
goldValue = "0\n2\n4\n6\n8\n40\n"
|
||||
source = "runtime/collections/array2.kt"
|
||||
}
|
||||
|
||||
task if_else(type: RunKonanTest) {
|
||||
source = "codegen/branching/if_else.kt"
|
||||
}
|
||||
@@ -536,6 +541,10 @@ task moderately_large_array(type: RunKonanTest) {
|
||||
source = "runtime/collections/moderately_large_array.kt"
|
||||
}
|
||||
|
||||
task moderately_large_array1(type: RunKonanTest) {
|
||||
goldValue = "-45392\n"
|
||||
source = "runtime/collections/moderately_large_array1.kt"
|
||||
}
|
||||
|
||||
task string_builder0(type: RunKonanTest) {
|
||||
goldValue = "OK\n"
|
||||
|
||||
@@ -3,5 +3,5 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
|
||||
fun foo(): Any {
|
||||
return Array<Any?>(0)
|
||||
return Array<Any?>(0, { i -> null })
|
||||
}
|
||||
@@ -24,6 +24,6 @@ fun main(args : Array<String>) {
|
||||
val booleanArray = BooleanArray(12)
|
||||
println(booleanArray.size.toString())
|
||||
|
||||
val stringArray = Array<String>(13)
|
||||
val stringArray = Array<String>(13, { i -> ""})
|
||||
println(stringArray.size.toString())
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fun main(args : Array<String>) {
|
||||
val byteArray = Array<Byte>(5, { i -> (i * 2).toByte() })
|
||||
byteArray.map { println(it) }
|
||||
|
||||
val intArray = Array<Int>(5, { i -> i * 4 })
|
||||
println(intArray.sum())
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fun main(args: Array<String>) {
|
||||
val a = Array<Byte>(100000, { i -> i.toByte()})
|
||||
|
||||
var sum = 0
|
||||
for (b in a) {
|
||||
sum += b
|
||||
}
|
||||
|
||||
println(sum)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user