~rabbits/left

ac50e330fbcc1f30c67a620da4a17d70752ebeef — Devine Lu Linvega 2 months ago fc2eea9
Made stdlib of some functions
1 files changed, 25 insertions(+), 25 deletions(-)

M src/left.tal
M src/left.tal => src/left.tal +25 -25
@@ 1040,7 1040,7 @@

@file-reopen ( -- )
	;text <sclr>
	;filepath DUP2 file-is-bin? ?file-open-binary
	;filepath DUP2 fbin? ?file-open-binary
	.File/name DEO2
	#fff0 ;text SUB2 .File/length DEO2
	;text .File/read DEO2


@@ 1082,16 1082,9 @@
	#0a18 DEO
	JMP2r

@file-size ( path* -- size* )
	.File/name DEO2
	#0100 .File/length DEO2
	#ff00 .File/stat DEO2
	#00 #ff04 STA
	#ff00 !shex

@file-inject ( name* -- )
	DUP2 file-is-bin? ?file-inject-binary
	DUP2 file-size ORAk ?{ POP2 POP2 JMP2r }
	DUP2 fbin? ?file-inject-binary
	DUP2 flen ORAk ?{ POP2 POP2 JMP2r }
	STH2k .File/length DEO2
	.File/name DEO2
	( | erase when selection length )


@@ 1102,7 1095,7 @@
	get-from STH2r ADD2 !<select-a>

@file-inject-binary ( name* -- )
	get-from STH2k OVR2 file-size DUP2 ADD2 DUP2 #02 SFT2 ADD2 <msfr>
	get-from STH2k OVR2 flen DUP2 ADD2 DUP2 #02 SFT2 ADD2 <msfr>
	.File/name DEO2
	#0001 .File/length DEO2
	STH2r inject-binary DUP2 get-from SUB2 <mod-length> !<select-a>


@@ 1132,20 1125,6 @@

	&tal-ext ".tal $1

@file-is-bin? ( path* -- bool )
	.File/name DEO2
	#0001 .File/length DEO2
	&s ( -- )
	;&b feof? ?{
		[ LIT &b $1 ] ?&s
		#01 JMP2r
		!&s }
	#00 JMP2r

@feof? ( buf* -- eof )
	.File/read DEO2
	.File/success DEI2 #0000 EQU2 JMP2r

@inject-binary ( addr* -- addr* )
	STH2
	#0000


@@ 1596,6 1575,27 @@
		SUB [ LIT "a ] ADD JMP2r }
	POP [ LIT "0 ] ADD JMP2r

@flen ( path* -- size* )
	.File/name DEO2
	#0100 .File/length DEO2
	#ff00 .File/stat DEO2
	#00 #ff04 STA
	#ff00 !shex

@fbin? ( path* -- bool )
	.File/name DEO2
	#0001 .File/length DEO2
	&s ( -- )
	;&b feof? ?{
		[ LIT &b $1 ] ?&s
		#01 JMP2r
		!&s }
	#00 JMP2r

@feof? ( buf* -- eof )
	.File/read DEO2
	.File/success DEI2 #0000 EQU2 JMP2r

@clab? ( c -- bool )
	DUP LIT "0 SUB #0a LTH ?&ok
	DUP LIT "a SUB #1a LTH ?&ok