fix comparison of memory expressions (this error prevented some optimizations)

This commit is contained in:
Irmen de Jong 2020-03-26 22:59:42 +01:00
parent 152888ee93
commit ab7d7c2907

View File

@ -432,7 +432,13 @@ data class AssignTarget(val register: Register?,
infix fun isSameAs(value: Expression): Boolean {
return when {
this.memoryAddress!=null -> false
this.memoryAddress!=null -> {
// if the target is a memory write, and the value is a memory read, they're the same if the address matches
if(value is DirectMemoryRead)
this.memoryAddress.addressExpression isSameAs value.addressExpression
else
false
}
this.register!=null -> value is RegisterExpr && value.register==register
this.identifier!=null -> value is IdentifierReference && value.nameInSource==identifier!!.nameInSource
this.arrayindexed!=null -> value is ArrayIndexedExpression &&