@@ -43,6 +43,7 @@ package Prelude(
43
43
sameFamily , isAncestor ,
44
44
chkClockDomain ,
45
45
46
+ isStaticValue ,
46
47
impCondOf ,
47
48
48
49
primZeroExt , primSignExt , primTrunc ,
@@ -1259,9 +1260,6 @@ replaceBit pos w i b =
1259
1260
data Bool = False | True
1260
1261
deriving (Eq , Bits , Bounded , FShow , DefaultValue )
1261
1262
1262
- isStaticBool :: Bool -> Bool
1263
- isStaticBool = compose areStaticBits pack
1264
-
1265
1263
--@ \begin{libverbatim}
1266
1264
--@ function Bool not(Bool x);
1267
1265
--@ \end{libverbatim}
@@ -2850,6 +2848,9 @@ primitive primAreStaticBits :: Bit n -> Bit 1
2850
2848
areStaticBits :: Bit n -> Bool
2851
2849
areStaticBits = compose primChr primAreStaticBits
2852
2850
2851
+ isStaticValue :: (Bits a n ) => a -> Bool
2852
+ isStaticValue = areStaticBits ∘ pack
2853
+
2853
2854
-- these are elaboration-time-only conversions
2854
2855
-- primAreStaticBits should be called first
2855
2856
primitive primUIntBitsToInteger :: Bit n -> Integer
@@ -3482,7 +3483,7 @@ listStaticSelect pos xs n =
3482
3483
listPrimSelect' Nil _ n0 =
3483
3484
let b = n0 < 0 || listNullOrUndef (listDrop n0 xs)
3484
3485
-- don't raise an error unless we can prove we are out-of-bounds
3485
- in if (isStaticBool b) && b then
3486
+ in if (isStaticValue b) && b then
3486
3487
primError pos $ listMessage n0 " list selection"
3487
3488
else primBuildUndefined pos iuDontCare -- should add runtime error here
3488
3489
listPrimSelect' (Cons x _) 0 _ = x
@@ -3518,7 +3519,7 @@ listPrimUpdate pos l k x =
3518
3519
primGenerateError 78 pos " Attempt to update an undetermined list"
3519
3520
else if (isRawUndefined k) then
3520
3521
primGenerateError 79 pos " Attempt to update a list at an undetermined position"
3521
- else if ((isStaticIndex k) && (k' < 0 || (isStaticBool b && b)))
3522
+ else if ((isStaticIndex k) && (k' < 0 || (isStaticValue b && b)))
3522
3523
then primError pos $ listMessage k' " list updating"
3523
3524
else listPrimMap (\ p -> if (rangeTest p.snd) && (k == fromInteger p.snd) then x else p.fst)
3524
3525
(listPrimNum l)
@@ -3597,7 +3598,7 @@ instance PrimSelectable (Array a) a
3597
3598
if (isStaticIndex x) then
3598
3599
letseq i = toStaticIndex x
3599
3600
b = i >= primArrayLength v
3600
- in if (isStaticBool b && b) || (i < 0 ) then
3601
+ in if (isStaticValue b && b) || (i < 0 ) then
3601
3602
primError pos (listMessage i " array selection" )
3602
3603
else primArraySelect v i
3603
3604
else primArrayDynSelect v (toDynamicIndex x)
@@ -3618,7 +3619,7 @@ instance PrimUpdateable (Array a) a
3618
3619
else if (isStaticIndex x) then
3619
3620
letseq i = toStaticIndex x
3620
3621
b = i >= primArrayLength v
3621
- in if (isStaticBool b && b) || (i < 0 ) then
3622
+ in if (isStaticValue b && b) || (i < 0 ) then
3622
3623
primError pos (listMessage i " array update" )
3623
3624
else primArrayUpdate v i n
3624
3625
else primArrayDynUpdate v (toDynamicIndex x) n
0 commit comments