ivory-backend-c-0.1.0.7: Ivory C backend.

Safe HaskellNone
LanguageHaskell2010

Ivory.Compile.C.Gen

Description

Ivory backend targeting language-c-quote.

Synopsis

Documentation

compile :: Def a -> Compile Source #

Compile a top-level element.

compileStruct :: Visibility -> Struct -> Compile Source #

Compile a struct.

compileAreaImport :: AreaImport -> Compile Source #

Compile an external memory area reference.

extractAreaProto :: Visibility -> Area -> Compile Source #

Get prototypes for memory areas.

compileArea :: Visibility -> Area -> Compile Source #

Compile a memory area definition into an extern in the header, and a structure in the source.

compileUnit :: Proc -> Compile Source #

Compile a definition unit.

extractProto :: Visibility -> Proc -> Compile Source #

Get the prototypes.

toArgs :: [Typed Var] -> [Param] Source #

Argument conversion.

toTypeDecay :: Type -> Type Source #

Make C type, and decay array types into pointers (e.g., `x[2][3]` decays into `(*x)[3]`).

toType :: Type -> Type Source #

Make C type, but don't decay array types (default).

toType' :: Bool -> Type -> Type Source #

C type conversion, with a special case for references and pointers.

toName :: Name -> String Source #

Call Symbols

toVar :: Var -> String Source #

Variable name mangling.

toBody :: [Cond] -> Stmt -> [BlockItem] Source #

Translate statements.

typedRet :: Typed Expr -> Exp Source #

Return statement.

toExpr :: Type -> Expr -> Exp Source #

Translate an expression.

exp0 :: [Exp] -> Exp Source #

exp1 :: [Exp] -> Exp Source #

exp2 :: [Exp] -> Exp Source #

mkArgs :: Type -> [Expr] -> [Exp] Source #

toExpOp :: Type -> ExpOp -> [Expr] -> Exp Source #

toMod :: Type -> [Expr] -> Exp Source #

absSym :: Type -> String Source #

Emit the function name for a call to abs. This doesn't include any symbol for unsigned things, as they should be optimized out by the front end.

signumSym :: Type -> String Source #

Emit the function name for a call to signum.

toEnsure :: Expr -> Cond -> BlockItem Source #

Takes the return expression, the condition, and returns a BlockItem.