"Cold boot in progress..." print\r
\r
[\r
+ "/version.factor"\r
"/version.factor"\r
"/library/stack.factor"\r
- "/library/kernel.factor"\r
- "/library/generic/generic.factor"\r
- "/library/generic/object.factor"\r
- "/library/generic/builtin.factor"\r
- "/library/generic/predicate.factor"\r
- "/library/generic/traits.factor"\r
- "/library/math/math.factor"\r
- "/library/cons.factor"\r
"/library/combinators.factor"\r
+ "/library/kernel.factor"\r
"/library/logic.factor"\r
- "/library/vectors.factor"\r
- "/library/lists.factor"\r
+ "/library/cons.factor"\r
"/library/assoc.factor"\r
+ "/library/math/generic.factor"\r
+ "/library/words.factor"\r
"/library/math/arithmetic.factor"\r
"/library/math/math-combinators.factor"\r
+ "/library/math/math.factor"\r
+ "/library/lists.factor"\r
+ "/library/vectors.factor"\r
"/library/strings.factor"\r
"/library/hashtables.factor"\r
"/library/namespaces.factor"\r
"/library/list-namespaces.factor"\r
"/library/sbuf.factor"\r
- "/library/continuations.factor"\r
"/library/errors.factor"\r
+ "/library/continuations.factor"\r
"/library/threads.factor"\r
"/library/io/stream.factor"\r
+ "/library/io/stdio.factor"\r
"/library/io/io-internals.factor"\r
"/library/io/stream-impl.factor"\r
- "/library/io/stdio.factor"\r
- "/library/words.factor"\r
"/library/vocabularies.factor"\r
"/library/syntax/parse-numbers.factor"\r
"/library/syntax/parser.factor"\r
- "/library/syntax/parse-syntax.factor"\r
"/library/syntax/parse-stream.factor"\r
- "/library/math/generic.factor"\r
+ "/library/generic/generic.factor"\r
+ "/library/generic/object.factor"\r
+ "/library/generic/builtin.factor"\r
+ "/library/generic/predicate.factor"\r
+ "/library/generic/traits.factor"\r
"/library/bootstrap/init.factor"\r
+ "/library/syntax/parse-syntax.factor"\r
\r
"/library/format.factor"\r
"/library/syntax/unparser.factor"\r
: alist>hash ( alist -- hash )
37 <hashtable> 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 ;
[ 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
IN: parser
USE: errors
+USE: generic
USE: kernel
USE: lists
USE: math
[ 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 )
#! 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.
[ 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 <hashtable> "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
: 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 <word> ;
put(cs,top);
}
-INLINE CELL cpeek(void)
-{
- return get(cs);
-}
-
INLINE void call(CELL quot)
{
/* tail call optimization */