proj_name
stringclasses 131
values | relative_path
stringlengths 30
228
| class_name
stringlengths 1
68
| func_name
stringlengths 1
48
| masked_class
stringlengths 78
9.82k
| func_body
stringlengths 46
9.61k
| len_input
int64 29
2.01k
| len_output
int64 14
1.94k
| total
int64 55
2.05k
| relevant_context
stringlengths 0
38.4k
|
|---|---|---|---|---|---|---|---|---|---|
soot-oss_soot
|
soot/src/main/java/soot/javaToJimple/jj/ast/JjBinary_c.java
|
JjBinary_c
|
childExpectedType
|
class JjBinary_c extends Binary_c {
public JjBinary_c(Position pos, Expr left, Binary.Operator op, Expr right) {
super(pos, left, op, right);
}
public Type childExpectedType(Expr child, AscriptionVisitor av) {<FILL_FUNCTION_BODY>}
/*
* public Node foldConstants(ConstantFolder cf) { if (left instanceof Binary || left instanceof Field){ left =
* left.del.foldConstants(cf); } if (right instanceof Binary || right instanceof Field){ right =
* right.del.foldConstants(cf); } if (left instanceof StringLit && right instanceof StringLit) { String l = ((StringLit)
* left).value(); String r = ((StringLit) right).value(); if (op == ADD) return nf.StringLit(position(), l + r); } else if
* (left instanceof }
*/
}
|
Expr other;
// System.out.println("child: "+child+" op: "+op);
if (child == left) {
other = right;
} else if (child == right) {
other = left;
} else {
return child.type();
}
TypeSystem ts = av.typeSystem();
if (op == EQ || op == NE) {
// Coercion to compatible types.
if (other.type().isReference() || other.type().isNull()) {
return ts.Object();
}
if (other.type().isBoolean()) {
return ts.Boolean();
}
if (other.type().isNumeric()) {
if (other.type().isDouble() || child.type().isDouble()) {
return ts.Double();
} else if (other.type().isFloat() || child.type().isFloat()) {
return ts.Float();
} else if (other.type().isLong() || child.type().isLong()) {
return ts.Long();
} else {
return ts.Int();
}
}
}
if (op == ADD && ts.equals(type, ts.String())) {
// Implicit coercion to String.
return ts.String();
}
if (op == GT || op == LT || op == GE || op == LE) {
if (other.type().isBoolean()) {
return ts.Boolean();
}
if (other.type().isNumeric()) {
if (other.type().isDouble() || child.type().isDouble()) {
return ts.Double();
} else if (other.type().isFloat() || child.type().isFloat()) {
return ts.Float();
} else if (other.type().isLong() || child.type().isLong()) {
return ts.Long();
} else {
return ts.Int();
}
}
}
if (op == COND_OR || op == COND_AND) {
return ts.Boolean();
}
if (op == BIT_AND || op == BIT_OR || op == BIT_XOR) {
if (other.type().isBoolean()) {
return ts.Boolean();
}
if (other.type().isNumeric()) {
if (other.type().isLong() || child.type().isLong()) {
return ts.Long();
} else {
return ts.Int();
}
}
}
if (op == ADD || op == SUB || op == MUL || op == DIV || op == MOD) {
// System.out.println("other: "+other+" type: "+other.type());
// System.out.println("child: "+child+" child: "+child.type());
if (other.type().isNumeric()) {
if (other.type().isDouble() || child.type().isDouble()) {
return ts.Double();
} else if (other.type().isFloat() || child.type().isFloat()) {
return ts.Float();
} else if (other.type().isLong() || child.type().isLong()) {
return ts.Long();
} else {
return ts.Int();
}
}
}
if (op == SHL || op == SHR || op == USHR) {
if (child == right || !child.type().isLong()) {
return ts.Int();
} else {
return child.type();
}
}
return child.type();
| 233
| 905
| 1,138
|
<methods>public void <init>(polyglot.util.Position, polyglot.ast.Expr, polyglot.ast.Binary.Operator, polyglot.ast.Expr) ,public List#RAW acceptCFG(polyglot.visit.CFGBuilder, List#RAW) ,public polyglot.types.Type childExpectedType(polyglot.ast.Expr, polyglot.visit.AscriptionVisitor) ,public java.lang.Object constantValue() ,public void dump(polyglot.util.CodeWriter) ,public polyglot.ast.Term entry() ,public boolean isConstant() ,public polyglot.ast.Expr left() ,public polyglot.ast.Binary left(polyglot.ast.Expr) ,public polyglot.ast.Binary.Operator operator() ,public polyglot.ast.Binary operator(polyglot.ast.Binary.Operator) ,public polyglot.ast.Precedence precedence() ,public polyglot.ast.Binary precedence(polyglot.ast.Precedence) ,public void prettyPrint(polyglot.util.CodeWriter, polyglot.visit.PrettyPrinter) ,public polyglot.ast.Expr right() ,public polyglot.ast.Binary right(polyglot.ast.Expr) ,public List#RAW throwTypes(polyglot.types.TypeSystem) ,public boolean throwsArithmeticException() ,public java.lang.String toString() ,public polyglot.ast.Node typeCheck(polyglot.visit.TypeChecker) throws polyglot.types.SemanticException,public polyglot.ast.Node visitChildren(polyglot.visit.NodeVisitor) <variables>protected polyglot.ast.Expr left,protected polyglot.ast.Binary.Operator op,protected polyglot.ast.Precedence precedence,protected polyglot.ast.Expr right
|
soot-oss_soot
|
soot/src/main/java/soot/javaToJimple/jj/ast/JjLocalAssign_c.java
|
JjLocalAssign_c
|
childExpectedType
|
class JjLocalAssign_c extends LocalAssign_c {
public JjLocalAssign_c(Position pos, Local left, Operator op, Expr right) {
super(pos, left, op, right);
}
public Type childExpectedType(Expr child, AscriptionVisitor av) {<FILL_FUNCTION_BODY>}
}
|
if (op == SHL_ASSIGN || op == SHR_ASSIGN || op == USHR_ASSIGN) {
// System.out.println("local assign: child type: "+child.type()+" child: "+child);
return child.type();
}
if (child == right) {
return left.type();
}
return child.type();
| 91
| 100
| 191
|
<methods>public void <init>(polyglot.util.Position, polyglot.ast.Local, polyglot.ast.Assign.Operator, polyglot.ast.Expr) ,public polyglot.ast.Term entry() ,public polyglot.ast.Assign left(polyglot.ast.Expr) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/javaToJimple/jj/ast/JjUnary_c.java
|
JjUnary_c
|
childExpectedType
|
class JjUnary_c extends Unary_c {
public JjUnary_c(Position pos, Unary.Operator op, Expr expr) {
super(pos, op, expr);
}
public Type childExpectedType(Expr child, AscriptionVisitor av) {<FILL_FUNCTION_BODY>}
}
|
TypeSystem ts = av.typeSystem();
if (child == expr) {
if (op == POST_INC || op == POST_DEC || op == PRE_INC || op == PRE_DEC) {
// if (child.type().isByte() || child.type().isShort()){// || child.type().isChar()) {
// return ts.Int();
// }
return child.type();
} else if (op == NEG || op == POS) {
// if (child.type().isByte() || child.type().isShort() || child.type().isChar()) {
// return ts.Int();
// }
return child.type();
} else if (op == BIT_NOT) {
// if (child.type().isByte() || child.type().isShort() || child.type().isChar()) {
// return ts.Int();
// }
return child.type();
} else if (op == NOT) {
return ts.Boolean();
}
}
return child.type();
| 87
| 270
| 357
|
<methods>public void <init>(polyglot.util.Position, polyglot.ast.Unary.Operator, polyglot.ast.Expr) ,public List#RAW acceptCFG(polyglot.visit.CFGBuilder, List#RAW) ,public polyglot.types.Type childExpectedType(polyglot.ast.Expr, polyglot.visit.AscriptionVisitor) ,public java.lang.Object constantValue() ,public polyglot.ast.Term entry() ,public polyglot.ast.Expr expr() ,public polyglot.ast.Unary expr(polyglot.ast.Expr) ,public boolean isConstant() ,public polyglot.ast.Unary.Operator operator() ,public polyglot.ast.Unary operator(polyglot.ast.Unary.Operator) ,public polyglot.ast.Precedence precedence() ,public void prettyPrint(polyglot.util.CodeWriter, polyglot.visit.PrettyPrinter) ,public java.lang.String toString() ,public polyglot.ast.Node typeCheck(polyglot.visit.TypeChecker) throws polyglot.types.SemanticException,public polyglot.ast.Node visitChildren(polyglot.visit.NodeVisitor) <variables>protected polyglot.ast.Expr expr,protected polyglot.ast.Unary.Operator op
|
soot-oss_soot
|
soot/src/main/java/soot/javaToJimple/toolkits/CondTransformer.java
|
CondTransformer
|
transformBody
|
class CondTransformer extends BodyTransformer {
private static final Logger logger = LoggerFactory.getLogger(CondTransformer.class);
public CondTransformer(Singletons.Global g) {
}
public static CondTransformer v() {
return G.v().soot_javaToJimple_toolkits_CondTransformer();
}
private static final int SEQ_LENGTH = 6;
private Stmt[] stmtSeq = new Stmt[SEQ_LENGTH];
private boolean sameGoto = true;
protected void internalTransform(Body b, String phaseName, Map options) {
// logger.debug("running cond and/or transformer");
boolean change = true;
/*
* the idea is to look for groups of statements of the form if cond goto L0 if cond goto L0 z0 = 1 goto L1 L0: z0 = 0 L1:
* if z0 == 0 goto L2 conseq L2: altern
*
* and transform to if cond goto L0 if cond goto L0 conseq L0: altern
*
*/
while (change) {
Iterator it = b.getUnits().iterator();
int pos = 0;
while (it.hasNext()) {
change = false;
Stmt s = (Stmt) it.next();
if (testStmtSeq(s, pos)) {
pos++;
}
if (pos == 6) {
// found seq now transform then continue
// logger.debug("found sequence will transform");
change = true;
break;
}
}
if (change) {
transformBody(b, (Stmt) it.next());
pos = 0;
stmtSeq = new Stmt[SEQ_LENGTH];
}
}
}
private void transformBody(Body b, Stmt next) {<FILL_FUNCTION_BODY>}
private boolean testStmtSeq(Stmt s, int pos) {
switch (pos) {
case 0: {
if (s instanceof IfStmt) {
stmtSeq[pos] = s;
return true;
}
break;
}
case 1: {
if (s instanceof IfStmt) {
if (sameTarget(stmtSeq[pos - 1], s)) {
stmtSeq[pos] = s;
return true;
}
}
break;
}
case 2: {
if (s instanceof AssignStmt) {
stmtSeq[pos] = s;
if ((((AssignStmt) s).getRightOp() instanceof IntConstant)
&& (((IntConstant) ((AssignStmt) s).getRightOp())).value == 0) {
sameGoto = false;
}
return true;
}
break;
}
case 3: {
if (s instanceof GotoStmt) {
stmtSeq[pos] = s;
return true;
}
break;
}
case 4: {
if (s instanceof AssignStmt) {
if (isTarget(((IfStmt) stmtSeq[0]).getTarget(), s) && sameLocal(stmtSeq[2], s)) {
stmtSeq[pos] = s;
return true;
}
}
break;
}
case 5: {
if (s instanceof IfStmt) {
if (isTarget((Stmt) ((GotoStmt) stmtSeq[3]).getTarget(), s) && sameCondLocal(stmtSeq[4], s)
&& (((IfStmt) s).getCondition() instanceof EqExpr)) {
stmtSeq[pos] = s;
return true;
} else if (isTarget((Stmt) ((GotoStmt) stmtSeq[3]).getTarget(), s) && sameCondLocal(stmtSeq[4], s)) {
stmtSeq[pos] = s;
sameGoto = false;
return true;
}
}
break;
}
default: {
break;
}
}
return false;
}
private boolean sameTarget(Stmt s1, Stmt s2) {
IfStmt is1 = (IfStmt) s1;
IfStmt is2 = (IfStmt) s2;
if (is1.getTarget().equals(is2.getTarget())) {
return true;
}
return false;
}
private boolean isTarget(Stmt s1, Stmt s) {
if (s1.equals(s)) {
return true;
}
return false;
}
private boolean sameLocal(Stmt s1, Stmt s2) {
AssignStmt as1 = (AssignStmt) s1;
AssignStmt as2 = (AssignStmt) s2;
if (as1.getLeftOp().equals(as2.getLeftOp())) {
return true;
}
return false;
}
private boolean sameCondLocal(Stmt s1, Stmt s2) {
AssignStmt as1 = (AssignStmt) s1;
IfStmt is2 = (IfStmt) s2;
if (is2.getCondition() instanceof BinopExpr) {
BinopExpr bs2 = (BinopExpr) is2.getCondition();
if (as1.getLeftOp().equals(bs2.getOp1())) {
return true;
}
}
return false;
}
}
|
// change target of stmts 0 and 1 to target of stmt 5
// remove stmts 2, 3, 4, 5
Stmt newTarget = null;
Stmt oldTarget = null;
if (sameGoto) {
newTarget = ((IfStmt) stmtSeq[5]).getTarget();
} else {
newTarget = next;
oldTarget = ((IfStmt) stmtSeq[5]).getTarget();
}
((IfStmt) stmtSeq[0]).setTarget(newTarget);
((IfStmt) stmtSeq[1]).setTarget(newTarget);
for (int i = 2; i <= 5; i++) {
b.getUnits().remove(stmtSeq[i]);
}
if (!sameGoto) {
b.getUnits().insertAfter(Jimple.v().newGotoStmt(oldTarget), stmtSeq[1]);
}
| 1,423
| 250
| 1,673
|
<methods>public non-sealed void <init>() ,public final void transform(soot.Body, java.lang.String, Map<java.lang.String,java.lang.String>) ,public final void transform(soot.Body, java.lang.String) ,public final void transform(soot.Body) <variables>private static final Map<java.lang.String,java.lang.String> enabledOnlyMap
|
soot-oss_soot
|
soot/src/main/java/soot/jbco/bafTransformations/BAFCounter.java
|
BAFCounter
|
internalTransform
|
class BAFCounter extends BodyTransformer implements IJbcoTransform {
static int count = 0;
public static String dependancies[] = new String[] { "bb.jbco_counter" };
public String[] getDependencies() {
return dependancies;
}
public static String name = "bb.jbco_counter";
public String getName() {
return name;
}
public void outputSummary() {
out.println("Count: " + count);
}
protected void internalTransform(Body b, String phaseName, Map<String, String> options) {<FILL_FUNCTION_BODY>}
}
|
for (Unit u : b.getUnits()) {
if (u instanceof TargetArgInst && !(u instanceof GotoInst) && !(u instanceof JSRInst)) {
count++;
}
}
| 164
| 56
| 220
|
<methods>public non-sealed void <init>() ,public final void transform(soot.Body, java.lang.String, Map<java.lang.String,java.lang.String>) ,public final void transform(soot.Body, java.lang.String) ,public final void transform(soot.Body) <variables>private static final Map<java.lang.String,java.lang.String> enabledOnlyMap
|
soot-oss_soot
|
soot/src/main/java/soot/jbco/bafTransformations/BAFPrintout.java
|
BAFPrintout
|
internalTransform
|
class BAFPrintout extends BodyTransformer implements IJbcoTransform {
public static String name = "bb.printout";
public void outputSummary() {
}
public String[] getDependencies() {
return new String[0];
}
public String getName() {
return name;
}
static boolean stack = false;
public BAFPrintout() {
}
public BAFPrintout(String newname, boolean print_stack) {
name = newname;
stack = print_stack;
}
protected void internalTransform(Body b, String phaseName, Map<String, String> options) {<FILL_FUNCTION_BODY>}
}
|
// if (b.getMethod().getSignature().indexOf("run")<0) return;
System.out.println("\n" + b.getMethod().getSignature());
if (stack) {
Map<Unit, Stack<Type>> stacks = null;
Map<Local, Local> b2j = soot.jbco.Main.methods2Baf2JLocals.get(b.getMethod());
try {
if (b2j == null) {
stacks = StackTypeHeightCalculator.calculateStackHeights(b);
} else {
stacks = StackTypeHeightCalculator.calculateStackHeights(b, b2j);
}
StackTypeHeightCalculator.printStack(b.getUnits(), stacks, true);
} catch (Exception exc) {
System.out.println("\n**************Exception calculating height " + exc + ", printing plain bytecode now\n\n");
soot.jbco.util.Debugger.printUnits(b, " FINAL");
}
} else {
soot.jbco.util.Debugger.printUnits(b, " FINAL");
}
System.out.println();
| 179
| 303
| 482
|
<methods>public non-sealed void <init>() ,public final void transform(soot.Body, java.lang.String, Map<java.lang.String,java.lang.String>) ,public final void transform(soot.Body, java.lang.String) ,public final void transform(soot.Body) <variables>private static final Map<java.lang.String,java.lang.String> enabledOnlyMap
|
soot-oss_soot
|
soot/src/main/java/soot/jbco/bafTransformations/ConstructorConfuser.java
|
ConstructorConfuser
|
internalTransform
|
class ConstructorConfuser extends BodyTransformer implements IJbcoTransform {
static int count = 0;
static int instances[] = new int[4];
public static String dependancies[] = new String[] { "bb.jbco_dcc", "bb.jbco_ful", "bb.lp" };
public String[] getDependencies() {
return dependancies;
}
public static String name = "bb.jbco_dcc";
public String getName() {
return name;
}
public void outputSummary() {
out.println("Constructor methods have been jumbled: " + count);
}
@SuppressWarnings("fallthrough")
protected void internalTransform(Body b, String phaseName, Map<String, String> options) {<FILL_FUNCTION_BODY>}
}
|
if (!b.getMethod().getSubSignature().equals("void <init>()")) {
return;
}
int weight = soot.jbco.Main.getWeight(phaseName, b.getMethod().getSignature());
if (weight == 0) {
return;
}
SootClass origClass = b.getMethod().getDeclaringClass();
SootClass c = origClass;
if (c.hasSuperclass()) {
c = c.getSuperclass();
} else {
c = null;
}
PatchingChain<Unit> units = b.getUnits();
Iterator<Unit> it = units.snapshotIterator();
Unit prev = null;
SpecialInvokeInst sii = null;
while (it.hasNext()) {
Unit u = (Unit) it.next();
if (u instanceof SpecialInvokeInst) {
sii = (SpecialInvokeInst) u;
SootMethodRef smr = sii.getMethodRef();
if (c == null || !smr.declaringClass().getName().equals(c.getName()) || !smr.name().equals("<init>")) {
sii = null;
} else {
break;
}
}
prev = u;
}
if (sii == null) {
return;
}
int lowi = -1, lowest = 99999999, rand = Rand.getInt(4);
for (int i = 0; i < instances.length; i++) {
if (lowest > instances[i]) {
lowest = instances[i];
lowi = i;
}
}
if (instances[rand] > instances[lowi]) {
rand = lowi;
}
boolean done = false;
switch (rand) {
case 0:
if (prev != null && prev instanceof LoadInst && sii.getMethodRef().parameterTypes().size() == 0
&& !BodyBuilder.isExceptionCaughtAt(units, sii, b.getTraps().iterator())) {
Local bl = ((LoadInst) prev).getLocal();
Map<Local, Local> locals = soot.jbco.Main.methods2Baf2JLocals.get(b.getMethod());
if (locals != null && locals.containsKey(bl)) {
Type t = ((Local) locals.get(bl)).getType();
if (t instanceof RefType && ((RefType) t).getSootClass().getName().equals(origClass.getName())) {
units.insertBefore(Baf.v().newDup1Inst(RefType.v()), sii);
Unit ifinst = Baf.v().newIfNullInst(sii);
units.insertBeforeNoRedirect(ifinst, sii);
units.insertAfter(Baf.v().newThrowInst(), ifinst);
units.insertAfter(Baf.v().newPushInst(NullConstant.v()), ifinst);
Unit pop = Baf.v().newPopInst(RefType.v());
units.add(pop);
units.add((Unit) prev.clone());
b.getTraps().add(Baf.v().newTrap(ThrowSet.getRandomThrowable(), ifinst, sii, pop));
if (Rand.getInt() % 2 == 0) {
pop = (Unit) pop.clone();
units.insertBefore(pop, sii);
units.insertBefore(Baf.v().newGotoInst(sii), pop);
units.add(Baf.v().newJSRInst(pop));
} else {
units.add(Baf.v().newGotoInst(sii));
}
done = true;
break;
}
}
}
case 1:
if (!BodyBuilder.isExceptionCaughtAt(units, sii, b.getTraps().iterator())) {
Unit handler = Baf.v().newThrowInst();
units.add(handler);
b.getTraps().add(Baf.v().newTrap(ThrowSet.getRandomThrowable(), sii, (Unit) units.getSuccOf(sii), handler));
done = true;
break;
}
case 2:
if (sii.getMethodRef().parameterTypes().size() == 0
&& !BodyBuilder.isExceptionCaughtAt(units, sii, b.getTraps().iterator())) {
while (c != null) {
if (c.getName().equals("java.lang.Throwable")) {
Unit throwThis = Baf.v().newThrowInst();
units.insertBefore(throwThis, sii);
b.getTraps().add(Baf.v().newTrap(origClass, throwThis, sii, sii));
done = true;
break;
}
if (c.hasSuperclass()) {
c = c.getSuperclass();
} else {
c = null;
}
}
}
if (done) {
break;
}
case 3:
Unit pop = Baf.v().newPopInst(RefType.v());
units.insertBefore(pop, sii);
units.insertBeforeNoRedirect(Baf.v().newJSRInst(pop), pop);
done = true;
break;
}
if (done) {
instances[rand]++;
count++;
}
if (debug) {
StackTypeHeightCalculator.calculateStackHeights(b);
}
| 212
| 1,402
| 1,614
|
<methods>public non-sealed void <init>() ,public final void transform(soot.Body, java.lang.String, Map<java.lang.String,java.lang.String>) ,public final void transform(soot.Body, java.lang.String) ,public final void transform(soot.Body) <variables>private static final Map<java.lang.String,java.lang.String> enabledOnlyMap
|
soot-oss_soot
|
soot/src/main/java/soot/jbco/bafTransformations/FixUndefinedLocals.java
|
FixUndefinedLocals
|
internalTransform
|
class FixUndefinedLocals extends BodyTransformer implements IJbcoTransform {
private int undefined = 0;
public static String dependancies[] = new String[] { "bb.jbco_j2bl", "bb.jbco_ful", "bb.lp" };
public String[] getDependencies() {
return dependancies;
}
public static String name = "bb.jbco_ful";
public String getName() {
return name;
}
public void outputSummary() {
out.println("Undefined Locals fixed with pre-initializers: " + undefined);
}
protected void internalTransform(Body b, String phaseName, Map<String, String> options) {<FILL_FUNCTION_BODY>}
public static PushInst getPushInitializer(Local l, Type t) {
if (t instanceof IntegerType) {
return Baf.v().newPushInst(IntConstant.v(soot.jbco.util.Rand.getInt()));
} else if (t instanceof RefLikeType || t instanceof StmtAddressType) {
return Baf.v().newPushInst(NullConstant.v());
} else if (t instanceof LongType) {
return Baf.v().newPushInst(LongConstant.v(soot.jbco.util.Rand.getLong()));
} else if (t instanceof FloatType) {
return Baf.v().newPushInst(FloatConstant.v(soot.jbco.util.Rand.getFloat()));
} else if (t instanceof DoubleType) {
return Baf.v().newPushInst(DoubleConstant.v(soot.jbco.util.Rand.getDouble()));
}
return null;
}
/*
*
* private Unit findInitializerSpotFor(Value v, Unit u, UnitGraph ug, GuaranteedDefs gd) { List preds = ug.getPredsOf(u);
* while (preds.size() == 1) { Unit p = (Unit) preds.get(0); //if (p instanceof IdentityInst) // break;
*
* u = p; preds = ug.getPredsOf(u); }
*
* if (preds.size() <= 1) return u;
*
* ArrayList nodef = new ArrayList(); Iterator pIt = preds.iterator(); while (pIt.hasNext()) { Unit u1 = (Unit) pIt.next();
* if (!gd.getGuaranteedDefs(u1).contains(v)) { nodef.add(u1); } }
*
* if (nodef.size() == preds.size()) return u;
*
* if (nodef.size() == 1) return findInitializerSpotFor(v, (Unit) nodef.get(0), ug, gd);
*
* throw new RuntimeException("Shouldn't Ever Get Here!"); }
*/
}
|
// deal with locals not defined at all used points
int icount = 0;
boolean passedIDs = false;
Map<Local, Local> bafToJLocals = soot.jbco.Main.methods2Baf2JLocals.get(b.getMethod());
ArrayList<Value> initialized = new ArrayList<Value>();
PatchingChain<Unit> units = b.getUnits();
GuaranteedDefs gd = new GuaranteedDefs(ExceptionalUnitGraphFactory.createExceptionalUnitGraph(b));
Iterator<Unit> unitIt = units.snapshotIterator();
Unit after = null;
while (unitIt.hasNext()) {
Unit u = unitIt.next();
if (!passedIDs && u instanceof IdentityInst) {
Value v = ((IdentityInst) u).getLeftOp();
if (v instanceof Local) {
initialized.add(v);
icount++;
}
after = u;
continue;
}
passedIDs = true;
if (after == null) {
after = Baf.v().newNopInst();
units.addFirst(after);
}
List<?> defs = gd.getGuaranteedDefs(u);
Iterator<ValueBox> useIt = u.getUseBoxes().iterator();
while (useIt.hasNext()) {
Value v = ((ValueBox) useIt.next()).getValue();
if (!(v instanceof Local) || defs.contains(v) || initialized.contains(v)) {
continue;
}
Type t = null;
Local l = (Local) v;
Local jl = (Local) bafToJLocals.get(l);
if (jl != null) {
t = jl.getType();
} else {
// We should hopefully never get here. There should be a jimple
// local unless it's one of our ControlDups
t = l.getType();
if (u instanceof OpTypeArgInst) {
OpTypeArgInst ota = (OpTypeArgInst) u;
t = ota.getOpType();
} else if (u instanceof AbstractOpTypeInst) {
AbstractOpTypeInst ota = (AbstractOpTypeInst) u;
t = ota.getOpType();
} else if (u instanceof IncInst) {
t = IntType.v();
}
if (t instanceof DoubleWordType || t instanceof WordType) {
throw new RuntimeException("Shouldn't get here (t is a double or word type: in FixUndefinedLocals)");
}
}
Unit store = Baf.v().newStoreInst(t, l);
units.insertAfter(store, after);
// TODO: is this necessary if I fix the other casting issues?
if (t instanceof ArrayType) {
Unit tmp = Baf.v().newInstanceCastInst(t);
units.insertBefore(tmp, store);
store = tmp;
}
/////
Unit pinit = getPushInitializer(l, t);
units.insertBefore(pinit, store);
/*
* if (t instanceof RefType) { SootClass sc = ((RefType)t).getSootClass(); if (sc != null)
* units.insertAfter(Baf.v().newInstanceCastInst(t), pinit); }
*/
initialized.add(l);
}
}
if (after instanceof NopInst) {
units.remove(after);
}
undefined += initialized.size() - icount;
| 740
| 898
| 1,638
|
<methods>public non-sealed void <init>() ,public final void transform(soot.Body, java.lang.String, Map<java.lang.String,java.lang.String>) ,public final void transform(soot.Body, java.lang.String) ,public final void transform(soot.Body) <variables>private static final Map<java.lang.String,java.lang.String> enabledOnlyMap
|
soot-oss_soot
|
soot/src/main/java/soot/jbco/bafTransformations/IfNullToTryCatch.java
|
IfNullToTryCatch
|
internalTransform
|
class IfNullToTryCatch extends BodyTransformer implements IJbcoTransform {
int count = 0;
int totalifs = 0;
public static String dependancies[] = new String[] { "bb.jbco_riitcb", "bb.jbco_ful", "bb.lp" };
public String[] getDependencies() {
return dependancies;
}
public static String name = "bb.jbco_riitcb";
public String getName() {
return name;
}
public void outputSummary() {
out.println("If(Non)Nulls changed to traps: " + count);
out.println("Total ifs found: " + totalifs);
}
protected void internalTransform(Body b, String phaseName, Map<String, String> options) {<FILL_FUNCTION_BODY>}
}
|
int weight = soot.jbco.Main.getWeight(phaseName, b.getMethod().getSignature());
if (weight == 0) {
return;
}
SootClass exc = G.v().soot_Scene().getSootClass("java.lang.NullPointerException");
SootClass obj = G.v().soot_Scene().getSootClass("java.lang.Object");
SootMethod toStrg = obj.getMethodByName("toString");
SootMethod eq = obj.getMethodByName("equals");
boolean change = false;
PatchingChain<Unit> units = b.getUnits();
Iterator<Unit> uit = units.snapshotIterator();
while (uit.hasNext()) {
Unit u = uit.next();
if (BodyBuilder.isBafIf(u)) {
totalifs++;
}
if (u instanceof IfNullInst && Rand.getInt(10) <= weight) {
Unit targ = ((IfNullInst) u).getTarget();
Unit succ = units.getSuccOf(u);
Unit pop = Baf.v().newPopInst(RefType.v());
Unit popClone = (Unit) pop.clone();
units.insertBefore(pop, targ);
Unit gotoTarg = Baf.v().newGotoInst(targ);
units.insertBefore(gotoTarg, pop);
if (Rand.getInt(2) == 0) {
Unit methCall = Baf.v().newVirtualInvokeInst(toStrg.makeRef());
units.insertBefore(methCall, u);
if (Rand.getInt(2) == 0) {
units.remove(u);
units.insertAfter(popClone, methCall);
}
b.getTraps().add(Baf.v().newTrap(exc, methCall, succ, pop));
} else {
Unit throwu = Baf.v().newThrowInst();
units.insertBefore(throwu, u);
units.remove(u);
units.insertBefore(Baf.v().newPushInst(NullConstant.v()), throwu);
Unit ifunit = Baf.v().newIfCmpNeInst(RefType.v(), succ);
units.insertBefore(ifunit, throwu);
units.insertBefore(Baf.v().newPushInst(NullConstant.v()), throwu);
b.getTraps().add(Baf.v().newTrap(exc, throwu, succ, pop));
}
count++;
change = true;
} else if (u instanceof IfNonNullInst && Rand.getInt(10) <= weight) {
Unit targ = ((IfNonNullInst) u).getTarget();
Unit methCall = Baf.v().newVirtualInvokeInst(eq.makeRef());
units.insertBefore(methCall, u);
units.insertBefore(Baf.v().newPushInst(NullConstant.v()), methCall);
if (Rand.getInt(2) == 0) {
Unit pop = Baf.v().newPopInst(BooleanType.v());
units.insertBefore(pop, u);
Unit gotoTarg = Baf.v().newGotoInst(targ);
units.insertBefore(gotoTarg, u);
pop = Baf.v().newPopInst(RefType.v());
units.insertAfter(pop, u);
units.remove(u);
// add first, so it is always checked first in the exception table
b.getTraps().addFirst(Baf.v().newTrap(exc, methCall, gotoTarg, pop));
} else {
Unit iffalse = Baf.v().newIfEqInst(targ);
units.insertBefore(iffalse, u);
units.insertBefore(Baf.v().newPushInst(NullConstant.v()), u);
Unit pop = Baf.v().newPopInst(RefType.v());
units.insertAfter(pop, u);
units.remove(u);
// add first, so it is always checked first in the exception table
b.getTraps().addFirst(Baf.v().newTrap(exc, methCall, iffalse, pop));
}
count++;
change = true;
}
}
if (change && debug) {
StackTypeHeightCalculator.calculateStackHeights(b);
// StackTypeHeightCalculator.printStack(units, StackTypeHeightCalculator.calculateStackHeights(b), true)
}
| 220
| 1,154
| 1,374
|
<methods>public non-sealed void <init>() ,public final void transform(soot.Body, java.lang.String, Map<java.lang.String,java.lang.String>) ,public final void transform(soot.Body, java.lang.String) ,public final void transform(soot.Body) <variables>private static final Map<java.lang.String,java.lang.String> enabledOnlyMap
|
soot-oss_soot
|
soot/src/main/java/soot/jbco/bafTransformations/Jimple2BafLocalBuilder.java
|
Jimple2BafLocalBuilder
|
internalTransform
|
class Jimple2BafLocalBuilder extends BodyTransformer implements IJbcoTransform {
public static String dependancies[] = new String[] { "jtp.jbco_jl", "bb.jbco_j2bl", "bb.lp" };
public String[] getDependencies() {
return dependancies;
}
public static String name = "bb.jbco_j2bl";
public String getName() {
return name;
}
public void outputSummary() {
}
private static boolean runOnce = false;
protected void internalTransform(Body b, String phaseName, Map<String, String> options) {<FILL_FUNCTION_BODY>}
}
|
if (soot.jbco.Main.methods2JLocals.size() == 0) {
if (!runOnce) {
runOnce = true;
out.println("[Jimple2BafLocalBuilder]:: Jimple Local Lists have not been built");
out.println(" Skipping Jimple To Baf Builder\n");
}
return;
}
Collection<Local> bLocals = b.getLocals();
HashMap<Local, Local> bafToJLocals = new HashMap<Local, Local>();
Iterator<Local> jlocIt = soot.jbco.Main.methods2JLocals.get(b.getMethod()).iterator();
while (jlocIt.hasNext()) {
Local jl = jlocIt.next();
Iterator<Local> blocIt = bLocals.iterator();
while (blocIt.hasNext()) {
Local bl = (Local) blocIt.next();
if (bl.getName().equals(jl.getName())) {
bafToJLocals.put(bl, jl);
break;
}
}
}
soot.jbco.Main.methods2Baf2JLocals.put(b.getMethod(), bafToJLocals);
| 179
| 321
| 500
|
<methods>public non-sealed void <init>() ,public final void transform(soot.Body, java.lang.String, Map<java.lang.String,java.lang.String>) ,public final void transform(soot.Body, java.lang.String) ,public final void transform(soot.Body) <variables>private static final Map<java.lang.String,java.lang.String> enabledOnlyMap
|
soot-oss_soot
|
soot/src/main/java/soot/jbco/bafTransformations/RemoveRedundantPushStores.java
|
RemoveRedundantPushStores
|
internalTransform
|
class RemoveRedundantPushStores extends BodyTransformer implements IJbcoTransform {
public static String dependancies[] = new String[] { "bb.jbco_rrps" };
public String[] getDependencies() {
return dependancies;
}
public static String name = "bb.jbco_rrps";
public String getName() {
return name;
}
public void outputSummary() {
}
protected void internalTransform(Body b, String phaseName, Map<String, String> options) {<FILL_FUNCTION_BODY>}
private void fixJumps(Unit from, Unit to, Chain<Trap> t) {
from.redirectJumpsToThisTo(to);
for (Trap trap : t) {
if (trap.getBeginUnit() == from) {
trap.setBeginUnit(to);
}
if (trap.getEndUnit() == from) {
trap.setEndUnit(to);
}
if (trap.getHandlerUnit() == from) {
trap.setHandlerUnit(to);
}
}
}
}
|
// removes all redundant load-stores
boolean changed = true;
PatchingChain<Unit> units = b.getUnits();
while (changed) {
changed = false;
Unit prevprevprev = null, prevprev = null, prev = null;
ExceptionalUnitGraph eug = ExceptionalUnitGraphFactory.createExceptionalUnitGraph(b);
Iterator<Unit> it = units.snapshotIterator();
while (it.hasNext()) {
Unit u = it.next();
if (prev != null && prev instanceof PushInst && u instanceof StoreInst) {
if (prevprev != null && prevprev instanceof StoreInst && prevprevprev != null
&& prevprevprev instanceof PushInst) {
Local lprev = ((StoreInst) prevprev).getLocal();
Local l = ((StoreInst) u).getLocal();
if (l == lprev && eug.getSuccsOf(prevprevprev).size() == 1 && eug.getSuccsOf(prevprev).size() == 1) {
fixJumps(prevprevprev, prev, b.getTraps());
fixJumps(prevprev, u, b.getTraps());
units.remove(prevprevprev);
units.remove(prevprev);
changed = true;
break;
}
}
}
prevprevprev = prevprev;
prevprev = prev;
prev = u;
}
} // end while changes have been made
| 291
| 366
| 657
|
<methods>public non-sealed void <init>() ,public final void transform(soot.Body, java.lang.String, Map<java.lang.String,java.lang.String>) ,public final void transform(soot.Body, java.lang.String) ,public final void transform(soot.Body) <variables>private static final Map<java.lang.String,java.lang.String> enabledOnlyMap
|
soot-oss_soot
|
soot/src/main/java/soot/jbco/bafTransformations/WrapSwitchesInTrys.java
|
WrapSwitchesInTrys
|
internalTransform
|
class WrapSwitchesInTrys extends BodyTransformer implements IJbcoTransform {
int totaltraps = 0;
public static String dependancies[] = new String[] { "bb.jbco_ptss", "bb.jbco_ful", "bb.lp" };
public String[] getDependencies() {
return dependancies;
}
public static String name = "bb.jbco_ptss";
public String getName() {
return name;
}
public void outputSummary() {
out.println("Switches wrapped in Tries: " + totaltraps);
}
protected void internalTransform(Body b, String phaseName, Map<String, String> options) {<FILL_FUNCTION_BODY>}
}
|
int weight = soot.jbco.Main.getWeight(phaseName, b.getMethod().getSignature());
if (weight == 0) {
return;
}
int i = 0;
Unit handler = null;
Chain<Trap> traps = b.getTraps();
PatchingChain<Unit> units = b.getUnits();
Iterator<Unit> it = units.snapshotIterator();
while (it.hasNext()) {
Unit u = (Unit) it.next();
if (u instanceof TableSwitchInst) {
TableSwitchInst twi = (TableSwitchInst) u;
if (!BodyBuilder.isExceptionCaughtAt(units, twi, traps.iterator()) && Rand.getInt(10) <= weight) {
if (handler == null) {
Iterator<Unit> uit = units.snapshotIterator();
while (uit.hasNext()) {
Unit uthrow = (Unit) uit.next();
if (uthrow instanceof ThrowInst && !BodyBuilder.isExceptionCaughtAt(units, uthrow, traps.iterator())) {
handler = uthrow;
break;
}
}
if (handler == null) {
handler = Baf.v().newThrowInst();
units.add(handler);
}
}
int size = 4;
Unit succ = (Unit) units.getSuccOf(twi);
while (!BodyBuilder.isExceptionCaughtAt(units, succ, traps.iterator()) && size-- > 0) {
Object o = units.getSuccOf(succ);
if (o != null) {
succ = (Unit) o;
} else {
break;
}
}
traps.add(Baf.v().newTrap(ThrowSet.getRandomThrowable(), twi, succ, handler));
i++;
}
}
}
totaltraps += i;
if (i > 0 && debug) {
StackTypeHeightCalculator.calculateStackHeights(b);
}
| 193
| 527
| 720
|
<methods>public non-sealed void <init>() ,public final void transform(soot.Body, java.lang.String, Map<java.lang.String,java.lang.String>) ,public final void transform(soot.Body, java.lang.String) ,public final void transform(soot.Body) <variables>private static final Map<java.lang.String,java.lang.String> enabledOnlyMap
|
soot-oss_soot
|
soot/src/main/java/soot/jbco/jimpleTransformations/CollectConstants.java
|
CollectConstants
|
addInitializingValue
|
class CollectConstants extends SceneTransformer implements IJbcoTransform {
private static final Logger logger = LoggerFactory.getLogger(FieldRenamer.class);
public static final String name = "wjtp.jbco_cc";
private final Map<Type, List<Constant>> typeToConstants = new HashMap<>();
public static HashMap<Constant, SootField> constantsToFields = new HashMap<>();
private int constants = 0;
private int updatedConstants = 0;
@Override
public String getName() {
return name;
}
@Override
public String[] getDependencies() {
return new String[] { name };
}
@Override
public void outputSummary() {
logger.info("Found {} constants, updated {} ones", constants, updatedConstants);
}
@Override
protected void internalTransform(String phaseName, Map<String, String> options) {
if (isVerbose()) {
logger.info("Collecting Constant Data");
}
BodyBuilder.retrieveAllNames();
final Chain<SootClass> applicationClasses = Scene.v().getApplicationClasses();
for (SootClass applicationClass : applicationClasses) {
for (SootMethod method : applicationClass.getMethods()) {
if (!method.hasActiveBody() || method.getName().contains(SootMethod.staticInitializerName)) {
continue;
}
for (ValueBox useBox : method.getActiveBody().getUseBoxes()) {
final Value value = useBox.getValue();
if (value instanceof Constant) {
final Constant constant = (Constant) value;
Type type = constant.getType();
List<Constant> constants = typeToConstants.computeIfAbsent(type, t -> new ArrayList<>());
if (!constants.contains(constant)) {
this.constants++;
constants.add(constant);
}
}
}
}
}
int count = 0;
String name = "newConstantJbcoName";
SootClass[] classes = applicationClasses.toArray(new SootClass[applicationClasses.size()]);
for (Type type : typeToConstants.keySet()) {
if (type instanceof NullType) {
continue; // type = RefType.v("java.lang.Object");
}
for (Constant constant : typeToConstants.get(type)) {
name += "_";
SootClass randomClass;
do {
randomClass = classes[Rand.getInt(classes.length)];
} while (!isSuitableClassToAddFieldConstant(randomClass, constant));
final SootField newField
= Scene.v().makeSootField(FieldRenamer.v().getOrAddNewName(name), type, Modifier.STATIC ^ Modifier.PUBLIC);
randomClass.addField(newField);
constantsToFields.put(constant, newField);
addInitializingValue(randomClass, newField, constant);
count++;
}
}
updatedConstants += count;
}
private boolean isSuitableClassToAddFieldConstant(SootClass sc, Constant constant) {
if (sc.isInterface()) {
return false;
}
if (constant instanceof ClassConstant) {
ClassConstant classConstant = (ClassConstant) constant;
RefType type = (RefType) classConstant.toSootType();
SootClass classFromConstant = type.getSootClass();
Hierarchy hierarchy = Scene.v().getActiveHierarchy();
return hierarchy.isVisible(sc, classFromConstant);
}
return true;
}
private void addInitializingValue(SootClass sc, SootField f, Constant constant) {<FILL_FUNCTION_BODY>}
}
|
if (constant instanceof NullConstant) {
return;
} else if (constant instanceof IntConstant) {
if (((IntConstant) constant).value == 0) {
return;
}
} else if (constant instanceof LongConstant) {
if (((LongConstant) constant).value == 0) {
return;
}
} else if (constant instanceof StringConstant) {
if (((StringConstant) constant).value == null) {
return;
}
} else if (constant instanceof DoubleConstant) {
if (((DoubleConstant) constant).value == 0) {
return;
}
} else if (constant instanceof FloatConstant) {
if (((FloatConstant) constant).value == 0) {
return;
}
}
Body b;
boolean newInit = false;
if (!sc.declaresMethodByName(SootMethod.staticInitializerName)) {
SootMethod m = Scene.v().makeSootMethod(SootMethod.staticInitializerName, emptyList(), VoidType.v(), Modifier.STATIC);
sc.addMethod(m);
b = Jimple.v().newBody(m);
m.setActiveBody(b);
newInit = true;
} else {
SootMethod m = sc.getMethodByName(SootMethod.staticInitializerName);
if (!m.hasActiveBody()) {
b = Jimple.v().newBody(m);
m.setActiveBody(b);
newInit = true;
} else {
b = m.getActiveBody();
}
}
PatchingChain<Unit> units = b.getUnits();
units.addFirst(Jimple.v().newAssignStmt(Jimple.v().newStaticFieldRef(f.makeRef()), constant));
if (newInit) {
units.addLast(Jimple.v().newReturnVoidStmt());
}
| 942
| 486
| 1,428
|
<methods>public non-sealed void <init>() ,public final void transform(java.lang.String, Map<java.lang.String,java.lang.String>) ,public final void transform(java.lang.String) ,public final void transform() <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/jbco/jimpleTransformations/GotoInstrumenter.java
|
GotoInstrumenter
|
internalTransform
|
class GotoInstrumenter extends BodyTransformer implements IJbcoTransform {
private static final Logger logger = LoggerFactory.getLogger(GotoInstrumenter.class);
public static final String name = "jtp.jbco_gia";
public static final String dependencies[] = new String[] { GotoInstrumenter.name };
private int trapsAdded = 0;
private int gotosInstrumented = 0;
private static final UnitBox[] EMPTY_UNIT_BOX_ARRAY = new UnitBox[0];
private static final int MAX_TRIES_TO_GET_REORDER_COUNT = 10;
@Override
public String getName() {
return name;
}
@Override
public String[] getDependencies() {
return Arrays.copyOf(dependencies, dependencies.length);
}
@Override
public void outputSummary() {
logger.info("Instrumented {} GOTOs, added {} traps.", gotosInstrumented, trapsAdded);
}
@Override
protected void internalTransform(Body body, String phaseName, Map<String, String> options) {<FILL_FUNCTION_BODY>}
private static boolean isExceptionCaught(Unit unit, Chain<Unit> units, Chain<Trap> traps) {
for (Trap trap : traps) {
final Unit end = trap.getEndUnit();
if (end.equals(unit)) {
return true;
}
final Iterator<Unit> unitsInTryIterator = units.iterator(trap.getBeginUnit(), units.getPredOf(end));
if (Iterators.contains(unitsInTryIterator, unit)) {
return true;
}
}
return false;
}
}
|
if (SootMethod.constructorName.equals(body.getMethod().getName())
|| SootMethod.staticInitializerName.equals(body.getMethod().getName())) {
if (isVerbose()) {
logger.info("Skipping {} method GOTO instrumentation as it is constructor/initializer.",
body.getMethod().getSignature());
}
return;
}
if (soot.jbco.Main.getWeight(phaseName, body.getMethod().getSignature()) == 0) {
return;
}
final PatchingChain<Unit> units = body.getUnits();
int precedingFirstNotIdentityIndex = 0;
Unit precedingFirstNotIdentity = null;
for (Unit unit : units) {
if (unit instanceof IdentityStmt) {
precedingFirstNotIdentity = unit;
precedingFirstNotIdentityIndex++;
continue;
}
break;
}
final int unitsLeft = units.size() - precedingFirstNotIdentityIndex;
if (unitsLeft < 8) {
if (isVerbose()) {
logger.info("Skipping {} method GOTO instrumentation as it is too small.", body.getMethod().getSignature());
}
return;
}
int tries = 0;
int unitsQuantityToReorder = 0;
while (tries < MAX_TRIES_TO_GET_REORDER_COUNT) {
// value must be in (0; unitsLeft - 1]
// - greater than 0 to avoid modifying the precedingFirstNotIdentity
// - less than unitsLeft - 1 to avoid getting out of bounds
unitsQuantityToReorder = Rand.getInt(unitsLeft - 2) + 1;
tries++;
final Unit selectedUnit = Iterables.get(units, precedingFirstNotIdentityIndex + unitsQuantityToReorder);
if (isExceptionCaught(selectedUnit, units, body.getTraps())) {
continue;
}
break;
}
// if 10 tries, we give up
if (tries >= MAX_TRIES_TO_GET_REORDER_COUNT) {
return;
}
if (isVerbose()) {
logger.info("Adding GOTOs to \"{}\".", body.getMethod().getName());
}
final Unit first = precedingFirstNotIdentity == null ? units.getFirst() : precedingFirstNotIdentity;
final Unit firstReorderingUnit = units.getSuccOf(first);
// move random-size chunk at beginning to end
Unit reorderingUnit = firstReorderingUnit;
for (int reorder = 0; reorder < unitsQuantityToReorder; reorder++) {
// create separate array to avoid coming modifications
final UnitBox pointingToReorderingUnit[] = reorderingUnit.getBoxesPointingToThis().toArray(EMPTY_UNIT_BOX_ARRAY);
for (UnitBox element : pointingToReorderingUnit) {
reorderingUnit.removeBoxPointingToThis(element);
}
// unit box targets stay with a unit even if the unit is removed.
final Unit nextReorderingUnit = units.getSuccOf(reorderingUnit);
units.remove(reorderingUnit);
units.add(reorderingUnit);
for (UnitBox element : pointingToReorderingUnit) {
reorderingUnit.addBoxPointingToThis(element);
}
reorderingUnit = nextReorderingUnit;
}
// add goto as FIRST unit to point to new chunk location
final Unit firstReorderingNotGotoStmt
= first instanceof GotoStmt ? ((GotoStmt) first).getTargetBox().getUnit() : firstReorderingUnit;
final GotoStmt gotoFirstReorderingNotGotoStmt = Jimple.v().newGotoStmt(firstReorderingNotGotoStmt);
units.insertBeforeNoRedirect(gotoFirstReorderingNotGotoStmt, reorderingUnit);
// add goto as LAST unit to point to new position of second chunk
if (units.getLast().fallsThrough()) {
final Stmt gotoStmt = (reorderingUnit instanceof GotoStmt)
? Jimple.v().newGotoStmt(((GotoStmt) reorderingUnit).getTargetBox().getUnit())
: Jimple.v().newGotoStmt(reorderingUnit);
units.add(gotoStmt);
}
gotosInstrumented++;
Unit secondReorderedUnit = units.getSuccOf(firstReorderingNotGotoStmt);
if (secondReorderedUnit == null
|| (secondReorderedUnit.equals(units.getLast()) && secondReorderedUnit instanceof IdentityStmt)) {
if (firstReorderingNotGotoStmt instanceof IdentityStmt) {
if (isVerbose()) {
logger.info("Skipping adding try-catch block at \"{}\".", body.getMethod().getSignature());
}
return;
}
secondReorderedUnit = firstReorderingNotGotoStmt;
}
final RefType throwable = Scene.v().getRefType("java.lang.Throwable");
final Local caughtExceptionLocal = Jimple.v().newLocal("jbco_gi_caughtExceptionLocal", throwable);
body.getLocals().add(caughtExceptionLocal);
final Unit caughtExceptionHandler = Jimple.v().newIdentityStmt(caughtExceptionLocal, Jimple.v().newCaughtExceptionRef());
units.add(caughtExceptionHandler);
units.add(Jimple.v().newThrowStmt(caughtExceptionLocal));
final Iterator<Unit> reorderedUnitsIterator
= units.iterator(secondReorderedUnit, units.getPredOf(caughtExceptionHandler));
Unit trapEndUnit = reorderedUnitsIterator.next();
while (trapEndUnit instanceof IdentityStmt && reorderedUnitsIterator.hasNext()) {
trapEndUnit = reorderedUnitsIterator.next();
}
trapEndUnit = units.getSuccOf(trapEndUnit);
body.getTraps().add(Jimple.v().newTrap(throwable.getSootClass(), units.getPredOf(firstReorderingNotGotoStmt),
trapEndUnit, caughtExceptionHandler));
trapsAdded++;
| 446
| 1,599
| 2,045
|
<methods>public non-sealed void <init>() ,public final void transform(soot.Body, java.lang.String, Map<java.lang.String,java.lang.String>) ,public final void transform(soot.Body, java.lang.String) ,public final void transform(soot.Body) <variables>private static final Map<java.lang.String,java.lang.String> enabledOnlyMap
|
soot-oss_soot
|
soot/src/main/java/soot/jbco/jimpleTransformations/New2InitFlowAnalysis.java
|
New2InitFlowAnalysis
|
flowThrough
|
class New2InitFlowAnalysis extends BackwardFlowAnalysis<Unit, FlowSet> {
FlowSet emptySet = new ArraySparseSet();
public New2InitFlowAnalysis(DirectedGraph<Unit> graph) {
super(graph);
doAnalysis();
}
@Override
protected void flowThrough(FlowSet in, Unit d, FlowSet out) {<FILL_FUNCTION_BODY>}
@Override
protected FlowSet newInitialFlow() {
return emptySet.clone();
}
@Override
protected FlowSet entryInitialFlow() {
return emptySet.clone();
}
@Override
protected void merge(FlowSet in1, FlowSet in2, FlowSet out) {
in1.union(in2, out);
}
@Override
protected void copy(FlowSet source, FlowSet dest) {
source.copy(dest);
}
}
|
in.copy(out);
if (d instanceof DefinitionStmt) {
DefinitionStmt ds = (DefinitionStmt) d;
if (ds.getRightOp() instanceof NewExpr) {
Value v = ds.getLeftOp();
if (v instanceof Local && in.contains(v)) {
out.remove(v);
}
}
} else {
for (ValueBox useBox : d.getUseBoxes()) {
Value v = useBox.getValue();
if (v instanceof Local) {
out.add(v);
}
}
}
/*
* else if (d instanceof InvokeStmt) { InvokeExpr ie = ((InvokeStmt)d).getInvokeExpr(); if (ie instanceof
* SpecialInvokeExpr) { Value v = ((SpecialInvokeExpr)ie).getBase(); if (v instanceof Local && !inf.contains(v))
* outf.add(v); } }
*/
| 229
| 241
| 470
|
<methods>public void <init>(DirectedGraph<soot.Unit>) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/jbco/util/BodyBuilder.java
|
BodyBuilder
|
updateTraps
|
class BodyBuilder {
public static boolean bodiesHaveBeenBuilt = false;
public static boolean namesHaveBeenRetrieved = false;
public static Set<String> nameList = new HashSet<String>();
public static void retrieveAllBodies() {
if (bodiesHaveBeenBuilt) {
return;
}
// iterate through application classes, rename fields with junk
for (SootClass c : soot.Scene.v().getApplicationClasses()) {
for (SootMethod m : c.getMethods()) {
if (!m.isConcrete()) {
continue;
}
if (!m.hasActiveBody()) {
m.retrieveActiveBody();
}
}
}
bodiesHaveBeenBuilt = true;
}
public static void retrieveAllNames() {
if (namesHaveBeenRetrieved) {
return;
}
// iterate through application classes, rename fields with junk
for (SootClass c : soot.Scene.v().getApplicationClasses()) {
nameList.add(c.getName());
for (SootMethod m : c.getMethods()) {
nameList.add(m.getName());
}
for (SootField m : c.getFields()) {
nameList.add(m.getName());
}
}
namesHaveBeenRetrieved = true;
}
public static Local buildThisLocal(PatchingChain<Unit> units, ThisRef tr, Collection<Local> locals) {
Local ths = Jimple.v().newLocal("ths", tr.getType());
locals.add(ths);
units.add(Jimple.v().newIdentityStmt(ths, Jimple.v().newThisRef((RefType) tr.getType())));
return ths;
}
public static List<Local> buildParameterLocals(PatchingChain<Unit> units, Collection<Local> locals,
List<Type> paramTypes) {
List<Local> args = new ArrayList<Local>();
for (int k = 0; k < paramTypes.size(); k++) {
Type type = paramTypes.get(k);
Local loc = Jimple.v().newLocal("l" + k, type);
locals.add(loc);
units.add(Jimple.v().newIdentityStmt(loc, Jimple.v().newParameterRef(type, k)));
args.add(loc);
}
return args;
}
public static void updateTraps(Unit oldu, Unit newu, Chain<Trap> traps) {<FILL_FUNCTION_BODY>}
public static boolean isExceptionCaughtAt(Chain<Unit> units, Unit u, Iterator<Trap> trapsIt) {
while (trapsIt.hasNext()) {
Trap t = trapsIt.next();
Iterator<Unit> it = units.iterator(t.getBeginUnit(), units.getPredOf(t.getEndUnit()));
while (it.hasNext()) {
if (u.equals(it.next())) {
return true;
}
}
}
return false;
}
public static int getIntegerNine() {
int r1 = Rand.getInt(8388606) * 256;
int r2 = Rand.getInt(28) * 9;
if (r2 > 126) {
r2 += 4;
}
return r1 + r2;
}
public static boolean isBafIf(Unit u) {
if (u instanceof IfCmpEqInst || u instanceof IfCmpGeInst || u instanceof IfCmpGtInst || u instanceof IfCmpLeInst
|| u instanceof IfCmpLtInst || u instanceof IfCmpNeInst || u instanceof IfEqInst || u instanceof IfGeInst
|| u instanceof IfGtInst || u instanceof IfLeInst || u instanceof IfLtInst || u instanceof IfNeInst
|| u instanceof IfNonNullInst || u instanceof IfNullInst) {
return true;
}
return false;
}
}
|
int size = traps.size();
if (size == 0) {
return;
}
Trap t = traps.getFirst();
do {
if (t.getBeginUnit() == oldu) {
t.setBeginUnit(newu);
}
if (t.getEndUnit() == oldu) {
t.setEndUnit(newu);
}
if (t.getHandlerUnit() == oldu) {
t.setHandlerUnit(newu);
}
} while ((--size > 0) && (t = traps.getSuccOf(t)) != null);
| 1,032
| 161
| 1,193
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jbco/util/Debugger.java
|
Debugger
|
printUnits
|
class Debugger {
public static void printBaf(Body b) {
System.out.println(b.getMethod().getName() + "\n");
int i = 0;
Map<Unit, Integer> index = new HashMap<Unit, Integer>();
Iterator<Unit> it = b.getUnits().iterator();
while (it.hasNext()) {
index.put(it.next(), new Integer(i++));
}
it = b.getUnits().iterator();
while (it.hasNext()) {
Object o = it.next();
System.out.println(index.get(o).toString() + " " + o + " "
+ (o instanceof TargetArgInst ? index.get(((TargetArgInst) o).getTarget()).toString() : ""));
}
System.out.println("\n");
}
public static void printUnits(Body b, String msg) {<FILL_FUNCTION_BODY>}
public static void printUnits(PatchingChain<Unit> u, String msg) {
int i = 0;
HashMap<Unit, Integer> numbers = new HashMap<Unit, Integer>();
Iterator<Unit> it = u.snapshotIterator();
while (it.hasNext()) {
numbers.put(it.next(), new Integer(i++));
}
System.out.println("\r\r*********** " + msg);
Iterator<Unit> udit = u.snapshotIterator();
while (udit.hasNext()) {
Unit unit = (Unit) udit.next();
Integer numb = numbers.get(unit);
if (numb.intValue() == 149) {
System.out.println("hi");
}
if (unit instanceof TargetArgInst) {
TargetArgInst ti = (TargetArgInst) unit;
if (ti.getTarget() == null) {
System.out.println(unit + " null null null null null null null null null");
continue;
}
System.out.println(numbers.get(unit).toString() + " " + unit + " #" + numbers.get(ti.getTarget()).toString());
continue;
} else if (unit instanceof TableSwitchInst) {
TableSwitchInst tswi = (TableSwitchInst) unit;
System.out.println(numbers.get(unit).toString() + " SWITCH:");
System.out.println("\tdefault: " + tswi.getDefaultTarget() + " " + numbers.get(tswi.getDefaultTarget()).toString());
int index = 0;
for (int x = tswi.getLowIndex(); x <= tswi.getHighIndex(); x++) {
System.out
.println("\t " + x + ": " + tswi.getTarget(index) + " " + numbers.get(tswi.getTarget(index++)).toString());
}
continue;
}
System.out.println(numb.toString() + " " + unit);
}
}
}
|
int i = 0;
Map<Unit, Integer> numbers = new HashMap<Unit, Integer>();
PatchingChain<Unit> u = b.getUnits();
Iterator<Unit> it = u.snapshotIterator();
while (it.hasNext()) {
numbers.put(it.next(), new Integer(i++));
}
int jsr = 0;
System.out.println("\r\r" + b.getMethod().getName() + " " + msg);
Iterator<Unit> udit = u.snapshotIterator();
while (udit.hasNext()) {
Unit unit = (Unit) udit.next();
Integer numb = numbers.get(unit);
if (numb.intValue() == 149) {
System.out.println("hi");
}
if (unit instanceof TargetArgInst) {
if (unit instanceof JSRInst) {
jsr++;
}
TargetArgInst ti = (TargetArgInst) unit;
if (ti.getTarget() == null) {
System.out.println(unit + " null null null null null null null null null");
continue;
}
System.out.println(numbers.get(unit).toString() + " " + unit + " #" + numbers.get(ti.getTarget()).toString());
continue;
} else if (unit instanceof TableSwitchInst) {
TableSwitchInst tswi = (TableSwitchInst) unit;
System.out.println(numbers.get(unit).toString() + " SWITCH:");
System.out.println("\tdefault: " + tswi.getDefaultTarget() + " " + numbers.get(tswi.getDefaultTarget()).toString());
int index = 0;
for (int x = tswi.getLowIndex(); x <= tswi.getHighIndex(); x++) {
System.out
.println("\t " + x + ": " + tswi.getTarget(index) + " " + numbers.get(tswi.getTarget(index++)).toString());
}
continue;
}
System.out.println(numb.toString() + " " + unit);
}
Iterator<Trap> tit = b.getTraps().iterator();
while (tit.hasNext()) {
Trap t = tit.next();
System.out.println(numbers.get(t.getBeginUnit()) + " " + t.getBeginUnit() + " to " + numbers.get(t.getEndUnit()) + " "
+ t.getEndUnit() + " at " + numbers.get(t.getHandlerUnit()) + " " + t.getHandlerUnit());
}
if (jsr > 0) {
System.out.println("\r\tJSR Instructions: " + jsr);
}
| 761
| 708
| 1,469
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jbco/util/HierarchyUtils.java
|
HierarchyUtils
|
getAllInterfacesOf
|
class HierarchyUtils {
private HierarchyUtils() {
throw new IllegalAccessError();
}
/**
* Get whole tree of interfaces on {@code Scene} for class/interface.
*
* @param sc
* class or interface to get all its interfaces
* @return all interfaces on {@code Scene} for class or interface
*/
public static List<SootClass> getAllInterfacesOf(SootClass sc) {<FILL_FUNCTION_BODY>}
}
|
Hierarchy hierarchy = Scene.v().getActiveHierarchy();
Stream<SootClass> superClassInterfaces = sc.isInterface() ? Stream.empty()
: hierarchy.getSuperclassesOf(sc).stream().map(HierarchyUtils::getAllInterfacesOf).flatMap(Collection::stream);
Stream<SootClass> directInterfaces = Stream.concat(sc.getInterfaces().stream(),
sc.getInterfaces().stream().map(HierarchyUtils::getAllInterfacesOf).flatMap(Collection::stream));
return Stream.concat(superClassInterfaces, directInterfaces).collect(toList());
| 129
| 153
| 282
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jbco/util/SimpleExceptionalGraph.java
|
SimpleExceptionalGraph
|
buildSimpleExceptionalEdges
|
class SimpleExceptionalGraph extends TrapUnitGraph {
/**
* @param body
*/
public SimpleExceptionalGraph(Body body) {
super(body);
int size = unitChain.size();
unitToSuccs = new HashMap<Unit, List<Unit>>(size * 2 + 1, 0.7f);
unitToPreds = new HashMap<Unit, List<Unit>>(size * 2 + 1, 0.7f);
buildUnexceptionalEdges(unitToSuccs, unitToPreds);
buildSimpleExceptionalEdges(unitToSuccs, unitToPreds);
buildHeadsAndTails();
}
protected void buildSimpleExceptionalEdges(Map<Unit, List<Unit>> unitToSuccs, Map<Unit, List<Unit>> unitToPreds) {<FILL_FUNCTION_BODY>}
}
|
for (Trap trap : body.getTraps()) {
Unit handler = trap.getHandlerUnit();
for (Unit pred : unitToPreds.get(trap.getBeginUnit())) {
addEdge(unitToSuccs, unitToPreds, pred, handler);
}
}
| 224
| 78
| 302
|
<methods>public void <init>(soot.Body) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/jbco/util/StringTrie.java
|
StringTrie
|
addChar
|
class StringTrie {
private char[] startChars = new char[0];
private StringTrie[] tries = new StringTrie[0];
public StringTrie() {
super();
}
public void add(char[] chars, int index) {
if (chars.length == index) {
return;
}
if (startChars.length == 0) {
startChars = new char[1];
startChars[0] = chars[0];
tries = new StringTrie[1];
tries[0].add(chars, index++);
} else {
int i = findStart(chars[index], 0, startChars.length - 1);
if (i >= 0) {
tries[i].add(chars, index++);
} else {
i = addChar(chars[index]);
tries[i].add(chars, index++);
}
}
}
private int addChar(char c) {<FILL_FUNCTION_BODY>}
private int findSpot(char c, int first, int last) {
int diff = last - first;
if (diff == 1) {
return c < startChars[first] ? first : c < startChars[last] ? last : last + 1;
}
diff /= 2;
if (startChars[first + diff] < c) {
return findSpot(c, first + diff, last);
} else {
return findSpot(c, first, last - diff);
}
}
public boolean contains(char[] chars, int index) {
if (chars.length == index) {
return true;
} else if (startChars.length == 0) {
return false;
}
int i = findStart(chars[index], 0, startChars.length - 1);
if (i >= 0) {
return tries[i].contains(chars, index++);
}
return false;
}
private int findStart(char c, int first, int last) {
int diff = last - first;
if (diff <= 1) {
return c == startChars[first] ? first : c == startChars[last] ? last : -1;
}
diff /= 2;
if (startChars[first + diff] <= c) {
return findStart(c, first + diff, last);
} else {
return findStart(c, first, last - diff);
}
}
}
|
int oldLength = startChars.length;
int i = findSpot(c, 0, oldLength - 1);
char tmp[] = startChars.clone();
StringTrie t[] = tries.clone();
startChars = new char[oldLength + 1];
tries = new StringTrie[oldLength + 1];
if (i > 0) {
System.arraycopy(tmp, 0, startChars, 0, i);
System.arraycopy(t, 0, tries, 0, i);
}
if (i < oldLength) {
System.arraycopy(tmp, i, startChars, i + 1, oldLength - i);
System.arraycopy(t, i, tries, i + 1, oldLength - i);
}
startChars[i] = c;
tries[i] = new StringTrie();
return i;
| 651
| 232
| 883
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/IntConstant.java
|
IntConstant
|
v
|
class IntConstant extends ArithmeticConstant {
private static final long serialVersionUID = 8622167089453261784L;
public final int value;
private static final int MAX_CACHE = 128;
private static final int MIN_CACHE = -127;
private static final int ABS_MIN_CACHE = Math.abs(MIN_CACHE);
private static final IntConstant[] CACHED = new IntConstant[MAX_CACHE + ABS_MIN_CACHE];
protected IntConstant(int value) {
this.value = value;
}
public static IntConstant v(int value) {<FILL_FUNCTION_BODY>}
@Override
public boolean equals(Object c) {
return c instanceof IntConstant && ((IntConstant) c).value == value;
}
@Override
public int hashCode() {
return value;
}
// PTC 1999/06/28
@Override
public NumericConstant add(NumericConstant c) {
if (!(c instanceof IntConstant)) {
throw new IllegalArgumentException("IntConstant expected");
}
return IntConstant.v(this.value + ((IntConstant) c).value);
}
@Override
public NumericConstant subtract(NumericConstant c) {
if (!(c instanceof IntConstant)) {
throw new IllegalArgumentException("IntConstant expected");
}
return IntConstant.v(this.value - ((IntConstant) c).value);
}
@Override
public NumericConstant multiply(NumericConstant c) {
if (!(c instanceof IntConstant)) {
throw new IllegalArgumentException("IntConstant expected");
}
return IntConstant.v(this.value * ((IntConstant) c).value);
}
@Override
public NumericConstant divide(NumericConstant c) {
if (!(c instanceof IntConstant)) {
throw new IllegalArgumentException("IntConstant expected");
}
return IntConstant.v(this.value / ((IntConstant) c).value);
}
@Override
public NumericConstant remainder(NumericConstant c) {
if (!(c instanceof IntConstant)) {
throw new IllegalArgumentException("IntConstant expected");
}
return IntConstant.v(this.value % ((IntConstant) c).value);
}
@Override
public NumericConstant equalEqual(NumericConstant c) {
if (!(c instanceof IntConstant)) {
throw new IllegalArgumentException("IntConstant expected");
}
return IntConstant.v((this.value == ((IntConstant) c).value) ? 1 : 0);
}
@Override
public NumericConstant notEqual(NumericConstant c) {
if (!(c instanceof IntConstant)) {
throw new IllegalArgumentException("IntConstant expected");
}
return IntConstant.v((this.value != ((IntConstant) c).value) ? 1 : 0);
}
@Override
public boolean isLessThan(NumericConstant c) {
if (!(c instanceof IntConstant)) {
throw new IllegalArgumentException("IntConstant expected");
}
return this.value < ((IntConstant) c).value;
}
@Override
public NumericConstant lessThan(NumericConstant c) {
if (!(c instanceof IntConstant)) {
throw new IllegalArgumentException("IntConstant expected");
}
return IntConstant.v((this.value < ((IntConstant) c).value) ? 1 : 0);
}
@Override
public NumericConstant lessThanOrEqual(NumericConstant c) {
if (!(c instanceof IntConstant)) {
throw new IllegalArgumentException("IntConstant expected");
}
return IntConstant.v((this.value <= ((IntConstant) c).value) ? 1 : 0);
}
@Override
public NumericConstant greaterThan(NumericConstant c) {
if (!(c instanceof IntConstant)) {
throw new IllegalArgumentException("IntConstant expected");
}
return IntConstant.v((this.value > ((IntConstant) c).value) ? 1 : 0);
}
@Override
public NumericConstant greaterThanOrEqual(NumericConstant c) {
if (!(c instanceof IntConstant)) {
throw new IllegalArgumentException("IntConstant expected");
}
return IntConstant.v((this.value >= ((IntConstant) c).value) ? 1 : 0);
}
@Override
public NumericConstant negate() {
return IntConstant.v(-(this.value));
}
@Override
public ArithmeticConstant and(ArithmeticConstant c) {
if (!(c instanceof IntConstant)) {
throw new IllegalArgumentException("IntConstant expected");
}
return IntConstant.v(this.value & ((IntConstant) c).value);
}
@Override
public ArithmeticConstant or(ArithmeticConstant c) {
if (!(c instanceof IntConstant)) {
throw new IllegalArgumentException("IntConstant expected");
}
return IntConstant.v(this.value | ((IntConstant) c).value);
}
@Override
public ArithmeticConstant xor(ArithmeticConstant c) {
if (!(c instanceof IntConstant)) {
throw new IllegalArgumentException("IntConstant expected");
}
return IntConstant.v(this.value ^ ((IntConstant) c).value);
}
@Override
public ArithmeticConstant shiftLeft(ArithmeticConstant c) {
if (!(c instanceof IntConstant)) {
throw new IllegalArgumentException("IntConstant expected");
}
return IntConstant.v(this.value << ((IntConstant) c).value);
}
@Override
public ArithmeticConstant shiftRight(ArithmeticConstant c) {
if (!(c instanceof IntConstant)) {
throw new IllegalArgumentException("IntConstant expected");
}
return IntConstant.v(this.value >> ((IntConstant) c).value);
}
@Override
public ArithmeticConstant unsignedShiftRight(ArithmeticConstant c) {
if (!(c instanceof IntConstant)) {
throw new IllegalArgumentException("IntConstant expected");
}
return IntConstant.v(this.value >>> ((IntConstant) c).value);
}
@Override
public String toString() {
return Integer.toString(value);
}
@Override
public Type getType() {
return IntType.v();
}
@Override
public void apply(Switch sw) {
((ConstantSwitch) sw).caseIntConstant(this);
}
}
|
if (value > MIN_CACHE && value < MAX_CACHE) {
int idx = value + ABS_MIN_CACHE;
IntConstant c = CACHED[idx];
if (c != null) {
return c;
}
c = new IntConstant(value);
CACHED[idx] = c;
return c;
}
return new IntConstant(value);
| 1,653
| 108
| 1,761
|
<methods>public non-sealed void <init>() ,public abstract soot.jimple.ArithmeticConstant and(soot.jimple.ArithmeticConstant) ,public abstract soot.jimple.ArithmeticConstant or(soot.jimple.ArithmeticConstant) ,public abstract soot.jimple.ArithmeticConstant shiftLeft(soot.jimple.ArithmeticConstant) ,public abstract soot.jimple.ArithmeticConstant shiftRight(soot.jimple.ArithmeticConstant) ,public abstract soot.jimple.ArithmeticConstant unsignedShiftRight(soot.jimple.ArithmeticConstant) ,public abstract soot.jimple.ArithmeticConstant xor(soot.jimple.ArithmeticConstant) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/JimpleBody.java
|
LazyValidatorsSingleton
|
insertIdentityStmts
|
class LazyValidatorsSingleton {
static final BodyValidator[] V = new BodyValidator[] { IdentityStatementsValidator.v(), TypesValidator.v(),
ReturnStatementsValidator.v(), InvokeArgumentValidator.v(), FieldRefValidator.v(), NewValidator.v(),
JimpleTrapValidator.v(), IdentityValidator.v(), MethodValidator.v() /* InvokeValidator.v() */ };
private LazyValidatorsSingleton() {
}
}
/**
* Construct an empty JimpleBody
*
* @param m
*/
public JimpleBody(SootMethod m) {
super(m);
if (Options.v().verbose()) {
logger.debug("[" + getMethod().getName() + "] Constructing JimpleBody...");
}
}
/**
* Construct an extremely empty JimpleBody, for parsing into.
*/
public JimpleBody() {
}
/**
* Clones the current body, making deep copies of the contents.
*
* @return
*/
@Override
public Object clone() {
Body b = new JimpleBody(getMethodUnsafe());
b.importBodyContentsFrom(this);
return b;
}
@Override
public Object clone(boolean noLocalsClone) {
Body b = new JimpleBody(getMethod());
b.importBodyContentsFrom(this, true);
return b;
}
/**
* Make sure that the JimpleBody is well formed. If not, throw an exception. Right now, performs only a handful of checks.
*/
@Override
public void validate() {
final List<ValidationException> exceptionList = new ArrayList<ValidationException>();
validate(exceptionList);
if (!exceptionList.isEmpty()) {
throw exceptionList.get(0);
}
}
/**
* Validates the jimple body and saves a list of all validation errors
*
* @param exceptionList
* the list of validation errors
*/
@Override
public void validate(List<ValidationException> exceptionList) {
super.validate(exceptionList);
final boolean runAllValidators = Options.v().debug() || Options.v().validate();
for (BodyValidator validator : LazyValidatorsSingleton.V) {
if (runAllValidators || validator.isBasicValidator()) {
validator.validate(this, exceptionList);
}
}
}
public void validateIdentityStatements() {
runValidation(IdentityStatementsValidator.v());
}
/**
* Inserts usual statements for handling this & parameters into body.
*/
public void insertIdentityStmts() {
insertIdentityStmts(getMethod().getDeclaringClass());
}
/**
* Inserts usual statements for handling this & parameters into body.
*
* @param declaringClass
* the class, which should be used for this references. Can be null for static methods
*/
public void insertIdentityStmts(SootClass declaringClass) {<FILL_FUNCTION_BODY>
|
final Jimple jimple = Jimple.v();
final PatchingChain<Unit> unitChain = this.getUnits();
final Chain<Local> localChain = this.getLocals();
Unit lastUnit = null;
// add this-ref before everything else
if (!getMethod().isStatic()) {
if (declaringClass == null) {
throw new IllegalArgumentException(
String.format("No declaring class given for method %s", method.getSubSignature()));
}
Local l = jimple.newLocal("this", RefType.v(declaringClass));
Stmt s = jimple.newIdentityStmt(l, jimple.newThisRef((RefType) l.getType()));
localChain.add(l);
unitChain.addFirst(s);
lastUnit = s;
}
int i = 0;
for (Type t : getMethod().getParameterTypes()) {
Local l = jimple.newLocal("parameter" + i, t);
Stmt s = jimple.newIdentityStmt(l, jimple.newParameterRef(l.getType(), i));
localChain.add(l);
if (lastUnit == null) {
unitChain.addFirst(s);
} else {
unitChain.insertAfter(s, lastUnit);
}
lastUnit = s;
i++;
}
| 774
| 353
| 1,127
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/LocalStmtPair.java
|
LocalStmtPair
|
equals
|
class LocalStmtPair {
Local local;
Stmt stmt;
public LocalStmtPair(Local local, Stmt stmt) {
this.local = local;
this.stmt = stmt;
}
public boolean equals(Object other) {<FILL_FUNCTION_BODY>}
public int hashCode() {
return local.hashCode() * 101 + stmt.hashCode() + 17;
}
}
|
if (other instanceof LocalStmtPair && ((LocalStmtPair) other).local == this.local
&& ((LocalStmtPair) other).stmt == this.stmt) {
return true;
} else {
return false;
}
| 119
| 63
| 182
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/MethodHandle.java
|
MethodHandle
|
getKind
|
class MethodHandle extends Constant {
private static final long serialVersionUID = -7948291265532721191L;
public static enum Kind {
REF_GET_FIELD(Opcodes.H_GETFIELD, "REF_GET_FIELD"), REF_GET_FIELD_STATIC(Opcodes.H_GETSTATIC,
"REF_GET_FIELD_STATIC"), REF_PUT_FIELD(Opcodes.H_PUTFIELD, "REF_PUT_FIELD"), REF_PUT_FIELD_STATIC(
Opcodes.H_PUTSTATIC, "REF_PUT_FIELD_STATIC"), REF_INVOKE_VIRTUAL(Opcodes.H_INVOKEVIRTUAL,
"REF_INVOKE_VIRTUAL"), REF_INVOKE_STATIC(Opcodes.H_INVOKESTATIC, "REF_INVOKE_STATIC"), REF_INVOKE_SPECIAL(
Opcodes.H_INVOKESPECIAL, "REF_INVOKE_SPECIAL"), REF_INVOKE_CONSTRUCTOR(Opcodes.H_NEWINVOKESPECIAL,
"REF_INVOKE_CONSTRUCTOR"), REF_INVOKE_INTERFACE(Opcodes.H_INVOKEINTERFACE, "REF_INVOKE_INTERFACE");
private final int val;
private final String valStr;
private Kind(int val, String valStr) {
this.val = val;
this.valStr = valStr;
}
@Override
public String toString() {
return valStr;
}
public int getValue() {
return val;
}
public static Kind getKind(int kind) {<FILL_FUNCTION_BODY>}
public static Kind getKind(String kind) {
for (Kind k : Kind.values()) {
if (k.toString().equals(kind)) {
return k;
}
}
throw new RuntimeException("Error: No method handle kind for value '" + kind + "'.");
}
}
protected final SootFieldRef fieldRef;
protected final SootMethodRef methodRef;
protected final int kind;
private MethodHandle(SootMethodRef ref, int kind) {
this.methodRef = ref;
this.kind = kind;
this.fieldRef = null;
}
private MethodHandle(SootFieldRef ref, int kind) {
this.fieldRef = ref;
this.kind = kind;
this.methodRef = null;
}
public static MethodHandle v(SootMethodRef ref, int kind) {
return new MethodHandle(ref, kind);
}
public static MethodHandle v(SootFieldRef ref, int kind) {
return new MethodHandle(ref, kind);
}
@Override
public String toString() {
return "methodhandle: \"" + getKindString() + "\" "
+ (methodRef == null ? Objects.toString(fieldRef) : Objects.toString(methodRef));
}
@Override
public Type getType() {
if (Options.v().src_prec() == Options.src_prec_dotnet) {
return isMethodRef() ? RefType.v(DotnetBasicTypes.SYSTEM_RUNTIMEMETHODHANDLE)
: RefType.v(DotnetBasicTypes.SYSTEM_RUNTIMEFIELDHANDLE);
}
return RefType.v("java.lang.invoke.MethodHandle");
}
public SootMethodRef getMethodRef() {
return methodRef;
}
public SootFieldRef getFieldRef() {
return fieldRef;
}
public int getKind() {
return kind;
}
public String getKindString() {
return Kind.getKind(kind).toString();
}
public boolean isFieldRef() {
return isFieldRef(kind);
}
public static boolean isFieldRef(int kind) {
return kind == Kind.REF_GET_FIELD.getValue() || kind == Kind.REF_GET_FIELD_STATIC.getValue()
|| kind == Kind.REF_PUT_FIELD.getValue() || kind == Kind.REF_PUT_FIELD_STATIC.getValue();
}
public boolean isMethodRef() {
return isMethodRef(kind);
}
public static boolean isMethodRef(int kind) {
return kind == Kind.REF_INVOKE_VIRTUAL.getValue() || kind == Kind.REF_INVOKE_STATIC.getValue()
|| kind == Kind.REF_INVOKE_SPECIAL.getValue() || kind == Kind.REF_INVOKE_CONSTRUCTOR.getValue()
|| kind == Kind.REF_INVOKE_INTERFACE.getValue();
}
@Override
public void apply(Switch sw) {
((ConstantSwitch) sw).caseMethodHandle(this);
}
@Override
public int hashCode() {
final int prime = 17;
int result = 31;
result = prime * result + Objects.hashCode(methodRef);
result = prime * result + Objects.hashCode(fieldRef);
result = prime * result + kind;
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || this.getClass() != obj.getClass()) {
return false;
}
MethodHandle other = (MethodHandle) obj;
return Objects.equals(this.methodRef, other.methodRef) && Objects.equals(this.fieldRef, other.fieldRef);
}
}
|
for (Kind k : Kind.values()) {
if (k.getValue() == kind) {
return k;
}
}
throw new RuntimeException("Error: No method handle kind for value '" + kind + "'.");
| 1,454
| 59
| 1,513
|
<methods>public non-sealed void <init>() ,public java.lang.Object clone() ,public void convertToBaf(soot.jimple.JimpleToBafContext, List<soot.Unit>) ,public int equivHashCode() ,public boolean equivTo(java.lang.Object) ,public final List<soot.ValueBox> getUseBoxes() ,public void toString(soot.UnitPrinter) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/MethodType.java
|
MethodType
|
hashCode
|
class MethodType extends Constant {
private static final long serialVersionUID = 3523899677165980823L;
protected Type returnType;
protected List<Type> parameterTypes;
private MethodType(List<Type> parameterTypes, Type returnType) {
this.returnType = returnType;
this.parameterTypes = parameterTypes;
}
public static MethodType v(List<Type> paramaterTypes, Type returnType) {
return new MethodType(paramaterTypes, returnType);
}
@Override
public Type getType() {
return RefType.v("java.lang.invoke.MethodType");
}
@Override
public String toString() {
return "methodtype: " + SootMethod.getSubSignature("__METHODTYPE__", parameterTypes, returnType);
}
public List<Type> getParameterTypes() {
return parameterTypes == null ? Collections.<Type>emptyList() : parameterTypes;
}
public Type getReturnType() {
return returnType;
}
@Override
public void apply(Switch sw) {
((ConstantSwitch) sw).caseMethodType(this);
}
@Override
public int hashCode() {<FILL_FUNCTION_BODY>}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || this.getClass() != obj.getClass()) {
return false;
}
MethodType other = (MethodType) obj;
return Objects.equals(returnType, other.returnType) && Objects.equals(parameterTypes, other.parameterTypes);
}
}
|
int result = 17;
result = 31 * result + Objects.hashCode(parameterTypes);
result = 31 * result + Objects.hashCode(returnType);
return result;
| 436
| 52
| 488
|
<methods>public non-sealed void <init>() ,public java.lang.Object clone() ,public void convertToBaf(soot.jimple.JimpleToBafContext, List<soot.Unit>) ,public int equivHashCode() ,public boolean equivTo(java.lang.Object) ,public final List<soot.ValueBox> getUseBoxes() ,public void toString(soot.UnitPrinter) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/NaiveSideEffectTester.java
|
NaiveSideEffectTester
|
unitCanReadFrom
|
class NaiveSideEffectTester implements SideEffectTester {
public void newMethod(SootMethod m) {
}
/**
* Returns true if the unit can read from v. Does not deal with expressions; deals with Refs.
*/
public boolean unitCanReadFrom(Unit u, Value v) {<FILL_FUNCTION_BODY>}
public boolean unitCanWriteTo(Unit u, Value v) {
Stmt s = (Stmt) u;
if (v instanceof Constant) {
return false;
}
if (v instanceof Expr) {
throw new RuntimeException("can't deal with expr");
}
// If it's an invoke, then only locals are safe.
if (s.containsInvokeExpr()) {
if (!(v instanceof Local)) {
return true;
}
}
// otherwise, def boxes tell all.
Iterator defIt = u.getDefBoxes().iterator();
while (defIt.hasNext()) {
Value def = ((ValueBox) (defIt.next())).getValue();
Iterator useIt = v.getUseBoxes().iterator();
while (useIt.hasNext()) {
Value use = ((ValueBox) useIt.next()).getValue();
if (def.equivTo(use)) {
return true;
}
}
// also handle the container of all these useboxes!
if (def.equivTo(v)) {
return true;
}
// deal with aliasing - handle case where they
// are a read to the same field, regardless of
// base object.
if (v instanceof InstanceFieldRef && def instanceof InstanceFieldRef) {
if (((InstanceFieldRef) v).getField() == ((InstanceFieldRef) def).getField()) {
return true;
}
}
}
return false;
}
}
|
Stmt s = (Stmt) u;
// This doesn't really make any sense, but we need to return something.
if (v instanceof Constant) {
return false;
}
if (v instanceof Expr) {
throw new RuntimeException("can't deal with expr");
}
// If it's an invoke, then only locals are safe.
if (s.containsInvokeExpr()) {
if (!(v instanceof Local)) {
return true;
}
}
// otherwise, use boxes tell all.
Iterator useIt = u.getUseBoxes().iterator();
while (useIt.hasNext()) {
Value use = (Value) useIt.next();
if (use.equivTo(v)) {
return true;
}
Iterator vUseIt = v.getUseBoxes().iterator();
while (vUseIt.hasNext()) {
if (use.equivTo(vUseIt.next())) {
return true;
}
}
}
return false;
| 472
| 268
| 740
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/ParameterRef.java
|
ParameterRef
|
toString
|
class ParameterRef implements IdentityRef {
int n;
Type paramType;
/** Constructs a ParameterRef object of the specified type, representing the specified parameter number. */
public ParameterRef(Type paramType, int number) {
this.n = number;
this.paramType = paramType;
}
public boolean equivTo(Object o) {
if (o instanceof ParameterRef) {
return n == ((ParameterRef) o).n && paramType.equals(((ParameterRef) o).paramType);
}
return false;
}
public int equivHashCode() {
return n * 101 + paramType.hashCode() * 17;
}
/** Create a new ParameterRef object with the same paramType and number. */
public Object clone() {
return new ParameterRef(paramType, n);
}
/** Converts the given ParameterRef into a String i.e. <code>@parameter0: .int</code>. */
public String toString() {<FILL_FUNCTION_BODY>}
public void toString(UnitPrinter up) {
up.identityRef(this);
}
/** Returns the index of this ParameterRef. */
public int getIndex() {
return n;
}
/** Sets the index of this ParameterRef. */
public void setIndex(int index) {
n = index;
}
@Override
public final List<ValueBox> getUseBoxes() {
return Collections.emptyList();
}
/** Returns the type of this ParameterRef. */
public Type getType() {
return paramType;
}
/** Used with RefSwitch. */
public void apply(Switch sw) {
((RefSwitch) sw).caseParameterRef(this);
}
}
|
return "@parameter" + n + ": " + paramType;
| 466
| 20
| 486
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/ReachingTypeDumper.java
|
StringComparator
|
handleClass
|
class StringComparator<T> implements Comparator<T> {
public int compare(T o1, T o2) {
return o1.toString().compareTo(o2.toString());
}
}
public ReachingTypeDumper(PointsToAnalysis pa, String output_dir) {
this.pa = pa;
this.output_dir = output_dir;
}
public void dump() {
try {
PrintWriter file = new PrintWriter(new FileOutputStream(new File(output_dir, "types")));
for (SootClass cls : Scene.v().getApplicationClasses()) {
handleClass(file, cls);
}
for (SootClass cls : Scene.v().getLibraryClasses()) {
handleClass(file, cls);
}
file.close();
} catch (IOException e) {
throw new RuntimeException("Couldn't dump reaching types." + e);
}
}
/* End of public methods. */
/* End of package methods. */
protected PointsToAnalysis pa;
protected String output_dir;
protected void handleClass(PrintWriter out, SootClass c) {<FILL_FUNCTION_BODY>
|
for (SootMethod m : c.getMethods()) {
if (!m.isConcrete()) {
continue;
}
Body b = m.retrieveActiveBody();
Local[] sortedLocals = b.getLocals().toArray(new Local[b.getLocalCount()]);
Arrays.sort(sortedLocals, new StringComparator<Local>());
for (Local l : sortedLocals) {
out.println("V " + m + l);
if (l.getType() instanceof RefLikeType) {
Set<Type> types = pa.reachingObjects(l).possibleTypes();
Type[] sortedTypes = types.toArray(new Type[types.size()]);
Arrays.sort(sortedTypes, new StringComparator<Type>());
for (Type type : sortedTypes) {
out.println("T " + type);
}
}
}
}
| 306
| 233
| 539
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/internal/AbstractCastExpr.java
|
AbstractCastExpr
|
equivTo
|
class AbstractCastExpr implements CastExpr, ConvertToBaf {
protected final ValueBox opBox;
protected Type type;
AbstractCastExpr(Value op, Type type) {
this(Jimple.v().newImmediateBox(op), type);
}
@Override
public abstract Object clone();
protected AbstractCastExpr(ValueBox opBox, Type type) {
this.opBox = opBox;
this.type = type;
}
@Override
public boolean equivTo(Object o) {<FILL_FUNCTION_BODY>}
/** Returns a hash code for this object, consistent with structural equality. */
@Override
public int equivHashCode() {
return opBox.getValue().equivHashCode() * 101 + type.hashCode() + 17;
}
@Override
public String toString() {
return "(" + type.toString() + ") " + opBox.getValue().toString();
}
@Override
public void toString(UnitPrinter up) {
up.literal("(");
up.type(type);
up.literal(") ");
final boolean needsBrackets = PrecedenceTest.needsBrackets(opBox, this);
if (needsBrackets) {
up.literal("(");
}
opBox.toString(up);
if (needsBrackets) {
up.literal(")");
}
}
@Override
public Value getOp() {
return opBox.getValue();
}
@Override
public void setOp(Value op) {
opBox.setValue(op);
}
@Override
public ValueBox getOpBox() {
return opBox;
}
@Override
public final List<ValueBox> getUseBoxes() {
List<ValueBox> list = new ArrayList<ValueBox>(opBox.getValue().getUseBoxes());
list.add(opBox);
return list;
}
@Override
public Type getCastType() {
return type;
}
@Override
public void setCastType(Type castType) {
this.type = castType;
}
@Override
public Type getType() {
return type;
}
@Override
public void apply(Switch sw) {
((ExprSwitch) sw).caseCastExpr(this);
}
@Override
public void convertToBaf(JimpleToBafContext context, List<Unit> out) {
((ConvertToBaf) getOp()).convertToBaf(context, out);
Unit u;
final Type toType = getCastType();
if (toType instanceof ArrayType || toType instanceof RefType) {
u = Baf.v().newInstanceCastInst(toType);
} else {
final Type fromType = getOp().getType();
if (!fromType.equals(toType)) {
u = Baf.v().newPrimitiveCastInst(fromType, toType);
} else {
u = Baf.v().newNopInst();
}
}
out.add(u);
u.addAllTagsOf(context.getCurrentUnit());
}
}
|
if (o instanceof AbstractCastExpr) {
AbstractCastExpr ace = (AbstractCastExpr) o;
return this.opBox.getValue().equivTo(ace.opBox.getValue()) && this.type.equals(ace.type);
}
return false;
| 820
| 68
| 888
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/internal/AbstractDefinitionStmt.java
|
AbstractDefinitionStmt
|
getUseBoxes
|
class AbstractDefinitionStmt extends AbstractStmt implements DefinitionStmt {
protected final ValueBox leftBox;
protected final ValueBox rightBox;
protected AbstractDefinitionStmt(ValueBox leftBox, ValueBox rightBox) {
this.leftBox = leftBox;
this.rightBox = rightBox;
}
@Override
public final Value getLeftOp() {
return leftBox.getValue();
}
@Override
public final Value getRightOp() {
return rightBox.getValue();
}
@Override
public final ValueBox getLeftOpBox() {
return leftBox;
}
@Override
public final ValueBox getRightOpBox() {
return rightBox;
}
@Override
public final List<ValueBox> getDefBoxes() {
return Collections.singletonList(leftBox);
}
@Override
public List<ValueBox> getUseBoxes() {<FILL_FUNCTION_BODY>}
@Override
public boolean fallsThrough() {
return true;
}
@Override
public boolean branches() {
return false;
}
}
|
List<ValueBox> list = new ArrayList<ValueBox>();
list.addAll(getLeftOp().getUseBoxes());
list.add(rightBox);
list.addAll(getRightOp().getUseBoxes());
return list;
| 291
| 65
| 356
|
<methods>public non-sealed void <init>() ,public boolean containsArrayRef() ,public boolean containsFieldRef() ,public boolean containsInvokeExpr() ,public void convertToBaf(soot.jimple.JimpleToBafContext, List<soot.Unit>) ,public soot.jimple.ArrayRef getArrayRef() ,public soot.ValueBox getArrayRefBox() ,public soot.jimple.FieldRef getFieldRef() ,public soot.ValueBox getFieldRefBox() ,public soot.jimple.InvokeExpr getInvokeExpr() ,public soot.ValueBox getInvokeExprBox() <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/internal/AbstractInstanceInvokeExpr.java
|
AbstractInstanceInvokeExpr
|
getUseBoxes
|
class AbstractInstanceInvokeExpr extends AbstractInvokeExpr implements InstanceInvokeExpr {
protected final ValueBox baseBox;
protected AbstractInstanceInvokeExpr(SootMethodRef methodRef, ValueBox baseBox, ValueBox[] argBoxes) {
super(methodRef, argBoxes);
this.baseBox = baseBox;
}
@Override
public Value getBase() {
return baseBox.getValue();
}
@Override
public ValueBox getBaseBox() {
return baseBox;
}
@Override
public void setBase(Value base) {
baseBox.setValue(base);
}
@Override
public List<ValueBox> getUseBoxes() {<FILL_FUNCTION_BODY>}
}
|
List<ValueBox> list = new ArrayList<ValueBox>(baseBox.getValue().getUseBoxes());
list.add(baseBox);
if (argBoxes != null) {
Collections.addAll(list, argBoxes);
for (ValueBox element : argBoxes) {
list.addAll(element.getValue().getUseBoxes());
}
}
return list;
| 193
| 106
| 299
|
<methods>public abstract java.lang.Object clone() ,public soot.Value getArg(int) ,public soot.ValueBox getArgBox(int) ,public int getArgCount() ,public List<soot.Value> getArgs() ,public soot.SootMethod getMethod() ,public soot.SootMethodRef getMethodRef() ,public soot.Type getType() ,public List<soot.ValueBox> getUseBoxes() ,public void setArg(int, soot.Value) ,public void setMethodRef(soot.SootMethodRef) <variables>protected final non-sealed soot.ValueBox[] argBoxes,protected soot.SootMethodRef methodRef
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/internal/AbstractJimpleFloatBinopExpr.java
|
AbstractJimpleFloatBinopExpr
|
convertToBaf
|
class AbstractJimpleFloatBinopExpr extends AbstractFloatBinopExpr implements ConvertToBaf {
AbstractJimpleFloatBinopExpr(Value op1, Value op2) {
this(Jimple.v().newArgBox(op1), Jimple.v().newArgBox(op2));
}
protected AbstractJimpleFloatBinopExpr(ValueBox op1Box, ValueBox op2Box) {
super(op1Box, op2Box);
}
@Override
public void convertToBaf(JimpleToBafContext context, List<Unit> out) {<FILL_FUNCTION_BODY>}
protected abstract Unit makeBafInst(Type opType);
}
|
((ConvertToBaf) this.getOp1()).convertToBaf(context, out);
((ConvertToBaf) this.getOp2()).convertToBaf(context, out);
Unit u = makeBafInst(this.getOp1().getType());
out.add(u);
u.addAllTagsOf(context.getCurrentUnit());
| 179
| 92
| 271
|
<methods>public soot.Type getType() <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/internal/AbstractJimpleIntLongBinopExpr.java
|
AbstractJimpleIntLongBinopExpr
|
convertToBaf
|
class AbstractJimpleIntLongBinopExpr extends AbstractIntLongBinopExpr implements ConvertToBaf {
protected AbstractJimpleIntLongBinopExpr(Value op1, Value op2) {
super(Jimple.v().newArgBox(op1), Jimple.v().newArgBox(op2));
}
@Override
public void convertToBaf(JimpleToBafContext context, List<Unit> out) {<FILL_FUNCTION_BODY>}
protected abstract Unit makeBafInst(Type opType);
}
|
((ConvertToBaf) this.getOp1()).convertToBaf(context, out);
((ConvertToBaf) this.getOp2()).convertToBaf(context, out);
Unit u = makeBafInst(this.getOp1().getType());
out.add(u);
u.addAllTagsOf(context.getCurrentUnit());
| 141
| 92
| 233
|
<methods>public soot.Type getType() ,public static boolean isIntLikeType(soot.Type) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/internal/AbstractNegExpr.java
|
AbstractNegExpr
|
getType
|
class AbstractNegExpr extends AbstractUnopExpr implements NegExpr {
protected AbstractNegExpr(ValueBox opBox) {
super(opBox);
}
/** Compares the specified object with this one for structural equality. */
@Override
public boolean equivTo(Object o) {
if (o instanceof AbstractNegExpr) {
return this.opBox.getValue().equivTo(((AbstractNegExpr) o).opBox.getValue());
}
return false;
}
/** Returns a hash code for this object, consistent with structural equality. */
@Override
public int equivHashCode() {
return opBox.getValue().equivHashCode();
}
@Override
public String toString() {
return Jimple.NEG + " " + opBox.getValue().toString();
}
@Override
public void toString(UnitPrinter up) {
up.literal(Jimple.NEG + " ");
opBox.toString(up);
}
@Override
public Type getType() {<FILL_FUNCTION_BODY>}
@Override
public void apply(Switch sw) {
((ExprSwitch) sw).caseNegExpr(this);
}
}
|
final Type type = opBox.getValue().getType();
final IntType tyInt = IntType.v();
final ByteType tyByte = ByteType.v();
final ShortType tyShort = ShortType.v();
final CharType tyChar = CharType.v();
final BooleanType tyBool = BooleanType.v();
if (tyInt.equals(type) || tyByte.equals(type) || tyShort.equals(type) || tyChar.equals(type) || tyBool.equals(type)) {
return tyInt;
}
final LongType tyLong = LongType.v();
if (tyLong.equals(type)) {
return tyLong;
}
final DoubleType tyDouble = DoubleType.v();
if (tyDouble.equals(type)) {
return tyDouble;
}
final FloatType tyFloat = FloatType.v();
if (tyFloat.equals(type)) {
return tyFloat;
}
return UnknownType.v();
| 305
| 248
| 553
|
<methods>public abstract java.lang.Object clone() ,public soot.Value getOp() ,public soot.ValueBox getOpBox() ,public final List<soot.ValueBox> getUseBoxes() ,public void setOp(soot.Value) <variables>protected final non-sealed soot.ValueBox opBox
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/internal/AbstractNewArrayExpr.java
|
AbstractNewArrayExpr
|
getType
|
class AbstractNewArrayExpr implements NewArrayExpr, ConvertToBaf {
protected Type baseType;
protected final ValueBox sizeBox;
protected AbstractNewArrayExpr(Type type, ValueBox sizeBox) {
this.baseType = type;
this.sizeBox = sizeBox;
}
@Override
public abstract Object clone();
@Override
public boolean equivTo(Object o) {
if (o instanceof AbstractNewArrayExpr) {
AbstractNewArrayExpr ae = (AbstractNewArrayExpr) o;
return this.sizeBox.getValue().equivTo(ae.sizeBox.getValue()) && this.baseType.equals(ae.baseType);
}
return false;
}
/** Returns a hash code for this object, consistent with structural equality. */
@Override
public int equivHashCode() {
return sizeBox.getValue().equivHashCode() * 101 + baseType.hashCode() * 17;
}
@Override
public String toString() {
StringBuilder buf = new StringBuilder(Jimple.NEWARRAY + " (");
buf.append(getBaseTypeString()).append(")[").append(sizeBox.getValue().toString()).append(']');
return buf.toString();
}
@Override
public void toString(UnitPrinter up) {
up.literal(Jimple.NEWARRAY + " (");
up.type(baseType);
up.literal(")[");
sizeBox.toString(up);
up.literal("]");
}
private String getBaseTypeString() {
return baseType.toString();
}
@Override
public Type getBaseType() {
return baseType;
}
@Override
public void setBaseType(Type type) {
baseType = type;
}
@Override
public ValueBox getSizeBox() {
return sizeBox;
}
@Override
public Value getSize() {
return sizeBox.getValue();
}
@Override
public void setSize(Value size) {
sizeBox.setValue(size);
}
@Override
public final List<ValueBox> getUseBoxes() {
List<ValueBox> useBoxes = new ArrayList<ValueBox>(sizeBox.getValue().getUseBoxes());
useBoxes.add(sizeBox);
return useBoxes;
}
@Override
public Type getType() {<FILL_FUNCTION_BODY>}
@Override
public void apply(Switch sw) {
((ExprSwitch) sw).caseNewArrayExpr(this);
}
@Override
public void convertToBaf(JimpleToBafContext context, List<Unit> out) {
((ConvertToBaf) getSize()).convertToBaf(context, out);
Unit u = Baf.v().newNewArrayInst(getBaseType());
out.add(u);
u.addAllTagsOf(context.getCurrentUnit());
}
}
|
if (baseType instanceof ArrayType) {
ArrayType base = (ArrayType) baseType;
return ArrayType.v(base.baseType, base.numDimensions + 1);
} else {
return ArrayType.v(baseType, 1);
}
| 761
| 70
| 831
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/internal/AbstractNewExpr.java
|
AbstractNewExpr
|
equivTo
|
class AbstractNewExpr implements NewExpr {
protected RefType type;
@Override
public abstract Object clone();
@Override
public boolean equivTo(Object o) {<FILL_FUNCTION_BODY>}
/** Returns a hash code for this object, consistent with structural equality. */
@Override
public int equivHashCode() {
return type.hashCode();
}
@Override
public String toString() {
return Jimple.NEW + " " + type.toString();
}
@Override
public void toString(UnitPrinter up) {
up.literal(Jimple.NEW + " ");
up.type(type);
}
@Override
public RefType getBaseType() {
return type;
}
@Override
public void setBaseType(RefType type) {
this.type = type;
}
@Override
public Type getType() {
return type;
}
@Override
public List<ValueBox> getUseBoxes() {
return Collections.emptyList();
}
@Override
public void apply(Switch sw) {
((ExprSwitch) sw).caseNewExpr(this);
}
}
|
if (o instanceof AbstractNewExpr) {
AbstractNewExpr ae = (AbstractNewExpr) o;
return type.equals(ae.type);
}
return false;
| 314
| 48
| 362
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/internal/AbstractNewMultiArrayExpr.java
|
AbstractNewMultiArrayExpr
|
toString
|
class AbstractNewMultiArrayExpr implements NewMultiArrayExpr, ConvertToBaf {
protected ArrayType baseType;
protected final ValueBox[] sizeBoxes;
protected AbstractNewMultiArrayExpr(ArrayType type, ValueBox[] sizeBoxes) {
this.baseType = type;
this.sizeBoxes = sizeBoxes;
}
@Override
public abstract Object clone();
@Override
public boolean equivTo(Object o) {
if (o instanceof AbstractNewMultiArrayExpr) {
AbstractNewMultiArrayExpr ae = (AbstractNewMultiArrayExpr) o;
return baseType.equals(ae.baseType) && (this.sizeBoxes.length == ae.sizeBoxes.length);
}
return false;
}
/** Returns a hash code for this object, consistent with structural equality. */
@Override
public int equivHashCode() {
return baseType.hashCode();
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
@Override
public void toString(UnitPrinter up) {
up.literal(Jimple.NEWMULTIARRAY + " (");
up.type(baseType.baseType);
up.literal(")");
for (ValueBox element : sizeBoxes) {
up.literal("[");
element.toString(up);
up.literal("]");
}
for (int i = 0, e = baseType.numDimensions - sizeBoxes.length; i < e; i++) {
up.literal("[]");
}
}
@Override
public ArrayType getBaseType() {
return baseType;
}
@Override
public void setBaseType(ArrayType baseType) {
this.baseType = baseType;
}
@Override
public ValueBox getSizeBox(int index) {
return sizeBoxes[index];
}
@Override
public int getSizeCount() {
return sizeBoxes.length;
}
@Override
public Value getSize(int index) {
return sizeBoxes[index].getValue();
}
@Override
public List<Value> getSizes() {
final ValueBox[] boxes = sizeBoxes;
List<Value> toReturn = new ArrayList<Value>(boxes.length);
for (ValueBox element : boxes) {
toReturn.add(element.getValue());
}
return toReturn;
}
@Override
public void setSize(int index, Value size) {
sizeBoxes[index].setValue(size);
}
@Override
public final List<ValueBox> getUseBoxes() {
List<ValueBox> list = new ArrayList<ValueBox>();
Collections.addAll(list, sizeBoxes);
for (ValueBox element : sizeBoxes) {
list.addAll(element.getValue().getUseBoxes());
}
return list;
}
@Override
public Type getType() {
return baseType;
}
@Override
public void apply(Switch sw) {
((ExprSwitch) sw).caseNewMultiArrayExpr(this);
}
@Override
public void convertToBaf(JimpleToBafContext context, List<Unit> out) {
final List<Value> sizes = getSizes();
for (Value s : sizes) {
((ConvertToBaf) s).convertToBaf(context, out);
}
Unit u = Baf.v().newNewMultiArrayInst(getBaseType(), sizes.size());
out.add(u);
u.addAllTagsOf(context.getCurrentUnit());
}
}
|
StringBuilder buf = new StringBuilder(Jimple.NEWMULTIARRAY + " (");
buf.append(baseType.baseType.toString()).append(')');
for (ValueBox element : sizeBoxes) {
buf.append('[').append(element.getValue().toString()).append(']');
}
for (int i = 0, e = baseType.numDimensions - sizeBoxes.length; i < e; i++) {
buf.append("[]");
}
return buf.toString();
| 941
| 133
| 1,074
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/internal/AbstractSpecialInvokeExpr.java
|
AbstractSpecialInvokeExpr
|
toString
|
class AbstractSpecialInvokeExpr extends AbstractInstanceInvokeExpr
implements SpecialInvokeExpr, ConvertToBaf {
protected AbstractSpecialInvokeExpr(ValueBox baseBox, SootMethodRef methodRef, ValueBox[] argBoxes) {
super(methodRef, baseBox, argBoxes);
if (methodRef.isStatic()) {
throw new RuntimeException("wrong static-ness");
}
}
@Override
public boolean equivTo(Object o) {
if (o instanceof AbstractSpecialInvokeExpr) {
AbstractSpecialInvokeExpr ie = (AbstractSpecialInvokeExpr) o;
if ((this.argBoxes == null ? 0 : this.argBoxes.length) != (ie.argBoxes == null ? 0 : ie.argBoxes.length)
|| !this.getMethod().equals(ie.getMethod()) || !this.baseBox.getValue().equivTo(ie.baseBox.getValue())) {
return false;
}
if (this.argBoxes != null) {
for (int i = 0, e = this.argBoxes.length; i < e; i++) {
if (!this.argBoxes[i].getValue().equivTo(ie.argBoxes[i].getValue())) {
return false;
}
}
}
return true;
}
return false;
}
/**
* Returns a hash code for this object, consistent with structural equality.
*/
@Override
public int equivHashCode() {
return baseBox.getValue().equivHashCode() * 101 + getMethod().equivHashCode() * 17;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
@Override
public void toString(UnitPrinter up) {
up.literal(Jimple.SPECIALINVOKE + " ");
baseBox.toString(up);
up.literal(".");
up.methodRef(methodRef);
up.literal("(");
if (argBoxes != null) {
for (int i = 0, e = argBoxes.length; i < e; i++) {
if (i != 0) {
up.literal(", ");
}
argBoxes[i].toString(up);
}
}
up.literal(")");
}
@Override
public void apply(Switch sw) {
((ExprSwitch) sw).caseSpecialInvokeExpr(this);
}
@Override
public void convertToBaf(JimpleToBafContext context, List<Unit> out) {
((ConvertToBaf) (getBase())).convertToBaf(context, out);
if (argBoxes != null) {
for (ValueBox element : argBoxes) {
((ConvertToBaf) (element.getValue())).convertToBaf(context, out);
}
}
Unit u = Baf.v().newSpecialInvokeInst(methodRef);
out.add(u);
u.addAllTagsOf(context.getCurrentUnit());
}
}
|
StringBuilder buf = new StringBuilder(Jimple.SPECIALINVOKE + " ");
buf.append(baseBox.getValue().toString()).append('.').append(methodRef.getSignature()).append('(');
if (argBoxes != null) {
for (int i = 0, e = argBoxes.length; i < e; i++) {
if (i != 0) {
buf.append(", ");
}
buf.append(argBoxes[i].getValue().toString());
}
}
buf.append(')');
return buf.toString();
| 786
| 153
| 939
|
<methods>public soot.Value getBase() ,public soot.ValueBox getBaseBox() ,public List<soot.ValueBox> getUseBoxes() ,public void setBase(soot.Value) <variables>protected final non-sealed soot.ValueBox baseBox
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/internal/AbstractStaticInvokeExpr.java
|
AbstractStaticInvokeExpr
|
equivTo
|
class AbstractStaticInvokeExpr extends AbstractInvokeExpr implements StaticInvokeExpr, ConvertToBaf {
AbstractStaticInvokeExpr(SootMethodRef methodRef, List<Value> args) {
this(methodRef, new ValueBox[args.size()]);
final Jimple jimp = Jimple.v();
for (ListIterator<Value> it = args.listIterator(); it.hasNext();) {
Value v = it.next();
this.argBoxes[it.previousIndex()] = jimp.newImmediateBox(v);
}
}
protected AbstractStaticInvokeExpr(SootMethodRef methodRef, ValueBox[] argBoxes) {
super(methodRef, argBoxes);
if (!methodRef.isStatic()) {
throw new RuntimeException("wrong static-ness");
}
}
@Override
public boolean equivTo(Object o) {<FILL_FUNCTION_BODY>}
/**
* Returns a hash code for this object, consistent with structural equality.
*/
@Override
public int equivHashCode() {
return getMethod().equivHashCode();
}
@Override
public String toString() {
StringBuilder buf = new StringBuilder(Jimple.STATICINVOKE + " ");
buf.append(methodRef.getSignature()).append('(');
if (argBoxes != null) {
for (int i = 0, e = argBoxes.length; i < e; i++) {
if (i != 0) {
buf.append(", ");
}
buf.append(argBoxes[i].getValue().toString());
}
}
buf.append(')');
return buf.toString();
}
@Override
public void toString(UnitPrinter up) {
up.literal(Jimple.STATICINVOKE);
up.literal(" ");
up.methodRef(methodRef);
up.literal("(");
if (argBoxes != null) {
for (int i = 0, e = argBoxes.length; i < e; i++) {
if (i != 0) {
up.literal(", ");
}
argBoxes[i].toString(up);
}
}
up.literal(")");
}
@Override
public void apply(Switch sw) {
((ExprSwitch) sw).caseStaticInvokeExpr(this);
}
@Override
public void convertToBaf(JimpleToBafContext context, List<Unit> out) {
if (argBoxes != null) {
for (ValueBox element : argBoxes) {
((ConvertToBaf) (element.getValue())).convertToBaf(context, out);
}
}
Unit u = Baf.v().newStaticInvokeInst(methodRef);
out.add(u);
u.addAllTagsOf(context.getCurrentUnit());
}
}
|
if (o instanceof AbstractStaticInvokeExpr) {
AbstractStaticInvokeExpr ie = (AbstractStaticInvokeExpr) o;
if ((this.argBoxes == null ? 0 : this.argBoxes.length) != (ie.argBoxes == null ? 0 : ie.argBoxes.length)
|| !this.getMethod().equals(ie.getMethod())) {
return false;
}
if (this.argBoxes != null) {
for (int i = 0, e = this.argBoxes.length; i < e; i++) {
if (!this.argBoxes[i].getValue().equivTo(ie.argBoxes[i].getValue())) {
return false;
}
}
}
return true;
}
return false;
| 753
| 202
| 955
|
<methods>public abstract java.lang.Object clone() ,public soot.Value getArg(int) ,public soot.ValueBox getArgBox(int) ,public int getArgCount() ,public List<soot.Value> getArgs() ,public soot.SootMethod getMethod() ,public soot.SootMethodRef getMethodRef() ,public soot.Type getType() ,public List<soot.ValueBox> getUseBoxes() ,public void setArg(int, soot.Value) ,public void setMethodRef(soot.SootMethodRef) <variables>protected final non-sealed soot.ValueBox[] argBoxes,protected soot.SootMethodRef methodRef
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/internal/AbstractSwitchStmt.java
|
AbstractSwitchStmt
|
setTargets
|
class AbstractSwitchStmt extends AbstractStmt implements SwitchStmt {
protected final ValueBox keyBox;
protected final UnitBox defaultTargetBox;
protected final UnitBox[] targetBoxes;
protected final List<UnitBox> stmtBoxes;
protected AbstractSwitchStmt(ValueBox keyBox, UnitBox defaultTargetBox, UnitBox... targetBoxes) {
this.keyBox = keyBox;
this.defaultTargetBox = defaultTargetBox;
this.targetBoxes = targetBoxes;
// Build up stmtBoxes
List<UnitBox> list = new ArrayList<UnitBox>();
Collections.addAll(list, targetBoxes);
list.add(defaultTargetBox);
this.stmtBoxes = Collections.unmodifiableList(list);
}
// This method is necessary to deal with constructor-must-be-first-ism.
protected static UnitBox[] getTargetBoxesArray(List<? extends Unit> targets, Function<Unit, UnitBox> stmtBoxWrap) {
UnitBox[] targetBoxes = new UnitBox[targets.size()];
for (ListIterator<? extends Unit> it = targets.listIterator(); it.hasNext();) {
Unit u = it.next();
targetBoxes[it.previousIndex()] = stmtBoxWrap.apply(u);
}
return targetBoxes;
}
@Override
final public Unit getDefaultTarget() {
return defaultTargetBox.getUnit();
}
@Override
final public void setDefaultTarget(Unit defaultTarget) {
defaultTargetBox.setUnit(defaultTarget);
}
@Override
final public UnitBox getDefaultTargetBox() {
return defaultTargetBox;
}
@Override
final public Value getKey() {
return keyBox.getValue();
}
@Override
final public void setKey(Value key) {
keyBox.setValue(key);
}
@Override
final public ValueBox getKeyBox() {
return keyBox;
}
@Override
final public List<ValueBox> getUseBoxes() {
List<ValueBox> list = new ArrayList<ValueBox>(keyBox.getValue().getUseBoxes());
list.add(keyBox);
return list;
}
final public int getTargetCount() {
return targetBoxes.length;
}
@Override
final public Unit getTarget(int index) {
return targetBoxes[index].getUnit();
}
@Override
final public UnitBox getTargetBox(int index) {
return targetBoxes[index];
}
@Override
final public void setTarget(int index, Unit target) {
targetBoxes[index].setUnit(target);
}
@Override
final public List<Unit> getTargets() {
final UnitBox[] boxes = this.targetBoxes;
List<Unit> targets = new ArrayList<Unit>(boxes.length);
for (UnitBox element : boxes) {
targets.add(element.getUnit());
}
return targets;
}
final public void setTargets(List<? extends Unit> targets) {
for (ListIterator<? extends Unit> it = targets.listIterator(); it.hasNext();) {
Unit u = it.next();
targetBoxes[it.previousIndex()].setUnit(u);
}
}
final public void setTargets(Unit[] targets) {<FILL_FUNCTION_BODY>}
@Override
final public List<UnitBox> getUnitBoxes() {
return stmtBoxes;
}
@Override
public final boolean fallsThrough() {
return false;
}
@Override
public final boolean branches() {
return true;
}
}
|
for (int i = 0, e = targets.length; i < e; i++) {
targetBoxes[i].setUnit(targets[i]);
}
| 953
| 45
| 998
|
<methods>public non-sealed void <init>() ,public boolean containsArrayRef() ,public boolean containsFieldRef() ,public boolean containsInvokeExpr() ,public void convertToBaf(soot.jimple.JimpleToBafContext, List<soot.Unit>) ,public soot.jimple.ArrayRef getArrayRef() ,public soot.ValueBox getArrayRefBox() ,public soot.jimple.FieldRef getFieldRef() ,public soot.ValueBox getFieldRefBox() ,public soot.jimple.InvokeExpr getInvokeExpr() ,public soot.ValueBox getInvokeExprBox() <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/internal/JArrayRef.java
|
JArrayRef
|
getType
|
class JArrayRef implements ArrayRef, ConvertToBaf {
protected final ValueBox baseBox;
protected final ValueBox indexBox;
public JArrayRef(Value base, Value index) {
this(Jimple.v().newLocalBox(base), Jimple.v().newImmediateBox(index));
}
protected JArrayRef(ValueBox baseBox, ValueBox indexBox) {
this.baseBox = baseBox;
this.indexBox = indexBox;
}
@Override
public Object clone() {
return new JArrayRef(Jimple.cloneIfNecessary(getBase()), Jimple.cloneIfNecessary(getIndex()));
}
@Override
public boolean equivTo(Object o) {
if (o instanceof ArrayRef) {
ArrayRef oArrayRef = (ArrayRef) o;
return this.getBase().equivTo(oArrayRef.getBase()) && this.getIndex().equivTo(oArrayRef.getIndex());
}
return false;
}
/** Returns a hash code for this object, consistent with structural equality. */
@Override
public int equivHashCode() {
return getBase().equivHashCode() * 101 + getIndex().equivHashCode() + 17;
}
@Override
public String toString() {
return baseBox.getValue().toString() + "[" + indexBox.getValue().toString() + "]";
}
@Override
public void toString(UnitPrinter up) {
baseBox.toString(up);
up.literal("[");
indexBox.toString(up);
up.literal("]");
}
@Override
public Value getBase() {
return baseBox.getValue();
}
@Override
public void setBase(Local base) {
baseBox.setValue(base);
}
@Override
public ValueBox getBaseBox() {
return baseBox;
}
@Override
public Value getIndex() {
return indexBox.getValue();
}
@Override
public void setIndex(Value index) {
indexBox.setValue(index);
}
@Override
public ValueBox getIndexBox() {
return indexBox;
}
@Override
public List<ValueBox> getUseBoxes() {
List<ValueBox> useBoxes = new ArrayList<ValueBox>();
useBoxes.addAll(baseBox.getValue().getUseBoxes());
useBoxes.add(baseBox);
useBoxes.addAll(indexBox.getValue().getUseBoxes());
useBoxes.add(indexBox);
return useBoxes;
}
@Override
public Type getType() {<FILL_FUNCTION_BODY>}
@Override
public void apply(Switch sw) {
((RefSwitch) sw).caseArrayRef(this);
}
@Override
public void convertToBaf(JimpleToBafContext context, List<Unit> out) {
((ConvertToBaf) getBase()).convertToBaf(context, out);
((ConvertToBaf) getIndex()).convertToBaf(context, out);
Unit x = Baf.v().newArrayReadInst(getType());
out.add(x);
for (Tag next : context.getCurrentUnit().getTags()) {
x.addTag(next);
}
}
}
|
Type type = baseBox.getValue().getType();
if (UnknownType.v().equals(type)) {
return UnknownType.v();
} else if (NullType.v().equals(type)) {
return NullType.v();
} else {
// use makeArrayType on non-array type references when they propagate to this point.
// kludge, most likely not correct.
// may stop spark from complaining when it gets passed phantoms.
// ideally I'd want to find out just how they manage to get this far.
ArrayType arrayType = (type instanceof ArrayType) ? (ArrayType) type : (ArrayType) type.makeArrayType();
if (arrayType.numDimensions == 1) {
return arrayType.baseType;
} else {
return ArrayType.v(arrayType.baseType, arrayType.numDimensions - 1);
}
}
| 867
| 227
| 1,094
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/internal/JEnterMonitorStmt.java
|
JEnterMonitorStmt
|
convertToBaf
|
class JEnterMonitorStmt extends AbstractOpStmt implements EnterMonitorStmt {
public JEnterMonitorStmt(Value op) {
this(Jimple.v().newImmediateBox(op));
}
protected JEnterMonitorStmt(ValueBox opBox) {
super(opBox);
}
@Override
public Object clone() {
return new JEnterMonitorStmt(Jimple.cloneIfNecessary(getOp()));
}
@Override
public String toString() {
return Jimple.ENTERMONITOR + " " + opBox.getValue().toString();
}
@Override
public void toString(UnitPrinter up) {
up.literal(Jimple.ENTERMONITOR + " ");
opBox.toString(up);
}
@Override
public void apply(Switch sw) {
((StmtSwitch) sw).caseEnterMonitorStmt(this);
}
@Override
public void convertToBaf(JimpleToBafContext context, List<Unit> out) {<FILL_FUNCTION_BODY>}
@Override
public boolean fallsThrough() {
return true;
}
@Override
public boolean branches() {
return false;
}
}
|
((ConvertToBaf) (getOp())).convertToBaf(context, out);
Unit u = Baf.v().newEnterMonitorInst();
u.addAllTagsOf(this);
out.add(u);
| 323
| 59
| 382
|
<methods>public final soot.Value getOp() ,public final soot.ValueBox getOpBox() ,public final List<soot.ValueBox> getUseBoxes() ,public final void setOp(soot.Value) <variables>protected final non-sealed soot.ValueBox opBox
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/internal/JEqExpr.java
|
JEqExpr
|
makeBafInst
|
class JEqExpr extends AbstractJimpleIntBinopExpr implements EqExpr {
public JEqExpr(Value op1, Value op2) {
super(op1, op2);
}
@Override
public final String getSymbol() {
return " == ";
}
@Override
public void apply(Switch sw) {
((ExprSwitch) sw).caseEqExpr(this);
}
@Override
protected Unit makeBafInst(Type opType) {<FILL_FUNCTION_BODY>}
@Override
public Object clone() {
return new JEqExpr(Jimple.cloneIfNecessary(getOp1()), Jimple.cloneIfNecessary(getOp2()));
}
}
|
throw new RuntimeException("unsupported conversion: " + this);
// return Baf.v().newEqInst(this.getOp1().getType()); }
| 187
| 41
| 228
|
<methods>public void convertToBaf(soot.jimple.JimpleToBafContext, List<soot.Unit>) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/internal/JExitMonitorStmt.java
|
JExitMonitorStmt
|
convertToBaf
|
class JExitMonitorStmt extends AbstractOpStmt implements ExitMonitorStmt {
public JExitMonitorStmt(Value op) {
this(Jimple.v().newImmediateBox(op));
}
protected JExitMonitorStmt(ValueBox opBox) {
super(opBox);
}
@Override
public Object clone() {
return new JExitMonitorStmt(Jimple.cloneIfNecessary(getOp()));
}
@Override
public String toString() {
return Jimple.EXITMONITOR + " " + opBox.getValue().toString();
}
@Override
public void toString(UnitPrinter up) {
up.literal(Jimple.EXITMONITOR + " ");
opBox.toString(up);
}
@Override
public void apply(Switch sw) {
((StmtSwitch) sw).caseExitMonitorStmt(this);
}
@Override
public void convertToBaf(JimpleToBafContext context, List<Unit> out) {<FILL_FUNCTION_BODY>}
@Override
public boolean fallsThrough() {
return true;
}
@Override
public boolean branches() {
return false;
}
}
|
((ConvertToBaf) (getOp())).convertToBaf(context, out);
Unit u = Baf.v().newExitMonitorInst();
u.addAllTagsOf(this);
out.add(u);
| 325
| 60
| 385
|
<methods>public final soot.Value getOp() ,public final soot.ValueBox getOpBox() ,public final List<soot.ValueBox> getUseBoxes() ,public final void setOp(soot.Value) <variables>protected final non-sealed soot.ValueBox opBox
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/internal/JGeExpr.java
|
JGeExpr
|
makeBafInst
|
class JGeExpr extends AbstractJimpleIntBinopExpr implements GeExpr {
public JGeExpr(Value op1, Value op2) {
super(op1, op2);
}
@Override
public final String getSymbol() {
return " >= ";
}
@Override
public void apply(Switch sw) {
((ExprSwitch) sw).caseGeExpr(this);
}
@Override
protected Unit makeBafInst(Type opType) {<FILL_FUNCTION_BODY>}
@Override
public Object clone() {
return new JGeExpr(Jimple.cloneIfNecessary(getOp1()), Jimple.cloneIfNecessary(getOp2()));
}
}
|
throw new RuntimeException("unsupported conversion: " + this);
// return Baf.v().newGeInst(this.getOp1().getType());
| 187
| 40
| 227
|
<methods>public void convertToBaf(soot.jimple.JimpleToBafContext, List<soot.Unit>) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/internal/JGotoStmt.java
|
JGotoStmt
|
convertToBaf
|
class JGotoStmt extends AbstractStmt implements GotoStmt {
protected final UnitBox targetBox;
protected final List<UnitBox> targetBoxes;
public JGotoStmt(Unit target) {
this(Jimple.v().newStmtBox(target));
}
public JGotoStmt(UnitBox box) {
this.targetBox = box;
this.targetBoxes = Collections.singletonList(box);
}
@Override
public Object clone() {
return new JGotoStmt(getTarget());
}
@Override
public String toString() {
Unit t = getTarget();
String target = t.branches() ? "(branch)" : t.toString();
return Jimple.GOTO + " [?= " + target + "]";
}
@Override
public void toString(UnitPrinter up) {
up.literal(Jimple.GOTO + " ");
targetBox.toString(up);
}
@Override
public Unit getTarget() {
return targetBox.getUnit();
}
@Override
public void setTarget(Unit target) {
targetBox.setUnit(target);
}
@Override
public UnitBox getTargetBox() {
return targetBox;
}
@Override
public List<UnitBox> getUnitBoxes() {
return targetBoxes;
}
@Override
public void apply(Switch sw) {
((StmtSwitch) sw).caseGotoStmt(this);
}
@Override
public void convertToBaf(JimpleToBafContext context, List<Unit> out) {<FILL_FUNCTION_BODY>}
@Override
public boolean fallsThrough() {
return false;
}
@Override
public boolean branches() {
return true;
}
}
|
final Baf vaf = Baf.v();
Unit u = vaf.newGotoInst(vaf.newPlaceholderInst(getTarget()));
u.addAllTagsOf(this);
out.add(u);
| 486
| 59
| 545
|
<methods>public non-sealed void <init>() ,public boolean containsArrayRef() ,public boolean containsFieldRef() ,public boolean containsInvokeExpr() ,public void convertToBaf(soot.jimple.JimpleToBafContext, List<soot.Unit>) ,public soot.jimple.ArrayRef getArrayRef() ,public soot.ValueBox getArrayRefBox() ,public soot.jimple.FieldRef getFieldRef() ,public soot.ValueBox getFieldRefBox() ,public soot.jimple.InvokeExpr getInvokeExpr() ,public soot.ValueBox getInvokeExprBox() <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/internal/JGtExpr.java
|
JGtExpr
|
makeBafInst
|
class JGtExpr extends AbstractJimpleIntBinopExpr implements GtExpr {
public JGtExpr(Value op1, Value op2) {
super(op1, op2);
}
@Override
public final String getSymbol() {
return " > ";
}
@Override
public void apply(Switch sw) {
((ExprSwitch) sw).caseGtExpr(this);
}
@Override
protected Unit makeBafInst(Type opType) {<FILL_FUNCTION_BODY>}
@Override
public Object clone() {
return new JGtExpr(Jimple.cloneIfNecessary(getOp1()), Jimple.cloneIfNecessary(getOp2()));
}
}
|
throw new RuntimeException("unsupported conversion: " + this);
// return Baf.v().newGtInst(this.getOp1().getType());
| 192
| 41
| 233
|
<methods>public void convertToBaf(soot.jimple.JimpleToBafContext, List<soot.Unit>) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/internal/JInstanceOfExpr.java
|
JInstanceOfExpr
|
convertToBaf
|
class JInstanceOfExpr extends AbstractInstanceOfExpr implements ConvertToBaf {
public JInstanceOfExpr(Value op, Type checkType) {
super(Jimple.v().newImmediateBox(op), checkType);
}
@Override
public void convertToBaf(JimpleToBafContext context, List<Unit> out) {<FILL_FUNCTION_BODY>}
@Override
public Object clone() {
return new JInstanceOfExpr(Jimple.cloneIfNecessary(getOp()), checkType);
}
}
|
((ConvertToBaf) (getOp())).convertToBaf(context, out);
Unit u = Baf.v().newInstanceOfInst(getCheckType());
u.addAllTagsOf(context.getCurrentUnit());
out.add(u);
| 141
| 67
| 208
|
<methods>public void apply(soot.util.Switch) ,public abstract java.lang.Object clone() ,public int equivHashCode() ,public boolean equivTo(java.lang.Object) ,public soot.Type getCheckType() ,public soot.Value getOp() ,public soot.ValueBox getOpBox() ,public soot.Type getType() ,public final List<soot.ValueBox> getUseBoxes() ,public void setCheckType(soot.Type) ,public void setOp(soot.Value) ,public java.lang.String toString() ,public void toString(soot.UnitPrinter) <variables>protected soot.Type checkType,protected final non-sealed soot.ValueBox opBox
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/internal/JInterfaceInvokeExpr.java
|
JInterfaceInvokeExpr
|
clone
|
class JInterfaceInvokeExpr extends AbstractInterfaceInvokeExpr {
public JInterfaceInvokeExpr(Value base, SootMethodRef methodRef, List<? extends Value> args) {
super(Jimple.v().newLocalBox(base), methodRef, new ValueBox[args.size()]);
// Check that the method's class is resolved enough
final SootClass declaringClass = methodRef.declaringClass();
// CheckLevel returns without doing anything because we can be not 'done' resolving
declaringClass.checkLevelIgnoreResolving(SootClass.HIERARCHY);
// now check if the class is valid
if (!declaringClass.isInterface() && !declaringClass.isPhantom()) {
throw new RuntimeException("Trying to create interface invoke expression for non-interface type: " + declaringClass
+ " Use JVirtualInvokeExpr or JSpecialInvokeExpr instead!");
}
final Jimple jimp = Jimple.v();
for (ListIterator<? extends Value> it = args.listIterator(); it.hasNext();) {
Value v = it.next();
this.argBoxes[it.previousIndex()] = jimp.newImmediateBox(v);
}
}
@Override
public Object clone() {<FILL_FUNCTION_BODY>}
}
|
final int count = getArgCount();
List<Value> clonedArgs = new ArrayList<Value>(count);
for (int i = 0; i < count; i++) {
clonedArgs.add(Jimple.cloneIfNecessary(getArg(i)));
}
return new JInterfaceInvokeExpr(Jimple.cloneIfNecessary(getBase()), methodRef, clonedArgs);
| 327
| 104
| 431
|
<methods>public void apply(soot.util.Switch) ,public void convertToBaf(soot.jimple.JimpleToBafContext, List<soot.Unit>) ,public int equivHashCode() ,public boolean equivTo(java.lang.Object) ,public java.lang.String toString() ,public void toString(soot.UnitPrinter) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/internal/JInvokeStmt.java
|
JInvokeStmt
|
convertToBaf
|
class JInvokeStmt extends AbstractStmt implements InvokeStmt {
protected final ValueBox invokeExprBox;
public JInvokeStmt(Value c) {
this(Jimple.v().newInvokeExprBox(c));
}
protected JInvokeStmt(ValueBox invokeExprBox) {
this.invokeExprBox = invokeExprBox;
}
@Override
public Object clone() {
return new JInvokeStmt(Jimple.cloneIfNecessary(getInvokeExpr()));
}
@Override
public boolean containsInvokeExpr() {
return true;
}
@Override
public String toString() {
return invokeExprBox.getValue().toString();
}
@Override
public void toString(UnitPrinter up) {
invokeExprBox.toString(up);
}
@Override
public void setInvokeExpr(Value invokeExpr) {
invokeExprBox.setValue(invokeExpr);
}
@Override
public InvokeExpr getInvokeExpr() {
return (InvokeExpr) invokeExprBox.getValue();
}
@Override
public ValueBox getInvokeExprBox() {
return invokeExprBox;
}
@Override
public List<ValueBox> getUseBoxes() {
List<ValueBox> list = new ArrayList<ValueBox>(invokeExprBox.getValue().getUseBoxes());
list.add(invokeExprBox);
return list;
}
@Override
public void apply(Switch sw) {
((StmtSwitch) sw).caseInvokeStmt(this);
}
@Override
public void convertToBaf(JimpleToBafContext context, List<Unit> out) {<FILL_FUNCTION_BODY>}
@Override
public boolean fallsThrough() {
return true;
}
@Override
public boolean branches() {
return false;
}
}
|
InvokeExpr ie = getInvokeExpr();
context.setCurrentUnit(this);
((ConvertToBaf) ie).convertToBaf(context, out);
Type returnType = ie.getMethodRef().returnType();
if (!VoidType.v().equals(returnType)) {
Unit u = Baf.v().newPopInst(returnType);
u.addAllTagsOf(this);
out.add(u);
}
| 495
| 120
| 615
|
<methods>public non-sealed void <init>() ,public boolean containsArrayRef() ,public boolean containsFieldRef() ,public boolean containsInvokeExpr() ,public void convertToBaf(soot.jimple.JimpleToBafContext, List<soot.Unit>) ,public soot.jimple.ArrayRef getArrayRef() ,public soot.ValueBox getArrayRefBox() ,public soot.jimple.FieldRef getFieldRef() ,public soot.ValueBox getFieldRefBox() ,public soot.jimple.InvokeExpr getInvokeExpr() ,public soot.ValueBox getInvokeExprBox() <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/internal/JLeExpr.java
|
JLeExpr
|
makeBafInst
|
class JLeExpr extends AbstractJimpleIntBinopExpr implements LeExpr {
public JLeExpr(Value op1, Value op2) {
super(op1, op2);
}
@Override
public final String getSymbol() {
return " <= ";
}
@Override
public void apply(Switch sw) {
((ExprSwitch) sw).caseLeExpr(this);
}
@Override
protected Unit makeBafInst(Type opType) {<FILL_FUNCTION_BODY>}
@Override
public Object clone() {
return new JLeExpr(Jimple.cloneIfNecessary(getOp1()), Jimple.cloneIfNecessary(getOp2()));
}
}
|
throw new RuntimeException("unsupported conversion: " + this);
// return Baf.v().newLeInst(this.getOp1().getType());
| 187
| 40
| 227
|
<methods>public void convertToBaf(soot.jimple.JimpleToBafContext, List<soot.Unit>) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/internal/JLengthExpr.java
|
JLengthExpr
|
convertToBaf
|
class JLengthExpr extends AbstractLengthExpr implements ConvertToBaf {
public JLengthExpr(Value op) {
super(Jimple.v().newImmediateBox(op));
}
@Override
public void convertToBaf(JimpleToBafContext context, List<Unit> out) {<FILL_FUNCTION_BODY>}
@Override
public Object clone() {
return new JLengthExpr(Jimple.cloneIfNecessary(getOp()));
}
}
|
((ConvertToBaf) (getOp())).convertToBaf(context, out);
Unit u = Baf.v().newArrayLengthInst();
u.addAllTagsOf(context.getCurrentUnit());
out.add(u);
| 127
| 64
| 191
|
<methods>public void apply(soot.util.Switch) ,public int equivHashCode() ,public boolean equivTo(java.lang.Object) ,public soot.Type getType() ,public java.lang.String toString() ,public void toString(soot.UnitPrinter) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/internal/JLtExpr.java
|
JLtExpr
|
makeBafInst
|
class JLtExpr extends AbstractJimpleIntBinopExpr implements LtExpr {
public JLtExpr(Value op1, Value op2) {
super(op1, op2);
}
@Override
public final String getSymbol() {
return " < ";
}
@Override
public void apply(Switch sw) {
((ExprSwitch) sw).caseLtExpr(this);
}
@Override
protected Unit makeBafInst(Type opType) {<FILL_FUNCTION_BODY>}
@Override
public Object clone() {
return new JLtExpr(Jimple.cloneIfNecessary(getOp1()), Jimple.cloneIfNecessary(getOp2()));
}
}
|
throw new RuntimeException("unsupported conversion: " + this);
// return Baf.v().newLtInst(this.getOp1().getType());
| 192
| 41
| 233
|
<methods>public void convertToBaf(soot.jimple.JimpleToBafContext, List<soot.Unit>) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/internal/JNeExpr.java
|
JNeExpr
|
makeBafInst
|
class JNeExpr extends AbstractJimpleIntBinopExpr implements NeExpr {
public JNeExpr(Value op1, Value op2) {
super(op1, op2);
}
@Override
public final String getSymbol() {
return " != ";
}
@Override
public void apply(Switch sw) {
((ExprSwitch) sw).caseNeExpr(this);
}
@Override
protected Unit makeBafInst(Type opType) {<FILL_FUNCTION_BODY>}
@Override
public Object clone() {
return new JNeExpr(Jimple.cloneIfNecessary(getOp1()), Jimple.cloneIfNecessary(getOp2()));
}
}
|
throw new RuntimeException("unsupported conversion: " + this);
// return Baf.v().newNeInst(this.getOp1().getType());
| 188
| 40
| 228
|
<methods>public void convertToBaf(soot.jimple.JimpleToBafContext, List<soot.Unit>) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/internal/JNegExpr.java
|
JNegExpr
|
convertToBaf
|
class JNegExpr extends AbstractNegExpr implements ConvertToBaf {
public JNegExpr(Value op) {
super(Jimple.v().newImmediateBox(op));
}
@Override
public void convertToBaf(JimpleToBafContext context, List<Unit> out) {<FILL_FUNCTION_BODY>}
@Override
public Object clone() {
return new JNegExpr(Jimple.cloneIfNecessary(getOp()));
}
}
|
((ConvertToBaf) (getOp())).convertToBaf(context, out);
Unit u = Baf.v().newNegInst(getType());
u.addAllTagsOf(context.getCurrentUnit());
out.add(u);
| 127
| 65
| 192
|
<methods>public void apply(soot.util.Switch) ,public int equivHashCode() ,public boolean equivTo(java.lang.Object) ,public soot.Type getType() ,public java.lang.String toString() ,public void toString(soot.UnitPrinter) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/internal/JNewMultiArrayExpr.java
|
JNewMultiArrayExpr
|
clone
|
class JNewMultiArrayExpr extends AbstractNewMultiArrayExpr {
public JNewMultiArrayExpr(ArrayType type, List<? extends Value> sizes) {
super(type, new ValueBox[sizes.size()]);
final Jimple jimp = Jimple.v();
for (ListIterator<? extends Value> it = sizes.listIterator(); it.hasNext();) {
Value v = it.next();
sizeBoxes[it.previousIndex()] = jimp.newImmediateBox(v);
}
}
public JNewMultiArrayExpr(ArrayType type, ValueBox[] sizes) {
super(type, sizes);
for (int i = 0; i < sizes.length; i++) {
ValueBox v = sizes[i];
sizeBoxes[i] = v;
}
}
@Override
public Object clone() {<FILL_FUNCTION_BODY>}
}
|
final ValueBox[] boxes = this.sizeBoxes;
List<Value> clonedSizes = new ArrayList<Value>(boxes.length);
for (ValueBox vb : boxes) {
clonedSizes.add(Jimple.cloneIfNecessary(vb.getValue()));
}
return new JNewMultiArrayExpr(baseType, clonedSizes);
| 231
| 96
| 327
|
<methods>public void apply(soot.util.Switch) ,public abstract java.lang.Object clone() ,public void convertToBaf(soot.jimple.JimpleToBafContext, List<soot.Unit>) ,public int equivHashCode() ,public boolean equivTo(java.lang.Object) ,public soot.ArrayType getBaseType() ,public soot.Value getSize(int) ,public soot.ValueBox getSizeBox(int) ,public int getSizeCount() ,public List<soot.Value> getSizes() ,public soot.Type getType() ,public final List<soot.ValueBox> getUseBoxes() ,public void setBaseType(soot.ArrayType) ,public void setSize(int, soot.Value) ,public java.lang.String toString() ,public void toString(soot.UnitPrinter) <variables>protected soot.ArrayType baseType,protected final non-sealed soot.ValueBox[] sizeBoxes
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/internal/JReturnStmt.java
|
JReturnStmt
|
convertToBaf
|
class JReturnStmt extends AbstractOpStmt implements ReturnStmt {
public JReturnStmt(Value returnValue) {
this(Jimple.v().newImmediateBox(returnValue));
}
protected JReturnStmt(ValueBox returnValueBox) {
super(returnValueBox);
}
@Override
public Object clone() {
return new JReturnStmt(Jimple.cloneIfNecessary(getOp()));
}
@Override
public String toString() {
return Jimple.RETURN + " " + opBox.getValue().toString();
}
@Override
public void toString(UnitPrinter up) {
up.literal(Jimple.RETURN + " ");
opBox.toString(up);
}
@Override
public void apply(Switch sw) {
((StmtSwitch) sw).caseReturnStmt(this);
}
@Override
public void convertToBaf(JimpleToBafContext context, List<Unit> out) {<FILL_FUNCTION_BODY>}
@Override
public boolean fallsThrough() {
return false;
}
@Override
public boolean branches() {
return false;
}
}
|
((ConvertToBaf) (getOp())).convertToBaf(context, out);
Unit u = Baf.v().newReturnInst(getOp().getType());
u.addAllTagsOf(this);
out.add(u);
| 315
| 65
| 380
|
<methods>public final soot.Value getOp() ,public final soot.ValueBox getOpBox() ,public final List<soot.ValueBox> getUseBoxes() ,public final void setOp(soot.Value) <variables>protected final non-sealed soot.ValueBox opBox
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/internal/JShrExpr.java
|
JShrExpr
|
getType
|
class JShrExpr extends AbstractJimpleIntLongBinopExpr implements ShrExpr {
public JShrExpr(Value op1, Value op2) {
super(op1, op2);
}
@Override
public String getSymbol() {
return " >> ";
}
@Override
public void apply(Switch sw) {
((ExprSwitch) sw).caseShrExpr(this);
}
@Override
protected Unit makeBafInst(Type opType) {
return Baf.v().newShrInst(this.getOp1().getType());
}
@Override
public Type getType() {<FILL_FUNCTION_BODY>}
@Override
public Object clone() {
return new JShrExpr(Jimple.cloneIfNecessary(getOp1()), Jimple.cloneIfNecessary(getOp2()));
}
}
|
if (isIntLikeType(op2Box.getValue().getType())) {
final Type t1 = op1Box.getValue().getType();
if (isIntLikeType(t1)) {
return IntType.v();
}
final LongType tyLong = LongType.v();
if (tyLong.equals(t1)) {
return tyLong;
}
}
return UnknownType.v();
| 230
| 108
| 338
|
<methods>public void convertToBaf(soot.jimple.JimpleToBafContext, List<soot.Unit>) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/internal/JSpecialInvokeExpr.java
|
JSpecialInvokeExpr
|
clone
|
class JSpecialInvokeExpr extends AbstractSpecialInvokeExpr {
public JSpecialInvokeExpr(Local base, SootMethodRef methodRef, List<? extends Value> args) {
super(Jimple.v().newLocalBox(base), methodRef, new ImmediateBox[args.size()]);
final Jimple jimp = Jimple.v();
for (ListIterator<? extends Value> it = args.listIterator(); it.hasNext();) {
Value v = it.next();
this.argBoxes[it.previousIndex()] = jimp.newImmediateBox(v);
}
}
@Override
public Object clone() {<FILL_FUNCTION_BODY>}
}
|
final int count = getArgCount();
List<Value> clonedArgs = new ArrayList<Value>(count);
for (int i = 0; i < count; i++) {
clonedArgs.add(Jimple.cloneIfNecessary(getArg(i)));
}
return new JSpecialInvokeExpr((Local) getBase(), methodRef, clonedArgs);
| 177
| 96
| 273
|
<methods>public void apply(soot.util.Switch) ,public void convertToBaf(soot.jimple.JimpleToBafContext, List<soot.Unit>) ,public int equivHashCode() ,public boolean equivTo(java.lang.Object) ,public java.lang.String toString() ,public void toString(soot.UnitPrinter) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/internal/JStaticInvokeExpr.java
|
JStaticInvokeExpr
|
clone
|
class JStaticInvokeExpr extends AbstractStaticInvokeExpr {
public JStaticInvokeExpr(SootMethodRef methodRef, List<? extends Value> args) {
super(methodRef, new ValueBox[args.size()]);
final Jimple jimp = Jimple.v();
for (ListIterator<? extends Value> it = args.listIterator(); it.hasNext();) {
Value v = it.next();
this.argBoxes[it.previousIndex()] = jimp.newImmediateBox(v);
}
}
@Override
public Object clone() {<FILL_FUNCTION_BODY>}
}
|
final int count = getArgCount();
List<Value> clonedArgs = new ArrayList<Value>(count);
for (int i = 0; i < count; i++) {
clonedArgs.add(Jimple.cloneIfNecessary(getArg(i)));
}
return new JStaticInvokeExpr(methodRef, clonedArgs);
| 161
| 91
| 252
|
<methods>public void apply(soot.util.Switch) ,public void convertToBaf(soot.jimple.JimpleToBafContext, List<soot.Unit>) ,public int equivHashCode() ,public boolean equivTo(java.lang.Object) ,public java.lang.String toString() ,public void toString(soot.UnitPrinter) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/internal/JTableSwitchStmt.java
|
JTableSwitchStmt
|
convertToBaf
|
class JTableSwitchStmt extends AbstractSwitchStmt implements TableSwitchStmt {
protected int lowIndex;
protected int highIndex;
public JTableSwitchStmt(Value key, int lowIndex, int highIndex, List<? extends Unit> targets, Unit defaultTarget) {
this(Jimple.v().newImmediateBox(key), lowIndex, highIndex, getTargetBoxesArray(targets, Jimple.v()::newStmtBox),
Jimple.v().newStmtBox(defaultTarget));
}
public JTableSwitchStmt(Value key, int lowIndex, int highIndex, List<? extends UnitBox> targets, UnitBox defaultTarget) {
this(Jimple.v().newImmediateBox(key), lowIndex, highIndex, targets.toArray(new UnitBox[targets.size()]), defaultTarget);
}
protected JTableSwitchStmt(ValueBox keyBox, int lowIndex, int highIndex, UnitBox[] targetBoxes, UnitBox defaultTargetBox) {
super(keyBox, defaultTargetBox, targetBoxes);
if (lowIndex > highIndex) {
throw new RuntimeException(
"Error creating tableswitch: lowIndex(" + lowIndex + ") can't be greater than highIndex(" + highIndex + ").");
}
this.lowIndex = lowIndex;
this.highIndex = highIndex;
}
@Override
public Object clone() {
return new JTableSwitchStmt(Jimple.cloneIfNecessary(getKey()), lowIndex, highIndex, getTargets(), getDefaultTarget());
}
@Override
public String toString() {
final char endOfLine = ' ';
StringBuilder buf = new StringBuilder(Jimple.TABLESWITCH + "(");
buf.append(keyBox.getValue().toString()).append(')').append(endOfLine);
buf.append('{').append(endOfLine);
// In this for-loop, we cannot use "<=" since 'i' would wrap around.
// The case for "i == highIndex" is handled separately after the loop.
final int low = lowIndex, high = highIndex;
for (int i = low; i < high; i++) {
buf.append(" " + Jimple.CASE + " ").append(i).append(": " + Jimple.GOTO + " ");
Unit target = getTarget(i - low);
buf.append(target == this ? "self" : target).append(';').append(endOfLine);
}
{
buf.append(" " + Jimple.CASE + " ").append(high).append(": " + Jimple.GOTO + " ");
Unit target = getTarget(high - low);
buf.append(target == this ? "self" : target).append(';').append(endOfLine);
}
{
Unit target = getDefaultTarget();
buf.append(" " + Jimple.DEFAULT + ": " + Jimple.GOTO + " ");
buf.append(target == this ? "self" : target).append(';').append(endOfLine);
}
buf.append('}');
return buf.toString();
}
@Override
public void toString(UnitPrinter up) {
up.literal(Jimple.TABLESWITCH);
up.literal("(");
keyBox.toString(up);
up.literal(")");
up.newline();
up.literal("{");
up.newline();
// In this for-loop, we cannot use "<=" since 'i' would wrap around.
// The case for "i == highIndex" is handled separately after the loop.
final int high = highIndex;
for (int i = lowIndex; i < high; i++) {
printCaseTarget(up, i);
}
printCaseTarget(up, high);
up.literal(" " + Jimple.DEFAULT + ": " + Jimple.GOTO + " ");
defaultTargetBox.toString(up);
up.literal(";");
up.newline();
up.literal("}");
}
private void printCaseTarget(UnitPrinter up, int targetIndex) {
up.literal(" " + Jimple.CASE + " ");
up.literal(Integer.toString(targetIndex));
up.literal(": " + Jimple.GOTO + " ");
targetBoxes[targetIndex - lowIndex].toString(up);
up.literal(";");
up.newline();
}
@Override
public void setLowIndex(int lowIndex) {
this.lowIndex = lowIndex;
}
@Override
public void setHighIndex(int highIndex) {
this.highIndex = highIndex;
}
@Override
public int getLowIndex() {
return lowIndex;
}
@Override
public int getHighIndex() {
return highIndex;
}
@Override
public void apply(Switch sw) {
((StmtSwitch) sw).caseTableSwitchStmt(this);
}
@Override
public void convertToBaf(JimpleToBafContext context, List<Unit> out) {<FILL_FUNCTION_BODY>}
@Override
public Unit getTargetForValue(int value) {
final int high = highIndex;
int tgtIdx = 0;
// In this for-loop, we cannot use "<=" since 'i' would wrap around.
// The case for "i == highIndex" is handled separately after the loop.
for (int i = lowIndex; i < high; i++) {
if (value == i) {
return getTarget(tgtIdx);
}
tgtIdx++;
}
if (high == value) {
return getTarget(tgtIdx);
}
return getDefaultTarget();
}
}
|
((ConvertToBaf) getKey()).convertToBaf(context, out);
final Baf vaf = Baf.v();
final List<Unit> targets = getTargets();
List<PlaceholderInst> targetPlaceholders = new ArrayList<PlaceholderInst>(targets.size());
for (Unit target : targets) {
targetPlaceholders.add(vaf.newPlaceholderInst(target));
}
Unit u = vaf.newTableSwitchInst(vaf.newPlaceholderInst(getDefaultTarget()), lowIndex, highIndex, targetPlaceholders);
u.addAllTagsOf(this);
out.add(u);
| 1,492
| 161
| 1,653
|
<methods>public final boolean branches() ,public final boolean fallsThrough() ,public final soot.Unit getDefaultTarget() ,public final soot.UnitBox getDefaultTargetBox() ,public final soot.Value getKey() ,public final soot.ValueBox getKeyBox() ,public final soot.Unit getTarget(int) ,public final soot.UnitBox getTargetBox(int) ,public final int getTargetCount() ,public final List<soot.Unit> getTargets() ,public final List<soot.UnitBox> getUnitBoxes() ,public final List<soot.ValueBox> getUseBoxes() ,public final void setDefaultTarget(soot.Unit) ,public final void setKey(soot.Value) ,public final void setTarget(int, soot.Unit) ,public final void setTargets(List<? extends soot.Unit>) ,public final void setTargets(soot.Unit[]) <variables>protected final non-sealed soot.UnitBox defaultTargetBox,protected final non-sealed soot.ValueBox keyBox,protected final non-sealed List<soot.UnitBox> stmtBoxes,protected final non-sealed soot.UnitBox[] targetBoxes
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/internal/JThrowStmt.java
|
JThrowStmt
|
convertToBaf
|
class JThrowStmt extends AbstractOpStmt implements ThrowStmt {
public JThrowStmt(Value op) {
this(Jimple.v().newImmediateBox(op));
}
protected JThrowStmt(ValueBox opBox) {
super(opBox);
}
@Override
public Object clone() {
return new JThrowStmt(Jimple.cloneIfNecessary(getOp()));
}
@Override
public String toString() {
return Jimple.THROW + " " + opBox.getValue().toString();
}
@Override
public void toString(UnitPrinter up) {
up.literal(Jimple.THROW + " ");
opBox.toString(up);
}
@Override
public void apply(Switch sw) {
((StmtSwitch) sw).caseThrowStmt(this);
}
@Override
public void convertToBaf(JimpleToBafContext context, List<Unit> out) {<FILL_FUNCTION_BODY>}
@Override
public boolean fallsThrough() {
return false;
}
@Override
public boolean branches() {
return false;
}
}
|
((ConvertToBaf) getOp()).convertToBaf(context, out);
Unit u = Baf.v().newThrowInst();
u.addAllTagsOf(this);
out.add(u);
| 312
| 57
| 369
|
<methods>public final soot.Value getOp() ,public final soot.ValueBox getOpBox() ,public final List<soot.ValueBox> getUseBoxes() ,public final void setOp(soot.Value) <variables>protected final non-sealed soot.ValueBox opBox
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/internal/JVirtualInvokeExpr.java
|
JVirtualInvokeExpr
|
clone
|
class JVirtualInvokeExpr extends AbstractVirtualInvokeExpr {
public JVirtualInvokeExpr(Value base, SootMethodRef methodRef, List<? extends Value> args) {
super(Jimple.v().newLocalBox(base), methodRef, new ValueBox[args.size()]);
if (!Options.v().ignore_resolution_errors()) {
final SootClass sc = methodRef.declaringClass();
// Check that the method's class is resolved enough
sc.checkLevelIgnoreResolving(SootClass.HIERARCHY);
// now check if the class is valid
if (sc.isInterface()) {
SourceFileTag tag = (SourceFileTag) sc.getTag(SourceFileTag.NAME);
throw new RuntimeException("Trying to create virtual invoke expression for interface type (" + sc.getName()
+ " in file " + (tag != null ? tag.getAbsolutePath() : "unknown") + "). Use JInterfaceInvokeExpr instead!");
}
}
final Jimple jimp = Jimple.v();
for (ListIterator<? extends Value> it = args.listIterator(); it.hasNext();) {
Value v = it.next();
this.argBoxes[it.previousIndex()] = jimp.newImmediateBox(v);
}
}
@Override
public Object clone() {<FILL_FUNCTION_BODY>}
}
|
final int count = getArgCount();
List<Value> clonedArgs = new ArrayList<Value>(count);
for (int i = 0; i < count; i++) {
clonedArgs.add(Jimple.cloneIfNecessary(getArg(i)));
}
return new JVirtualInvokeExpr(getBase(), methodRef, clonedArgs);
| 348
| 94
| 442
|
<methods>public void apply(soot.util.Switch) ,public void convertToBaf(soot.jimple.JimpleToBafContext, List<soot.Unit>) ,public int equivHashCode() ,public boolean equivTo(java.lang.Object) ,public java.lang.String toString() ,public void toString(soot.UnitPrinter) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/internal/JimpleLocal.java
|
JimpleLocal
|
equivHashCode
|
class JimpleLocal implements Local, ConvertToBaf {
protected String name;
protected Type type;
private volatile int number = 0;
/** Constructs a JimpleLocal of the given name and type. */
public JimpleLocal(String name, Type type) {
setName(name);
setType(type);
}
/** Returns true if the given object is structurally equal to this one. */
@Override
public boolean equivTo(Object o) {
return this.equals(o);
}
/**
* Returns a hash code for this object, consistent with structural equality.
*/
@Override
public int equivHashCode() {<FILL_FUNCTION_BODY>}
/** Returns a clone of the current JimpleLocal. */
@Override
public Object clone() {
// do not intern the name again
JimpleLocal local = new JimpleLocal(null, type);
local.name = name;
return local;
}
/** Returns the name of this object. */
@Override
public String getName() {
return name;
}
/** Sets the name of this object as given. */
@Override
public void setName(String name) {
this.name = (name == null) ? null : name.intern();
}
/** Returns the type of this local. */
@Override
public Type getType() {
return type;
}
/** Sets the type of this local. */
@Override
public void setType(Type t) {
this.type = t;
}
@Override
public String toString() {
return getName();
}
@Override
public void toString(UnitPrinter up) {
up.local(this);
}
@Override
public final List<ValueBox> getUseBoxes() {
return Collections.emptyList();
}
@Override
public void apply(Switch sw) {
((JimpleValueSwitch) sw).caseLocal(this);
}
@Override
public void convertToBaf(JimpleToBafContext context, List<Unit> out) {
Unit u = Baf.v().newLoadInst(getType(), context.getBafLocalOfJimpleLocal(this));
u.addAllTagsOf(context.getCurrentUnit());
out.add(u);
}
@Override
public final int getNumber() {
return number;
}
@Override
public void setNumber(int number) {
this.number = number;
}
@Override
public boolean isStackLocal() {
String n = getName();
return n != null && n.charAt(0) == '$';
}
}
|
final int prime = 31;
int result = 1;
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((type == null) ? 0 : type.hashCode());
return result;
| 699
| 68
| 767
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/internal/RValueBox.java
|
RValueBox
|
canContainValue
|
class RValueBox extends AbstractValueBox {
public RValueBox(Value value) {
setValue(value);
}
@Override
public boolean canContainValue(Value value) {<FILL_FUNCTION_BODY>}
}
|
return value instanceof Immediate || value instanceof ConcreteRef || value instanceof Expr;
| 64
| 22
| 86
|
<methods>public non-sealed void <init>() ,public soot.Value getValue() ,public void setValue(soot.Value) ,public void toString(soot.UnitPrinter) ,public java.lang.String toString() <variables>protected soot.Value value
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/paddle/PaddleHook.java
|
PaddleHook
|
paddleG
|
class PaddleHook extends SceneTransformer {
public PaddleHook(Singletons.Global g) {
}
public static PaddleHook v() {
return G.v().soot_jimple_paddle_PaddleHook();
}
private IPaddleTransformer paddleTransformer;
public IPaddleTransformer paddleTransformer() {
if (paddleTransformer == null) {
paddleTransformer = (IPaddleTransformer) instantiate("soot.jimple.paddle.PaddleTransformer");
}
return paddleTransformer;
}
protected void internalTransform(String phaseName, Map<String, String> options) {
paddleTransformer().transform(phaseName, options);
}
public Object instantiate(String className) {
Object ret;
try {
ret = Class.forName(className).newInstance();
} catch (ClassNotFoundException e) {
throw new RuntimeException("Could not find " + className + ". Did you include Paddle on your Java classpath?");
} catch (InstantiationException e) {
throw new RuntimeException("Could not instantiate " + className + ": " + e);
} catch (IllegalAccessException e) {
throw new RuntimeException("Could not instantiate " + className + ": " + e);
}
return ret;
}
private Object paddleG;
public Object paddleG() {<FILL_FUNCTION_BODY>}
/**
* This is called when Soot finishes executing all interprocedural phases. Paddle uses it to stop profiling if profiling is
* enabled.
*/
public void finishPhases() {
if (paddleTransformer != null) {
paddleTransformer().finishPhases();
}
}
}
|
if (paddleG == null) {
paddleG = instantiate("soot.PaddleG");
}
return paddleG;
| 451
| 40
| 491
|
<methods>public non-sealed void <init>() ,public final void transform(java.lang.String, Map<java.lang.String,java.lang.String>) ,public final void transform(java.lang.String) ,public final void transform() <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/parser/BodyExtractorWalker.java
|
BodyExtractorWalker
|
caseAFile
|
class BodyExtractorWalker extends Walker {
private static final Logger logger = LoggerFactory.getLogger(BodyExtractorWalker.class);
Map<SootMethod, JimpleBody> methodToParsedBodyMap;
/**
* Constructs a walker, and attaches it to the given SootClass, sending bodies to the given methodToParsedBodyMap.
*/
public BodyExtractorWalker(SootClass sc, SootResolver resolver, Map<SootMethod, JimpleBody> methodToParsedBodyMap) {
super(sc, resolver);
this.methodToParsedBodyMap = methodToParsedBodyMap;
}
/*
* file = modifier* file_type class_name extends_clause? implements_clause? file_body;
*/
public void caseAFile(AFile node) {<FILL_FUNCTION_BODY>}
public void outAFile(AFile node) {
if (node.getImplementsClause() != null) {
mProductions.removeLast(); // implements_clause
}
if (node.getExtendsClause() != null) {
mProductions.removeLast(); // extends_clause
}
mProductions.removeLast(); // file_type
mProductions.addLast(mSootClass);
}
/*
* member = {field} modifier* type name semicolon | {method} modifier* type name l_paren parameter_list? r_paren
* throws_clause? method_body;
*/
public void outAFieldMember(AFieldMember node) {
mProductions.removeLast(); // name
mProductions.removeLast(); // type
}
public void outAMethodMember(AMethodMember node) {
Type type;
String name;
List<Type> parameterList = new ArrayList<Type>();
List throwsClause = null;
JimpleBody methodBody = null;
if (node.getMethodBody() instanceof AFullMethodBody) {
methodBody = (JimpleBody) mProductions.removeLast();
}
if (node.getThrowsClause() != null) {
throwsClause = (List) mProductions.removeLast();
}
if (node.getParameterList() != null) {
parameterList = (List) mProductions.removeLast();
}
name = (String) mProductions.removeLast(); // name
type = (Type) mProductions.removeLast(); // type
SootMethod sm = mSootClass.getMethodUnsafe(SootMethod.getSubSignature(name, parameterList, type));
if (sm != null) {
if (Options.v().verbose()) {
logger.debug("[Jimple parser] " + SootMethod.getSubSignature(name, parameterList, type));
}
} else {
logger.debug("[!!! Couldn't parse !!] " + SootMethod.getSubSignature(name, parameterList, type));
logger.debug("[!] Methods in class are:");
for (SootMethod next : mSootClass.getMethods()) {
logger.debug("" + next.getSubSignature());
}
}
if (sm.isConcrete() && methodBody != null) {
if (Options.v().verbose()) {
logger.debug("[Parsed] " + sm.getDeclaration());
}
methodBody.setMethod(sm);
methodToParsedBodyMap.put(sm, methodBody);
} else if (node.getMethodBody() instanceof AFullMethodBody) {
if (sm.isPhantom() && Options.v().verbose()) {
logger.debug("[jimple parser] phantom method!");
}
throw new RuntimeException("Impossible: !concrete => ! instanceof " + sm.getName());
}
}
}
|
inAFile(node);
{
Object temp[] = node.getModifier().toArray();
for (Object element : temp) {
((PModifier) element).apply(this);
}
}
if (node.getFileType() != null) {
node.getFileType().apply(this);
}
if (node.getClassName() != null) {
node.getClassName().apply(this);
}
String className = (String) mProductions.removeLast();
if (!className.equals(mSootClass.getName())) {
throw new RuntimeException("expected: " + className + ", but got: " + mSootClass.getName());
}
if (node.getExtendsClause() != null) {
node.getExtendsClause().apply(this);
}
if (node.getImplementsClause() != null) {
node.getImplementsClause().apply(this);
}
if (node.getFileBody() != null) {
node.getFileBody().apply(this);
}
outAFile(node);
| 986
| 287
| 1,273
|
<methods>public void <init>(soot.SootResolver) ,public void <init>(soot.SootClass, soot.SootResolver) ,public void caseAFile(AFile) ,public void defaultCase(Node) ,public soot.SootClass getSootClass() ,public void inAFile(AFile) ,public void inAFullMethodBody(AFullMethodBody) ,public void outAAndBinop(AAndBinop) ,public void outAArrayNewExpr(AArrayNewExpr) ,public void outAArrayReference(AArrayReference) ,public void outAAssignStatement(AAssignStatement) ,public void outABaseNonvoidType(ABaseNonvoidType) ,public void outABinopBoolExpr(ABinopBoolExpr) ,public void outABinopExpr(ABinopExpr) ,public void outABooleanBaseType(ABooleanBaseType) ,public void outABooleanBaseTypeNoName(ABooleanBaseTypeNoName) ,public void outABreakpointStatement(ABreakpointStatement) ,public void outAByteBaseType(AByteBaseType) ,public void outAByteBaseTypeNoName(AByteBaseTypeNoName) ,public void outACaseStmt(ACaseStmt) ,public void outACastExpression(ACastExpression) ,public void outACatchClause(ACatchClause) ,public void outACharBaseType(ACharBaseType) ,public void outACharBaseTypeNoName(ACharBaseTypeNoName) ,public void outAClassFileType(AClassFileType) ,public void outAClassNameBaseType(AClassNameBaseType) ,public void outAClassNameMultiClassNameList(AClassNameMultiClassNameList) ,public void outAClassNameSingleClassNameList(AClassNameSingleClassNameList) ,public void outAClzzConstant(AClzzConstant) ,public void outACmpBinop(ACmpBinop) ,public void outACmpeqBinop(ACmpeqBinop) ,public void outACmpgBinop(ACmpgBinop) ,public void outACmpgeBinop(ACmpgeBinop) ,public void outACmpgtBinop(ACmpgtBinop) ,public void outACmplBinop(ACmplBinop) ,public void outACmpleBinop(ACmpleBinop) ,public void outACmpltBinop(ACmpltBinop) ,public void outACmpneBinop(ACmpneBinop) ,public void outAConstantCaseLabel(AConstantCaseLabel) ,public void outADeclaration(ADeclaration) ,public void outADivBinop(ADivBinop) ,public void outADoubleBaseType(ADoubleBaseType) ,public void outADoubleBaseTypeNoName(ADoubleBaseTypeNoName) ,public void outADynamicInvokeExpr(ADynamicInvokeExpr) ,public void outAEntermonitorStatement(AEntermonitorStatement) ,public void outAExitmonitorStatement(AExitmonitorStatement) ,public void outAFieldMember(AFieldMember) ,public void outAFieldSignature(AFieldSignature) ,public void outAFile(AFile) ,public void outAFloatBaseType(AFloatBaseType) ,public void outAFloatBaseTypeNoName(AFloatBaseTypeNoName) ,public void outAFloatConstant(AFloatConstant) ,public void outAFullIdentNonvoidType(AFullIdentNonvoidType) ,public void outAFullMethodBody(AFullMethodBody) ,public void outAGotoStatement(AGotoStatement) ,public void outAIdentNonvoidType(AIdentNonvoidType) ,public void outAIdentityNoTypeStatement(AIdentityNoTypeStatement) ,public void outAIdentityStatement(AIdentityStatement) ,public void outAIfStatement(AIfStatement) ,public void outAInstanceofExpression(AInstanceofExpression) ,public void outAIntBaseType(AIntBaseType) ,public void outAIntBaseTypeNoName(AIntBaseTypeNoName) ,public void outAIntegerConstant(AIntegerConstant) ,public void outAInterfaceFileType(AInterfaceFileType) ,public void outAInvokeStatement(AInvokeStatement) ,public void outALabelStatement(ALabelStatement) ,public void outALengthofUnop(ALengthofUnop) ,public void outALocalFieldRef(ALocalFieldRef) ,public void outALocalImmediate(ALocalImmediate) ,public void outALocalVariable(ALocalVariable) ,public void outALongBaseType(ALongBaseType) ,public void outALongBaseTypeNoName(ALongBaseTypeNoName) ,public void outALookupswitchStatement(ALookupswitchStatement) ,public void outAMethodMember(AMethodMember) ,public void outAMethodSignature(AMethodSignature) ,public void outAMinusBinop(AMinusBinop) ,public void outAModBinop(AModBinop) ,public void outAMultBinop(AMultBinop) ,public void outAMultiArgList(AMultiArgList) ,public void outAMultiLocalNameList(AMultiLocalNameList) ,public void outAMultiNewExpr(AMultiNewExpr) ,public void outAMultiParameterList(AMultiParameterList) ,public void outANegUnop(ANegUnop) ,public void outANonstaticInvokeExpr(ANonstaticInvokeExpr) ,public void outANopStatement(ANopStatement) ,public void outANovoidType(ANovoidType) ,public void outANullBaseType(ANullBaseType) ,public void outANullBaseTypeNoName(ANullBaseTypeNoName) ,public void outANullConstant(ANullConstant) ,public void outAOrBinop(AOrBinop) ,public void outAPlusBinop(APlusBinop) ,public void outAQuotedNonvoidType(AQuotedNonvoidType) ,public void outARetStatement(ARetStatement) ,public void outAReturnStatement(AReturnStatement) ,public void outAShlBinop(AShlBinop) ,public void outAShortBaseType(AShortBaseType) ,public void outAShortBaseTypeNoName(AShortBaseTypeNoName) ,public void outAShrBinop(AShrBinop) ,public void outASigFieldRef(ASigFieldRef) ,public void outASimpleNewExpr(ASimpleNewExpr) ,public void outASingleArgList(ASingleArgList) ,public void outASingleLocalNameList(ASingleLocalNameList) ,public void outASingleParameterList(ASingleParameterList) ,public void outAStaticInvokeExpr(AStaticInvokeExpr) ,public void outAStringConstant(AStringConstant) ,public void outATableswitchStatement(ATableswitchStatement) ,public void outAThrowStatement(AThrowStatement) ,public void outAThrowsClause(AThrowsClause) ,public void outAUnknownJimpleType(AUnknownJimpleType) ,public void outAUnnamedMethodSignature(AUnnamedMethodSignature) ,public void outAUnopExpr(AUnopExpr) ,public void outAUnopExpression(AUnopExpression) ,public void outAUshrBinop(AUshrBinop) ,public void outAVoidType(AVoidType) ,public void outAXorBinop(AXorBinop) ,public void outStart(Start) <variables>boolean debug,private static final org.slf4j.Logger logger,Map<java.lang.String,List#RAW> mLabelToPatchList,Map<java.lang.Object,soot.Unit> mLabelToStmtMap,Map<java.lang.String,soot.Local> mLocals,LinkedList#RAW mProductions,protected final non-sealed soot.SootResolver mResolver,soot.SootClass mSootClass,soot.Value mValue
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/parser/CstPoolExtractor.java
|
CstPoolExtractorWalker
|
outAFullIdentNonvoidType
|
class CstPoolExtractorWalker extends DepthFirstAdapter {
CstPoolExtractorWalker() {
}
public void inStart(Start node) {
defaultIn(node);
}
public void outAQuotedClassName(AQuotedClassName node) {
String tokenString = node.getQuotedName().getText();
tokenString = tokenString.substring(1, tokenString.length() - 1);
tokenString = StringTools.getUnEscapedStringOf(tokenString);
mRefTypes.add(tokenString);
}
public void outAIdentClassName(AIdentClassName node) {
String tokenString = node.getIdentifier().getText();
tokenString = StringTools.getUnEscapedStringOf(tokenString);
mRefTypes.add(tokenString);
}
public void outAFullIdentClassName(AFullIdentClassName node) {
String tokenString = node.getFullIdentifier().getText();
tokenString = Scene.v().unescapeName(tokenString);
tokenString = StringTools.getUnEscapedStringOf(tokenString);
mRefTypes.add(tokenString);
}
public void outAQuotedNonvoidType(AQuotedNonvoidType node) {
String tokenString = node.getQuotedName().getText();
tokenString = tokenString.substring(1, tokenString.length() - 1);
tokenString = StringTools.getUnEscapedStringOf(tokenString);
mRefTypes.add(tokenString);
}
public void outAFullIdentNonvoidType(AFullIdentNonvoidType node) {<FILL_FUNCTION_BODY>}
public void outAIdentNonvoidType(AIdentNonvoidType node) {
String tokenString = node.getIdentifier().getText();
tokenString = StringTools.getUnEscapedStringOf(tokenString);
mRefTypes.add(tokenString);
}
}
|
String tokenString = node.getFullIdentifier().getText();
tokenString = Scene.v().unescapeName(tokenString);
tokenString = StringTools.getUnEscapedStringOf(tokenString);
mRefTypes.add(tokenString);
| 485
| 64
| 549
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/parser/Parse.java
|
Parse
|
main
|
class Parse {
private static final Logger logger = LoggerFactory.getLogger(Parse.class);
private static final String EXT = ".jimple";
private static final String USAGE = "usage: java Parse [options] " + "jimple_file [jimple_file ...]";
/*
* Parses a jimple input stream. If you just want to get the method bodies for a SootClass, pass as the second argument the
* SootClass you want fill it's method bodies. If you want to create a SootClass for the inputStream set the 2nd arg to
* null.
*/
static public SootClass parse(InputStream istream, SootClass sc) {
Start tree = null;
Parser p = new Parser(
new Lexer(new PushbackReader(new EscapedReader(new BufferedReader(new InputStreamReader(istream))), 1024)));
try {
tree = p.parse();
} catch (ParserException e) {
throw new RuntimeException("Parser exception occurred: " + e);
} catch (LexerException e) {
throw new RuntimeException("Lexer exception occurred: " + e);
} catch (IOException e) {
throw new RuntimeException("IOException occurred: " + e);
}
Walker w;
if (sc == null) {
w = new Walker(null);
} else {
w = new BodyExtractorWalker(sc, null, new HashMap<SootMethod, JimpleBody>());
}
tree.apply(w);
return w.getSootClass();
}
public static void main(String args[]) throws java.lang.Exception
{<FILL_FUNCTION_BODY>} // main
}
|
boolean verbose = false;
InputStream inFile;
// check arguments
if (args.length < 1) {
logger.debug("" + USAGE);
System.exit(0);
}
Scene.v().setPhantomRefs(true);
for (String arg : args) {
if (arg.startsWith("-")) {
arg = arg.substring(1);
if (arg.equals("d")) {
} else if (arg.equals("v")) {
verbose = true;
}
} else {
try {
if (verbose) {
logger.debug(" ... looking for " + arg);
}
inFile = new FileInputStream(arg);
} catch (FileNotFoundException e) {
if (arg.endsWith(EXT)) {
logger.debug(" *** can't find " + arg);
continue;
}
arg = arg + EXT;
try {
if (verbose) {
logger.debug(" ... looking for " + arg);
}
inFile = new BufferedInputStream(new FileInputStream(arg));
} catch (FileNotFoundException ee) {
logger.debug(" *** can't find " + arg);
continue;
}
}
Parser p = new Parser(new Lexer(new PushbackReader(new InputStreamReader(inFile), 1024)));
Start tree = p.parse();
tree.apply(new Walker(null));
}
}
| 444
| 386
| 830
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/spark/builder/ContextInsensitiveBuilder.java
|
ContextInsensitiveBuilder
|
build
|
class ContextInsensitiveBuilder {
private static final Logger logger = LoggerFactory.getLogger(ContextInsensitiveBuilder.class);
public void preJimplify() {
boolean change = true;
while (change) {
change = false;
for (Iterator<SootClass> cIt = new ArrayList<>(Scene.v().getClasses()).iterator(); cIt.hasNext();) {
final SootClass c = cIt.next();
for (final SootMethod m : c.getMethods()) {
if (!m.isConcrete() || m.isNative() || m.isPhantom()) {
continue;
}
if (!m.hasActiveBody()) {
change = true;
m.retrieveActiveBody();
}
}
}
}
}
/** Creates an empty pointer assignment graph. */
public PAG setup(SparkOptions opts) {
pag = opts.geom_pta() ? new GeomPointsTo(opts) : new PAG(opts);
if (opts.simulate_natives()) {
pag.nativeMethodDriver = new NativeMethodDriver(new SparkNativeHelper(pag));
}
if (opts.on_fly_cg() && !opts.vta()) {
ofcg = new OnFlyCallGraph(pag, opts.apponly());
pag.setOnFlyCallGraph(ofcg);
} else {
cgb = new CallGraphBuilder(DumbPointerAnalysis.v());
}
return pag;
}
/** Fills in the pointer assignment graph returned by setup. */
public void build() {<FILL_FUNCTION_BODY>}
/* End of public methods. */
/* End of package methods. */
protected void handleClass(SootClass c) {
boolean incedClasses = false;
if (c.isConcrete() || Scene.v().getFastHierarchy().getSubclassesOf(c).stream().anyMatch(SootClass::isConcrete)) {
for (SootMethod m : c.getMethods()) {
if (!m.isConcrete() && !m.isNative()) {
continue;
}
totalMethods++;
if (reachables.contains(m)) {
MethodPAG mpag = MethodPAG.v(pag, m);
mpag.build();
mpag.addToPAG(null);
analyzedMethods++;
if (!incedClasses) {
incedClasses = true;
classes++;
}
}
}
}
}
protected PAG pag;
protected CallGraphBuilder cgb;
protected OnFlyCallGraph ofcg;
protected ReachableMethods reachables;
int classes = 0;
int totalMethods = 0;
int analyzedMethods = 0;
int stmts = 0;
}
|
QueueReader<Edge> callEdges;
if (ofcg != null) {
callEdges = ofcg.callGraph().listener();
ofcg.build();
reachables = ofcg.reachableMethods();
reachables.update();
} else {
callEdges = cgb.getCallGraph().listener();
cgb.build();
reachables = cgb.reachables();
}
for (final SootClass c : new ArrayList<>(Scene.v().getClasses())) {
handleClass(c);
}
while (callEdges.hasNext()) {
Edge e = callEdges.next();
if (e == null) {
continue;
}
if (!e.isInvalid()) {
if (e.tgt().isConcrete() || e.tgt().isNative()) {
MethodPAG mpag = MethodPAG.v(pag, e.tgt());
mpag.build();
mpag.addToPAG(null);
}
pag.addCallTarget(e);
}
}
if (pag.getOpts().verbose()) {
logger.debug("Total methods: " + totalMethods);
logger.debug("Initially reachable methods: " + analyzedMethods);
logger.debug("Classes with at least one reachable method: " + classes);
}
| 706
| 345
| 1,051
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/spark/builder/GlobalNodeFactory.java
|
GlobalNodeFactory
|
caseNewInstance
|
class GlobalNodeFactory {
protected final RefType rtObject;
protected final RefType rtClassLoader;
protected final RefType rtString;
protected final RefType rtThread;
protected final RefType rtThreadGroup;
protected final RefType rtThrowable;
public GlobalNodeFactory(PAG pag) {
this.pag = pag;
this.rtObject = Scene.v().getObjectType();
this.rtClassLoader = RefType.v("java.lang.ClassLoader");
this.rtString = RefType.v("java.lang.String");
this.rtThread = RefType.v("java.lang.Thread");
this.rtThreadGroup = RefType.v("java.lang.ThreadGroup");
this.rtThrowable = Scene.v().getBaseExceptionType();
}
final public Node caseDefaultClassLoader() {
AllocNode a = pag.makeAllocNode(PointsToAnalysis.DEFAULT_CLASS_LOADER, AnySubType.v(rtClassLoader), null);
VarNode v = pag.makeGlobalVarNode(PointsToAnalysis.DEFAULT_CLASS_LOADER_LOCAL, rtClassLoader);
pag.addEdge(a, v);
return v;
}
final public Node caseMainClassNameString() {
AllocNode a = pag.makeAllocNode(PointsToAnalysis.MAIN_CLASS_NAME_STRING, rtString, null);
VarNode v = pag.makeGlobalVarNode(PointsToAnalysis.MAIN_CLASS_NAME_STRING_LOCAL, rtString);
pag.addEdge(a, v);
return v;
}
final public Node caseMainThreadGroup() {
AllocNode threadGroupNode = pag.makeAllocNode(PointsToAnalysis.MAIN_THREAD_GROUP_NODE, rtThreadGroup, null);
VarNode threadGroupNodeLocal = pag.makeGlobalVarNode(PointsToAnalysis.MAIN_THREAD_GROUP_NODE_LOCAL, rtThreadGroup);
pag.addEdge(threadGroupNode, threadGroupNodeLocal);
return threadGroupNodeLocal;
}
final public Node casePrivilegedActionException() {
AllocNode a = pag.makeAllocNode(PointsToAnalysis.PRIVILEGED_ACTION_EXCEPTION,
AnySubType.v(RefType.v("java.security.PrivilegedActionException")), null);
VarNode v = pag.makeGlobalVarNode(PointsToAnalysis.PRIVILEGED_ACTION_EXCEPTION_LOCAL,
RefType.v("java.security.PrivilegedActionException"));
pag.addEdge(a, v);
return v;
}
final public Node caseCanonicalPath() {
AllocNode a = pag.makeAllocNode(PointsToAnalysis.CANONICAL_PATH, rtString, null);
VarNode v = pag.makeGlobalVarNode(PointsToAnalysis.CANONICAL_PATH_LOCAL, rtString);
pag.addEdge(a, v);
return v;
}
final public Node caseMainThread() {
AllocNode threadNode = pag.makeAllocNode(PointsToAnalysis.MAIN_THREAD_NODE, rtThread, null);
VarNode threadNodeLocal = pag.makeGlobalVarNode(PointsToAnalysis.MAIN_THREAD_NODE_LOCAL, rtThread);
pag.addEdge(threadNode, threadNodeLocal);
return threadNodeLocal;
}
final public Node caseFinalizeQueue() {
return pag.makeGlobalVarNode(PointsToAnalysis.FINALIZE_QUEUE, rtObject);
}
final public Node caseArgv() {
ArrayType strArray = ArrayType.v(rtString, 1);
AllocNode argv = pag.makeAllocNode(PointsToAnalysis.STRING_ARRAY_NODE, strArray, null);
VarNode sanl = pag.makeGlobalVarNode(PointsToAnalysis.STRING_ARRAY_NODE_LOCAL, strArray);
AllocNode stringNode = pag.makeAllocNode(PointsToAnalysis.STRING_NODE, rtString, null);
VarNode stringNodeLocal = pag.makeGlobalVarNode(PointsToAnalysis.STRING_NODE_LOCAL, rtString);
pag.addEdge(argv, sanl);
pag.addEdge(stringNode, stringNodeLocal);
pag.addEdge(stringNodeLocal, pag.makeFieldRefNode(sanl, ArrayElement.v()));
return sanl;
}
final public Node caseNewInstance(VarNode cls) {<FILL_FUNCTION_BODY>}
public Node caseThrow() {
VarNode ret = pag.makeGlobalVarNode(PointsToAnalysis.EXCEPTION_NODE, rtThrowable);
ret.setInterProcTarget();
ret.setInterProcSource();
return ret;
}
/* End of public methods. */
/* End of package methods. */
protected PAG pag;
}
|
if (cls instanceof ContextVarNode) {
cls = pag.findLocalVarNode(cls.getVariable());
}
VarNode local = pag.makeGlobalVarNode(cls, rtObject);
for (SootClass cl : Scene.v().dynamicClasses()) {
AllocNode site = pag.makeAllocNode(new Pair<VarNode, SootClass>(cls, cl), cl.getType(), null);
pag.addEdge(site, local);
}
return local;
| 1,223
| 126
| 1,349
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/spark/fieldrw/FieldTagger.java
|
FieldTagger
|
internalTransform
|
class FieldTagger extends BodyTransformer {
public FieldTagger(Singletons.Global g) {
}
public static FieldTagger v() {
return G.v().soot_jimple_spark_fieldrw_FieldTagger();
}
private final HashSet<SootMethod> processedMethods = new HashSet<SootMethod>();
private final HashMultiMap methodToWrite = new HashMultiMap();
private final HashMultiMap methodToRead = new HashMultiMap();
protected void ensureProcessed(SootMethod m) {
if (processedMethods.contains(m)) {
return;
}
processedMethods.add(m);
if (!m.isConcrete() || m.isPhantom()) {
return;
}
for (Iterator sIt = m.retrieveActiveBody().getUnits().iterator(); sIt.hasNext();) {
final Stmt s = (Stmt) sIt.next();
if (s instanceof AssignStmt) {
AssignStmt as = (AssignStmt) s;
Value l = as.getLeftOp();
if (l instanceof FieldRef) {
methodToWrite.put(m, ((FieldRef) l).getField());
}
Value r = as.getRightOp();
if (r instanceof FieldRef) {
methodToRead.put(m, ((FieldRef) r).getField());
}
}
}
}
protected void internalTransform(Body body, String phaseName, Map options) {<FILL_FUNCTION_BODY>}
}
|
int threshold = PhaseOptions.getInt(options, "threshold");
ensureProcessed(body.getMethod());
CallGraph cg = Scene.v().getCallGraph();
TransitiveTargets tt = new TransitiveTargets(cg);
statement: for (Iterator sIt = body.getUnits().iterator(); sIt.hasNext();) {
final Stmt s = (Stmt) sIt.next();
HashSet read = new HashSet();
HashSet write = new HashSet();
Iterator<MethodOrMethodContext> it = tt.iterator(s);
while (it.hasNext()) {
SootMethod target = (SootMethod) it.next();
ensureProcessed(target);
if (target.isNative() || target.isPhantom()) {
continue statement;
}
read.addAll(methodToRead.get(target));
write.addAll(methodToWrite.get(target));
if (read.size() + write.size() > threshold) {
continue statement;
}
}
s.addTag(new FieldReadTag(read));
s.addTag(new FieldWriteTag(write));
}
| 393
| 298
| 691
|
<methods>public non-sealed void <init>() ,public final void transform(soot.Body, java.lang.String, Map<java.lang.String,java.lang.String>) ,public final void transform(soot.Body, java.lang.String) ,public final void transform(soot.Body) <variables>private static final Map<java.lang.String,java.lang.String> enabledOnlyMap
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/spark/geom/dataMgr/Obj_full_extractor.java
|
Obj_full_extractor
|
visit
|
class Obj_full_extractor extends PtSensVisitor<IntervalContextVar> {
private List<IntervalContextVar> backupList = new ArrayList<IntervalContextVar>();
private IntervalContextVar tmp_icv = new IntervalContextVar();
@Override
public boolean visit(Node var, long L, long R, int sm_int) {<FILL_FUNCTION_BODY>}
}
|
if (readyToUse) {
return false;
}
List<IntervalContextVar> resList = tableView.get(var);
if (resList == null) {
// The first time this object is inserted
resList = new ArrayList<IntervalContextVar>();
} else {
// We search the list and merge the context sensitive objects
backupList.clear();
tmp_icv.L = L;
tmp_icv.R = R;
for (IntervalContextVar old_cv : resList) {
if (old_cv.contains(tmp_icv)) {
/*
* Becase we keep the intervals disjoint. It's impossible the passed in interval is contained in an interval or
* intersects with other intervals. In such case, we can directly return.
*/
return false;
}
if (!tmp_icv.merge(old_cv)) {
backupList.add(old_cv);
}
}
// We switch the backup list with the original list
List<IntervalContextVar> tmpList = backupList;
backupList = resList;
resList = tmpList;
// Write back
L = tmp_icv.L;
R = tmp_icv.R;
}
IntervalContextVar icv = new IntervalContextVar(L, R, var);
resList.add(icv);
tableView.put(var, resList);
return true;
| 100
| 366
| 466
|
<methods>public non-sealed void <init>() ,public void debugPrint() ,public void finish() ,public List<soot.jimple.spark.geom.dataRep.IntervalContextVar> getCSList(soot.jimple.spark.pag.Node) ,public boolean getUsageState() ,public boolean hasNonEmptyIntersection(PtSensVisitor<soot.jimple.spark.geom.dataRep.IntervalContextVar>) ,public int numOfDiffObjects() ,public void prepare() ,public soot.PointsToSet toSparkCompatiableResult(soot.jimple.spark.pag.VarNode) ,public abstract boolean visit(soot.jimple.spark.pag.Node, long, long, int) <variables>public List<soot.jimple.spark.geom.dataRep.IntervalContextVar> outList,protected soot.jimple.spark.geom.geomPA.GeomPointsTo ptsProvider,protected boolean readyToUse,protected Map<soot.jimple.spark.pag.Node,List<soot.jimple.spark.geom.dataRep.IntervalContextVar>> tableView
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/spark/geom/dataMgr/PtSensVisitor.java
|
PtSensVisitor
|
hasNonEmptyIntersection
|
class PtSensVisitor<VarType extends ContextVar> {
// Indicates if this visitor is prepared
protected boolean readyToUse = false;
protected GeomPointsTo ptsProvider = (GeomPointsTo) Scene.v().getPointsToAnalysis();
// The list view
public List<VarType> outList = new ArrayList<VarType>();
// The table view (cannot be accessed directly outside)
protected Map<Node, List<VarType>> tableView = new HashMap<Node, List<VarType>>();
/**
* Called before each round of collection.
*/
public void prepare() {
tableView.clear();
readyToUse = false;
}
/**
* Called after each round of collection.
*/
public void finish() {
if (!readyToUse) {
// We flatten the list
readyToUse = true;
outList.clear();
if (tableView.size() == 0) {
return;
}
for (Map.Entry<Node, List<VarType>> entry : tableView.entrySet()) {
List<VarType> resList = entry.getValue();
outList.addAll(resList);
}
}
}
/**
* The visitor contains valid information only when this function returns true.
*
* @return
*/
public boolean getUsageState() {
return readyToUse;
}
/**
* Return the number of different points-to targets.
*/
public int numOfDiffObjects() {
return readyToUse ? outList.size() : tableView.size();
}
/**
* Tests if two containers have contain same things. Can be used to answer the alias query.
*/
public boolean hasNonEmptyIntersection(PtSensVisitor<VarType> other) {<FILL_FUNCTION_BODY>}
/**
* Obtain the list of context sensitive objects pointed to by var.
*
* @param var
* @return
*/
public List<VarType> getCSList(Node var) {
return tableView.get(var);
}
/**
* Transform the result to SPARK style context insensitive points-to set. The transformed result is stored in the points-to
* set of the querying pointer.
*
* @param vn:
* the querying pointer
* @return
*/
public PointsToSet toSparkCompatiableResult(VarNode vn) {
if (!readyToUse) {
finish();
}
PointsToSetInternal ptset = vn.makeP2Set();
for (VarType cv : outList) {
ptset.add(cv.var);
}
return ptset;
}
/**
* Print the objects.
*/
public void debugPrint() {
if (!readyToUse) {
finish();
}
for (VarType cv : outList) {
System.out.printf("\t%s\n", cv.toString());
}
}
/**
* We use visitor pattern to collect contexts. Derived classes decide how to deal with the variable with the contexts [L,
* R). Returning false means this interval [L, R) is covered by other intervals.
*
* @param var
* @param L
* @param R
* @param sm_int
* : the integer ID of the SootMethod
*/
public abstract boolean visit(Node var, long L, long R, int sm_int);
}
|
// Using table view for comparison, that's faster
for (Map.Entry<Node, List<VarType>> entry : tableView.entrySet()) {
Node var = entry.getKey();
List<VarType> list1 = entry.getValue();
List<VarType> list2 = other.getCSList(var);
if (list1.size() == 0 || list2.size() == 0) {
continue;
}
for (VarType cv1 : list1) {
for (VarType cv2 : list2) {
if (cv1.intersect(cv2)) {
return true;
}
}
}
}
return false;
| 906
| 176
| 1,082
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/spark/geom/dataRep/CallsiteContextVar.java
|
CallsiteContextVar
|
hashCode
|
class CallsiteContextVar extends ContextVar {
/*
* If var is a local pointer or object, context is the callsite for the creation of the pointer or object. If var is a
* instance field, context is the callsite for the creation of its base object.
*/
public CgEdge context = null;
public CallsiteContextVar() {
}
public CallsiteContextVar(CgEdge c, Node v) {
context = c;
var = v;
}
public CallsiteContextVar(CallsiteContextVar o) {
context = o.context;
var = o.var;
}
@Override
public String toString() {
return "<" + context.toString() + ", " + var.toString() + ">";
}
@Override
public boolean equals(Object o) {
CallsiteContextVar other = (CallsiteContextVar) o;
return (other.context == context) && (other.var == var);
}
@Override
public int hashCode() {<FILL_FUNCTION_BODY>}
@Override
public boolean contains(ContextVar cv) {
CallsiteContextVar ccv = (CallsiteContextVar) cv;
if (context == ccv.context) {
return true;
}
return false;
}
@Override
public boolean merge(ContextVar cv) {
// The behavior of merging callsite context sensitive variables is undefined.
return false;
}
@Override
public boolean intersect(ContextVar cv) {
return contains(cv);
}
}
|
int ch = 0;
if (context != null) {
ch = context.hashCode();
}
int ans = var.hashCode() + ch;
if (ans < 0) {
ans = -ans;
}
return ans;
| 411
| 73
| 484
|
<methods>public abstract boolean contains(soot.jimple.spark.geom.dataRep.ContextVar) ,public int getNumber() ,public abstract boolean intersect(soot.jimple.spark.geom.dataRep.ContextVar) ,public abstract boolean merge(soot.jimple.spark.geom.dataRep.ContextVar) ,public void setNumber(int) <variables>public int id,public soot.jimple.spark.pag.Node var
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/spark/geom/dataRep/CgEdge.java
|
CgEdge
|
toString
|
class CgEdge {
// The edge structure in soot
public Edge sootEdge;
// The source/destination
public int s, t;
// The starting context of function t
// Thus, the interval is: (1, |s|, map_offset + |s| - 1)
public long map_offset;
// Is this call edge a SCC edge, i.e two ends both in the same SCC?
public boolean scc_edge = false;
// Is this call edge still in service?
public boolean is_obsoleted = false;
// Base variable of this virtual call edge
public VarNode base_var = null;
// Next call edge
public CgEdge next = null;
// cg_edge inv_next = null;
public CgEdge(int ss, int tt, Edge se, CgEdge ne) {
s = ss;
t = tt;
sootEdge = se;
next = ne;
}
/**
* Copy itself.
*
* @return
*/
public CgEdge duplicate() {
CgEdge new_edge = new CgEdge(s, t, sootEdge, null);
new_edge.map_offset = map_offset;
new_edge.scc_edge = scc_edge;
new_edge.base_var = base_var;
return new_edge;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
if (sootEdge != null) {
return sootEdge.toString();
}
return "(" + s + "->" + t + ", " + map_offset + ")";
| 381
| 51
| 432
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/spark/geom/dataRep/IntervalContextVar.java
|
IntervalContextVar
|
toString
|
class IntervalContextVar extends ContextVar implements Comparable<IntervalContextVar> {
// The interval is [L, R), which stands for a set of consecutive contexts
public long L = 0, R = 0;
public IntervalContextVar() {
}
public IntervalContextVar(long l, long r, Node v) {
assert l < r;
L = l;
R = r;
var = v;
}
public IntervalContextVar(IntervalContextVar o) {
L = o.L;
R = o.R;
var = o.var;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
@Override
public boolean equals(Object o) {
IntervalContextVar other = (IntervalContextVar) o;
return (other.L == L) && (other.R == R) && (other.var == var);
}
@Override
public int hashCode() {
int ch = (int) ((L + R) % Integer.MAX_VALUE);
int ans = var.hashCode() + ch;
if (ans < 0) {
ans = var.hashCode();
}
return ans;
}
@Override
public int compareTo(IntervalContextVar o) {
if (L == o.L) {
return R < o.R ? -1 : 1;
}
return L < o.L ? -1 : 1;
}
@Override
public boolean contains(ContextVar cv) {
IntervalContextVar icv = (IntervalContextVar) cv;
if (L <= icv.L && R >= icv.R) {
return true;
}
return false;
}
@Override
public boolean merge(ContextVar cv) {
IntervalContextVar icv = (IntervalContextVar) cv;
if (icv.L < L) {
if (L <= icv.R) {
L = icv.L;
if (R < icv.R) {
R = icv.R;
}
return true;
}
} else {
if (icv.L <= R) {
if (R < icv.R) {
R = icv.R;
}
return true;
}
}
return false;
}
@Override
public boolean intersect(ContextVar cv) {
IntervalContextVar icv = (IntervalContextVar) cv;
if ((L <= icv.L && icv.L < R) || (icv.L <= L && L < icv.R)) {
return true;
}
return false;
}
}
|
return "<" + var.toString() + ", " + L + ", " + R + ">";
| 699
| 28
| 727
|
<methods>public abstract boolean contains(soot.jimple.spark.geom.dataRep.ContextVar) ,public int getNumber() ,public abstract boolean intersect(soot.jimple.spark.geom.dataRep.ContextVar) ,public abstract boolean merge(soot.jimple.spark.geom.dataRep.ContextVar) ,public void setNumber(int) <variables>public int id,public soot.jimple.spark.pag.Node var
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/spark/geom/dataRep/RectangleNode.java
|
RectangleNode
|
intersect
|
class RectangleNode extends SegmentNode {
// I1 : the starting x coordinate
// I2 : the starting y coordinate
// L : the length of the x-axis side
// L_prime : the length of the y-axis side
public long L_prime;
public RectangleNode() {
}
public RectangleNode(RectangleNode other) {
copyRectangle(other);
}
public void copyRectangle(RectangleNode other) {
I1 = other.I1;
I2 = other.I2;
L = other.L;
L_prime = other.L_prime;
}
public RectangleNode(long I1, long I2, long L, long LL) {
super(I1, I2, L);
L_prime = LL;
}
public boolean equals(RectangleNode other) {
if (I1 == other.I1 && I2 == other.I2 && L == other.L && L_prime == other.L_prime) {
return true;
}
return false;
}
@Override
public long yEnd() {
return I2 + L_prime;
}
@Override
public boolean intersect(SegmentNode q) {<FILL_FUNCTION_BODY>}
private boolean point_within_rectangle(long x, long y, RectangleNode rect) {
if (x >= rect.I1 && x < rect.I1 + rect.L) {
if (y >= rect.I2 && y < rect.I2 + rect.L_prime) {
return true;
}
}
return false;
}
private boolean diagonal_line_intersect_vertical(SegmentNode p, long x, long y, long L) {
if (x >= p.I1 && x < (p.I1 + p.L)) {
long y_cross = x - p.I1 + p.I2;
if (y_cross >= y && y_cross < y + L) {
return true;
}
}
return false;
}
private boolean diagonal_line_intersect_horizontal(SegmentNode p, long x, long y, long L) {
if (y >= p.I2 && y < (p.I2 + p.L)) {
long x_cross = y - p.I2 + p.I1;
if (x_cross >= x && x_cross < x + L) {
return true;
}
}
return false;
}
}
|
RectangleNode p = this;
if (q instanceof SegmentNode) {
// If one of the end point is in the body of the rectangle
if (point_within_rectangle(q.I1, q.I2, p) || point_within_rectangle(q.I1 + q.L - 1, q.I2 + q.L - 1, p)) {
return true;
}
// Otherwise, the diagonal line must intersect with one of the boundary lines
if (diagonal_line_intersect_horizontal(q, p.I1, p.I2, p.L)
|| diagonal_line_intersect_horizontal(q, p.I1, p.I2 + p.L_prime - 1, p.L)
|| diagonal_line_intersect_vertical(q, p.I1, p.I2, p.L_prime)
|| diagonal_line_intersect_vertical(q, p.I1 + p.L - 1, p.I2, p.L_prime)) {
return true;
}
} else {
RectangleNode rect_q = (RectangleNode) q;
// If the segment is not entirely above, below, to the left, to the right of this rectangle
// then, they must intersect
if ((p.I2 >= rect_q.I2 + rect_q.L_prime) || (p.I2 + p.L_prime <= rect_q.I2) || (p.I1 + p.L <= rect_q.I1)
|| (p.I1 >= rect_q.I1 + rect_q.L)) {
return false;
}
return true;
}
return false;
| 648
| 430
| 1,078
|
<methods>public void <init>() ,public void <init>(soot.jimple.spark.geom.dataRep.SegmentNode) ,public void <init>(long, long, long) ,public int compareTo(soot.jimple.spark.geom.dataRep.SegmentNode) ,public void copySegment(soot.jimple.spark.geom.dataRep.SegmentNode) ,public boolean equals(soot.jimple.spark.geom.dataRep.SegmentNode) ,public boolean intersect(soot.jimple.spark.geom.dataRep.SegmentNode) ,public boolean projYIntersect(soot.jimple.spark.geom.dataRep.SegmentNode) ,public long xEnd() ,public long yEnd() <variables>public long I1,public long I2,public long L,public boolean is_new,public soot.jimple.spark.geom.dataRep.SegmentNode next
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/spark/geom/dataRep/SegmentNode.java
|
SegmentNode
|
equals
|
class SegmentNode implements Comparable<SegmentNode> {
// I1 : start interval of the pointer
// I2 : start interval of the pointed to object
// L : length of the interval
// is_new : a flag to indicate that this interval has not been processed
public long I1;
public long I2;
public long L;
public SegmentNode next = null;
public boolean is_new = true;
public SegmentNode() {
}
public SegmentNode(SegmentNode other) {
copySegment(other);
}
public void copySegment(SegmentNode other) {
I1 = other.I1;
I2 = other.I2;
L = other.L;
}
public SegmentNode(long i1, long i2, long l) {
I1 = i1;
I2 = i2;
L = l;
}
public boolean equals(SegmentNode other) {<FILL_FUNCTION_BODY>}
@Override
public int compareTo(SegmentNode o) {
long d;
d = I1 - o.I1;
if (d != 0) {
return d < 0 ? -1 : 1;
}
d = I2 - o.I2;
if (d != 0) {
return d < 0 ? -1 : 1;
}
d = L - o.L;
if (d != 0) {
return d < 0 ? -1 : 1;
}
if (this instanceof RectangleNode && o instanceof RectangleNode) {
d = ((RectangleNode) this).L_prime - ((RectangleNode) o).L_prime;
if (d != 0) {
return d < 0 ? -1 : 1;
}
}
return 0;
}
public long xEnd() {
return I1 + L;
}
public long yEnd() {
return I2 + L;
}
/**
* Testing if two figures are intersected. This interface implements standard intersection testing that ignores the
* semantics of the X- and Y- axis. Processing the semantics issues before calling this method. A sample usage, please @see
* heap_sensitive_intersection
*
* @param q
* @return
*/
public boolean intersect(SegmentNode q) {
// Intersection with a rectangle is tested in the overrode method
if (q instanceof RectangleNode) {
return q.intersect(this);
}
SegmentNode p = this;
if ((p.I2 - p.I1) == (q.I2 - q.I1)) {
// Two segments have the same offset, so they are on the same line
if (p.I1 <= q.I1) {
return q.I1 < p.I1 + p.L;
} else {
return p.I1 < q.I1 + q.L;
}
}
return false;
}
public boolean projYIntersect(SegmentNode q) {
long py1 = this.I2;
long py2 = yEnd();
long qy1 = q.I2;
long qy2 = q.yEnd();
if (py1 <= qy1) {
return qy1 < py2;
}
return py1 < qy2;
}
}
|
if (other instanceof RectangleNode) {
return false;
}
if (I1 == other.I1 && I2 == other.I2 && L == other.L) {
return true;
}
return false;
| 879
| 65
| 944
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/spark/geom/geomE/FullSensitiveNodeGenerator.java
|
FullSensitiveNodeGenerator
|
initFlowGraph
|
class FullSensitiveNodeGenerator extends IEncodingBroker {
private static final int full_convertor[] = { GeometricManager.ONE_TO_ONE, GeometricManager.MANY_TO_MANY,
GeometricManager.MANY_TO_MANY, GeometricManager.MANY_TO_MANY };
@Override
public void initFlowGraph(GeomPointsTo ptAnalyzer) {<FILL_FUNCTION_BODY>}
@Override
public String getSignature() {
return Constants.geomE;
}
@Override
public IVarAbstraction generateNode(Node vNode) {
IVarAbstraction ret;
if (vNode instanceof AllocNode || vNode instanceof FieldRefNode) {
ret = new DummyNode(vNode);
} else {
ret = new FullSensitiveNode(vNode);
}
return ret;
}
}
|
int k;
int n_legal_cons;
int nf1, nf2;
int code;
IVarAbstraction my_lhs, my_rhs;
// Visit all the simple constraints
n_legal_cons = 0;
for (PlainConstraint cons : ptAnalyzer.constraints) {
if (!cons.isActive) {
continue;
}
my_lhs = cons.getLHS().getRepresentative();
my_rhs = cons.getRHS().getRepresentative();
nf1 = ptAnalyzer.getMethodIDFromPtr(my_lhs);
nf2 = ptAnalyzer.getMethodIDFromPtr(my_rhs);
// Test how many globals are in this constraint
code = ((nf1 == Constants.SUPER_MAIN ? 1 : 0) << 1) | (nf2 == Constants.SUPER_MAIN ? 1 : 0);
switch (cons.type) {
case Constants.NEW_CONS:
// We directly add the objects to the points-to set
if (code == 0) {
// the allocation result is assigned to a local variable
my_rhs.add_points_to_3((AllocNode) my_lhs.getWrappedNode(), 1, 1, ptAnalyzer.context_size[nf1]);
} else {
// Assigned to a global or the object itself is a global
my_rhs.add_points_to_4((AllocNode) my_lhs.getWrappedNode(), 1, 1, ptAnalyzer.context_size[nf2],
ptAnalyzer.context_size[nf1]);
}
// Enqueue to the worklist
ptAnalyzer.getWorklist().push(my_rhs);
break;
case Constants.ASSIGN_CONS:
// Assigning between two pointers
if (cons.interCallEdges != null) {
// Inter-procedural assignment (parameter passing, function return)
for (Iterator<Edge> it = cons.interCallEdges.iterator(); it.hasNext();) {
Edge sEdge = it.next();
CgEdge q = ptAnalyzer.getInternalEdgeFromSootEdge(sEdge);
if (q.is_obsoleted) {
continue;
}
// Parameter passing or not
if (nf2 == q.t) {
/*
* The receiver must be a local, while the sender is perhaps not (e.g. for handling reflection, see class
* PAG)
*/
// Handle the special case first
// In that case, nf1 is SUPER_MAIN.
if (nf1 == Constants.SUPER_MAIN) {
my_lhs.add_simple_constraint_4(my_rhs, 1, q.map_offset, 1, ptAnalyzer.max_context_size_block[q.s]);
} else {
// nf1 == q.s
// We should treat the self recursive calls specially
if (q.s == q.t) {
my_lhs.add_simple_constraint_3(my_rhs, 1, 1, ptAnalyzer.context_size[nf1]);
} else {
for (k = 0; k < ptAnalyzer.block_num[nf1]; ++k) {
my_lhs.add_simple_constraint_3(my_rhs, k * ptAnalyzer.max_context_size_block[nf1] + 1, q.map_offset,
ptAnalyzer.max_context_size_block[nf1]);
}
}
}
} else {
// nf2 == q.s
// Return value
// Both are locals
if (q.s == q.t) {
// Self-recursive calls may fall here, we handle them properly
my_lhs.add_simple_constraint_3(my_rhs, 1, 1, ptAnalyzer.context_size[nf2]);
} else {
for (k = 0; k < ptAnalyzer.block_num[nf2]; ++k) {
my_lhs.add_simple_constraint_3(my_rhs, q.map_offset, k * ptAnalyzer.max_context_size_block[nf2] + 1,
ptAnalyzer.max_context_size_block[nf2]);
}
}
}
}
} else {
// Intra-procedural assignment
// And, the assignments involving the global variables go here. By our definition, the global variables belong to
// SUPER_MAIN.
// And according to the Jimple IR, not both sides are global variables
if (code == 0) {
// local to local assignment
my_lhs.add_simple_constraint_3(my_rhs, 1, 1, ptAnalyzer.context_size[nf1]);
} else {
my_lhs.add_simple_constraint_4(my_rhs, 1, 1, ptAnalyzer.context_size[nf1], ptAnalyzer.context_size[nf2]);
}
}
break;
case Constants.LOAD_CONS:
// lhs is always a local
// rhs = lhs.f
cons.code = full_convertor[code];
cons.otherSide = my_rhs;
my_lhs.put_complex_constraint(cons);
break;
case Constants.STORE_CONS:
// rhs is always a local
// rhs.f = lhs
cons.code = full_convertor[code];
cons.otherSide = my_lhs;
my_rhs.put_complex_constraint(cons);
break;
default:
throw new RuntimeException("Invalid type");
}
++n_legal_cons;
}
ptAnalyzer.ps.printf("Only %d (%.1f%%) constraints are needed for this run.\n", n_legal_cons,
((double) n_legal_cons / ptAnalyzer.n_init_constraints) * 100);
| 228
| 1,592
| 1,820
|
<methods>public non-sealed void <init>() ,public abstract soot.jimple.spark.geom.geomPA.IVarAbstraction generateNode(soot.jimple.spark.pag.Node) ,public abstract java.lang.String getSignature() ,public abstract void initFlowGraph(soot.jimple.spark.geom.geomPA.GeomPointsTo) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/spark/geom/geomPA/IFigureManager.java
|
IFigureManager
|
getRectangleNode
|
class IFigureManager {
// We implement an internal memory manager here
private static SegmentNode segHeader = null;
private static SegmentNode rectHeader = null;
/**
* Generate a segment node from our own cache.
*
* @return
*/
protected static SegmentNode getSegmentNode() {
SegmentNode ret = null;
if (segHeader != null) {
ret = segHeader;
segHeader = ret.next;
ret.next = null;
ret.is_new = true;
} else {
ret = new SegmentNode();
}
return ret;
}
/**
* Generate a rectangle node from our own cache.
*
* @return
*/
protected static RectangleNode getRectangleNode() {<FILL_FUNCTION_BODY>}
/**
* Return the segment node to cache.
*
* @param p
* @return
*/
protected static SegmentNode reclaimSegmentNode(SegmentNode p) {
SegmentNode q = p.next;
p.next = segHeader;
segHeader = p;
return q;
}
/**
* Return the rectangle node to cache.
*
* @param p
* @return
*/
protected static SegmentNode reclaimRectangleNode(SegmentNode p) {
SegmentNode q = p.next;
p.next = rectHeader;
rectHeader = p;
return q;
}
/**
* We return the cached memory to garbage collector.
*/
public static void cleanCache() {
segHeader = null;
rectHeader = null;
}
// Get the information of the figures
public abstract SegmentNode[] getFigures();
public abstract int[] getSizes();
public abstract boolean isThereUnprocessedFigures();
public abstract void flush();
// Deal with the figures
public abstract SegmentNode addNewFigure(int code, RectangleNode pnew);
public abstract void mergeFigures(int size);
public abstract void removeUselessSegments();
}
|
RectangleNode ret = null;
if (rectHeader != null) {
ret = (RectangleNode) rectHeader;
rectHeader = ret.next;
ret.next = null;
ret.is_new = true;
} else {
ret = new RectangleNode();
}
return ret;
| 544
| 88
| 632
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/spark/geom/geomPA/IVarAbstraction.java
|
IVarAbstraction
|
toString
|
class IVarAbstraction implements Numberable {
// A shape manager that has only one all map to all member, representing the context insensitive points-to info
protected static IFigureManager stubManager = null;
// This is used to indicate the corresponding object should be removed
protected static IFigureManager deadManager = null;
// A temporary rectangle holds the candidate figure
protected static RectangleNode pres = null;
// Corresponding SPARK node
public Node me;
// The integer mapping for this node
public int id = -1;
// Position in the queue
public int Qpos = 0;
// Will we update the points-to information for this node in the geometric analysis?
// Because of constraints distillation, not all the pointers will be updated.
public boolean willUpdate = false;
// top_value: the topological value for this node on the symbolic assignment graph
// lrf_value: the number of processing times for this pointer
// top_value will be modified in the offlineProcessor and every pointer has a different value
public int top_value = 1, lrf_value = 0;
// union-find tree link
protected IVarAbstraction parent;
public IVarAbstraction() {
parent = this;
}
/**
* Used by ordering the nodes in priority worklist.
*/
public boolean lessThan(IVarAbstraction other) {
if (lrf_value != other.lrf_value) {
return lrf_value < other.lrf_value;
}
return top_value < other.top_value;
}
public IVarAbstraction getRepresentative() {
return parent == this ? this : (parent = parent.getRepresentative());
}
/**
* Make the variable other be the parent of this variable.
*
* @param other
* @return
*/
public IVarAbstraction merge(IVarAbstraction other) {
getRepresentative();
parent = other.getRepresentative();
return parent;
}
@Override
public void setNumber(int number) {
id = number;
}
@Override
public int getNumber() {
return id;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
/**
* This pointer/object is reachable if its enclosing method is reachable. Pleas always call this method to check the status
* before querying points-to information.
*/
public boolean reachable() {
return id != -1;
}
/**
* Test if this pointer currently has points-to result. The result can be computed in the last iteration of geomPTA,
* although its willUpdate = false this round.
*/
public boolean hasPTResult() {
return num_of_diff_objs() != -1;
}
/**
* Processing the wrapped SPARK node.
*/
public Node getWrappedNode() {
return me;
}
public Type getType() {
return me.getType();
}
public boolean isLocalPointer() {
return me instanceof LocalVarNode;
}
public SootMethod enclosingMethod() {
if (me instanceof LocalVarNode) {
return ((LocalVarNode) me).getMethod();
}
return null;
}
// Initiation
public abstract boolean add_points_to_3(AllocNode obj, long I1, long I2, long L);
public abstract boolean add_points_to_4(AllocNode obj, long I1, long I2, long L1, long L2);
public abstract boolean add_simple_constraint_3(IVarAbstraction qv, long I1, long I2, long L);
public abstract boolean add_simple_constraint_4(IVarAbstraction qv, long I1, long I2, long L1, long L2);
public abstract void put_complex_constraint(PlainConstraint cons);
public abstract void reconstruct();
// Points-to facts propagation
public abstract void do_before_propagation();
public abstract void do_after_propagation();
public abstract void propagate(GeomPointsTo ptAnalyzer, IWorklist worklist);
// Manipulate points-to results
public abstract void drop_duplicates();
public abstract void remove_points_to(AllocNode obj);
public abstract void deleteAll();
public abstract void keepPointsToOnly();
public abstract void injectPts();
// Obtaining points-to information statistics
/**
* Return -1 if this pointer does not have points-to information. This function can be used for testing if the pointer has
* been processed by geomPTA.
*/
public abstract int num_of_diff_objs();
public abstract int num_of_diff_edges();
public abstract int count_pts_intervals(AllocNode obj);
public abstract int count_new_pts_intervals();
public abstract int count_flow_intervals(IVarAbstraction qv);
// Querying procedures
/**
* Perform context sensitive alias checking with qv.
*
* @param qv
* @return
*/
public abstract boolean heap_sensitive_intersection(IVarAbstraction qv);
/**
* Test if the pointer in the context range [l, R) points to object obj.
*
* @param l
* @param r
* @param obj
* @return
*/
public abstract boolean pointer_interval_points_to(long l, long r, AllocNode obj);
/**
* Test if the particular object has been obsoleted. It's mainly for points-to developer use.
*
* @param obj
* @return
*/
public abstract boolean isDeadObject(AllocNode obj);
/**
* Obtain context insensitive points-to result (by removing contexts).
*
* @return
*/
public abstract Set<AllocNode> get_all_points_to_objects();
/**
* Given the pointers falling in the context range [l, r), we compute the set of context sensitive objects pointed to by
* those pointers. This function is designed in visitor pattern.
*
* @see Obj_1cfa_extractor
* @see Obj_full_extractor
*/
public abstract void get_all_context_sensitive_objects(long l, long r, PtSensVisitor visitor);
// Debugging facilities
public abstract void print_context_sensitive_points_to(PrintStream outPrintStream);
}
|
if (me != null) {
return me.toString();
}
return super.toString();
| 1,678
| 30
| 1,708
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/spark/geom/geomPA/PQ_Worklist.java
|
PQ_Worklist
|
next
|
class PQ_Worklist implements IWorklist {
private IVarAbstraction[] heap = null;
int cur_tail = 0;
@Override
public void initialize(int size) {
heap = new IVarAbstraction[size];
cur_tail = 1;
}
@Override
public boolean has_job() {
return cur_tail > 1;
}
@Override
public IVarAbstraction next() {<FILL_FUNCTION_BODY>}
@Override
public void push(IVarAbstraction e) {
e.lrf_value++;
if (e.Qpos == 0) {
// This element has not been inserted
int k = cur_tail;
while (k > 1) {
int kk = k / 2;
if (heap[kk].lessThan(e)) {
break;
}
heap[k] = heap[kk];
heap[k].Qpos = k;
k /= 2;
}
e.Qpos = k;
heap[k] = e;
++cur_tail;
} else {
// We decrease this element whenever possible
int k = e.Qpos;
while ((k * 2) < cur_tail) {
int kk = k * 2;
if ((kk + 1) < cur_tail && heap[kk + 1].lessThan(heap[kk])) {
kk++;
}
if (e.lessThan(heap[kk])) {
break;
}
heap[k] = heap[kk];
heap[kk].Qpos = k;
k = kk;
}
e.Qpos = k;
heap[k] = e;
}
}
@Override
public int size() {
return cur_tail - 1;
}
@Override
public void clear() {
cur_tail = 1;
}
}
|
IVarAbstraction ret = heap[1];
--cur_tail;
if (cur_tail > 1) {
IVarAbstraction e = heap[cur_tail];
int k = 1;
while ((k * 2) < cur_tail) {
int kk = k * 2;
if ((kk + 1) < cur_tail && heap[kk + 1].lessThan(heap[kk])) {
kk++;
}
if (e.lessThan(heap[kk])) {
break;
}
heap[k] = heap[kk];
heap[k].Qpos = k;
k = kk;
}
e.Qpos = k;
heap[k] = e;
}
ret.Qpos = 0;
return ret;
| 507
| 214
| 721
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/spark/geom/utils/Histogram.java
|
Histogram
|
printResult
|
class Histogram {
private int[] limits;
private int count = 0;
private int[] results = null;
public Histogram(int[] limits) {
int i;
this.limits = limits;
results = new int[limits.length + 1];
for (i = 0; i <= limits.length; ++i) {
results[i] = 0;
}
}
public void printResult(PrintStream output) {<FILL_FUNCTION_BODY>}
public void printResult(PrintStream output, String title) {
output.println(title);
printResult(output);
}
/**
* This function prints two histograms together for comparative reading. It requires the two histograms having the same
* data separators.
*
* @param output
* @param title
* @param other
*/
public void printResult(PrintStream output, String title, Histogram other) {
output.println(title);
if (count == 0) {
output.println("No samples are inserted, no output!");
return;
}
output.println("Samples : " + count + " (" + other.count + ")");
for (int i = 0; i < results.length; i++) {
if (i == 0) {
output.printf("<= %d: %d (%d)", limits[0], results[i], other.results[i]);
} else if (i == results.length - 1) {
output.printf("> %d: %d (%d)", limits[limits.length - 1], results[i], other.results[i]);
} else {
output.printf("%d < x <= %d: %d (%d)", limits[i - 1], limits[i], results[i], other.results[i]);
}
output.printf(", percentage = %.2f%% (%.2f%%) \n", (double) results[i] * 100 / count,
(double) other.results[i] * 100 / other.count);
}
output.println();
}
public void addNumber(int num) {
count++;
int i = 0;
for (i = 0; i < limits.length; i++) {
if (num <= limits[i]) {
results[i]++;
break;
}
}
if (i == limits.length) {
results[i]++;
}
}
/**
* Merge two histograms.
*
* @param other
*/
public void merge(Histogram other) {
int i;
for (i = 0; i <= limits.length; ++i) {
results[i] += other.results[i];
}
count += other.count;
}
public int getTotalNumofSamples() {
return count;
}
/**
* Use the current distribution but scale the samples close to the user specified one
*
* @param usrSamples
*/
public void scaleToSamples(int usrSamples) {
double ratio;
ratio = (double) usrSamples / count;
count = 0;
for (int i = 0; i <= limits.length; ++i) {
results[i] = (int) Math.round(results[i] * ratio);
count += results[i];
}
}
public int getResult(int inx) {
if (inx >= limits.length) {
return 0;
}
return results[inx];
}
}
|
if (count == 0) {
output.println("No samples are inserted, no output!");
return;
}
output.println("Samples : " + count);
for (int i = 0; i < results.length; i++) {
if (i == 0) {
output.print("<=" + limits[0] + ": " + results[i]);
} else if (i == results.length - 1) {
output.print(">" + limits[limits.length - 1] + ": " + results[i]);
} else {
output.print(limits[i - 1] + "< x <=" + limits[i] + ": " + results[i]);
}
output.printf(", percentage = %.2f\n", (double) results[i] * 100 / count);
}
| 925
| 219
| 1,144
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/spark/geom/utils/SootInfo.java
|
SootInfo
|
countCallEdgesForCallsite
|
class SootInfo {
public static int countCallEdgesForCallsite(Stmt callsite, boolean stopForMutiple) {<FILL_FUNCTION_BODY>}
}
|
CallGraph cg = Scene.v().getCallGraph();
int count = 0;
for (Iterator<Edge> it = cg.edgesOutOf(callsite); it.hasNext();) {
it.next();
++count;
if (stopForMutiple && count > 1) {
break;
}
}
return count;
| 47
| 96
| 143
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/spark/internal/SparkLibraryHelper.java
|
SparkLibraryHelper
|
caseRefType
|
class SparkLibraryHelper extends TypeSwitch {
private PAG pag;
private Node node;
private SootMethod method;
/**
* The constructor for this {@link TypeSwitch}.
*
* @param pag
* the pointer assignment graph in that the new edges and nodes should be added into.
* @param node
* the node of the value for which allocations should be made.
* @param method
* the method in which the allocations should take place. This parameter can be null.
*/
public SparkLibraryHelper(PAG pag, Node node, SootMethod method) {
this.pag = pag;
this.node = node;
this.method = method;
}
/**
* A new local will be created and connected to {@link SparkLibraryHelper#node} of type {@link RefType}. For this new local
* an allocation edge to {@link AnySubType} of its declared type will be added.
*/
@Override
public void caseRefType(RefType t) {<FILL_FUNCTION_BODY>}
/**
* A new local array will be created and connected to {@link SparkLibraryHelper#node} of type {@link ArrayType}. For this
* new local an allocation edge to a new array of its declared type will be added. If the
* {@link ArrayType#getElementType()} is still an array an allocation to a new array of this element type will be made and
* stored until the element type is a {@link RefType}. If this is the case an allocation to {@link AnySubType} of
* {@link ArrayType#baseType} will be made.
*/
@Override
public void caseArrayType(ArrayType type) {
Node array = node;
for (Type t = type; t instanceof ArrayType; t = ((ArrayType) t).getElementType()) {
ArrayType at = (ArrayType) t;
if (at.baseType instanceof RefType) {
// var tmpArray;
LocalVarNode localArray = pag.makeLocalVarNode(new Object(), t, method);
// x = tmpArray;
pag.addEdge(localArray, array);
// new T[]
AllocNode newArray = pag.makeAllocNode(new Object(), at, method);
// tmpArray = new T[]
pag.addEdge(newArray, localArray);
// tmpArray[i]
FieldRefNode arrayRef = pag.makeFieldRefNode(localArray, ArrayElement.v());
// var tmp
LocalVarNode local = pag.makeLocalVarNode(new Object(), at.getElementType(), method);
// tmpArray[i] = tmp
pag.addEdge(local, arrayRef);
// x = tmp
array = local;
if (at.numDimensions == 1) {
// new T()
AllocNode alloc = pag.makeAllocNode(new Object(), AnySubType.v((RefType) at.baseType), method);
// tmp = new T()
pag.addEdge(alloc, local);
}
}
}
}
}
|
// var tmp;
VarNode local = pag.makeLocalVarNode(new Object(), t, method);
// new T();
AllocNode alloc = pag.makeAllocNode(new Object(), AnySubType.v(t), method);
// tmp = new T();
pag.addAllocEdge(alloc, local);
// x = tmp;
pag.addEdge(local, node);
| 764
| 102
| 866
|
<methods>public non-sealed void <init>() ,public void caseAnySubType(soot.AnySubType) ,public void caseArrayType(soot.ArrayType) ,public void caseBooleanType(soot.BooleanType) ,public void caseByteType(soot.ByteType) ,public void caseCharType(soot.CharType) ,public void caseDefault(soot.Type) ,public void caseDoubleType(soot.DoubleType) ,public void caseErroneousType(soot.ErroneousType) ,public void caseFloatType(soot.FloatType) ,public void caseIntType(soot.IntType) ,public void caseLongType(soot.LongType) ,public void caseNullType(soot.NullType) ,public void caseRefType(soot.RefType) ,public void caseShortType(soot.ShortType) ,public void caseStmtAddressType(soot.StmtAddressType) ,public void caseUnknownType(soot.UnknownType) ,public void caseVoidType(soot.VoidType) ,public void defaultCase(soot.Type) ,public java.lang.Object getResult() ,public void setResult(java.lang.Object) <variables>java.lang.Object result
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/spark/ondemand/AllocAndContext.java
|
AllocAndContext
|
equals
|
class AllocAndContext {
public final AllocNode alloc;
public final ImmutableStack<Integer> context;
public AllocAndContext(AllocNode alloc, ImmutableStack<Integer> context) {
this.alloc = alloc;
this.context = context;
}
public String toString() {
return alloc + ", context " + context;
}
public int hashCode() {
final int PRIME = 31;
int result = 1;
result = PRIME * result + alloc.hashCode();
result = PRIME * result + context.hashCode();
return result;
}
public boolean equals(Object obj) {<FILL_FUNCTION_BODY>}
}
|
if (this == obj) {
return true;
}
if ((obj == null) || (getClass() != obj.getClass())) {
return false;
}
final AllocAndContext other = (AllocAndContext) obj;
if (!alloc.equals(other.alloc) || !context.equals(other.context)) {
return false;
}
return true;
| 181
| 101
| 282
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/spark/ondemand/AllocAndContextSet.java
|
AllocAndContextSet
|
nonEmptyHelper
|
class AllocAndContextSet extends ArraySet<AllocAndContext> implements EqualsSupportingPointsToSet {
public boolean hasNonEmptyIntersection(PointsToSet other) {
if (other instanceof AllocAndContextSet) {
return nonEmptyHelper((AllocAndContextSet) other);
} else if (other instanceof WrappedPointsToSet) {
return hasNonEmptyIntersection(((WrappedPointsToSet) other).getWrapped());
} else if (other instanceof PointsToSetInternal) {
return ((PointsToSetInternal) other).forall(new P2SetVisitor() {
@Override
public void visit(Node n) {
if (!returnValue) {
for (AllocAndContext allocAndContext : AllocAndContextSet.this) {
if (n.equals(allocAndContext.alloc)) {
returnValue = true;
break;
}
}
}
}
});
}
throw new UnsupportedOperationException("can't check intersection with set of type " + other.getClass());
}
private boolean nonEmptyHelper(AllocAndContextSet other) {<FILL_FUNCTION_BODY>}
public Set<ClassConstant> possibleClassConstants() {
Set<ClassConstant> res = new HashSet<ClassConstant>();
for (AllocAndContext allocAndContext : this) {
AllocNode n = allocAndContext.alloc;
if (n instanceof ClassConstantNode) {
res.add(((ClassConstantNode) n).getClassConstant());
} else {
return null;
}
}
return res;
}
public Set<String> possibleStringConstants() {
Set<String> res = new HashSet<String>();
for (AllocAndContext allocAndContext : this) {
AllocNode n = allocAndContext.alloc;
if (n instanceof StringConstantNode) {
res.add(((StringConstantNode) n).getString());
} else {
return null;
}
}
return res;
}
public Set<Type> possibleTypes() {
Set res = new HashSet<Type>();
for (AllocAndContext allocAndContext : this) {
res.add(allocAndContext.alloc.getType());
}
return res;
}
/**
* Computes a hash code based on the contents of the points-to set. Note that hashCode() is not overwritten on purpose.
* This is because Spark relies on comparison by object identity.
*/
public int pointsToSetHashCode() {
final int PRIME = 31;
int result = 1;
for (AllocAndContext elem : this) {
result = PRIME * result + elem.hashCode();
}
return result;
}
/**
* Returns <code>true</code> if and only if other holds the same alloc nodes as this. Note that equals() is not overwritten
* on purpose. This is because Spark relies on comparison by object identity.
*/
public boolean pointsToSetEquals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof AllocAndContextSet)) {
return false;
}
AllocAndContextSet otherPts = (AllocAndContextSet) other;
// both sets are equal if they are supersets of each other
return superSetOf(otherPts, this) && superSetOf(this, otherPts);
}
/**
* Returns <code>true</code> if <code>onePts</code> is a (non-strict) superset of <code>otherPts</code>.
*/
private boolean superSetOf(AllocAndContextSet onePts, final AllocAndContextSet otherPts) {
return onePts.containsAll(otherPts);
}
}
|
for (AllocAndContext otherAllocAndContext : other) {
for (AllocAndContext myAllocAndContext : this) {
if (otherAllocAndContext.alloc.equals(myAllocAndContext.alloc)) {
ImmutableStack<Integer> myContext = myAllocAndContext.context;
ImmutableStack<Integer> otherContext = otherAllocAndContext.context;
if (myContext.topMatches(otherContext) || otherContext.topMatches(myContext)) {
return true;
}
}
}
}
return false;
| 951
| 138
| 1,089
|
<methods>public void <init>(int, boolean) ,public void <init>() ,public void <init>(ArraySet<soot.jimple.spark.ondemand.AllocAndContext>) ,public void <init>(Collection<soot.jimple.spark.ondemand.AllocAndContext>) ,public boolean add(soot.jimple.spark.ondemand.AllocAndContext) ,public boolean addAll(ArraySet<soot.jimple.spark.ondemand.AllocAndContext>) ,public boolean addAll(Collection<? extends soot.jimple.spark.ondemand.AllocAndContext>) ,public void clear() ,public boolean contains(java.lang.Object) ,public static final ArraySet<T> empty() ,public void forall(ObjectVisitor<soot.jimple.spark.ondemand.AllocAndContext>) ,public soot.jimple.spark.ondemand.AllocAndContext get(int) ,public boolean intersects(ArraySet<soot.jimple.spark.ondemand.AllocAndContext>) ,public boolean isEmpty() ,public Iterator<soot.jimple.spark.ondemand.AllocAndContext> iterator() ,public boolean remove(java.lang.Object) ,public boolean remove(int) ,public int size() ,public java.lang.Object[] toArray() ,public U[] toArray(U[]) ,public java.lang.String toString() <variables>private static final ArraySet#RAW EMPTY,private int _curIndex,private soot.jimple.spark.ondemand.AllocAndContext[] _elems,private final non-sealed boolean checkDupes
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/spark/ondemand/DotPointerGraph.java
|
DotPointerGraph
|
dump
|
class DotPointerGraph {
private static final Logger logger = LoggerFactory.getLogger(DotPointerGraph.class);
private final Set<String> edges = new HashSet<String>();
private final Set<Node> nodes = new HashSet<Node>();
public void addAssign(VarNode from, VarNode to) {
addEdge(to, from, "", "black");
}
private void addEdge(Node from, Node to, String edgeLabel, String color) {
nodes.add(from);
nodes.add(to);
addEdge(PagToDotDumper.makeNodeName(from), PagToDotDumper.makeNodeName(to), edgeLabel, color);
}
private void addEdge(String from, String to, String edgeLabel, String color) {
StringBuffer tmp = new StringBuffer();
tmp.append(" ");
tmp.append(from);
tmp.append(" -> ");
tmp.append(to);
tmp.append(" [label=\"");
tmp.append(edgeLabel);
tmp.append("\", color=");
tmp.append(color);
tmp.append("];");
edges.add(tmp.toString());
}
public void addNew(AllocNode from, VarNode to) {
addEdge(to, from, "", "yellow");
}
public void addCall(VarNode from, VarNode to, Integer callSite) {
addEdge(to, from, callSite.toString(), "blue");
}
public void addMatch(VarNode from, VarNode to) {
addEdge(to, from, "", "brown");
}
public void addLoad(FieldRefNode from, VarNode to) {
addEdge(to, from.getBase(), from.getField().toString(), "green");
}
public void addStore(VarNode from, FieldRefNode to) {
addEdge(to.getBase(), from, to.getField().toString(), "red");
}
public int numEdges() {
return edges.size();
}
public void dump(String filename) {<FILL_FUNCTION_BODY>}
}
|
PrintWriter pw = null;
try {
pw = new PrintWriter(new FileOutputStream(filename));
} catch (FileNotFoundException e) {
logger.error(e.getMessage(), e);
}
// pw.println("digraph G {\n\trankdir=LR;");
pw.println("digraph G {");
Predicate<Node> falsePred = new Predicate<Node>() {
@Override
public boolean test(Node obj_) {
return false;
}
};
for (Node node : nodes) {
pw.println(PagToDotDumper.makeDotNodeLabel(node, falsePred));
}
for (String edge : edges) {
pw.println(edge);
}
pw.println("}");
pw.close();
| 542
| 213
| 755
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/spark/ondemand/InnerTypesIncrementalHeuristic.java
|
InnerTypesIncrementalHeuristic
|
validateMatchesForField
|
class InnerTypesIncrementalHeuristic implements FieldCheckHeuristic {
private final TypeManager manager;
private final Set<RefType> typesToCheck = new HashSet<RefType>();
private String newTypeOnQuery = null;
private final Set<RefType> bothEndsTypes = new HashSet<RefType>();
private final Set<RefType> notBothEndsTypes = new HashSet<RefType>();
private int numPasses = 0;
private final int passesInDirection;
private boolean allNotBothEnds = false;
public InnerTypesIncrementalHeuristic(TypeManager manager, int maxPasses) {
this.manager = manager;
this.passesInDirection = maxPasses / 2;
}
public boolean runNewPass() {
numPasses++;
if (numPasses == passesInDirection) {
return switchToNotBothEnds();
} else {
if (newTypeOnQuery != null) {
String topLevelTypeStr = Util.topLevelTypeString(newTypeOnQuery);
boolean added;
if (Scene.v().containsType(topLevelTypeStr)) {
RefType refType = Scene.v().getRefType(topLevelTypeStr);
added = typesToCheck.add(refType);
} else {
added = false;
}
newTypeOnQuery = null;
return added;
} else {
return switchToNotBothEnds();
}
}
}
private boolean switchToNotBothEnds() {
if (!allNotBothEnds) {
numPasses = 0;
allNotBothEnds = true;
newTypeOnQuery = null;
typesToCheck.clear();
return true;
} else {
return false;
}
}
public boolean validateMatchesForField(SparkField field) {<FILL_FUNCTION_BODY>}
public boolean validFromBothEnds(SparkField field) {
if (allNotBothEnds) {
return false;
}
if (field instanceof ArrayElement) {
return true;
}
SootField sootField = (SootField) field;
RefType declaringType = sootField.getDeclaringClass().getType();
if (bothEndsTypes.contains(declaringType)) {
return true;
} else if (notBothEndsTypes.contains(declaringType)) {
return false;
} else {
if (SootUtil.hasRecursiveField(declaringType.getSootClass())) {
notBothEndsTypes.add(declaringType);
return false;
} else {
bothEndsTypes.add(declaringType);
return true;
}
}
}
@Override
public String toString() {
return typesToCheck.toString();
}
}
|
if (field instanceof ArrayElement) {
return true;
}
SootField sootField = (SootField) field;
RefType declaringType = sootField.getDeclaringClass().getType();
String declaringTypeStr = declaringType.toString();
String topLevel = Util.topLevelTypeString(declaringTypeStr);
RefType refType;
if (Scene.v().containsType(topLevel)) {
refType = Scene.v().getRefType(topLevel);
} else {
refType = null;
}
for (RefType checkedType : typesToCheck) {
if (manager.castNeverFails(checkedType, refType)) {
// System.err.println("validate " + declaringTypeStr);
return true;
}
}
if (newTypeOnQuery == null) {
newTypeOnQuery = declaringTypeStr;
}
return false;
| 733
| 236
| 969
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/spark/ondemand/genericutil/AbstractMultiMap.java
|
AbstractMultiMap
|
remove
|
class AbstractMultiMap<K, V> implements MultiMap<K, V> {
protected final Map<K, Set<V>> map = new HashMap<K, Set<V>>();
protected final boolean create;
protected AbstractMultiMap(boolean create) {
this.create = create;
}
protected abstract Set<V> createSet();
protected Set<V> emptySet() {
return Collections.<V>emptySet();
}
/*
* (non-Javadoc)
*
* @see AAA.util.MultiMap#get(K)
*/
@Override
public Set<V> get(K key) {
Set<V> ret = map.get(key);
if (ret == null) {
if (create) {
ret = createSet();
map.put(key, ret);
} else {
ret = emptySet();
}
}
return ret;
}
/*
* (non-Javadoc)
*
* @see AAA.util.MultiMap#put(K, V)
*/
@Override
public boolean put(K key, V val) {
Set<V> vals = map.get(key);
if (vals == null) {
vals = createSet();
map.put(key, vals);
}
return vals.add(val);
}
/*
* (non-Javadoc)
*
* @see AAA.util.MultiMap#remove(K, V)
*/
@Override
public boolean remove(K key, V val) {<FILL_FUNCTION_BODY>}
@Override
public Set<V> removeAll(K key) {
return map.remove(key);
}
/*
* (non-Javadoc)
*
* @see AAA.util.MultiMap#keys()
*/
@Override
public Set<K> keySet() {
return map.keySet();
}
/*
* (non-Javadoc)
*
* @see AAA.util.MultiMap#containsKey(java.lang.Object)
*/
@Override
public boolean containsKey(K key) {
return map.containsKey(key);
}
/*
* (non-Javadoc)
*
* @see AAA.util.MultiMap#size()
*/
@Override
public int size() {
int ret = 0;
for (K key : keySet()) {
ret += get(key).size();
}
return ret;
}
/*
* (non-Javadoc)
*
* @see AAA.util.MultiMap#toString()
*/
@Override
public String toString() {
return map.toString();
}
/*
* (non-Javadoc)
*
* @see AAA.util.MultiMap#putAll(K, java.util.Set)
*/
@Override
public boolean putAll(K key, Collection<? extends V> vals) {
Set<V> edges = map.get(key);
if (edges == null) {
edges = createSet();
map.put(key, edges);
}
return edges.addAll(vals);
}
@Override
public void clear() {
map.clear();
}
@Override
public boolean isEmpty() {
return map.isEmpty();
}
}
|
Set<V> elems = map.get(key);
if (elems == null) {
return false;
}
boolean ret = elems.remove(val);
if (elems.isEmpty()) {
map.remove(key);
}
return ret;
| 908
| 74
| 982
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/spark/ondemand/genericutil/ArraySet.java
|
ArraySet
|
remove
|
class ArraySet<T> extends AbstractSet<T> {
private static final ArraySet EMPTY = new ArraySet<Object>(0, true) {
public boolean add(Object obj_) {
throw new RuntimeException();
}
};
@SuppressWarnings("all")
public static final <T> ArraySet<T> empty() {
return (ArraySet<T>) EMPTY;
}
private T[] _elems;
private int _curIndex = 0;
private final boolean checkDupes;
@SuppressWarnings("all")
public ArraySet(int numElems_, boolean checkDupes) {
_elems = (T[]) new Object[numElems_];
this.checkDupes = checkDupes;
}
public ArraySet() {
this(1, true);
}
@SuppressWarnings("all")
public ArraySet(ArraySet<T> other) {
int size = other._curIndex;
this._elems = (T[]) new Object[size];
this.checkDupes = other.checkDupes;
this._curIndex = size;
System.arraycopy(other._elems, 0, _elems, 0, size);
}
public ArraySet(Collection<T> other) {
this(other.size(), true);
addAll(other);
}
/*
* (non-Javadoc)
*
* @see AAA.util.AAASet#add(java.lang.Object)
*/
@SuppressWarnings("all")
public boolean add(T obj_) {
assert obj_ != null;
if (checkDupes && this.contains(obj_)) {
return false;
}
if (_curIndex == _elems.length) {
// lengthen array
Object[] tmp = _elems;
_elems = (T[]) new Object[tmp.length * 2];
System.arraycopy(tmp, 0, _elems, 0, tmp.length);
}
_elems[_curIndex] = obj_;
_curIndex++;
return true;
}
public boolean addAll(ArraySet<T> other) {
boolean ret = false;
for (int i = 0; i < other.size(); i++) {
boolean added = add(other.get(i));
ret = ret || added;
}
return ret;
}
/*
* (non-Javadoc)
*
* @see AAA.util.AAASet#contains(java.lang.Object)
*/
public boolean contains(Object obj_) {
for (int i = 0; i < _curIndex; i++) {
if (_elems[i].equals(obj_)) {
return true;
}
}
return false;
}
public boolean intersects(ArraySet<T> other) {
for (int i = 0; i < other.size(); i++) {
if (contains(other.get(i))) {
return true;
}
}
return false;
}
/*
* (non-Javadoc)
*
* @see AAA.util.AAASet#forall(AAA.util.ObjectVisitor)
*/
public void forall(ObjectVisitor<T> visitor_) {
for (int i = 0; i < _curIndex; i++) {
visitor_.visit(_elems[i]);
}
}
public int size() {
return _curIndex;
}
public T get(int i) {
return _elems[i];
}
public boolean remove(Object obj_) {<FILL_FUNCTION_BODY>}
/**
* @param ind
* @return
*/
public boolean remove(int ind) {
// hope i got this right...
System.arraycopy(_elems, ind + 1, _elems, ind, _curIndex - (ind + 1));
_curIndex--;
return true;
}
public void clear() {
_curIndex = 0;
}
public boolean isEmpty() {
return size() == 0;
}
public String toString() {
StringBuffer ret = new StringBuffer();
ret.append('[');
for (int i = 0; i < size(); i++) {
ret.append(get(i).toString());
if (i + 1 < size()) {
ret.append(", ");
}
}
ret.append(']');
return ret.toString();
}
/*
* (non-Javadoc)
*
* @see java.util.Set#toArray()
*/
public Object[] toArray() {
throw new UnsupportedOperationException();
}
/*
* (non-Javadoc)
*
* @see java.util.Set#addAll(java.util.Collection)
*/
public boolean addAll(Collection<? extends T> c) {
boolean ret = false;
for (T element : c) {
boolean added = add(element);
ret = ret || added;
}
return ret;
}
/*
* (non-Javadoc)
*
* @see java.util.Set#iterator()
*/
public Iterator<T> iterator() {
return new ArraySetIterator();
}
/*
* (non-Javadoc)
*
* @see java.util.Set#toArray(java.lang.Object[])
*/
@SuppressWarnings("unchecked")
public <U> U[] toArray(U[] a) {
for (int i = 0; i < _curIndex; i++) {
T t = _elems[i];
a[i] = (U) t;
}
return a;
}
/**
* @author manu
*/
public class ArraySetIterator implements Iterator<T> {
int ind = 0;
final int setSize = size();
/**
*
*/
public ArraySetIterator() {
}
/*
* (non-Javadoc)
*
* @see java.util.Iterator#remove()
*/
public void remove() {
throw new UnsupportedOperationException();
}
/*
* (non-Javadoc)
*
* @see java.util.Iterator#hasNext()
*/
public boolean hasNext() {
return ind < setSize;
}
/*
* (non-Javadoc)
*
* @see java.util.Iterator#next()
*/
public T next() {
if (ind >= setSize) {
throw new NoSuchElementException();
}
return get(ind++);
}
}
}
|
int ind;
for (ind = 0; ind < _curIndex && !_elems[ind].equals(obj_); ind++) {
}
// check if object was never there
if (ind == _curIndex) {
return false;
}
return remove(ind);
| 1,788
| 75
| 1,863
|
<methods>public boolean equals(java.lang.Object) ,public int hashCode() ,public boolean removeAll(Collection<?>) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/spark/ondemand/genericutil/FIFOQueue.java
|
FIFOQueue
|
add
|
class FIFOQueue {
/**
* the buffer.
*/
private Object[] _buf;
/**
* pointer to current top of buffer
*/
private int _top;
/**
* point to current bottom of buffer, where things will be added invariant: after call to add / remove, should always point
* to an empty slot in the buffer
*/
private int _bottom;
/**
* @param initialSize_
* the initial size of the queue
*/
public FIFOQueue(int initialSize_) {
_buf = new Object[initialSize_];
}
public FIFOQueue() {
this(10);
}
public boolean push(Object obj_) {
return add(obj_);
}
/**
* add an element to the bottom of the queue
*/
public boolean add(Object obj_) {<FILL_FUNCTION_BODY>}
public Object pop() {
return remove();
}
/**
* remove the top element from the buffer
*/
public Object remove() {
// check if buffer is empty
if (_bottom == _top) {
return null;
}
Object ret = _buf[_top];
// increment top, wrapping if necessary
_top = (_top == _buf.length - 1) ? 0 : _top + 1;
return ret;
}
public boolean isEmpty() {
return _bottom == _top;
}
public String toString() {
return _bottom + " " + _top;
}
public void clear() {
_bottom = 0;
_top = 0;
}
}
|
// Assert.chk(obj_ != null);
// add the element
_buf[_bottom] = obj_;
// increment bottom, wrapping around if necessary
_bottom = (_bottom == _buf.length - 1) ? 0 : _bottom + 1;
// see if we need to increase the queue size
if (_bottom == _top) {
// allocate a new array and copy
int oldLen = _buf.length;
int newLen = oldLen * 2;
// System.out.println("growing buffer to size " + newLen);
Object[] newBuf = new Object[newLen];
int topToEnd = oldLen - _top;
int newTop = newLen - topToEnd;
// copy from 0 to _top to beginning of new buffer,
// _top to _buf.length to the end of the new buffer
System.arraycopy(_buf, 0, newBuf, 0, _top);
System.arraycopy(_buf, _top, newBuf, newTop, topToEnd);
_buf = newBuf;
_top = newTop;
return true;
}
return false;
| 429
| 288
| 717
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/spark/ondemand/genericutil/ImmutableStack.java
|
ImmutableStack
|
topMatches
|
class ImmutableStack<T> {
private static final ImmutableStack<Object> EMPTY = new ImmutableStack<Object>(new Object[0]);
private static final int MAX_SIZE = Integer.MAX_VALUE;
public static int getMaxSize() {
return MAX_SIZE;
}
@SuppressWarnings("unchecked")
public static final <T> ImmutableStack<T> emptyStack() {
return (ImmutableStack<T>) EMPTY;
}
final private T[] entries;
private ImmutableStack(T[] entries) {
this.entries = entries;
}
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o != null && o instanceof ImmutableStack) {
ImmutableStack other = (ImmutableStack) o;
return Arrays.equals(entries, other.entries);
}
return false;
}
public int hashCode() {
return Util.hashArray(this.entries);
}
@SuppressWarnings("unchecked")
public ImmutableStack<T> push(T entry) {
assert entry != null;
if (MAX_SIZE == 0) {
return emptyStack();
}
int size = entries.length + 1;
T[] tmpEntries = null;
if (size <= MAX_SIZE) {
tmpEntries = (T[]) new Object[size];
System.arraycopy(entries, 0, tmpEntries, 0, entries.length);
tmpEntries[size - 1] = entry;
} else {
tmpEntries = (T[]) new Object[MAX_SIZE];
System.arraycopy(entries, 1, tmpEntries, 0, entries.length - 1);
tmpEntries[MAX_SIZE - 1] = entry;
}
return new ImmutableStack<T>(tmpEntries);
}
public T peek() {
assert entries.length != 0;
return entries[entries.length - 1];
}
@SuppressWarnings("unchecked")
public ImmutableStack<T> pop() {
assert entries.length != 0;
int size = entries.length - 1;
T[] tmpEntries = (T[]) new Object[size];
System.arraycopy(entries, 0, tmpEntries, 0, size);
return new ImmutableStack<T>(tmpEntries);
}
public boolean isEmpty() {
return entries.length == 0;
}
public int size() {
return entries.length;
}
public T get(int i) {
return entries[i];
}
public String toString() {
String objArrayToString = Util.objArrayToString(entries);
assert entries.length <= MAX_SIZE : objArrayToString;
return objArrayToString;
}
public boolean contains(T entry) {
return Util.arrayContains(entries, entry, entries.length);
}
public boolean topMatches(ImmutableStack<T> other) {<FILL_FUNCTION_BODY>}
@SuppressWarnings("unchecked")
public ImmutableStack<T> reverse() {
T[] tmpEntries = (T[]) new Object[entries.length];
for (int i = entries.length - 1, j = 0; i >= 0; i--, j++) {
tmpEntries[j] = entries[i];
}
return new ImmutableStack<T>(tmpEntries);
}
@SuppressWarnings("unchecked")
public ImmutableStack<T> popAll(ImmutableStack<T> other) {
// TODO Auto-generated method stub
assert topMatches(other);
int size = entries.length - other.entries.length;
T[] tmpEntries = (T[]) new Object[size];
System.arraycopy(entries, 0, tmpEntries, 0, size);
return new ImmutableStack<T>(tmpEntries);
}
@SuppressWarnings("unchecked")
public ImmutableStack<T> pushAll(ImmutableStack<T> other) {
// TODO Auto-generated method stub
int size = entries.length + other.entries.length;
T[] tmpEntries = null;
if (size <= MAX_SIZE) {
tmpEntries = (T[]) new Object[size];
System.arraycopy(entries, 0, tmpEntries, 0, entries.length);
System.arraycopy(other.entries, 0, tmpEntries, entries.length, other.entries.length);
} else {
tmpEntries = (T[]) new Object[MAX_SIZE];
// other has size at most MAX_SIZE
// must keep all in other
// top MAX_SIZE - other.size from this
int numFromThis = MAX_SIZE - other.entries.length;
System.arraycopy(entries, entries.length - numFromThis, tmpEntries, 0, numFromThis);
System.arraycopy(other.entries, 0, tmpEntries, numFromThis, other.entries.length);
}
return new ImmutableStack<T>(tmpEntries);
}
}
|
if (other.size() > size()) {
return false;
}
for (int i = other.size() - 1, j = this.size() - 1; i >= 0; i--, j--) {
if (!other.get(i).equals(get(j))) {
return false;
}
}
return true;
| 1,343
| 92
| 1,435
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/spark/ondemand/genericutil/Predicate.java
|
Predicate
|
or
|
class Predicate<T> {
public static final Predicate FALSE = new Predicate() {
@Override
public boolean test(Object obj_) {
return false;
}
};
public static final Predicate TRUE = FALSE.not();
@SuppressWarnings("unchecked")
public static <T> Predicate<T> truePred() {
return (Predicate<T>) TRUE;
}
@SuppressWarnings("unchecked")
public static <T> Predicate<T> falsePred() {
return (Predicate<T>) FALSE;
}
/** Test whether an {@link Object} satisfies this {@link Predicate} */
public abstract boolean test(T obj_);
/** Return a predicate that is a negation of this predicate */
public Predicate<T> not() {
final Predicate<T> originalPredicate = this;
return new Predicate<T>() {
public boolean test(T obj_) {
return !originalPredicate.test(obj_);
}
};
}
/**
* Return a predicate that is a conjunction of this predicate and another predicate
*/
public Predicate<T> and(final Predicate<T> conjunct_) {
final Predicate<T> originalPredicate = this;
return new Predicate<T>() {
public boolean test(T obj_) {
return originalPredicate.test(obj_) && conjunct_.test(obj_);
}
};
}
/**
* Return a predicate that is a conjunction of this predicate and another predicate
*/
public Predicate<T> or(final Predicate<T> disjunct_) {<FILL_FUNCTION_BODY>}
}
|
final Predicate<T> originalPredicate = this;
return new Predicate<T>() {
public boolean test(T obj_) {
return originalPredicate.test(obj_) || disjunct_.test(obj_);
}
};
| 426
| 64
| 490
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/spark/ondemand/genericutil/Stack.java
|
Stack
|
clone
|
class Stack<T> implements Cloneable {
private T[] elems;
private int size = 0;
@SuppressWarnings("unchecked")
public Stack(int numElems_) {
elems = (T[]) new Object[numElems_];
}
public Stack() {
this(4);
}
@SuppressWarnings("unchecked")
public void push(T obj_) {
assert obj_ != null;
if (size == elems.length) {
// lengthen array
Object[] tmp = elems;
elems = (T[]) new Object[tmp.length * 2];
System.arraycopy(tmp, 0, elems, 0, tmp.length);
}
elems[size] = obj_;
size++;
}
public void pushAll(Collection<T> c) {
for (T t : c) {
push(t);
}
}
public T pop() {
if (size == 0) {
return null;
}
size--;
T ret = elems[size];
elems[size] = null;
return ret;
}
public T peek() {
if (size == 0) {
return null;
}
return elems[size - 1];
}
public int size() {
return size;
}
public boolean isEmpty() {
return size == 0;
}
public void clear() {
size = 0;
}
@SuppressWarnings("unchecked")
public Stack<T> clone() {<FILL_FUNCTION_BODY>}
public Object get(int i) {
return elems[i];
}
public boolean contains(Object o) {
return Util.arrayContains(elems, o, size);
}
/**
* returns first index
*
* @param o
* @return
*/
public int indexOf(T o) {
for (int i = 0; i < size && elems[i] != null; i++) {
if (elems[i].equals(o)) {
return i;
}
}
return -1;
}
public String toString() {
StringBuffer s = new StringBuffer();
s.append("[");
for (int i = 0; i < size && elems[i] != null; i++) {
if (i > 0) {
s.append(", ");
}
s.append(elems[i].toString());
}
s.append("]");
return s.toString();
}
}
|
Stack<T> ret = null;
try {
ret = (Stack<T>) super.clone();
ret.elems = (T[]) new Object[elems.length];
System.arraycopy(elems, 0, ret.elems, 0, size);
return ret;
} catch (CloneNotSupportedException e) {
// should not happen
throw new InternalError();
}
| 694
| 108
| 802
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/spark/ondemand/genericutil/UnorderedPair.java
|
UnorderedPair
|
equals
|
class UnorderedPair<U, V> {
public U o1;
public V o2;
public UnorderedPair(U o1, V o2) {
this.o1 = o1;
this.o2 = o2;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(Object obj) {<FILL_FUNCTION_BODY>}
/*
* (non-Javadoc)
*
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
return o1.hashCode() + o2.hashCode();
}
public String toString() {
return "{" + o1.toString() + ", " + o2.toString() + "}";
}
}
|
if (obj != null && obj.getClass() == UnorderedPair.class) {
UnorderedPair u = (UnorderedPair) obj;
return (u.o1.equals(o1) && u.o2.equals(o2)) || (u.o1.equals(o2) && u.o2.equals(o1));
}
return false;
| 229
| 95
| 324
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/spark/ondemand/pautil/OTFMethodSCCManager.java
|
OTFMethodSCCManager
|
makeSameSCC
|
class OTFMethodSCCManager {
private DisjointSets disj;
private Map<SootMethod, Integer> numbers = new HashMap<>();
public OTFMethodSCCManager() {
int num = 0;
for (SootClass c : Scene.v().getClasses()) {
for (SootMethod m : c.getMethods()) {
numbers.put(m, num++);
}
}
disj = new DisjointSets(num + 1);
}
public boolean inSameSCC(SootMethod m1, SootMethod m2) {
return disj.find(numbers.get(m1)) == disj.find(numbers.get(m2));
}
public void makeSameSCC(Set<SootMethod> methods) {<FILL_FUNCTION_BODY>}
}
|
SootMethod prevMethod = null;
for (SootMethod method : methods) {
if (prevMethod != null) {
int prevMethodRep = disj.find(numbers.get(prevMethod));
int methodRep = disj.find(numbers.get(method));
if (prevMethodRep != methodRep) {
disj.union(prevMethodRep, methodRep);
}
}
prevMethod = method;
}
| 214
| 117
| 331
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/spark/pag/AllocDotField.java
|
AllocDotField
|
toString
|
class AllocDotField extends Node {
/** Returns the base AllocNode. */
public AllocNode getBase() {
return base;
}
/** Returns the field of this node. */
public SparkField getField() {
return field;
}
public String toString() {<FILL_FUNCTION_BODY>}
/* End of public methods. */
AllocDotField(PAG pag, AllocNode base, SparkField field) {
super(pag, null);
if (field == null) {
throw new RuntimeException("null field");
}
this.base = base;
this.field = field;
base.addField(this, field);
pag.getAllocDotFieldNodeNumberer().add(this);
}
/* End of package methods. */
protected AllocNode base;
protected SparkField field;
}
|
return "AllocDotField " + getNumber() + " " + base + "." + field;
| 231
| 27
| 258
|
<methods>public void discardP2Set() ,public final boolean equals(java.lang.Object) ,public final int getNumber() ,public soot.jimple.spark.sets.PointsToSetInternal getP2Set() ,public soot.jimple.spark.pag.PAG getPag() ,public soot.jimple.spark.pag.Node getReplacement() ,public soot.Type getType() ,public final int hashCode() ,public soot.jimple.spark.sets.PointsToSetInternal makeP2Set() ,public void mergeWith(soot.jimple.spark.pag.Node) ,public final void setNumber(int) ,public void setP2Set(soot.jimple.spark.sets.PointsToSetInternal) ,public void setType(soot.Type) <variables>private int number,protected soot.jimple.spark.sets.PointsToSetInternal p2set,protected soot.jimple.spark.pag.PAG pag,protected soot.jimple.spark.pag.Node replacement,protected soot.Type type
|
soot-oss_soot
|
soot/src/main/java/soot/jimple/spark/pag/AllocNode.java
|
AllocNode
|
getFields
|
class AllocNode extends Node implements Context {
/** Returns the new expression of this allocation site. */
public Object getNewExpr() {
return newExpr;
}
/** Returns all field ref nodes having this node as their base. */
public Collection<AllocDotField> getAllFieldRefs() {
if (fields == null) {
return Collections.emptySet();
}
return fields.values();
}
/**
* Returns the field ref node having this node as its base, and field as its field; null if nonexistent.
*/
public AllocDotField dot(SparkField field) {
return fields == null ? null : fields.get(field);
}
public String toString() {
return "AllocNode " + getNumber() + " " + newExpr + " in method " + method;
}
/* End of public methods. */
AllocNode(PAG pag, Object newExpr, Type t, SootMethod m) {
super(pag, t);
this.method = m;
if (t instanceof RefType) {
RefType rt = (RefType) t;
if (rt.getSootClass().isAbstract()) {
boolean usesReflectionLog = new CGOptions(PhaseOptions.v().getPhaseOptions("cg")).reflection_log() != null;
if (!usesReflectionLog) {
throw new RuntimeException("Attempt to create allocnode with abstract type " + t);
}
}
}
this.newExpr = newExpr;
if (newExpr instanceof ContextVarNode) {
throw new RuntimeException();
}
pag.getAllocNodeNumberer().add(this);
}
/** Registers a AllocDotField as having this node as its base. */
void addField(AllocDotField adf, SparkField field) {
if (fields == null) {
fields = new HashMap<SparkField, AllocDotField>();
}
fields.put(field, adf);
}
public Set<AllocDotField> getFields() {<FILL_FUNCTION_BODY>}
/* End of package methods. */
protected Object newExpr;
protected Map<SparkField, AllocDotField> fields;
private SootMethod method;
public SootMethod getMethod() {
return method;
}
}
|
if (fields == null) {
return Collections.emptySet();
}
return new HashSet<AllocDotField>(fields.values());
| 601
| 41
| 642
|
<methods>public void discardP2Set() ,public final boolean equals(java.lang.Object) ,public final int getNumber() ,public soot.jimple.spark.sets.PointsToSetInternal getP2Set() ,public soot.jimple.spark.pag.PAG getPag() ,public soot.jimple.spark.pag.Node getReplacement() ,public soot.Type getType() ,public final int hashCode() ,public soot.jimple.spark.sets.PointsToSetInternal makeP2Set() ,public void mergeWith(soot.jimple.spark.pag.Node) ,public final void setNumber(int) ,public void setP2Set(soot.jimple.spark.sets.PointsToSetInternal) ,public void setType(soot.Type) <variables>private int number,protected soot.jimple.spark.sets.PointsToSetInternal p2set,protected soot.jimple.spark.pag.PAG pag,protected soot.jimple.spark.pag.Node replacement,protected soot.Type type
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.