1 package Analysis.Pointer;
2 import Analysis.Disjoint.PointerMethod;
6 public class BasicBlock {
10 public BasicBlock(BBlock start, BBlock exit) {
15 public BBlock getStart() {
19 public BBlock getExit() {
23 public static class BBlock {
24 Vector<FlatNode> nodes;
29 nodes=new Vector<FlatNode>();
30 prevb=new Vector<BBlock>();
31 nextb=new Vector<BBlock>();
34 public Vector<FlatNode> nodes() {
37 public Vector<BBlock> next() {
40 public Vector<BBlock> prev() {
45 public static BasicBlock getBBlock(FlatMethod fm) {
47 Stack<FlatNode> toprocess=new Stack<FlatNode>();
48 HashMap<FlatNode, BBlock> map=new HashMap<FlatNode, BBlock>();
49 PointerMethod pm=new PointerMethod();
52 map.put(fm, new BBlock());
54 while(!toprocess.isEmpty()) {
55 FlatNode fn=toprocess.pop();
56 BBlock block=map.get(fn);
58 if (fn.kind()==FKind.FlatExit)
61 if (pm.numNext(fn)!=1) {
62 for(int i=0;i<pm.numNext(fn);i++) {
63 FlatNode fnext=pm.getNext(fn,i);
64 if (!map.containsKey(fnext)) {
65 map.put(fn, new BBlock());
69 if (!block.nextb.contains(map.get(fn))) {
70 block.nextb.add(map.get(fn));
71 map.get(fn).prevb.add(block);
79 if (!map.containsKey(fn)) {
80 map.put(fn, new BBlock());
84 if (!block.nextb.contains(map.get(fn))) {
85 block.nextb.add(map.get(fn));
86 map.get(fn).prevb.add(block);
94 return new BasicBlock(map.get(fm), exit);