[ append-dimensions ] bi ;
: new-fortran-type ( out? dims size class -- type )
- new [ [ (>>size) ] [ (>>dims) ] [ (>>out?) ] tri ] keep ;
+ new [ [ size<< ] [ dims<< ] [ out?<< ] tri ] keep ;
GENERIC: (fortran-type>c-type) ( type -- c-type )
[ byte-pos>> 8 * ] [ bit-pos>> + ] bi ; inline
: set-abp ( abp bitstream -- )
- [ 8 /mod ] dip [ (>>bit-pos) ] [ (>>byte-pos) ] bi ; inline
+ [ 8 /mod ] dip [ bit-pos<< ] [ byte-pos<< ] bi ; inline
: seek ( n bitstream -- )
[ get-abp + ] [ set-abp ] bi ; inline
byte bs widthed>> |widthed :> new-byte
new-byte #bits>> 8 = [
new-byte bits>> bs bytes>> push
- zero-widthed bs (>>widthed)
+ zero-widthed bs widthed<<
remainder widthed>bytes
- [ bs bytes>> push-all ] [ bs (>>widthed) ] bi*
+ [ bs bytes>> push-all ] [ bs widthed<< ] bi*
] [
- byte bs (>>widthed)
+ byte bs widthed<<
] if ;
: enough-bits? ( n bs -- ? )
n 8 /mod :> ( #bytes #bits )
bs [ #bytes + ] change-byte-pos
bit-pos>> #bits + dup 8 >= [
- 8 - bs (>>bit-pos)
+ 8 - bs bit-pos<<
bs [ 1 + ] change-byte-pos drop
] [
- bs (>>bit-pos)
+ bs bit-pos<<
] if ;
:: (peek) ( n bs endian> subseq-endian -- bits )
\r
: >box ( value box -- )\r
dup occupied>>\r
- [ box-full ] [ t >>occupied (>>value) ] if ; inline\r
+ [ box-full ] [ t >>occupied value<< ] if ; inline\r
\r
ERROR: box-empty box ;\r
\r
: update-md5 ( md5 -- )
[ state>> ] [ old-state>> v-w+ dup clone ] [ ] tri
- [ (>>old-state) ] [ (>>state) ] bi ;
+ [ old-state<< ] [ state<< ] bi ;
CONSTANT: T
$[
state [ H [ w+ ] 2map ] change-H drop ; inline
M:: sha1-state checksum-block ( bytes state -- )
- bytes prepare-sha1-message-schedule state (>>W)
+ bytes prepare-sha1-message-schedule state W<<
bytes
state [ H>> clone ] [ W>> ] [ K>> ] tri state process-sha1-chunk ;
: change-circular-start ( n circular -- )
#! change start to (start + n) mod length
- circular-wrap (>>start) ; inline
+ circular-wrap start<< ; inline
: rotate-circular ( circular -- )
[ 1 ] dip change-circular-start ; inline
M: struct-slot-spec compute-slot-offset
[ type>> over c-type-align-at 8 * align ] keep
- [ [ 8 /i ] dip (>>offset) ] [ type>> heap-size 8 * + ] 2bi ;
+ [ [ 8 /i ] dip offset<< ] [ type>> heap-size 8 * + ] 2bi ;
M: struct-bit-slot-spec compute-slot-offset
- [ (>>offset) ] [ bits>> + ] 2bi ;
+ [ offset<< ] [ bits>> + ] 2bi ;
: compute-struct-offsets ( slots -- size )
0 [ compute-slot-offset ] reduce 8 align 8 /i ;
[ instructions>> ] bi@ dup pop* push-all ;
: update-successors ( bb pred -- )
- [ successors>> ] dip (>>successors) ;
+ [ successors>> ] dip successors<< ;
: join-block ( bb pred -- )
[ join-instructions ] [ update-successors ] 2bi ;
bi v+ supremum
] if-empty
node insn>> temp-vregs length +
- dup node (>>registers) ;
+ dup node registers<< ;
! Constructing fan-in trees
>>instructions t >>unlikely? ;
:: insert-guard ( body check bb -- )
- bb predecessors>> check (>>predecessors)
- V{ bb body } check (>>successors)
+ bb predecessors>> check predecessors<<
+ V{ bb body } check successors<<
- V{ check } body (>>predecessors)
- V{ bb } body (>>successors)
+ V{ check } body predecessors<<
+ V{ bb } body successors<<
- V{ check body } bb (>>predecessors)
+ V{ check body } bb predecessors<<
check predecessors>> [ bb check update-successors ] each ;
: trim-before-ranges ( live-interval -- )
[ ranges>> ] [ last-use n>> 1 + ] bi
[ '[ from>> _ <= ] filter! drop ]
- [ swap last (>>to) ]
+ [ swap last to<< ]
2bi ;
: trim-after-ranges ( live-interval -- )
[ ranges>> ] [ first-use n>> ] bi
[ '[ to>> _ >= ] filter! drop ]
- [ swap first (>>from) ]
+ [ swap first from<< ]
2bi ;
: assign-spill ( live-interval -- )
live-interval n check-split
live-interval clone :> before
live-interval clone :> after
- live-interval uses>> n split-uses before after [ (>>uses) ] bi-curry@ bi*
- live-interval ranges>> n split-ranges before after [ (>>ranges) ] bi-curry@ bi*
+ live-interval uses>> n split-uses before after [ uses<< ] bi-curry@ bi*
+ live-interval ranges>> n split-ranges before after [ ranges<< ] bi-curry@ bi*
before split-before
after split-after ;
: shorten-range ( n live-interval -- )
dup ranges>> empty?
- [ dupd add-new-range ] [ ranges>> last (>>from) ] if ;
+ [ dupd add-new-range ] [ ranges>> last from<< ] if ;
: extend-range ( from to live-range -- )
ranges>> last
: number-instruction ( n insn -- n' )
[ nip dup insn#>> [ already-numbered ] [ drop ] if ]
- [ (>>insn#) ]
+ [ insn#<< ]
[ drop 2 + ]
2tri ;
:: insert-basic-block ( from to insns -- )
! Insert basic block on the edge between 'from' and 'to'.
<basic-block> :> bb
- insns V{ } like bb (>>instructions)
- V{ from } bb (>>predecessors)
- V{ to } bb (>>successors)
+ insns V{ } like bb instructions<<
+ V{ from } bb predecessors<<
+ V{ to } bb successors<<
from to bb update-predecessors
from to bb update-successors ;
: update-inline-cache ( word/quot ic -- )
[ effect-counter ] dip
- [ (>>value) ] [ (>>counter) ] bi-curry bi* ; inline
+ [ value<< ] [ counter<< ] bi-curry bi* ; inline
SINGLETON: +unknown+
: save-effect ( effect quot -- )
[ effect-counter ] dip
- [ (>>cached-effect) ] [ (>>cache-counter) ] bi-curry bi* ;
+ [ cached-effect<< ] [ cache-counter<< ] bi-curry bi* ;
M: quotation cached-effect
dup cached-effect-valid?
word already-inlined? [ f ] [
#call word splicing-body [
word add-to-history
- #call (>>body)
+ #call body<<
#call propagate-body
] [ f ] if*
] if ;
] with-scope ;
M: #return-recursive node-call-graph
- nip dup label>> (>>return) ;
+ nip dup label>> return<< ;
M: #call-recursive node-call-graph
[ dup label>> call-site boa ] keep
tdesc\r
[\r
code next-size\r
- [ code (>>value) code clone quot call code next-code ] each\r
+ [ code value<< code clone quot call code next-code ] each\r
] each ; inline\r
\r
: update-reverse-table ( huffman-code n table -- )\r
size>> h>> ; inline
: set-CGRect-x ( x CGRect -- )
- origin>> (>>x) ; inline
+ origin>> x<< ; inline
: set-CGRect-y ( y CGRect -- )
- origin>> (>>y) ; inline
+ origin>> y<< ; inline
: set-CGRect-w ( w CGRect -- )
- size>> (>>w) ; inline
+ size>> w<< ; inline
: set-CGRect-h ( h CGRect -- )
- size>> (>>h) ; inline
+ size>> h<< ; inline
: <CGRect> ( x y w h -- rect )
[ CGPoint <struct-boa> ] [ CGSize <struct-boa> ] 2bi*
IN: cpu.ppc.linux
<<
-t "longlong" c-type (>>stack-align?)
-t "ulonglong" c-type (>>stack-align?)
+t "longlong" c-type stack-align?<<
+t "ulonglong" c-type stack-align?<<
>>
M: linux reserved-area-size 2 cells ;
M: consultation where loc>> ;
-M: consultation set-where (>>loc) ;
+M: consultation set-where loc<< ;
M: consultation forget*
[ unconsult-methods ] [ unregister-consult ] bi ;
M: dlist-node node-value obj>> ;
: set-prev-when ( dlist-node dlist-node/f -- )
- [ (>>prev) ] [ drop ] if* ; inline
+ [ prev<< ] [ drop ] if* ; inline
: set-next-when ( dlist-node dlist-node/f -- )
- [ (>>next) ] [ drop ] if* ; inline
+ [ next<< ] [ drop ] if* ; inline
: set-next-prev ( dlist-node -- )
dup next>> set-prev-when ; inline
M: dlist push-front* ( obj dlist -- dlist-node )
[ front>> f swap <dlist-node> dup dup set-next-prev ] keep
- [ (>>front) ] keep
+ [ front<< ] keep
set-back-to-front ;
M: dlist push-back* ( obj dlist -- dlist-node )
[ back>> f <dlist-node> ] keep
[ back>> set-next-when ] 2keep
- [ (>>back) ] 2keep
+ [ back<< ] 2keep
set-front-to-back ;
ERROR: empty-dlist ;
: handle-USER ( ftp-command -- )
[
- tokenized>> second client get (>>user)
+ tokenized>> second client get user<<
"Please specify the password." 331 server-response
] [
2drop "bad USER" ftp-error
: handle-PASS ( ftp-command -- )
[
- tokenized>> second client get (>>password)
+ tokenized>> second client get password<<
"Login successful" 230 server-response
] [
2drop "PASS error" ftp-error
] if ;
: expect-connection ( -- port )
- <promise> client get (>>extra-connection)
+ <promise> client get extra-connection<<
random-local-server
[ [ passive-loop ] curry in-thread ]
[ addr>> port>> ] bi ;
{
[ [ attrs>> chloe-attrs-only ] dip add-tag-attrs ]
[ [ attrs>> non-chloe-attrs-only ] dip "button" deep-tag-named add-tag-attrs ]
- [ [ children>> ] dip "button" deep-tag-named (>>children) ]
+ [ [ children>> ] dip "button" deep-tag-named children<< ]
[ nip ]
} 2cleave compile-chloe-tag ;
: fill-controller-state ( XINPUT_STATE -- controller-state )
Gamepad>> controller-state new dup rot
{
- [ wButtons>> HEX: f bitand >pov swap (>>pov) ]
- [ wButtons>> fill-buttons swap (>>buttons) ]
- [ sThumbLX>> >axis swap (>>x) ]
- [ sThumbLY>> >axis swap (>>y) ]
- [ sThumbRX>> >axis swap (>>rx) ]
- [ sThumbRY>> >axis swap (>>ry) ]
- [ bLeftTrigger>> >trigger swap (>>z) ]
- [ bRightTrigger>> >trigger swap (>>rz) ]
+ [ wButtons>> HEX: f bitand >pov swap pov<< ]
+ [ wButtons>> fill-buttons swap buttons<< ]
+ [ sThumbLX>> >axis swap x<< ]
+ [ sThumbLY>> >axis swap y<< ]
+ [ sThumbRX>> >axis swap rx<< ]
+ [ sThumbRY>> >axis swap ry<< ]
+ [ bLeftTrigger>> >trigger swap z<< ]
+ [ bRightTrigger>> >trigger swap rz<< ]
} 2cleave ;
PRIVATE>
M: link where name>> article loc>> ;
-M: link set-where name>> article (>>loc) ;
+M: link set-where name>> article loc<< ;
M: link forget* name>> remove-article ;
M: tip where loc>> ;
-M: tip set-where (>>loc) ;
+M: tip set-where loc<< ;
: <tip> ( content -- tip ) f tip boa ;
HINTS: M\ hashtable blahblah { object fixnum object } { object word object } ;
-[ t ] [ M\ hashtable blahblah { count>> (>>count) } inlined? ] unit-test
+[ t ] [ M\ hashtable blahblah { count>> count<< } inlined? ] unit-test
: jpeg> ( -- jpeg-image ) jpeg-image get ;
: apply-diff ( dc color -- dc' )
- [ diff>> + dup ] [ (>>diff) ] bi ;
+ [ diff>> + dup ] [ diff<< ] bi ;
: fetch-tables ( component -- )
[ [ jpeg> quant-tables>> nth ] change-quant-table drop ]
read1 8 assert=
2 read be>
2 read be>
- swap 2array jpeg> (>>dim)
+ swap 2array jpeg> dim<<
read1
[
read1 read4/4 read1 <jpeg-color-info>
[ drop
read1 jpeg> color-info>> nth clone
read1 16 /mod [ >>dc-huff-table ] [ >>ac-huff-table ] bi*
- ] map jpeg> (>>components)
+ ] map jpeg> components<<
read1 0 assert=
read1 63 assert=
read1 16 /mod [ 0 assert= ] bi@
: baseline-decompress ( -- )
jpeg> bitstream>> cleanup-bitstream { 255 255 255 255 } append
- >byte-array bs:<msb0-bit-reader> jpeg> (>>bitstream)
+ >byte-array bs:<msb0-bit-reader> jpeg> bitstream<<
jpeg>
[ bitstream>> ]
[ [ [ <huffman-decoder> ] with map ] change-huff-tables drop ] bi
ERROR: seek-before-start n ;
: set-seek-ptr ( n handle -- )
- [ dup 0 < [ seek-before-start ] when ] dip (>>ptr) ;
+ [ dup 0 < [ seek-before-start ] when ] dip ptr<< ;
M: winnt tell-handle ( handle -- n ) ptr>> ;
char encoding type>> value? [
char find-type
[ stream stream-write ]
- [ encoding (>>type) ] bi*
+ [ encoding type<< ] bi*
] unless
char encoding type>> value-at stream stream-write-num ;
stream stream-read1 {
{ ESC [
stream read-escape [
- encoding (>>type)
+ encoding type<<
stream encoding decode-char
] [ replacement-char ] if*
] }
M: winnt fill-redirection ( process args -- )
dup lpStartupInfo>>
- [ [ redirect-stdout ] dip (>>hStdOutput) ]
- [ [ redirect-stderr ] dip (>>hStdError) ]
- [ [ redirect-stdin ] dip (>>hStdInput) ] 3tri ;
+ [ [ redirect-stdout ] dip hStdOutput<< ]
+ [ [ redirect-stderr ] dip hStdError<< ]
+ [ [ redirect-stdin ] dip hStdInput<< ] 3tri ;
M: monitor timeout timeout>> ;
-M: monitor set-timeout (>>timeout) ;
+M: monitor set-timeout timeout<< ;
<PRIVATE
M: port timeout timeout>> ;
-M: port set-timeout (>>timeout) ;
+M: port set-timeout timeout<< ;
: <port> ( handle class -- port )
new-disposable swap >>handle ; inline
handle>> closesocket drop ;\r
\r
: unspecific-sockaddr/size ( addrspec -- sockaddr len )\r
- [ empty-sockaddr/size ] [ protocol-family ] bi pick (>>family) ;\r
+ [ empty-sockaddr/size ] [ protocol-family ] bi pick family<< ;\r
\r
: opened-socket ( handle -- win32-socket )\r
<win32-socket> |dispose dup add-completion ;\r
:: limited-stream-seek ( n seek-type stream -- )
seek-type {
- { seek-absolute [ n stream (>>current) ] }
+ { seek-absolute [ n stream current<< ] }
{ seek-relative [ stream [ n + ] change-current drop ] }
- { seek-end [ stream stop>> n - stream (>>current) ] }
+ { seek-end [ stream stop>> n - stream current<< ] }
[ bad-seek-type ]
} case ;
[ rect-bounds ] dip vmin <rect> ;
: set-rect-bounds ( rect1 rect -- )
- [ [ loc>> ] dip (>>loc) ]
- [ [ dim>> ] dip (>>dim) ]
+ [ [ loc>> ] dip loc<< ]
+ [ [ dim>> ] dip dim<< ]
2bi ; inline
USE: vocabs.loader
: update-velocity ( dt actor -- )
[ acceleration>> n*v ] [ velocity>> v+ ] [ ] tri
- (>>velocity) ; inline
+ velocity<< ; inline
: update-position ( dt actor -- )
[ velocity>> n*v ] [ position>> v+ ] [ ] tri
- (>>position) ; inline
+ position<< ; inline
M: actor advance ( dt actor -- )
[ >float ] dip
((change-model)) set-model ; inline
: (change-model) ( model quot -- )
- ((change-model)) (>>value) ; inline
+ ((change-model)) value<< ; inline
GENERIC: range-value ( model -- value )
GENERIC: range-page-value ( model -- value )
s [
s left-recursion? [ s throw ] unless
s head>> l head>> eq? [
- l head>> s (>>head)
+ l head>> s head<<
l head>> [ s rule-id>> suffix ] change-involved-set drop
l s next>> (setup-lr)
] unless
:: setup-lr ( r l -- )
l head>> [
- r rule-id V{ } clone V{ } clone peg-head boa l (>>head)
+ r rule-id V{ } clone V{ } clone peg-head boa l head<<
] unless
l lrstack get (setup-lr) ;
:: lr-answer ( r p m -- ast )
m ans>> head>> :> h
h rule-id>> r rule-id eq? [
- m ans>> seed>> m (>>ans)
+ m ans>> seed>> m ans<<
m ans>> failed? [
fail
] [
lr lrstack set lr p memo-entry boa dup p r rule-id set-memo :> m
r eval-rule :> ans
lrstack get next>> lrstack set
- pos get m (>>pos)
+ pos get m pos<<
lr head>> [
m ans>> left-recursion? [
- ans lr (>>seed)
+ ans lr seed<<
r p m lr-answer
] [ ans ] if
] [
- ans m (>>ans)
+ ans m ans<<
ans
] if ; inline
: calc-seq-result ( prev-result current-result -- next-result )
[
- [ remaining>> swap (>>remaining) ] 2keep
+ [ remaining>> swap remaining<< ] 2keep
ast>> dup ignore? [
drop
] [
: (repeat) ( quot: ( -- result ) result -- result )
over call [
- [ remaining>> swap (>>remaining) ] 2keep
+ [ remaining>> swap remaining<< ] 2keep
ast>> swap [ ast>> push ] keep
(repeat)
] [
dup pprinter get last-newline>> = [
drop
] [
- pprinter get (>>last-newline)
+ pprinter get last-newline<<
line-limit? [
"..." write pprinter get return
] when
: pprinter-manifest ( -- manifest )
<manifest>
- [ [ pprinter-use get keys >vector ] dip (>>search-vocabs) ]
- [ [ pprinter-in get ] dip (>>current-vocab) ]
+ [ [ pprinter-use get keys >vector ] dip search-vocabs<< ]
+ [ [ pprinter-in get ] dip current-vocab<< ]
[ ]
tri ;
M:: sfmt generate ( sfmt -- )
sfmt state>> :> state
sfmt uint-4-array>> :> array
- state n>> 2 - array nth state (>>r1)
- state n>> 1 - array nth state (>>r2)
+ state n>> 2 - array nth state r1<<
+ state n>> 1 - array nth state r2<<
state m>> :> m
state n>> :> n
state mask>> :> mask
mask state r1>> state r2>> formula :> r
r i array set-nth-unsafe
- state r2>> state (>>r1)
- r state (>>r2)
+ state r2>> state r1<<
+ r state r2<<
] each
! n m - 1 + n [a,b) [
mask state r1>> state r2>> formula :> r
r i array set-nth-unsafe
- state r2>> state (>>r1)
- r state (>>r2)
+ state r2>> state r1<<
+ r state r2<<
] each
- 0 state (>>index) ;
+ 0 state index<< ;
: period-certified? ( sfmt -- ? )
[ uint-4-array>> first ]
TUPLE: obj-ref obj ;
C: <obj-ref> obj-ref
M: obj-ref get-ref obj>> ;
-M: obj-ref set-ref (>>obj) ;
+M: obj-ref set-ref obj<< ;
INSTANCE: obj-ref ref
TUPLE: var-ref var ;
[ transitions>> keys ] bi*
[ intersects? ] with filter
fast-set
- ] keep (>>final-states) ;
+ ] keep final-states<< ;
: initialize-dfa ( nfa -- dfa )
<transition-table>
:: with-sequence-parser ( sequence-parser quot -- seq/f )
sequence-parser n>> :> n
sequence-parser quot call [
- n sequence-parser (>>n) f
+ n sequence-parser n<< f
] unless* ; inline
: offset ( sequence-parser offset -- char/f )
sequence-parser [ growing length - 1 + ] change-n drop
! sequence-parser advance drop
] [
- saved sequence-parser (>>n)
+ saved sequence-parser n<<
f
] if ;
: associate-thread ( walker -- )
walker-thread tset
[ f walker-thread tget send-synchronous drop ]
- self (>>exit-handler) ;
+ self exit-handler<< ;
: start-walker-thread ( status continuation -- thread' )
self [
window world window-loc>> auto-position
world window save-position
window install-window-delegate
- view window <window-handle> world (>>handle)
+ view window <window-handle> world handle<<
window f -> makeKeyAndOrderFront: ;
M: cocoa-ui-backend (close-window) ( handle -- )
: handle-wm-size ( hWnd uMsg wParam lParam -- )
2nip
[ lo-word ] keep hi-word 2array
- dup { 0 0 } = [ 2drop ] [ swap window [ (>>dim) ] [ drop ] if* ] if ;
+ dup { 0 0 } = [ 2drop ] [ swap window [ dim<< ] [ drop ] if* ] if ;
: handle-wm-move ( hWnd uMsg wParam lParam -- )
2nip
[ lo-word ] keep hi-word 2array
- swap window [ (>>window-loc) ] [ drop ] if* ;
+ swap window [ window-loc<< ] [ drop ] if* ;
CONSTANT: wm-keydown-codes
H{
] unless ;
:: set-window-active ( hwnd uMsg wParam lParam ? -- n )
- ? hwnd window (>>active?)
+ ? hwnd window active?<<
hwnd uMsg wParam lParam DefWindowProc ;
: handle-wm-syscommand ( hWnd uMsg wParam lParam -- n )
M: x-clipboard copy-clipboard
[ x-clipboard@ own-selection ] keep
- (>>contents) ;
+ contents<< ;
M: x-clipboard paste-clipboard
[ find-world handle>> window>> ] dip atom>> convert-selection ;
M: clipboard clipboard-contents contents>> ;
-M: clipboard set-clipboard-contents (>>contents) ;
+M: clipboard set-clipboard-contents contents<< ;
: <clipboard> ( -- clipboard ) "" clipboard boa ;
PRIVATE>
-M: gadget (>>dim) ( dim gadget -- )
+M: gadget dim<< ( dim gadget -- )
2dup dim>> =
[ 2drop ]
[ [ nip ] [ call-next-method ] 2bi dim-changed ] if ;
: pref-dim ( gadget -- dim )
dup pref-dim>> [ ] [
[ pref-dim* ] [ ] [ layout-state>> ] tri
- [ drop ] [ dupd (>>pref-dim) ] if
+ [ drop ] [ dupd pref-dim<< ] if
] ?if ;
: pref-dims ( gadgets -- seq ) [ pref-dim ] map ;
ERROR: not-a-string object ;
-M: label (>>string) ( string label -- )
+M: label string<< ( string label -- )
[
{
{ [ dup string-array? ] [ ] }
{ [ dup string? ] [ ?string-lines ] }
[ not-a-string ]
} cond
- ] dip (>>text) ; inline
+ ] dip text<< ; inline
: label-theme ( gadget -- gadget )
sans-serif-font >>font ; inline
: pack-layout ( pack sizes -- )
[ round-dims packed-dims ] [ drop ] 2bi
- [ children>> [ (>>dim) ] 2each ]
- [ [ packed-locs ] [ children>> ] bi [ (>>loc) ] 2each ] 2bi ;
+ [ children>> [ dim<< ] 2each ]
+ [ [ packed-locs ] [ children>> ] bi [ loc<< ] 2each ] 2bi ;
: <pack> ( orientation -- pack )
pack new
: show-status ( string/f gadget -- )
dup find-world dup [
dup status>> [
- [ (>>status-owner) ] [ status>> set-model ] bi
+ [ status-owner<< ] [ status>> set-model ] bi
] [ 3drop ] if
] [ 3drop ] if ;
: hide-status ( gadget -- )
dup find-world dup [
[ status-owner>> eq? ] keep
- '[ f _ [ (>>status-owner) ] [ status>> set-model ] 2bi ] when
+ '[ f _ [ status-owner<< ] [ status>> set-model ] 2bi ] when
] [ 2drop ] if ;
: window-resource ( resource -- resource )
M: world resize-world
drop ;
-M: world (>>dim)
+M: world dim<<
[ call-next-method ]
[
dup active?>> [
dup send-lose-focus
f swap t focus-child
] when*
- dupd (>>focus) [
+ dupd focus<< [
send-gain-focus
] when*
] [
- (>>focus)
+ focus<<
] if ;
: modifier ( mod modifiers -- seq )
TUPLE: dummy obj ;
M: dummy history-value obj>> ;
-M: dummy set-history-value (>>obj) ;
+M: dummy set-history-value obj<< ;
dummy new <history> "history" set
[ ] [ <promise> "promise" set ] unit-test
[
- self "interactor" get (>>thread)
+ self "interactor" get thread<<
"interactor" get stream-read-quot "promise" get fulfill
] "Interactor test" spawn drop
[ ] [ <promise> "promise" set ] unit-test
[
- self "interactor" get (>>thread)
+ self "interactor" get thread<<
"interactor" get stream-readln "promise" get fulfill
] "Interactor test" spawn drop
: define-main-window ( word attributes quot -- )
[
'[ [ f _ clone @ open-window ] with-ui ] (( -- )) define-declared
- ] [ 2drop current-vocab (>>main) ] 3bi ;
+ ] [ 2drop current-vocab main<< ] 3bi ;
SYNTAX: MAIN-WINDOW:
CREATE
unroll-factor 0 <array>
[ unroll-factor 1 - swap set-nth ] keep f
] dip [ node boa dup ] keep
- dup [ (>>prev) ] [ 2drop ] if ; inline
+ dup [ prev<< ] [ 2drop ] if ; inline
: normalize-back ( list -- )
dup back>> [
[
unroll-factor 0 <array> [ set-first ] keep
] dip [ f node boa dup ] keep
- dup [ (>>next) ] [ 2drop ] if ; inline
+ dup [ next<< ] [ 2drop ] if ; inline
: normalize-front ( list -- )
dup front>> [
M: value-word definition drop f ;
: set-value ( value word -- )
- def>> first (>>obj) ;
+ def>> first obj<< ;
SYNTAX: to:
scan-word literalize suffix!
2nip set-second
] [
[ assure-name swap 2array ] dip
- [ alist>> ?push ] keep (>>alist)
+ [ alist>> ?push ] keep alist<<
] if* ;
M: attrs assoc-size alist>> length ;
TAG: MODE parse-mode-tag
dup "NAME" attr [
mode new {
- { "FILE" f (>>file) }
- { "FILE_NAME_GLOB" f (>>file-name-glob) }
- { "FIRST_LINE_GLOB" f (>>first-line-glob) }
+ { "FILE" f file<< }
+ { "FILE_NAME_GLOB" f file-name-glob<< }
+ { "FIRST_LINE_GLOB" f first-line-glob<< }
} init-from-tag
] dip
rot set-at ;
over [ assoc-union! ] [ nip clone ] if ;
: import-keywords ( parent child -- )
- over [ [ keywords>> ] bi@ ?update ] dip (>>keywords) ;
+ over [ [ keywords>> ] bi@ ?update ] dip keywords<< ;
: import-rules ( parent child -- )
swap [ add-rule ] curry each-rule ;
TAG: KEYWORDS parse-rule-tag
rule-set get ignore-case?>> <keyword-map>
swap children-tags [ over parse-keyword-tag ] each
- swap (>>keywords) ;
+ swap keywords<< ;
: ?<regexp> ( string/f -- regexp/f )
dup [ rule-set get ignore-case?>> <?insensitive-regexp> ] when ;
: (parse-rules-tag) ( tag -- rule-set )
<rule-set> dup rule-set set
{
- { "SET" string>rule-set-name (>>name) }
- { "IGNORE_CASE" string>boolean (>>ignore-case?) }
- { "HIGHLIGHT_DIGITS" string>boolean (>>highlight-digits?) }
- { "DIGIT_RE" ?<regexp> (>>digit-re) }
+ { "SET" string>rule-set-name name<< }
+ { "IGNORE_CASE" string>boolean ignore-case?<< }
+ { "HIGHLIGHT_DIGITS" string>boolean highlight-digits?<< }
+ { "DIGIT_RE" ?<regexp> digit-re<< }
{ "ESCAPE" f add-escape-rule }
- { "DEFAULT" string>token (>>default) }
- { "NO_WORD_SEP" f (>>no-word-sep) }
+ { "DEFAULT" string>token default<< }
+ { "NO_WORD_SEP" f no-word-sep<< }
} init-from-tag ;
: parse-rules-tag ( tag -- rule-set )
swap position-attrs <matcher> ;
: shared-tag-attrs ( -- )
- { "TYPE" string>token (>>body-token) } , ; inline
+ { "TYPE" string>token body-token<< } , ; inline
: parse-delegate ( string -- pair )
"::" split1 [ rule-set get swap ] unless* 2array ;
: delegate-attr ( -- )
- { "DELEGATE" f (>>delegate) } , ;
+ { "DELEGATE" f delegate<< } , ;
: regexp-attr ( -- )
- { "HASH_CHAR" f (>>chars) } , ;
+ { "HASH_CHAR" f chars<< } , ;
: match-type-attr ( -- )
- { "MATCH_TYPE" string>match-type (>>match-token) } , ;
+ { "MATCH_TYPE" string>match-type match-token<< } , ;
: span-attrs ( -- )
- { "NO_LINE_BREAK" string>boolean (>>no-line-break?) } ,
- { "NO_WORD_BREAK" string>boolean (>>no-word-break?) } ,
- { "NO_ESCAPE" string>boolean (>>no-escape?) } , ;
+ { "NO_LINE_BREAK" string>boolean no-line-break?<< } ,
+ { "NO_WORD_BREAK" string>boolean no-word-break?<< } ,
+ { "NO_ESCAPE" string>boolean no-escape?<< } , ;
: literal-start ( -- )
[ parse-literal-matcher >>start drop ] , ;
add-remaining-token
[ rule-match-token* next-token, ] keep
! ... end subst ...
- dup context get (>>in-rule)
+ dup context get in-rule<<
delegate>> push-context ;
M: span-rule handle-rule-end
?end-rule
mark-token add-remaining-token
[ rule-match-token* next-token, ] keep
- f context get (>>end)
- context get (>>in-rule) ;
+ f context get end<<
+ context get in-rule<< ;
M: mark-following-rule handle-rule-end
nip rule-match-token* prev-token,
- f context get (>>in-rule) ;
+ f context get in-rule<< ;
M: mark-previous-rule handle-rule-start
?end-rule
: init-span ( rule -- )
dup delegate>> [ drop ] [
dup body-token>> standard-rule-set
- swap (>>delegate)
+ swap delegate<<
] if ;
: init-eol-span ( rule -- )
: add-escape-rule ( string ruleset -- )
over [
[ <escape-rule> ] dip
- 2dup (>>escape-rule)
+ 2dup escape-rule<<
add-rule
] [
2drop
"This defines a class word named " { $snippet "employee" } ", a predicate " { $snippet "employee?" } ", and the following slot accessors:"
{ $table
{ "Reader" "Writer" "Setter" "Changer" }
- { { $snippet "name>>" } { $snippet "(>>name)" } { $snippet ">>name" } { $snippet "change-name" } }
- { { $snippet "salary>>" } { $snippet "(>>salary)" } { $snippet ">>salary" } { $snippet "change-salary" } }
- { { $snippet "position>>" } { $snippet "(>>position)" } { $snippet ">>position" } { $snippet "change-position" } }
+ { { $snippet "name>>" } { $snippet "name<<" } { $snippet ">>name" } { $snippet "change-name" } }
+ { { $snippet "salary>>" } { $snippet "salary<<" } { $snippet ">>salary" } { $snippet "change-salary" } }
+ { { $snippet "position>>" } { $snippet "position<<" } { $snippet ">>position" } { $snippet "change-position" } }
}
"We can define a constructor which makes an empty employee:"
{ $code ": <employee> ( -- employee )"
[ ] [ "IN: classes.tuple.tests TUPLE: reshape-test { x read-only } ;" eval( -- ) ] unit-test
-[ f ] [ \ reshape-test \ (>>x) method ] unit-test
+[ f ] [ \ reshape-test \ x<< method ] unit-test
[ "tuple" get 5 >>x ] must-fail
] [
2dup capacity > [ 2dup expand ] when
] if
- (>>length) ;
+ length<< ;
: new-size ( old -- new ) 1 + 3 * ; inline
2dup length >= [
2dup capacity >= [ over new-size over expand ] when
[ >fixnum ] dip
- over 1 fixnum+fast over (>>length)
+ over 1 fixnum+fast over length<<
] [
[ >fixnum ] dip
] if ; inline
M: growable lengthen ( n seq -- )
2dup length > [
2dup capacity > [ over new-size over expand ] when
- 2dup (>>length)
+ 2dup length<<
] when 2drop ; inline
M: growable shorten ( n seq -- )
growable-check
2dup length < [
2dup contract
- 2dup (>>length)
+ 2dup length<<
] when 2drop ; inline
M: growable new-resizable new-sequence 0 over set-length ; inline
: push-unsafe ( elt seq -- )
[ length ] keep
[ underlying>> set-array-nth ]
- [ [ 1 fixnum+fast { array-capacity } declare ] dip (>>length) ]
+ [ [ 1 fixnum+fast { array-capacity } declare ] dip length<< ]
2bi ; inline
PRIVATE>
: (stream-seek) ( n seek-type stream -- )
swap {
- { seek-absolute [ (>>i) ] }
+ { seek-absolute [ i<< ] }
{ seek-relative [ [ + ] change-i drop ] }
- { seek-end [ [ underlying>> length + ] [ (>>i) ] bi ] }
+ { seek-end [ [ underlying>> length + ] [ i<< ] bi ] }
[ bad-seek-type ]
} case ;
: change-lexer-column ( lexer quot -- )
[ [ column>> ] [ line-text>> ] bi ] prepose keep
- (>>column) ; inline
+ column<< ; inline
GENERIC: skip-blank ( lexer -- )
"The following uses writers, and requires some stack shuffling:"
{ $code
"<email>"
- " \"Happy birthday\" over (>>subject)"
- " { \"bob@bigcorp.com\" } over (>>to)"
- " \"alice@bigcorp.com\" over (>>from)"
+ " \"Happy birthday\" over subject<<"
+ " { \"bob@bigcorp.com\" } over to<<"
+ " \"alice@bigcorp.com\" over from<<"
"send-email"
}
"Even if some of the slot values come from the stack underneath the tuple being constructed, setters win:"
"The above has less shuffling than the writer version:"
{ $code
"<email>"
- " [ (>>subject) ] keep"
- " [ (>>to) ] keep"
- " \"alice@bigcorp.com\" over (>>from)"
+ " [ subject<< ] keep"
+ " [ to<< ] keep"
+ " \"alice@bigcorp.com\" over from<<"
"send-email"
}
"The changer word abstracts a common pattern where a slot value is read then stored again; so the following is not idiomatic code:"
TUPLE: protocol-slot-test-tuple x ;
M: protocol-slot-test-tuple my-protocol-slot-test>> x>> sq ;
-M: protocol-slot-test-tuple (>>my-protocol-slot-test) [ sqrt ] dip (>>x) ;
+M: protocol-slot-test-tuple my-protocol-slot-test<< [ sqrt ] dip x<< ;
[ 9 ] [ T{ protocol-slot-test-tuple { x 3 } } my-protocol-slot-test>> ] unit-test
] 2bi ;
: writer-word ( name -- word )
- "(>>" ")" surround "accessors" create
+ "<<" append "accessors" create
dup t "writer" set-word-prop ;
ERROR: bad-slot-value value class ;
definitions ;
: record-top-level-form ( quot file -- )
- (>>top-level-form)
+ top-level-form<<
[ ] [ H{ } notify-definition-observers ] if-bootstrapping ;
: record-checksum ( lines source-file -- )
- [ crc32 checksum-lines ] dip (>>checksum) ;
+ [ crc32 checksum-lines ] dip checksum<< ;
: record-definitions ( file -- )
new-definitions get >>definitions drop ;
[ column>> ] [ line-text>> ] bi
] dip swap subseq
] [
- lexer get (>>column)
+ lexer get column<<
] bi ;
: rest-of-line ( lexer -- seq )
"))" parse-effect suffix!
] define-core-syntax
- "MAIN:" [ scan-word current-vocab (>>main) ] define-core-syntax
+ "MAIN:" [ scan-word current-vocab main<< ] define-core-syntax
"<<" [
[
: set-current-vocab ( name -- )
create-vocab
- [ manifest get (>>current-vocab) ] [ (add-qualified) ] bi ;
+ [ manifest get current-vocab<< ] [ (add-qualified) ] bi ;
: with-current-vocab ( name quot -- )
manifest get clone manifest [
: (set-tag) ( -- )
elements get id>> 31 bitand
- dup elements get (>>tag)
+ dup elements get tag<<
31 < [
[ "unsupported tag encoding: #{" %
get-id # "}" %
: set-tagclass ( -- )
get-id -6 shift tag-classes nth
- elements get (>>tagclass) ;
+ elements get tagclass<< ;
: set-encoding ( -- )
get-id HEX: 20 bitand
zero? "primitive" "constructed" ?
- elements get (>>encoding) ;
+ elements get encoding<< ;
: set-content-length ( -- )
read1
dup 127 <= [
127 bitand read be>
- ] unless elements get (>>contentlength) ;
+ ] unless elements get contentlength<< ;
: set-newobj ( -- )
elements get contentlength>> read
- elements get (>>newobj) ;
+ elements get newobj<< ;
: set-objtype ( syntax -- )
builtin-syntax 2array [
elements get encoding>> swap at
elements get tag>>
swap at [
- elements get (>>objtype)
+ elements get objtype<<
] when*
] each ;
} case ;
: set-id ( -- boolean )
- read1 dup elements get (>>id) ;
+ read1 dup elements get id<< ;
: read-ber ( syntax -- object )
element new
] with-scope ; inline
: set-tag ( value -- )
- tagnum get (>>value) ;
+ tagnum get value<< ;
M: string >ber ( str -- byte-array )
tagnum get value>> 1array "C" pack-native swap dup
first2 {
[ [ [ 1 + ] change-count ] bi@ 2drop ]
[ 2dup = [ [ 1 + ] change-self-count ] when 2drop ]
- [ [ [ color>> ] bi@ complement-color ] [ [ (>>color) ] bi-curry@ bi ] 2bi ]
+ [ [ [ color>> ] bi@ complement-color ] [ [ color<< ] bi-curry@ bi ] 2bi ]
[ [ mailbox>> f swap mailbox-put ] bi@ ]
} 2cleave ;
sequence-parser current quote-char = [
sequence-parser advance* string
] [
- start-n sequence-parser (>>n) f
+ start-n sequence-parser n<< f
] if ;
: (take-token) ( sequence-parser -- string )
SLOT: (n)
SLOT: (vectored)
-FUNCTOR: define-vectored-accessors ( S>> (>>S) T -- )
+FUNCTOR: define-vectored-accessors ( S>> S<< T -- )
WHERE
M: T S>>
[ (n)>> ] [ (vectored)>> S>> ] bi nth-unsafe ; inline
-M: T (>>S)
+M: T S<<
[ (n)>> ] [ (vectored)>> S>> ] bi set-nth-unsafe ; inline
;FUNCTOR
#! Return the 16-bit pseudo register AF.
[ a>> 8 shift ] keep f>> bitor ;
-: (>>af) ( value cpu -- )
+: af<< ( value cpu -- )
#! Set the value of the 16-bit pseudo register AF
[ >word< ] dip swap >>f swap >>a drop ;
#! Return the 16-bit pseudo register BC.
[ b>> 8 shift ] keep c>> bitor ;
-: (>>bc) ( value cpu -- )
+: bc<< ( value cpu -- )
#! Set the value of the 16-bit pseudo register BC
[ >word< ] dip swap >>c swap >>b drop ;
#! Return the 16-bit pseudo register DE.
[ d>> 8 shift ] keep e>> bitor ;
-: (>>de) ( value cpu -- )
+: de<< ( value cpu -- )
#! Set the value of the 16-bit pseudo register DE
[ >word< ] dip swap >>e swap >>d drop ;
#! Return the 16-bit pseudo register HL.
[ h>> 8 shift ] keep l>> bitor ;
-: (>>hl) ( value cpu -- )
+: hl<< ( value cpu -- )
#! Set the value of the 16-bit pseudo register HL
[ >word< ] dip swap >>l swap >>h drop ;
[ pc>> ] keep
[ read-byte ] keep
[ pc>> 1 + ] keep
- (>>pc) ;
+ pc<< ;
: next-word ( cpu -- word )
#! Return the value of the word at PC, and increment PC.
[ pc>> ] keep
[ read-word ] keep
[ pc>> 2 + ] keep
- (>>pc) ;
+ pc<< ;
: write-byte ( value addr cpu -- )
: cpu-a-bitand ( quot cpu -- )
#! A &= quot call
- [ a>> swap call bitand ] keep (>>a) ; inline
+ [ a>> swap call bitand ] keep a<< ; inline
: cpu-a-bitor ( quot cpu -- )
#! A |= quot call
- [ a>> swap call bitor ] keep (>>a) ; inline
+ [ a>> swap call bitor ] keep a<< ; inline
: cpu-a-bitxor ( quot cpu -- )
#! A ^= quot call
- [ a>> swap call bitxor ] keep (>>a) ; inline
+ [ a>> swap call bitxor ] keep a<< ; inline
: cpu-a-bitxor= ( value cpu -- )
#! cpu-a ^= value
- [ a>> bitxor ] keep (>>a) ;
+ [ a>> bitxor ] keep a<< ;
: cpu-f-bitand ( quot cpu -- )
#! F &= quot call
- [ f>> swap call bitand ] keep (>>f) ; inline
+ [ f>> swap call bitand ] keep f<< ; inline
: cpu-f-bitor ( quot cpu -- )
#! F |= quot call
- [ f>> swap call bitor ] keep (>>f) ; inline
+ [ f>> swap call bitor ] keep f<< ; inline
: cpu-f-bitxor ( quot cpu -- )
#! F |= quot call
- [ f>> swap call bitxor ] keep (>>f) ; inline
+ [ f>> swap call bitxor ] keep f<< ; inline
: cpu-f-bitor= ( value cpu -- )
#! cpu-f |= value
- [ f>> bitor ] keep (>>f) ;
+ [ f>> bitor ] keep f<< ;
: cpu-f-bitand= ( value cpu -- )
#! cpu-f &= value
- [ f>> bitand ] keep (>>f) ;
+ [ f>> bitand ] keep f<< ;
: cpu-f-bitxor= ( value cpu -- )
#! cpu-f ^= value
- [ f>> bitxor ] keep (>>f) ;
+ [ f>> bitxor ] keep f<< ;
: set-flag ( cpu flag -- )
swap cpu-f-bitor= ;
: decrement-sp ( n cpu -- )
#! Decrement the stackpointer by n.
[ sp>> ] keep
- [ swap - ] dip (>>sp) ;
+ [ swap - ] dip sp<< ;
: save-pc ( cpu -- )
#! Save the value of the PC on the stack.
: call-sub ( addr cpu -- )
#! Call the address as a subroutine.
dup push-pc
- [ HEX: FFFF bitand ] dip (>>pc) ;
+ [ HEX: FFFF bitand ] dip pc<< ;
: ret-from-sub ( cpu -- )
- [ pop-pc ] keep (>>pc) ;
+ [ pop-pc ] keep pc<< ;
: interrupt ( number cpu -- )
#! Perform a hardware interrupt
! "***Interrupt: " write over 16 >base print
dup f>> interrupt-flag bitand 0 = not [
dup push-pc
- (>>pc)
+ pc<<
] [
2drop
] if ;
: inc-cycles ( n cpu -- )
#! Increment the number of cpu cycles
- [ cycles>> + ] keep (>>cycles) ;
+ [ cycles>> + ] keep cycles<< ;
: instruction-cycles ( -- vector )
#! Return a 256 element vector containing the cycles for
#! Read the next instruction from the cpu's program
#! counter, and increment the program counter.
[ pc>> ] keep ! pc cpu
- [ over 1 + swap (>>pc) ] keep
+ [ over 1 + swap pc<< ] keep
read-byte ;
: get-cycles ( n -- opcode )
over 16667 < [
2drop
] [
- [ [ 16667 - ] dip (>>cycles) ] keep
+ [ [ 16667 - ] dip cycles<< ] keep
dup last-interrupt>> HEX: 10 = [
- HEX: 08 over (>>last-interrupt) HEX: 08 swap interrupt
+ HEX: 08 over last-interrupt<< HEX: 08 swap interrupt
] [
- HEX: 10 over (>>last-interrupt) HEX: 10 swap interrupt
+ HEX: 10 over last-interrupt<< HEX: 10 swap interrupt
] if
] if ;
#! where the 1st item is the getter and the 2nd is the setter
#! for that register.
H{
- { "A" { a>> (>>a) } }
- { "B" { b>> (>>b) } }
- { "C" { c>> (>>c) } }
- { "D" { d>> (>>d) } }
- { "E" { e>> (>>e) } }
- { "H" { h>> (>>h) } }
- { "L" { l>> (>>l) } }
- { "AF" { af>> (>>af) } }
- { "BC" { bc>> (>>bc) } }
- { "DE" { de>> (>>de) } }
- { "HL" { hl>> (>>hl) } }
- { "SP" { sp>> (>>sp) } }
+ { "A" { a>> a<< } }
+ { "B" { b>> b<< } }
+ { "C" { c>> c<< } }
+ { "D" { d>> d<< } }
+ { "E" { e>> e<< } }
+ { "H" { h>> h<< } }
+ { "L" { l>> l<< } }
+ { "AF" { af>> af<< } }
+ { "BC" { bc>> bc<< } }
+ { "DE" { de>> de<< } }
+ { "HL" { hl>> hl<< } }
+ { "SP" { sp>> sp<< } }
} at ;
#! Given a string containing a flag name, return a vector
#! where the 1st item is a word that tests that flag.
H{
- { "NZ" { flag-nz? } }
- { "NC" { flag-nc? } }
- { "PO" { flag-po? } }
- { "PE" { flag-pe? } }
+ { "NZ" { flag-nz? } }
+ { "NC" { flag-nc? } }
+ { "PO" { flag-po? } }
+ { "PE" { flag-pe? } }
{ "Z" { flag-z? } }
{ "C" { flag-c? } }
{ "P" { flag-p? } }
- { "M" { flag-m? } }
+ { "M" { flag-m? } }
} at ;
SYMBOLS: $1 $2 $3 $4 ;
: (emulate-RST) ( n cpu -- )
#! RST nn
[ sp>> 2 - dup ] keep ! sp sp cpu
- [ (>>sp) ] keep ! sp cpu
+ [ sp<< ] keep ! sp cpu
[ pc>> ] keep ! sp pc cpu
swapd [ write-word ] keep ! cpu
- [ 8 * ] dip (>>pc) ;
+ [ 8 * ] dip pc<< ;
: (emulate-CALL) ( cpu -- )
#! 205 - CALL nn
[ next-word HEX: FFFF bitand ] keep ! addr cpu
[ sp>> 2 - dup ] keep ! addr sp sp cpu
- [ (>>sp) ] keep ! addr sp cpu
+ [ sp<< ] keep ! addr sp cpu
[ pc>> ] keep ! addr sp pc cpu
swapd [ write-word ] keep ! addr cpu
- (>>pc) ;
+ pc<< ;
: (emulate-RLCA) ( cpu -- )
#! The content of the accumulator is rotated left
[ a>> -7 shift ] keep
over 0 = [ dup carry-flag clear-flag ] [ dup carry-flag set-flag ] if
[ a>> 1 shift HEX: FF bitand ] keep
- [ bitor ] dip (>>a) ;
+ [ bitor ] dip a<< ;
: (emulate-RRCA) ( cpu -- )
#! The content of the accumulator is rotated right
[ a>> 1 bitand 7 shift ] keep
over 0 = [ dup carry-flag clear-flag ] [ dup carry-flag set-flag ] if
[ a>> 254 bitand -1 shift ] keep
- [ bitor ] dip (>>a) ;
+ [ bitor ] dip a<< ;
: (emulate-RLA) ( cpu -- )
#! The content of the accumulator is rotated left
[ carry-flag swap flag-set? [ 1 ] [ 0 ] if ] keep
[ a>> 127 bitand 7 shift ] keep
dup a>> 128 bitand 0 = [ dup carry-flag clear-flag ] [ dup carry-flag set-flag ] if
- [ bitor ] dip (>>a) ;
+ [ bitor ] dip a<< ;
: (emulate-RRA) ( cpu -- )
#! The content of the accumulator is rotated right
[ carry-flag swap flag-set? [ BIN: 10000000 ] [ 0 ] if ] keep
[ a>> 254 bitand -1 shift ] keep
dup a>> 1 bitand 0 = [ dup carry-flag clear-flag ] [ dup carry-flag set-flag ] if
- [ bitor ] dip (>>a) ;
+ [ bitor ] dip a<< ;
: (emulate-CPL) ( cpu -- )
#! The contents of the accumulator are complemented
] keep
[ a>> + ] keep
[ update-flags ] 2keep
- [ swap HEX: FF bitand swap (>>a) ] keep
+ [ swap HEX: FF bitand swap a<< ] keep
[
dup carry-flag swap flag-set? swap
a>> -4 shift BIN: 1111 bitand 9 > or [ 96 ] [ 0 ] if
] keep
[ a>> + ] keep
[ update-flags ] 2keep
- swap HEX: FF bitand swap (>>a) ;
+ swap HEX: FF bitand swap a<< ;
: patterns ( -- hashtable )
#! table of code quotation patterns for each type of instruction.
H{
- { "NOP" [ drop ] }
- { "RET-NN" [ ret-from-sub ] }
- { "RST-0" [ 0 swap (emulate-RST) ] }
- { "RST-8" [ 8 swap (emulate-RST) ] }
- { "RST-10H" [ HEX: 10 swap (emulate-RST) ] }
- { "RST-18H" [ HEX: 18 swap (emulate-RST) ] }
- { "RST-20H" [ HEX: 20 swap (emulate-RST) ] }
- { "RST-28H" [ HEX: 28 swap (emulate-RST) ] }
- { "RST-30H" [ HEX: 30 swap (emulate-RST) ] }
- { "RST-38H" [ HEX: 38 swap (emulate-RST) ] }
- { "RET-F|FF" [ dup $1 [ 6 over inc-cycles ret-from-sub ] [ drop ] if ] }
- { "CP-N" [ [ a>> ] keep [ next-byte ] keep sub-byte drop ] }
- { "CP-R" [ [ a>> ] keep [ $1 ] keep sub-byte drop ] }
- { "CP-(RR)" [ [ a>> ] keep [ $1 ] keep [ read-byte ] keep sub-byte drop ] }
- { "OR-N" [ [ a>> ] keep [ next-byte ] keep [ or-byte ] keep (>>a) ] }
- { "OR-R" [ [ a>> ] keep [ $1 ] keep [ or-byte ] keep (>>a) ] }
- { "OR-(RR)" [ [ a>> ] keep [ $1 ] keep [ read-byte ] keep [ or-byte ] keep (>>a) ] }
- { "XOR-N" [ [ a>> ] keep [ next-byte ] keep [ xor-byte ] keep (>>a) ] }
- { "XOR-R" [ [ a>> ] keep [ $1 ] keep [ xor-byte ] keep (>>a) ] }
- { "XOR-(RR)" [ [ a>> ] keep [ $1 ] keep [ read-byte ] keep [ xor-byte ] keep (>>a) ] }
- { "AND-N" [ [ a>> ] keep [ next-byte ] keep [ and-byte ] keep (>>a) ] }
- { "AND-R" [ [ a>> ] keep [ $1 ] keep [ and-byte ] keep (>>a) ] }
- { "AND-(RR)" [ [ a>> ] keep [ $1 ] keep [ read-byte ] keep [ and-byte ] keep (>>a) ] }
- { "ADC-R,N" [ [ $1 ] keep [ next-byte ] keep [ add-byte-with-carry ] keep $2 ] }
- { "ADC-R,R" [ [ $1 ] keep [ $3 ] keep [ add-byte-with-carry ] keep $2 ] }
- { "ADC-R,(RR)" [ [ $1 ] keep [ $3 ] keep [ read-byte ] keep [ add-byte-with-carry ] keep $2 ] }
- { "ADD-R,N" [ [ $1 ] keep [ next-byte ] keep [ add-byte ] keep $2 ] }
- { "ADD-R,R" [ [ $1 ] keep [ $3 ] keep [ add-byte ] keep $2 ] }
- { "ADD-RR,RR" [ [ $1 ] keep [ $3 ] keep [ add-word ] keep $2 ] }
- { "ADD-R,(RR)" [ [ $1 ] keep [ $3 ] keep [ read-byte ] keep [ add-byte ] keep $2 ] }
- { "SBC-R,N" [ [ $1 ] keep [ next-byte ] keep [ sub-byte-with-carry ] keep $2 ] }
- { "SBC-R,R" [ [ $1 ] keep [ $3 ] keep [ sub-byte-with-carry ] keep $2 ] }
- { "SBC-R,(RR)" [ [ $1 ] keep [ $3 ] keep [ read-byte ] keep [ sub-byte-with-carry ] keep $2 ] }
- { "SUB-R" [ [ a>> ] keep [ $1 ] keep [ sub-byte ] keep (>>a) ] }
- { "SUB-(RR)" [ [ a>> ] keep [ $1 ] keep [ read-byte ] keep [ sub-byte ] keep (>>a) ] }
- { "SUB-N" [ [ a>> ] keep [ next-byte ] keep [ sub-byte ] keep (>>a) ] }
- { "CPL" [ (emulate-CPL) ] }
- { "DAA" [ (emulate-DAA) ] }
- { "RLA" [ (emulate-RLA) ] }
- { "RRA" [ (emulate-RRA) ] }
- { "CCF" [ carry-flag swap cpu-f-bitxor= ] }
- { "SCF" [ carry-flag swap cpu-f-bitor= ] }
- { "RLCA" [ (emulate-RLCA) ] }
- { "RRCA" [ (emulate-RRCA) ] }
- { "HALT" [ drop ] }
- { "DI" [ [ 255 interrupt-flag - ] swap cpu-f-bitand ] }
- { "EI" [ [ interrupt-flag ] swap cpu-f-bitor ] }
- { "POP-RR" [ [ pop-sp ] keep $2 ] }
- { "PUSH-RR" [ [ $1 ] keep push-sp ] }
- { "INC-R" [ [ $1 ] keep [ inc-byte ] keep $2 ] }
- { "DEC-R" [ [ $1 ] keep [ dec-byte ] keep $2 ] }
- { "INC-RR" [ [ $1 ] keep [ inc-word ] keep $2 ] }
- { "DEC-RR" [ [ $1 ] keep [ dec-word ] keep $2 ] }
- { "DEC-(RR)" [ [ $1 ] keep [ read-byte ] keep [ dec-byte ] keep [ $1 ] keep write-byte ] }
- { "INC-(RR)" [ [ $1 ] keep [ read-byte ] keep [ inc-byte ] keep [ $1 ] keep write-byte ] }
- { "JP-NN" [ [ pc>> ] keep [ read-word ] keep (>>pc) ] }
- { "JP-F|FF,NN" [ [ $1 ] keep swap [ [ next-word ] keep [ (>>pc) ] keep [ cycles>> ] keep swap 5 + swap (>>cycles) ] [ [ pc>> 2 + ] keep (>>pc) ] if ] }
- { "JP-(RR)" [ [ $1 ] keep (>>pc) ] }
- { "CALL-NN" [ (emulate-CALL) ] }
- { "CALL-F|FF,NN" [ [ $1 ] keep swap [ 7 over inc-cycles (emulate-CALL) ] [ [ pc>> 2 + ] keep (>>pc) ] if ] }
- { "LD-RR,NN" [ [ next-word ] keep $2 ] }
- { "LD-RR,RR" [ [ $3 ] keep $2 ] }
- { "LD-R,N" [ [ next-byte ] keep $2 ] }
- { "LD-(RR),N" [ [ next-byte ] keep [ $1 ] keep write-byte ] }
- { "LD-(RR),R" [ [ $3 ] keep [ $1 ] keep write-byte ] }
- { "LD-R,R" [ [ $3 ] keep $2 ] }
- { "LD-R,(RR)" [ [ $3 ] keep [ read-byte ] keep $2 ] }
- { "LD-(NN),RR" [ [ $1 ] keep [ next-word ] keep write-word ] }
- { "LD-(NN),R" [ [ $1 ] keep [ next-word ] keep write-byte ] }
- { "LD-RR,(NN)" [ [ next-word ] keep [ read-word ] keep $2 ] }
- { "LD-R,(NN)" [ [ next-word ] keep [ read-byte ] keep $2 ] }
- { "OUT-(N),R" [ [ $1 ] keep [ next-byte ] keep write-port ] }
- { "IN-R,(N)" [ [ next-byte ] keep [ read-port ] keep (>>a) ] }
- { "EX-(RR),RR" [ [ $1 ] keep [ read-word ] keep [ $3 ] keep [ $1 ] keep [ write-word ] keep $4 ] }
- { "EX-RR,RR" [ [ $1 ] keep [ $3 ] keep [ $2 ] keep $4 ] }
+ { "NOP" [ drop ] }
+ { "RET-NN" [ ret-from-sub ] }
+ { "RST-0" [ 0 swap (emulate-RST) ] }
+ { "RST-8" [ 8 swap (emulate-RST) ] }
+ { "RST-10H" [ HEX: 10 swap (emulate-RST) ] }
+ { "RST-18H" [ HEX: 18 swap (emulate-RST) ] }
+ { "RST-20H" [ HEX: 20 swap (emulate-RST) ] }
+ { "RST-28H" [ HEX: 28 swap (emulate-RST) ] }
+ { "RST-30H" [ HEX: 30 swap (emulate-RST) ] }
+ { "RST-38H" [ HEX: 38 swap (emulate-RST) ] }
+ { "RET-F|FF" [ dup $1 [ 6 over inc-cycles ret-from-sub ] [ drop ] if ] }
+ { "CP-N" [ [ a>> ] keep [ next-byte ] keep sub-byte drop ] }
+ { "CP-R" [ [ a>> ] keep [ $1 ] keep sub-byte drop ] }
+ { "CP-(RR)" [ [ a>> ] keep [ $1 ] keep [ read-byte ] keep sub-byte drop ] }
+ { "OR-N" [ [ a>> ] keep [ next-byte ] keep [ or-byte ] keep a<< ] }
+ { "OR-R" [ [ a>> ] keep [ $1 ] keep [ or-byte ] keep a<< ] }
+ { "OR-(RR)" [ [ a>> ] keep [ $1 ] keep [ read-byte ] keep [ or-byte ] keep a<< ] }
+ { "XOR-N" [ [ a>> ] keep [ next-byte ] keep [ xor-byte ] keep a<< ] }
+ { "XOR-R" [ [ a>> ] keep [ $1 ] keep [ xor-byte ] keep a<< ] }
+ { "XOR-(RR)" [ [ a>> ] keep [ $1 ] keep [ read-byte ] keep [ xor-byte ] keep a<< ] }
+ { "AND-N" [ [ a>> ] keep [ next-byte ] keep [ and-byte ] keep a<< ] }
+ { "AND-R" [ [ a>> ] keep [ $1 ] keep [ and-byte ] keep a<< ] }
+ { "AND-(RR)" [ [ a>> ] keep [ $1 ] keep [ read-byte ] keep [ and-byte ] keep a<< ] }
+ { "ADC-R,N" [ [ $1 ] keep [ next-byte ] keep [ add-byte-with-carry ] keep $2 ] }
+ { "ADC-R,R" [ [ $1 ] keep [ $3 ] keep [ add-byte-with-carry ] keep $2 ] }
+ { "ADC-R,(RR)" [ [ $1 ] keep [ $3 ] keep [ read-byte ] keep [ add-byte-with-carry ] keep $2 ] }
+ { "ADD-R,N" [ [ $1 ] keep [ next-byte ] keep [ add-byte ] keep $2 ] }
+ { "ADD-R,R" [ [ $1 ] keep [ $3 ] keep [ add-byte ] keep $2 ] }
+ { "ADD-RR,RR" [ [ $1 ] keep [ $3 ] keep [ add-word ] keep $2 ] }
+ { "ADD-R,(RR)" [ [ $1 ] keep [ $3 ] keep [ read-byte ] keep [ add-byte ] keep $2 ] }
+ { "SBC-R,N" [ [ $1 ] keep [ next-byte ] keep [ sub-byte-with-carry ] keep $2 ] }
+ { "SBC-R,R" [ [ $1 ] keep [ $3 ] keep [ sub-byte-with-carry ] keep $2 ] }
+ { "SBC-R,(RR)" [ [ $1 ] keep [ $3 ] keep [ read-byte ] keep [ sub-byte-with-carry ] keep $2 ] }
+ { "SUB-R" [ [ a>> ] keep [ $1 ] keep [ sub-byte ] keep a<< ] }
+ { "SUB-(RR)" [ [ a>> ] keep [ $1 ] keep [ read-byte ] keep [ sub-byte ] keep a<< ] }
+ { "SUB-N" [ [ a>> ] keep [ next-byte ] keep [ sub-byte ] keep a<< ] }
+ { "CPL" [ (emulate-CPL) ] }
+ { "DAA" [ (emulate-DAA) ] }
+ { "RLA" [ (emulate-RLA) ] }
+ { "RRA" [ (emulate-RRA) ] }
+ { "CCF" [ carry-flag swap cpu-f-bitxor= ] }
+ { "SCF" [ carry-flag swap cpu-f-bitor= ] }
+ { "RLCA" [ (emulate-RLCA) ] }
+ { "RRCA" [ (emulate-RRCA) ] }
+ { "HALT" [ drop ] }
+ { "DI" [ [ 255 interrupt-flag - ] swap cpu-f-bitand ] }
+ { "EI" [ [ interrupt-flag ] swap cpu-f-bitor ] }
+ { "POP-RR" [ [ pop-sp ] keep $2 ] }
+ { "PUSH-RR" [ [ $1 ] keep push-sp ] }
+ { "INC-R" [ [ $1 ] keep [ inc-byte ] keep $2 ] }
+ { "DEC-R" [ [ $1 ] keep [ dec-byte ] keep $2 ] }
+ { "INC-RR" [ [ $1 ] keep [ inc-word ] keep $2 ] }
+ { "DEC-RR" [ [ $1 ] keep [ dec-word ] keep $2 ] }
+ { "DEC-(RR)" [ [ $1 ] keep [ read-byte ] keep [ dec-byte ] keep [ $1 ] keep write-byte ] }
+ { "INC-(RR)" [ [ $1 ] keep [ read-byte ] keep [ inc-byte ] keep [ $1 ] keep write-byte ] }
+ { "JP-NN" [ [ pc>> ] keep [ read-word ] keep pc<< ] }
+ { "JP-F|FF,NN" [ [ $1 ] keep swap [ [ next-word ] keep [ pc<< ] keep [ cycles>> ] keep swap 5 + swap cycles<< ] [ [ pc>> 2 + ] keep pc<< ] if ] }
+ { "JP-(RR)" [ [ $1 ] keep pc<< ] }
+ { "CALL-NN" [ (emulate-CALL) ] }
+ { "CALL-F|FF,NN" [ [ $1 ] keep swap [ 7 over inc-cycles (emulate-CALL) ] [ [ pc>> 2 + ] keep pc<< ] if ] }
+ { "LD-RR,NN" [ [ next-word ] keep $2 ] }
+ { "LD-RR,RR" [ [ $3 ] keep $2 ] }
+ { "LD-R,N" [ [ next-byte ] keep $2 ] }
+ { "LD-(RR),N" [ [ next-byte ] keep [ $1 ] keep write-byte ] }
+ { "LD-(RR),R" [ [ $3 ] keep [ $1 ] keep write-byte ] }
+ { "LD-R,R" [ [ $3 ] keep $2 ] }
+ { "LD-R,(RR)" [ [ $3 ] keep [ read-byte ] keep $2 ] }
+ { "LD-(NN),RR" [ [ $1 ] keep [ next-word ] keep write-word ] }
+ { "LD-(NN),R" [ [ $1 ] keep [ next-word ] keep write-byte ] }
+ { "LD-RR,(NN)" [ [ next-word ] keep [ read-word ] keep $2 ] }
+ { "LD-R,(NN)" [ [ next-word ] keep [ read-byte ] keep $2 ] }
+ { "OUT-(N),R" [ [ $1 ] keep [ next-byte ] keep write-port ] }
+ { "IN-R,(N)" [ [ next-byte ] keep [ read-port ] keep a<< ] }
+ { "EX-(RR),RR" [ [ $1 ] keep [ read-word ] keep [ $3 ] keep [ $1 ] keep [ write-word ] keep $4 ] }
+ { "EX-RR,RR" [ [ $1 ] keep [ $3 ] keep [ $2 ] keep $4 ] }
} ;
: 8-bit-registers ( -- parser )
over get-cycles over inc-cycles\r
[ swap instructions nth call( cpu -- ) ] keep\r
[ pc>> HEX: FFFF bitand ] keep \r
- [ (>>pc) ] keep \r
+ [ pc<< ] keep \r
process-interrupts ;\r
\r
: test-step ( cpu -- cpu )\r
+++ /dev/null
-Sam Anklesaria
\ No newline at end of file
+++ /dev/null
-! Copyright (C) 2009 Sam Anklesaria.
-! See http://factorcode.org/license.txt for BSD license.
-USING: accessors kernel parser vocabs.parser words ;
-IN: enter
-! main words are usually only used for entry, doing initialization, etc
-! it makes sense, then to define it all at once, rather than factoring it out into a seperate word
-! and then declaring it main
-SYNTAX: ENTER: gensym [ parse-definition (( -- )) define-declared ] keep current-vocab (>>main) ;
\ No newline at end of file
triple
world handle>> hWnd>>
fullscreen? [
- enable-fullscreen world (>>saved-position)
+ enable-fullscreen world saved-position<<
] [
[ world saved-position>> ] 2dip disable-fullscreen
] if
- fullscreen? world (>>fullscreen?)
+ fullscreen? world fullscreen?<<
] when ;
: set-fullscreen ( gadget triple fullscreen? -- )
t >>running?
[ reset-loop-benchmark ]
[ [ run-loop ] curry "game loop" spawn ]
- [ (>>thread) ] tri ;
+ [ thread<< ] tri ;
: stop-loop ( loop -- )
f >>running?
[ material new swap >>name current-material set ]
[ cm swap md set-at ] bi
] }
- { "Ka" [ 3 head strings>numbers cm (>>ambient-reflectivity) ] }
- { "Kd" [ 3 head strings>numbers cm (>>diffuse-reflectivity) ] }
- { "Ks" [ 3 head strings>numbers cm (>>specular-reflectivity) ] }
- { "Tf" [ 3 head strings>numbers cm (>>transmission-filter) ] }
- { "d" [ first string>number cm (>>dissolve) ] }
- { "Ns" [ first string>number cm (>>specular-exponent) ] }
- { "Ni" [ first string>number cm (>>refraction-index) ] }
- { "map_Ka" [ first cm (>>ambient-map) ] }
- { "map_Kd" [ first cm (>>diffuse-map) ] }
- { "map_Ks" [ first cm (>>specular-map) ] }
- { "map_Ns" [ first cm (>>specular-exponent-map) ] }
- { "map_d" [ first cm (>>dissolve-map) ] }
- { "map_bump" [ first cm (>>bump-map) ] }
- { "bump" [ first cm (>>bump-map) ] }
- { "disp" [ first cm (>>displacement-map) ] }
- { "refl" [ first cm (>>reflection-map) ] }
+ { "Ka" [ 3 head strings>numbers cm ambient-reflectivity<< ] }
+ { "Kd" [ 3 head strings>numbers cm diffuse-reflectivity<< ] }
+ { "Ks" [ 3 head strings>numbers cm specular-reflectivity<< ] }
+ { "Tf" [ 3 head strings>numbers cm transmission-filter<< ] }
+ { "d" [ first string>number cm dissolve<< ] }
+ { "Ns" [ first string>number cm specular-exponent<< ] }
+ { "Ni" [ first string>number cm refraction-index<< ] }
+ { "map_Ka" [ first cm ambient-map<< ] }
+ { "map_Kd" [ first cm diffuse-map<< ] }
+ { "map_Ks" [ first cm specular-map<< ] }
+ { "map_Ns" [ first cm specular-exponent-map<< ] }
+ { "map_d" [ first cm dissolve-map<< ] }
+ { "map_bump" [ first cm bump-map<< ] }
+ { "bump" [ first cm bump-map<< ] }
+ { "disp" [ first cm displacement-map<< ] }
+ { "refl" [ first cm reflection-map<< ] }
[ 2drop ]
} case
] unless-empty ;
M: indexed-seq new-resizable
[ dseq>> ] [ iseq>> ] [ rassoc>> ] tri <indexed-seq>
dup -rot
- [ [ dseq>> new-resizable ] keep (>>dseq) ]
- [ [ iseq>> new-resizable ] keep (>>iseq) ]
- [ [ rassoc>> clone nip ] keep (>>rassoc) ]
+ [ [ dseq>> new-resizable ] keep dseq<< ]
+ [ [ iseq>> new-resizable ] keep iseq<< ]
+ [ [ rassoc>> clone nip ] keep rassoc<< ]
2tri ;
: configure-termios ( serial -- )
dup termios>>
{
- [ [ iflag>> ] dip over [ (>>iflag) ] [ 2drop ] if ]
- [ [ oflag>> ] dip over [ (>>oflag) ] [ 2drop ] if ]
+ [ [ iflag>> ] dip over [ iflag<< ] [ 2drop ] if ]
+ [ [ oflag>> ] dip over [ oflag<< ] [ 2drop ] if ]
[
[
[ cflag>> 0 or ] [ baud>> lookup-baud ] bi bitor
- ] dip (>>cflag)
+ ] dip cflag<<
]
- [ [ lflag>> ] dip over [ (>>lflag) ] [ 2drop ] if ]
+ [ [ lflag>> ] dip over [ lflag<< ] [ 2drop ] if ]
} 2cleave ;
: tciflush ( serial -- )
2bi ;
M: irc-server-chat (attach-chat)
- irc> [ (>>client) ] [ chats>> +server-chat+ set-at ] 2bi ;
+ irc> [ client<< ] [ chats>> +server-chat+ set-at ] 2bi ;
GENERIC: remove-chat ( irc-chat -- )
M: irc-nick-chat remove-chat name>> unregister-chat ;
: apply-mode ( ? participant mode -- )
{
- { CHAR: o [ (>>operator) ] }
- { CHAR: v [ (>>voice) ] }
+ { CHAR: o [ operator<< ] }
+ { CHAR: v [ voice<< ] }
[ 3drop ]
} case ;
GENERIC: set-irc-command ( irc-message -- )
M: irc-message set-irc-command
- [ irc-command-string ] [ (>>command) ] bi ;
+ [ irc-command-string ] [ command<< ] bi ;
: irc-message>string ( irc-message -- string )
{
[ >>parameters ]
[ >>trailing ]
tri*
- [ (>>prefix) ] [ fill-irc-message-slots ] [ swap >>line ] tri
+ [ prefix<< ] [ fill-irc-message-slots ] [ swap >>line ] tri
dup sender >>sender ;
:: move-axis ( gadget x y z -- )
x y z (xyz>loc) :> ( xy z )
- xy gadget indicator>> (>>loc)
- z gadget z-indicator>> (>>loc) ;
+ xy gadget indicator>> loc<<
+ z gadget z-indicator>> loc<< ;
: move-pov ( gadget pov -- )
swap pov>> [ interior>> -rot = COLOR: gray COLOR: white ? >>color drop ]
gadget controller>> read-controller buttons>> length iota [
number>string [ drop ] <border-button>
shelf over add-gadget drop
- ] map gadget (>>buttons) ;
+ ] map gadget buttons<< ;
: add-button-gadgets ( gadget shelf -- gadget shelf )
[ (add-button-gadgets) ] 2keep ;
: update-key-caps-state ( gadget -- )
read-keyboard keys>> over keys>>
- [ [ (>>selected?) ] [ drop ] if* ] 2each
+ [ [ selected?<< ] [ drop ] if* ] 2each
relayout-1 ;
M: key-caps-gadget graft*
] "" append-outputs-as send-everyone ;
: handle-quit ( string -- )
- client [ (>>object) ] [ t >>quit? drop ] bi ;
+ client [ object<< ] [ t >>quit? drop ] bi ;
: handle-help ( string -- )
[
] [
[ username swap warn-name-changed ]
[ username clients rename-at ]
- [ client (>>username) ] tri
+ [ client username<< ] tri
] if
] if-empty ;
M: chat-server handle-already-logged-in
username username-taken-string send-line
- t client (>>quit?) ;
+ t client quit?<< ;
M: chat-server handle-managed-client*
- readln dup f = [ t client (>>quit?) ] when
+ readln dup f = [ t client quit?<< ] when
[
"/" ?head [ handle-command ] [ handle-chat ] if
] unless-empty ;
username clients key? [
handle-already-logged-in
] [
- t client (>>logged-in?)
+ t client logged-in?<<
client username clients set-at
] if ;
M: model-world begin-game-world
init-gpu
{ 0.0 0.0 2.0 } 0 0 set-wasd-view
- [ <model-state> [ fill-model-state ] keep ] [ (>>model-state) ] bi ;
+ [ <model-state> [ fill-model-state ] keep ] [ model-state<< ] bi ;
M: model-world apply-world-attributes
{
[ model-path>> >>model-path ]
[ [ value>> ] dip set-model f ]
[ 2drop t ] if 100 milliseconds sleep
] 2curry "models.conditional" spawn-server
- ] keep (>>thread) ;
+ ] keep thread<< ;
: <conditional> ( condition -- model )
f conditional new-model swap >>condition ;
M: mdb-persistent id>> ( object -- id )
dup class id-slot reader-word execute( object -- id ) ;
-M: mdb-persistent (>>id) ( object value -- )
+M: mdb-persistent id<< ( object value -- )
over class id-slot writer-word execute( object value -- ) ;
] if-key ; inline
M: pair set-at
- [ (>>value) ] [
+ [ value<< ] [
[ set-at ]
[ [ associate ] dip swap >>hash drop ] if-hash
] if-key ; inline
: (init) ( from to astar -- )
swap >>goal
- H{ } clone over astar>> (>>g)
- { } <hash-set> over astar>> (>>in-closed-set)
+ H{ } clone over astar>> g<<
+ { } <hash-set> over astar>> in-closed-set<<
H{ } clone >>origin
H{ } clone >>in-open-set
<min-heap> >>open-set
PRIVATE>
: find-path ( start target astar -- path/f )
- (astar) new [ (>>astar) ] keep [ (init) ] [ (find-path) ] bi ;
+ (astar) new [ astar<< ] keep [ (init) ] [ (find-path) ] bi ;
: <astar> ( neighbours cost heuristic -- astar )
astar-simple new swap >>heuristic swap >>cost swap >>neighbours ;
: get-ok-and-total ( -- total )
stream [
readln dup "+OK" head? [
- " " split second string>number dup account (>>count)
+ " " split second string>number dup account count<<
] [ throw ] if
] with-stream* ;
: (list) ( -- )
stream [
"LIST" command
- readlns account (>>list)
+ readlns account list<<
] with-stream* ;
: (uidls) ( -- )
stream [
"UIDL" command
- readlns account (>>uidls)
+ readlns account uidls<<
] with-stream* ;
PRIVATE>
: capa ( -- array )
stream [
"CAPA" command
- readlns dup account (>>capa)
+ readlns dup account capa<<
] with-stream* ;
: count ( -- n )
"TOP " _ number>string append " "
append _ number>string append
command
- readlns dup raw (>>top)
+ readlns dup raw top<<
] with-stream* ;
: headers ( -- assoc )
: retrieve ( message# -- seq )
[ stream ] dip '[
"RETR " _ number>string append command
- readlns dup raw (>>content)
+ readlns dup raw content<<
] with-stream* ;
: delete ( message# -- )
SYNTAX: SOLUTION:
scan-word
[ name>> "-main" append create-in ] keep
- [ drop current-vocab (>>main) ]
+ [ drop current-vocab main<< ]
[ [ . ] swap prefix (( -- )) define-declared ]
2bi ;
: leaf-insert ( value point leaf -- )
2dup leaf-replaceable?
- [ [ (>>point) ] [ (>>value) ] bi ]
+ [ [ point<< ] [ value<< ] bi ]
[ split-leaf ] if ;
: node-insert ( value point node -- )
[ [ i>> ] [ Q>> ] bi nth-unsafe * ]
[ c>> + ] tri
- [ >fixnum -32 shift cmwc (>>c) ]
+ [ >fixnum -32 shift cmwc c<< ]
[ cmwc [ b>> bitand ] [ c>> + ] bi 32 bits ] bi
dup cmwc r>> > [
dupd <repeating> swap like ;
M: repeating length len>> ;
-M: repeating set-length (>>len) ;
+M: repeating set-length len<< ;
M: repeating virtual@ ( n seq -- n' seq' ) circular>> ;
[ [ \ tuple ] ] [ "Object" lexenv get lookup-reader ] unit-test
[ [ fake-local ] ] [ "jumble" lexenv get lookup-writer ] unit-test
-[ [ fake-self (>>y) ] ] [ "y" lexenv get lookup-writer ] unit-test
+[ [ fake-self y<< ] ] [ "y" lexenv get lookup-writer ] unit-test
[ "blahblah" lexenv get lookup-writer ] must-fail
\ No newline at end of file
: init-sounds ( cpu -- )
init-openal
- [ 9 gen-sources swap (>>sounds) ] keep
+ [ 9 gen-sources swap sounds<< ] keep
[ SOUND-SHOT "vocab:space-invaders/resources/Shot.wav" init-sound ] keep
[ SOUND-UFO "vocab:space-invaders/resources/Ufo.wav" init-sound ] keep
[ sounds>> SOUND-UFO swap nth AL_LOOPING AL_TRUE set-source-param ] keep
[ SOUND-WALK3 "vocab:space-invaders/resources/Walk3.wav" init-sound ] keep
[ SOUND-WALK4 "vocab:space-invaders/resources/Walk4.wav" init-sound ] keep
[ SOUND-UFO-HIT "vocab:space-invaders/resources/UfoHit.wav" init-sound ] keep
- f swap (>>looping?) ;
+ f swap looping?<< ;
: cpu-init ( cpu -- cpu )
- make-opengl-bitmap over (>>bitmap)
+ make-opengl-bitmap over bitmap<<
[ init-sounds ] keep
[ reset ] keep ;
#! Bit 5 = player one left
#! Bit 6 = player one right
[ port1>> dup HEX: FE bitand ] keep
- (>>port1) ;
+ port1<< ;
: read-port2 ( cpu -- byte )
#! Port 2 maps player 2 controls and dip switches
: write-port2 ( value cpu -- )
#! Setting this value affects the value read from port 3
- (>>port2o) ;
+ port2o<< ;
:: bit-newly-set? ( old-value new-value bit -- bool )
new-value bit bit? [ old-value bit bit? not ] dip and ;
#! Bit 4 = Extended play sound
over 0 bit? over looping?>> not and [
dup SOUND-UFO play-invaders-sound
- t over (>>looping?)
+ t over looping?<<
] when
over 0 bit? not over looping?>> and [
dup SOUND-UFO stop-invaders-sound
- f over (>>looping?)
+ f over looping?<<
] when
2dup 0 port3-newly-set? [ dup SOUND-UFO play-invaders-sound ] when
2dup 1 port3-newly-set? [ dup SOUND-SHOT play-invaders-sound ] when
2dup 2 port3-newly-set? [ dup SOUND-BASE-HIT play-invaders-sound ] when
2dup 3 port3-newly-set? [ dup SOUND-INVADER-HIT play-invaders-sound ] when
- (>>port3o) ;
+ port3o<< ;
: write-port4 ( value cpu -- )
#! Affects the value returned by reading port 3
[ port4hi>> ] keep
- [ (>>port4lo) ] keep
- (>>port4hi) ;
+ [ port4lo<< ] keep
+ port4hi<< ;
: write-port5 ( value cpu -- )
#! Plays sounds
2dup 2 port5-newly-set? [ dup SOUND-WALK3 play-invaders-sound ] when
2dup 3 port5-newly-set? [ dup SOUND-WALK4 play-invaders-sound ] when
2dup 4 port5-newly-set? [ dup SOUND-UFO-HIT play-invaders-sound ] when
- (>>port5o) ;
+ port5o<< ;
M: space-invaders write-port ( value port cpu -- )
#! Write a byte to the hardware port, where 'port' is
over get-cycles over inc-cycles
[ swap instructions nth call( cpu -- ) ] keep
[ pc>> HEX: FFFF bitand ] keep
- (>>pc) ;
+ pc<< ;
: gui-frame/2 ( cpu -- )
[ gui-step ] keep
over 16667 < [ ! cycles cpu
nip gui-frame/2
] [
- [ [ 16667 - ] dip (>>cycles) ] keep
+ [ [ 16667 - ] dip cycles<< ] keep
dup last-interrupt>> HEX: 10 = [
- HEX: 08 over (>>last-interrupt) HEX: 08 swap interrupt
+ HEX: 08 over last-interrupt<< HEX: 08 swap interrupt
] [
- HEX: 10 over (>>last-interrupt) HEX: 10 swap interrupt
+ HEX: 10 over last-interrupt<< HEX: 10 swap interrupt
] if
] if ;
dup gui-frame/2 gui-frame/2 ;
: coin-down ( cpu -- )
- [ port1>> 1 bitor ] keep (>>port1) ;
+ [ port1>> 1 bitor ] keep port1<< ;
: coin-up ( cpu -- )
- [ port1>> 255 1 - bitand ] keep (>>port1) ;
+ [ port1>> 255 1 - bitand ] keep port1<< ;
: player1-down ( cpu -- )
- [ port1>> 4 bitor ] keep (>>port1) ;
+ [ port1>> 4 bitor ] keep port1<< ;
: player1-up ( cpu -- )
- [ port1>> 255 4 - bitand ] keep (>>port1) ;
+ [ port1>> 255 4 - bitand ] keep port1<< ;
: player2-down ( cpu -- )
- [ port1>> 2 bitor ] keep (>>port1) ;
+ [ port1>> 2 bitor ] keep port1<< ;
: player2-up ( cpu -- )
- [ port1>> 255 2 - bitand ] keep (>>port1) ;
+ [ port1>> 255 2 - bitand ] keep port1<< ;
: fire-down ( cpu -- )
- [ port1>> HEX: 10 bitor ] keep (>>port1) ;
+ [ port1>> HEX: 10 bitor ] keep port1<< ;
: fire-up ( cpu -- )
- [ port1>> 255 HEX: 10 - bitand ] keep (>>port1) ;
+ [ port1>> 255 HEX: 10 - bitand ] keep port1<< ;
: left-down ( cpu -- )
- [ port1>> HEX: 20 bitor ] keep (>>port1) ;
+ [ port1>> HEX: 20 bitor ] keep port1<< ;
: left-up ( cpu -- )
- [ port1>> 255 HEX: 20 - bitand ] keep (>>port1) ;
+ [ port1>> 255 HEX: 20 - bitand ] keep port1<< ;
: right-down ( cpu -- )
- [ port1>> HEX: 40 bitor ] keep (>>port1) ;
+ [ port1>> HEX: 40 bitor ] keep port1<< ;
: right-up ( cpu -- )
- [ port1>> 255 HEX: 40 - bitand ] keep (>>port1) ;
+ [ port1>> 255 HEX: 40 - bitand ] keep port1<< ;
TUPLE: invaders-gadget < gadget cpu quit? windowed? ;
invaders-gadget H{
- { T{ key-down f f "ESC" } [ t over (>>quit?) dup windowed?>> [ close-window ] [ drop ] if ] }
+ { T{ key-down f f "ESC" } [ t over quit?<< dup windowed?>> [ close-window ] [ drop ] if ] }
{ T{ key-down f f "BACKSPACE" } [ cpu>> coin-down ] }
{ T{ key-up f f "BACKSPACE" } [ cpu>> coin-up ] }
{ T{ key-down f f "1" } [ cpu>> player1-down ] }
M: invaders-gadget graft* ( gadget -- )
dup cpu>> init-sounds
- f over (>>quit?)
+ f over quit?<<
[ system:system-micros swap invaders-process ] curry
"Space invaders" threads:spawn drop ;
M: invaders-gadget ungraft* ( gadget -- )
- t swap (>>quit?) ;
+ t swap quit?<< ;
: (run) ( title cpu rom-info -- )
over load-rom* <invaders-gadget> t >>windowed? swap open-window ;
[ sample-freq>> -rot sine-wave ] keep swap >>data ;
: >silent-buffer ( seconds buffer -- buffer )
- [ sample-freq>> * >integer 0 <repetition> ] [ (>>data) ] [ ] tri ;
+ [ sample-freq>> * >integer 0 <repetition> ] [ data<< ] [ ] tri ;
TUPLE: harmonic n amplitude ;
C: <harmonic> harmonic
harmonic amplitude>> <scaled> ;
: >note ( harmonics note buffer -- buffer )
- [ [ note-harmonic-data ] 2curry map <summed> ] [ (>>data) ] [ ] tri ;
+ [ [ note-harmonic-data ] 2curry map <summed> ] [ data<< ] [ ] tri ;
read-keyboard keys>> :> keys
key-left-shift keys nth
- VELOCITY-MODIFIER-FAST VELOCITY-MODIFIER-NORMAL ? player (>>velocity-modifier)
+ VELOCITY-MODIFIER-FAST VELOCITY-MODIFIER-NORMAL ? player velocity-modifier<<
{
[ key-1 keys nth 1 f ? ]
[ key-3 keys nth 3 f ? ]
[ key-4 keys nth 4 f ? ]
[ key-5 keys nth 10000 f ? ]
- } 0|| player (>>reverse-time)
+ } 0|| player reverse-time<<
key-w keys nth [ player walk-forward ] when
key-s keys nth [ player walk-backward ] when
world history>> :> history
history length 0 > [
history length reverse-time 1 - - 1 max history set-length
- history pop world (>>player)
+ history pop world player<<
] when ;
: tick-player-forward ( world player -- )
[ tetris>> ?update ] [ relayout-1 ] bi ;
M: tetris-gadget graft* ( gadget -- )
- [ [ tick ] curry 100 milliseconds every ] keep (>>alarm) ;
+ [ [ tick ] curry 100 milliseconds every ] keep alarm<< ;
M: tetris-gadget ungraft* ( gadget -- )
[ cancel-alarm f ] change-alarm drop ;
: <tokyo-abstractdb> ( name -- tokyo-abstractdb )
tcadbnew [ swap tcadbopen drop ] keep
- tokyo-abstractdb new [ (>>handle) ] keep ;
+ tokyo-abstractdb new [ handle<< ] keep ;
: <tokyo-remotedb> ( host port -- tokyo-remotedb )
[ tcrdbnew dup ] 2dip tcrdbopen drop
- tokyo-remotedb new [ (>>handle) ] keep ;
+ tokyo-remotedb new [ handle<< ] keep ;
: single-rotate ( node -- node )
0 >>balance
0 over node+link
- (>>balance) rotate ;
+ balance<< rotate ;
: pick-balances ( a node -- balance balance )
balance>> {
[
node+link [
node-link current-side get neg
- over pick-balances rot 0 swap (>>balance)
- ] keep (>>balance)
+ over pick-balances rot 0 swap balance<<
+ ] keep balance<<
] keep swap >>balance
dup node+link [ rotate ] with-other-side
over set-node+link rotate ;
: (avl-set) ( value key node -- node taller? )
2dup key>> = [
- -rot pick (>>key) over (>>value) f
+ -rot pick key<< over value<< f
] [ avl-insert ] if ;
: avl-set ( value key node -- node taller? )
: delete-select-rotate ( node -- node shorter? )
dup node+link balance>> zero? [
- current-side get neg over (>>balance)
- current-side get over node+link (>>balance) rotate f
+ current-side get neg over balance<<
+ current-side get over node+link balance<< rotate f
] [
select-rotate t
] if ;
: balance-delete ( node -- node shorter? )
current-side get over balance>> {
- { [ dup zero? ] [ drop neg over (>>balance) f ] }
+ { [ dup zero? ] [ drop neg over balance<< f ] }
{ [ dupd = ] [ drop 0 >>balance t ] }
[ dupd neg increase-balance rebalance-delete ]
} cond ;
: rotate-right ( node -- node )
dup left>>
- [ right>> swap (>>left) ] 2keep
- [ (>>right) ] keep ;
+ [ right>> swap left<< ] 2keep
+ [ right<< ] keep ;
: rotate-left ( node -- node )
dup right>>
- [ left>> swap (>>right) ] 2keep
- [ (>>left) ] keep ;
+ [ left>> swap right<< ] 2keep
+ [ left<< ] keep ;
: link-right ( left right key node -- left right key node )
- swap [ [ swap (>>left) ] 2keep
+ swap [ [ swap left<< ] 2keep
nip dup left>> ] dip swap ;
: link-left ( left right key node -- left right key node )
- swap [ rot [ (>>right) ] 2keep
+ swap [ rot [ right<< ] 2keep
drop dup right>> swapd ] dip swap ;
: cmp ( key node -- obj node <=> )
} case ;
: assemble ( head left right node -- root )
- [ right>> swap (>>left) ] keep
- [ left>> swap (>>right) ] keep
- [ swap left>> swap (>>right) ] 2keep
- [ swap right>> swap (>>left) ] keep ;
+ [ right>> swap left<< ] keep
+ [ left>> swap right<< ] keep
+ [ swap left>> swap right<< ] 2keep
+ [ swap right>> swap left<< ] keep ;
: splay-at ( key node -- node )
[ T{ node } clone dup dup ] 2dip
(splay) nip assemble ;
: do-splay ( key tree -- )
- [ root>> splay-at ] keep (>>root) ;
+ [ root>> splay-at ] keep root<< ;
: splay-split ( key tree -- node node )
2dup do-splay root>> cmp +lt+ = [
- nip dup left>> swap f over (>>left)
+ nip dup left>> swap f over left<<
] [
- nip dup right>> swap f over (>>right) swap
+ nip dup right>> swap f over right<< swap
] if ;
: get-splay ( key tree -- node ? )
: splay-join ( n2 n1 -- node )
splay-largest [
- [ (>>right) ] keep
+ [ right<< ] keep
] [
drop f
] if* ;
[ get-splay nip ] keep [
dup dec-count
dup right>> swap left>> splay-join
- swap (>>root)
+ swap root<<
] [ drop ] if* ;
: set-splay ( value key tree -- )
- 2dup get-splay [ 2nip (>>value) ] [
+ 2dup get-splay [ 2nip value<< ] [
drop dup inc-count
2dup splay-split rot
- [ [ swapd ] dip node boa ] dip (>>root)
+ [ [ swapd ] dip node boa ] dip root<<
] if ;
: new-root ( value key tree -- )
1 >>count
- [ swap <node> ] dip (>>root) ;
+ [ swap <node> ] dip root<< ;
M: splay set-at ( value key tree -- )
dup root>> [ set-splay ] [ new-root ] if ;
go-left? xor [ left>> ] [ right>> ] if ;
: set-node-link@ ( left parent ? -- )
- go-left? xor [ (>>left) ] [ (>>right) ] if ;
+ go-left? xor [ left<< ] [ right<< ] if ;
: node-link ( node -- child ) f node-link@ ;
dup list-empty? [
2drop
] [
- [ control-value length rem ] [ (>>index) ] [ ] tri
+ [ control-value length rem ] [ index<< ] [ ] tri
[ relayout-1 ] [ scroll>selected ] bi
] if ;
: [global-getter] ( box -- quot )
'[ _ value>> ] ;
: [global-setter] ( box -- quot )
- '[ _ (>>value) ] ;
+ '[ _ value<< ] ;
: define-global ( word -- )
global-box new [ [global-getter] ] [ [global-setter] ] bi (define-variable) ;