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

db4
John Benediktsson 2009-03-16 07:22:35 -07:00
commit c79a689c59
9 changed files with 35 additions and 44 deletions

View File

@ -83,14 +83,15 @@ ERROR: bmp-not-supported n ;
:: fixup-color-index ( loading-bitmap -- loading-bitmap )
loading-bitmap width>> :> width
width 3 * :> width*3
loading-bitmap height>> abs :> height
loading-bitmap color-index>> length :> color-index-length
height 3 * :> height*3
color-index-length width height*3 * - height*3 /i :> misaligned
misaligned 0 > [
color-index-length height /i :> stride
color-index-length width*3 height * - height /i :> padding
padding 0 > [
loading-bitmap [
loading-bitmap width>> misaligned + 3 * <sliced-groups>
[ 3 misaligned * head* ] map concat
stride <sliced-groups>
[ width*3 head-slice ] map concat
] change-color-index
] [
loading-bitmap

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

View File

@ -477,26 +477,24 @@ ERROR: unknown-component-order ifd ;
[ unknown-component-order ]
} case ;
: normalize-alpha-data ( seq -- byte-array )
! [ normalize-alpha-data ] change-bitmap
B{ } like dup
byte-array>float-array
4 <sliced-groups>
[
dup fourth dup 0 = [
2drop
] [
[ 3 head-slice ] dip '[ _ / ] change-each
] if
] each ;
: handle-alpha-data ( ifd -- ifd )
dup extra-samples find-tag {
{ extra-samples-associated-alpha-data [
[
B{ } like dup
byte-array>float-array
4 <sliced-groups>
[
dup fourth dup 0 = [
2drop
] [
[ 3 head-slice ] dip '[ _ / ] change-each
] if
] each
] change-bitmap
] }
{ extra-samples-unspecified-alpha-data [
] }
{ extra-samples-unassociated-alpha-data [
] }
{ extra-samples-associated-alpha-data [ ] }
{ extra-samples-unspecified-alpha-data [ ] }
{ extra-samples-unassociated-alpha-data [ ] }
[ bad-extra-samples ]
} case ;

View File

@ -104,13 +104,11 @@ C: <box> box
transitions>quot ;
: states>code ( words dfa -- )
[
'[
dup _ word>quot
(( last-match index string -- ? ))
define-declared
] each
] with-compilation-unit ;
'[
dup _ word>quot
(( last-match index string -- ? ))
define-declared
] each ;
: states>words ( dfa -- words dfa )
dup transitions>> keys [ gensym ] H{ } map>assoc
@ -123,12 +121,9 @@ C: <box> box
PRIVATE>
: simple-define-temp ( quot effect -- word )
[ define-temp ] with-compilation-unit ;
: dfa>word ( dfa -- quot )
dfa>main-word execution-quot '[ drop [ f ] 2dip @ ]
(( start-index string regexp -- i/f )) simple-define-temp ;
(( start-index string regexp -- i/f )) define-temp ;
: dfa>shortest-word ( dfa -- word )
t shortest? [ dfa>word ] with-variable ;

View File

@ -4,7 +4,7 @@ USING: accessors combinators kernel kernel.private math sequences
sequences.private strings sets assocs prettyprint.backend
prettyprint.custom make lexer namespaces parser arrays fry locals
regexp.parser splitting sorting regexp.ast regexp.negation
regexp.compiler words call call.private math.ranges ;
regexp.compiler compiler.units words call call.private math.ranges ;
IN: regexp
TUPLE: regexp
@ -35,7 +35,7 @@ M: lookbehind question>quot ! Returns ( index string -- ? )
: match-index-from ( i string regexp -- index/f )
! This word is unsafe. It assumes that i is a fixnum
! and that string is a string.
dup dfa>> execute-unsafe( index string regexp -- i/f ) ;
dup dfa>> execute-unsafe( index string regexp -- i/f ) ; inline
GENERIC: end/start ( string regexp -- end start )
M: regexp end/start drop length 0 ;
@ -129,31 +129,28 @@ PRIVATE>
GENERIC: compile-regexp ( regex -- regexp )
: regexp-initial-word ( i string regexp -- i/f )
compile-regexp match-index-from ;
[ compile-regexp ] with-compilation-unit match-index-from ;
: do-compile-regexp ( regexp -- regexp )
M: regexp compile-regexp ( regexp -- regexp )
dup '[
dup \ regexp-initial-word =
[ drop _ get-ast ast>dfa dfa>word ] when
] change-dfa ;
M: regexp compile-regexp ( regexp -- regexp )
do-compile-regexp ;
M: reverse-regexp compile-regexp ( regexp -- regexp )
t backwards? [ do-compile-regexp ] with-variable ;
t backwards? [ call-next-method ] with-variable ;
DEFER: compile-next-match
: next-initial-word ( i string regexp -- i start end string )
compile-next-match do-next-match ;
[ compile-next-match ] with-compilation-unit do-next-match ;
: compile-next-match ( regexp -- regexp )
dup '[
dup \ next-initial-word = [
drop _ [ compile-regexp dfa>> def>> ] [ reverse-regexp? ] bi
'[ { array-capacity string regexp } declare _ _ next-match ]
(( i string regexp -- i start end string )) simple-define-temp
(( i string regexp -- i start end string )) define-temp
] when
] change-next-match ;