本文整理汇总了Java中soot.jimple.InstanceFieldRef.getBase方法的典型用法代码示例。如果您正苦于以下问题:Java InstanceFieldRef.getBase方法的具体用法?Java InstanceFieldRef.getBase怎么用?Java InstanceFieldRef.getBase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类soot.jimple.InstanceFieldRef
的用法示例。
在下文中一共展示了InstanceFieldRef.getBase方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldPropagateInstanceField
import soot.jimple.InstanceFieldRef; //导入方法依赖的package包/类
/**
* 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;
}
示例2: isAliasValue
import soot.jimple.InstanceFieldRef; //导入方法依赖的package包/类
private Set<AliasValue> isAliasValue(Set<AliasValue> aliasSet, Value value){
Set<AliasValue> result = new HashSet<AliasValue>();
for(AliasValue av : aliasSet){
if(value instanceof InstanceFieldRef){
ArrayList<SootFieldRef> accessPath = av.getAccessPath();
if(accessPath != null && accessPath.size() > 0){
InstanceFieldRef ifr = (InstanceFieldRef) value;
Value base = ifr.getBase();
SootFieldRef sfr = ifr.getFieldRef();
if(av.getAliasBase().toString().equals(base.toString()) &&
accessPath.get(0).toString().equals(sfr.toString())){
result.add(av);
}
}
}else{
if(av.getAliasBase().toString().equals(value.toString())){
result.add(av);
}
}
}
return result;
}
示例3: hasPrefix
import soot.jimple.InstanceFieldRef; //导入方法依赖的package包/类
public boolean hasPrefix(Value v) { // if this has prefix v
if (v instanceof Local) {
if (local == null)
return false;
else
return (local.equals(v));
} else if (v instanceof InstanceFieldRef) {
InstanceFieldRef ifr = (InstanceFieldRef) v;
if (local == null) {
if (ifr.getBase() != null)
return false;
} else if (!local.equals(ifr.getBase()))
return false;
if (fields.length > 0 && ifr.getField() == fields[0])
return true;
return false;
} else if (v instanceof StaticFieldRef) {
StaticFieldRef sfr = (StaticFieldRef) v;
if (local != null)
return false;
if (fields.length > 0 && sfr.getField() == fields[0])
return true;
return false;
} else if (v instanceof ArrayRef) {
ArrayRef ar = (ArrayRef) v;
if (local == null)
return false;
else
return (local.equals(ar.getBase()));
} else if (v instanceof Constant) {
return false;
} else
throw new RuntimeException("Unexpected left side " + v.getClass());
}
示例4: handleFieldRef
import soot.jimple.InstanceFieldRef; //导入方法依赖的package包/类
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);
}
示例5: handleFieldRef
import soot.jimple.InstanceFieldRef; //导入方法依赖的package包/类
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);
}
}
示例6: buildInstanceFieldPutInsn
import soot.jimple.InstanceFieldRef; //导入方法依赖的package包/类
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);
}
示例7: buildInstanceFieldGetInsn
import soot.jimple.InstanceFieldRef; //导入方法依赖的package包/类
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);
}
示例8: isMe
import soot.jimple.InstanceFieldRef; //导入方法依赖的package包/类
public boolean isMe(InstanceFieldRef ifr){
boolean result = false;
if(accessPath.size() == 1){
Value base = ifr.getBase();
SootFieldRef srf = ifr.getFieldRef();
if(aliasBase.toString().equals(base.toString()) &&
srf.toString().equals(accessPath.get(0).toString())){
result = true;
}
}
return result;
}
示例9: caseInstanceFieldRef
import soot.jimple.InstanceFieldRef; //导入方法依赖的package包/类
@Override
public void caseInstanceFieldRef(InstanceFieldRef arg0) {
boolean islhs = this.isLeftHandSide;
this.isLeftHandSide = false;
arg0.getBase().apply(this);
Expression base = this.getExpression();
Expression field = GlobalsCache.v().lookupSootField(arg0.getField());
boolean nullCheckNeeded = true;
// check if the field may be modified by another thread.
if (!islhs && checkSharedField(arg0, field)) {
havocField(field, base);
nullCheckNeeded = false;
}
SootProcedureInfo pinfo = this.stmtSwitch.getProcInfo();
// check if base is trivially non-null
if (pinfo != null) {
CustomNullnessAnalysis nna = this.stmtSwitch.getProcInfo()
.getNullnessAnalysis();
if (nna != null && arg0.getBase() instanceof Immediate) {
if (nna.isAlwaysNonNullBefore(
this.stmtSwitch.getCurrentStatement(),
(Immediate) arg0.getBase())) {
nullCheckNeeded = false;
}
}
//TODO: this is a very clumsy way of obtaining thislocal
// but it is not obvious when it throws an exception.
Local thislocal = null;
try {
thislocal = pinfo.getSootMethod().getActiveBody().getThisLocal();
} catch (Exception e) {
thislocal = null;
}
//check if base is "this" or a local variable
//that is an alias of "this".
if (arg0.getBase() ==thislocal || arg0.getBase() instanceof ThisRef) {
nullCheckNeeded = false; // TODO: check if this is actually needed.
}
}
// We are checking if this is a @NonNull field
// if so, we add an assume to ensure that it actually is
// not null here.
checkFieldAnnotations(
this.makeHeapAccessExpression(base, field, false), arg0);
this.expressionStack.push(this.makeHeapAccessExpression(base, field,
nullCheckNeeded));
}
示例10: setLevelOfAssignStmt
import soot.jimple.InstanceFieldRef; //导入方法依赖的package包/类
/**
* Set the level of a field of an object. It can be the field of the actually
* analyzed object or the field
* @param f Reference to the instance field
* @param pos The statement where this field occurs
*/
public static void setLevelOfAssignStmt(InstanceFieldRef f, Unit pos) {
logger.log(Level.INFO, "Set level to field {0} in assignStmt in method {1}",
new Object[] {f.getField().getSignature(),b.getMethod().getName()});
// if (!(units.getFirst() instanceof IdentityStmt)
// || !(units.getFirst().getUseBoxes().get(0).getValue()
// instanceof ThisRef)) {
// System.out.println(units.getFirst().getUseBoxes().toString());
// throw new InternalAnalyzerException("Expected @this reference");
// }
String fieldSignature = getSignatureForField(f.getField());
ArrayList<Type> parameterTypes = new ArrayList<Type>();
parameterTypes.add(RefType.v("java.lang.Object"));
parameterTypes.add(RefType.v("java.lang.String"));
// units.getFirst is already a reference to @this
// Local tmpLocal = (Local) units.getFirst().getDefBoxes().get(0).getValue();
// Retrieve the object it belongs to
Local tmpLocal = (Local) f.getBase();
Unit assignSignature = Jimple.v().newAssignStmt(
local_for_Strings, StringConstant.v(fieldSignature));
// insert: checkGlobalPC(Object, String)
Expr checkGlobalPC = Jimple.v().newVirtualInvokeExpr(
hs, Scene.v().makeMethodRef(
Scene.v().getSootClass(HANDLE_CLASS), "checkGlobalPC",
parameterTypes, VoidType.v(), false),
tmpLocal, local_for_Strings);
Unit checkGlobalPCExpr = Jimple.v().newInvokeStmt(checkGlobalPC);
// insert setLevelOfField
Expr addObj = Jimple.v().newVirtualInvokeExpr(
hs, Scene.v().makeMethodRef(
Scene.v().getSootClass(HANDLE_CLASS), "setLevelOfField",
parameterTypes, Scene.v().getObjectType(), false),
tmpLocal, local_for_Strings);
Unit assignExpr = Jimple.v().newInvokeStmt(addObj);
unitStore_Before.insertElement(unitStore_After.new Element(checkGlobalPCExpr, pos));
unitStore_Before.insertElement(unitStore_Before.new Element(assignSignature, pos));
unitStore_Before.insertElement(unitStore_After.new Element(assignExpr, pos));
lastPos = pos;
}
示例11: caseInstanceFieldRef
import soot.jimple.InstanceFieldRef; //导入方法依赖的package包/类
/**
* Looks up the <em>security level</em> of the given field reference with
* the type {@link InstanceFieldRef} and stores the resulting level in
* {@link SecurityLevelValueReadSwitch#level}. Additionally, the base of the
* field will be checked and if the level of the base if stronger than the
* resulting <em>security level</em> of the field, then this base
* <em>security level</em> will be stored in
* {@link SecurityLevelValueReadSwitch#level}.
*
* @param v
* Instance field reference for which the <em>security level</em>
* should be calculated.
* @see soot.jimple.RefSwitch#caseInstanceFieldRef(soot.jimple.InstanceFieldRef)
* @see SecurityLevelValueReadSwitch#handleFieldAccess(FieldRef)
* @see SecurityLevelValueReadSwitch#handleBase(Value, Value)
*/
@Override
public void caseInstanceFieldRef(InstanceFieldRef v) {
handleFieldAccess(v);
Value baseValue = v.getBase();
handleBase(baseValue, v);
}