fixed invalid removal of string tag from memory()

This commit is contained in:
Irmen de Jong 2021-02-16 23:58:31 +01:00
parent ab544ee965
commit 2f97aedc3c
3 changed files with 2 additions and 44 deletions

View File

@ -87,10 +87,6 @@ internal class BuiltinFunctionsAsmGen(private val program: Program, private val
AsmAssignTarget.fromRegisters(resultRegister ?: RegisterOrPair.AY, null, program, asmgen)
val assign = AsmAssignment(src, target, false, fcall.position)
asmgen.translateNormalAssignment(assign)
// remove the variable for the name, it's not used as a variable only as a tag for the assembler.
val nameDecl = scope.statements.single { it is VarDecl && it.name==nameRef.nameInSource.single() }
asmgen.removals.add(Pair(nameDecl, scope))
asmgen.slabs[name] = size
}

View File

@ -3,6 +3,7 @@ TODO
====
- add sound to the cx16 tehtriz
- hoist all variable declarations up to the subroutine scope *before* even the constant folding takes place (to avoid undefined symbol errors when referring to a variable from another nested scope in the subroutine)
- refactor the asmgen into their own submodule?
- refactor the compiler optimizers into their own submodule?
- optimize swap of two memread values with index, using the same pointer expression/variable, like swap(@(ptr+1), @(ptr+2))
@ -13,7 +14,6 @@ TODO
- add a f_seek() routine for the Cx16 that uses its seek dos api?
- optimizer: detect variables that are written but never read - mark those as unused too and remove them, such as uword unused = memory("unused222", 20) - also remove the memory slab allocation
- add a compiler option to not remove unused subroutines. this allows for building library programs
- hoist all variable declarations up to the subroutine scope *before* even the constant folding takes place (to avoid undefined symbol errors when referring to a variable from another nested scope in the subroutine)
- make it possible to use cpu opcodes such as 'nop' as variable names by prefixing all asm vars with something such as 'v_'
- option to load the built-in library files from a directory instead of the embedded ones (for easier library development/debugging)
- c64: make the graphics.BITMAP_ADDRESS configurable (VIC banking)

View File

@ -6,45 +6,7 @@ main {
sub start() {
uword zzz=memory("derp", 2000)
txt.print("hello")
txt.print("hello2")
txt.print("hello")
txt.print("hello2")
txt.nl()
txt.print("1")
txt.print("1")
txt.nl()
txt.print("12")
txt.print("12")
txt.nl()
txt.print("123")
txt.print("123")
txt.nl()
derp.derp2()
txt.chrout('!')
sys.wait(3*60)
}
}
derp {
sub derp2 () {
txt.print("hello")
txt.print("hello2")
txt.print("hello")
txt.print("hello2")
txt.nl()
txt.print("1")
txt.print("1")
txt.nl()
txt.print("12")
txt.print("12")
txt.nl()
txt.print("123")
txt.print("123")
txt.nl()
}
}