mirror of https://git.sr.ht/~rabbits/uxnlin
Detect tail-calls for JSI
This commit is contained in:
parent
3d3bbad675
commit
f50f4cfee5
|
@ -76,9 +76,17 @@
|
||||||
#0102 ADD
|
#0102 ADD
|
||||||
|
|
||||||
( do not catch )
|
( do not catch )
|
||||||
[ LIT &test $1 ] #00 EQU
|
[ LIT &test $1 ] #00 EQU
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
|
( try tailcall )
|
||||||
|
|
||||||
|
@label
|
||||||
|
|
||||||
|
label-name
|
||||||
|
|
||||||
|
JMP2r
|
||||||
|
|
||||||
~etc/include.tal
|
~etc/include.tal
|
||||||
|
|
||||||
|
|
|
@ -151,6 +151,13 @@ JMP2r
|
||||||
;static-dup print-warn2
|
;static-dup print-warn2
|
||||||
&no-lit
|
&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
|
&cleanup
|
||||||
;token/last ;token/last2 scpy
|
;token/last ;token/last2 scpy
|
||||||
;token ;token/last 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
|
||||||
|
LDAk LIT ", EQU ?&pass
|
||||||
LDAk LIT "# EQU ?&pass
|
LDAk LIT "# EQU ?&pass
|
||||||
POP2 #00
|
POP2 #00
|
||||||
|
|
||||||
JMP2r
|
JMP2r
|
||||||
&pass POP2 #01 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* -- )
|
@print-warn ( str* -- )
|
||||||
|
|
||||||
.stats/warnings LDZ2k INC2 ROT STZ2
|
.stats/warnings LDZ2k INC2 ROT STZ2
|
||||||
|
@ -271,6 +296,7 @@ JMP2r
|
||||||
@|stdlib )
|
@|stdlib )
|
||||||
|
|
||||||
@ciuc ( c -- f ) LIT "A SUB #19 LTH JMP2r
|
@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
|
@scap ( str* -- end* ) LDAk #00 NEQ [ JMP JMP2r ] &w INC2 LDAk ?&w JMP2r
|
||||||
@sput ( chr str* -- ) scap STA JMP2r
|
@sput ( chr str* -- ) scap STA JMP2r
|
||||||
@slen ( str* -- len* ) DUP2 scap SWP2 SUB2 JMP2r
|
@slen ( str* -- len* ) DUP2 scap SWP2 SUB2 JMP2r
|
||||||
|
@ -351,6 +377,13 @@ JMP2r
|
||||||
(
|
(
|
||||||
@|assets )
|
@|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
|
@ariopcodes
|
||||||
"ADD $1 "SUB $1 "MUL $1 "DIV $1
|
"ADD $1 "SUB $1 "MUL $1 "DIV $1
|
||||||
"GTH $1 "LTH $1 "EQU $1 "NEQ $1
|
"GTH $1 "LTH $1 "EQU $1 "NEQ $1
|
||||||
|
@ -383,6 +416,7 @@ JMP2r
|
||||||
@combine "Combine $1 ( sequences of two literal bytes )
|
@combine "Combine $1 ( sequences of two literal bytes )
|
||||||
@uncalled "Uncalled $1 ( using JSR when could be calling )
|
@uncalled "Uncalled $1 ( using JSR when could be calling )
|
||||||
@optimize "Optimize $1 ( bad design )
|
@optimize "Optimize $1 ( bad design )
|
||||||
|
@tailcall "Tailcall $1 ( should be a jmi )
|
||||||
|
|
||||||
( specifics )
|
( specifics )
|
||||||
@inc "INC $1 @inc2 "INC2 $1
|
@inc "INC $1 @inc2 "INC2 $1
|
||||||
|
|
Loading…
Reference in New Issue