nurpax / c64jasm

C64 6502 assembler in TypeScript
51 stars 14 forks source link

nested namespaces #35

Closed nurpax closed 5 years ago

nurpax commented 5 years ago

would support https://github.com/nurpax/c64jasm/issues/20 too.

some problems in current scoping:

foo: {
bar:
}

lda foo.bar

the dot operator resolution in the assembler is sort of complicated since it can be either an object reference or a sort of undefined scope resolve.

perhaps nested access should instead be done by :: like in C++. e.g.,

lda foo::bar

to make it explicit and simplify symbol resolution.

macro expanded labels should also be accessible. KA does it like this, this seems good:

        *=$1000
start:  inc c1.color
        dec c2.color
c1:     :setColor()
c2:     :setColor()
        jmp start

KA also supports for-loop labels and if-labels:

       jmp myIf.label

myIf: .if (true) {
         ...
label:   lda #0  // <-- Jumps here
         ...
      } else {
         ...
label:   nop
         ...
}

similarly, for-loop labels can be accessed similarly (in c64jasm syntax):

foo: !for i in range(4) {
lbl: 
}
lda foo[0].lbl
nurpax commented 5 years ago

something like this should also work:

my_lut: {
!byte 0,1,2,3,4,5,6,7
end:
}

macro foo(lut) {
  lda #lut.end - lut
}
nurpax commented 5 years ago

something like this should also work:

my_lut: {
!byte 0,1,2,3,4,5,6,7
end:
}

macro foo(lut) {
  lda #lut.end - lut
}

This won't be supported for now. Would need some sort of string substitution style macro expansion.

nurpax commented 5 years ago

Pretty much all done.