本文整理汇总了Java中soot.jimple.DefinitionStmt.getRightOp方法的典型用法代码示例。如果您正苦于以下问题:Java DefinitionStmt.getRightOp方法的具体用法?Java DefinitionStmt.getRightOp怎么用?Java DefinitionStmt.getRightOp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类soot.jimple.DefinitionStmt
的用法示例。
在下文中一共展示了DefinitionStmt.getRightOp方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleAssign
import soot.jimple.DefinitionStmt; //导入方法依赖的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");
}
}
示例2: handleRefTypeAssignment
import soot.jimple.DefinitionStmt; //导入方法依赖的package包/类
private void handleRefTypeAssignment(DefinitionStmt assignStmt,
AnalysisInfo rhsInfo, AnalysisInfo out) {
Value left = assignStmt.getLeftOp();
Value right = assignStmt.getRightOp();
//unbox casted value
if(right instanceof JCastExpr) {
JCastExpr castExpr = (JCastExpr) right;
right = castExpr.getOp();
}
// An assignment invalidates any assumptions of null/non-null for lhs
// We COULD be more accurate by assigning those assumptions to the rhs prior to this statement
rhsInfo.put(right,BOTTOM);
//assign from rhs to lhs
out.put(left,rhsInfo.get(right));
}
示例3: flowThrough
import soot.jimple.DefinitionStmt; //导入方法依赖的package包/类
protected void flowThrough(HashMap<Local,Set<NewExpr>> in, Unit unit,
HashMap<Local,Set<NewExpr>> out)
{
Stmt s = (Stmt) unit;
out.clear();
out.putAll(in);
if (s instanceof DefinitionStmt) {
DefinitionStmt ds = (DefinitionStmt) s;
Value lhs = ds.getLeftOp();
Value rhs = ds.getRightOp();
if (lhs instanceof Local) {
HashSet<NewExpr> lv = new HashSet<NewExpr>();
out.put((Local) lhs, lv);
if (rhs instanceof NewExpr) {
lv.add((NewExpr) rhs);
} else if (rhs instanceof Local) {
lv.addAll(in.get(rhs));
} else lv.add(UNKNOWN);
}
}
}
示例4: getIntConstantsFromLocal
import soot.jimple.DefinitionStmt; //导入方法依赖的package包/类
void getIntConstantsFromLocal(SimpleLocalDefs sld, Local l, Unit u, List<String> whats) throws IOException {
Iterator<Unit> iter = sld.getDefsOfAt(l, u).iterator();
while (iter.hasNext()) {
Unit def = iter.next();
if (! (def instanceof DefinitionStmt)) continue;
DefinitionStmt assign = (DefinitionStmt) def;
Value rightOp = assign.getRightOp();
if (rightOp instanceof IntConstant) {
whats.add(rightOp.toString());
} else if (rightOp instanceof ParameterRef){
whats.add(rightOp.toString());
} else if (rightOp instanceof Local) {
getIntConstantsFromLocal(sld, (Local)rightOp, def, whats);
print("getIntConstantsFromLocal -> local");
} else {
print("???"+def.toString());
}
}
}
示例5: applySanitizer
import soot.jimple.DefinitionStmt; //导入方法依赖的package包/类
/***** API calls *****/
// Sanitizer for user study. Kill the parameter and its aliases
private boolean applySanitizer(Unit call, FlowAbstraction source) {
// Call itself
Stmt stmt = (Stmt) call;
final String target = stmt.getInvokeExpr().getMethod().getSignature();
final List<Value> args = stmt.getInvokeExpr().getArgs();
if (!target.equals("<sanitizers.Sanitizer: void sanitize(java.lang.Object)>"))
return false;
if (killforSanit(call, args.get(0), source))
return true;
// Case of valueOf for primitive types
// a = Integer.valueOf(b); and sanit(a) -> must also treat aliases of b
List<Unit> predecessors = icfg.getPredsOf(call);
for (Unit predecessor : predecessors) {
if (predecessor instanceof DefinitionStmt) {
DefinitionStmt def = (DefinitionStmt) predecessor;
if (def.getLeftOp().equals(args.get(0)) && def.getRightOp() instanceof StaticInvokeExpr) {
InvokeExpr expr = (StaticInvokeExpr) def.getRightOp();
final SootMethod method = expr.getMethod();
if (method.getName().equals("valueOf") && expr.getArgCount() == 1
&& method.getDeclaringClass().getType().equals(method.getReturnType())
&& isPrimitiveType(method.getReturnType())) {
if (killforSanit(predecessor, expr.getArg(0), source))
return true;
}
}
}
}
return false;
}
示例6: methodIsAndroidStub
import soot.jimple.DefinitionStmt; //导入方法依赖的package包/类
/**
* Checks whether the given method is a library stub method
* @param method The method to check
* @return True if the given method is an Android library stub, false
* otherwise
*/
private boolean methodIsAndroidStub(SootMethod method) {
if (!(Options.v().src_prec() == Options.src_prec_apk
&& method.getDeclaringClass().isLibraryClass()
&& SystemClassHandler.isClassInSystemPackage(
method.getDeclaringClass().getName())))
return false;
// Check whether there is only a single throw statement
for (Unit u : method.getActiveBody().getUnits()) {
if (u instanceof DefinitionStmt) {
DefinitionStmt defStmt = (DefinitionStmt) u;
if (!(defStmt.getRightOp() instanceof ThisRef)
&& !(defStmt.getRightOp() instanceof ParameterRef)
&& !(defStmt.getRightOp() instanceof NewExpr))
return false;
}
else if (u instanceof InvokeStmt) {
InvokeStmt stmt = (InvokeStmt) u;
// Check for exception constructor invocations
SootMethod callee = stmt.getInvokeExpr().getMethod();
if (!callee.getSubSignature().equals("void <init>(java.lang.String)"))
// Check for super class constructor invocation
if (!(method.getDeclaringClass().hasSuperclass()
&& callee.getDeclaringClass() == method.getDeclaringClass().getSuperclass()
&& callee.getName().equals("<init>")))
return false;
}
else if (!(u instanceof ThrowStmt))
return false;
}
return true;
}
示例7: handleRefTypeAssignment
import soot.jimple.DefinitionStmt; //导入方法依赖的package包/类
private void handleRefTypeAssignment(DefinitionStmt assignStmt, AnalysisInfo out) {
Value left = assignStmt.getLeftOp();
Value right = assignStmt.getRightOp();
//unbox casted value
if(right instanceof JCastExpr) {
JCastExpr castExpr = (JCastExpr) right;
right = castExpr.getOp();
}
//if we have a definition (assignment) statement to a ref-like type, handle it,
if ( isAlwaysNonNull(right)
|| right instanceof NewExpr || right instanceof NewArrayExpr
|| right instanceof NewMultiArrayExpr || right instanceof ThisRef
|| right instanceof StringConstant || right instanceof ClassConstant
|| right instanceof CaughtExceptionRef) {
//if we assign new... or @this, the result is non-null
out.put(left,NON_NULL);
} else if(right==NullConstant.v()) {
//if we assign null, well, it's null
out.put(left, NULL);
} else if(left instanceof Local && right instanceof Local) {
out.put(left, out.get(right));
} else {
out.put(left, TOP);
}
}
示例8: isAlwaysNullBefore
import soot.jimple.DefinitionStmt; //导入方法依赖的package包/类
/**
* Checks whether the given local is guaranteed to be always null at the
* given statement
* @param s The statement at which to check the local
* @param base The local to check
* @param defs The definition analysis object to use for the check
* @return True if the given local is guaranteed to always be null at the
* given statement, otherwise false
*/
private boolean isAlwaysNullBefore(Stmt s, Local base, LocalDefs defs) {
List<Unit> baseDefs = defs.getDefsOfAt(base, s);
if (baseDefs.isEmpty())
return true;
for (Unit u : baseDefs) {
if (!(u instanceof DefinitionStmt))
return false;
DefinitionStmt defStmt = (DefinitionStmt) u;
if (defStmt.getRightOp() != NullConstant.v())
return false;
}
return true;
}
示例9: findIntAssignmentsForLocal
import soot.jimple.DefinitionStmt; //导入方法依赖的package包/类
/**
* Return all possible values for an integer local variable.
*
* @param start The statement where the analysis should start.
* @param local The local variable whose values we are looking for.
* @param visitedStmts The set of visited statement.
* @return The set of possible values for the local variable.
*/
private Set<Object> findIntAssignmentsForLocal(Stmt start, Local local, Set<Stmt> visitedStmts) {
List<DefinitionStmt> assignStmts =
findAssignmentsForLocal(start, local, true, new HashSet<Pair<Unit, Local>>());
Set<Object> result = new HashSet<>(assignStmts.size());
for (DefinitionStmt assignStmt : assignStmts) {
Value rhsValue = assignStmt.getRightOp();
if (rhsValue instanceof IntConstant) {
result.add(((IntConstant) rhsValue).value);
} else if (rhsValue instanceof LongConstant) {
result.add(((LongConstant) rhsValue).value);
} else if (rhsValue instanceof ParameterRef) {
ParameterRef parameterRef = (ParameterRef) rhsValue;
Iterator<Edge> edges =
Scene.v().getCallGraph()
.edgesInto(AnalysisParameters.v().getIcfg().getMethodOf(assignStmt));
while (edges.hasNext()) {
Edge edge = edges.next();
InvokeExpr invokeExpr = edge.srcStmt().getInvokeExpr();
Value argValue = invokeExpr.getArg(parameterRef.getIndex());
if (argValue instanceof IntConstant) {
result.add(((IntConstant) argValue).value);
} else if (argValue instanceof LongConstant) {
result.add(((LongConstant) argValue).value);
} else if (argValue instanceof Local) {
Set<Object> newResults =
findIntAssignmentsForLocal(edge.srcStmt(), (Local) argValue, visitedStmts);
result.addAll(newResults);
} else {
result.add(TOP_VALUE);
}
}
} else {
return Collections.singleton((Object) TOP_VALUE);
}
}
return result;
}
示例10: getStringConstantsFromLocal
import soot.jimple.DefinitionStmt; //导入方法依赖的package包/类
void getStringConstantsFromLocal(SimpleLocalDefs sld, Local l, Unit u, HashMap<String,String> perms) throws IOException {
Iterator<Unit> iter = sld.getDefsOfAt(l, u).iterator();
while (iter.hasNext()) {
Unit def = iter.next();
if (! (def instanceof DefinitionStmt)) continue;
DefinitionStmt assign = (DefinitionStmt) def;
Value rightOp = assign.getRightOp();
if (rightOp instanceof StringConstant) {
int i=0;
boolean found = false;
while(i<numPerm && !found) {
if (rightOp.toString().equals("\""+permissions[i]+"\"")) {
found = true;
if (u instanceof DefinitionStmt && !isKnownCheck(u.toString())) {
perms.put(permissions[i], "NOTDIRECTUSE");
} else {
perms.put(permissions[i], "");
}
}
i++;
}
} else if (rightOp instanceof Local) {
getStringConstantsFromLocal(sld, (Local)rightOp, def, perms);
} else {
//irrelevant types
}
}
}
示例11: propagateNormalFlow
import soot.jimple.DefinitionStmt; //导入方法依赖的package包/类
@Override
public KillGenInfo propagateNormalFlow(Trackable trackable, Unit curr, Unit succ) {
if (!(curr instanceof DefinitionStmt))
return identity();
Taint taint = (Taint) trackable;
DefinitionStmt defStmt = (DefinitionStmt) curr;
// extract "base" locals of array refs
Value leftBase = AnalysisUtil.getBackwardsBase(defStmt.getLeftOp());
Value rightBase = AnalysisUtil.getBackwardsBase(defStmt.getRightOp());
if (!AnalysisUtil.maybeSameLocation(taint.value, leftBase))
return identity();
if (leftBase.equals(rightBase)) // x = x; or x[i] = x[j]; -> do nothing
return identity();
if (defStmt.getLeftOp() instanceof Local) { // Local
if (defStmt.getRightOp() instanceof Constant || !AnalysisUtil.isAssignable(taint.type, rightBase.getType()))
return kill();
return propagate(taint.createAlias(rightBase, curr));
} else { // Field
if (defStmt.getRightOp() instanceof Constant || !AnalysisUtil.isAssignable(taint.type, rightBase.getType()))
return identity();
// if the stmt defines a local then we know that this value we
// definitely overwritten;
// if it does not define a local (but, say, a FieldRef) then the
// value *may* have been
// overwritten; hence we need to track the source, too
return gen(taint.createAlias(rightBase, curr));
}
}
示例12: processStatement
import soot.jimple.DefinitionStmt; //导入方法依赖的package包/类
@Override
public DavaFlowSet processStatement(Stmt s, DavaFlowSet input) {
if (!(input instanceof CPFlowSet))
throw new RuntimeException("processStatement is not implemented for other flowSet types");
CPFlowSet inSet = (CPFlowSet) input;
if (inSet == NOPATH)
return inSet;
if (!(s instanceof DefinitionStmt))
return inSet;
DefinitionStmt defStmt = (DefinitionStmt) s;
// x = expr;
// confirm that the left side is a local with a primitive type
Value left = defStmt.getLeftOp();
if (!(left instanceof Local && ((Local) left).getType() instanceof PrimType))
return inSet;
// left is a primitive primitive local
CPFlowSet toReturn = (CPFlowSet) cloneFlowSet(inSet);
/*
* KILL ANY PREVIOUS VALUE OF this local as this is an assignment
* Remember the returned value can be null if the element was not found
* or it was TOP
*/
Object killedValue = killButGetValueForUse((Local) left, toReturn);
Value right = defStmt.getRightOp();
Object value = CPHelper.isAConstantValue(right);
if (value != null) {
// EXPR IS A CONSTANT
if (left.getType() instanceof BooleanType) {
Integer tempValue = (Integer) value;
if (tempValue.intValue() == 0)
value = new Boolean(false);
else
value = new Boolean(true);
}
addOrUpdate(toReturn, (Local) left, value);
} else {
// EXPR IS NOT A CONSTANT
handleMathematical(toReturn, (Local) left, right, killedValue);
}
return toReturn;
}
示例13: isInSequenceAssignmentPatternTwo
import soot.jimple.DefinitionStmt; //导入方法依赖的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;
}