vm var allocator now also recognises the memory-mapped variables. no longer crashes

This commit is contained in:
Irmen de Jong
2022-06-30 21:48:42 +02:00
parent 2ad4fdbbb9
commit f675dbc726
5 changed files with 65 additions and 29 deletions
@@ -26,6 +26,18 @@ class VariableAllocator(private val st: SymbolTable, private val program: PtProg
allocations[variable.scopedName] = nextLocation
nextLocation += memsize
}
for (memvar in st.allMemMappedVariables) {
// TODO virtual machine doesn't have memory mapped variables, so treat them as regular allocated variables for now
val memsize =
when (memvar.dt) {
in NumericDatatypes -> program.memsizer.memorySize(memvar.dt)
in ArrayDatatypes -> program.memsizer.memorySize(memvar.dt, memvar.length!!)
else -> throw InternalCompilerException("weird dt")
}
allocations[memvar.scopedName] = nextLocation
nextLocation += memsize
}
freeMemoryStart = nextLocation
}