feldspar-compiler-0.6.0.2: Compiler for the Feldspar language

Safe HaskellNone

Feldspar.Compiler.Imperative.FromCore.Interpretation

Contents

Synopsis

Documentation

type CodeWriter = RWS Readers Writers StatesSource

Code generation monad

data Readers Source

Constructors

Readers 

Fields

alias :: [(VarId, Expr)]

variable aliasing

sourceInfo :: SourceInfo

Surrounding source info

data Writers Source

Constructors

Writers 

Fields

block :: Block

collects code within one block

def :: [Ent]

collects top level definitions

Instances

type Task = [Prog]Source

data States Source

Constructors

States 

Fields

fresh :: Integer

The first fresh variable id

type Location = ExprSource

Where to place the program result

class Compile sub dom whereSource

A minimal complete instance has to define either compileProgSym or compileExprSym.

Methods

compileProgSym :: sub a -> Info (DenResult a) -> Location -> Args (AST (Decor Info dom)) a -> CodeWriter ()Source

compileExprSym :: sub a -> Info (DenResult a) -> Args (AST (Decor Info dom)) a -> CodeWriter ExprSource

Instances

Compile FeldDomain FeldDomain 
(Compile dom dom, Project (:|| Variable Type) dom) => Compile ParFeature dom 
(Compile dom dom, Project (CLambda Type) dom, Project (:|| Variable Type) dom) => Compile MutableToPure dom 
(Compile dom dom, Project (CLambda Type) dom) => Compile MutableReference dom 
(Compile dom dom, Project (CLambda Type) dom) => Compile MutableArray dom 
(Compile dom dom, Project (CLambda Type) dom) => Compile Mutable dom 
Compile Empty FeldDomain 
Compile dom dom => Compile Semantics dom

Converts symbols to primitive function calls

(Compile dom dom, Project (CLambda Type) dom) => Compile (MONAD Mut) dom 
(Compile dom dom, Project (CLambda Type) dom, Project ParFeature dom) => Compile (MONAD Par) dom 
(Compile dom dom, Project (CLambda Type) dom, Project (:|| Literal Type) dom, Project (:|| Variable Type) dom) => Compile (LoopM Mut) dom 
Compile dom dom => Compile (ConditionM m) dom 
Compile (CLambda Type) dom 
Compile dom dom => Compile (:|| Condition Type) dom 
(Compile dom dom, Project (CLambda Type) dom) => Compile (:|| Let Type) dom 
Compile (:|| Variable Type) dom 
Compile dom dom => Compile (:|| Select Type) dom 
Compile dom dom => Compile (:|| Tuple Type) dom 
Compile dom dom => Compile (:|| (Decor SourceInfo1 Identity) Type) dom 
Compile (:|| Literal Type) dom 
Compile dom dom => Compile (:|| PropSize Type) dom 
Compile dom dom => Compile (:|| Conversion Type) dom 
(Compile dom dom, Project (CLambda Type) dom, Project (:|| Literal Type) dom, Project (:|| Variable Type) dom) => Compile (:|| Loop Type) dom 
Compile dom dom => Compile (:|| FUTURE Type) dom 
(Compile dom dom, Project (CLambda Type) dom, Project (:|| Literal Type) dom, Project (:|| Variable Type) dom) => Compile (:|| Array Type) dom 
Compile dom dom => Compile (:|| Save Type) dom 
Compile dom dom => Compile (:|| FFI Type) dom 
Compile dom dom => Compile (:|| Trace Type) dom 
Compile dom dom => Compile (:|| NoInline Type) dom 
Compile dom dom => Compile (:|| INTEGRAL Type) dom 
Compile dom dom => Compile (:|| FRACTIONAL Type) dom 
Compile dom dom => Compile (:|| NUM Type) dom 
Compile dom dom => Compile (:|| FLOATING Type) dom 
Compile dom dom => Compile (:|| Error Type) dom 
Compile dom dom => Compile (:|| COMPLEX Type) dom 
Compile dom dom => Compile (:|| BITS Type) dom 
Compile dom dom => Compile (:|| Logic Type) dom 
Compile dom dom => Compile (:|| EQ Type) dom 
Compile dom dom => Compile (:|| ORD Type) dom 
(Compile sub1 dom, Compile sub2 dom) => Compile (:+: sub1 sub2) dom 

compileExprLoc :: Compile sub dom => sub a -> Info (DenResult a) -> Location -> Args (AST (Decor Info dom)) a -> CodeWriter ()Source

Implementation of compileExprSym that assigns an expression to the given location.

compileProgFresh :: Compile sub dom => sub a -> Info (DenResult a) -> Args (AST (Decor Info dom)) a -> CodeWriter ExprSource

Implementation of compileProgSym that generates code into a fresh variable.

compileProgDecor :: Compile dom dom => Location -> Decor Info dom a -> Args (AST (Decor Info dom)) a -> CodeWriter ()Source

compileProg :: Compile dom dom => Location -> ASTF (Decor Info dom) a -> CodeWriter ()Source

Utility functions

confiscateBlock :: CodeWriter a -> CodeWriter (a, Block)Source

Like listen, but also prevents the program from being written in the monad.