本文整理汇总了Java中soot.jimple.ArrayRef.getIndex方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayRef.getIndex方法的具体用法?Java ArrayRef.getIndex怎么用?Java ArrayRef.getIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类soot.jimple.ArrayRef
的用法示例。
在下文中一共展示了ArrayRef.getIndex方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例4: caseArrayRef
import soot.jimple.ArrayRef; //导入方法依赖的package包/类
@Override
public void caseArrayRef(ArrayRef v) {
Value array = v.getBase();
Value index = v.getIndex();
SecurityConstraintValueReadSwitch baseSwitch = getReadSwitch(array);
SecurityConstraintValueReadSwitch indexSwitch = getReadSwitch(index);
addInheritedWriteEffects(baseSwitch.getInheritedWriteEffects());
addInheritedWriteEffects(indexSwitch.getInheritedWriteEffects());
addReadComponents(baseSwitch.getReadComponents());
addReadComponents(indexSwitch.getReadComponents());
setComponentDimension(getDimension(v.getType()));
if (baseSwitch.getEqualComponents().size() > 0) {
addReadComponent(baseSwitch.getEqualComponents().get(0));
for (int i = 1; i < baseSwitch.getEqualComponents().size(); i++) {
appendEqualComponent(baseSwitch.getEqualComponents().get(1));
}
}
}
示例5: findMaxIndexOfArray
import soot.jimple.ArrayRef; //导入方法依赖的package包/类
private int findMaxIndexOfArray(InvokeExpr invokeExpr) {
Value array = null;
int maxIndex = -1;
for(Stmt stmt : stmtVisitor.getJimpleDataFlowStatements()) {
if(stmt instanceof AssignStmt) {
AssignStmt assign = (AssignStmt)stmt;
if(array == null) {
if(assign.getRightOp().equals(invokeExpr)) {
array = assign.getLeftOp();
}
}
else{
Value rhs = assign.getRightOp();
if(rhs instanceof ArrayRef) {
ArrayRef arrayRef = (ArrayRef)rhs;
if(arrayRef.getBase().equals(array)) {
Value index = arrayRef.getIndex();
if(index instanceof IntConstant) {
IntConstant constant = (IntConstant)index;
maxIndex = constant.value;
}
}
}
}
}
}
return maxIndex;
}
示例6: buildArrayPutInsn
import soot.jimple.ArrayRef; //导入方法依赖的package包/类
private Insn buildArrayPutInsn(ArrayRef destRef, Value source) {
Value array = destRef.getBase();
Register arrayReg = regAlloc.asLocal(array);
Value index = destRef.getIndex();
Register indexReg = regAlloc.asImmediate(index, constantV);
Register sourceReg = regAlloc.asImmediate(source, constantV);
String arrayTypeDescriptor = SootToDexUtils.getArrayTypeDescriptor((ArrayType) array.getType());
Opcode opc = getPutGetOpcodeWithTypeSuffix("aput", arrayTypeDescriptor);
return new Insn23x(opc, sourceReg, arrayReg, indexReg);
}
示例7: buildArrayGetInsn
import soot.jimple.ArrayRef; //导入方法依赖的package包/类
private Insn buildArrayGetInsn(Register destinationReg, ArrayRef sourceRef) {
Value index = sourceRef.getIndex();
Register indexReg = regAlloc.asImmediate(index, constantV);
Value array = sourceRef.getBase();
Register arrayReg = regAlloc.asLocal(array);
String arrayTypeDescriptor = SootToDexUtils.getArrayTypeDescriptor((ArrayType) array.getType());
Opcode opc = getPutGetOpcodeWithTypeSuffix("aget", arrayTypeDescriptor);
return new Insn23x(opc, destinationReg, arrayReg, indexReg);
}
示例8: isInSequenceAssignment
import soot.jimple.ArrayRef; //导入方法依赖的package包/类
public boolean isInSequenceAssignment(Stmt s, Value leftOp, int index){
//DEBUG=false;
if(!(s instanceof DefinitionStmt))
return false;
DefinitionStmt ds = (DefinitionStmt)s;
Value leftValue = ds.getLeftOp();
if(! (leftValue instanceof ArrayRef))
return false;
if(DEBUG){
System.out.println("Stmt number "+index + " is an array ref assignment"+leftValue);
System.out.println("Array is"+leftOp);
}
ArrayRef leftRef = (ArrayRef)leftValue;
if(! (leftOp.equals(leftRef.getBase()))){
if(DEBUG)
System.out.println("Not assigning to same array");
return false;
}
if( ! (leftRef.getIndex() instanceof IntConstant)){
if(DEBUG)
System.out.println("Cant determine index of assignment");
return false;
}
IntConstant leftIndex = (IntConstant)leftRef.getIndex();
if(leftIndex.value != index){
if(DEBUG)
System.out.println("Out of order assignment");
return false;
}
return true;
}
示例9: caseArrayRef
import soot.jimple.ArrayRef; //导入方法依赖的package包/类
/**
* The method should update the <em>security level</em> of an array
* reference, more precisely, the level is not changed, however, it is
* checked whether the assignment is possible. In this case, the level of
* the array, the level of the index and the level of the right hand side,
* which may be affected by the program counter, will be considered. In
* addition, a <em>write effect</em> is added and also checked, because an
* assignment to an array occurs. Note, that arrays may contain only values
* with the weakest available <em>security level</em>. Occurring exceptions
* are logged.
*
* @param v
* The array reference for which the <em>security level</em>
* should be updated.
* @see soot.jimple.RefSwitch#caseArrayRef(soot.jimple.ArrayRef)
*/
@Override
public void caseArrayRef(ArrayRef v) {
ILevel rightLevel = takePCintoAccount(level);
Value array = v.getBase();
ILevel arrayLevel = calculateLevel(array, v.toString());
addWriteEffectCausedByArrayAssign(arrayLevel, v);
Value index = v.getIndex();
ILevel indexLevel = calculateLevel(index, v.toString());
if (!isEqualLevel(rightLevel, getWeakestSecurityLevel())) {
// Only weakest security level array elements
logSecurity(getMsg("security.array.restrictions",
getSignatureOfAnalyzedMethod(),
getSourceLine(),
rightLevel.getName(),
getWeakestSecurityLevel().getName()));
}
if (!isWeakerOrEqualLevel(indexLevel, arrayLevel)) {
logSecurity(getMsg("security.array.stronger_index",
getSignatureOfAnalyzedMethod(),
getSourceLine(),
arrayLevel.getName(),
indexLevel.getName()));
}
if (!isWeakerOrEqualLevel(rightLevel, arrayLevel)) {
logSecurity(getMsg("security.array.stronger_assign",
getSignatureOfAnalyzedMethod(),
getSourceLine(),
rightLevel.getName(),
arrayLevel.getName()));
}
}
示例10: isInSequenceAssignmentPatternTwo
import soot.jimple.ArrayRef; //导入方法依赖的package包/类
public boolean isInSequenceAssignmentPatternTwo(Stmt one, Stmt two, Value leftOp, int index){
if(!(two instanceof DefinitionStmt))
return false;
DefinitionStmt ds = (DefinitionStmt)two;
Value leftValue = ds.getLeftOp();
if(! (leftValue instanceof ArrayRef))
return false;
ArrayRef leftRef = (ArrayRef)leftValue;
if(! (leftOp.equals(leftRef.getBase()))){
if(DEBUG)
System.out.println("Not assigning to same array");
return false;
}
if( ! (leftRef.getIndex() instanceof IntConstant)){
if(DEBUG)
System.out.println("Cant determine index of assignment");
return false;
}
IntConstant leftIndex = (IntConstant)leftRef.getIndex();
if(leftIndex.value != index){
if(DEBUG)
System.out.println("Out of order assignment");
return false;
}
Value rightOp = ds.getRightOp();
if(!(one instanceof DShortcutAssignStmt))
return false;
DShortcutAssignStmt shortcut = (DShortcutAssignStmt)one;
Value shortcutVar = shortcut.getLeftOp();
if(!shortcutVar.equals(rightOp))
return false;
return true;
}
示例11: caseArrayRef
import soot.jimple.ArrayRef; //导入方法依赖的package包/类
/**
* Looks up the <em>security level</em> for the given array reference and
* stores the level in {@link SecurityLevelValueReadSwitch#level}. The
* resulting level is the strongest <em>security level</em> of the array
* level and the index level.
*
* @param v
* The array reference for which the <em>security level</em>
* should be looked up.
* @see soot.jimple.RefSwitch#caseArrayRef(soot.jimple.ArrayRef)
*/
@Override
public void caseArrayRef(ArrayRef v) {
Value array = v.getBase();
ILevel arrayLevel = calculateLevel(array, v.toString());
Value index = v.getIndex();
ILevel indexLevel = calculateLevel(index, v.toString());
this.level = getMaxLevel(indexLevel, arrayLevel);
}