errormessage for assignment to str/arrays in ROM

This commit is contained in:
Irmen de Jong
2025-03-31 23:57:04 +02:00
parent 1075ee8fc3
commit 61079c1eb7
2 changed files with 48 additions and 6 deletions

View File

@@ -686,6 +686,25 @@ internal class AstChecker(private val program: Program,
}
}
}
fun checkRomTarget(target: AssignTarget) {
val idx=target.arrayindexed
if(idx!=null) {
val decl = idx.arrayvar.targetVarDecl(program)!!
if(decl.type!=VarDeclType.MEMORY && decl.zeropage!=ZeropageWish.REQUIRE_ZEROPAGE) {
// memory mapped arrays are assumed to be in RAM. If they're not.... well, POOF
errors.err("cannot assign to an array or string that is located in ROM", assignTarget.position)
}
}
}
if(compilerOptions.romable) {
if (assignTarget.multi != null)
assignTarget.multi?.forEach { checkRomTarget(it) }
else
checkRomTarget(assignTarget)
}
}
override fun visit(addressOf: AddressOf) {