Skip to content

Commit

Permalink
Render numbers inside gensym
Browse files Browse the repository at this point in the history
This allows things like

:: SSymbol foo
-> SNat n

~GENSYM[~LIT[0]_~LIT[1]][0] to append numbers to strings inside
a GENSYM.
  • Loading branch information
christiaanb committed Sep 24, 2019
1 parent 7ef39bd commit bc76f0f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions clash-lib/src/Clash/Netlist/BlackBox/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,13 @@ setSym mkUniqueIdentifierM bbCtx l = do
error $ $(curLoc) ++ "Could not convert "
++ "~NAME[" ++ show i ++ "]"
++ " to string:" ++ msg
; Lit i -> case elementToText bbCtx (Lit i) of
Right t ->
t
Left msg ->
error $ $(curLoc) ++ "Could not convert "
++ "~LIT[" ++ show i ++ "]"
++ " to string:" ++ msg
; Result _ | Identifier t _ <- fst (bbResult bbCtx)
-> Text.fromStrict t
; CompName -> Text.fromStrict (bbCompName bbCtx)
Expand Down Expand Up @@ -708,6 +715,7 @@ elementToText _bbCtx e = error $ "Unexpected string like: " ++ show e
exprToString
:: Expr
-> Maybe String
exprToString (Literal _ (NumLit i)) = Just (show i)
exprToString (Literal _ (StringLit l)) = Just l
exprToString (BlackBoxE "Clash.Promoted.Symbol.SSymbol" _ _ _ _ ctx _) =
let (e',_,_) = head (bbInputs ctx)
Expand Down

0 comments on commit bc76f0f

Please sign in to comment.