1 19 20 package soot.util.cfgcmd; 21 22 import soot.Body; 23 import soot.jimple.Jimple; 24 import soot.jimple.JimpleBody; 25 import soot.baf.Baf; 26 import soot.grimp.Grimp; 27 import soot.shimple.Shimple; 28 29 36 public abstract class CFGIntermediateRep extends CFGOptionMatcher.CFGOption { 37 38 private CFGIntermediateRep(String name) { 39 super(name); 40 } 41 42 52 public abstract Body getBody(JimpleBody b); 53 54 55 public static final CFGIntermediateRep JIMPLE_IR = new CFGIntermediateRep("jimple") { 56 public Body getBody(JimpleBody b) { 57 return b; 58 } 59 }; 60 61 public static final CFGIntermediateRep BAF_IR = new CFGIntermediateRep("baf") { 62 public Body getBody(JimpleBody b) { 63 return Baf.v().newBody(b); 64 } 65 }; 66 67 public static final CFGIntermediateRep GRIMP_IR = new CFGIntermediateRep("grimp") { 68 public Body getBody(JimpleBody b) { 69 return Grimp.v().newBody(b, "gb"); 70 } 71 }; 72 73 public static final CFGIntermediateRep SHIMPLE_IR = new CFGIntermediateRep("shimple") { 74 public Body getBody(JimpleBody b) { 75 return Shimple.v().newBody(b); 76 } 77 }; 78 79 public static final CFGIntermediateRep VIA_SHIMPLE_JIMPLE_IR = 80 new CFGIntermediateRep("viaShimpleJimple") { 81 public Body getBody(JimpleBody b) { 82 return Shimple.v().newJimpleBody(Shimple.v().newBody(b)); 83 } 84 }; 85 86 private final static CFGOptionMatcher irOptions = 87 new CFGOptionMatcher(new CFGIntermediateRep[] { 88 JIMPLE_IR, 89 BAF_IR, 90 GRIMP_IR, 91 SHIMPLE_IR, 92 VIA_SHIMPLE_JIMPLE_IR, 93 }); 94 95 106 public static CFGIntermediateRep getIR(String name) { 107 return (CFGIntermediateRep) irOptions.match(name); 108 } 109 110 128 public static String help(int initialIndent, int rightMargin, 129 int hangingIndent) { 130 return irOptions.help(initialIndent, rightMargin, hangingIndent); 131 } 132 133 } 134 135 136 | Popular Tags |