translator: fix for return class and strings
This commit is contained in:
@@ -493,7 +493,11 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
|
||||
args.addAll(names)
|
||||
|
||||
codeBuilder.addLLVMCode(LLVMCall(LLVMVoidType(), function.toString(), args).toString())
|
||||
return codeBuilder.loadAndGetVariable(returnVar)
|
||||
if (returnVar.pointer == 2) {
|
||||
return returnVar
|
||||
} else {
|
||||
return codeBuilder.loadAndGetVariable(returnVar)
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
val result = codeBuilder.getNewVariable(returnType)
|
||||
@@ -1027,7 +1031,8 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
|
||||
allocVar.kotlinName = identifier
|
||||
|
||||
variableManager.addVariable(identifier, allocVar, scopeDepth)
|
||||
codeBuilder.copyVariable(assignExpression, allocVar)
|
||||
|
||||
addPrimitiveBinaryOperation(KtTokens.EQ, null, allocVar, assignExpression)
|
||||
} else {
|
||||
assignExpression.kotlinName = identifier
|
||||
variableManager.addVariable(identifier, assignExpression, scopeDepth)
|
||||
|
||||
@@ -123,8 +123,12 @@ class LLVMBuilder(val arm: Boolean = false) {
|
||||
}
|
||||
|
||||
fun storeVariable(target: LLVMSingleValue, source: LLVMSingleValue) {
|
||||
val code = "store ${source.getType()} $source, ${target.getType()} $target, align ${source.type?.align!!}"
|
||||
localCode.appendln(code)
|
||||
if ((source.type is LLVMStringType) && (!(source.type as LLVMStringType).isLoaded)) {
|
||||
storeString(target as LLVMVariable, source as LLVMVariable, 0)
|
||||
} else {
|
||||
val code = "store ${source.getType()} $source, ${target.getType()} $target, align ${source.type?.align!!}"
|
||||
localCode.appendln(code)
|
||||
}
|
||||
}
|
||||
|
||||
fun storeNull(result: LLVMVariable) {
|
||||
|
||||
@@ -8,11 +8,11 @@ class LLVMFloatType() : LLVMType() {
|
||||
|
||||
//TODO switch by types: int + double = int
|
||||
override fun operatorMinus(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
|
||||
LLVMExpression(LLVMFloatType(), "fsub float i32 $firstOp, $secondOp")
|
||||
LLVMExpression(LLVMFloatType(), "fsub float $firstOp, $secondOp")
|
||||
|
||||
//TODO switch by types: int + double = int
|
||||
override fun operatorTimes(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
|
||||
LLVMExpression(LLVMFloatType(), "fmul float i32 $firstOp, $secondOp")
|
||||
LLVMExpression(LLVMFloatType(), "fmul float $firstOp, $secondOp")
|
||||
|
||||
//TODO switch by types: int + double = int
|
||||
override fun operatorPlus(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
|
||||
|
||||
Reference in New Issue
Block a user