From c7ed8a88bb5040c140948e053ffb4fce8ec5c22d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bj=C3=B6rn=20Lindqvist?= Date: Fri, 18 Mar 2016 20:21:51 +0100 Subject: [PATCH] bootstrap.primitives: new predicate integer-array-capacity It is to be used to declare values for better optimizations. --- core/bootstrap/primitives.factor | 29 +++++++++++++++++++--------- core/sequences/sequences-docs.factor | 12 +++++++++--- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/core/bootstrap/primitives.factor b/core/bootstrap/primitives.factor index 5079cf6acf..2fbbfdf1c5 100755 --- a/core/bootstrap/primitives.factor +++ b/core/bootstrap/primitives.factor @@ -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 [ 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 [ <= ] 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 ] diff --git a/core/sequences/sequences-docs.factor b/core/sequences/sequences-docs.factor index 098bbc543f..6b4a8907d4 100644 --- a/core/sequences/sequences-docs.factor +++ b/core/sequences/sequences-docs.factor @@ -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 } } -- 2.34.1