cubix-0.1.0.0: A framework for multi-language transformation
Safe HaskellNone
LanguageHaskell2010

Cubix.Language.Parametric.Semantics.Cfg

Synopsis

Documentation

collapseFProd :: (HFunctor f, f :-<: gs) => f (Term gs :*: t) :-> (Term gs :*: f t) Source #

collapseFProd' :: (HFunctor f, f :-<: gs) => (f :&: a) (AnnTerm a gs :*: t) :-> (AnnTerm a gs :*: f t) Source #

fprodFst' :: (HFunctor f, f :-<: gs) => (f :&: a) (AnnTerm a gs :*: t) :-> AnnTerm a gs Source #

data EnterExitPair fs l Source #

Constructors

EnterExitPair 

Fields

SubPairs (Sum fs (EnterExitPair fs) l) 
EmptyEnterExit 

Instances

Instances details
(All ShowHF fs, All HFunctor fs) => Show (EnterExitPair fs l) Source # 
Instance details

Defined in Cubix.Language.Parametric.Semantics.Cfg.CfgConstruction

Methods

showsPrec :: Int -> EnterExitPair fs l -> ShowS #

show :: EnterExitPair fs l -> String #

showList :: [EnterExitPair fs l] -> ShowS #

extractEEPList :: forall fs l. (ListF :-<: fs, Typeable l) => EnterExitPair fs [l] -> [EnterExitPair fs l] Source #

extractEEPPair :: forall fs a b. PairF :-<: fs => EnterExitPair fs (a, b) -> (EnterExitPair fs a, EnterExitPair fs b) Source #

labeledIsComputationSort :: forall fs l. (IsComputationSort fs, All HFunctor fs) => TermLab fs l -> Bool Source #

labeledIsSuspendedComputationSort :: (IsSuspendedComputationSort fs, All HFunctor fs) => AnnTerm a fs l -> Bool Source #

labeledIsContainer :: (IsContainer fs, All HFunctor fs) => AnnTerm a fs l -> Bool Source #

type PreRAlg f g a = f (HFix g :*: a) :-> a Source #

PreRAlg's are things that can be modularly composed to form R-algebras. R-algebras are in turn the building block used to define paramorphisms, a recursion scheme where each step can depend on both an entire term and the previous results. Because the map of variables in scope within a term depends both on the entire term and the variables in scope in each subterm, this is a correct recursion scheme to use.

PreRAlg f f a == RAlg f a

In PreRAlg f g a, f is the signature functor of the outer layer, while g is the recursive signature functor, and a is the carrier of the R-algebra.

class ConstructCfg gs s f where Source #

Instances

Instances details
(f :-<: gs, HTraversable f, CfgComponent gs s, SortChecks gs) => ConstructCfg gs s f Source # 
Instance details

Defined in Cubix.Language.Parametric.Semantics.Cfg.CfgConstruction

All (ConstructCfg g s) fs => ConstructCfg g s (Sum fs) Source # 
Instance details

Defined in Cubix.Language.Parametric.Semantics.Cfg.CfgConstruction

data HState s f l Source #

Constructors

HState 

Fields

runSubCfgs :: (f :-<: gs, HTraversable f, CfgComponent gs s) => f (HState s (EnterExitPair gs)) i -> State s (EnterExitPair gs j) Source #

constructCfgGeneric :: forall f gs s. (f :-<: gs, HTraversable f, CfgComponent gs s) => PreRAlg (f :&: Label) (Sum gs :&: Label) (HState s (EnterExitPair gs)) Source #

constructCfgDefault :: forall f gs s. (f :-<: gs, HTraversable f, CfgComponent gs s, SortChecks gs) => PreRAlg (f :&: Label) (Sum gs :&: Label) (HState s (EnterExitPair gs)) Source #

type family CfgState (f :: [(* -> *) -> * -> *]) :: * Source #

class (CfgComponent fs (CfgState fs), ConstructCfg fs (CfgState fs) (Sum fs), CfgInitState fs) => CfgBuilder fs Source #

Instances

