make-mirror method on structs. fix typo on struct-slots stack effect. don't filter initial values in struct>assoc because structs are more low-level and you want to see the entire layout of the struct you're working with, imo.

db4
Doug Coleman 2009-08-31 18:51:47 -05:00
parent f6da4856b4
commit fee0953cc4
3 changed files with 7 additions and 6 deletions

View File

@ -12,7 +12,7 @@ IN: classes.struct.prettyprint
[ drop \ STRUCT: ] if ;
: struct>assoc ( struct -- assoc )
[ class struct-slots ] [ struct-slot-values ] bi zip filter-tuple-assoc ;
[ class struct-slots ] [ struct-slot-values ] bi zip ;
: pprint-struct-slot ( slot -- )
<flow \ { pprint-word

View File

@ -23,7 +23,7 @@ TUPLE: struct-slot-spec < slot-spec
PREDICATE: struct-class < tuple-class
{ [ \ struct subclass-of? ] [ all-slots length 1 = ] } 1&& ;
: struct-slots ( struct -- slots )
: struct-slots ( struct-class -- slots )
"struct-slots" word-prop ;
! struct allocation

View File

@ -1,9 +1,9 @@
! Copyright (C) 2007, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: assocs hashtables kernel sequences generic words
arrays classes slots slots.private classes.tuple
classes.tuple.private math vectors quotations accessors
combinators ;
USING: accessors arrays assocs classes classes.struct
classes.struct.prettyprint.private classes.tuple
classes.tuple.private combinators generic hashtables kernel
math quotations sequences slots slots.private vectors words ;
IN: mirrors
TUPLE: mirror { object read-only } ;
@ -55,3 +55,4 @@ M: array make-mirror <enum> ;
M: vector make-mirror <enum> ;
M: quotation make-mirror <enum> ;
M: object make-mirror <mirror> ;
M: struct make-mirror struct>assoc [ [ class>> ] dip ] assoc-map ;