packages feed

copilot-c99 3.6 → 3.7

raw patch · 4 files changed

+37/−23 lines, 4 filesdep ~copilot-corePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: copilot-core

API changes (from Hackage documentation)

Files

CHANGELOG view
@@ -1,3 +1,8 @@+2022-01-07+        * Version bump (3.7). (#287)+        * Guard against empty specs. (#274)+        * Make typetypes respect dependency order. (#275)+ 2021-11-07         * Version bump (3.6). (#264)         * Introduce new ops atan2, ceiling, floor. (#246)
copilot-c99.cabal view
@@ -1,6 +1,6 @@ cabal-version             : >= 1.10 name                      : copilot-c99-version                   : 3.6+version                   : 3.7 synopsis                  : A compiler for Copilot targeting C99. description               :   This package is a back-end from Copilot to C.@@ -48,7 +48,7 @@                           , mtl                 >= 2.2 && < 2.3                           , pretty              >= 1.1 && < 1.2 -                          , copilot-core        >= 3.6   && < 3.7+                          , copilot-core        >= 3.7   && < 3.8                           , language-c99        >= 0.1.1 && < 0.2                           , language-c99-util   >= 0.1.1 && < 0.2                           , language-c99-simple >= 0.1.1 && < 0.2
src/Copilot/Compile/C99/CodeGen.hs view
@@ -165,8 +165,8 @@ -- | List all types of a type, returns items uniquely. typetypes :: Typeable a => Type a -> [UType] typetypes ty = case ty of-  Array ty' -> [UType ty] `union` typetypes ty'-  Struct x  -> [UType ty] `union` map (\(Value ty' _) -> UType ty') (toValues x)+  Array ty' -> typetypes ty' `union` [UType ty]+  Struct x  -> concatMap (\(Value ty' _) -> typetypes ty') (toValues x) `union` [UType ty]   _         -> [UType ty]  -- | Collect all expression of a list of streams and triggers and wrap them
src/Copilot/Compile/C99/Compile/Internal.hs view
@@ -8,7 +8,9 @@ import Data.List            (nub) import Data.Maybe           (catMaybes) import System.Directory     (createDirectoryIfMissing)+import System.Exit          (exitFailure) import System.FilePath      ((</>))+import System.IO            (hPutStrLn, stderr)  import Language.C99.Pretty  (pretty) import qualified Language.C99.Simple as C@@ -26,27 +28,34 @@ -- -- The second argument is used as prefix for the .h and .c files generated. compileWith :: CSettings -> String -> Spec -> IO ()-compileWith cSettings prefix spec = do-  let cfile = render $ pretty $ C.translate $ compilec cSettings spec-      hfile = render $ pretty $ C.translate $ compileh cSettings spec+compileWith cSettings prefix spec+  | null (specTriggers spec)+  = do hPutStrLn stderr $+         "Copilot error: attempt at compiling empty specification.\n"+         ++ "You must define at least one trigger to generate C monitors."+       exitFailure -      -- TODO: find a nicer solution using annotated AST's-      -- Should figure out exactly which headers are needed, based on what-      -- is used.-      cmacros = unlines [ "#include <stdint.h>"-                        , "#include <stdbool.h>"-                        , "#include <string.h>"-                        , "#include <stdlib.h>"-                        , "#include <math.h>"-                        , ""-                        , "#include \"" ++ prefix ++ ".h\""-                        , ""-                        ]+  | otherwise+  = do let cfile = render $ pretty $ C.translate $ compilec cSettings spec+           hfile = render $ pretty $ C.translate $ compileh cSettings spec -  let dir = cSettingsOutputDirectory cSettings-  createDirectoryIfMissing True dir-  writeFile (dir </> prefix ++ ".c") $ cmacros ++ cfile-  writeFile (dir </> prefix ++ ".h") hfile+           -- TODO: find a nicer solution using annotated AST's+           -- Should figure out exactly which headers are needed, based on what+           -- is used.+           cmacros = unlines [ "#include <stdint.h>"+                             , "#include <stdbool.h>"+                             , "#include <string.h>"+                             , "#include <stdlib.h>"+                             , "#include <math.h>"+                             , ""+                             , "#include \"" ++ prefix ++ ".h\""+                             , ""+                             ]++       let dir = cSettingsOutputDirectory cSettings+       createDirectoryIfMissing True dir+       writeFile (dir </> prefix ++ ".c") $ cmacros ++ cfile+       writeFile (dir </> prefix ++ ".h") hfile  -- | Compile a specification to a .h and a .c file. --