M: word see-class* drop ;
M: builtin-class see-class*
- "! Built-in class" comment.
<block
- \ PRIMITIVE: pprint-word
+ \ BUILTIN: pprint-word
[ pprint-word ]
[ <block "slots" word-prop [ pprint-slot ] each pprint-; block> ] bi
block> ;
init kernel kernel.private math namespaces sequences ;
IN: alien
+BUILTIN: alien { underlying c-ptr read-only initial: f } expired ;
+BUILTIN: dll { path byte-array read-only initial: B{ } } ;
+
PREDICATE: pinned-alien < alien underlying>> not ;
UNION: pinned-c-ptr pinned-alien POSTPONE: f ;
USING: accessors kernel math sequences sequences.private ;
IN: arrays
+BUILTIN: array { length array-capacity read-only initial: 0 } ;
+
M: array clone (clone) ; inline
M: array length length>> ; inline
M: array nth-unsafe [ integer>fixnum ] dip array-nth ; inline
"SBUF\""
"SINGLETON:"
"SINGLETONS:"
+ "BUILTIN:"
"SYMBOL:"
"SYMBOLS:"
"CONSTANT:"
sequences.private ;
IN: byte-arrays
+BUILTIN: byte-array
+{ length array-capacity read-only initial: 0 } ;
+
M: byte-array clone (clone) ; inline
M: byte-array length length>> ; inline
M: byte-array nth-unsafe swap integer>fixnum alien-unsigned-1 ; inline
PREDICATE: builtin-class < class
"metaclass" word-prop builtin-class eq? ;
+ERROR: not-a-builtin object ;
+
+: check-builtin ( class -- )
+ dup builtin-class? [ drop ] [ not-a-builtin ] if ;
+
: class>type ( class -- n ) "type" word-prop ; foldable
: type>class ( n -- class ) builtins get-global nth ; foldable
: parse-tuple-slots ( -- )
";" parse-tuple-slots-delim ;
-: parse-tuple-definition ( -- class superclass slots )
- scan-new-class
+: (parse-tuple-definition) ( word -- class superclass slots )
scan-token {
{ ";" [ tuple f ] }
{ "<" [ scan-word [ parse-tuple-slots ] { } make ] }
dup check-duplicate-slots
3dup check-slot-shadowing ;
+: parse-tuple-definition ( -- class superclass slots )
+ scan-new-class (parse-tuple-definition) ;
+
+
ERROR: bad-literal-tuple ;
ERROR: bad-slot-name class slot ;
USING: kernel.private slots.private math.private ;
IN: kernel
+BUILTIN: callstack ;
+BUILTIN: tuple ;
+BUILTIN: wrapper { wrapped read-only } ;
+
DEFER: dip
DEFER: 2dip
DEFER: 3dip
USING: kernel ;
IN: math
+BUILTIN: fixnum ;
+BUILTIN: bignum ;
+BUILTIN: float ;
+
GENERIC: >fixnum ( x -- n ) foldable
GENERIC: >bignum ( x -- n ) foldable
GENERIC: >integer ( x -- n ) foldable
sequences.private slots.private ;
IN: quotations
+BUILTIN: quotation
+ { array array read-only initial: { } }
+ cached-effect
+ cache-counter ;
+
<PRIVATE
: uncurry ( curry -- obj quot )
slots.private ;
IN: strings
+BUILTIN: string { length array-capacity read-only initial: 0 } aux ;
+
<PRIVATE
: string-hashcode ( str -- n ) 3 slot ; inline
! Copyright (C) 2004, 2010 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays byte-arrays byte-vectors
-classes.algebra.private classes.intersection classes.maybe
-classes.mixin classes.parser classes.predicate
+classes.algebra.private classes.builtin classes.intersection
+classes.maybe classes.mixin classes.parser classes.predicate
classes.singleton classes.tuple classes.tuple.parser
classes.union combinators compiler.units definitions
effects.parser generic generic.hook generic.math generic.parser
scan-new-word parse-definition define-syntax
] define-core-syntax
+ "BUILTIN:" [
+ scan-word-name
+ current-vocab lookup-word
+ (parse-tuple-definition) 2drop check-builtin
+ ] define-core-syntax
+
"SYMBOL:" [
scan-new-word define-symbol
] define-core-syntax
FROM: assocs => change-at ;
IN: words
+BUILTIN: word
+{ hashcode fixnum initial: 0 } name vocabulary
+{ def quotation initial: [ ] } props pic-def pic-tail-def
+{ sub-primitive read-only } ;
+
: word ( -- word ) \ word get-global ;
: set-word ( word -- ) \ word set-global ;