Merge branch 'master' of git://factorcode.org/git/factor

Slava Pestov 2009-10-30 21:00:26 -05:00
commit d100bb355b
30 changed files with 23 additions and 19 deletions

View File

@ -4,7 +4,7 @@ USING: accessors cpu.architecture vocabs.loader system
sequences namespaces parser kernel kernel.private classes sequences namespaces parser kernel kernel.private classes
classes.private arrays hashtables vectors classes.tuple sbufs classes.private arrays hashtables vectors classes.tuple sbufs
hashtables.private sequences.private math classes.tuple.private hashtables.private sequences.private math classes.tuple.private
growable namespaces.private shuffle assocs words command-line vocabs io growable namespaces.private assocs words command-line vocabs io
io.encodings.string libc splitting math.parser memory compiler.units io.encodings.string libc splitting math.parser memory compiler.units
math.order quotations quotations.private assocs.private ; math.order quotations quotations.private assocs.private ;
FROM: compiler => enable-optimizer ; FROM: compiler => enable-optimizer ;
@ -49,7 +49,7 @@ gc
{ {
not ? not ?
2over roll -roll 2over
array? hashtable? vector? array? hashtable? vector?
tuple? sbuf? tombstone? tuple? sbuf? tombstone?

View File

@ -7,7 +7,7 @@ sorting assocs definitions prettyprint io inspector
classes.tuple classes.union classes.predicate debugger classes.tuple classes.union classes.predicate debugger
threads.private io.streams.string io.timeouts io.thread threads.private io.streams.string io.timeouts io.thread
sequences.private destructors combinators eval locals.backend sequences.private destructors combinators eval locals.backend
system compiler.units ; system compiler.units shuffle ;
IN: stack-checker.tests IN: stack-checker.tests
[ 1234 infer ] must-fail [ 1234 infer ] must-fail

View File

@ -270,30 +270,34 @@ ERROR: integer-length-expected obj ;
: check-length ( n -- n ) : check-length ( n -- n )
dup integer? [ integer-length-expected ] unless ; inline dup integer? [ integer-length-expected ] unless ; inline
: ((copy)) ( dst i src j n -- ) TUPLE: copy-state
[ + swap nth-unsafe [ ] curry 2dip ] keep { src-i integer read-only }
+ swap set-nth-unsafe ; inline { src sequence read-only }
{ dst-i integer read-only }
{ dst sequence read-only } ;
: 5bi ( a b c d e x y -- ) C: <copy> copy-state
bi-curry bi-curry bi-curry bi-curry bi ; inline
: (copy) ( dst i src j n -- dst ) : ((copy)) ( n copy -- )
dup 0 <= [ 2drop 2drop ] [ 1 - [ ((copy)) ] [ (copy) ] 5bi ] if ; [ [ src-i>> + ] [ src>> ] bi nth-unsafe ]
[ [ dst-i>> + ] [ dst>> ] bi set-nth-unsafe ] 2bi ; inline
: (copy) ( n copy -- dst )
over 0 <= [ nip dst>> ] [ [ 1 - ] dip [ ((copy)) ] [ (copy) ] 2bi ] if ;
inline recursive inline recursive
: prepare-subseq ( from to seq -- dst i src j n ) : subseq>copy ( from to seq -- n copy )
[ over - ] dip [ over - check-length swap ] dip
[ new-sequence 0 rot ] 2keep 3dup nip new-sequence 0 swap <copy> ; inline
[ ] curry 2dip check-length ; inline
: check-copy ( src n dst -- ) : check-copy ( src n dst -- src n dst )
over 0 < [ bounds-error ] when 3dup over 0 < [ bounds-error ] when
[ swap length + ] dip lengthen ; inline [ swap length + ] dip lengthen ; inline
PRIVATE> PRIVATE>
: subseq ( from to seq -- subseq ) : subseq ( from to seq -- subseq )
[ check-slice prepare-subseq (copy) ] keep like ; [ check-slice subseq>copy (copy) ] keep like ;
: head ( seq n -- headseq ) (head) subseq ; : head ( seq n -- headseq ) (head) subseq ;
@ -309,8 +313,8 @@ PRIVATE>
: copy ( src i dst -- ) : copy ( src i dst -- )
#! The check-length call forces partial dispatch #! The check-length call forces partial dispatch
pick length check-length [ 3dup check-copy spin 0 ] dip [ [ length check-length 0 ] keep ] 2dip
(copy) drop ; inline check-copy <copy> (copy) drop ; inline
M: sequence clone-like M: sequence clone-like
[ dup length ] dip new-sequence [ 0 swap copy ] keep ; inline [ dup length ] dip new-sequence [ 0 swap copy ] keep ; inline