Fix primitive type globals initialization. (#189)
This commit is contained in:
+3
-2
@@ -597,11 +597,12 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid
|
||||
context.log("visitField : ${ir2string(expression)}")
|
||||
val descriptor = expression.descriptor
|
||||
if (descriptor.containingDeclaration is PackageFragmentDescriptor) {
|
||||
val globalProperty = LLVMAddGlobal(context.llvmModule, codegen.getLLVMType(descriptor.type), descriptor.symbolName)
|
||||
val type = codegen.getLLVMType(descriptor.type)
|
||||
val globalProperty = LLVMAddGlobal(context.llvmModule, type, descriptor.symbolName)
|
||||
if (expression.initializer!!.expression is IrConst<*>) {
|
||||
LLVMSetInitializer(globalProperty, evaluateExpression(expression.initializer!!.expression))
|
||||
} else {
|
||||
LLVMSetInitializer(globalProperty, codegen.kNullObjHeaderPtr)
|
||||
LLVMSetInitializer(globalProperty, LLVMConstNull(type))
|
||||
context.llvm.fileInitializers.add(expression)
|
||||
}
|
||||
return
|
||||
|
||||
@@ -829,8 +829,7 @@ task initializers3(type: RunKonanTest) {
|
||||
}
|
||||
|
||||
task initializers4(type: RunKonanTest) {
|
||||
disabled = true
|
||||
goldValue = "fixme\n"
|
||||
goldValue = "1073741824\ntrue\n"
|
||||
source = "runtime/basic/initializers4.kt"
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,8 @@ private class IteratorImpl<T>(val collection: Array<T>) : Iterator<T> {
|
||||
}
|
||||
}
|
||||
|
||||
fun <T> arrayOf(vararg elements: T) : Array<out T> = elements
|
||||
|
||||
public fun <T, C : MutableCollection<in T>> Array<out T>.toCollection(destination: C): C {
|
||||
for (item in this) {
|
||||
destination.add(item)
|
||||
|
||||
Reference in New Issue
Block a user