Static Value-Flow Analysis
Public Member Functions | Protected Attributes | Private Attributes | List of all members
SVF::GenericGraphReader< NodeTy, EdgeTy > Class Template Reference

#include <SVFFileSystem.h>

Inheritance diagram for SVF::GenericGraphReader< NodeTy, EdgeTy >:
SVF::ICFGReader

Public Member Functions

template<typename NodeCreator , typename EdgeCreator >
void createObjs (const cJSON *graphJson, NodeCreator nodeCreator, EdgeCreator edgeCreator)
 
NodeTy * getNodePtr (unsigned id) const
 
EdgeTy * getEdgePtr (unsigned id) const
 
template<typename NodeFiller , typename EdgeFiller >
void fillObjs (NodeFiller nodeFiller, EdgeFiller edgeFiller)
 
void saveToGenericGraph (GenericGraph< NodeTy, EdgeTy > *graph) const
 
const cJSONgetFieldJson () const
 

Protected Attributes

const cJSONgraphFieldJson = nullptr
 

Private Attributes

ReaderIDToObjMap< NodeTy > idToNodeMap
 
ReaderPtrPool< EdgeTy > edgePool
 

Detailed Description

template<typename NodeTy, typename EdgeTy>
class SVF::GenericGraphReader< NodeTy, EdgeTy >

Definition at line 821 of file SVFFileSystem.h.

Member Function Documentation

◆ createObjs()

template<typename NodeTy , typename EdgeTy >
template<typename NodeCreator , typename EdgeCreator >
void SVF::GenericGraphReader< NodeTy, EdgeTy >::createObjs ( const cJSON graphJson,
NodeCreator  nodeCreator,
EdgeCreator  edgeCreator 
)
inline

Definition at line 832 of file SVFFileSystem.h.

834  {
835  // Read nodeNum
836  const cJSON* nodeNum = graphJson->child;
837  CHECK_JSON_KEY(nodeNum);
838  u32_t numOfNodes = jsonGetNumber(nodeNum);
839  (void)numOfNodes;
840 
841  // Read allNode
842  const cJSON* allNode = nodeNum->next;
843  CHECK_JSON_KEY(allNode);
844  idToNodeMap.createObjs(allNode, nodeCreator);
845  // TODO: ABORT_IFNOT(idToNodeMap.size() == numOfNodes, "nodeNum mismatch");
846 
847  // Read edgeNum
848  const cJSON* edgeNum = allNode->next;
849  CHECK_JSON_KEY(edgeNum);
850  u32_t numOfEdges = jsonGetNumber(edgeNum);
851  (void)numOfEdges;
852 
853  // Read allEdge
854  const cJSON* allEdge = edgeNum->next;
855  CHECK_JSON_KEY(allEdge);
856  edgePool.createObjs(allEdge, edgeCreator);
857  // TODO: ABORT_IFNOT(edgePool.size() == numOfEdges, "edgeNum mismatch");
858 
859  // Rest fields
860  assert(!graphFieldJson && "graphFieldJson should be empty");
861  graphFieldJson = allEdge->next;
862  }
unsigned u32_t
Definition: CommandLine.h:18
#define CHECK_JSON_KEY(obj)
Definition: SVFFileSystem.h:96
const cJSON * graphFieldJson
ReaderIDToObjMap< NodeTy > idToNodeMap
ReaderPtrPool< EdgeTy > edgePool
void createObjs(const cJSON *idObjArrayJson, IdObjCreator idObjCreator)
idObjcreator : (const cJSON*) -> (id, T*) with id set
void createObjs(const cJSON *objArrayJson, Creator creator)
double jsonGetNumber(const cJSON *item)
Definition: cJSON.h:104
struct cJSON * child
Definition: cJSON.h:109
struct cJSON * next
Definition: cJSON.h:106

◆ fillObjs()

template<typename NodeTy , typename EdgeTy >
template<typename NodeFiller , typename EdgeFiller >
void SVF::GenericGraphReader< NodeTy, EdgeTy >::fillObjs ( NodeFiller  nodeFiller,
EdgeFiller  edgeFiller 
)
inline

Definition at line 875 of file SVFFileSystem.h.

876  {
877  // GenericNode<> contains field `InEdges` and `OutEdges`, which are
878  // ordered set of edges with comparator `GenericEdge::equalGEdge()`,
879  // which need operands `src` and `dst` to be non-null to get IDs, so we
880  // need to fill nodes first.
881  edgePool.fillObjs(edgeFiller);
882  idToNodeMap.fillObjs(nodeFiller);
883  }
void fillObjs(FillFunc fillFunc)
void fillObjs(FillFunc fillFunc)

◆ getEdgePtr()

template<typename NodeTy , typename EdgeTy >
EdgeTy* SVF::GenericGraphReader< NodeTy, EdgeTy >::getEdgePtr ( unsigned  id) const
inline

Definition at line 869 of file SVFFileSystem.h.

870  {
871  return edgePool.getPtr(id);
872  }
T * getPtr(size_t id) const

◆ getFieldJson()

template<typename NodeTy , typename EdgeTy >
const cJSON* SVF::GenericGraphReader< NodeTy, EdgeTy >::getFieldJson ( ) const
inline

Definition at line 892 of file SVFFileSystem.h.

893  {
894  return graphFieldJson;
895  }

◆ getNodePtr()

template<typename NodeTy , typename EdgeTy >
NodeTy* SVF::GenericGraphReader< NodeTy, EdgeTy >::getNodePtr ( unsigned  id) const
inline

Definition at line 864 of file SVFFileSystem.h.

865  {
866  return idToNodeMap.getPtr(id);
867  }
T * getPtr(unsigned id) const

◆ saveToGenericGraph()

template<typename NodeTy , typename EdgeTy >
void SVF::GenericGraphReader< NodeTy, EdgeTy >::saveToGenericGraph ( GenericGraph< NodeTy, EdgeTy > *  graph) const
inline

Definition at line 885 of file SVFFileSystem.h.

886  {
887  graph->edgeNum = edgePool.size();
888  graph->nodeNum = idToNodeMap.size();
889  idToNodeMap.saveToIDToObjMap(graph->IDToNodeMap);
890  }
size_t size() const
void saveToIDToObjMap(Map &idToObjMap) const
size_t size() const

Member Data Documentation

◆ edgePool

template<typename NodeTy , typename EdgeTy >
ReaderPtrPool<EdgeTy> SVF::GenericGraphReader< NodeTy, EdgeTy >::edgePool
private

Definition at line 825 of file SVFFileSystem.h.

◆ graphFieldJson

template<typename NodeTy , typename EdgeTy >
const cJSON* SVF::GenericGraphReader< NodeTy, EdgeTy >::graphFieldJson = nullptr
protected

Definition at line 828 of file SVFFileSystem.h.

◆ idToNodeMap

template<typename NodeTy , typename EdgeTy >
ReaderIDToObjMap<NodeTy> SVF::GenericGraphReader< NodeTy, EdgeTy >::idToNodeMap
private

Definition at line 824 of file SVFFileSystem.h.


The documentation for this class was generated from the following files: