using if-zero in even more places.

db4
John Benediktsson 2012-07-16 19:38:49 -07:00
parent b9900248b7
commit 2f325e4fee
5 changed files with 20 additions and 22 deletions

View File

@ -38,10 +38,10 @@ HOOK: reserved-stack-space cpu ( -- n )
: spill@ ( n -- op ) spill-offset special-offset stack@ ; : spill@ ( n -- op ) spill-offset special-offset stack@ ;
: decr-stack-reg ( n -- ) : decr-stack-reg ( n -- )
dup 0 = [ drop ] [ stack-reg swap SUB ] if ; [ stack-reg swap SUB ] unless-zero ;
: incr-stack-reg ( n -- ) : incr-stack-reg ( n -- )
dup 0 = [ drop ] [ stack-reg swap ADD ] if ; [ stack-reg swap ADD ] unless-zero ;
: align-stack ( n -- n' ) 16 align ; : align-stack ( n -- n' ) 16 align ;
@ -61,7 +61,7 @@ M: x86 test-instruction? t ;
M: x86 immediate-store? immediate-comparand? ; M: x86 immediate-store? immediate-comparand? ;
M: x86 %load-immediate dup 0 = [ drop dup XOR ] [ MOV ] if ; M: x86 %load-immediate [ dup XOR ] [ MOV ] if-zero ;
M: x86 %load-reference M: x86 %load-reference
[ swap 0 MOV rc-absolute-cell rel-literal ] [ swap 0 MOV rc-absolute-cell rel-literal ]

View File

@ -1,7 +1,7 @@
! Copyright (C) 2008 Slava Pestov. ! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien.c-types alien.data alien.strings USING: accessors alien.c-types alien.data alien.strings
combinators continuations destructors fry io io.backend assocs combinators continuations destructors fry io io.backend
io.directories io.encodings.binary io.files.info.unix io.directories io.encodings.binary io.files.info.unix
io.encodings.utf8 io.files io.pathnames io.files.types kernel io.encodings.utf8 io.files io.pathnames io.files.types kernel
math.bitwise sequences system unix unix.stat vocabs.loader math.bitwise sequences system unix unix.stat vocabs.loader
@ -48,17 +48,16 @@ M: unix find-next-file ( DIR* -- byte-array )
void* deref [ drop f ] unless ; void* deref [ drop f ] unless ;
: dirent-type>file-type ( ch -- type ) : dirent-type>file-type ( ch -- type )
{ H{
{ DT_BLK [ +block-device+ ] } { $ DT_BLK +block-device+ }
{ DT_CHR [ +character-device+ ] } { $ DT_CHR +character-device+ }
{ DT_DIR [ +directory+ ] } { $ DT_DIR +directory+ }
{ DT_LNK [ +symbolic-link+ ] } { $ DT_LNK +symbolic-link+ }
{ DT_SOCK [ +socket+ ] } { $ DT_SOCK +socket+ }
{ DT_FIFO [ +fifo+ ] } { $ DT_FIFO +fifo+ }
{ DT_REG [ +regular-file+ ] } { $ DT_REG +regular-file+ }
{ DT_WHT [ +whiteout+ ] } { $ DT_WHT +whiteout+ }
[ drop +unknown+ ] } at* [ drop +unknown+ ] unless ;
} case ;
M: unix >directory-entry ( byte-array -- directory-entry ) M: unix >directory-entry ( byte-array -- directory-entry )
{ {

View File

@ -159,8 +159,7 @@ M: process-failed error.
] [ process>> . ] bi ; ] [ process>> . ] bi ;
: wait-for-success ( process -- ) : wait-for-success ( process -- )
dup wait-for-process 0 = dup wait-for-process [ drop ] [ process-failed ] if-zero ;
[ drop ] [ process-failed ] if ;
: try-process ( desc -- ) : try-process ( desc -- )
run-process wait-for-success ; run-process wait-for-success ;

View File

@ -18,7 +18,7 @@ ERROR: bad-length bytes n ;
1 - 8 * 0 swap 8 <range> ; inline 1 - 8 * 0 swap 8 <range> ; inline
: reassemble-bytes ( range -- quot ) : reassemble-bytes ( range -- quot )
[ dup 0 = [ drop [ ] ] [ '[ _ shift ] ] if ] map [ [ [ ] ] [ '[ _ shift ] ] if-zero ] map
'[ [ _ spread ] [ bitor ] reduce-outputs ] ; inline '[ [ _ spread ] [ bitor ] reduce-outputs ] ; inline
MACRO: reassemble-be ( n -- quot ) be-range reassemble-bytes ; MACRO: reassemble-be ( n -- quot ) be-range reassemble-bytes ;

View File

@ -51,9 +51,9 @@ SYMBOL: and-needed?
: tens-place ( n -- str ) : tens-place ( n -- str )
100 mod dup 20 >= [ 100 mod dup 20 >= [
10 /mod [ tens ] dip 10 /mod [ tens ] dip
dup 0 = [ drop ] [ small-numbers "-" glue ] if [ small-numbers "-" glue ] unless-zero
] [ ] [
dup 0 = [ drop "" ] [ small-numbers ] if [ "" ] [ small-numbers ] if-zero
] if ; ] if ;
: 3digits>text ( n -- str ) : 3digits>text ( n -- str )