fix invalid assignment reordering

This commit is contained in:
Irmen de Jong 2019-04-20 13:24:42 +02:00
parent ef6e364339
commit a6d0aecd66
3 changed files with 11 additions and 2 deletions

View File

@ -806,6 +806,9 @@ data class AssignTarget(val register: Register?,
return (if(withTypePrefix) "1address::" else "") +address.asIntegerValue.toString()
return if(withTypePrefix) "???::???" else "???"
}
fun isMemoryMapped(namespace: INameScope): Boolean =
memoryAddress!=null || (identifier?.targetVarDecl(namespace)?.type==VarDeclType.MEMORY)
}

View File

@ -160,7 +160,7 @@ private class StatementReorderer(private val namespace: INameScope, private val
val result = mutableListOf<IStatement>()
val stmtIter = statements.iterator()
for(stmt in stmtIter) {
if(stmt is Assignment) {
if(stmt is Assignment && !stmt.targets.any { it.isMemoryMapped(namespace) }) {
val constval = stmt.value.constValue(namespace, heap)
if(constval!=null) {
val (sorted, trailing) = sortConstantAssignmentSequence(stmt, stmtIter)

View File

@ -1,9 +1,15 @@
%zeropage basicsafe
~ main {
&uword COLORS = $d020
sub start() {
%asmbinary "LICENSE", 100, 200
COLORS=12345
COLORS=12346
@(COLORS) = 54
return
}
}