diff --git a/library/bootstrap/boot-stage2.factor b/library/bootstrap/boot-stage2.factor index 4471d3012b..830a8f9b65 100644 --- a/library/bootstrap/boot-stage2.factor +++ b/library/bootstrap/boot-stage2.factor @@ -34,43 +34,44 @@ USE: stdio "Cold boot in progress..." print [ + "/version.factor" "/version.factor" "/library/stack.factor" - "/library/kernel.factor" - "/library/generic/generic.factor" - "/library/generic/object.factor" - "/library/generic/builtin.factor" - "/library/generic/predicate.factor" - "/library/generic/traits.factor" - "/library/math/math.factor" - "/library/cons.factor" "/library/combinators.factor" + "/library/kernel.factor" "/library/logic.factor" - "/library/vectors.factor" - "/library/lists.factor" + "/library/cons.factor" "/library/assoc.factor" + "/library/math/generic.factor" + "/library/words.factor" "/library/math/arithmetic.factor" "/library/math/math-combinators.factor" + "/library/math/math.factor" + "/library/lists.factor" + "/library/vectors.factor" "/library/strings.factor" "/library/hashtables.factor" "/library/namespaces.factor" "/library/list-namespaces.factor" "/library/sbuf.factor" - "/library/continuations.factor" "/library/errors.factor" + "/library/continuations.factor" "/library/threads.factor" "/library/io/stream.factor" + "/library/io/stdio.factor" "/library/io/io-internals.factor" "/library/io/stream-impl.factor" - "/library/io/stdio.factor" - "/library/words.factor" "/library/vocabularies.factor" "/library/syntax/parse-numbers.factor" "/library/syntax/parser.factor" - "/library/syntax/parse-syntax.factor" "/library/syntax/parse-stream.factor" - "/library/math/generic.factor" + "/library/generic/generic.factor" + "/library/generic/object.factor" + "/library/generic/builtin.factor" + "/library/generic/predicate.factor" + "/library/generic/traits.factor" "/library/bootstrap/init.factor" + "/library/syntax/parse-syntax.factor" "/library/format.factor" "/library/syntax/unparser.factor" diff --git a/library/hashtables.factor b/library/hashtables.factor index db3cd9316a..63238063be 100644 --- a/library/hashtables.factor +++ b/library/hashtables.factor @@ -93,27 +93,3 @@ PREDICATE: vector hashtable ( obj -- ? ) : alist>hash ( alist -- hash ) 37 swap [ unswons pick set-hash ] each ; - -: hash-map ( hash code -- hash ) - #! Apply the code to each key/value pair of the hashtable, - #! collecting return values in a new hashtable. - >r hash>alist r> map alist>hash ; - -! In case I break hashing: - -! : hash ( key table -- value ) -! hash>alist assoc ; -! -! : set-hash ( value key table -- ) -! dup vector-length [ -! ( value key table index ) -! >r 3dup r> -! ( value key table value key table index ) -! [ -! swap vector-nth -! ( value key table value key alist ) -! set-assoc -! ] keep -! ( value key table new-assoc index ) -! pick set-vector-nth -! ] times* 3drop ; diff --git a/library/kernel.factor b/library/kernel.factor index bd9e2aeae4..28f700640c 100644 --- a/library/kernel.factor +++ b/library/kernel.factor @@ -76,7 +76,7 @@ USE: vectors [ cons-hashcode ] ! 2 [ drop 0 ] ! 3 [ >fixnum ] ! 4 - [ >fixnum ] ! 5 + [ >rect >fixnum swap >fixnum bitxor ] ! 5 [ drop 0 ] ! 6 [ drop 0 ] ! 7 [ drop 0 ] ! 8 diff --git a/library/syntax/parse-numbers.factor b/library/syntax/parse-numbers.factor index 5d5f8ba80b..da8438c34d 100644 --- a/library/syntax/parse-numbers.factor +++ b/library/syntax/parse-numbers.factor @@ -27,6 +27,7 @@ IN: parser USE: errors +USE: generic USE: kernel USE: lists USE: math @@ -47,14 +48,14 @@ USE: unparser [ drop t ] [ not-a-number ] ] cond ; -: digit ( num digit base -- num ) +: digit+ ( num digit base -- num ) 2dup < [ rot * + ] [ not-a-number ] ifte ; : (base>) ( base str -- num ) dup str-length 0 = [ not-a-number ] [ - 0 swap [ digit> pick digit ] str-each nip + 0 swap [ digit> pick digit+ ] str-each nip ] ifte ; : base> ( str base -- num ) @@ -62,16 +63,19 @@ USE: unparser #! conversion fails. swap "-" ?str-head [ (base>) neg ] [ (base>) ] ifte ; -: str>ratio ( str -- num ) +DEFER: str>number +FORGET: str>number +GENERIC: str>number ( str -- num ) + +M: string str>number 10 base> ; + +PREDICATE: string potential-ratio "/" swap str-contains? ; +M: potential-ratio str>number ( str -- num ) dup CHAR: / index-of str// swap 10 base> swap 10 base> / ; -: str>number ( str -- num ) - #! Convert a string to a number; throws errors. - [ - [ "/" swap str-contains? ] [ str>ratio ] - [ "." swap str-contains? ] [ str>float ] - [ drop t ] [ 10 base> ] - ] cond ; +PREDICATE: string potential-float "." swap str-contains? ; +M: potential-float str>number ( str -- num ) + str>float ; : parse-number ( str -- num ) #! Convert a string to a number; return f on error. diff --git a/library/test/hashtables.factor b/library/test/hashtables.factor index 663c052fc4..3f76647c60 100644 --- a/library/test/hashtables.factor +++ b/library/test/hashtables.factor @@ -34,3 +34,15 @@ unit-test [ t ] [ 12 hashcode 12 hashcode = ] unit-test [ t ] [ 12 >bignum hashcode 12 hashcode = ] unit-test [ t ] [ 12.0 hashcode 12 >bignum hashcode = ] unit-test + +! Test various odd keys to see if they work. + +16 "testhash" set + +t #{ 2 3 } "testhash" get set-hash +f 100 fac "testhash" get set-hash +{ } { [ { } ] } "testhash" get set-hash + +[ t ] [ #{ 2 3 } "testhash" get hash ] unit-test +[ f ] [ 100 fac "testhash" get hash* cdr ] unit-test +[ { } ] [ { [ { } ] } vector-clone "testhash" get hash* cdr ] unit-test diff --git a/library/words.factor b/library/words.factor index c5c9317506..406c72bce9 100644 --- a/library/words.factor +++ b/library/words.factor @@ -63,8 +63,3 @@ PREDICATE: word undefined ( obj -- ? ) word-primitive 0 = ; : word-vocabulary ( word -- str ) "vocabulary" word-property ; : stack-effect ( word -- str ) "stack-effect" word-property ; : documentation ( word -- str ) "documentation" word-property ; - -: word-clone ( word -- word ) - dup word-primitive - over word-parameter - rot word-plist ; diff --git a/native/run.h b/native/run.h index 2a5d4691f4..1033f23a0d 100644 --- a/native/run.h +++ b/native/run.h @@ -74,11 +74,6 @@ INLINE void cpush(CELL top) put(cs,top); } -INLINE CELL cpeek(void) -{ - return get(cs); -} - INLINE void call(CELL quot) { /* tail call optimization */