fixed subroutine name shadow check

This commit is contained in:
Irmen de Jong 2022-11-10 22:45:07 +01:00
parent e614e9787a
commit 3dcf628fdb
4 changed files with 31 additions and 13 deletions

View File

@ -290,8 +290,9 @@ cx16 {
&ubyte d2ier = via2+14
&ubyte d2ora = via2+15
&ubyte ym2151adr = $9f40
&ubyte ym2151dat = $9f41
; YM-2151 sound chip
&ubyte YM_ADDRESS = $9f40
&ubyte YM_DATA = $9f41
const uword extdev = $9f60

View File

@ -86,7 +86,7 @@ internal class AstIdentifiersChecker(private val errors: IErrorReporter,
val existing = subroutine.lookup(listOf(subroutine.name))
if (existing != null && existing !== subroutine) {
if(existing.parent!==existing.parent) // TODO fix this check
if(existing.parent!==subroutine.parent && existing is Subroutine)
nameShadowWarning(subroutine.name, existing.position, subroutine)
else
nameError(subroutine.name, existing.position, subroutine)

View File

@ -3,7 +3,6 @@ TODO
For next release
^^^^^^^^^^^^^^^^
- AstIdentifiersChecker: fix the subroutine name shadow if-condition (see vardecl check)
- 6502 codegen: make it possible to use cpu opcodes such as 'nop' as variable names by prefixing all asm vars with something such as ``p8v_``? Or not worth it (most 3 letter opcodes as variables are nonsensical anyway)
then we can get rid of the instruction lists in the machinedefinitions as well. This is already no problem at all in the IR codegen.
- create BSS section in output program and put StStaticVariables in there with bss=true. Don't forget to add init code to zero out everything that was put in bss. If array in bss->only zero ONCE! So requires self-modifying code

View File

@ -1,17 +1,35 @@
%import textio
%import psg
%zeropage basicsafe
main {
ubyte @shared qqq=123
&uword mapped = $ea31
sub start() {
ubyte bb = 99
txt.print_ub(bb)
txt.print("Hello, world!")
uword ww = bb
txt.print_uw(bb)
txt.print_uw(ww)
ubyte @shared variable
sub nested() {
ubyte @shared variable2
variable2 = 33
nested()
sub nested() {
ubyte @shared variable3
variable3 = 33
}
}
nested()
explosion()
}
sub explosion() {
; this subroutine is not used but it is an example of how to make a sound effect using the psg library!
psg.silent()
psg.voice(0, psg.LEFT, 63, psg.NOISE, 0)
psg.voice(1, psg.RIGHT, 63, psg.NOISE, 0)
psg.freq(0, 1000)
psg.freq(1, 2000)
}
}