Instances details
(CfgComponent fs (CfgState fs), ConstructCfg fs (CfgState fs) (Sum fs), CfgInitState fs) => CfgBuilder fs Source # 
Instance details

Defined in Cubix.Language.Parametric.Semantics.Cfg.CfgConstruction

makeCfg :: forall fs l. CfgBuilder fs => TermLab fs l -> Cfg fs Source #

Constructs a CFG for the given labelled term

constructCfgReturn :: (MonadState s m, CfgComponent gs s) => TermLab gs l -> m (Maybe (EnterExitPair gs i)) -> m (EnterExitPair gs l) Source #

constructCfgIfElseIfElse :: (MonadState s m, CfgComponent gs s) => TermLab gs l -> m [(EnterExitPair gs i, EnterExitPair gs j)] -> m (Maybe (EnterExitPair gs k)) -> m (EnterExitPair gs l) Source #

class HasLoopStack c where Source #

Minimal complete definition

loopStack

Methods

loopStack :: Lens' c LoopStack Source #

break_stack :: Lens' c [Label] Source #

continue_stack :: Lens' c [Label] Source #

pushLoopNode :: (MonadState s m, HasLoopStack s) => CfgNode fs -> CfgNode fs -> m () Source #

constructCfgWhile :: (HasLoopStack s, MonadState s m, CfgComponent gs s) => TermLab gs l -> m (EnterExitPair gs i) -> m (EnterExitPair gs j) -> m (EnterExitPair gs k) Source #

constructCfgDoWhile :: (HasLoopStack s, MonadState s m, CfgComponent gs s) => TermLab gs l -> m (EnterExitPair gs i) -> m (EnterExitPair gs j) -> m (EnterExitPair gs k) Source #

constructCfgFor :: (HasLoopStack s, MonadState s m, CfgComponent gs s) => TermLab gs l -> m (Maybe (EnterExitPair gs h)) -> m (Maybe (EnterExitPair gs i)) -> m (Maybe (EnterExitPair gs j)) -> m (EnterExitPair gs k) -> m (EnterExitPair gs l) Source #

class HasLabelMap c where Source #

Minimal complete definition

labelMap

Methods

labelMap :: Lens' c LabelMap Source #

label_map :: Lens' c (Map String (Label, [Label])) Source #

Instances

Instances details
HasLabelMap LabelMap Source # 
Instance details

Defined in Cubix.Language.Parametric.Semantics.Cfg.CommonNodes

constructCfgLabel :: forall gs s m l i. (MonadState s m, HasLabelMap s, CfgComponent gs s) => TermLab gs l -> String -> m (EnterExitPair gs i) Source #

data ScopedLabelMap Source #

Use this if labels are lexically scoped and may not be shadowed In accordance with the representable/valid principle, we are not reusing LabelMap for this purpose. LabelMap is for C's goto labels; ScopedLabelMap is for JavaJS labeled breakcontinue

constructCfgCondOp :: (MonadState s m, CfgComponent fs s) => TermLab fs l -> m (EnterExitPair fs ls) -> m (EnterExitPair fs rs) -> m (EnterExitPair fs es) -> m (EnterExitPair fs es) Source #

data Cfg fs Source #

Instances

Instances details
All EqHF fs => Eq (Cfg fs) Source # 
Instance details

Defined in Cubix.Language.Parametric.Semantics.Cfg.Graph

Methods

(==) :: Cfg fs -> Cfg fs -> Bool #

(/=) :: Cfg fs -> Cfg fs -> Bool #

(All HFunctor fs, All OrdHF fs, All EqHF fs) => Ord (Cfg fs) Source # 
Instance details

Defined in Cubix.Language.Parametric.Semantics.Cfg.Graph

Methods

compare :: Cfg fs -> Cfg fs -> Ordering #

(<) :: Cfg fs -> Cfg fs -> Bool #

(<=) :: Cfg fs -> Cfg fs -> Bool #

(>) :: Cfg fs -> Cfg fs -> Bool #

(>=) :: Cfg fs -> Cfg fs -> Bool #

