cubix
Safe HaskellNone
LanguageHaskell2010

Cubix.Language.Parametric.Semantics.Cfg

Synopsis

Documentation

class (CfgComponent fs (CfgState fs), ConstructCfg fs (CfgState fs) (Sum fs), CfgInitState fs) => CfgBuilder (fs :: Signature) 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 :: Signature) l. CfgBuilder fs => TermLab fs l -> Cfg fs Source #

Constructs a CFG for the given labelled term

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

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

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

data EnterExitPair (fs :: Signature) 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 :: Signature) l. (ListF :-<: fs, Typeable l) => EnterExitPair fs [l] -> [EnterExitPair fs l] Source #

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

extractEEPMaybe :: forall (fs :: [(Type -> Type) -> Type -> Type]) m l. (All (KExtractF' Maybe) fs, Monad m) => m (EnterExitPair fs (Maybe l)) -> m (Maybe (EnterExitPair fs l)) Source #

identEnterExit :: forall (fs :: Signature) l. CfgNode fs -> EnterExitPair fs l Source #

combineEnterExit :: forall s (fs :: Signature) m i j k. (HasCurCfg s fs, All HTraversable fs, All HFoldable fs, All HFunctor fs, MonadState s m) => EnterExitPair fs i -> EnterExitPair fs j -> m (EnterExitPair fs k) Source #

collapseEnterExit :: forall s (fs :: Signature) m i j. (HasCurCfg s fs, All HTraversable fs, All HFoldable fs, All HFunctor fs, MonadState s m) => EnterExitPair fs i -> m (EnterExitPair fs j) Source #

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

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

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

type PreRAlg (f :: (Type -> Type) -> Type -> Type) (g :: (Type -> Type) -> Type -> Type) (a :: Type -> Type) = 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 :: Signature) s (f :: Node) 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 :: Type -> Type) l Source #

Constructors

HState 

Fields

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

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

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

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

constructCfgEmpty :: forall s m (gs :: Signature) l. (MonadState s m, CfgComponent gs s) => TermLab gs l -> m (EnterExitPair gs l) Source #

constructCfgIfElseIfElse :: forall s m (gs :: Signature) l i j k. (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 #

pushContinueNode :: forall s m (fs :: Signature). (MonadState s m, HasLoopStack s) => CfgNode fs -> m () Source #

pushBreakNode :: forall s m (fs :: Signature). (MonadState s m, HasLoopStack s) => CfgNode fs -> m () Source #

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

constructCfgWhile :: forall s m (gs :: Signature) l i j k. (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 :: forall s m (gs :: Signature) l i j k. (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 :: forall s m (gs :: Signature) l h i j k. (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 #

constructCfgBreak :: forall s m (gs :: Signature) l i. (HasLoopStack s, MonadState s m, CfgComponent gs s) => TermLab gs l -> m (EnterExitPair gs i) Source #

constructCfgContinue :: forall s m (gs :: Signature) l i. (HasLoopStack s, MonadState s m, CfgComponent gs s) => TermLab gs l -> m (EnterExitPair gs i) 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

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

constructCfgLabel :: forall (gs :: Signature) 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

edgeToScopedLabel :: forall s m (fs :: Signature). (MonadState s m, HasScopedLabelMap s, CfgComponent fs s) => CfgNode fs -> String -> CfgNodeType -> m () Source #

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

constructCfgScopedLabel :: forall s m (fs :: Signature) l s0 i. (HasScopedLabelMap s, MonadState s m, CfgComponent fs s) => TermLab fs l -> String -> TermLab fs s0 -> m (EnterExitPair fs s0) -> m (EnterExitPair fs i) Source #

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

constructCfgCondOp :: forall s m (fs :: Signature) l ls rs es. (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 :: Signature) Source #

Instances

Instances details
Generic (Cfg fs) Source # 
Instance details

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

Associated Types

type Rep (Cfg fs) 
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.7.0.15-inplace" '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)))))

Methods

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

to :: Rep (Cfg fs) x -> 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 #

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 #

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.7.0.15-inplace" '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 :: Signature) Source #

Instances

Instances details
Generic (CfgNode fs) Source # 
Instance details

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

Associated Types

type Rep (CfgNode fs) 
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.7.0.15-inplace" '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)))))))

Methods

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

to :: Rep (CfgNode fs) x -> 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 #

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 #

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.7.0.15-inplace" '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)))))))

safeLookupCfg :: forall (fs :: Signature). Cfg fs -> Label -> Maybe (CfgNode fs) Source #

lookupCfg :: forall (fs :: Signature). Cfg fs -> Label -> CfgNode fs Source #

cfgNodeForTerm :: forall (fs :: Signature) l. Cfg fs -> CfgNodeType -> TermLab fs l -> Maybe (CfgNode fs) Source #

data CfgNodeType Source #

Instances

Instances details
Generic CfgNodeType Source # 
Instance details

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

Associated Types

type Rep CfgNodeType 
Instance details

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

type Rep CfgNodeType = D1 ('MetaData "CfgNodeType" "Cubix.Language.Parametric.Semantics.Cfg.Graph" "cubix-0.7.0.15-inplace" 'True) (C1 ('MetaCons "CfgNodeType" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 NodeEvaluationPoint)))
Show CfgNodeType Source # 
Instance details

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

NFData CfgNodeType Source # 
Instance details

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

Methods

rnf :: CfgNodeType -> () #

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

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.7.0.15-inplace" 'True) (C1 ('MetaCons "CfgNodeType" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 NodeEvaluationPoint)))

class HasCurCfg c (fs :: Signature) | 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 #

emptyCfg :: forall (fs :: Signature). Cfg fs Source #

cfgNodes :: forall (fs :: Signature). Cfg fs -> [CfgNode fs] Source #

addCfgNode :: forall s (fs :: Signature) m l. (HasCurCfg s fs, HasLabelGen s, MonadState s m) => TermLab fs l -> CfgNodeType -> m (CfgNode fs) Source #

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

addEdge :: forall (fs :: Signature). CfgNode fs -> CfgNode fs -> Cfg fs -> Cfg fs Source #

addEdgeLab :: forall (fs :: Signature). Label -> Label -> Cfg fs -> Cfg fs Source #

contractNode :: forall (fs :: Signature). Label -> Cfg fs -> Cfg fs Source #

satisfyingPredBoundary :: forall (fs :: Signature). (CfgNode fs -> Bool) -> Cfg fs -> CfgNode fs -> Maybe [CfgNode fs] Source #

satisfyingSuccBoundary :: forall (fs :: Signature). (CfgNode fs -> Bool) -> Cfg fs -> CfgNode fs -> Maybe [CfgNode fs] Source #

satisfyingStrictPredBoundary :: forall (fs :: Signature). (CfgNode fs -> Bool) -> Cfg fs -> CfgNode fs -> Maybe [CfgNode fs] Source #

satisfyingStrictSuccBoundary :: forall (fs :: Signature). (CfgNode fs -> Bool) -> Cfg fs -> CfgNode fs -> Maybe [CfgNode fs] Source #

prettyCfg :: forall (fs :: Signature). Cfg fs -> String Source #

debugCfg :: forall (fs :: [(Type -> Type) -> Type -> Type]) l. (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

isStartNode :: forall (fs :: Signature). Cfg fs -> CfgNode fs -> Bool Source #

startsBasicBlock :: forall (fs :: Signature). Cfg fs -> CfgNode fs -> Bool Source #

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