This commit is contained in:
Irmen de Jong 2021-04-01 22:10:04 +02:00
parent 1fe4439395
commit fe2954ce08
3 changed files with 17 additions and 19 deletions

View File

@ -205,7 +205,7 @@ internal class AstChecker(private val program: Program,
if(subroutine.inline) {
if (subroutine.containsDefinedVariables())
err("can't inline a subroutine that defines variables")
err("can't inline a subroutine that defines variables (might also be a generated intermediate variable for complex return expressions)")
if (!subroutine.isAsmSubroutine && subroutine.parameters.isNotEmpty())
err("can't inline a non-asm subroutine that has parameters")
}

View File

@ -2,6 +2,7 @@
TODO
====
- allow inlining of subroutines with vardecls
- optimize several inner loops in gfx2
- hoist all variable declarations up to the subroutine scope *before* even the constant folding takes place (to avoid undefined symbol errors when referring to a variable from another nested scope in the subroutine)
- optimize swap of two memread values with index, using the same pointer expression/variable, like swap(@(ptr+1), @(ptr+2))

View File

@ -1,27 +1,11 @@
%import textio
%zeropage basicsafe
%option no_sysinit
main {
sub start() {
ubyte color=0
ubyte xx
uword ptr = $0400
@($02) = 0
repeat {
sys.waitvsync()
%asm {{
ldy $02
lda #'*'
sta $0400,y
inc $02
}}
}
txt.print("hello")
ubyte thing = otherblock.othersub()
txt.print_ub(thing) ; should print 99!
; str filename = "titlescreen.bin"
; ubyte success = cx16.vload(filename, 8, 0, $0000)
@ -38,3 +22,16 @@ main {
}
}
otherblock {
ubyte othervar=20
ubyte calcparam=10
sub calc(ubyte zz) -> ubyte {
return zz+1
}
inline sub othersub() -> ubyte {
return calc(calcparam)
}
}