Adding remember + revive.
This commit is contained in:
@ -124,7 +124,7 @@ $(GEN):
|
||||
POSIX_BOOT = common/boot.fs common/vocabulary.fs common/hide_calls.fs common/ansi.fs \
|
||||
posix/posix.fs posix/posix_highlevel.fs posix/termios.fs common/locals.fs \
|
||||
common/utils.fs common/highlevel.fs common/filetools.fs posix/posix_desktop.fs \
|
||||
common/tasks.fs common/streams.fs common/blocks.fs posix/args.fs \
|
||||
common/tasks.fs common/streams.fs common/blocks.fs posix/autoexec.fs \
|
||||
common/fini.fs
|
||||
$(GEN)/posix_boot.h: common/source_to_string.js $(POSIX_BOOT) | $(GEN)
|
||||
echo "ok" | cat $(POSIX_BOOT) - | $< boot $(VERSION) $(REVISION) >$@
|
||||
|
||||
@ -1,9 +1,18 @@
|
||||
internals definitions
|
||||
|
||||
( Change default block source on arduino )
|
||||
: arduino-default-use s" /spiffs/blocks.fb" open-blocks ;
|
||||
' arduino-default-use is default-use
|
||||
|
||||
( Check for autoexec.fs and run if present )
|
||||
: autoexec ( a n -- ) s" /spiffs/autoexec.fs" ['] included catch 2drop drop ;
|
||||
( Setup remember file )
|
||||
: arduino-remember-filename s" /spiffs/myforth" ;
|
||||
' arduino-remember-filename is remember-filename
|
||||
|
||||
( Check for autoexec.fs and run if present.
|
||||
Failing that, try to revive save image. )
|
||||
: autoexec
|
||||
s" /spiffs/autoexec.fs" ['] included catch 2drop drop
|
||||
['] revive catch drop ;
|
||||
' autoexec ( leave on the stack for fini.fs )
|
||||
|
||||
forth definitions
|
||||
|
||||
@ -17,6 +17,8 @@
|
||||
: -rot ( a b c -- b c a ) swap >r swap r> ;
|
||||
: < ( a b -- a<b ) - 0< ;
|
||||
: > ( a b -- a>b ) swap - 0< ;
|
||||
: <= ( a b -- a>b ) swap - 0< 0= ;
|
||||
: >= ( a b -- a<b ) - 0< 0= ;
|
||||
: = ( a b -- a!=b ) - 0= ;
|
||||
: <> ( a b -- a!=b ) = 0= ;
|
||||
: 0<> ( n -- n) 0= 0= ;
|
||||
|
||||
@ -10,6 +10,7 @@ $4000 constant growth-gap
|
||||
here growth-gap + growth-gap 1- + growth-gap 1- invert and constant saving-base
|
||||
: park-heap ( -- a ) saving-base ;
|
||||
: park-forth ( -- a ) saving-base cell+ ;
|
||||
: bootword ( -- a ) saving-base 2 cells + ; 0 bootword !
|
||||
|
||||
: save-name
|
||||
'heap @ park-heap !
|
||||
@ -23,11 +24,20 @@ here growth-gap + growth-gap 1- + growth-gap 1- invert and constant saving-base
|
||||
saving-base r@ file-size throw r@ read-file throw drop
|
||||
r> close-file throw
|
||||
park-heap @ 'heap !
|
||||
park-forth @ forth-wordlist ! ;
|
||||
park-forth @ forth-wordlist !
|
||||
bootword @ dup if execute else drop then ;
|
||||
|
||||
defer remember-filename
|
||||
: default-remember-filename s" myforth" ;
|
||||
' default-remember-filename is remember-filename
|
||||
|
||||
forth definitions also internals
|
||||
|
||||
: save ( "name" -- ) bl parse save-name ;
|
||||
: restore ( "name" -- ) bl parse restore-name ;
|
||||
: remember remember-filename save-name ;
|
||||
: startup: ( "name" ) ' bootword ! remember ;
|
||||
: revive remember-filename restore-name ;
|
||||
: reset remember-filename delete-file throw ;
|
||||
|
||||
only forth definitions
|
||||
|
||||
@ -1,5 +0,0 @@
|
||||
( Include first argument if any )
|
||||
internals definitions
|
||||
: optional-args argc 2 < if exit then 1 argv included ;
|
||||
' optional-args ( leave on dstack for fini.fs )
|
||||
forth definitions
|
||||
10
ueforth/posix/autoexec.fs
Normal file
10
ueforth/posix/autoexec.fs
Normal file
@ -0,0 +1,10 @@
|
||||
( Include first argument if any )
|
||||
internals definitions
|
||||
: autoexec
|
||||
( Open passed file if any. )
|
||||
argc 2 >= if 1 argv included exit then
|
||||
( Open remembered file if any. )
|
||||
['] revive catch drop
|
||||
;
|
||||
' autoexec ( leave on dstack for fini.fs )
|
||||
forth definitions
|
||||
Reference in New Issue
Block a user