Simplify terminate + bye + fix build.

This commit is contained in:
Brad Nelson
2022-12-31 21:02:04 -08:00
parent d60606b4c8
commit 1c500c2233
11 changed files with 14 additions and 27 deletions

View File

@ -93,6 +93,7 @@ e: check-boot
out: space
out: emit
out: bye
out: terminate
out: key?
out: key
out: type
@ -669,7 +670,6 @@ e: check-esp32-builtins
out: analogRead
out: pulseIn
out: MS-TICKS
out: TERMINATE
check-files-reverse
check-files-dir-reverse
out: dacWrite

View File

@ -16,7 +16,8 @@
defer type
defer key
defer key?
defer bye
defer terminate
: bye 0 terminate ;
: emit ( n -- ) >r rp@ 1 type rdrop ;
: space bl emit ; : cr 13 emit nl emit ;

View File

@ -14,17 +14,6 @@
also ansi also internals
DEFINED? windows [IF]
also windows
: sysexit ( n -- ) ExitProcess ;
[ELSE]
DEFINED? posix [IF]
also posix
[ELSE]
: sysexit ( n -- ) terminate ;
[THEN]
[THEN]
( Support for eval tests )
40000 constant expect-limit
create expect-buffer expect-limit allot
@ -117,5 +106,5 @@ variable tests-found variable tests-run variable tests-passed
: run-tests
reset-test-counters ['] count-test for-tests
['] run-test for-tests show-test-results
tests-passed @ tests-found @ <> sysexit ;
tests-passed @ tests-found @ <> terminate ;
only forth

View File

@ -86,7 +86,7 @@ static cell_t ResizeFile(cell_t fd, cell_t size);
#define REQUIRED_SYSTEM_SUPPORT \
X("MS-TICKS", MS_TICKS, PUSH millis()) \
XV(internals, "RAW-YIELD", RAW_YIELD, yield()) \
Y(TERMINATE, exit(n0))
XV(internals, "RAW-TERMINATE", RAW_TERMINATE, exit(n0))
#define REQUIRED_SERIAL_SUPPORT \
XV(serial, "Serial.begin", SERIAL_BEGIN, Serial.begin(tos); DROP) \

View File

@ -21,7 +21,6 @@ forth definitions
( Set up Basic I/O )
internals definitions also serial
: esp32-bye 0 terminate ;
: serial-type ( a n -- ) Serial.write drop ;
: serial-key ( -- n )
begin pause Serial.available until 0 >r rp@ 1 Serial.readBytes drop r> ;
@ -33,7 +32,7 @@ also forth definitions
' default-type is type
' default-key is key
' default-key? is key?
' esp32-bye is bye
' raw-terminate is terminate
only forth definitions
also ledc also serial also SPIFFS

View File

@ -97,7 +97,7 @@ static cell_t *simulated(cell_t *sp, const char *op) {
} else if (op == STR_SERIAL_AVAILABLE) {
*++sp = 1;
return sp;
} else if (op == STR_TERMINATE) {
} else if (op == STR_RAW_TERMINATE) {
exit(*sp--);
return sp;
} else if (op == STR_R_O) {

View File

@ -13,12 +13,12 @@
\ limitations under the License.
( Include first argument if any )
posix also internals definitions
internals definitions
: autoexec
( Open passed file if any. )
argc 2 >= if 1 argv ['] included catch if 1 sysexit then exit then
argc 2 >= if 1 argv ['] included catch if 1 terminate then exit then
( Open remembered file if any. )
['] revive catch drop
;
' autoexec ( leave on dstack for fini.fs )
only forth definitions
forth definitions

View File

@ -105,7 +105,6 @@ decimal
( Hookup I/O )
: stdout-write ( a n -- ) stdout -rot write drop ;
: stdin-key ( -- n ) 0 >r stdin rp@ 1 read drop r> ;
: posix-bye 0 sysexit ;
also forth definitions
: default-type stdout-write ;
@ -113,7 +112,7 @@ also forth definitions
only posix definitions
' default-type is type
' default-key is key
' posix-bye is bye
' sysexit is terminate
( I/O Error Helpers )
: 0<ior ( n -- ior ) 0< if errno else 0 then ;

View File

@ -598,7 +598,7 @@ JSWORD: web-key?-raw { -- f }
return context.inbuffer.length ? -1 : 0;
~
JSWORD: terminate { retval }
JSWORD: web-terminate { retval }
if (globalObj.quit) {
quit(retval);
} else {
@ -918,7 +918,6 @@ JSWORD: random { n -- n }
forth definitions web
: bye 0 terminate ;
: ms-ticks ms-ticks ;
forth definitions

View File

@ -20,6 +20,7 @@ web definitions
' web-key is key
: web-key? ( -- f ) pause web-key?-raw ;
' web-key? is key?
' web-terminate is terminate
: upload-file ( a n -- )
upload-start

View File

@ -64,7 +64,6 @@ variable console-mode
: raw-key ( -- n ) 0 >r stdin rp@ 1 NULL NULL ReadFile drop r> ;
: win-key? ( -- f ) stdin 0 WaitForSingleObject 0= ;
: win-key ( -- n ) raw-key dup 13 = if drop nl then ;
: win-bye ( -- ) 0 ExitProcess drop ;
also forth definitions
: default-type win-type ;
@ -74,6 +73,6 @@ only windows definitions
' default-type is type
' default-key is key
' default-key? is key?
' win-bye is bye
' ExitProcess is terminate
only forth definitions