refs: some cleanup.
parent
c8feb479cb
commit
a1f91ba482
|
@ -1,6 +1,7 @@
|
||||||
! Copyright (C) 2007, 2008 Slava Pestov, 2009 Alex Chapman
|
! Copyright (C) 2007, 2008 Slava Pestov, 2009 Alex Chapman
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: kernel assocs accessors boxes math namespaces ;
|
USING: accessors assocs boxes kernel math namespaces
|
||||||
|
slots.private ;
|
||||||
IN: refs
|
IN: refs
|
||||||
|
|
||||||
MIXIN: ref
|
MIXIN: ref
|
||||||
|
@ -22,7 +23,7 @@ GENERIC: delete-ref ( ref -- )
|
||||||
: ref-dec ( ref -- ) -1 swap ref-+@ ;
|
: ref-dec ( ref -- ) -1 swap ref-+@ ;
|
||||||
|
|
||||||
: take ( ref -- obj )
|
: take ( ref -- obj )
|
||||||
dup get-ref swap delete-ref ;
|
[ get-ref ] [ delete-ref ] bi ;
|
||||||
|
|
||||||
! delete-ref defaults to setting ref to f
|
! delete-ref defaults to setting ref to f
|
||||||
M: ref delete-ref ref-off ;
|
M: ref delete-ref ref-off ;
|
||||||
|
@ -45,7 +46,6 @@ M: global-var-ref get-ref var>> get-global ;
|
||||||
M: global-var-ref set-ref var>> set-global ;
|
M: global-var-ref set-ref var>> set-global ;
|
||||||
INSTANCE: global-var-ref ref
|
INSTANCE: global-var-ref ref
|
||||||
|
|
||||||
USE: slots.private
|
|
||||||
TUPLE: slot-ref tuple slot ;
|
TUPLE: slot-ref tuple slot ;
|
||||||
C: <slot-ref> slot-ref
|
C: <slot-ref> slot-ref
|
||||||
: >slot-ref< ( slot-ref -- tuple slot ) [ tuple>> ] [ slot>> ] bi ; inline
|
: >slot-ref< ( slot-ref -- tuple slot ) [ tuple>> ] [ slot>> ] bi ; inline
|
||||||
|
@ -59,9 +59,7 @@ M: box delete-ref box> drop ;
|
||||||
INSTANCE: box ref
|
INSTANCE: box ref
|
||||||
|
|
||||||
TUPLE: assoc-ref assoc key ;
|
TUPLE: assoc-ref assoc key ;
|
||||||
|
|
||||||
: >assoc-ref< ( assoc-ref -- key value ) [ key>> ] [ assoc>> ] bi ; inline
|
: >assoc-ref< ( assoc-ref -- key value ) [ key>> ] [ assoc>> ] bi ; inline
|
||||||
|
|
||||||
M: assoc-ref delete-ref ( assoc-ref -- ) >assoc-ref< delete-at ;
|
M: assoc-ref delete-ref ( assoc-ref -- ) >assoc-ref< delete-at ;
|
||||||
|
|
||||||
TUPLE: key-ref < assoc-ref ;
|
TUPLE: key-ref < assoc-ref ;
|
||||||
|
|
Loading…
Reference in New Issue