mirror of
https://github.com/irmen/prog8.git
synced 2024-11-29 17:50:35 +00:00
remove unneeded sibling methods
This commit is contained in:
parent
fe17566370
commit
1b576f826d
@ -1304,7 +1304,7 @@ $repeatLabel lda $counterVar
|
|||||||
}
|
}
|
||||||
inits.add(stmt)
|
inits.add(stmt)
|
||||||
} else {
|
} else {
|
||||||
val next = (stmt.parent as IStatementContainer).nextSibling(stmt)
|
val next = stmt.nextSibling()
|
||||||
if (next !is ForLoop || next.loopVar.nameInSource.single() != stmt.name) {
|
if (next !is ForLoop || next.loopVar.nameInSource.single() != stmt.name) {
|
||||||
assignInitialValueToVar(stmt, listOf(stmt.name))
|
assignInitialValueToVar(stmt, listOf(stmt.name))
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ class UnusedCodeRemover(private val program: Program,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun reportUnreachable(stmt: Statement, parent: IStatementContainer) {
|
private fun reportUnreachable(stmt: Statement, parent: IStatementContainer) {
|
||||||
when(val next = parent.nextSibling(stmt)) {
|
when(val next = stmt.nextSibling()) {
|
||||||
null, is Label, is Directive, is VarDecl, is InlineAssembly, is Subroutine -> {}
|
null, is Label, is Directive, is VarDecl, is InlineAssembly, is Subroutine -> {}
|
||||||
else -> errors.warn("unreachable code", next.position)
|
else -> errors.warn("unreachable code", next.position)
|
||||||
}
|
}
|
||||||
|
@ -56,22 +56,6 @@ interface IStatementContainer {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
fun nextSibling(stmt: Statement): Statement? {
|
|
||||||
val nextIdx = statements.indexOfFirst { it===stmt } + 1
|
|
||||||
return if(nextIdx < statements.size)
|
|
||||||
statements[nextIdx]
|
|
||||||
else
|
|
||||||
null
|
|
||||||
}
|
|
||||||
|
|
||||||
fun previousSibling(stmt: Statement): Statement? {
|
|
||||||
val previousIdx = statements.indexOfFirst { it===stmt } - 1
|
|
||||||
return if(previousIdx>=0)
|
|
||||||
statements[previousIdx]
|
|
||||||
else
|
|
||||||
null
|
|
||||||
}
|
|
||||||
|
|
||||||
fun indexOfChild(stmt: Statement): Int {
|
fun indexOfChild(stmt: Statement): Int {
|
||||||
val idx = statements.indexOfFirst { it===stmt }
|
val idx = statements.indexOfFirst { it===stmt }
|
||||||
if(idx>=0)
|
if(idx>=0)
|
||||||
|
@ -4,6 +4,7 @@ TODO
|
|||||||
For next compiler release (7.2)
|
For next compiler release (7.2)
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
- fix the asm-labels problem (github issue #62)
|
- fix the asm-labels problem (github issue #62)
|
||||||
|
- fix that "uword qq =$1000+xx" uses stack eval, while "uword qq; qq=$1000+xx" uses optimized code
|
||||||
- find a way to optimize asm-subroutine param passing where it now sometimes uses the evalstack?
|
- find a way to optimize asm-subroutine param passing where it now sometimes uses the evalstack?
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,23 +1,26 @@
|
|||||||
%import textio
|
%import textio
|
||||||
%zeropage basicsafe
|
%zeropage dontuse
|
||||||
|
|
||||||
main {
|
main {
|
||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
|
|
||||||
|
|
||||||
ubyte xx = 100
|
ubyte xx = 100
|
||||||
ubyte cv
|
uword qq =$1234+xx ; TODO FIX THAT THIS USES STACK
|
||||||
|
|
||||||
sys.memset($1000+xx, 10, 255) ; TODO uses stack eval now to precalc parameters
|
uword ww
|
||||||
|
ww=$1234+xx
|
||||||
|
|
||||||
xx = xx & %0001 ; doesn't use stack... because it uses AugmentableAssignmentAsmGen
|
; ubyte cv
|
||||||
;yy = xx & %0001 ; doesn't use stack... because it uses AugmentableAssignmentAsmGen
|
; sys.memset($1000+xx, 10, 255) ; TODO uses stack eval now to precalc parameters
|
||||||
|
;
|
||||||
;ubyte yy = xx & %0001 ; TODO uses stack eval....
|
; xx = xx & %0001 ; doesn't use stack... because it uses AugmentableAssignmentAsmGen
|
||||||
if xx & %0001 { ; TODO why does this use stack? because it uses asmgen.assignExpressionToRegister eventually line 253 in AssignmentAsmGen no augmentable-assignment.
|
; ;yy = xx & %0001 ; doesn't use stack... because it uses AugmentableAssignmentAsmGen
|
||||||
xx--
|
;
|
||||||
}
|
; ;ubyte yy = xx & %0001 ; TODO uses stack eval....
|
||||||
|
; if xx & %0001 { ; TODO why does this use stack? because it uses asmgen.assignExpressionToRegister eventually line 253 in AssignmentAsmGen no augmentable-assignment.
|
||||||
|
; xx--
|
||||||
|
; }
|
||||||
|
|
||||||
; if xx+1 { ; TODO why does this use stack? see above
|
; if xx+1 { ; TODO why does this use stack? see above
|
||||||
; xx++
|
; xx++
|
||||||
|
Loading…
Reference in New Issue
Block a user