-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A compiler for Copilot targeting C99. -- -- This package is a back-end from Copilot to C. -- -- Copilot is a stream (i.e., infinite lists) domain-specific language -- (DSL) in Haskell that compiles into embedded C. Copilot contains an -- interpreter, multiple back-end compilers, and other verification -- tools. A tutorial, bug reports, and todos are available at -- https://github.com/Copilot-Language/copilot-discussion. -- -- Examples are available at -- https://github.com/Copilot-Language/Copilot/tree/master/Examples. @package copilot-c99 @version 3.0 module Copilot.Compile.C99.Util type FunEnv = ([Decln], [Ident]) -- | tell equivalent for State. statetell :: Monoid m => m -> State m () -- | Generate fresh variable name based on a given one. fresh :: String -> [String] -> String -- | Collect all the names from a list of C99 declarations. names :: [Decln] -> [String] -- | Turn a stream id into a suitable C variable name. streamname :: Id -> String -- | Turn a stream id into the global varname for indices. indexname :: Id -> String -- | Add a postfix for copies of external variables the name. excpyname :: String -> String -- | Turn stream id into name of its generator function. generatorname :: Id -> String -- | Turn a the name of a trigger into a guard generator. guardname :: String -> String -- | Turn a trigger name into a an trigger argument name. argname :: String -> Int -> String -- | Enumerate all argument names based on trigger name. argnames :: String -> [String] funcall :: Ident -> [Expr] -> Expr module Copilot.Compile.C99.Translate -- | Translates a Copilot expression into a C99 expression. transexpr :: Expr a -> State FunEnv Expr -- | Translates a Copilot unary operator and arguments into a C99 -- expression. transop1 :: Op1 a b -> Expr -> Expr -- | Translates a Copilot binary operator and arguments into a C99 -- expression. transop2 :: Op2 a b c -> Expr -> Expr -> Expr -- | Translates a Copilot ternaty operator and arguments into a C99 -- expression. transop3 :: Op3 a b c d -> Expr -> Expr -> Expr -> Expr -- | Give a C99 literal expression based on a value and a type. constty :: Type a -> a -> Expr -- | Translate a Copilot type to a C99 type. transtype :: Type a -> Type -- | Translate a Copilot type intro a C typename transtypename :: Type a -> TypeName module Copilot.Compile.C99.External -- | Representation of external variables. data External External :: String -> String -> Type a -> External [extname] :: External -> String [extcpyname] :: External -> String [exttype] :: External -> Type a -- | Union over lists of External, we solely base the equality on the -- extname's. extunion :: [External] -> [External] -> [External] -- | Collect all external variables from the streams and triggers. gatherexts :: [Stream] -> [Trigger] -> [External] module Copilot.Compile.C99.CodeGen -- | Write a declaration for a generator function. gendecln :: String -> Type a -> Decln -- | Write a generator function for a stream. genfun :: String -> Expr a -> Type a -> FunDef -- | Make a extern declaration of an variable. mkextdecln :: External -> Decln -- | Make a declaration for a copy of an external variable. mkextcpydecln :: External -> Decln -- | Make a C buffer variable and initialise it with the stream buffer. mkbuffdecln :: Id -> Type a -> [a] -> Decln -- | Make a C index variable and initialise it to 0. mkindexdecln :: Id -> Decln -- | Make an initial declaration from a single value. mkinit :: Type a -> a -> Init -- | The step function updates all streams,a mkstep :: [Stream] -> [Trigger] -> [External] -> FunDef -- | Write a struct declaration based on its definition. mkstructdecln :: Struct a => Type a -> Decln -- | Write a forward struct decralration. mkstructforwdecln :: Struct a => Type a -> Decln -- | List all types of an expression, returns items uniquely. exprtypes :: Typeable a => Expr a -> [UType] -- | List all types of an type, returns items uniquely. typetypes :: Typeable a => Type a -> [UType] -- | Collect all expression of a list of streams and triggers and wrap them -- into an UEXpr. gatherexprs :: [Stream] -> [Trigger] -> [UExpr] module Copilot.Compile.C99.Compile -- | Compile the specification to a .h and a .c file. compile :: String -> Spec -> IO () module Copilot.Compile.C99 -- | Compile the specification to a .h and a .c file. compile :: String -> Spec -> IO ()