]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/inspector/inspector.factor
use reject instead of [ ... not ] filter.
[factor.git] / basis / inspector / inspector.factor
index 1347b4f207dfdefd1a35d320eed90d11f17118ac..97c28f7dfeb85ac9099a8cc9466d49f392307605 100644 (file)
@@ -1,15 +1,17 @@
-! Copyright (C) 2005, 2009 Slava Pestov.
+! Copyright (C) 2005, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays generic hashtables io kernel assocs math
 namespaces prettyprint prettyprint.custom prettyprint.sections
 sequences strings io.styles vectors words quotations mirrors
 splitting math.parser classes vocabs sets sorting summary
 debugger continuations fry combinators ;
+FROM: namespaces => set ;
 IN: inspector
 
 SYMBOL: +number-rows+
 
-: summary. ( obj -- ) [ summary ] keep write-object nl ;
+: print-summary ( obj -- )
+    [ safe-summary ] keep write-object ;
 
 <PRIVATE
 
@@ -23,9 +25,7 @@ GENERIC: add-numbers ( alist -- table' )
 M: enum add-numbers ;
 
 M: assoc add-numbers
-    +number-rows+ get [
-        dup length [ prefix ] 2map
-    ] when ;
+    +number-rows+ get [ [ prefix ] map-index ] when ;
 
 TUPLE: slot-name name ;
 
@@ -40,7 +40,7 @@ M: mirror fix-slot-names
 
 : (describe) ( obj assoc -- keys )
     t pprint-string-cells? [
-        [ summary. ] [
+        [ print-summary nl ] [
             dup hashtable? [ sort-unparsed-keys ] when
             [ fix-slot-names add-numbers simple-table. ] [ keys ] bi
         ] bi*
@@ -52,15 +52,15 @@ PRIVATE>
 
 M: tuple error. describe ;
 
-: namestack. ( seq -- )
-    [ [ global eq? not ] filter [ keys ] gather ] keep
-    '[ dup _ assoc-stack ] H{ } map>assoc describe ;
+: vars-in-scope ( seq -- alist )
+    [ [ global eq? ] reject [ keys ] gather ] keep
+    '[ dup _ assoc-stack ] H{ } map>assoc ;
 
 : .vars ( -- )
-    namestack namestack. ;
+    namestack vars-in-scope describe ;
 
 : :vars ( -- )
-    error-continuation get name>> namestack. ;
+    error-continuation get name>> vars-in-scope describe ;
 
 SYMBOL: me
 
@@ -91,7 +91,7 @@ PRIVATE>
 
 : &back ( -- )
     inspector-stack get
-    dup length 1 <= [ drop ] [ [ pop* ] [ peek reinspect ] bi ] if ;
+    dup length 1 <= [ drop ] [ [ pop* ] [ last reinspect ] bi ] if ;
 
 : &add ( value key -- ) mirror get set-at &push reinspect ;