max :: Cfg fs -> Cfg fs -> Cfg fs #

min :: Cfg fs -> Cfg fs -> Cfg fs #

(All ShowHF fs, All HFunctor fs) => Show (Cfg fs) Source # 
Instance details

Defined in Cubix.Language.Parametric.Semantics.Cfg.Graph

Methods

showsPrec :: Int -> Cfg fs -> ShowS #

show :: Cfg fs -> String #

showList :: [Cfg fs] -> ShowS #

Generic (Cfg fs) Source # 
Instance details

Defined in Cubix.Language.Parametric.Semantics.Cfg.Graph

Associated Types

type Rep (Cfg fs) :: Type -> Type #

Methods

from :: Cfg fs -> Rep (Cfg fs) x #

to :: Rep (Cfg fs) x -> Cfg fs #

HasCurCfg (Cfg fs) fs Source # 
Instance details

Defined in Cubix.Language.Parametric.Semantics.Cfg.Graph

Methods

cur_cfg :: Lens' (Cfg fs) (Cfg fs) Source #

cfg_ast_nodes :: Lens' (Cfg fs) (Map Label (Map CfgNodeType Label)) Source #

cfg_nodes :: Lens' (Cfg fs) (Map Label (CfgNode fs)) Source #

type Rep (Cfg fs) Source # 
Instance details

Defined in Cubix.Language.Parametric.Semantics.Cfg.Graph

