make struct-prototype foldable so that <struct> compiles efficiently

db4
Joe Groff 2009-08-26 21:27:12 -05:00
parent 4b56fa8009
commit 4bf4cacc4b
1 changed files with 5 additions and 3 deletions

View File

@ -48,8 +48,10 @@ M: struct equal?
: (struct) ( class -- struct ) : (struct) ( class -- struct )
[ heap-size <byte-array> ] keep memory>struct ; inline [ heap-size <byte-array> ] keep memory>struct ; inline
: struct-prototype ( class -- prototype ) "prototype" word-prop ; foldable
: <struct> ( class -- struct ) : <struct> ( class -- struct )
dup "prototype" word-prop dup struct-prototype
[ >c-ptr clone swap memory>struct ] [ (struct) ] if* ; inline [ >c-ptr clone swap memory>struct ] [ (struct) ] if* ; inline
MACRO: <struct-boa> ( class -- quot: ( ... -- struct ) ) MACRO: <struct-boa> ( class -- quot: ( ... -- struct ) )
@ -176,7 +178,7 @@ M: struct-class heap-size
! class definition ! class definition
: struct-prototype ( class -- prototype ) : make-struct-prototype ( class -- prototype )
[ heap-size <byte-array> ] [ heap-size <byte-array> ]
[ memory>struct ] [ memory>struct ]
[ struct-slots ] tri [ struct-slots ] tri
@ -198,7 +200,7 @@ M: struct-class heap-size
[ "struct-size" set-word-prop ] [ "struct-size" set-word-prop ]
[ "struct-align" set-word-prop ] tri-curry* [ "struct-align" set-word-prop ] tri-curry*
[ tri ] 3curry [ tri ] 3curry
[ dup struct-prototype "prototype" set-word-prop ] [ dup make-struct-prototype "prototype" set-word-prop ]
[ (struct-methods) ] tri ; [ (struct-methods) ] tri ;
: check-struct-slots ( slots -- ) : check-struct-slots ( slots -- )