Commit eac09b2d authored by bernd's avatar bernd
Browse files

Use Forward instead of Defer

parent 54bc0938
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ $20 value hash-size#

scope{ n2o

:noname ( -- )
: help ( -- )
    \U help [cmd1 .. cmdn]
    \G help: print commands or details about specified command
    ?cr ?nextarg IF
@@ -96,7 +96,7 @@ scope{ n2o
	s"     \O " ['] .usage search-help
	." === Commands ===" cr
	s"     \U " ['] .usage search-help
    THEN ; is help
    THEN ;

}scope

+5 −5
Original line number Diff line number Diff line
@@ -60,8 +60,8 @@ gen-table $freeze
    punch-addrs $@ bounds ?DO  I @ .n2o:dispose-addr  cell +LOOP
    punch-addrs $off  defers extra-dispose ; is extra-dispose

:noname ( addr u -- o ) \G create a new address object from string
    n2o:new-addr n:>o nest-cmd-loop o n:o> ; is new-addr
: new-addr ( addr u -- o ) \G create a new address object from string
    n2o:new-addr n:>o nest-cmd-loop o n:o> ;

also net2o-base
: o-genaddr ( o -- ) >o \G create new address string from object
@@ -100,8 +100,8 @@ previous
: .nat-addrs ( -- )
    punch-addrs $@ bounds ?DO  I @ .addr cr  cell +LOOP ;

:noname ( addr u -- )
    new-addr >o o .addr n2o:dispose-addr o> ; is .addr$
: .addr$ ( addr u -- )
    new-addr >o o .addr n2o:dispose-addr o> ;

User dest-0key> \ pointer to dest-0key
User dest-0key< \ pointer to obtained dest-0key
@@ -161,7 +161,7 @@ User dest-0key< \ pointer to obtained dest-0key
: .my-addrs ( -- )
    my-addr[] [: .addr cr ;] $[]o-map ;

:noname addrs-off !my-addrs !my-addr$ ; is !my-addr
: !my-addr ( -- ) addrs-off !my-addrs !my-addr$ ;

\ merge addresses

+18 −13
Original line number Diff line number Diff line
@@ -376,14 +376,14 @@ Defer .n-name ' noop is .n-name
: cmdsig ( -- addr )  last-2o 3 cells + ;
: net2o' ( "name" -- ) ' >body @ ;

Defer net2o:words
Forward net2o:words

: inherit-table ( addr u "name" -- )
    ' dup IS gen-table  execute $! ;

Vocabulary net2o-base

Defer do-req>
Forward do-req>

: do-nest ( addr u flag -- )
    dup >r  validated or!  nest-cmd-loop
@@ -456,7 +456,6 @@ comp: drop cmdsig @ IF ')' parse 2drop EXIT THEN
    pf@ ;
+net2o: end-with ( o:object -- ) \g end scope
    do-req> n:o> ;
:noname o IF  req? @ 0<  IF  end-with req? off  THEN  THEN ; is do-req>
+net2o: oswap ( o:nest o:current -- o:current o:nest )
    do-req> n:oswap ;
+net2o: tru ( -- f:true ) \g true flag literal
@@ -478,6 +477,10 @@ comp: drop cmdsig @ IF ')' parse 2drop EXIT THEN
    string@ $> 2drop ;
}scope

also net2o-base
: do-req> o IF  req? @ 0<  IF  end-with req? off  THEN  THEN ;
previous

gen-table $freeze
gen-table $@ inherit-table reply-table

@@ -578,7 +581,7 @@ previous
	1 packets2 +!
    ELSE  dest-addr 64@ [ cell 4 = ] [IF] 0<> - [THEN] dup 0 r> 2! u>=  THEN ;

: cmd-loop ( addr u -- )
: cmd-exec ( addr u -- )
    string-stack $off
    object-stack $off
    nest-stack $off
@@ -595,8 +598,6 @@ previous
    [: outflag @ >r cmdreset init-reply do-cmd-loop
      r> outflag ! cmd-send? ;] cmdlock c-section ;

' cmd-loop is cmd-exec

\ nested commands

User neststart#
@@ -711,7 +712,15 @@ $10 net2o: push' ( #cmd -- ) \g push command into answer packet
+net2o: error-id ( $:errorid -- ) \g error-id string
    $> $error-id $! ;

:noname ( start -- )
gen-table $freeze

: ]nest  ( -- )  ]nest$ push-$ push' nest ;

}scope

also net2o-base

: net2o:words ( start -- )
    token-table $@ 2 pick cells safe/string bounds U+DO
	I @ ?dup-IF
	    dup >net2o-sig 2>r >net2o-name
@@ -719,13 +728,9 @@ $10 net2o: push' ( #cmd -- ) \g push command into answer packet
		2 pick ulit, 2r> 2swap [: type type ;] $tmp $, token
	    ELSE  2drop rdrop rdrop  THEN
	THEN  1+
    cell +LOOP  drop ; IS net2o:words

gen-table $freeze
    cell +LOOP  drop ;

: ]nest  ( -- )  ]nest$ push-$ push' nest ;

}scope
previous

0 [IF]
Local Variables:
+1 −1
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@
\ You should have received a copy of the GNU Affero General Public License
\ along with this program.  If not, see <http://www.gnu.org/licenses/>.

Defer >invitations
Forward >invitations

scope{ net2o-base
\ nat traversal functions
+2 −3
Original line number Diff line number Diff line
@@ -401,13 +401,12 @@ also net2o-base
    pings new-request false gen-punchload gen-punch ;
previous

:noname ( addr u -- )
: punch-reply ( addr u -- )
    outflag @ >r  cmdbuf-o @ >r
    [: cmd0! cmdreset init-reply also net2o-base
      [ also net2o-base ]
      $, nest end-code ;] catch
    r> cmdbuf-o !  r> outflag !  throw
; is punch-reply
    r> cmdbuf-o !  r> outflag !  throw ;

: 0-resend? ( -- n )
    resend0 @ IF
Loading