1 ! Copyright (C) 2004, 2010 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: classes classes.algebra.private classes.private kernel
4 kernel.private make namespaces sequences words ;
9 PREDICATE: builtin-class < class
10 "metaclass" word-prop builtin-class eq? ;
12 ERROR: not-a-builtin object ;
14 : check-builtin ( class -- )
15 dup builtin-class? [ drop ] [ not-a-builtin ] if ;
17 : class>type ( class -- n ) "type" word-prop ; foldable
19 : type>class ( n -- class ) builtins get-global nth ; foldable
21 : bootstrap-type>class ( n -- class ) builtins get nth ;
23 M: object class-of tag type>class ; inline
25 M: builtin-class rank-class drop 0 ;
27 M: builtin-class instance? [ tag ] [ class>type ] bi* eq? ;
29 M: builtin-class (flatten-class) dup ,, ;
31 M: builtin-class (classes-intersect?) eq? ;
33 : full-cover ( -- ) builtins get [ (flatten-class) ] each ;
35 M: anonymous-complement (flatten-class) drop full-cover ;