Skip to content

Commit

Permalink
IntLit combinators
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanGlScott committed Dec 19, 2022
1 parent a12f074 commit fc80f74
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/Language/Bluespec/Classic/AST/IntLit.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
-- This corresponds to src/comp/IntLit.hs in bsc.
module Language.Bluespec.Classic.AST.IntLit
( IntLit(..)
, ilDec
, ilSizedDec
, ilHex
, ilSizedHex
, ilBin
, ilSizedBin
) where

import Text.PrettyPrint.HughesPJClass
Expand Down Expand Up @@ -30,3 +36,21 @@ instance Show IntLit where

instance Pretty IntLit where
pPrintPrec _d _p i = text (show i)

ilDec :: Integer -> IntLit
ilDec i = IntLit { ilWidth = Nothing, ilBase = 10, ilValue = i }

ilSizedDec :: Integer -> Integer -> IntLit
ilSizedDec w i = IntLit { ilWidth = Just w, ilBase = 10, ilValue = i }

ilHex :: Integer -> IntLit
ilHex i = IntLit { ilWidth = Nothing, ilBase = 16, ilValue = i }

ilSizedHex :: Integer -> Integer -> IntLit
ilSizedHex w i = IntLit { ilWidth = Just w, ilBase = 16, ilValue = i }

ilBin :: Integer -> IntLit
ilBin i = IntLit { ilWidth = Nothing, ilBase = 2, ilValue = i }

ilSizedBin :: Integer -> Integer -> IntLit
ilSizedBin w i = IntLit { ilWidth = Just w, ilBase = 2, ilValue = i }

0 comments on commit fc80f74

Please sign in to comment.