:vars and .vars
parent
c5de10ec49
commit
6c0dd93ff1
|
@ -31,6 +31,9 @@ M: string error. print ;
|
||||||
: :get ( variable -- value )
|
: :get ( variable -- value )
|
||||||
error-continuation get continuation-name assoc-stack ;
|
error-continuation get continuation-name assoc-stack ;
|
||||||
|
|
||||||
|
: :vars ( -- )
|
||||||
|
error-continuation get continuation-name namestack. ;
|
||||||
|
|
||||||
: :res ( n -- )
|
: :res ( n -- )
|
||||||
1- restarts get-global nth f restarts set-global restart ;
|
1- restarts get-global nth f restarts set-global restart ;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
! Copyright (C) 2005, 2007 Slava Pestov.
|
! Copyright (C) 2005, 2008 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: arrays generic hashtables io kernel assocs math
|
USING: arrays generic hashtables io kernel assocs math
|
||||||
namespaces prettyprint sequences strings io.styles vectors words
|
namespaces prettyprint sequences strings io.styles vectors words
|
||||||
|
@ -93,6 +93,15 @@ SYMBOL: +editable+
|
||||||
|
|
||||||
: describe ( obj -- ) H{ } describe* ;
|
: describe ( obj -- ) H{ } describe* ;
|
||||||
|
|
||||||
|
: namestack. ( seq -- )
|
||||||
|
[
|
||||||
|
[ global eq? not ] subset
|
||||||
|
[ keys ] map concat prune
|
||||||
|
] keep [ dupd assoc-stack ] curry H{ } map>assoc describe ;
|
||||||
|
|
||||||
|
: .vars ( -- )
|
||||||
|
namestack namestack. ;
|
||||||
|
|
||||||
SYMBOL: inspector-hook
|
SYMBOL: inspector-hook
|
||||||
|
|
||||||
[ H{ { +number-rows+ t } } describe* ] inspector-hook set-global
|
[ H{ { +number-rows+ t } } describe* ] inspector-hook set-global
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
! Copyright (C) 2007 Slava Pestov.
|
! Copyright (C) 2007, 2008 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: assocs hashtables kernel sequences generic words
|
USING: assocs hashtables kernel sequences generic words
|
||||||
arrays classes slots slots.private tuples math vectors
|
arrays classes slots slots.private tuples math vectors
|
||||||
quotations ;
|
quotations sorting prettyprint ;
|
||||||
IN: mirrors
|
IN: mirrors
|
||||||
|
|
||||||
GENERIC: object-slots ( obj -- seq )
|
GENERIC: object-slots ( obj -- seq )
|
||||||
|
@ -69,8 +69,13 @@ M: enum clear-assoc enum-seq delete-all ;
|
||||||
|
|
||||||
INSTANCE: enum assoc
|
INSTANCE: enum assoc
|
||||||
|
|
||||||
|
: sort-assoc ( assoc -- alist )
|
||||||
|
>alist
|
||||||
|
[ dup first unparse-short swap ] { } map>assoc
|
||||||
|
sort-keys values ;
|
||||||
|
|
||||||
GENERIC: make-mirror ( obj -- assoc )
|
GENERIC: make-mirror ( obj -- assoc )
|
||||||
M: hashtable make-mirror ;
|
M: hashtable make-mirror sort-assoc ;
|
||||||
M: integer make-mirror drop f ;
|
M: integer make-mirror drop f ;
|
||||||
M: array make-mirror <enum> ;
|
M: array make-mirror <enum> ;
|
||||||
M: vector make-mirror <enum> ;
|
M: vector make-mirror <enum> ;
|
||||||
|
|
|
@ -67,7 +67,7 @@ unit-test
|
||||||
[ "[ \\ [ ]" ] [ [ \ [ ] unparse ] unit-test
|
[ "[ \\ [ ]" ] [ [ \ [ ] unparse ] unit-test
|
||||||
|
|
||||||
[ t ] [
|
[ t ] [
|
||||||
100 \ dup <array> [ pprint-short ] with-string-writer
|
100 \ dup <array> unparse-short
|
||||||
"{" head?
|
"{" head?
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
|
|
|
@ -75,6 +75,9 @@ combinators quotations ;
|
||||||
{ string-limit t }
|
{ string-limit t }
|
||||||
} clone [ pprint ] bind ;
|
} clone [ pprint ] bind ;
|
||||||
|
|
||||||
|
: unparse-short ( obj -- str )
|
||||||
|
[ pprint-short ] with-string-writer ;
|
||||||
|
|
||||||
: short. ( obj -- ) pprint-short nl ;
|
: short. ( obj -- ) pprint-short nl ;
|
||||||
|
|
||||||
: .b ( n -- ) >bin print ;
|
: .b ( n -- ) >bin print ;
|
||||||
|
|
Loading…
Reference in New Issue