mirror of https://github.com/zachjs/sv2v.git
restore positive Decimal invariant
This commit is contained in:
parent
52575560ef
commit
57d6d2e9e8
|
|
@ -23,7 +23,7 @@ convert = map $ traverseDescriptions traverseDescription
|
|||
elaborationFatalIdent :: Identifier
|
||||
elaborationFatalIdent = "_sv2v_elaboration_fatal"
|
||||
elaborationFatalCancelCode :: Expr
|
||||
elaborationFatalCancelCode = RawNum (-1)
|
||||
elaborationFatalCancelCode = UniOp UniSub $ RawNum 1
|
||||
|
||||
-- Checker for fatal elaboration
|
||||
elaborationFatalDecl :: ModuleItem
|
||||
|
|
|
|||
|
|
@ -322,7 +322,7 @@ numberBitLength (Based size _ _ _ _) =
|
|||
then max 32 $ negate size
|
||||
else size
|
||||
|
||||
-- get whether or not a number is sized
|
||||
-- get whether or not a number is signed
|
||||
numberIsSized :: Number -> Bool
|
||||
numberIsSized UnbasedUnsized{} = False
|
||||
numberIsSized (Decimal size _ _) = size > 0
|
||||
|
|
@ -359,7 +359,9 @@ instance Show Number where
|
|||
show (UnbasedUnsized bit) =
|
||||
'\'' : show bit
|
||||
show (Decimal (-32) True value) =
|
||||
show value
|
||||
if value < 0
|
||||
then error $ "illegal decimal: " ++ show value
|
||||
else show value
|
||||
show (Decimal size signed value) =
|
||||
if size == 0
|
||||
then error $ "illegal decimal literal: "
|
||||
|
|
|
|||
Loading…
Reference in New Issue