本文整理汇总了Java中soot.jimple.ArrayRef类的典型用法代码示例。如果您正苦于以下问题:Java ArrayRef类的具体用法?Java ArrayRef怎么用?Java ArrayRef使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ArrayRef类属于soot.jimple包,在下文中一共展示了ArrayRef类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateParameterArray
import soot.jimple.ArrayRef; //导入依赖的package包/类
public static Pair<Value, List<Unit>> generateParameterArray(List<Value> parameterList, Body body){
List<Unit> generated = new ArrayList<Unit>();
NewArrayExpr arrayExpr = Jimple.v().newNewArrayExpr(RefType.v("java.lang.Object"), IntConstant.v(parameterList.size()));
Value newArrayLocal = generateFreshLocal(body, getParameterArrayType());
Unit newAssignStmt = Jimple.v().newAssignStmt(newArrayLocal, arrayExpr);
generated.add(newAssignStmt);
for(int i = 0; i < parameterList.size(); i++){
Value index = IntConstant.v(i);
ArrayRef leftSide = Jimple.v().newArrayRef(newArrayLocal, index);
Value rightSide = generateCorrectObject(body, parameterList.get(i), generated);
Unit parameterInArray = Jimple.v().newAssignStmt(leftSide, rightSide);
generated.add(parameterInArray);
}
return new Pair<Value, List<Unit>>(newArrayLocal, generated);
}
示例2: hasConstantIndexAtArrayForSplitDataFlow
import soot.jimple.ArrayRef; //导入依赖的package包/类
private boolean hasConstantIndexAtArrayForSplitDataFlow(Stmt[] dataflow) {
Stmt firstAssign = dataflow[0];
if(firstAssign instanceof AssignStmt) {
AssignStmt ass = (AssignStmt)firstAssign;
Value value = ass.getRightOp();
if(value instanceof ArrayRef) {
ArrayRef aRef = (ArrayRef)value;
Value index = aRef.getIndex();
if(index instanceof IntConstant)
return true;
}
}
else
throw new RuntimeException("this should not happen - wrong assumption");
return false;
}
示例3: getConstantArrayIndexForSplitDataFlow
import soot.jimple.ArrayRef; //导入依赖的package包/类
private int getConstantArrayIndexForSplitDataFlow(Stmt[] dataflow) {
Stmt firstAssign = dataflow[0];
if(firstAssign instanceof AssignStmt) {
AssignStmt ass = (AssignStmt)firstAssign;
Value value = ass.getRightOp();
if(value instanceof ArrayRef) {
ArrayRef aRef = (ArrayRef)value;
Value index = aRef.getIndex();
if(index instanceof IntConstant)
return ((IntConstant) index).value;
}
}
else
throw new RuntimeException("this should not happen - wrong assumption");
return -1;
}
示例4: getPointsToSet
import soot.jimple.ArrayRef; //导入依赖的package包/类
/**
* Gets the points-to-set for the given value
* @param targetValue The value for which to get the points-to-set
* @return The points-to-set for the given value
*/
private PointsToSet getPointsToSet(Value targetValue) {
PointsToAnalysis pta = Scene.v().getPointsToAnalysis();
synchronized (pta) {
if (targetValue instanceof Local)
return pta.reachingObjects((Local) targetValue);
else if (targetValue instanceof InstanceFieldRef) {
InstanceFieldRef iref = (InstanceFieldRef) targetValue;
return pta.reachingObjects((Local) iref.getBase(), iref.getField());
}
else if (targetValue instanceof StaticFieldRef) {
StaticFieldRef sref = (StaticFieldRef) targetValue;
return pta.reachingObjects(sref.getField());
}
else if (targetValue instanceof ArrayRef) {
ArrayRef aref = (ArrayRef) targetValue;
return pta.reachingObjects((Local) aref.getBase());
}
else
throw new RuntimeException("Unexpected value type for aliasing: " + targetValue.getClass());
}
}
示例5: selectBase
import soot.jimple.ArrayRef; //导入依赖的package包/类
/**
* the operations that are not relevant for analysis like "not" or casts
* are removed - array refs are only removed if explicitly stated
* @param val the value which should be pruned
* @param keepArrayRef if false then array refs are pruned to the base array object
* @return the value (possibly pruned to base object)
*/ //we want to keep ArrayRef for objects on the right side of the assignment
public static Value selectBase(Value val, boolean keepArrayRef){
//we taint base of array instead of array elements
if (val instanceof ArrayRef && !keepArrayRef) {
return selectBase(((ArrayRef) val).getBase(), keepArrayRef);
}
if (val instanceof CastExpr) {
return selectBase(((CastExpr) val).getOp(), keepArrayRef);
}
// Check for unary operators like "not" or "length"
if (val instanceof UnopExpr)
return selectBase(((UnopExpr) val).getOp(), keepArrayRef);
return val;
}
示例6: handleAssign
import soot.jimple.ArrayRef; //导入依赖的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");
}
}
示例7: caseArrayRef
import soot.jimple.ArrayRef; //导入依赖的package包/类
public void caseArrayRef(ArrayRef v) {
String oldName = varName;
Value base = v.getBase();
suggestVariableName("base");
String baseName = varName;
base.apply(this);
Value index = v.getIndex();
suggestVariableName("index");
String indexName = varName;
index.apply(this);
p.println("Value "+oldName+" = Jimple.v().newArrayRef("+baseName+", "+indexName+");");
varName = oldName;
}
示例8: jimplify
import soot.jimple.ArrayRef; //导入依赖的package包/类
public void jimplify (DexBody body) {
if(!(instruction instanceof Instruction23x))
throw new IllegalArgumentException("Expected Instruction23x but got: "+instruction.getClass());
Instruction23x aPutInstr = (Instruction23x)instruction;
int source = aPutInstr.getRegisterA();
Local arrayBase = body.getRegisterLocal(aPutInstr.getRegisterB());
Local index = body.getRegisterLocal(aPutInstr.getRegisterC());
ArrayRef arrayRef = Jimple.v().newArrayRef(arrayBase, index);
Local sourceValue = body.getRegisterLocal(source);
assign = getAssignStmt(body, sourceValue, arrayRef);
if (aPutInstr.getOpcode().value == Opcode.APUT_OBJECT.value)
assign.addTag(new ObjectOpTag());
setUnit(assign);
addTags(assign);
body.add(assign);
if (IDalvikTyper.ENABLE_DVKTYPER) {
Debug.printDbg(IDalvikTyper.DEBUG, "constraint: "+ assign);
DalvikTyper.v().addConstraint(assign.getLeftOpBox(), assign.getRightOpBox());
DalvikTyper.v().setType(arrayRef.getIndexBox(), IntType.v(), true);
}
}
示例9: convertArrayLoadInsn
import soot.jimple.ArrayRef; //导入依赖的package包/类
private void convertArrayLoadInsn(InsnNode insn) {
StackFrame frame = getFrame(insn);
Operand[] out = frame.out();
Operand opr;
if (out == null) {
Operand indx = popImmediate();
Operand base = popImmediate();
ArrayRef ar = Jimple.v().newArrayRef(
base.stackOrValue(), indx.stackOrValue());
indx.addBox(ar.getIndexBox());
base.addBox(ar.getBaseBox());
opr = new Operand(insn, ar);
frame.in(indx, base);
frame.boxes(ar.getIndexBox(), ar.getBaseBox());
frame.out(opr);
} else {
opr = out[0];
frame.mergeIn(pop(), pop());
}
int op = insn.getOpcode();
if (op == DALOAD || op == LALOAD)
pushDual(opr);
else
push(opr);
}
示例10: convertArrayStoreInsn
import soot.jimple.ArrayRef; //导入依赖的package包/类
private void convertArrayStoreInsn(InsnNode insn) {
int op = insn.getOpcode();
boolean dword = op == LASTORE || op == DASTORE;
StackFrame frame = getFrame(insn);
if (!units.containsKey(insn)) {
Operand valu = dword ? popImmediateDual() : popImmediate();
Operand indx = popImmediate();
Operand base = popLocal();
ArrayRef ar = Jimple.v().newArrayRef(
base.stackOrValue(), indx.stackOrValue());
indx.addBox(ar.getIndexBox());
base.addBox(ar.getBaseBox());
AssignStmt as = Jimple.v().newAssignStmt(ar, valu.stackOrValue());
valu.addBox(as.getRightOpBox());
frame.in(valu, indx, base);
frame.boxes(as.getRightOpBox(),
ar.getIndexBox(), ar.getBaseBox());
setUnit(insn, as);
} else {
frame.mergeIn(dword ? popDual() : pop(), pop(), pop());
}
}
示例11: testJArrayRef
import soot.jimple.ArrayRef; //导入依赖的package包/类
@Test
public void testJArrayRef() {
ArrayRef arrayRef = Jimple.v().newArrayRef(
Jimple.v().newLocal("local1",
ArrayType.v(RefType.v("java.lang.Object"), 1)),
IntConstant.v(0));
Set expectedRep = new ExceptionHashSet(utility.VM_ERRORS);
expectedRep.add(utility.NULL_POINTER_EXCEPTION);
expectedRep.add(utility.ARRAY_INDEX_OUT_OF_BOUNDS_EXCEPTION);
assertTrue(ExceptionTestUtility.sameMembers(expectedRep, Collections.EMPTY_SET,
unitAnalysis.mightThrow(arrayRef)));
Set expectedCatch = new ExceptionHashSet(utility.VM_ERRORS_PLUS_SUPERTYPES);
expectedCatch.add(utility.NULL_POINTER_EXCEPTION);
expectedCatch.add(utility.ARRAY_INDEX_OUT_OF_BOUNDS_EXCEPTION);
expectedCatch.add(utility.INDEX_OUT_OF_BOUNDS_EXCEPTION);
expectedCatch.add(utility.RUNTIME_EXCEPTION);
expectedCatch.add(utility.EXCEPTION);
assertEquals(expectedCatch,
utility.catchableSubset(unitAnalysis.mightThrow(arrayRef)));
}
示例12: testGArrayRef
import soot.jimple.ArrayRef; //导入依赖的package包/类
@Test
public void testGArrayRef() {
ArrayRef arrayRef = Grimp.v().newArrayRef(
Grimp.v().newLocal("local1",
ArrayType.v(RefType.v("java.lang.Object"), 1)),
IntConstant.v(0));
Set expectedRep = new ExceptionHashSet(utility.VM_ERRORS);
expectedRep.add(utility.NULL_POINTER_EXCEPTION);
expectedRep.add(utility.ARRAY_INDEX_OUT_OF_BOUNDS_EXCEPTION);
assertTrue(ExceptionTestUtility.sameMembers(expectedRep, Collections.EMPTY_SET,
unitAnalysis.mightThrow(arrayRef)));
Set expectedCatch = new ExceptionHashSet(utility.VM_ERRORS_PLUS_SUPERTYPES);
expectedCatch.add(utility.NULL_POINTER_EXCEPTION);
expectedCatch.add(utility.ARRAY_INDEX_OUT_OF_BOUNDS_EXCEPTION);
expectedCatch.add(utility.INDEX_OUT_OF_BOUNDS_EXCEPTION);
expectedCatch.add(utility.RUNTIME_EXCEPTION);
expectedCatch.add(utility.EXCEPTION);
assertEquals(expectedCatch,
utility.catchableSubset(unitAnalysis.mightThrow(arrayRef)));
}
示例13: getErrSuf
import soot.jimple.ArrayRef; //导入依赖的package包/类
public DNF getErrSuf(Unit q) {
if (!(q instanceof AssignStmt)) return null;
AssignStmt s = (AssignStmt)q;
soot.Value lhs = s.getLeftOp();
soot.Value rhs = s.getRightOp();
soot.Value rx;
if (rhs instanceof ArrayRef)
rx = ((ArrayRef)rhs).getBase();
else if (rhs instanceof InstanceFieldRef)
rx = ((InstanceFieldRef)rhs).getBase();
else if (lhs instanceof ArrayRef)
rx = ((ArrayRef)lhs).getBase();
else if (lhs instanceof InstanceFieldRef)
rx = ((InstanceFieldRef)lhs).getBase();
else
throw new RuntimeException("Wrong query + " + q);
EscVVariable escv = null;
if (rx instanceof Local) {
int vidx = this.getDomVIdx((Local)rx);
escv = new EscVVariable(vidx,domV);
}
return new DNF(new ClauseSizeCMP(), escv, Value.E());
}
示例14: getPointsToSet
import soot.jimple.ArrayRef; //导入依赖的package包/类
/**
* Gets the points-to-set for the given value
* @param targetValue The value for which to get the points-to-set
* @return The points-to-set for the given value
*/
private PointsToSet getPointsToSet(Value targetValue) {
if (targetValue instanceof Local)
return Scene.v().getPointsToAnalysis().reachingObjects((Local) targetValue);
else if (targetValue instanceof InstanceFieldRef) {
InstanceFieldRef iref = (InstanceFieldRef) targetValue;
return Scene.v().getPointsToAnalysis().reachingObjects((Local) iref.getBase(), iref.getField());
}
else if (targetValue instanceof StaticFieldRef) {
StaticFieldRef sref = (StaticFieldRef) targetValue;
return Scene.v().getPointsToAnalysis().reachingObjects(sref.getField());
}
else if (targetValue instanceof ArrayRef) {
ArrayRef aref = (ArrayRef) targetValue;
return Scene.v().getPointsToAnalysis().reachingObjects((Local) aref.getBase());
}
else
throw new RuntimeException("Unexpected value type for aliasing: " + targetValue.getClass());
}
示例15: selectBase
import soot.jimple.ArrayRef; //导入依赖的package包/类
/**
* the operations that are not relevant for analysis like "not" or casts
* are removed - array refs are only removed if explicitly stated
* @param val the value which should be pruned
* @param keepArrayRef if false then array refs are pruned to the base array object
* @return the value (possibly pruned to base object)
*/ //we want to keep ArrayRef for objects on the right side of the assignment
public static Value selectBase(Value val, boolean keepArrayRef){
//we taint base of array instead of array elements
if (val instanceof ArrayRef && !keepArrayRef) {
return selectBase(((ArrayRef) val).getBase(), keepArrayRef);
}
if (val instanceof JCastExpr) {
return selectBase(((JCastExpr) val).getOpBox().getValue(), keepArrayRef);
}
// Check for unary operators like "not" or "length"
if (val instanceof UnopExpr)
return selectBase(((UnopExpr) val).getOp(), keepArrayRef);
return val;
}