( Whatever I see I swallow immediately | Just as it is, unmisted by love or dislike. ) |10 @Console/vector $2 &read $5 &type $1 &write $1 &error $1 ( @|Enums ) |0101 @EPS |0202 @GAM |0003 @EPS-GAM |0404 @DEL |ffff @NIL |0005 @EPS-DEL |0006 @GAM-DEL |0808 @DEAD |0008 @NODE-WIDTH |000 @queue/buf $100 &buf-end |100 @on-reset ( -> ) net/ #010e DEO BRK @main-tests ( -- ) net/ net/ net/ net/ net/ net/ net/ net/ net/ net/ net/ net/ net/ net/ net/ JMP2r @experimental-tests ( -- ) net/ JMP2r ( @|Macros ) %+/p ( n* -- ) { INC2 INC2 } %+/x ( n* -- ) { #0004 ADD2 } %+/y ( n* -- ) { #0006 ADD2 } %is-nil ( n* -- t ) { ;NIL EQU2 } %is-pri ( n* -- t ) { #07 AND #02 EQU NIP } %not-primary-ports ( a/p* b/p* -- a/p* b/p* t ) { ROTk #0707 AND2 #0202 NEQ2 NIP } %get-aux ( x* -- x* bit ) { #0004 ADD2 LDA2k ;NIL NEQ2 STH INC2k INC2 LDA2 ;NIL NEQ2 #10 SFT STHr ORA } ( @|Net ) @net/ ( -- ) [ LITr 01 ] &>w / / INCr STHkr ?{ ;dict/inf str/ POP #00 } ?&>w POPr ! @net/ ( -- rewrite ) queue/get-boundary EQUk ?{ &>ws queue/pop-wire SWP2 / #04 ADD NEQk ?&>ws POP2 #01 ! } POP2 #00 JMP2r @net/ ( -- ) ;dict/spacer str/ queue/ ;&buf ,&+ptr STR2 ;&buf-end ;&buf &>l ;DEAD OVR2 / INC2 INC2 GTH2k ?&>l POP2 POP2 JMP2r @net/alloc ( type* -- node* ) [ LIT2 &+ptr =&buf ] DUP2 ;NODE-WIDTH ADD2 ( | overflow ) DUP2 ;&buf-end LTH2 ?{ ;dict/err str/ POP2 ;&buf } ,&+ptr STR2 STH2k / STH2r JMP2r @net/ ( type* addr* -- ) STH2k STA2 ;NIL STH2r ( P0 ) INC2 INC2 STA2k ( P1 ) INC2 INC2 STA2k ( P2 ) INC2 INC2 STA2 JMP2r @net/ ( a* b* -- ) / ( >> ) @net/ ( node* -- ) ;DEAD SWP2 STA2 JMP2r %net/ ( a/p* b/p* -- a/p* b/p* ) { STA2k SWP2 STA2k SWP2 } %net/ ( a/p* b/p* -- ) { STA2k SWP2 STA2 } @net/ ( a* b* -- ) +/p SWP2 +/p SWP2 ( wire ) / !queue/ @net/ ( a/p* b/p* -- ) DUP2 is-nil ?{ OVR2 is-nil ?{ / not-primary-ports ?{ !queue/ } } } POP2 POP2 JMP2r @net/ ( a* b* -- ) ( | gather types ) LDAk STH SWP2 LDAk STHr ORA ( | Find rule ) DUP .EPS EQU ?/ DUP .GAM EQU ?/ DUP .DEL EQU ?/ DUP .EPS-GAM EQU ?/ DUP .EPS-DEL EQU ?/ DUP .GAM-DEL EQU ?/ #1a DEO2 POP2 POP2 JMP2r @net/ ( a* b* type -- ) POP !/ @net/ ( a* b* type -- ) POP ( a.p1 b.p1 ) OVR2 +/x LDA2 OVR2 +/x LDA2 / ( a.p2 b.p2 ) OVR2 +/y LDA2 OVR2 +/y LDA2 / !/ @net/ ( a* b* type -- ) POP ( raise del/gam ) LDAk .EPS NEQ ?{ SWP2 } ( e1 ) DUP2 +/x LDA2 ;EPS /alloc +/p / ( e2 ) DUP2 +/y LDA2 ;EPS /alloc +/p / !/ @net/ ( a* b* type -- ) POP ( | outside ) ( d1 ) OVR2 +/x LDA2 ;DEL /alloc STH2k +/p / ( g1 ) DUP2 +/x LDA2 ;GAM /alloc ( g1x ) DUP2 +/x ,&g1x STR2 ( g1y ) DUP2 +/y ,&g1y STR2 +/p / ( d2 ) OVR2 +/y LDA2 ;DEL /alloc STH2k +/p / ( g2 ) DUP2 +/y LDA2 ;GAM /alloc ( g2x ) DUP2 +/x ,&g2x STR2 ( g2y ) DUP2 +/y ,&g2y STR2 +/p / ( | cross . d1 d2 ) STH2kr +/x [ LIT2 &g1y $2 ] / STH2r +/y [ LIT2 &g2y $2 ] / STH2kr +/x [ LIT2 &g1x $2 ] / STH2r +/y [ LIT2 &g2x $2 ] / !/ @is-already-printed ( node* -- node* t ) ( get pri ) INC2k INC2 LDA2k is-pri ?{ POP2 #00 JMP2r } LDA2 OVR2 LTH2 JMP2r @net/ ( -- ) [ LITr 00 ] ;&+ptr LDA2 ;&buf &>lp LDA2k ;DEAD EQU2 ?{ is-already-printed ?{ / INCr } } ;NODE-WIDTH ADD2 GTH2k ?&>lp POP2 POP2 STHr ?{ ;dict/empty !str/ } JMP2r @net/ ( addr* -- addr* ) LDA2k / DUP2 #03 SFT NIP LIT "a ADD #18 DEO DUP2 / DUP2 / ! @net/ ( addr* -- ) INC2 INC2 LDA2k is-pri ?{ ;dict/wire str/ LDA2 !/ } ( | Principal ) ;dict/wire-pri str/ LDA2 #33 SFT2 LDA2k / DUP2 #03 SFT NIP LIT "a ADD #18 DEO !/ @net/ ( addr* -- ) get-aux ( | handlers ) DUP ?{ POP POP2 JMP2r } #01 NEQ ?{ LIT2 "( 18 DEO LDA2 / LIT2 ") 18 DEO JMP2r } LIT2 "( 18 DEO LDA2k / [ LIT2 ", 18 DEO ] #2018 DEO INC2 INC2 LDA2 / LIT2 ") 18 DEO JMP2r @net/ ( addr* -- ) INC2k ORA ?{ POP2 ;dict/tomb !str/ } ( | name ) DUP2 #33 SFT2 LDA2k / #03 SFT2 NIP LIT "a ADD #18 DEO NIP #07 AND #01 SFT DUP #01 NEQ ?{ POP JMP2r } ( | id ) LIT2 ". 18 DEO ( | port ) #01 SUB LIT "w ADD #18 DEO JMP2r @net/ ( value* -- ) DUP2 ;EPS NEQ2 ?{ POP2 ;dict/eps !str/ } DUP2 ;GAM NEQ2 ?{ POP2 ;dict/gam !str/ } ;DEL NEQ2 ?{ ;dict/del !str/ } ;dict/dead !str/ ( @|Queue ) @queue/ ( -- ) [ LIT2 -&buf _&+ptr ] STR [ LIT2 -&buf _&+follower ] STR JMP2r @queue/ ( a/p* b/p* -- ) SWP2 / ( >> ) @queue/ ( p* -- ) ( get node addr ) #33 SFT2 ( | store ) [ LIT &+ptr -&buf ] INCk INC ,&+ptr STR STZ2 JMP2r @queue/pop-wire ( -- b* a* ) /follow ( >> ) @queue/follow ( -- a* ) [ LIT &+follower -&buf ] INCk INC ,&+follower STR LDZ2 JMP2r @queue/get-boundary ( -- to from ) ,&+ptr LDR ,&+follower LDR JMP2r ( @|Stdlib ) @str/ ( str* -- ) LDAk DUP ?{ POP POP2 JMP2r } #18 DEO INC2 !/ @ ( -- ) #0a18 DEO JMP2r ( @|Prefabs ) @net/make-app ( x/p* y/p* -- gam* ) ( y ) ;GAM /alloc STH2k +/y / ( x ) STH2kr +/x / STH2r JMP2r @net/make-identity ( -- port* ) ;GAM /alloc ( x ) DUP2 +/x ( y ) OVR2 +/y / JMP2r @net/make-false ( -- port* ) ( y ) ;EPS /alloc +/p ( x ) /make-identity +/p !/make-app @net/make-true ( -- port* ) ;GAM /alloc ( y ) ;EPS /alloc +/p OVR2 +/x / ( x ) DUP2 +/y SWP2 +/p !/make-app @net/make-cat ( a* -- port* ) +/p ;GAM /alloc STH2k +/x / STH2r JMP2r @net/make-concat ( a* b* -- port* ) ( x ) /make-cat +/p ( y ) SWP2 /make-cat STH2k +/y / STH2r JMP2r @net/make-and ( -- port* ) ( id~>app1.x ) /make-identity +/p ;GAM /alloc STH2k +/x / ( stash: app1 ) ( false~>app2.y ) /make-false +/p ;GAM /alloc STH2k +/y / ( stash: app1 app2 ) ( app1~>app2.x ) OVR2r STH2r +/p STH2kr +/x / ( stash: app1 app2 ) ( app2~>la.y ) STH2r +/p ;GAM /alloc STH2k +/y / ( stash: app1 la ) STH2r DUP2 +/x STH2r +/y / JMP2r @net/make-zero ( -- port* ) ( x ) ;EPS /alloc +/p ( y ) /make-identity +/p !/make-app @net/make-one ( -- port* ) ;GAM /alloc ;GAM /alloc OVR2 +/x OVR2 +/x / OVR2 +/y OVR2 +/y / +/p SWP2 +/p !/make-app @net/make-succ ( -- port* ) #0000 JMP2r ( @|Tests ) @net/ ( -- ) / ;EPS /alloc ;EPS /alloc / !/ @net/ ( -- ) / ( c ) ;GAM /alloc ( a ) ;GAM /alloc / !/ @net/ ( -- ) / ( g1 ) ;GAM /alloc STH2k ( g1 g2 ) ;GAM /alloc STH2k / ( | connect to dummy nodes ) ;EPS /alloc +/p STH2r +/x / ;EPS /alloc +/p STH2r +/x / !/ @net/ ( -- ) / ( c ) ;DEL /alloc ( a ) ;DEL /alloc / !/ @net/ ( -- ) / ( g1 ) ;DEL /alloc STH2k ( g1 g2 ) ;DEL /alloc STH2k / ( | connect to dummy nodes ) ;EPS /alloc +/p STH2kr +/x / ;EPS /alloc +/p STH2r +/y / ;EPS /alloc +/p STH2kr +/x / ;EPS /alloc +/p STH2r +/y / !/ @net/ ( -- ) / ( e ) ;EPS /alloc ( e g ) ;GAM /alloc STH2k ( g.p1 >< x.p0 ) ;EPS /alloc +/p STH2kr +/x / ( g.p2 >< y.p0 ) ;EPS /alloc +/p STH2r +/y / ( e.p0 >< g.p0 ) / !/ @net/ ( -- ) / ( e ) ;GAM /alloc STH2k ( e g ) ;EPS /alloc ( g.p1 >< x.p0 ) ;EPS /alloc +/p STH2kr +/x / ( g.p2 >< y.p0 ) ;EPS /alloc +/p STH2r +/y / ( e.p0 >< g.p0 ) / !/ @net/ ( -- ) / ( g ) ;GAM /alloc STH2k ( d ) ;DEL /alloc STH2k / ( i.p0<>d.p1 ) ;EPS /alloc +/p STH2kr +/x / ( j.p0<>d.p2 ) ;EPS /alloc +/p STH2r +/y / ( k.p0<>g.p1 ) ;EPS /alloc +/p STH2kr +/x / ( l.p0<>g.p2 ) ;EPS /alloc +/p STH2r +/y / !/ @net/ ( -- ) / ( g ) ;GAM /alloc STH2k ( d ) ;DEL /alloc STH2k / ( e1~dy ) ;EPS /alloc +/p STH2kr +/y / ( e2~gx ) ;EPS /alloc +/p OVR2r STH2r +/x / ( dx~gy ) STH2r +/x STH2r +/y / !/ @net/ ( -- ) / ( | 3 ) ( 0 ) ;EPS /alloc +/p ( 0+ ) ;DEL /alloc STH2k +/x / ( 0++ ) STH2r +/p ;DEL /alloc STH2k +/x / ( 0+++ ) STH2r +/p ;DEL /alloc STH2k +/x / ( | 2 ) ( 0 ) ;EPS /alloc +/p ( 0+ ) ;DEL /alloc STH2k +/x / ( 0++ ) STH2r +/p ;DEL /alloc STH2k +/x / ( | Add ) ;DEL /alloc DUP2 +/x STH2r +/p / STH2r / !/ @net/ ( -- ) / ( dx~dy ) ;DEL /alloc STH2k +/x STH2kr +/y / ( d~>gx ) STH2r +/p ;GAM /alloc STH2k +/x / ( e1~gy ) ;EPS /alloc +/p STH2kr +/y / ( e2> !/ @net/ ( -- ) / ( | del-gam, where has identity-del in x, esp in y ) ( g1x~g1y ) ;GAM /alloc STH2k DUP2 +/x SWP2 +/y / ( g1~>g2y ) ;GAM /alloc DUP2 +/y STH2r +/p / ( e~>g2x ) DUP2 +/x ;EPS /alloc +/p / ( d> !/ @net/ ( -- ) / ( | two del, each have a eps in x, and each other in y ) ;DEL /alloc DUP2 +/x ;EPS /alloc +/p / ;DEL /alloc DUP2 +/x ;EPS /alloc +/p / OVR2 +/y OVR2 +/y / / !/ @net/ ( -- ) / ( | deg-gam, but gam is wired on itself ) ;GAM /alloc ;DEL /alloc DUP2 +/x OVR2 +/y / / !/ @net/ ( -- ) / ( #t ) ;EPS /alloc ( #f ) ;EPS /alloc /make-concat ( .. ) /make-true / !/ @net/ ( -- ) / ( #t ) ;EPS /alloc ( #f ) ;EPS /alloc /make-concat ( .. ) /make-false / !/ @net/ ( -- ) / /make-succ POP2 !/ ( @|Assets ) @dict/wire 20 "~> 20 00 &wire-pri 20 ">< 20 00 &eps "E 00 &gam "G 00 &del "D 00 &inf "(Infinite-loop) 0a00 &dead "--- 00 &tomb "nil 00 &empty "(empty) 0a00 &spacer "------------------ 0a00 &err "Overflow 0a00 &test-epseps "============= 20 "EPS-EPS 0a00 &test-gamgam "============= 20 "GAM-GAM 0a00 &test-deldel "============= 20 "DEL-DEL 0a00 &test-epsgam "============= 20 "EPS-GAM 0a00 &test-gamdel "============= 20 "GAM-DEL 0a00 &test-twothree "============= 20 "TWO-THREE 0a00 ( @|Aligned Memory ) |8000 @net/buf $7ff8 &buf-end