本文整理汇总了Java中soot.jimple.FieldRef类的典型用法代码示例。如果您正苦于以下问题:Java FieldRef类的具体用法?Java FieldRef怎么用?Java FieldRef使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FieldRef类属于soot.jimple包,在下文中一共展示了FieldRef类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findFieldDef
import soot.jimple.FieldRef; //导入依赖的package包/类
private AssignStmt findFieldDef(Body b, FieldRef fr) {
AssignStmt fdef = null;
for (Unit u : b.getUnits()) {
if (u instanceof AssignStmt) {
AssignStmt fass = (AssignStmt) u;
Value l = fass.getLeftOp();
if (l instanceof FieldRef) {
FieldRef ffr = (FieldRef) l;
if (ffr.getField().getSignature().toString()
.equals(fr.getField().getSignature())) {
fdef = fass;
break;
}
}
}
}
return fdef;
}
示例2: handleAssign
import soot.jimple.FieldRef; //导入依赖的package包/类
void handleAssign(DefinitionStmt stmt) {
Value lval = stmt.getLeftOp();
Value rval = stmt.getRightOp();
Variable rvar;
if (lval instanceof Local) {
rvar = getLocalVariable((Local)lval);
} else {
rvar = jt.makeVariable(rval);
}
et.translateExpr(rvar, stmt.getRightOpBox());
if (lval instanceof ArrayRef) {
notSupported("We do not support arrays");
} else if (lval instanceof FieldRef) {
notSupported("We do not support field references");
}
}
示例3: printFieldRef
import soot.jimple.FieldRef; //导入依赖的package包/类
private void printFieldRef(FieldRef v) {
String refTypeName = v.getClass().getSimpleName();
p.openBlock();
String oldName = varName;
SootField f = v.getField();
ttp.setVariableName("type");
f.getType().apply(ttp);
p.print("SootFieldRef fieldRef = ");
p.printNoIndent("Scene.v().makeFieldRef(");
String className = f.getDeclaringClass().getName();
p.printNoIndent("Scene.v().getSootClass(\""+className+"\"),");
p.printNoIndent("\""+f.getName()+"\",");
p.printNoIndent("type,");
p.printNoIndent(f.isStatic()+");");
p.println("Value "+oldName+" = Jimple.v().new"+refTypeName+"(fieldRef);");
varName = oldName;
p.closeBlock();
}
示例4: isObjectArray
import soot.jimple.FieldRef; //导入依赖的package包/类
private boolean isObjectArray(Value v, Body body) {
for (Unit u : body.getUnits()) {
if (u instanceof AssignStmt) {
AssignStmt assign = (AssignStmt) u;
if (assign.getLeftOp() == v) {
if (assign.getRightOp() instanceof NewArrayExpr) {
NewArrayExpr nea = (NewArrayExpr) assign.getRightOp();
if (isObject(nea.getBaseType()))
return true;
}
else if (assign.getRightOp() instanceof FieldRef) {
FieldRef fr = (FieldRef) assign.getRightOp();
if (fr.getType() instanceof ArrayType)
if (isObject(((ArrayType) fr.getType())
.getArrayElementType()))
return true;
}
}
}
}
return false;
}
示例5: getOrCreateInitializer
import soot.jimple.FieldRef; //导入依赖的package包/类
private SootMethod getOrCreateInitializer(SootClass sc,
Set<SootField> alreadyInitialized) {
SootMethod smInit;
// Create a static initializer if we don't already have one
smInit = sc.getMethodByNameUnsafe("<clinit>");
if (smInit == null) {
smInit = new SootMethod("<clinit>", Collections.<Type>emptyList(), VoidType.v());
smInit.setActiveBody(Jimple.v().newBody(smInit));
sc.addMethod(smInit);
smInit.setModifiers(Modifier.PUBLIC | Modifier.STATIC);
}
else {
smInit.retrieveActiveBody();
// We need to collect those variables that are already initialized somewhere
for (Unit u : smInit.getActiveBody().getUnits()) {
Stmt s = (Stmt) u;
for (ValueBox vb : s.getDefBoxes())
if (vb.getValue() instanceof FieldRef)
alreadyInitialized.add(((FieldRef) vb.getValue()).getField());
}
}
return smInit;
}
示例6: checkAccessStmt
import soot.jimple.FieldRef; //导入依赖的package包/类
private void checkAccessStmt(Stmt sootStmt, SootMethod currentMethod)
{
if(sootStmt.containsFieldRef())
{
SootField accessField = sootStmt.getFieldRef().getField();
boolean isWrite = (((DefinitionStmt)sootStmt).getLeftOp() instanceof FieldRef);
boolean isStatic = (sootStmt.getFieldRef() instanceof StaticFieldRef);
Value object = isStatic ? NullConstant.v() : ((InstanceFieldRef)sootStmt.getFieldRef()).getBase();
String methodSig = currentMethod.getSignature();
List<Value> currentLocks = new ArrayList<Value>(lockStack);
System.out.println(isWrite+" access on "+isStatic+" field "+accessField+" of "+object+" in "+methodSig+" with "+currentLocks.size()+" locks");
if(!variableAccesses.containsKey(methodSig))
{
variableAccesses.put(methodSig, new HashSet<VariableAccess>());
}
variableAccesses.get(currentMethod.getSignature()).add(
new VariableAccess(accessField, sootStmt, currentMethod, isWrite, isStatic, currentLocks));
}
}
示例7: checkSharedField
import soot.jimple.FieldRef; //导入依赖的package包/类
private boolean checkSharedField(FieldRef ref, Expression field) {
if (!Options.v().useSoundThreads()) {
return false;
} else {
if (!this.stmtSwitch.isInMonitor()) {
if (MhpInfo.v().getSharedFields(this.procInfo.getSootMethod())
.contains(ref.getField())) {
// if the field can be modified in another thread, add a
// havoc statement before it is used.
return true;
} else {
// do nothing
}
} else {
Log.info("Was in monitor ... ");
}
}
return false;
}
示例8: containsSameField
import soot.jimple.FieldRef; //导入依赖的package包/类
private boolean containsSameField(ValueM u, ValueM v)
{
Value uValue;
Value vValue;
SootField uField;
SootField vField;
analyzeMethod(u.getMethod());
analyzeMethod(v.getMethod());
uValue=localAssigns.get(u);
vValue=localAssigns.get(v);
if (uValue == null || vValue == null
|| !(uValue instanceof FieldRef) || !(vValue instanceof FieldRef))
return false;
uField=((FieldRef)uValue).getField();
vField=((FieldRef)vValue).getField();
return uField.getSignature().equals(vField.getSignature());
}
示例9: findUriDef
import soot.jimple.FieldRef; //导入依赖的package包/类
private String findUriDef(Body b, Unit u, Local l) {
final UnitGraph g = new ExceptionalUnitGraph(b);
final SmartLocalDefs localDefs = new SmartLocalDefs(g, new SimpleLiveLocals(g));
final SimpleLocalUses localUses = new SimpleLocalUses(g, localDefs);
List<Unit> defs = localDefs.getDefsOfAt((Local) l, u);
if (defs.size() == 0) {
System.out.println("warning: uri def empty!");
return null;
}
Unit def = defs.get(0);
logger.debug("uri def: " + def);
if (def instanceof IdentityStmt) {
System.out.println("warning: do not handle uri from identity stmt");
return null;
} else if (def instanceof AssignStmt) {
AssignStmt ass = (AssignStmt) def;
Value r = ass.getRightOp();
if (r instanceof FieldRef) {
FieldRef fr = (FieldRef) r;
SootField sf = fr.getField();
if (sf.getName().contains("URI")) {
String auth = getFieldFromClass(sf);
return auth;
}
} else {
System.out.println("warning: uri: do not handle def '" + def + "'");
return null;
}
}
return null;
}
示例10: computeGlobalAliases
import soot.jimple.FieldRef; //导入依赖的package包/类
/**
* Computes the global non-flow-sensitive alias information for the given
* method
* @param method The method for which to compute the alias information
*/
private Map<AccessPath, Set<AccessPath>> computeGlobalAliases(SootMethod method) {
Map<AccessPath, Set<AccessPath>> res = new HashMap<AccessPath, Set<AccessPath>>();
// Find the aliases
for (Unit u : method.getActiveBody().getUnits()) {
if (!(u instanceof AssignStmt))
continue;
final AssignStmt assign = (AssignStmt) u;
// Aliases can only be generated on the heap
if (!(assign.getLeftOp() instanceof FieldRef
&& (assign.getRightOp() instanceof FieldRef
|| assign.getRightOp() instanceof Local)))
if (!(assign.getRightOp() instanceof FieldRef
&& (assign.getLeftOp() instanceof FieldRef
|| assign.getLeftOp() instanceof Local)))
continue;
final AccessPath apLeft = new AccessPath(assign.getLeftOp(), true);
final AccessPath apRight = new AccessPath(assign.getRightOp(), true);
Set<AccessPath> mapLeft = res.get(apLeft);
if (mapLeft == null) {
mapLeft = new HashSet<AccessPath>();
res.put(apLeft, mapLeft);
}
mapLeft.add(apRight);
Set<AccessPath> mapRight = res.get(apRight);
if (mapRight == null) {
mapRight = new HashSet<AccessPath>();
res.put(apRight, mapRight);
}
mapLeft.add(apLeft);
}
return res;
}
示例11: getFieldRefWrap
import soot.jimple.FieldRef; //导入依赖的package包/类
public static Value getFieldRefWrap(Value value) {
if (value instanceof FieldRef) {
return new EquivalentValue((FieldRef) value);
} else {
return value;
}
}
示例12: handleFieldRef
import soot.jimple.FieldRef; //导入依赖的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);
}
示例13: handleFieldRef
import soot.jimple.FieldRef; //导入依赖的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);
}
}
示例14: wrapValue
import soot.jimple.FieldRef; //导入依赖的package包/类
private Value wrapValue(Value value)
{
if(value instanceof EquivalentValue)
{
return value;
}
else if(value instanceof FieldRef)
{
return new EquivalentValue(value);
}
else
{
return value;
}
}
示例15: inDefinitionStmt
import soot.jimple.FieldRef; //导入依赖的package包/类
public void inDefinitionStmt(DefinitionStmt s){
Value leftOp = s.getLeftOp();
if(leftOp instanceof FieldRef){
//System.out.println("leftOp is a fieldRef:"+s);
SootField field = ((FieldRef)leftOp).getField();
//check if this is a final field
if(field.isFinal()){
//System.out.println("the field is a final variable");
finalFieldDefined=true;
}
}
}