type Rep (Cfg fs) = D1 ('MetaData "Cfg" "Cubix.Language.Parametric.Semantics.Cfg.Graph" "cubix-0.1.0.0-GE3qzSJT6A0CUj1veI8jGO" 'False) (C1 ('MetaCons "Cfg" 'PrefixI 'True) (S1 ('MetaSel ('Just "_cfg_nodes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map Label (CfgNode fs))) :*: S1 ('MetaSel ('Just "_cfg_ast_nodes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map Label (Map CfgNodeType Label)))))

data CfgNode fs Source #

Instances

Instances details
All EqHF fs => Eq (CfgNode fs) Source # 
Instance details

Defined in Cubix.Language.Parametric.Semantics.Cfg.Graph

Methods

(==) :: CfgNode fs -> CfgNode fs -> Bool #

(/=) :: CfgNode fs -> CfgNode fs -> Bool #

(All HFunctor fs, All OrdHF fs, All EqHF fs) => Ord (CfgNode fs) Source # 
Instance details

Defined in Cubix.Language.Parametric.Semantics.Cfg.Graph

Methods

compare :: CfgNode fs -> CfgNode fs -> Ordering #

(<) :: CfgNode fs -> CfgNode fs -> Bool #

(<=) :: CfgNode fs -> CfgNode fs -> Bool #

(>) :: CfgNode fs -> CfgNode fs -> Bool #

(>=) :: CfgNode fs -> CfgNode fs -> Bool #

max :: CfgNode fs -> CfgNode fs -> CfgNode fs #

min :: CfgNode fs -> CfgNode fs -> CfgNode fs #

(All ShowHF fs, All HFunctor fs) => Show (CfgNode fs) Source # 
Instance details

Defined in Cubix.Language.Parametric.Semantics.Cfg.Graph

Methods

showsPrec :: Int -> CfgNode fs -> ShowS #

show :: CfgNode fs -> String #

showList :: [CfgNode fs] -> ShowS #

Generic (CfgNode fs) Source # 
Instance details

Defined in Cubix.Language.Parametric.Semantics.Cfg.Graph

Associated Types

type Rep (CfgNode fs) :: Type -> Type #

Methods

from :: CfgNode fs -> Rep (CfgNode fs) x #

to :: Rep (CfgNode fs) x -> CfgNode fs #

type Rep (CfgNode fs) Source # 
Instance details

Defined in Cubix.Language.Parametric.Semantics.Cfg.Graph

type Rep (CfgNode fs) = D1 ('MetaData "CfgNode" "Cubix.Language.Parametric.Semantics.Cfg.Graph" "cubix-0.1.0.0-GE3qzSJT6A0CUj1veI8jGO" 'False) (C1 ('MetaCons "CfgNode" 'PrefixI 'True) ((S1 ('MetaSel ('Just "_cfg_node_prevs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Set Label)) :*: S1 ('MetaSel ('Just "_cfg_node_succs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Set Label))) :*: (S1 ('MetaSel ('Just "_cfg_node_lab") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Label) :*: (S1 ('MetaSel ('Just "_cfg_node_type") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CfgNodeType) :*: S1 ('MetaSel ('Just "_cfg_node_term") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (E (TermLab fs)))))))

data CfgNodeType Source #

Instances

Instances details
Eq CfgNodeType Source # 
Instance details

Defined in Cubix.Language.Parametric.Semantics.Cfg.Graph

Ord CfgNodeType Source # 
Instance details

Defined in Cubix.Language.Parametric.Semantics.Cfg.Graph

Show CfgNodeType Source # 
Instance details

Defined in Cubix.Language.Parametric.Semantics.Cfg.Graph

Generic CfgNodeType Source # 
Instance details

Defined in Cubix.Language.Parametric.Semantics.Cfg.Graph

Associated Types

type Rep CfgNodeType :: Type -> Type #

NFData CfgNodeType Source # 
Instance details

Defined in Cubix.Language.Parametric.Semantics.Cfg.Graph

Methods

rnf :: CfgNodeType -> () #

type Rep CfgNodeType Source # 
Instance details

Defined in Cubix.Language.Parametric.Semantics.Cfg.Graph

type Rep CfgNodeType = D1 ('MetaData "CfgNodeType" "Cubix.Language.Parametric.Semantics.Cfg.Graph" "cubix-0.1.0.0-GE3qzSJT6A0CUj1veI8jGO" 'True) (C1 ('MetaCons "CfgNodeType" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 NodeEvaluationPoint)))

class HasCurCfg c fs | c -> fs where Source #

Minimal complete definition

cur_cfg

Methods

cur_cfg :: Lens' c (Cfg fs) Source #

cfg_ast_nodes :: Lens' c (Map Label (Map CfgNodeType Label)) Source #

cfg_nodes :: Lens' c (Map Label (CfgNode fs)) Source #

Instances

Instances details
HasCurCfg (Cfg fs) fs Source # 
Instance details

Defined in Cubix.Language.Parametric.Semantics.Cfg.Graph

Methods

cur_cfg :: Lens' (Cfg fs) (Cfg fs) Source #

cfg_ast_nodes :: Lens' (Cfg fs) (Map Label (Map CfgNodeType Label)) Source #

cfg_nodes :: Lens' (Cfg fs) (Map Label (CfgNode fs)) Source #

cfg_node_prevs :: HasCfgNode c fs => Lens' c (Set Label) Source #

cfg_node_succs :: HasCfgNode c fs => Lens' c (Set Label) Source #

cfg_node_lab :: HasCfgNode c fs => Lens' c Label Source #

cfg_node_type :: HasCfgNode c fs => Lens' c CfgNodeType Source #

cfg_node_term :: HasCfgNode c fs => Lens' c (E (TermLab fs)) Source #

cfgNodes :: Cfg fs -> [CfgNode fs] Source #

nodeForLab :: (HasCurCfg s fs, MonadState s m) => Label -> m (Maybe (CfgNode fs)) Source #

addEdge :: CfgNode fs -> CfgNode fs -> Cfg fs -> Cfg fs Source #

addEdgeLab :: forall fs. Proxy fs -> Label -> Label -> Cfg fs -> Cfg fs Source #

contractNode :: Label -> Cfg fs -> Cfg fs Source #

debugCfg :: (All ShowHF fs, All HFoldable fs, All HFunctor fs) => TermLab fs l -> Cfg fs -> IO () Source #

Prints a large amount of debug information about a CFG, including a node list, an edge list, and a record of which nodes begin basic blocks.

For an actual graph visualization, see Cubix.Language.Parametric.Semantics.CfgDot

renderCfgDot :: forall fs l. CfgBuilder fs => TermLab fs l -> Graph Source #