From: Doug Coleman Date: Sun, 10 Mar 2013 19:04:34 +0000 (-0700) Subject: classes.builtin: Add the BUILTIN: keyword which lets builtin classes show up in sourc... X-Git-Tag: 0.97~1919 X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=5a9e7cd374bac7214aeaed4a1298b8f19bf18b19 classes.builtin: Add the BUILTIN: keyword which lets builtin classes show up in source files. Probably could use save-location to allow editing, but it seemed to break things. --- diff --git a/basis/see/see.factor b/basis/see/see.factor index b022c244ba..7450d827fe 100644 --- a/basis/see/see.factor +++ b/basis/see/see.factor @@ -204,9 +204,8 @@ M: tuple-class see-class* M: word see-class* drop ; M: builtin-class see-class* - "! Built-in class" comment. ] bi block> ; diff --git a/core/alien/alien.factor b/core/alien/alien.factor index 6440181622..43617f451e 100755 --- a/core/alien/alien.factor +++ b/core/alien/alien.factor @@ -4,6 +4,9 @@ USING: accessors byte-arrays byte-vectors continuations.private 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 ; diff --git a/core/arrays/arrays.factor b/core/arrays/arrays.factor index 085a6a582b..384f0af678 100644 --- a/core/arrays/arrays.factor +++ b/core/arrays/arrays.factor @@ -3,6 +3,8 @@ 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 diff --git a/core/bootstrap/syntax.factor b/core/bootstrap/syntax.factor index d63d74e2a6..651beae234 100644 --- a/core/bootstrap/syntax.factor +++ b/core/bootstrap/syntax.factor @@ -42,6 +42,7 @@ IN: bootstrap.syntax "SBUF\"" "SINGLETON:" "SINGLETONS:" + "BUILTIN:" "SYMBOL:" "SYMBOLS:" "CONSTANT:" diff --git a/core/byte-arrays/byte-arrays.factor b/core/byte-arrays/byte-arrays.factor index d4d2d95cf2..85bf0c45da 100644 --- a/core/byte-arrays/byte-arrays.factor +++ b/core/byte-arrays/byte-arrays.factor @@ -4,6 +4,9 @@ USING: accessors alien.accessors kernel math sequences 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 diff --git a/core/classes/builtin/builtin.factor b/core/classes/builtin/builtin.factor index ad07e00756..72178f62f2 100644 --- a/core/classes/builtin/builtin.factor +++ b/core/classes/builtin/builtin.factor @@ -9,6 +9,11 @@ SYMBOL: builtins 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 diff --git a/core/classes/tuple/parser/parser.factor b/core/classes/tuple/parser/parser.factor index 3ecf70a84d..8f523635e0 100644 --- a/core/classes/tuple/parser/parser.factor +++ b/core/classes/tuple/parser/parser.factor @@ -54,8 +54,7 @@ ERROR: invalid-slot-name name ; : 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 ] } @@ -64,6 +63,10 @@ ERROR: invalid-slot-name name ; 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 ; diff --git a/core/kernel/kernel.factor b/core/kernel/kernel.factor index 710a899856..01e3e5929d 100644 --- a/core/kernel/kernel.factor +++ b/core/kernel/kernel.factor @@ -3,6 +3,10 @@ USING: kernel.private slots.private math.private ; IN: kernel +BUILTIN: callstack ; +BUILTIN: tuple ; +BUILTIN: wrapper { wrapped read-only } ; + DEFER: dip DEFER: 2dip DEFER: 3dip diff --git a/core/math/math.factor b/core/math/math.factor index b7ef811d3a..fa81ce3e2a 100644 --- a/core/math/math.factor +++ b/core/math/math.factor @@ -3,6 +3,10 @@ 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 diff --git a/core/quotations/quotations.factor b/core/quotations/quotations.factor index 7e7a77d4e1..2c59f3f41a 100644 --- a/core/quotations/quotations.factor +++ b/core/quotations/quotations.factor @@ -4,6 +4,11 @@ USING: accessors arrays kernel kernel.private math sequences sequences.private slots.private ; IN: quotations +BUILTIN: quotation + { array array read-only initial: { } } + cached-effect + cache-counter ; + 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 ;