fix var prefix issues in asm gen of anonscopes

This commit is contained in:
Irmen de Jong 2019-07-30 21:13:52 +02:00
parent 8cec032e7d
commit ae90a957c6
3 changed files with 28 additions and 5 deletions

View File

@ -57,8 +57,8 @@ class AnonymousScopeVarsCleanup(val program: Program): IAstModifyingVisitor {
val scope = ident.definingScope() as? AnonymousScope ?: return ident
val vardecl = ident.targetVarDecl(program.namespace)
return if(vardecl!=null) {
// prefix the variable name reference
return if(vardecl!=null && vardecl.definingScope() == ident.definingScope()) {
// prefix the variable name reference that is defined inside the anon scope
ident.withPrefixedName(nameprefix(scope))
} else {
ident

View File

@ -840,7 +840,10 @@ internal class AsmGen2(val program: Program,
}
private fun translate(stmt: RepeatLoop) {
TODO("repeat $stmt")
// TODO("repeat $stmt")
out(";------ TODO REPEAT")
translate(stmt.body)
out(";------ TODO REPEAT END")
}
private fun translate(stmt: WhenStatement) {

View File

@ -10,9 +10,29 @@ main {
sub start() {
A=abc
ubyte zzz
repeat {
uword wvar
Y=abc
Y=zzz
wvar=99
} until 99
repeat {
uword wvar
Y=abc
Y=zzz
wvar=99
} until 99
if A>0 {
uword wvar
Y=abc
Y=zzz
wvar=99
}
if A>0
Y=abc ; @todo gets prefixed with anon1_ but should not be because is found in other scope...
}
}