This commit is contained in:
Irmen de Jong 2021-10-13 00:50:54 +02:00
parent 66574d058a
commit 557f4f689f
3 changed files with 16 additions and 8 deletions

View File

@ -137,6 +137,9 @@ internal class AstChecker(private val program: Program,
errors.err("word loop variable can only loop over bytes or words", forLoop.position)
}
DataType.FLOAT -> {
// Looping over float variables is very inefficient because the loopvar is going to
// get copied over with new values all the time. We don't support this for now.
// Loop with an integer index variable if you really need to... or write different code.
errors.err("for loop only supports integers", forLoop.position)
}
else -> errors.err("loop variable must be numeric type", forLoop.position)

View File

@ -513,12 +513,14 @@ internal class AsmGen(private val program: Program,
return if(targetScope !== identScope) {
val scopedName = getScopedSymbolNameForTarget(identifier.nameInSource.last(), target)
if(target is Label) {
// make labels locally scoped in the asm. Is slightly problematic, see github issue #62
val last = scopedName.removeLast()
scopedName.add("_$last")
}
fixNameSymbols(scopedName.joinToString("."))
} else {
if(target is Label) {
// make labels locally scoped in the asm. Is slightly problematic, see github issue #62
val scopedName = identifier.nameInSource.toMutableList()
val last = scopedName.removeLast()
scopedName.add("_$last")
@ -1232,7 +1234,8 @@ $repeatLabel lda $counterVar
}
private fun translate(stmt: Label) {
out("_${stmt.name}") // underscore prefix to make sure it's a local label
// underscore prefix to make sure it's a local label. Is slightly problematic, see github issue #62
out("_${stmt.name}")
}
private fun translate(scope: AnonymousScope) {

View File

@ -1,12 +1,14 @@
%import textio
%import test_stack
%zeropage basicsafe
main {
sub start() {
%asminclude "fozsdfsdf.asm"
str myBar = "main.bar"
txt.print("ok")
test_stack.test()
}
foo_bar:
%asminclude "compiler/test/fixtures/foo_bar.asm" ; FIXME: should be accessible from inside start() but give assembler error
sub start() {
txt.print(myBar)
txt.print(&foo_bar)
return
}
}