Stability | experimental |
---|---|
Maintainer | developer@flocc.net |
Safe Haskell | None |
For more information please see http://www.flocc.net/
- checkNodeTreeEx :: Monad m => String -> NodeTreeEx -> GenM m
- getGenTrace :: Monad m => GenM1 m String
- createOrGetEnv :: Monad m => NodeId -> GenM1 m (ValEnv m)
- getThisEnv :: Monad m => GenM1 m (ValEnv m)
- modifyThisEnv :: Monad m => (ValEnv m -> ValEnv m) -> GenState m -> GenState m
- updateThisEnv :: Monad m => (ValEnv m -> ValEnv m) -> GenM m
- createOrGetMembers :: Monad m => NodeId -> GenM1 m (ValEnv m)
- modifyMembers :: Monad m => NodeId -> (ValEnv m -> ValEnv m) -> GenState m -> GenState m
- updateMembers :: Monad m => NodeId -> (ValEnv m -> ValEnv m) -> GenM m
- createVar :: Monad m => Ty -> GenM1 m IdTree
- newVar :: Monad m => IdTree -> Ty -> GenM m
- newStructVar :: Monad m => IdTree -> Ty -> GenM m
- newVal :: Monad m => Id -> Val m -> GenM m
- newIntList :: Monad m => Id -> [Int] -> GenM m
- getIntList :: Monad m => Id -> GenM1 m [Int]
- setVar1 :: Monad m => NodeTreeEx -> Id -> Id -> GenM m
- getVar1 :: Monad m => Id -> NodeTreeEx -> Id -> GenM m
- alignVars :: Monad m => IdTree -> Ty -> IdTree -> [(Id, Val m)]
- makeStructAccessors :: Id -> Tree a -> [(Id, a)]
- aliasVar :: forall m. Monad m => IdTree -> IdTree -> GenM m
- varExp :: Monad m => Id -> Id -> Id -> Ty -> GenM m
- ifnVarInit :: Monad m => Id -> Id -> IdTree -> Ty -> Maybe IdTree -> GenM m
- ifnVar :: Monad m => Id -> Id -> IdTree -> Ty -> GenM m
- setLocalVal :: Monad m => Id -> Val m -> GenM m
- getLocalVal :: Monad m => Id -> GenM1 m (Val m)
- getLocalVar :: Monad m => IdTree -> GenM1 m (Val m)
- getVal :: Monad m => NodeTreeEx -> Id -> GenM1 m (Val m)
- getValMaybe :: Monad m => NodeTreeEx -> Id -> GenM1 m (Maybe (Val m))
- getVal2 :: Monad m => NodeTreeEx -> Id -> (Val m -> [(Id, Val m)]) -> GenM m
- setVal :: Monad m => NodeTreeEx -> Id -> Val m -> GenM m
- setVal2 :: Monad m => NodeTreeEx -> Id -> IdTree -> (Tree (Val m) -> Val m) -> GenM m
- getVar :: Monad m => IdTree -> NodeTreeEx -> Id -> GenM m
- ifVarExists :: Monad m => Id -> NodeTreeEx -> Id -> GenM m -> GenM m -> GenM m
- ifVarsExist :: Monad m => [(Id, NodeTreeEx, Id)] -> GenM m -> GenM m -> GenM m
- treeValToVar :: Monad m => String -> Tree (Val m) -> Val m
- setVar :: Monad m => NodeTreeEx -> Id -> IdTree -> GenM m
- setFun :: Monad m => NodeTreeEx -> Id -> Maybe IdTree -> TemplateProc m -> GenM m
- callFun :: Monad m => NodeTreeEx -> Id -> Maybe IdTree -> GenM m
- callAll :: Monad m => NodeTreeEx -> Id -> Maybe IdTree -> GenM1 m Int
- callConsumers :: Monad m => NodeTreeEx -> Id -> Maybe IdTree -> GenM1 m Int
- shouldBeGlobal :: Monad m => NodeTreeEx -> GenM1 m Bool
- tryCall :: Monad m => NodeTreeEx -> Id -> Maybe IdTree -> GenM m
- getCode :: Monad m => Id -> NodeTreeEx -> Id -> GenM m
- setCode :: Monad m => NodeTreeEx -> Id -> StrTem -> GenM m
- addCode :: Monad m => NodeTreeEx -> Id -> StrTem -> GenM m
- expandTem :: Monad m => String -> StrTem -> GenM1 m Code
- output :: Monad m => Id -> StrTem -> GenM m
- outputDecl :: Monad m => NodeTreeEx -> StrTem -> GenM m
- getGlobal :: Monad m => String -> Tree OrdVal -> GenM1 m (Maybe (Val m))
- setGlobal :: Monad m => String -> Tree OrdVal -> Maybe (Val m) -> GenM m
- runGen :: Monad m => Id -> Id -> [Val m] -> GenM m
- runGenV :: Monad m => Id -> Id -> [IdTree] -> GenM m
- getFun :: Monad m => NodeTreeEx -> GenM1 m (Val m)
- varsToExclude :: Map Id ()
- evalFun :: (Monad m, MonadCatch m) => Val m -> Val m -> NodeTreeEx -> Val m -> GenM1 m Code
- genFun :: (Monad m, MonadCatch m) => Id -> Val m -> Ty -> IdTree -> NodeTreeEx -> IdTree -> GenM m
- genFunV :: (Monad m, MonadCatch m) => Id -> NodeTreeEx -> IdTree -> NodeTreeEx -> IdTree -> GenM m
- getNestedGraph :: Graph -> Graph
- getGraphTy :: Monad m => Graph -> GenM1 m Ty
- getGraphTyV :: Monad m => Either (Val m) NodeTreeEx -> GenM1 m Ty
- genTyFunV :: (Monad m, MonadCatch m) => Id -> Ty -> IdTree -> NodeTreeEx -> IdTree -> GenM m
- genStaticFun :: (Monad m, MonadCatch m) => Graph -> Maybe Ty -> Maybe Ty -> String -> GenM1 m Ty
- funClassTemplate :: String -> StrTem
- outVarName :: [Char]
- generateVisitor :: (Monad m, MonadCatch m) => [Graph] -> Node -> GenM m
- generateVisitor2 :: Monad m => [Graph] -> Node -> GenM m
- enabledFlagName :: [Char]
- type EnabledFlags = Tree Bool
- generateVisitor3 :: Monad m => [Graph] -> Node -> GenM m
- visitIfEnabled :: Monad m => ([Graph] -> Node -> GenM m) -> [Graph] -> Node -> GenM m
- generateM :: (Monad m, MonadCatch m) => [Graph] -> GenM m
- generate :: (Monad m, MonadCatch m) => GenM m -> Generators m -> Templates m -> NodeEnv Ty -> Graph -> Int -> m (Map Id Code)
Documentation
checkNodeTreeEx :: Monad m => String -> NodeTreeEx -> GenM m
checkNodeTreeEx msg nodeTree. Checks if nodeTree has |a non empty path, and if so throws an error.
getGenTrace :: Monad m => GenM1 m String
createOrGetEnv :: Monad m => NodeId -> GenM1 m (ValEnv m)
createOrGetEnv tries to get local env, but if it doesn't exist |creates an empty one and puts it in the state.
getThisEnv :: Monad m => GenM1 m (ValEnv m)
returns the local context for the current node
modifyThisEnv :: Monad m => (ValEnv m -> ValEnv m) -> GenState m -> GenState m
modify current locals environment, creating a new one if it doesn't |already exist.
updateThisEnv :: Monad m => (ValEnv m -> ValEnv m) -> GenM m
createOrGetMembers :: Monad m => NodeId -> GenM1 m (ValEnv m)
createOrGetMembers nodeId. Returns the value environment for a |given node, creating a new empty one if it doesn't already exist.
modifyMembers :: Monad m => NodeId -> (ValEnv m -> ValEnv m) -> GenState m -> GenState m
modifys a generator state's member environment for a node. If |no environment exists yet, it creates a new one.
updateMembers :: Monad m => NodeId -> (ValEnv m -> ValEnv m) -> GenM m
updates the generator state's member environment for a node.
createVar :: Monad m => Ty -> GenM1 m IdTree
createVar type generates a fresh id for each scalar part of the |the type, and composes them into an id tree for the VarV.
newVar :: Monad m => IdTree -> Ty -> GenM m
newVar ids type generates fresh vars for the id tree and type, |and adds the bindings to the local environment.
newStructVar :: Monad m => IdTree -> Ty -> GenM m
newStructVar idTree tyTree. Creates a new struct variable |for every id in the idTree. Differs from newVar, in that newVar |creates a new variable for every scalar part of the type, rather |than a struct for each id.
newIntList :: Monad m => Id -> [Int] -> GenM m
getIntList :: Monad m => Id -> GenM1 m [Int]
alignVars :: Monad m => IdTree -> Ty -> IdTree -> [(Id, Val m)]
alignVars destIds srcTy srcIds. Returns a list of mappings |from ids in destIds to their equivalent ids and types in srcTy and srcId, |expanding srcId to access struct members when needed.
makeStructAccessors :: Id -> Tree a -> [(Id, a)]
makeStructAccessors rootId tree. Makes variable names for |accessing the tuple struct called rootId's members that correspond to leaves in tree.
aliasVar :: forall m. Monad m => IdTree -> IdTree -> GenM m
aliasVar destIds srcIds. Gets the var(s) at srcIds, |and aligns them with the destIds to create some new |local names for existing vars.
varExp :: Monad m => Id -> Id -> Id -> Ty -> GenM m
varExp destId srcId strTem type. Creates a new binding |in the local env called destId, which is bound to the |expression strTem where v is replaced with | the var name of the var srcId, with the given type. |Note: the expression is re-evaluated at each reference.
ifnVarInit :: Monad m => Id -> Id -> IdTree -> Ty -> Maybe IdTree -> GenM m
ifnVarInit decName publicName localNames type val. If a public var already exists |called publicName, then assign it to localNames, otherwise create |a new local var called localNames, and assign it to publicName. Also create |initializing declaration called decName that inits with val. If val is |(LitV NulVal) then doesn't init with any parameters.
ifnVar :: Monad m => Id -> Id -> IdTree -> Ty -> GenM m
ifnVar decName publicName localNames varTy. Works as ifnVarInit, only val has values Nothing.
setLocalVal :: Monad m => Id -> Val m -> GenM m
getLocalVal gets a value from the current node's |local environment, or throws an error if it doesn't exist.
setLocalVal id val. Binds val to the name id |in the local env.
getLocalVal :: Monad m => Id -> GenM1 m (Val m)
getLVal varId. Returns the value of the var called varId |in the current local environment or throws an error if it is |not defined.
getLocalVar :: Monad m => IdTree -> GenM1 m (Val m)
getVal :: Monad m => NodeTreeEx -> Id -> GenM1 m (Val m)
getVal srcNode srcId. Gets the public member called srcId at |srcNode and returns it.
getValMaybe :: Monad m => NodeTreeEx -> Id -> GenM1 m (Maybe (Val m))
getValMaybe srcNode srcId. Looks up the public member called srcId |in srcNode's public members. Throws an error if no public env exists |for srcNode.
getVal2 :: Monad m => NodeTreeEx -> Id -> (Val m -> [(Id, Val m)]) -> GenM m
getVal2 srcNode srcId bindGenF. Gets the public member value stored at node |srcNode under srcId, then applies bindGenF to create new local var-value bindings |from the value, and updates the current node's local environment by adding these |bindings.
setVal :: Monad m => NodeTreeEx -> Id -> Val m -> GenM m
setVal destNode destId val. Sets the public member called destId at destNode |to val.
setVal2 :: Monad m => NodeTreeEx -> Id -> IdTree -> (Tree (Val m) -> Val m) -> GenM m
setVal destNode destId srcId valGenF. Gets all the local vals in srcId, combines |them into a new val using valGenF, and then adds this to destNode's public |members under destId.
getVar :: Monad m => IdTree -> NodeTreeEx -> Id -> GenM m
getVar -- gets a var from an object's environment into the local context |if there is no members environment set yet, or the var doesn't exist, it throws |an error.
ifVarExists :: Monad m => Id -> NodeTreeEx -> Id -> GenM m -> GenM m -> GenM m
ifVarExists destId srcNode srcId thenAction elseAction. Like getVar, only if the var |doesn't exist it performs elseAction, and if it does, in after binding |it to destId locally, it performs thenAction.
ifVarsExist :: Monad m => [(Id, NodeTreeEx, Id)] -> GenM m -> GenM m -> GenM m
isVarsExist vars thenAction elseAction. Checks if all the vars in the list |[(destId, srcNode, srcId)] exist. If they do, binds them to the destIds in the |local env, and performs thenAction. Else performs elseAction.
treeValToVar :: Monad m => String -> Tree (Val m) -> Val m
treeValToVar vals. Takes a tree of Var vals and composes them to form a |Var val.
setFun :: Monad m => NodeTreeEx -> Id -> Maybe IdTree -> TemplateProc m -> GenM m
setFun node procId argIdTree proc. Creates a new template procedure and |adds it to the public members of the node given.
callFun :: Monad m => NodeTreeEx -> Id -> Maybe IdTree -> GenM m
callFun node procId valIdTree. Gets the procedure stored at procId in node's |public members, and invokes it with the node as the current node.
callAll :: Monad m => NodeTreeEx -> Id -> Maybe IdTree -> GenM1 m Int
callAll node procId valIdTree. Gets all of node's outputs |and invokes the procedure called procId at each of them, |with the parameters implied by valIdTree. Returns number of consumers.
callConsumers :: Monad m => NodeTreeEx -> Id -> Maybe IdTree -> GenM1 m Int
callConsumers node procId valIdTree. Gets all of node's consumers |and invokes the procedure callec procId at each of them, with the |parameters implied by valIdTree. Then gets all members of the |preceding nodes that have changed, merges the changes, and applies |them to node's public members. Returns the number of consumers.
shouldBeGlobal :: Monad m => NodeTreeEx -> GenM1 m Bool
shouldBeGlobal node. Returns true if the value returned |by node should be a global var (e.g. is used in a funNode).
tryCall :: Monad m => NodeTreeEx -> Id -> Maybe IdTree -> GenM m
tryCall node procId valIdTree. Calls node.procId if it exists, |and does nothing otherwise.
getCode :: Monad m => Id -> NodeTreeEx -> Id -> GenM m
getCode destId srcNode srcId. Gets the code from srcNode.srcId |and adds it to the local context under destId.
setCode :: Monad m => NodeTreeEx -> Id -> StrTem -> GenM m
setCode destNode destId tem. Expands tem using the current |local vars, and then sets destNode's public member called destId |to the expanded code.
addCode :: Monad m => NodeTreeEx -> Id -> StrTem -> GenM m
addCode destNode destId tem. Expands tem using the |current local vars, gets the current value of destId |at destNode, appends the expanded template, and saves it |back to the state. destId must already exist or it will |throw an error!
output :: Monad m => Id -> StrTem -> GenM m
output streamId template expands the template using the values of the current node's |local vars and appends it to the stream identified by streamId. If the stream does not |yet exist, creates it, and appends the expanded template to it.
outputDecl :: Monad m => NodeTreeEx -> StrTem -> GenM m
outputDecl node dec. Checks to see if declaration should |be global by calling shouldBeGlobal, and outputs to |main or globals as appropriate.
getGlobal :: Monad m => String -> Tree OrdVal -> GenM1 m (Maybe (Val m))
getGlobal envName key. Looks up a value with key in the globals Map called envName.
setGlobal :: Monad m => String -> Tree OrdVal -> Maybe (Val m) -> GenM m
setGlobal key val. Inserts, updates, or deletes the value of key in the |globals map.
runGen :: Monad m => Id -> Id -> [Val m] -> GenM m
runGen genId destVarId argVars. Runs the generator called genId |with arguments from argVars, and binds the result to destVarId in the current local |vars environment.
runGenV :: Monad m => Id -> Id -> [IdTree] -> GenM m
runGenV genId destVarId varIds. Runs the generator called genId |with arguments from the local variables refered to as varIds, |and assigns the result to destVarId in the locals environment.
getFun :: Monad m => NodeTreeEx -> GenM1 m (Val m)
getFun node. Returns a GraphV for the function graph |stored in node. TODO Will there ever be Lambdas that take Lambdas as arguments? Because if so we need to support having trees of any kind of Vals passed to Lambda input nodes, including GraphVs.
varsToExclude :: Map Id ()
evalFun :: (Monad m, MonadCatch m) => Val m -> Val m -> NodeTreeEx -> Val m -> GenM1 m Code
evalFun funVal inVarVal outVarVal. Creates a new copy of |the graph funVal with new node ids, then assigns input and output |vars to it, and generates the code for the graph.
genFun :: (Monad m, MonadCatch m) => Id -> Val m -> Ty -> IdTree -> NodeTreeEx -> IdTree -> GenM m
eval funId inVarId outVarId. Generates the code to |implement the graph stored as funId in the local env |with the vars stored as inVarId and outVarId in the |local env.
genFun codeVarName funVal inVars outVars. Generates code to implement |funVal using input vars inVars and outVars outVars (stored in local env). |Stores the resultant code in the local env as codeVarName.
genFunV :: (Monad m, MonadCatch m) => Id -> NodeTreeEx -> IdTree -> NodeTreeEx -> IdTree -> GenM m
appFun codeVarName funNode inVars outVars. Generates code for the |lambda at funNode, with inVars and outVars, assigning the generated |code to codeVarName in the local environment.
getNestedGraph :: Graph -> Graph
getNestedGraph graph. Checks if graph returns another |graph, and if it does, returns that nested graph.
getGraphTy :: Monad m => Graph -> GenM1 m Ty
getGraphTy graph. Returns the type of the function |represented by the graph.
getGraphTyV :: Monad m => Either (Val m) NodeTreeEx -> GenM1 m Ty
getGraphTyV val. Returns the type of the graph in the |variable, type, or node respectively.
genTyFunV :: (Monad m, MonadCatch m) => Id -> Ty -> IdTree -> NodeTreeEx -> IdTree -> GenM m
genTyFunV codeVarName funTy inVars outVars. Generates code for |the function stored in funTy, with inVars and outVars.
genStaticFun :: (Monad m, MonadCatch m) => Graph -> Maybe Ty -> Maybe Ty -> String -> GenM1 m Ty
genProjFun []. Generates a class for this projection function, with |proj() and inject() members. (Does not cache in globals).
funClassTemplate :: String -> StrTem
outVarName :: [Char]
generateVisitor :: (Monad m, MonadCatch m) => [Graph] -> Node -> GenM m
generateVisitor graph node performs whatever generation actions |are required for each node in the graph.
generateVisitor2 :: Monad m => [Graph] -> Node -> GenM m
geneateVisitor2 graph node. Tries to call the procedure |gen for each node.
enabledFlagName :: [Char]
type EnabledFlags = Tree Bool
generateVisitor3 :: Monad m => [Graph] -> Node -> GenM m
generareVisitor3 graph node. Propagates enabled trees |throughout graph, so discover which nodes should be visited |and which should not.
visitIfEnabled :: Monad m => ([Graph] -> Node -> GenM m) -> [Graph] -> Node -> GenM m
visitIfEnabled visitFun graph node. Applies visitFun unless node's enabled |flag tree is all false (i.e. there is no true)