From 452fbe65b2ea24306e58d6fc9ffed4b63e2b7ed7 Mon Sep 17 00:00:00 2001 From: e5l Date: Tue, 19 Jul 2016 12:34:44 +0300 Subject: [PATCH] translator: fix allocation type on primitive type --- .../org/kotlinnative/translator/FunctionCodegen.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/translator/src/main/kotlin/org/kotlinnative/translator/FunctionCodegen.kt b/translator/src/main/kotlin/org/kotlinnative/translator/FunctionCodegen.kt index ff7744536e8..9ae314b7316 100644 --- a/translator/src/main/kotlin/org/kotlinnative/translator/FunctionCodegen.kt +++ b/translator/src/main/kotlin/org/kotlinnative/translator/FunctionCodegen.kt @@ -458,7 +458,15 @@ class FunctionCodegen(val state: TranslationState, val variableManager: Variable when (assignExpression) { is LLVMVariable -> { - variableManager.addVariable(identifier!!.text, assignExpression, scopeDepth) + if (assignExpression.pointer == 0) { + val allocVar = variableManager.receiveVariable(identifier!!.text, assignExpression.type, LLVMRegisterScope(), pointer = 0) + codeBuilder.allocStackVar(allocVar) + allocVar.pointer++ + variableManager.addVariable(identifier.text, allocVar, scopeDepth) + copyVariable(assignExpression, allocVar) + } else { + variableManager.addVariable(identifier!!.text, assignExpression, scopeDepth) + } } is LLVMConstant -> { val newVar = variableManager.receiveVariable(identifier!!.text, assignExpression.type!!, LLVMRegisterScope(), pointer = 1)