mirror of
https://github.com/irmen/prog8.git
synced 2024-12-27 05:29:38 +00:00
doc
This commit is contained in:
parent
66574d058a
commit
557f4f689f
@ -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)
|
errors.err("word loop variable can only loop over bytes or words", forLoop.position)
|
||||||
}
|
}
|
||||||
DataType.FLOAT -> {
|
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)
|
errors.err("for loop only supports integers", forLoop.position)
|
||||||
}
|
}
|
||||||
else -> errors.err("loop variable must be numeric type", forLoop.position)
|
else -> errors.err("loop variable must be numeric type", forLoop.position)
|
||||||
|
@ -513,12 +513,14 @@ internal class AsmGen(private val program: Program,
|
|||||||
return if(targetScope !== identScope) {
|
return if(targetScope !== identScope) {
|
||||||
val scopedName = getScopedSymbolNameForTarget(identifier.nameInSource.last(), target)
|
val scopedName = getScopedSymbolNameForTarget(identifier.nameInSource.last(), target)
|
||||||
if(target is Label) {
|
if(target is Label) {
|
||||||
|
// make labels locally scoped in the asm. Is slightly problematic, see github issue #62
|
||||||
val last = scopedName.removeLast()
|
val last = scopedName.removeLast()
|
||||||
scopedName.add("_$last")
|
scopedName.add("_$last")
|
||||||
}
|
}
|
||||||
fixNameSymbols(scopedName.joinToString("."))
|
fixNameSymbols(scopedName.joinToString("."))
|
||||||
} else {
|
} else {
|
||||||
if(target is Label) {
|
if(target is Label) {
|
||||||
|
// make labels locally scoped in the asm. Is slightly problematic, see github issue #62
|
||||||
val scopedName = identifier.nameInSource.toMutableList()
|
val scopedName = identifier.nameInSource.toMutableList()
|
||||||
val last = scopedName.removeLast()
|
val last = scopedName.removeLast()
|
||||||
scopedName.add("_$last")
|
scopedName.add("_$last")
|
||||||
@ -1232,7 +1234,8 @@ $repeatLabel lda $counterVar
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun translate(stmt: Label) {
|
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) {
|
private fun translate(scope: AnonymousScope) {
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
%import textio
|
%import textio
|
||||||
%import test_stack
|
|
||||||
%zeropage basicsafe
|
|
||||||
|
|
||||||
main {
|
main {
|
||||||
sub start() {
|
str myBar = "main.bar"
|
||||||
%asminclude "fozsdfsdf.asm"
|
|
||||||
|
|
||||||
txt.print("ok")
|
foo_bar:
|
||||||
test_stack.test()
|
%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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user