30 #ifndef INCLUDE_CFL_CFLSolver_H_
31 #define INCLUDE_CFL_CFLSolver_H_
65 virtual void initialize();
68 virtual void processCFLEdge(
const CFLEdge* Y_edge);
86 return worklist.push(
item);
90 return worklist.empty();
98 return worklist.pop();
103 return worklist.find(
item);
119 typedef std::map<const Label, NodeBS>
TypeMap;
120 typedef std::unordered_map<NodeID, TypeMap>
DataMap;
133 return predMap[key][ty].test_and_set(src);
138 return succMap[key][ty].test_and_set(dst);
145 return predMap[key][ty] |= data;
152 return succMap[key][ty] |= data;
165 return succMap.begin();
170 return succMap.end();
175 return succMap.begin();
180 return succMap.end();
205 return succMap[key][ty];
210 return predMap[key][ty];
217 addSucc(src, dst, ty);
218 return addPred(dst, src, ty);
225 if (addSuccs(src, dstData, ty))
227 for (
const NodeID datum: dstData)
228 if (addPred(datum, src, ty))
238 if (addPreds(dst, srcData, ty))
240 for (
const NodeID datum: srcData)
241 if (addSucc(datum, dst, ty))
251 if (iter1 == succMap.end())
254 auto iter2 = iter1->second.find(ty);
255 if (iter2 == iter1->second.end())
258 return iter2->second.test(dst);
264 succMap[key].clear();
265 predMap[key].clear();
279 virtual void processCFLEdge(
const CFLEdge* Y_edge);
282 virtual void buildCFLData();
284 virtual void initialize();
333 return indMap[dst][src];
344 void meld_h(
NodeID x, TreeNode* uNode, TreeNode* vNode);
353 for (
auto iter1: indMap)
355 for (
auto iter2: iter1.second)
364 virtual void processCFLEdge(
const CFLEdge* Y_edge);
366 virtual void initialize();
370 void meld(
NodeID x, TreeNode* uNode, TreeNode* vNode);
bool isInWorklist(const CFLEdge *item)
FIFOWorkList< const CFLEdge * > WorkList
Define worklist.
WorkList worklist
Worklist for resolution.
const CFLGraph * getGraph() const
Return CFL Graph.
static double numOfChecks
CFGrammar::Production Production
const CFLEdge * popFromWorklist()
Worklist operations.
virtual bool pushIntoWorklist(const CFLEdge *item)
virtual bool isWorklistEmpty()
CFLSolver(CFLGraph *_graph, CFGrammar *_grammar)
const CFGrammar * getGrammar() const
Return CFL Grammar.
std::vector< Symbol > Production
Solver Utilize Hybrid Representation of Graph.
void insertEdge_h(TreeNode *u, TreeNode *v)
add v into desc(x) as a child of u
POCRHybridSolver(CFLGraph *_graph, CFGrammar *_grammar)
TreeNode * getNode_h(NodeID src, NodeID dst)
Get the node dst in tree(src)
Map< NodeID, std::unordered_map< NodeID, TreeNode * > > indMap
virtual ~POCRHybridSolver()
Destructor.
DataMap::const_iterator const_iterator
void clearEdges(const NodeID key)
bool addPred(const NodeID key, const NodeID src, const Label ty)
bool hasEdge(const NodeID src, const NodeID dst, const Label ty)
find src -> find src[ty] -> find dst in set
virtual ~POCRSolver()
Destructor.
DataMap::iterator iterator
TypeMap & getPredMap(const NodeID key)
NodeBS & getPreds(const NodeID key, const Label ty)
NodeBS addEdges(const NodeID src, const NodeBS &dstData, const Label ty)
add edges and return the set of added edges (dst) for src
const_iterator begin() const
bool addSucc(const NodeID key, const NodeID dst, const Label ty)
TypeMap & getSuccMap(const NodeID key)
NodeBS addEdges(const NodeBS &srcData, const NodeID dst, const Label ty)
add edges and return the set of added edges (src) for dst
NodeBS & getSuccs(const NodeID key, const Label ty)
std::map< const Label, NodeBS > TypeMap
POCRSolver(CFLGraph *_graph, CFGrammar *_grammar)
bool addEdge(const NodeID src, const NodeID dst, const Label ty)
std::unordered_map< NodeID, TypeMap > DataMap
bool addPreds(const NodeID key, const NodeBS &data, const Label ty)
const_iterator end() const
bool addSuccs(const NodeID key, const NodeBS &data, const Label ty)
GrammarBase::Symbol Label
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > Map
bool operator==(const TreeNode &rhs) const
bool operator<(const TreeNode &rhs) const
std::unordered_set< TreeNode * > children