mirror of
https://github.com/irmen/prog8.git
synced 2025-02-04 17:38:37 +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
|
||||
} 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
|
||||
while(statementScope !is ParentSentinel) {
|
||||
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.
|
||||
return when (val stmt = localContext.definingModule().lookup(scopedName, localContext)) {
|
||||
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 ;-)
|
||||
- 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"
|
||||
- make it possible for array literals to not only contain compile time constants
|
||||
- further optimize assignment codegeneration
|
||||
@ -20,6 +19,7 @@ More optimizations
|
||||
|
||||
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:
|
||||
- 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?
|
||||
|
@ -8,8 +8,10 @@ main $0900{
|
||||
|
||||
sub start() {
|
||||
|
||||
ubyte x= 1
|
||||
do {
|
||||
ubyte v = 1
|
||||
ubyte v = x
|
||||
x++
|
||||
} until v==0
|
||||
|
||||
; @($c000) *= 99 ; TODO implement
|
||||
|
Loading…
x
Reference in New Issue
Block a user