translator: fix string name resolving
This commit is contained in:
@@ -124,7 +124,7 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
|
|||||||
val receiveValue = state.bindingContext.get(BindingContext.COMPILE_TIME_VALUE, expr)
|
val receiveValue = state.bindingContext.get(BindingContext.COMPILE_TIME_VALUE, expr)
|
||||||
val type = (receiveValue as TypedCompileTimeConstant).type
|
val type = (receiveValue as TypedCompileTimeConstant).type
|
||||||
val value = receiveValue.getValue(type) ?: return null
|
val value = receiveValue.getValue(type) ?: return null
|
||||||
val variable = variableManager.receiveVariable(".str", LLVMStringType(value.toString().length, isLoaded = false), LLVMVariableScope(), pointer = 0)
|
val variable = variableManager.receiveVariable(".str" + LLVMBuilder.UniqueGenerator.generateUniqueString(), LLVMStringType(value.toString().length, isLoaded = false), LLVMVariableScope(), pointer = 0)
|
||||||
|
|
||||||
codeBuilder.addStringConstant(variable, value.toString())
|
codeBuilder.addStringConstant(variable, value.toString())
|
||||||
return variable
|
return variable
|
||||||
|
|||||||
@@ -11,6 +11,14 @@ class LLVMBuilder(val arm: Boolean = false) {
|
|||||||
private var variableCount = 0
|
private var variableCount = 0
|
||||||
private var labelCount = 0
|
private var labelCount = 0
|
||||||
|
|
||||||
|
object UniqueGenerator {
|
||||||
|
private var unique = 0
|
||||||
|
fun generateUniqueString(): String {
|
||||||
|
unique += 1
|
||||||
|
return ".unique." + unique
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
initBuilder()
|
initBuilder()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user