]> gitweb.factorcode.org Git - factor.git/commitdiff
see now shows classes and methods
authorSlava Pestov <slava@factorcode.org>
Sun, 21 Aug 2005 18:25:05 +0000 (18:25 +0000)
committerSlava Pestov <slava@factorcode.org>
Sun, 21 Aug 2005 18:25:05 +0000 (18:25 +0000)
TODO.FACTOR.txt
library/syntax/prettyprint.factor
library/syntax/see.factor
library/test/prettyprint.factor
library/ui/ui.factor

index b8d6c3aa6b73a889053a99218388dac2a2d4f65b..48a6c1e0fba5c5a5a5422bdb3bc70b3f006343c7 100644 (file)
@@ -1,8 +1,6 @@
 - flushing optimization\r
 - new prettyprinter\r
   - reader syntax for arrays, byte arrays, displaced aliens\r
-  - print parsing words in bold\r
-  - unify unparse and prettyprint\r
 - split, group: return vectors\r
 - sleep word\r
 \r
index 31acd365dc1ab6a4f9f71639ca943b4466ba295e..83c18faa987f243dd11926c4707c4e4b591d79c1 100644 (file)
@@ -11,6 +11,7 @@ parser sequences strings styles unparser vectors words ;
 ! - out of memory when printing global namespace
 ! - formatting HTML code
 ! - limit strings
+! - merge unparse into this
 
 ! State
 SYMBOL: column
index 1c47e3db1e13d22dcfe499766e8846ae1f5e4a1a..67f3bedb61152d52d63573e3571223a381ebda16 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2003, 2005 Slava Pestov.
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: prettyprint
-USING: generic io kernel lists namespaces sequences styles words ;
+USING: generic hashtables io kernel lists namespaces sequences
+styles words ;
 
 : declaration. ( word prop -- )
     tuck word-name word-prop
@@ -52,9 +53,11 @@ M: word (see) definer. t newline ;
         "\n" split [ "#!" swap append comment. t newline ] each
     ] when* ;
 
+: pprint-; \ ; pprint-object ;
+
 : see-body ( quot word -- )
     dup definer. <block dup documentation. swap pprint-elements
-    \ ; pprint-object declarations. block> ;
+    pprint-; declarations. block> ;
 
 M: compound (see)
     dup word-def swap see-body t newline ;
@@ -64,7 +67,7 @@ M: compound (see)
     \ M: pprint-object bl
     unswons pprint-object bl
     swap pprint-object t newline
-    pprint-elements \ ; pprint-object
+    pprint-elements pprint-;
     block> t newline ;
 
 M: generic (see)
@@ -73,5 +76,44 @@ M: generic (see)
     swap see-body block> t newline
     dup methods [ method. ] each-with ;
 
+GENERIC: class. ( word -- )
+
+: methods. ( class -- )
+    #! List all methods implemented for this class.
+    dup metaclass [
+        t newline
+        dup implementors [
+            dup in. tuck "methods" word-prop hash* method.
+        ] each-with
+    ] [
+        drop
+    ] ifte ;
+
+M: union class.
+    \ UNION: pprint-object bl
+    dup pprint-object bl
+    "members" word-prop pprint-elements pprint-; ;
+
+M: complement class.
+    \ COMPLEMENT: pprint-object bl
+    dup pprint-object bl
+    "complement" word-prop pprint-object ;
+
+M: predicate class.
+    \ PREDICATE: pprint-object bl
+    dup "superclass" word-prop pprint-object bl
+    dup pprint-object f newline
+    <block
+    "definition" word-prop pprint-elements
+    pprint-; block> ;
+
+M: tuple-class class.
+    \ TUPLE: pprint-object bl
+    dup pprint-object bl
+    "slot-names" word-prop [ f text bl ] each
+    pprint-; ;
+
+M: word class. drop ;
+
 : see ( word -- )
-    [ dup in. (see) ] with-pprint ;
+    [ dup in. dup (see) dup class. methods. ] with-pprint ;
index 6e8dd2d43adfea9568a1557a0e7f61151929ac99..02fdcf810ae1f8b8c8dd313c033a264bc3dfccd5 100644 (file)
@@ -1,5 +1,5 @@
 IN: temporary
-USING: io kernel math sequences test xp ;
+USING: io kernel lists math prettyprint sequences test words ;
 
 [ "4" ] [ 4 pprint>string ] unit-test
 [ "1.0" ] [ 1.0 pprint>string ] unit-test
@@ -39,3 +39,13 @@ unit-test
 
 [ "IN: temporary\n: foo dup * ; inline\n" ]
 [ [ \ foo see ] string-out ] unit-test
+
+[ ] [ \ fixnum see ] unit-test
+
+[ ] [ \ integer see ] unit-test
+
+[ ] [ \ general-t see ] unit-test
+
+[ ] [ \ compound see ] unit-test
+
+[ ] [ \ pprinter see ] unit-test
index b566d24ae299e8db36e5566d60add2d6b110cc9b..73339aec923a23df88a5a399c8caf615fe1d2194 100644 (file)
@@ -10,9 +10,7 @@ prettyprint sdl sequences styles threads words ;
 SYMBOL: stack-display
 
 : ui.s ( -- )
-    stack-display get dup pane-clear [
-        datastack reverse [ unparse. terpri ] each
-    ] with-stream* ;
+    stack-display get dup pane-clear [ .s ] with-stream* ;
 
 : init-world
     global [
@@ -30,13 +28,13 @@ SYMBOL: stack-display
             [[ font-style plain ]]
         }} world get set-gadget-paint
         
-        { 1024 768 0 } world get set-gadget-dim
+        { 640 768 0 } world get set-gadget-dim
         
         <plain-gadget> add-layer
     
         <pane> dup pane set <scroller>
         <pane> dup stack-display set <scroller>
-        3/4 <y-splitter> add-layer
+        3/4 <x-splitter> add-layer
         
         [
             pane get [