see now shows classes and methods

cvs
Slava Pestov 2005-08-21 18:25:05 +00:00
parent 9adffd9388
commit 17b0f15425
5 changed files with 61 additions and 12 deletions

View File

@ -1,8 +1,6 @@
- flushing optimization
- new prettyprinter
- reader syntax for arrays, byte arrays, displaced aliens
- print parsing words in bold
- unify unparse and prettyprint
- split, group: return vectors
- sleep word

View 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

View 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 ;

View 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

View 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 [