no locals in bit-arrays
parent
c2e6ef0366
commit
cf99c7afd1
|
@ -1,7 +1,7 @@
|
||||||
! Copyright (C) 2007, 2008 Slava Pestov.
|
! Copyright (C) 2007, 2008 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: alien.c-types accessors math alien.accessors kernel
|
USING: alien.c-types accessors math alien.accessors kernel
|
||||||
kernel.private locals sequences sequences.private byte-arrays
|
kernel.private sequences sequences.private byte-arrays
|
||||||
parser prettyprint.custom fry ;
|
parser prettyprint.custom fry ;
|
||||||
IN: bit-arrays
|
IN: bit-arrays
|
||||||
|
|
||||||
|
@ -70,16 +70,15 @@ M: bit-array byte-length length 7 + -3 shift ;
|
||||||
|
|
||||||
: ?{ \ } [ >bit-array ] parse-literal ; parsing
|
: ?{ \ } [ >bit-array ] parse-literal ; parsing
|
||||||
|
|
||||||
:: integer>bit-array ( n -- bit-array )
|
: integer>bit-array ( n -- bit-array )
|
||||||
n zero? [ 0 <bit-array> ] [
|
dup 0 = [
|
||||||
[let | out [ n log2 1+ <bit-array> ] i! [ 0 ] n'! [ n ] |
|
<bit-array>
|
||||||
[ n' zero? ] [
|
] [
|
||||||
n' out underlying>> i set-alien-unsigned-1
|
[ log2 1+ <bit-array> 0 ] keep
|
||||||
n' -8 shift n'!
|
[ dup 0 = ] [
|
||||||
i 1+ i!
|
[ pick underlying>> pick set-alien-unsigned-1 ] keep
|
||||||
] [ ] until
|
[ 1+ ] [ -8 shift ] bi*
|
||||||
out
|
] [ ] until 2drop
|
||||||
]
|
|
||||||
] if ;
|
] if ;
|
||||||
|
|
||||||
: bit-array>integer ( bit-array -- n )
|
: bit-array>integer ( bit-array -- n )
|
||||||
|
|
Loading…
Reference in New Issue