mirror of
https://github.com/KarolS/millfork.git
synced 2024-06-12 06:29:34 +00:00
Explicitly addressed variables should have "*.addr"
This commit is contained in:
parent
c57c0c2fdb
commit
917210b4cf
|
@ -71,7 +71,7 @@ class Environment(val parent: Option[Environment], val prefix: String) {
|
|||
def allocateVariables(nf: Option[NormalFunction], callGraph: CallGraph, allocator: VariableAllocator, options: CompilationOptions, onEachVariable: (String, Int) => Unit): Unit = {
|
||||
val b = get[Type]("byte")
|
||||
val p = get[Type]("pointer")
|
||||
var params = nf.fold(List[String]()) { f =>
|
||||
val params = nf.fold(List[String]()) { f =>
|
||||
f.params match {
|
||||
case NormalParamSignature(ps) =>
|
||||
ps.map(p => p.name)
|
||||
|
@ -378,7 +378,7 @@ class Environment(val parent: Option[Environment], val prefix: String) {
|
|||
)
|
||||
addThing(mangled, stmt.position)
|
||||
} else {
|
||||
var stackVariablesSize = env.things.values.map {
|
||||
val stackVariablesSize = env.things.values.map {
|
||||
case StackVariable(n, t, _) if !n.contains(".") => t.size
|
||||
case _ => 0
|
||||
}.sum
|
||||
|
@ -569,7 +569,9 @@ class Environment(val parent: Option[Environment], val prefix: String) {
|
|||
case NumericConstant(n, _) => n < 0x100
|
||||
case _ => false
|
||||
}
|
||||
(RelativeVariable(prefix + name, addr, typ, zeropage = zp), addr)
|
||||
val v = RelativeVariable(prefix + name, addr, typ, zeropage = zp)
|
||||
registerAddressConstant(v, stmt.position)
|
||||
(v, addr)
|
||||
})
|
||||
addThing(v, stmt.position)
|
||||
if (!v.isInstanceOf[MemoryVariable]) {
|
||||
|
|
|
@ -130,4 +130,29 @@ class ArraySuite extends FunSuite with Matchers {
|
|||
m.readByte(0xc001) should equal(0)
|
||||
}
|
||||
}
|
||||
|
||||
test("Pointers") {
|
||||
EmuBenchmarkRun(
|
||||
"""
|
||||
| byte output
|
||||
| pointer a
|
||||
| pointer b
|
||||
| pointer c
|
||||
| void main () {
|
||||
| setup()
|
||||
| reset()
|
||||
| }
|
||||
| void setup() {
|
||||
| a = output.addr
|
||||
| b = output.addr
|
||||
| c = output.addr
|
||||
| }
|
||||
| void reset() {
|
||||
| a[0] = 0
|
||||
| b[0] = 0
|
||||
| c[0] = 0
|
||||
| }
|
||||
""".stripMargin)(_.readByte(0xc000) should equal(0))
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user