MCPcopy Create free account
hub / github.com/LFYSec/MScan / AbstractCFG

Class AbstractCFG

src/main/java/pascal/taie/analysis/graph/cfg/AbstractCFG.java:36–158  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34import java.util.Set;
35
36abstract class AbstractCFG<N> implements CFG<N> {
37
38 protected final IR ir;
39
40 protected N entry;
41
42 protected N exit;
43
44 protected final Set<N> nodes;
45
46 private final MultiMap<N, CFGEdge<N>> inEdges;
47
48 private final MultiMap<N, CFGEdge<N>> outEdges;
49
50 AbstractCFG(IR ir) {
51 this.ir = ir;
52 // number of nodes = number of statements in IR + entry + exit
53 int nNodes = ir.getStmts().size() + 2;
54 nodes = Sets.newSet(nNodes);
55 inEdges = Maps.newMultiMap(nNodes);
56 outEdges = Maps.newMultiMap(nNodes);
57 }
58
59 @Override
60 public IR getIR() {
61 return ir;
62 }
63
64 @Override
65 public JMethod getMethod() {
66 return ir.getMethod();
67 }
68
69 void setEntry(N entry) {
70 assert this.entry == null : "CFG entry should be set only once";
71 this.entry = entry;
72 nodes.add(entry);
73 }
74
75 @Override
76 public N getEntry() {
77 return entry;
78 }
79
80 void setExit(N exit) {
81 assert this.exit == null : "CFG exit should be set only once";
82 this.exit = exit;
83 nodes.add(exit);
84 }
85
86 @Override
87 public N getExit() {
88 return exit;
89 }
90
91 @Override
92 public boolean isEntry(N node) {
93 return node == entry;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected