Verified Commit 6cfcfe9b authored by Bernd Paysan's avatar Bernd Paysan
Browse files

Add latestnt

parent a64290e5
Loading
Loading
Loading
Loading
Loading
+9 −10
Original line number Original line Diff line number Diff line
@@ -391,16 +391,15 @@ FORTH_SRC = $(KERN_SRC) $(GFORTH_FI_DIST_SRC) $(EC_SRC) $(LIBCC_FORTH_SRC) \
	make-app.fs doc/makedoc.fs locate.fs locate1.fs more.fs onebench.fs   \
	make-app.fs doc/makedoc.fs locate.fs locate1.fs more.fs onebench.fs   \
	fft-bench.fs other.fs prims2x.fs prims2x0.6.2.fs proxy.fs random.fs   \
	fft-bench.fs other.fs prims2x.fs prims2x0.6.2.fs proxy.fs random.fs   \
	regexp.fs regexp-test.fs sokoban.fs string.fs table.fs tags.fs tt.fs  \
	regexp.fs regexp-test.fs sokoban.fs string.fs table.fs tags.fs tt.fs  \
	quotations.fs unbuffer.fs wordsets.fs 2012words.fs $(patsubst %,      \
	unbuffer.fs wordsets.fs 2012words.fs $(patsubst %, test/%,	      \
	test/%, $(TEST_SRC)) bubble.fs siev.fs matrix.fs fib.fs oof.fs	      \
	$(TEST_SRC)) bubble.fs siev.fs matrix.fs fib.fs oof.fs oofsampl.fs    \
	oofsampl.fs objects.fs objexamp.fs mini-oof.fs moof-exm.fs	      \
	objects.fs objexamp.fs mini-oof.fs moof-exm.fs moofglos.fs fixpath.fs \
	moofglos.fs fixpath.fs mini-oof2.fs moof2-example.fs callable.fs      \
	mini-oof2.fs moof2-example.fs callable.fs add.fs lib.fs oldlib.fs     \
	add.fs lib.fs oldlib.fs sieve.fs list.fs endtry-iferror.fs	      \
	sieve.fs list.fs endtry-iferror.fs recover-endtry.fs $(patsubst %,    \
	recover-endtry.fs $(patsubst %, unix/%, $(UNIX_SRC)) date.fs	      \
	unix/%, $(UNIX_SRC)) date.fs script.fs wf.fs traceall.fs rec-scope.fs \
	script.fs wf.fs traceall.fs rec-scope.fs rec-env.fs rec-meta.fs	      \
	rec-env.fs rec-meta.fs notfound.fs utf16.fs archive.fs cilk.fs	      \
	notfound.fs utf16.fs archive.fs cilk.fs sections.fs fixfiles.fs	      \
	sections.fs fixfiles.fs bits.fs reverse-words.fs config.fs	      \
	bits.fs reverse-words.fs config.fs set-compsem.fs coverage.fs	      \
	set-compsem.fs coverage.fs tokenize.fs
	tokenize.fs


COMPAT = compat/README \
COMPAT = compat/README \
	compat/anslocal.fs \
	compat/anslocal.fs \
+8 −8
Original line number Original line Diff line number Diff line
@@ -48,7 +48,7 @@ Variable extra-locals ( additional hidden locals size )


locals-types definitions
locals-types definitions


: :}* ( vtaddr u latest latestxt wid 0 a-addr1 u1 ... xt -- ) \ gforth close-brace-dictionary
: :}* ( vtaddr u latest latestnt wid 0 a-addr1 u1 ... xt -- ) \ gforth close-brace-dictionary
    0 lit, lits, here cell- >r
    0 lit, lits, here cell- >r
    compile, ]] >lp [[
    compile, ]] >lp [[
    :}
    :}
@@ -57,19 +57,19 @@ locals-types definitions
    ['] execute is end-d  ['] noop is endref,
    ['] execute is end-d  ['] noop is endref,
    extra-locals off ;
    extra-locals off ;


: :}xt ( vtaddr u latest latestxt wid 0 a-addr1 u1 ... -- ) \ gforth close-brace-xt
: :}xt ( vtaddr u latest latestnt wid 0 a-addr1 u1 ... -- ) \ gforth close-brace-xt
    \G end a closure's locals declaration.  The closure will be allocated by
    \G end a closure's locals declaration.  The closure will be allocated by
    \G the xt on the stack, so the closure's run-time stack effect is @code{(
    \G the xt on the stack, so the closure's run-time stack effect is @code{(
    \G xt-alloc -- xt-closure}.
    \G xt-alloc -- xt-closure}.
    \ run-time: ( xt size -- ... )
    \ run-time: ( xt size -- ... )
    [: swap execute ;] :}* ;
    [: swap execute ;] :}* ;


: :}d ( vtaddr u latest latestxt wid 0 a-addr1 u1 ... -- ) \ gforth close-brace-dictionary
: :}d ( vtaddr u latest latestnt wid 0 a-addr1 u1 ... -- ) \ gforth close-brace-dictionary
    \G end a closure's locals declaration.  The closure will be allocated in
    \G end a closure's locals declaration.  The closure will be allocated in
    \G the dictionary.
    \G the dictionary.
    ['] allocd :}* ;
    ['] allocd :}* ;


: :}h ( vtaddr u latest latestxt wid 0 a-addr1 u1 ... -- ) \ gforth close-brace-heap
: :}h ( vtaddr u latest latestnt wid 0 a-addr1 u1 ... -- ) \ gforth close-brace-heap
    \G end a closure's locals declaration.  The closure will be allocated on
    \G end a closure's locals declaration.  The closure will be allocated on
    \G the heap.
    \G the heap.
    ['] alloch :}* ;
    ['] alloch :}* ;
@@ -86,7 +86,7 @@ forth definitions


locals-types definitions
locals-types definitions


: :}l ( vtaddr u latest latestxt wid 0 a-addr1 u1 ... -- ) \ gforth close-brace-locals
: :}l ( vtaddr u latest latestnt wid 0 a-addr1 u1 ... -- ) \ gforth close-brace-locals
    \G end a closure's locals declaration.  The closure will be allocated on
    \G end a closure's locals declaration.  The closure will be allocated on
    \G the local's stack.
    \G the local's stack.
    :}
    :}
@@ -108,7 +108,7 @@ forth definitions


: closure-:-hook ( sys -- sys addr xt n )
: closure-:-hook ( sys -- sys addr xt n )
    \ addr is the nfa of the defined word, xt its xt
    \ addr is the nfa of the defined word, xt its xt
    latest latestxt
    latest latestnt
    clear-leave-stack
    clear-leave-stack
    dead-code off
    dead-code off
    defstart ;
    defstart ;
@@ -130,7 +130,7 @@ forth definitions
    endcase
    endcase
    ['] (closure-;]) colon-sys-xt-offset stick ;
    ['] (closure-;]) colon-sys-xt-offset stick ;


: [{: ( -- vtaddr u latest latestxt wid 0 ) \ gforth-experimental start-closure
: [{: ( -- vtaddr u latest latestnt wid 0 ) \ gforth-experimental start-closure
    \G starts a closure.  Closures first declare the locals frame they are
    \G starts a closure.  Closures first declare the locals frame they are
    \G going to use, and then the code that is executed with those locals.
    \G going to use, and then the code that is executed with those locals.
    \G Closures end like quotations with a @code{;]}.  The locals declaration
    \G Closures end like quotations with a @code{;]}.  The locals declaration
@@ -147,7 +147,7 @@ forth definitions
    postpone {:
    postpone {:
; immediate compile-only
; immediate compile-only


: <{: ( -- vtaddr u latest latestxt wid 0 ) \ gforth-experimental start-homelocation
: <{: ( -- vtaddr u latest latestnt wid 0 ) \ gforth-experimental start-homelocation
    \G starts a home location
    \G starts a home location
    #0. push-locals postpone {:
    #0. push-locals postpone {:
; immediate compile-only
; immediate compile-only
+4 −4
Original line number Original line Diff line number Diff line
@@ -57,7 +57,7 @@ vocabulary assembler ( -- ) \ tools-ext


: (;code) ( -- ) \ gforth
: (;code) ( -- ) \ gforth
    \ execution semantics of @code{;code}
    \ execution semantics of @code{;code}
    r> latestxt code-address! ;
    r> latestnt code-address! ;


[ifundef] ?colon-sys
[ifundef] ?colon-sys
: ?colon-sys  ( ... xt tag -- )
: ?colon-sys  ( ... xt tag -- )
@@ -65,7 +65,7 @@ vocabulary assembler ( -- ) \ tools-ext
[then]
[then]


:noname ( -- colon-sys )
:noname ( -- colon-sys )
    align here latestxt code-address!
    align here latestnt code-address!
    defstart init-asm ;
    defstart init-asm ;
:noname ( colon-sys1 -- colon-sys2 )	\ tools-ext	semicolon-code
:noname ( colon-sys1 -- colon-sys2 )	\ tools-ext	semicolon-code
    ( create the [;code] part of a low level defining word )
    ( create the [;code] part of a low level defining word )
@@ -80,7 +80,7 @@ interpret/compile: ;code ( compilation. colon-sys1 -- colon-sys2 ) \ tools-ext s


[ifdef] do;abicode: 
[ifdef] do;abicode: 
: !;abi-code ( addr -- )
: !;abi-code ( addr -- )
    latestxt do;abicode: any-code! ;
    latestnt do;abicode: any-code! ;


: ;abi-code ( -- ) \ gforth semicolon-abi-code
: ;abi-code ( -- ) \ gforth semicolon-abi-code
    ['] !;abi-code does>-like postpone [ init-asm ; immediate
    ['] !;abi-code does>-like postpone [ init-asm ; immediate
@@ -91,5 +91,5 @@ interpret/compile: ;code ( compilation. colon-sys1 -- colon-sys2 ) \ tools-ext s
    \G return from the ABI call (for @code{abi-code}) or the dispatch
    \G return from the ABI call (for @code{abi-code}) or the dispatch
    \G to the next VM instruction (for @code{code} and @code{;code})
    \G to the next VM instruction (for @code{code} and @code{;code})
    \G yourself.
    \G yourself.
    latestxt here over - flush-icache
    latestnt here over - flush-icache
    previous ?struc reveal ;
    previous ?struc reveal ;
+1 −1
Original line number Original line Diff line number Diff line
@@ -220,7 +220,7 @@ set-current
    ' NestXT IF EXIT THEN (debug) Leave-D ;
    ' NestXT IF EXIT THEN (debug) Leave-D ;


: break:, ( -- )
: break:, ( -- )
  latestxt postpone literal ;
  latestnt postpone literal ;
  
  
: break: ( -- ) \ gforth
: break: ( -- ) \ gforth
    break:, postpone (break:) ; immediate
    break:, postpone (break:) ; immediate
+8 −8
Original line number Original line Diff line number Diff line
@@ -457,22 +457,22 @@ create new-locals-map ( -- wordlist-map )
new-locals-map mappedwordlist Constant new-locals-wl
new-locals-map mappedwordlist Constant new-locals-wl


\ and now, finally, the user interface words
\ and now, finally, the user interface words
: { ( -- vtaddr u latest latestxt wid 0 ) \ gforth open-brace
: { ( -- vtaddr u latest latestnt wid 0 ) \ gforth open-brace
    ( >docolloc ) vtsave \ as locals will mess with their own vttemplate
    ( >docolloc ) vtsave \ as locals will mess with their own vttemplate
    latest latestxt get-current
    latest latestnt get-current
    get-order new-locals-wl swap 1+ set-order
    get-order new-locals-wl swap 1+ set-order
    also locals definitions locals-types
    also locals definitions locals-types
    val-part off
    val-part off
    0 TO locals-wordlist
    0 TO locals-wordlist
    0 postpone [ ; immediate
    0 postpone [ ; immediate


synonym {: { ( -- vtaddr u latest latestxt wid 0 ) \ forth-2012 open-brace-colon
synonym {: { ( -- vtaddr u latest latestnt wid 0 ) \ forth-2012 open-brace-colon
\G Start standard locals declaration.  All Gforth locals extensions are
\G Start standard locals declaration.  All Gforth locals extensions are
\G supported by Gforth, though the standard only supports the subset of cells.
\G supported by Gforth, though the standard only supports the subset of cells.


locals-types definitions
locals-types definitions


: } ( vtaddr u latest latestxt wid 0 a-addr1 u1 ... -- ) \ gforth close-brace
: } ( vtaddr u latest latestnt wid 0 a-addr1 u1 ... -- ) \ gforth close-brace
    \ ends locals definitions
    \ ends locals definitions
    ]
    ]
    begin
    begin
@@ -483,13 +483,13 @@ locals-types definitions
    drop vt,
    drop vt,
    locals-size @ alignlp-f locals-size ! \ the strictest alignment
    locals-size @ alignlp-f locals-size ! \ the strictest alignment
    previous previous
    previous previous
    set-current lastcfa ! last !
    set-current lastnt ! last !
    vtrestore
    vtrestore
    locals-list 0 wordlist-id - TO locals-wordlist ;
    locals-list 0 wordlist-id - TO locals-wordlist ;


synonym :} }
synonym :} }


: -- ( vtaddr u latest latestxt wid 0 ... -- ) \ gforth dash-dash
: -- ( vtaddr u latest latestnt wid 0 ... -- ) \ gforth dash-dash
    }
    }
    BEGIN  '}' parse dup WHILE
    BEGIN  '}' parse dup WHILE
        + 1- c@ dup bl = swap ':' = or  UNTIL
        + 1- c@ dup bl = swap ':' = or  UNTIL
@@ -611,7 +611,7 @@ is adjust-locals-list
: locals-:-hook ( sys -- sys addr xt n )
: locals-:-hook ( sys -- sys addr xt n )
    \ addr is the nfa of the defined word, xt its xt
    \ addr is the nfa of the defined word, xt its xt
    DEFERS :-hook
    DEFERS :-hook
    latest latestxt
    latest latestnt
    clear-leave-stack
    clear-leave-stack
    0 locals-size !
    0 locals-size !
    0 locals-list!
    0 locals-list!
@@ -628,7 +628,7 @@ is free-old-local-names
: locals-;-hook ( sys addr xt sys -- sys )
: locals-;-hook ( sys addr xt sys -- sys )
    ?struc
    ?struc
    0 TO locals-wordlist
    0 TO locals-wordlist
    lastcfa ! last !
    lastnt ! last !
    DEFERS ;-hook ;
    DEFERS ;-hook ;


\ THEN (another control flow from before joins the current one):
\ THEN (another control flow from before joins the current one):
Loading