module Feldspar.Compiler.Imperative.FromCore.Primitive where
import Language.Syntactic
import Feldspar.Core.Types (Type)
import Feldspar.Core.Interpretation
import Feldspar.Core.Constructs.Bits
import Feldspar.Core.Constructs.Complex
import Feldspar.Core.Constructs.Conversion
import Feldspar.Core.Constructs.Eq
import Feldspar.Core.Constructs.Floating
import Feldspar.Core.Constructs.Fractional
import Feldspar.Core.Constructs.Integral
import Feldspar.Core.Constructs.Logic
import Feldspar.Core.Constructs.Num
import Feldspar.Core.Constructs.Ord
import Feldspar.Core.Constructs.RealFloat
import Feldspar.Core.Constructs.Trace
import Feldspar.Compiler.Imperative.Frontend
import Feldspar.Compiler.Imperative.Representation (Expression(..))
import Feldspar.Compiler.Imperative.FromCore.Interpretation
instance Compile dom dom => Compile Semantics dom
where
compileExprSym (Sem name _) info args = do
argExprs <- sequence $ listArgs compileExpr args
return $ fun (compileTypeRep (infoType info) (infoSize info)) name argExprs
compilePrim :: (Semantic expr, Compile dom dom)
=> (expr :|| Type) a
-> Info (DenResult a)
-> Args (AST (Decor Info dom)) a
-> CodeWriter (Expression ())
compilePrim (C' s) = compileExprSym $ semantics s
instance Compile dom dom => Compile (BITS :|| Type) dom where compileExprSym = compilePrim
instance Compile dom dom => Compile (COMPLEX :|| Type) dom where compileExprSym = compilePrim
instance Compile dom dom => Compile (Conversion :|| Type) dom where compileExprSym = compilePrim
instance Compile dom dom => Compile (EQ :|| Type) dom where compileExprSym = compilePrim
instance Compile dom dom => Compile (FLOATING :|| Type) dom where compileExprSym = compilePrim
instance Compile dom dom => Compile (FRACTIONAL :|| Type) dom where compileExprSym = compilePrim
instance Compile dom dom => Compile (INTEGRAL :|| Type) dom where compileExprSym = compilePrim
instance Compile dom dom => Compile (Logic :|| Type) dom where compileExprSym = compilePrim
instance Compile dom dom => Compile (NUM :|| Type) dom where compileExprSym = compilePrim
instance Compile dom dom => Compile (ORD :|| Type) dom where compileExprSym = compilePrim
instance Compile dom dom => Compile (REALFLOAT :|| Type) dom where compileExprSym = compilePrim
instance Compile dom dom => Compile (Trace :|| Type) dom where compileExprSym = compilePrim