copilot-c99 3.1 → 3.1.1
raw patch · 4 files changed
+12/−9 lines, 4 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Copilot.Compile.C99.CodeGen: mkinit :: Type a -> a -> Init
Files
- CHANGELOG +4/−0
- copilot-c99.cabal +1/−1
- src/Copilot/Compile/C99/CodeGen.hs +1/−8
- src/Copilot/Compile/C99/Translate.hs +6/−0
CHANGELOG view
@@ -1,3 +1,7 @@+2019-12-23 Frank Dedden <dev@dedden.net>+ * Version bump (3.1.1).+ * Fixed bug with constant structs and arrays.(#13).+ 2019-11-22 Ivan Perez <ivan.perez@nianet.org> * Version bump (3.1). * Remove ExternFun (#6).
copilot-c99.cabal view
@@ -1,6 +1,6 @@ cabal-version : >= 1.10 name : copilot-c99-version : 3.1+version : 3.1.1 synopsis : A compiler for Copilot targeting C99. description : This package is a back-end from Copilot to C.
src/Copilot/Compile/C99/CodeGen.hs view
@@ -43,7 +43,7 @@ name = streamname sid cty = C.Array (transtype ty) (Just $ C.LitInt $ fromIntegral buffsize) buffsize = length xs- initvals = Just $ C.InitArray $ map (mkinit ty) xs+ initvals = Just $ C.InitArray $ map (C.InitExpr . constty ty) xs -- | Make a C index variable and initialise it to 0. mkindexdecln :: Id -> C.Decln@@ -51,13 +51,6 @@ name = indexname sid cty = C.TypeSpec $ C.TypedefName "size_t" initval = Just $ C.InitExpr $ C.LitInt 0---- | Make an initial declaration from a single value.-mkinit :: Type a -> a -> C.Init-mkinit (Array ty') xs = C.InitArray $ map (mkinit ty') (arrayelems xs)-mkinit (Struct _) x = C.InitArray $ map fieldinit (toValues x) where- fieldinit (Value ty (Field val)) = mkinit ty val-mkinit ty x = C.InitExpr $ constty ty x -- | The step function updates all streams,a mkstep :: [Stream] -> [Trigger] -> [External] -> C.FunDef
src/Copilot/Compile/C99/Translate.hs view
@@ -122,6 +122,12 @@ Word64 -> C.LitInt . fromIntegral Float -> C.LitFloat Double -> C.LitDouble+ Struct _ -> \v -> C.InitVal (transtypename ty) (map fieldinit (toValues v))+ where+ fieldinit (Value ty (Field val)) = C.InitExpr $ constty ty val+ Array ty' -> \v -> C.InitVal (transtypename ty) (map valinit (arrayelems v))+ where+ valinit = C.InitExpr . constty ty' -- | Translate a Copilot type to a C99 type. transtype :: Type a -> C.Type