diff --git a/ueforth/Makefile b/ueforth/Makefile index a56f4f5..9999d7a 100644 --- a/ueforth/Makefile +++ b/ueforth/Makefile @@ -120,7 +120,7 @@ $(GEN): mkdir -p $@ 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/tasks.fs common/streams.fs common/blocks.fs posix/args.fs $(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/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) echo "ok" | cat $(WINDOWS_BOOT) - | $< boot $(VERSION) $(REVISION) >$@ ARDUINO_BOOT = common/boot.fs common/vocabulary.fs \ arduino/arduino.fs arduino/arduino_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 \ arduino/arduino_bterm.fs \ arduino/esp_camera.fs common/blocks.fs \ diff --git a/ueforth/common/base_tests.fs b/ueforth/common/base_tests.fs index 2b8f8f0..a791e2c 100644 --- a/ueforth/common/base_tests.fs +++ b/ueforth/common/base_tests.fs @@ -52,3 +52,17 @@ e: test-multiline out: There out: Test! ;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 diff --git a/ueforth/common/boot.fs b/ueforth/common/boot.fs index 695a6f0..79afc58 100644 --- a/ueforth/common/boot.fs +++ b/ueforth/common/boot.fs @@ -39,7 +39,7 @@ : base ( -- a ) 'sys 4 cells + ; : 'heap ( -- a ) 'sys 5 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 + ; ( Dictionary ) @@ -131,8 +131,7 @@ variable handler ( Values ) : value ( n -- ) create , does> @ ; -: to ( n -- ) state @ if postpone ['] postpone >body postpone ! - else ' >body ! then ; immediate +: to ( n -- ) ' >body state @ if aliteral postpone ! else ! then ; immediate ( Deferred Words ) : defer ( "name" -- ) create 0 , does> @ dup 0= throw execute ; diff --git a/ueforth/common/locals.fs b/ueforth/common/locals.fs new file mode 100644 index 0000000..a2e115d --- /dev/null +++ b/ueforth/common/locals.fs @@ -0,0 +1,3 @@ +( Local Variables ) + + diff --git a/ueforth/common/vocabulary.fs b/ueforth/common/vocabulary.fs index adade5a..be2592f 100644 --- a/ueforth/common/vocabulary.fs +++ b/ueforth/common/vocabulary.fs @@ -22,6 +22,19 @@ current @ constant forth-wordlist ( Hide some words in an internals vocabulary ) 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-xt voc-stack-end forth-wordlist last-vocabulary @@ -36,4 +49,3 @@ transfer{ tib-setup input-limit }transfer forth definitions -