mirror of
https://github.com/irmen/prog8.git
synced 2024-09-16 16:55:50 +00:00
do..until condition can now refer to variables defined in the loop's inner scope.
This commit is contained in:
parent
1d1fe364d0
commit
e1d0dbed0c
@ -137,7 +137,15 @@ interface INameScope {
|
|||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
} else {
|
} else {
|
||||||
// unqualified name, find the scope the localContext is in, look in that first
|
// unqualified name
|
||||||
|
// special case: the do....until statement can also look INSIDE the anonymous scope
|
||||||
|
if(localContext.parent.parent is UntilLoop) {
|
||||||
|
val symbolFromInnerScope = (localContext.parent.parent as UntilLoop).body.getLabelOrVariable(scopedName[0])
|
||||||
|
if(symbolFromInnerScope!=null)
|
||||||
|
return symbolFromInnerScope
|
||||||
|
}
|
||||||
|
|
||||||
|
// find the scope the localContext is in, look in that first
|
||||||
var statementScope = localContext
|
var statementScope = localContext
|
||||||
while(statementScope !is ParentSentinel) {
|
while(statementScope !is ParentSentinel) {
|
||||||
val localScope = statementScope.definingScope()
|
val localScope = statementScope.definingScope()
|
||||||
@ -312,6 +320,16 @@ class GlobalNamespace(val modules: List<Module>): Node, INameScope {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// special case: the do....until statement can also look INSIDE the anonymous scope
|
||||||
|
if(localContext.parent.parent is UntilLoop) {
|
||||||
|
val symbolFromInnerScope = (localContext.parent.parent as UntilLoop).body.lookup(scopedName, localContext)
|
||||||
|
if(symbolFromInnerScope!=null)
|
||||||
|
return symbolFromInnerScope
|
||||||
|
}
|
||||||
|
val p1 = localContext.parent
|
||||||
|
val p2 = localContext.parent.parent
|
||||||
|
|
||||||
// lookup something from the module.
|
// lookup something from the module.
|
||||||
return when (val stmt = localContext.definingModule().lookup(scopedName, localContext)) {
|
return when (val stmt = localContext.definingModule().lookup(scopedName, localContext)) {
|
||||||
is Label, is VarDecl, is Block, is Subroutine, is StructDecl -> stmt
|
is Label, is VarDecl, is Block, is Subroutine, is StructDecl -> stmt
|
||||||
|
@ -4,7 +4,6 @@ TODO
|
|||||||
|
|
||||||
- get rid of all other TODO's in the code ;-)
|
- get rid of all other TODO's in the code ;-)
|
||||||
- line-circle-gfx examples are now a few hundred bytes larger than before (~4.0/4.1 version i think?). Why is that, can it be fixed?
|
- line-circle-gfx examples are now a few hundred bytes larger than before (~4.0/4.1 version i think?). Why is that, can it be fixed?
|
||||||
- until condition should be able to refer to variables defined IN the do-until block itself.
|
|
||||||
- add support? example? for processing arguments to a sys call : sys 999, 1, 2, "aaa"
|
- add support? example? for processing arguments to a sys call : sys 999, 1, 2, "aaa"
|
||||||
- make it possible for array literals to not only contain compile time constants
|
- make it possible for array literals to not only contain compile time constants
|
||||||
- further optimize assignment codegeneration
|
- further optimize assignment codegeneration
|
||||||
@ -20,6 +19,7 @@ More optimizations
|
|||||||
|
|
||||||
Add more compiler optimizations to the existing ones.
|
Add more compiler optimizations to the existing ones.
|
||||||
|
|
||||||
|
- better assembly for comparison expressions most notably == and != (these use eval stack all the time)
|
||||||
- more targeted optimizations for assigment asm code, such as the following:
|
- more targeted optimizations for assigment asm code, such as the following:
|
||||||
- subroutine calling convention? like: 1 byte arg -> pass in A, 2 bytes -> pass in A+Y, return value likewise.
|
- subroutine calling convention? like: 1 byte arg -> pass in A, 2 bytes -> pass in A+Y, return value likewise.
|
||||||
- can such parameter passing to subroutines be optimized to avoid copying?
|
- can such parameter passing to subroutines be optimized to avoid copying?
|
||||||
|
@ -8,8 +8,10 @@ main $0900{
|
|||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
|
|
||||||
|
ubyte x= 1
|
||||||
do {
|
do {
|
||||||
ubyte v = 1
|
ubyte v = x
|
||||||
|
x++
|
||||||
} until v==0
|
} until v==0
|
||||||
|
|
||||||
; @($c000) *= 99 ; TODO implement
|
; @($c000) *= 99 ; TODO implement
|
||||||
|
Loading…
Reference in New Issue
Block a user