mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-29 02:49:54 +00:00
04a83f00f3
MKDIR:completely implemented LS/RM/MV/CP: combined switches KERNEL:SList API now handle options to handle several languages/parsers
425 lines
7.1 KiB
Plaintext
425 lines
7.1 KiB
Plaintext
NEW
|
||
AUTO 3,1
|
||
*--------------------------------------
|
||
TYPE.GetTQInYA >ENTER 2
|
||
lda #0
|
||
sta (pStack) Type
|
||
ldy #1
|
||
sta (pStack),y Qual
|
||
|
||
jsr .8
|
||
bcs .99
|
||
|
||
ldy #1
|
||
lda (pStack),y
|
||
pha
|
||
lda (pStack)
|
||
tay Y = Type
|
||
pla A = Qual
|
||
|
||
clc
|
||
|
||
.99 >LEAVE
|
||
rts
|
||
|
||
.8 jmp (J.CC.TYPEQUAL,x)
|
||
*--------------------------------------
|
||
TYPE.GetTQInYA2 >ENTER 2
|
||
lda (ZPLookupSymPtr)
|
||
sta (pStack) Type
|
||
|
||
ldy #SYM.Q
|
||
lda (ZPLookupSymPtr),y
|
||
|
||
* ldy #1
|
||
sta (pStack),y Qual
|
||
|
||
jsr TYPE.GetQ2
|
||
bcs .99
|
||
|
||
jsr SYM.LookupFree
|
||
|
||
ldy #1
|
||
lda (pStack),y
|
||
pha
|
||
lda (pStack)
|
||
tay Y = Type
|
||
pla A = Qual
|
||
|
||
clc
|
||
|
||
.99 >LEAVE
|
||
rts
|
||
*--------------------------------------
|
||
* Type Declaration keywords
|
||
*--------------------------------------
|
||
TYPE.CONST lda #SYM.Q.CONST
|
||
bra TYPE.VOLATILE.1
|
||
*--------------------------------------
|
||
TYPE.VOLATILE lda #SYM.Q.VOLATILE
|
||
TYPE.VOLATILE.1 ldy #1
|
||
ora (pStack),y
|
||
sta (pStack),y
|
||
|
||
jsr CC.CheckSpace
|
||
bcs .9
|
||
|
||
>LDYA L.CC.TYPESPEC
|
||
jsr CC.LookupID
|
||
bcs .9
|
||
|
||
jmp (J.CC.TYPESPEC,x)
|
||
|
||
.9 lda #E.CSYN
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
TYPE.STRUCT clc
|
||
.HS B0 BCS
|
||
*--------------------------------------
|
||
TYPE.UNION sec
|
||
ror ZPPtr2+1 bStrucUnion
|
||
|
||
stz ZPPtr2 bNewTagDef
|
||
|
||
bit bPass2
|
||
bpl TYPE.SU.1 Pass 1: create def
|
||
*--------------------------------------
|
||
TYPE.SU.2 jsr CORE.GetCharNBNL
|
||
bcs .98
|
||
|
||
cmp #'{'
|
||
beq .1 no TAG
|
||
|
||
jsr TYPE.GetTag
|
||
bcs .99
|
||
|
||
jsr CORE.GetNCharNBNL
|
||
bcs .98
|
||
|
||
cmp #'{'
|
||
bne .8
|
||
|
||
.1 jsr CORE.GetNCharNBNL skip '{'
|
||
|
||
cmp #'}'
|
||
bne .1 skip definition
|
||
|
||
jsr CORE.GetNCharNB skip '}'
|
||
|
||
.8 lda #SYM.T.SU
|
||
jmp TYPE.GetQ
|
||
|
||
.98 lda #E.CSYN
|
||
sec
|
||
.99 rts
|
||
*--------------------------------------
|
||
TYPE.SU.1 ldy #SYM.T.SU
|
||
lda #0
|
||
ldx #SYM.SC.TAG
|
||
sec reset buffer
|
||
jsr SYM.BufInitYAXC
|
||
|
||
jsr CORE.GetCharNBNL
|
||
bcs .98
|
||
|
||
cmp #'{'
|
||
beq .30 no TAG
|
||
|
||
jsr TYPE.GetTag
|
||
bcc .20
|
||
|
||
jsr TYPE.NewTag
|
||
bcs .99
|
||
|
||
sec
|
||
ror ZPPtr2 bNewTagDef
|
||
*--------------------------------------
|
||
.20 jsr CORE.GetCharNBNL
|
||
bcs .98
|
||
|
||
cmp #'{'
|
||
beq .30
|
||
|
||
bit ZPPtr2 bNewTagDef
|
||
bmi .98
|
||
|
||
bra .38
|
||
*--------------------------------------
|
||
.30 jsr CORE.GetNCharNBNL skip '{' of ';'
|
||
bcs .98
|
||
|
||
cmp #'}'
|
||
beq .37
|
||
|
||
>LDYA L.CC.TYPEQUAL
|
||
jsr CC.LookupID
|
||
bcs .98
|
||
|
||
cpx #4 no const nor volatile
|
||
bcc .98
|
||
|
||
jsr TYPE.GetTQInYA
|
||
bcs .99
|
||
|
||
jsr TYPE.SizeOf get sizeof in X
|
||
|
||
jsr TYPE.SU.AddYAX
|
||
bcs .99
|
||
|
||
jsr SYM.Add0000 TODO: bitO & bitW
|
||
bcs .99
|
||
|
||
jsr SYM.AddName
|
||
bcs .99
|
||
|
||
jsr CC.GetCharNB
|
||
cmp #';'
|
||
bne .98
|
||
|
||
bra .30
|
||
*--------------------------------------
|
||
.37 jsr CORE.GetNCharNB skip '}'
|
||
bcs .98
|
||
|
||
jsr SYM.Add0000 Close F definition
|
||
bcs .99
|
||
|
||
bit ZPPtr2 bNewTagDef
|
||
bpl .38
|
||
|
||
jsr TYPE.StoreTag
|
||
bcs .99
|
||
*--------------------------------------
|
||
.38 lda #SYM.T.SU
|
||
jmp TYPE.GetQ
|
||
|
||
.98 lda #E.CSYN
|
||
sec
|
||
.99 rts
|
||
*--------------------------------------
|
||
TYPE.SU.AddYAX jsr SYM.AddWord add T/Q
|
||
bcs .99
|
||
|
||
bit ZPPtr2+1 bStrucUnion
|
||
bmi .1
|
||
|
||
ldy #SYM.SizeOf
|
||
lda (ZPSymBufPtr),y
|
||
pha
|
||
iny
|
||
lda (ZPSymBufPtr),y
|
||
ply
|
||
|
||
jsr SYM.AddWord Add Y/A Offset
|
||
bcs .99
|
||
|
||
txa
|
||
|
||
ldy #SYM.SizeOf
|
||
* clc
|
||
adc (ZPSymBufPtr),y
|
||
sta (ZPSymBufPtr),y
|
||
bcc .99
|
||
|
||
iny
|
||
lda #0
|
||
adc (ZPSymBufPtr),y
|
||
sta (ZPSymBufPtr),y
|
||
|
||
* clc
|
||
|
||
.99 rts
|
||
|
||
.1 txa
|
||
ldy #SYM.SizeOf
|
||
cmp (ZPSymBufPtr),y
|
||
bcs .2
|
||
|
||
sta (ZPSymBufPtr),y
|
||
|
||
.2 jmp SYM.Add0000 Add Y/A Offset (always 0 for union)
|
||
*--------------------------------------
|
||
TYPE.ENUM
|
||
lda #E.CSYN
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
TYPE.NewTag >LDA.G CC.hTags
|
||
jsr SYM.NewKey
|
||
bcs .9
|
||
|
||
>STYA ZPPtr1 TagID
|
||
dec ZPPtr2 bNewTagDef = true
|
||
|
||
jsr CC.SkipX
|
||
|
||
.9 rts
|
||
*--------------------------------------
|
||
TYPE.GetTag >PUSHB.G CC.hTags
|
||
>PUSHW ZPLineBufPtr
|
||
|
||
>SYSCALL SListLookup
|
||
bcs .9
|
||
|
||
phy Y,A = KeyID
|
||
pha
|
||
|
||
jsr CC.SkipX X = KeyLen
|
||
|
||
>PUSHB.G CC.hTags
|
||
pla
|
||
>PUSHA
|
||
pla
|
||
>PUSHA
|
||
>PUSHW ZPSymBufPtr
|
||
>PUSHWI 65535 all
|
||
>PUSHWZ From Start
|
||
>SYSCALL SListGetData
|
||
.9 rts
|
||
*--------------------------------------
|
||
TYPE.StoreTag >PUSHB.G CC.hTags
|
||
>PUSHW ZPPtr1
|
||
>PUSHW ZPSymBufPtr
|
||
>PUSHBI 0
|
||
ldy #SYM.DefSize
|
||
lda (ZPSymBufPtr),y
|
||
>PUSHA
|
||
|
||
>SYSCALL SListAddData
|
||
rts
|
||
*--------------------------------------
|
||
TYPE.SIGNED sec
|
||
.HS 90 BCC
|
||
*--------------------------------------
|
||
TYPE.UNSIGNED clc
|
||
php
|
||
|
||
jsr CC.CheckSpace
|
||
bcs .9
|
||
|
||
>LDYA L.CC.TYPES
|
||
jsr CC.LookupID
|
||
bcs .9
|
||
|
||
cpx #SYM.T.UCHAR
|
||
bcc .9 void
|
||
|
||
cpx #SYM.T.SLONG+1 only char int long allowed
|
||
bcs .9
|
||
|
||
plp
|
||
bcs .8
|
||
|
||
jmp (J.CC.UTYPES-2,x)
|
||
|
||
.8 jmp (J.CC.STYPES-2,x)
|
||
|
||
.9 plp
|
||
|
||
lda #E.CSYN
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
TYPE.SHORT jsr CC.CheckSpace
|
||
bcs .9
|
||
|
||
>LDYA L.CC.TYPES
|
||
jsr CC.LookupID
|
||
|
||
bcs TYPE.UCHAR
|
||
|
||
cpx #4 only int allowed
|
||
beq TYPE.SCHAR
|
||
|
||
.9 lda #E.CSYN
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
TYPE.VOID lda #SYM.T.VOID
|
||
bra TYPE.GetQ
|
||
|
||
TYPE.CHAR
|
||
TYPE.UCHAR lda #SYM.T.UCHAR
|
||
bra TYPE.GetQ
|
||
|
||
TYPE.SCHAR lda #SYM.T.SCHAR
|
||
bra TYPE.GetQ
|
||
|
||
TYPE.UINT lda #SYM.T.UINT
|
||
bra TYPE.GetQ
|
||
|
||
TYPE.INT
|
||
TYPE.SINT lda #SYM.T.SINT
|
||
bra TYPE.GetQ
|
||
|
||
TYPE.ULONG lda #SYM.T.ULONG
|
||
bra TYPE.GetQ
|
||
|
||
TYPE.LONG
|
||
TYPE.SLONG lda #SYM.T.SLONG
|
||
bra TYPE.GetQ
|
||
|
||
TYPE.FLOAT lda #SYM.T.FLOAT
|
||
|
||
TYPE.GetQ sta (pStack) T
|
||
|
||
TYPE.GetQ2 jsr CC.GetCharNB
|
||
bcs .9
|
||
|
||
.1 cmp #'*'
|
||
bne .10
|
||
|
||
ldy #1 Q
|
||
lda (pStack),y
|
||
clc
|
||
adc #SYM.Q.POINTER
|
||
bcs .9 more than ***
|
||
|
||
sta (pStack),y
|
||
|
||
jsr CORE.GetNCharNB
|
||
bcc .1
|
||
|
||
.9 lda #E.CSYN
|
||
sec
|
||
.99 rts
|
||
*--------------------------------------
|
||
.10 jsr CC.IsLetter
|
||
bcs .8
|
||
|
||
>LDYA L.CC.FTYPES int fastcall f() ?
|
||
jsr CC.LookupID
|
||
bcs .8 next char is an identifier
|
||
|
||
ldy #1
|
||
lda (pStack),y
|
||
ora #SYM.Q.FUNC+SYM.Q.FASTCALL
|
||
sta (pStack),y
|
||
|
||
jsr CORE.GetNCharNB
|
||
bcs .9 next char is an identifier, ",", "(",")"
|
||
|
||
.8 clc
|
||
rts
|
||
*--------------------------------------
|
||
* in : Y,A = type/qual
|
||
* out : X = size
|
||
*--------------------------------------
|
||
TYPE.SizeOf bit #SYM.Q.PPPOINTER
|
||
bne .2
|
||
|
||
ldx CC.TYPESIZE-1,y
|
||
|
||
clc
|
||
rts
|
||
|
||
.2 ldx #2 pointer
|
||
sec +1 for hMem Storage
|
||
rts
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE usr/src/bin/cc.s.type
|
||
LOAD usr/src/bin/cc.s
|
||
ASM
|