- 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
! 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
"\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 ;
\ 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)
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 ;
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
[ "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
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 [
[[ 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 [