separated endless interpret lop into INTERP; both OUTER and LOADH now use it (LOADH failed)
This commit is contained in:
parent
7b018e819f
commit
2c0fa53c08
|
@ -2,7 +2,7 @@ MEMSIZE = $20000
|
|||
CFG_PRINT_SYMTAB = 1
|
||||
|
||||
;; features
|
||||
CFG_DEBUG = 0
|
||||
CFG_DEBUG = 1
|
||||
CFG_TIME = 0
|
||||
|
||||
|
||||
|
|
6
nf.f
6
nf.f
|
@ -1,4 +1,4 @@
|
|||
." nForth 0.0.1, Copyright (C) 2022 StackSmith" cr
|
||||
( ." nForth 0.0.1, Copyright (C) 2022 StackSmith" cr )
|
||||
|
||||
: lit, { \ (val--) compile value as a literal
|
||||
' lit , , ; }
|
||||
|
@ -105,7 +105,9 @@
|
|||
dotprim ;
|
||||
}
|
||||
sync
|
||||
( ." done" cr )
|
||||
|
||||
\ [ " tstamp.f" included; ]
|
||||
\ [ " cgi.f" included; ]
|
||||
( " cgi.f" included; )
|
||||
|
||||
|
||||
|
|
27
nforth.asm
27
nforth.asm
|
@ -572,6 +572,15 @@ HEADN spaces,"sps",docol
|
|||
dd dbra,@b
|
||||
dd return;
|
||||
.x: dd drop,return
|
||||
|
||||
HEAD INTERP,docol
|
||||
.loop:
|
||||
dd HEREfetch,RUNPTR,xstore ; save HERE to run later
|
||||
dd COMPILE ; compile a single unit
|
||||
dd lit,return,comma ; compile a return
|
||||
dd RUNPTR,fetch,xdup,HERE,xstore,eval ; restore HERE, then run
|
||||
dd branch,.loop
|
||||
|
||||
;;;===========================================================================
|
||||
; OUTER interpreter
|
||||
;
|
||||
|
@ -586,12 +595,7 @@ HEAD OUTER,docol
|
|||
dd ERR.CATCH,xdup,nzbranch,.err ; we catch errors
|
||||
dd drop ; 0 means no error
|
||||
.loop:
|
||||
dd HEREfetch,RUNPTR,xstore ; save HERE to run later
|
||||
dd COMPILE ; compile a single unit
|
||||
dd lit,return,comma ; compile a return
|
||||
dd RUNPTR,fetch,xdup,HERE,xstore,eval ; restore HERE, then run
|
||||
dd branch, .loop
|
||||
|
||||
dd INTERP
|
||||
.err:
|
||||
dd xdup,lit,ERRNUM_EOF,minus,zbranch,.eof ; handle EOF
|
||||
dd TIB,fetch,strlen,type ; print the error line
|
||||
|
@ -1208,22 +1212,13 @@ end if
|
|||
if 1
|
||||
;;; Loader
|
||||
;;;
|
||||
;;; Problem: This is an always-compile system, so invoking the loader
|
||||
;;; compiles the invoking code, which will be stuck there below the
|
||||
;;; loaded code. We must distinguish between the two possibilities:
|
||||
;;; 1) loading interactively, or chain-loading multiple files, in which case
|
||||
;;; the invoking code must be wiped, and we must therefore return
|
||||
;;; two levels up (since the calling code is destroyed);
|
||||
;;; 2) loading from compiled code (non-interactively, such as loading a
|
||||
;;; layer during execution), in which case we will return normally;
|
||||
;;;
|
||||
;;;(handle--) Load a forth file from an open file handle
|
||||
HEADN xloadh,"loadh",docol
|
||||
dd HANDLE.IN, fetch, xpush ; keep old input handle on stack
|
||||
dd HANDLE.IN, xstore ; use provided handle
|
||||
dd ERR.CATCH,xdup,nzbranch,.err
|
||||
dd drop,parsereset ; will force a line load
|
||||
.loop: dd COMPILE,branch,.loop ; no way out except EOF
|
||||
dd INTERP ; no way out except EOF
|
||||
|
||||
.err:
|
||||
dd HANDLE.IN,fetch,osclose,drop
|
||||
|
|
Loading…
Reference in New Issue