aboutsummaryrefslogtreecommitdiff
path: root/frontend/containers.icl
diff options
context:
space:
mode:
authorjohnvg2001-09-06 15:30:01 +0000
committerjohnvg2001-09-06 15:30:01 +0000
commitd27143250ac87f53b0083a3a1cc3fb2190fb0015 (patch)
tree49d48418e4315d0da58d354ff2074862fff8ddd5 /frontend/containers.icl
parentadded command line flag to enable generics (diff)
remove 'dcl_is_cashed'
git-svn-id: https://svn.cs.ru.nl/repos/clean-compiler/trunk@758 1f8540f1-abd5-4d5b-9d24-4c5ce8603e2d
Diffstat (limited to 'frontend/containers.icl')
-rw-r--r--frontend/containers.icl18
1 files changed, 15 insertions, 3 deletions
diff --git a/frontend/containers.icl b/frontend/containers.icl
index 1056c3f..13f0fe1 100644
--- a/frontend/containers.icl
+++ b/frontend/containers.icl
@@ -127,6 +127,10 @@ BITNUMBER index :== index bitand 31
:: LargeBitvect :== {#Int}
+bitvectCreate :: !Int -> .LargeBitvect
+bitvectCreate 0 = {}
+bitvectCreate n_elements = createArray ((BITINDEX (n_elements-1)+1)) 0
+
bitvectSelect :: !Int !LargeBitvect -> Bool
bitvectSelect index a
= a.[BITINDEX index] bitand (1 << BITNUMBER index) <> 0
@@ -143,9 +147,17 @@ bitvectReset index a
a_bit_index = a.[bit_index]
= { a & [bit_index] = a_bit_index bitand (bitnot (1 << BITNUMBER index))}
-bitvectCreate :: !Int -> .LargeBitvect
-bitvectCreate 0 = {}
-bitvectCreate n_elements = createArray ((BITINDEX (n_elements-1)+1)) 0
+bitvectSetFirstN :: !Int !*LargeBitvect -> .LargeBitvect
+bitvectSetFirstN n_bits a
+ = set_bits 0 n_bits a
+ where
+ set_bits index n_bits a
+ | n_bits<=0
+ = a
+ | n_bits<32
+ # (a_index,a) = a![index]
+ = {a & [index]=a_index bitor (bitnot ((-1)<<n_bits))}
+ = set_bits (index+1) (n_bits-32) {a & [index]= -1}
bitvectResetAll :: !*LargeBitvect -> .LargeBitvect
bitvectResetAll arr