Java Code Examples for soot.jimple.InstanceFieldRef#getBase()

The following examples show how to use soot.jimple.InstanceFieldRef#getBase() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FunctionFactoryUtils.java    From DroidRA with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Determines if an instance field should be propagated through a method call. This method only
 * checks propagation rule for the field base. It does not check if the field points to an
 * argument, which should be done outside this method.
 * 
 * @param instanceFieldRef An instance field reference.
 * @param invokeExpr An invoke expression for the called method.
 * @return True if the field should be propagated.
 */
public static boolean shouldPropagateInstanceField(InstanceFieldRef instanceFieldRef,
    InvokeExpr invokeExpr) {
  Value fieldBase = instanceFieldRef.getBase();
  List<Value> argList = invokeExpr.getArgs();
  // A field reference should be propagated if the base of the field points to a method argument.
  for (int i = 0; i < argList.size(); ++i) {
    if (sourcePointsToArgument(fieldBase, argList.get(i))) {
      return true;
    }
  }

  // A field reference should be propagated if the base of the field points to the base of the
  // method call for an instance call.
  if (invokeExpr instanceof InstanceInvokeExpr) {
    Value invokeExprBase = ((InstanceInvokeExpr) invokeExpr).getBase();
    if (sourcePointsToArgument(fieldBase, invokeExprBase)) {
      return true;
    }
  }

  return false;
}
 
Example 2
Source File: NullnessAssumptionAnalysis.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
private void handleFieldRef(FieldRef fieldRef,
			AnalysisInfo out) {
		if(fieldRef instanceof InstanceFieldRef) {
			InstanceFieldRef instanceFieldRef = (InstanceFieldRef) fieldRef;
			//here we know that the receiver must point to an object
			Value base = instanceFieldRef.getBase();
			out.put(base,NON_NULL);
		}
		//but the referenced object might point to everything
//		out.put(fieldRef, TOP);
	}
 
Example 3
Source File: NullnessAnalysis.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
private void handleFieldRef(FieldRef fieldRef,
		AnalysisInfo out) {
	if(fieldRef instanceof InstanceFieldRef) {
		InstanceFieldRef instanceFieldRef = (InstanceFieldRef) fieldRef;
		//here we know that the receiver must point to an object
		Value base = instanceFieldRef.getBase();
		out.put(base,NON_NULL);
	}
}
 
Example 4
Source File: StmtVisitor.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
private Insn buildInstanceFieldPutInsn(InstanceFieldRef destRef, Value source) {
	SootField destSootField = destRef.getField();
	BuilderFieldReference destField = DexPrinter.toFieldReference(destSootField, belongingFile);
	Value instance = destRef.getBase();
	Register instanceReg = regAlloc.asLocal(instance);
	Register sourceReg = regAlloc.asImmediate(source, constantV);
	Opcode opc = getPutGetOpcodeWithTypeSuffix("iput", destField.getType());
	return new Insn22c(opc, sourceReg, instanceReg, destField);
}
 
Example 5
Source File: StmtVisitor.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
private Insn buildInstanceFieldGetInsn(Register destinationReg, InstanceFieldRef sourceRef) {
	Value instance = sourceRef.getBase();
	Register instanceReg = regAlloc.asLocal(instance);
	SootField sourceSootField = sourceRef.getField();
	BuilderFieldReference sourceField = DexPrinter.toFieldReference(sourceSootField, belongingFile);
	Opcode opc = getPutGetOpcodeWithTypeSuffix("iget", sourceField.getType());
	return new Insn22c(opc, destinationReg, instanceReg, sourceField);
}
 
Example 6
Source File: WeightedBoomerang.java    From SPDS with Eclipse Public License 2.0 5 votes vote down vote up
protected FieldReadPOI createFieldLoad(Statement s) {
    Stmt stmt = s.getUnit().get();
    AssignStmt as = (AssignStmt) stmt;
    InstanceFieldRef ifr = (InstanceFieldRef) as.getRightOp();
    Val base = new Val(ifr.getBase(), icfg().getMethodOf(as));
    Field field = new Field(ifr.getField());
    return fieldReads
            .getOrCreate(new FieldReadPOI(s, base, field, new Val(as.getLeftOp(), icfg().getMethodOf(as))));
}
 
Example 7
Source File: WeightedBoomerang.java    From SPDS with Eclipse Public License 2.0 5 votes vote down vote up
protected FieldWritePOI createFieldStore(Statement s) {
    Stmt stmt = s.getUnit().get();
    AssignStmt as = (AssignStmt) stmt;
    InstanceFieldRef ifr = (InstanceFieldRef) as.getLeftOp();
    Val base = new Val(ifr.getBase(), icfg().getMethodOf(as));
    Val stored = new Val(as.getRightOp(), icfg().getMethodOf(as));
    Field field = new Field(ifr.getField());
    return fieldWrites.getOrCreate(new FieldWritePOI(s, base, field, stored));
}