bootstrap.primitives: new predicate integer-array-capacity

It is to be used to declare values for better optimizations.
locals-and-roots
Björn Lindqvist 2016-03-18 20:21:51 +01:00
parent a3ce61f8da
commit c7ed8a88bb
2 changed files with 29 additions and 12 deletions

View File

@ -1,13 +1,11 @@
! Copyright (C) 2004, 2010 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien alien.strings arrays assocs byte-arrays classes
classes.intersection classes.union combinators generic hashtables
hashtables.private io io.encodings.ascii kernel math math.private math.order
namespaces make parser quotations sequences strings vectors words layouts
classes.private classes.builtin classes.singleton classes.tuple
classes.tuple.private kernel.private vocabs vocabs.loader
source-files definitions slots classes.predicate compiler.units
bootstrap.image.private io.files splitting ;
USING: alien.strings arrays assocs bootstrap.image.private classes
classes.builtin classes.intersection classes.predicate classes.private
classes.singleton classes.tuple classes.tuple.private classes.union
combinators compiler.units io io.encodings.ascii kernel kernel.private
layouts make math math.private namespaces parser quotations sequences
slots source-files splitting vocabs vocabs.loader words ;
IN: bootstrap.primitives
"Creating primitives and basic runtime structures..." print flush
@ -160,7 +158,11 @@ call( -- ) ! syntax-quot
"byte-array" "byte-arrays" lookup-word ,
] { } make define-union-class
! A predicate class used for declarations
"integer" "math" create-word
"fixnum" "math" lookup-word "bignum" "math" lookup-word 2array
define-union-class
! Two predicate classes used for declarations.
"array-capacity" "sequences.private" create-word
"fixnum" "math" lookup-word
[
@ -174,6 +176,15 @@ define-predicate-class
[ >fixnum ] bootstrap-max-array-capacity <fake-bignum> [ fixnum-bitand ] curry append
"coercer" set-word-prop
"integer-array-capacity" "sequences.private" create-word
"integer" "math" lookup-word
[
[ dup 0 >= ] %
bootstrap-max-array-capacity <fake-bignum> [ <= ] curry ,
[ [ drop f ] if ] %
] [ ] make
define-predicate-class
! Catch-all class for providing a default method.
"object" "kernel" create-word
[ f f { } intersection-class define-class ]

View File

@ -267,10 +267,16 @@ HELP: first4
{ $errors "Throws an error if the sequence has less than four elements." } ;
HELP: array-capacity
{ $values { "array" array } { "n" "a non-negative fixnum" } }
{ $class-description "A predicate class whose instances are valid array sizes for the current architecture. The minimum value is zero and the maximum value is " { $link max-array-capacity } "." }
{ $class-description "A predicate class whose instances are fixnums of valid array sizes for the current architecture. The minimum value is zero and the maximum value is " { $link max-array-capacity } "." }
{ $description "Low-level array length accessor." }
{ $warning "This word is in the " { $vocab-link "sequences.private" } " vocabulary because it is unsafe. It does not check types, so improper use can corrupt memory." } ;
{ $warning "This word is in the " { $vocab-link "sequences.private" } " vocabulary because it is unsafe. It does not check types, so improper use can corrupt memory." }
{ $see-also integer-array-capacity } ;
HELP: integer-array-capacity
{ $class-description "A predicate class whose instances are integer of valid array sizes for the current architecture. The minimum value is zero and the maximum value is " { $link max-array-capacity } "." }
{ $description "Low-level array length accessor." }
{ $warning "This word is in the " { $vocab-link "sequences.private" } " vocabulary because it is unsafe. It does not check types, so improper use can corrupt memory." }
{ $see-also array-capacity } ;
HELP: array-nth
{ $values { "n" "a non-negative fixnum" } { "array" array } { "elt" object } }