mirror of
https://github.com/irmen/prog8.git
synced 2024-11-16 22:09:56 +00:00
tweak return's use of intermediate variable
This commit is contained in:
parent
adb979df38
commit
586ce1fc80
@ -459,10 +459,14 @@ class StatementOptimizer(private val program: Program,
|
||||
return null
|
||||
}
|
||||
|
||||
if(returnStmt.value is BinaryExpression) {
|
||||
val mod = returnViaIntermediaryVar(returnStmt.value!!)
|
||||
if(mod!=null)
|
||||
return mod
|
||||
// TODO decision when to use intermediary variable to calculate returnvalue seems a bit arbitrary...
|
||||
val returnvalue = returnStmt.value
|
||||
if (returnvalue!=null) {
|
||||
if (returnvalue is BinaryExpression || (returnvalue is TypecastExpression && !returnvalue.expression.isSimple)) {
|
||||
val mod = returnViaIntermediaryVar(returnvalue)
|
||||
if(mod!=null)
|
||||
return mod
|
||||
}
|
||||
}
|
||||
|
||||
return noModifications
|
||||
|
@ -3,10 +3,7 @@ TODO
|
||||
|
||||
For next release
|
||||
^^^^^^^^^^^^^^^^
|
||||
- why does this use stack eval on return:
|
||||
sub sprite_y_for_row(ubyte row) -> word {
|
||||
return (8-row as byte)
|
||||
}
|
||||
...
|
||||
|
||||
|
||||
Need help with
|
||||
|
@ -4,22 +4,20 @@
|
||||
|
||||
main {
|
||||
sub start() {
|
||||
ubyte ccc
|
||||
ubyte @shared qq = string.find("irmendejong", ccc)!=0
|
||||
word ww
|
||||
ww = calculate(6)
|
||||
word ww = calculate(6)
|
||||
txt.print_w(ww)
|
||||
txt.nl()
|
||||
ww = calculate(8)
|
||||
txt.print_w(ww)
|
||||
ubyte bb = calculate2(6)
|
||||
txt.print_ub(bb)
|
||||
txt.nl()
|
||||
ww = calculate(10)
|
||||
txt.print_w(ww)
|
||||
txt.nl()
|
||||
qq = string.find("irmendejong", ccc)!=0
|
||||
}
|
||||
|
||||
sub calculate2(ubyte row) -> ubyte {
|
||||
return 8+row
|
||||
}
|
||||
|
||||
|
||||
sub calculate(ubyte row) -> word {
|
||||
return 8-(row as byte)
|
||||
return 8+row
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user