generalize the 'zero' operation

This commit is contained in:
Rob Dockins 2016-05-15 22:34:06 -07:00
parent da4a458aed
commit 1b51f0edf4

View File

@ -473,17 +473,20 @@ funCmp op =
-- Logic ----------------------------------------------------------------------- -- Logic -----------------------------------------------------------------------
zeroV :: TValue -> Value zeroV :: forall b w
. BitWord b w
=> TValue
-> GenValue b w
zeroV ty zeroV ty
-- bits -- bits
| isTBit ty = | isTBit ty =
VBit False VBit (bitLit False)
-- sequences -- sequences
| Just (n,ety) <- isTSeq ty = | Just (n,ety) <- isTSeq ty =
case numTValue n of case numTValue n of
Nat w | isTBit ety -> word w 0 Nat w | isTBit ety -> VWord $ wordLit w 0
| otherwise -> mkSeq n ety (SeqMap $ \_ -> ready $ zeroV ety) | otherwise -> mkSeq n ety (SeqMap $ \_ -> ready $ zeroV ety)
Inf -> mkSeq n ety (SeqMap $ \_ -> ready $ zeroV ety) Inf -> mkSeq n ety (SeqMap $ \_ -> ready $ zeroV ety)