feldspar-compiler-0.6.0.2: Compiler for the Feldspar language

Safe Haskell | None

Feldspar.Compiler.Imperative.Frontend

Contents

- Frontend data types
- Conversion between representation and frontend

Synopsis

- data Mod = Mod [Ent]
- data Ent
  - = StructD String [(String, Type)]
  - | ProcDf String [Var] [Var] Prog
  - | ProcDcl String [Var] [Var]
- data Type
  - = Void
  - | Boolean
  - | Bit
  - | Floating
  - | I8
  - | I16
  - | I32
  - | I40
  - | I64
  - | U8
  - | U16
  - | U32
  - | U40
  - | U64
  - | Complex Type
  - | UserType String
  - | Array Type
  - | SizedArray Int Type
  - | Struct [(String, Type)]
  - | IVar Type
- data Expr
  - = Var Type String
  - | Ptr Type String
  - | Tr
  - | Fl
  - | LitI Type Integer
  - | LitF Double
  - | LitC Expr Expr
  - | Expr :!: Expr
  - | Expr :.: String
  - | Binop Type String [Expr]
  - | Fun Type String [Expr]
  - | Cast Type Expr
  - | SizeofE Expr
  - | SizeofT Type
- data Prog
  - = Skip
  - | BComment String
  - | Comment String
  - | Expr := Expr
  - | Call String [Param]
  - | Seq [Prog]
  - | If Expr Prog Prog
  - | While Prog Expr Prog
  - | For String Expr Int Prog
  - | Block [Def] Prog
- data Param
  - = In Expr
  - | Out Expr
  - | TypAuto Type
  - | TypScalar Type
  - | Fn String
  - | FnAddr String
- data Block = Bl [Def] Prog
- data Def
  - = Init Type String Expr
  - | Def Type String
- data Var
  - = Variable Type String
  - | Pointer Type String
- class Named a where
  - getName :: a -> String
- class Interface t where
  - type Repr t
  - toInterface :: Repr t -> t
  - fromInterface :: t -> Repr t
- toBlock :: Prog -> Block ()
- toProg :: Block () -> Prog
- boolToExpr :: Bool -> Expr
- setLength :: Expr -> Expr -> Prog
- copyProg :: Expr -> Expr -> Prog
- copyProgPos :: Expr -> Expr -> Expr -> Prog
- copyProgLen :: Expr -> Expr -> Expr -> Prog
- initArray :: Expr -> Expr -> Prog
- assignProg :: Expr -> Expr -> Prog
- freeArray :: Var -> Prog
- arrayLength :: Expr -> Expr
- iVarInit :: Expr -> Prog
- iVarGet :: Expr -> Expr -> Prog
- iVarPut :: Expr -> Expr -> Prog
- spawn :: String -> [Var] -> Prog
- run :: String -> [Var] -> Prog
- intWidth :: Type -> Maybe Integer
- intSigned :: Type -> Maybe Bool
- litB :: Bool -> Expr
- isArray :: Type -> Bool
- vType :: Var -> Type
- vName :: Var -> String
- lName :: Expr -> String
- varToExpr :: Var -> Expr

# Frontend data types

data Mod

Constructors

Mod [Ent] |

Instances

Show Mod |
Interface Mod |

data Ent

Constructors

StructD String [(String, Type)] |
ProcDf String [Var] [Var] Prog |
ProcDcl String [Var] [Var] |

Instances

Eq Ent |
Show Ent |
Interface Ent |

data Type

Constructors

Void |
Boolean |
Bit |
Floating |
I8 |
I16 |
I32 |
I40 |
I64 |
U8 |
U16 |
U32 |
U40 |
U64 |
Complex Type |
UserType String |
Array Type |
SizedArray Int Type |
Struct [(String, Type)] |
IVar Type |

Instances

Eq Type |
Show Type |
Interface Type |

data Expr

Constructors

Var Type String |
Ptr Type String |
Tr |
Fl |
LitI Type Integer |
LitF Double |
LitC Expr Expr |
Expr :!: Expr |
Expr :.: String |
Binop Type String [Expr] |
Fun Type String [Expr] |
Cast Type Expr |
SizeofE Expr |
SizeofT Type |

Instances

Eq Expr |
Show Expr |
HasType Expr |
Interface Expr |

data Prog

Constructors

Skip |
BComment String |
Comment String |
Expr := Expr |
Call String [Param] |
Seq [Prog] |
If Expr Prog Prog |
While Prog Expr Prog |
For String Expr Int Prog |
Block [Def] Prog |

Instances

Eq Prog |
Show Prog |
Monoid Prog |
Interface Prog |

data Param

Constructors

In Expr |
Out Expr |
TypAuto Type |
TypScalar Type |
Fn String |
FnAddr String |

Instances

Eq Param |
Show Param |
Interface Param |

data Block

Constructors

Bl [Def] Prog |

Instances

Eq Block |
Show Block |
Monoid Block |
Interface Block |

data Def

Constructors

Init Type String Expr |
Def Type String |

Instances

Eq Def |
Show Def |
Interface Def |
Named Def |

data Var

Constructors

Variable Type String |
Pointer Type String |

Instances

Eq Var |
Show Var |
Combine Collection |
Default Collection |
HasType Var |
Interface Var |
Named Var |

class Named a where

Methods

getName :: a -> String

Instances

Named Var |
Named Def |

# Conversion between representation and frontend

class Interface t where

Associated Types

type Repr t

Methods

toInterface :: Repr t -> t

fromInterface :: t -> Repr t

Instances

Interface Var |
Interface Def |
Interface Block |
Interface Param |
Interface Prog |
Interface Expr |
Interface Type |
Interface Ent |
Interface Mod |

toBlock :: Prog -> Block ()

toProg :: Block () -> Prog

boolToExpr :: Bool -> Expr

setLength :: Expr -> Expr -> Prog

copyProg :: Expr -> Expr -> Prog

copyProgPos :: Expr -> Expr -> Expr -> Prog

copyProgLen :: Expr -> Expr -> Expr -> Prog

initArray :: Expr -> Expr -> Prog

assignProg :: Expr -> Expr -> Prog

freeArray :: Var -> Prog

arrayLength :: Expr -> Expr

iVarInit :: Expr -> Prog

iVarGet :: Expr -> Expr -> Prog

iVarPut :: Expr -> Expr -> Prog

spawn :: String -> [Var] -> Prog

run :: String -> [Var] -> Prog

intWidth :: Type -> Maybe Integer

intSigned :: Type -> Maybe Bool

litB :: Bool -> Expr

isArray :: Type -> Bool

vType :: Var -> Type

vName :: Var -> String

lName :: Expr -> String

varToExpr :: Var -> Expr