fix assigning a pointer (uword) to string not copying the correct memory

This commit is contained in:
Irmen de Jong 2022-05-15 16:10:58 +02:00
parent 4dc9b45297
commit d1a707df57
2 changed files with 10 additions and 7 deletions

View File

@ -414,14 +414,10 @@ internal class StatementReorderer(val program: Program,
private fun copyStringValue(assign: Assignment): List<IAstModification> { private fun copyStringValue(assign: Assignment): List<IAstModification> {
val identifier = assign.target.identifier!! val identifier = assign.target.identifier!!
val sourceIdent = assign.value as? IdentifierReference
val strcopy = FunctionCallStatement(IdentifierReference(listOf("sys", "internal_stringcopy"), assign.position), val strcopy = FunctionCallStatement(IdentifierReference(listOf("sys", "internal_stringcopy"), assign.position),
mutableListOf( mutableListOf(
if(sourceIdent!=null) assign.value as? IdentifierReference ?: assign.value,
AddressOf(sourceIdent, assign.position) identifier
else
assign.value,
AddressOf(identifier, assign.position)
), ),
true, true,
assign.position assign.position

View File

@ -27,7 +27,14 @@ main {
ubyte @shared value = inline_candidate() ubyte @shared value = inline_candidate()
str name = "irmen123ABC" str name = "irmen123ABC"
str other = "zrmen123ABC" str other = "zrmen123zzz"
txt.print(name)
txt.nl()
name=other
txt.print(name)
txt.nl()
txt.nl()
txt.print_ub(string.upper(name)) txt.print_ub(string.upper(name))
txt.print(name) txt.print(name)