2009-09-09 23:33:34 -04:00
|
|
|
! Copyright (C) 2008, 2009 Slava Pestov.
|
2008-11-14 21:18:16 -05:00
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2009-09-09 23:33:34 -04:00
|
|
|
USING: accessors alien.c-types assocs compiler.units functors
|
2009-09-10 15:46:26 -04:00
|
|
|
growable kernel lexer namespaces parser prettyprint.custom
|
2009-09-09 23:33:34 -04:00
|
|
|
sequences specialized-arrays specialized-arrays.private strings
|
2009-09-10 22:41:12 -04:00
|
|
|
vocabs vocabs.parser fry ;
|
2009-09-09 23:33:34 -04:00
|
|
|
QUALIFIED: vectors.functor
|
2008-11-14 21:18:16 -05:00
|
|
|
IN: specialized-vectors
|
2009-09-09 23:33:34 -04:00
|
|
|
|
|
|
|
<PRIVATE
|
|
|
|
|
|
|
|
FUNCTOR: define-vector ( T -- )
|
|
|
|
|
|
|
|
V DEFINES-CLASS ${T}-vector
|
|
|
|
|
|
|
|
A IS ${T}-array
|
|
|
|
S IS ${T}-sequence
|
|
|
|
<A> IS <${A}>
|
|
|
|
|
|
|
|
>V DEFERS >${V}
|
|
|
|
V{ DEFINES ${V}{
|
|
|
|
|
|
|
|
WHERE
|
|
|
|
|
|
|
|
V A <A> vectors.functor:define-vector
|
|
|
|
|
|
|
|
M: V contract 2drop ;
|
|
|
|
|
|
|
|
M: V byte-length underlying>> byte-length ;
|
|
|
|
|
|
|
|
M: V pprint-delims drop \ V{ \ } ;
|
|
|
|
|
|
|
|
M: V >pprint-sequence ;
|
|
|
|
|
|
|
|
M: V pprint* pprint-object ;
|
|
|
|
|
|
|
|
SYNTAX: V{ \ } [ >V ] parse-literal ;
|
|
|
|
|
|
|
|
INSTANCE: V growable
|
|
|
|
INSTANCE: V S
|
|
|
|
|
|
|
|
;FUNCTOR
|
|
|
|
|
|
|
|
: specialized-vector-vocab ( type -- vocab )
|
|
|
|
"specialized-vectors.instances." prepend ;
|
|
|
|
|
|
|
|
PRIVATE>
|
|
|
|
|
2009-09-10 15:46:26 -04:00
|
|
|
: define-vector-vocab ( type -- vocab )
|
2009-09-09 23:33:34 -04:00
|
|
|
underlying-type
|
2009-09-10 15:46:26 -04:00
|
|
|
[ specialized-vector-vocab ] [ '[ _ define-vector ] ] bi
|
|
|
|
generate-vocab ;
|
2009-09-09 23:33:34 -04:00
|
|
|
|
|
|
|
SYNTAX: SPECIALIZED-VECTOR:
|
|
|
|
scan
|
|
|
|
[ define-array-vocab use-vocab ]
|
|
|
|
[ define-vector-vocab use-vocab ] bi ;
|