mirror of https://git.sr.ht/~rabbits/uxnlin
Detect tail-calls for JSI
This commit is contained in:
parent
3d3bbad675
commit
f50f4cfee5
|
@ -80,5 +80,13 @@
|
|||
|
||||
BRK
|
||||
|
||||
( try tailcall )
|
||||
|
||||
@label
|
||||
|
||||
label-name
|
||||
|
||||
JMP2r
|
||||
|
||||
~etc/include.tal
|
||||
|
||||
|
|
|
@ -151,6 +151,13 @@ JMP2r
|
|||
;static-dup print-warn2
|
||||
&no-lit
|
||||
|
||||
( tail-calls )
|
||||
;token ;jmp scmp3 #00 EQU ?&no-tail
|
||||
;token/last is-opcode ?&no-tail
|
||||
;token/last LDA cilc #00 EQU ?&no-tail
|
||||
;tailcall print-warn2
|
||||
&no-tail
|
||||
|
||||
&cleanup
|
||||
;token/last ;token/last2 scpy
|
||||
;token ;token/last scpy
|
||||
|
@ -206,12 +213,30 @@ JMP2r
|
|||
|
||||
LDAk LIT "; EQU ?&pass
|
||||
LDAk LIT ". EQU ?&pass
|
||||
LDAk LIT ", EQU ?&pass
|
||||
LDAk LIT "# EQU ?&pass
|
||||
POP2 #00
|
||||
|
||||
JMP2r
|
||||
&pass POP2 #01 JMP2r
|
||||
|
||||
@is-opcode ( string* -- f )
|
||||
|
||||
DUP2 ;opcodes/brk scmp3 ?find-opcode/on-brk
|
||||
|
||||
@find-opcode ( name* -- byte )
|
||||
|
||||
,&t STR2
|
||||
#2000
|
||||
&l
|
||||
#00 OVR #03 MUL ;opcodes ADD2 [ LIT2 &t $2 ] scmp3 ?&on-found
|
||||
INC GTHk ?&l
|
||||
POP2 #00
|
||||
|
||||
JMP2r
|
||||
&on-found POP2 #01 JMP2r
|
||||
&on-brk POP2 #01 JMP2r
|
||||
|
||||
@print-warn ( str* -- )
|
||||
|
||||
.stats/warnings LDZ2k INC2 ROT STZ2
|
||||
|
@ -271,6 +296,7 @@ JMP2r
|
|||
@|stdlib )
|
||||
|
||||
@ciuc ( c -- f ) LIT "A SUB #19 LTH JMP2r
|
||||
@cilc ( c -- f ) LIT "a SUB #1a LTH JMP2r
|
||||
@scap ( str* -- end* ) LDAk #00 NEQ [ JMP JMP2r ] &w INC2 LDAk ?&w JMP2r
|
||||
@sput ( chr str* -- ) scap STA JMP2r
|
||||
@slen ( str* -- len* ) DUP2 scap SWP2 SUB2 JMP2r
|
||||
|
@ -351,6 +377,13 @@ JMP2r
|
|||
(
|
||||
@|assets )
|
||||
|
||||
@opcodes
|
||||
"LIT "INC "POP "NIP "SWP "ROT "DUP "OVR
|
||||
"EQU "NEQ "GTH "LTH "JMP "JCN "JSR "STH
|
||||
"LDZ "STZ "LDR "STR "LDA "STA "DEI "DEO
|
||||
"ADD "SUB "MUL "DIV "AND "ORA "EOR "SFT
|
||||
&brk "BRK
|
||||
|
||||
@ariopcodes
|
||||
"ADD $1 "SUB $1 "MUL $1 "DIV $1
|
||||
"GTH $1 "LTH $1 "EQU $1 "NEQ $1
|
||||
|
@ -383,6 +416,7 @@ JMP2r
|
|||
@combine "Combine $1 ( sequences of two literal bytes )
|
||||
@uncalled "Uncalled $1 ( using JSR when could be calling )
|
||||
@optimize "Optimize $1 ( bad design )
|
||||
@tailcall "Tailcall $1 ( should be a jmi )
|
||||
|
||||
( specifics )
|
||||
@inc "INC $1 @inc2 "INC2 $1
|
||||
|
|
Loading…
Reference in New Issue