packages feed

feldspar-compiler-0.2: Feldspar/Compiler/Imperative/Semantics.hs

{-# LANGUAGE TypeFamilies, EmptyDataDecls, FlexibleContexts #-}
module Feldspar.Compiler.Imperative.Semantics where

-- ===========================================================================
--  == Semantic info class
-- ===========================================================================

class (Show (ProcedureInfo t),
       Show (BlockInfo t),
       Show (ProgramInfo t),
       Show (EmptyInfo t), Show (PrimitiveInfo t), Show (SequenceInfo t), Show (BranchInfo t), Show (SequentialLoopInfo t), Show (ParallelLoopInfo t),
       Show (FormalParameterInfo t),
       Show (LocalDeclarationInfo t),
       Show (FunctionCallInfo t),
       Show (LeftValueExpressionInfo t), 
       Show (VariableInLeftValueInfo t),
       Show (ArrayElemReferenceInfo t),
       Show (InputActualParameterInfo t), Show (OutputActualParameterInfo t),
       Show (AssignmentInfo t),
       Show (ProcedureCallInfo t),
       Show (IntConstantInfo t), Show (FloatConstantInfo t), Show (BoolConstantInfo t), Show (ArrayConstantInfo t),
       Show (VariableInfo     t),
       Eq (ProcedureInfo t),
       Eq (BlockInfo t),
       Eq (ProgramInfo t),
       Eq (EmptyInfo t), Eq (PrimitiveInfo t), Eq (SequenceInfo t), Eq (BranchInfo t), Eq (SequentialLoopInfo t), Eq (ParallelLoopInfo t),
       Eq (FormalParameterInfo t),
       Eq (LocalDeclarationInfo t),
       Eq (FunctionCallInfo t),
       Eq (LeftValueExpressionInfo t),
       Eq (VariableInLeftValueInfo t),
       Eq (ArrayElemReferenceInfo t),
       Eq (InputActualParameterInfo t), Eq (OutputActualParameterInfo t),
       Eq (AssignmentInfo t),
       Eq (ProcedureCallInfo t),
       Eq (IntConstantInfo t), Eq (FloatConstantInfo t), Eq (BoolConstantInfo t), Eq (ArrayConstantInfo t),
       Eq (VariableInfo     t))
            => SemanticInfo t where
    type ProcedureInfo t
    type BlockInfo t
    type ProgramInfo t
    type EmptyInfo t
    type PrimitiveInfo t
    type SequenceInfo t
    type BranchInfo t
    type SequentialLoopInfo t
    type ParallelLoopInfo t
    type FormalParameterInfo t
    type LocalDeclarationInfo t
    type LeftValueExpressionInfo t
    type VariableInLeftValueInfo t
    type ArrayElemReferenceInfo t
    type InputActualParameterInfo t
    type OutputActualParameterInfo t
    type AssignmentInfo t
    type ProcedureCallInfo t
    type FunctionCallInfo t
    type IntConstantInfo t
    type FloatConstantInfo t
    type BoolConstantInfo t
    type ArrayConstantInfo t
    type VariableInfo t

-- ===========================================================================
--  == Unit semantic info instance
-- ===========================================================================

instance SemanticInfo () where
    type ProcedureInfo () = ()
    type BlockInfo () = ()
    type ProgramInfo () = ()
    type EmptyInfo () = ()
    type PrimitiveInfo () = ()
    type SequenceInfo () = ()
    type BranchInfo () = ()
    type SequentialLoopInfo () = ()
    type ParallelLoopInfo () = ()
    type FormalParameterInfo () = ()
    type LocalDeclarationInfo () = ()
    type LeftValueExpressionInfo () = ()
    type VariableInLeftValueInfo () = ()
    type ArrayElemReferenceInfo () = ()
    type InputActualParameterInfo () = ()
    type OutputActualParameterInfo () = ()
    type AssignmentInfo () = ()
    type ProcedureCallInfo () = ()
    type FunctionCallInfo () = ()
    type IntConstantInfo () = ()
    type FloatConstantInfo () = ()
    type BoolConstantInfo () = ()
    type ArrayConstantInfo () = ()
    type VariableInfo () = ()

-- ===========================================================================
--  == Basic semantic info instance
-- ===========================================================================

data InitSemInf

instance SemanticInfo InitSemInf where
    type ProcedureInfo InitSemInf = ()
    type BlockInfo InitSemInf = ()
    type ProgramInfo InitSemInf = ()
    type EmptyInfo InitSemInf = ()
    type PrimitiveInfo InitSemInf = Bool
    type SequenceInfo InitSemInf = ()
    type BranchInfo InitSemInf = ()
    type SequentialLoopInfo InitSemInf = ()
    type ParallelLoopInfo InitSemInf = ()
    type FormalParameterInfo InitSemInf = ()
    type LocalDeclarationInfo InitSemInf = ()
    type LeftValueExpressionInfo InitSemInf = ()
    type VariableInLeftValueInfo InitSemInf = ()
    type ArrayElemReferenceInfo InitSemInf = ()
    type InputActualParameterInfo InitSemInf = ()
    type OutputActualParameterInfo InitSemInf = ()
    type AssignmentInfo InitSemInf = ()
    type ProcedureCallInfo InitSemInf = ()
    type FunctionCallInfo InitSemInf = ()
    type IntConstantInfo InitSemInf = ()
    type FloatConstantInfo InitSemInf = ()
    type BoolConstantInfo InitSemInf = ()
    type ArrayConstantInfo InitSemInf = ()
    type VariableInfo InitSemInf = ()

-- ===========================================================================
--  == PrettyPrint semantic info instance
-- ===========================================================================


data IsRestrict = Restrict | NoRestrict
    deriving (Show,Eq)

data IsDefaultArraySize = DefaultArraySize | NoDefaultArraySize
    deriving (Show,Eq)

data PrettyPrintSemanticInfo

instance SemanticInfo PrettyPrintSemanticInfo where
    type ProcedureInfo PrettyPrintSemanticInfo = ()
    type BlockInfo PrettyPrintSemanticInfo = ()
    type ProgramInfo PrettyPrintSemanticInfo = ()
    type EmptyInfo PrettyPrintSemanticInfo = ()
    type PrimitiveInfo PrettyPrintSemanticInfo = ()
    type SequenceInfo PrettyPrintSemanticInfo = ()
    type BranchInfo PrettyPrintSemanticInfo = ()
    type SequentialLoopInfo PrettyPrintSemanticInfo = ()
    type ParallelLoopInfo PrettyPrintSemanticInfo = ()
    type FormalParameterInfo PrettyPrintSemanticInfo = IsRestrict
    type LocalDeclarationInfo PrettyPrintSemanticInfo = ()
    type LeftValueExpressionInfo PrettyPrintSemanticInfo = ()
    type VariableInLeftValueInfo PrettyPrintSemanticInfo = ()
    type ArrayElemReferenceInfo PrettyPrintSemanticInfo = ()
    type InputActualParameterInfo PrettyPrintSemanticInfo = ()
    type OutputActualParameterInfo PrettyPrintSemanticInfo = ()
    type AssignmentInfo PrettyPrintSemanticInfo = ()
    type ProcedureCallInfo PrettyPrintSemanticInfo = ()
    type FunctionCallInfo PrettyPrintSemanticInfo = ()
    type IntConstantInfo PrettyPrintSemanticInfo = ()
    type FloatConstantInfo PrettyPrintSemanticInfo = ()
    type BoolConstantInfo PrettyPrintSemanticInfo = ()
    type ArrayConstantInfo PrettyPrintSemanticInfo = ()
    type VariableInfo PrettyPrintSemanticInfo = ()