Adding file for locals, make TO more efficient, prepare fix for interpret DOES>.

This commit is contained in:
Brad Nelson
2021-02-14 22:38:06 -08:00
parent 9e6af37a6d
commit 8f8155dd83
5 changed files with 35 additions and 7 deletions

View File

@ -120,7 +120,7 @@ $(GEN):
mkdir -p $@ mkdir -p $@
POSIX_BOOT = common/boot.fs common/vocabulary.fs common/hide_calls.fs common/ansi.fs \ 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 \ 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/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/args.fs
$(GEN)/posix_boot.h: common/source_to_string.js $(POSIX_BOOT) | $(GEN) $(GEN)/posix_boot.h: common/source_to_string.js $(POSIX_BOOT) | $(GEN)
@ -128,14 +128,14 @@ $(GEN)/posix_boot.h: common/source_to_string.js $(POSIX_BOOT) | $(GEN)
WINDOWS_BOOT = common/boot.fs common/vocabulary.fs common/hide_calls.fs common/ansi.fs \ WINDOWS_BOOT = common/boot.fs common/vocabulary.fs common/hide_calls.fs common/ansi.fs \
windows/windows.fs windows/windows_highlevel.fs common/highlevel.fs \ windows/windows.fs windows/windows_highlevel.fs common/highlevel.fs \
common/utils.fs common/tasks.fs common/streams.fs common/blocks.fs common/utils.fs common/tasks.fs common/streams.fs common/blocks.fs common/locals.fs
$(GEN)/windows_boot.h: common/source_to_string.js $(WINDOWS_BOOT) | $(GEN) $(GEN)/windows_boot.h: common/source_to_string.js $(WINDOWS_BOOT) | $(GEN)
echo "ok" | cat $(WINDOWS_BOOT) - | $< boot $(VERSION) $(REVISION) >$@ echo "ok" | cat $(WINDOWS_BOOT) - | $< boot $(VERSION) $(REVISION) >$@
ARDUINO_BOOT = common/boot.fs common/vocabulary.fs \ ARDUINO_BOOT = common/boot.fs common/vocabulary.fs \
arduino/arduino.fs arduino/arduino_highlevel.fs \ arduino/arduino.fs arduino/arduino_highlevel.fs \
arduino/bindings.fs common/highlevel.fs \ arduino/bindings.fs common/highlevel.fs \
common/filetools.fs common/utils.fs \ common/filetools.fs common/utils.fs common/locals.fs \
common/tasks.fs common/streams.fs arduino/arduino_server.fs \ common/tasks.fs common/streams.fs arduino/arduino_server.fs \
arduino/arduino_bterm.fs \ arduino/arduino_bterm.fs \
arduino/esp_camera.fs common/blocks.fs \ arduino/esp_camera.fs common/blocks.fs \

View File

@ -52,3 +52,17 @@ e: test-multiline
out: There out: There
out: Test! out: Test!
;e ;e
e: test-value-to
123 value foo
foo . cr
out: 123
55 to foo
foo . cr
out: 55
: bar 99 to foo ;
foo . cr
out: 55
bar foo . cr
out: 99
;e

View File

@ -39,7 +39,7 @@
: base ( -- a ) 'sys 4 cells + ; : base ( -- a ) 'sys 4 cells + ;
: 'heap ( -- a ) 'sys 5 cells + ; : 'heap ( -- a ) 'sys 5 cells + ;
: current ( -- a ) 'sys 6 cells + ; : current ( -- a ) 'sys 6 cells + ;
: 'context ( -- a ) 'sys 7 cells + ; : context 'context @ ; : 'context ( -- a ) 'sys 7 cells + ; : context 'context @ cell+ ;
: 'notfound ( -- a ) 'sys 8 cells + ; : 'notfound ( -- a ) 'sys 8 cells + ;
( Dictionary ) ( Dictionary )
@ -131,8 +131,7 @@ variable handler
( Values ) ( Values )
: value ( n -- ) create , does> @ ; : value ( n -- ) create , does> @ ;
: to ( n -- ) state @ if postpone ['] postpone >body postpone ! : to ( n -- ) ' >body state @ if aliteral postpone ! else ! then ; immediate
else ' >body ! then ; immediate
( Deferred Words ) ( Deferred Words )
: defer ( "name" -- ) create 0 , does> @ dup 0= throw execute ; : defer ( "name" -- ) create 0 , does> @ dup 0= throw execute ;

3
ueforth/common/locals.fs Normal file
View File

@ -0,0 +1,3 @@
( Local Variables )

View File

@ -22,6 +22,19 @@ current @ constant forth-wordlist
( Hide some words in an internals vocabulary ) ( Hide some words in an internals vocabulary )
vocabulary internals internals definitions vocabulary internals internals definitions
( Vocabulary chain for current scope, place at the -1 position )
variable scope scope context cell - !
( Make DOES> switch to compile mode when interpreted )
(
vocabulary partial-does partial-does definitions
transfer does>
only forth definitions also partial-does
: does> postpone does> ; immediate
only internals definitions
)
transfer{ transfer{
transfer-xt voc-stack-end forth-wordlist transfer-xt voc-stack-end forth-wordlist
last-vocabulary last-vocabulary
@ -36,4 +49,3 @@ transfer{
tib-setup input-limit tib-setup input-limit
}transfer }transfer
forth definitions forth definitions