constructor should initialize fields of object basing on comparizon with storage structure

This commit is contained in:
Vasily Levchenko
2016-10-22 09:35:03 +03:00
parent 64acd9d894
commit 1b97973dc8
@@ -48,8 +48,13 @@ internal class CodeGenerator(override val context:Context) : ContextUtils {
fun initFunction(declaration: IrConstructor) {
function(declaration)
val thisPtr = bitcast(pointerType(classType(declaration.descriptor.containingDeclaration)), load(thisVariable(), tmpVariable()), tmpVariable())
declaration.descriptor.valueParameters.forEachIndexed { i, descriptor ->
declaration.descriptor.containingDeclaration.fields.forEachIndexed { i, descriptor ->
val name = descriptor.name.asString()
if (!declaration.descriptor.valueParameters.any { it -> it.name.asString() == name })
return@forEachIndexed
val ptr = LLVMBuildStructGEP(context.llvmBuilder, thisPtr, i, tmpVariable())
val value = load(variable(name)!!, tmpVariable())