translator: fix allocation type on primitive type

This commit is contained in:
e5l
2016-07-19 12:34:44 +03:00
parent 84cbaa0f5b
commit 452fbe65b2
@@ -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)