mirror of
https://github.com/irmen/prog8.git
synced 2024-11-20 03:32:05 +00:00
fix inlining of sub with var that has default initialization
This commit is contained in:
parent
e5ff61f201
commit
a9d297ee31
@ -22,7 +22,7 @@ internal class BeforeAsmGenerationAstChanger(val program: Program, val errors: I
|
||||
if(decl.allowInitializeWithZero)
|
||||
{
|
||||
val nextAssign = decl.definingScope().nextSibling(decl) as? Assignment
|
||||
if (nextAssign != null && nextAssign.target.isSameAs(IdentifierReference(listOf(decl.name), Position.DUMMY)))
|
||||
if (nextAssign != null && nextAssign.target isSameAs IdentifierReference(listOf(decl.name), Position.DUMMY))
|
||||
decl.value = null
|
||||
else
|
||||
decl.value = decl.zeroElementValue()
|
||||
|
@ -124,7 +124,8 @@ internal class FunctionCallAsmGen(private val program: Program, private val asmg
|
||||
if(it is Return) {
|
||||
asmgen.translate(it, false) // don't use RTS for the inlined return statement
|
||||
} else {
|
||||
asmgen.translate(it)
|
||||
if(!sub.inline || it !is VarDecl)
|
||||
asmgen.translate(it)
|
||||
}
|
||||
}
|
||||
asmgen.out(" \t; inlined routine end: ${sub.name}")
|
||||
|
@ -1,5 +1,5 @@
|
||||
%import textio
|
||||
%zeropage basicsafe
|
||||
%zeropage dontuse
|
||||
|
||||
main {
|
||||
|
||||
@ -9,17 +9,15 @@ main {
|
||||
; cx16.rambank(4)
|
||||
; cx16.rambank(4)
|
||||
; cx16.rambank(4)
|
||||
uword yy = 12345
|
||||
ubyte xx
|
||||
xx = calc2(41, 12345)
|
||||
xx = calc2(41, 12345)
|
||||
xx = calc2(41, 12345)
|
||||
xx = calc2(41, 12345)
|
||||
txt.print_ub(xx) ; must be 99
|
||||
txt.nl()
|
||||
}
|
||||
|
||||
inline sub calc2(ubyte a1, uword a2) -> ubyte {
|
||||
uword thesum = a2 + a1
|
||||
return lsb(thesum+a2)
|
||||
uword thesum
|
||||
thesum = a2 + a1
|
||||
return lsb(thesum)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user