本文整理汇总了Java中soot.jimple.DefinitionStmt.getLeftOp方法的典型用法代码示例。如果您正苦于以下问题:Java DefinitionStmt.getLeftOp方法的具体用法?Java DefinitionStmt.getLeftOp怎么用?Java DefinitionStmt.getLeftOp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类soot.jimple.DefinitionStmt
的用法示例。
在下文中一共展示了DefinitionStmt.getLeftOp方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: propagateCallToReturnFlow
import soot.jimple.DefinitionStmt; //导入方法依赖的package包/类
@Override
public KillGenInfo propagateCallToReturnFlow(Trackable trackable, Stmt callSite) {
if (!(callSite instanceof DefinitionStmt))
return identity();
Taint taint = (Taint) trackable;
DefinitionStmt defStmt = (DefinitionStmt) callSite;
if (!defStmt.getLeftOp().equals(taint.value))
return identity();
if (defStmt.getLeftOp() instanceof Local) {
return kill();
} else {
// 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 identity();
}
}
示例5: 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);
}
}
示例6: isRedefined
import soot.jimple.DefinitionStmt; //导入方法依赖的package包/类
/**
* Checks whether the given local has been redefined between the original
* definition unitDef and the use unitUse.
* @param l The local for which to check for redefinitions
* @param unitUse The unit that uses the local
* @param unitDef The unit that defines the local
* @param graph The unit graph to use for the check
* @return True if there is at least one path between unitDef and unitUse on
* which local l gets redefined, otherwise false
*/
private boolean isRedefined(Local l, Unit unitUse, AssignStmt unitDef,
UnitGraph graph) {
List<Unit> workList = new ArrayList<Unit>();
workList.add(unitUse);
Set<Unit> doneSet = new HashSet<Unit>();
// Check for redefinitions of the local between definition and use
while (!workList.isEmpty()) {
Unit curStmt = workList.remove(0);
if (!doneSet.add(curStmt))
continue;
for (Unit u : graph.getPredsOf(curStmt)) {
if (u != unitDef) {
if (u instanceof DefinitionStmt) {
DefinitionStmt defStmt = (DefinitionStmt) u;
if (defStmt.getLeftOp() == l)
return true;
}
workList.add(u);
}
}
}
return false;
}
示例7: inDefinitionStmt
import soot.jimple.DefinitionStmt; //导入方法依赖的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;
}
}
}
示例8: isInSequenceAssignment
import soot.jimple.DefinitionStmt; //导入方法依赖的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: 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));
}
}
示例10: propagateNormalFlow
import soot.jimple.DefinitionStmt; //导入方法依赖的package包/类
@Override
public KillGenInfo propagateNormalFlow(Trackable trackable, Unit curr, Unit succ) {
Taint taint = (Taint) trackable;
if (curr instanceof DefinitionStmt) {
DefinitionStmt defStmt = (DefinitionStmt) curr;
Value rightBase = AnalysisUtil.getForwardsBase(defStmt.getRightOp());
Value leftBase = AnalysisUtil.getForwardsBase(defStmt.getLeftOp());
if (leftBase.equals(rightBase)) // x = x; or x[i] = x[j]; -> do
// nothing
return identity();
// kill the LHS if it is assigned another value
Value left = defStmt.getLeftOp();
if (left instanceof Local && taint.value.equals(left)) {
return kill();
}
if (rightBase instanceof CastExpr) {
CastExpr castExpr = (CastExpr) rightBase;
if (AnalysisUtil.maybeSameLocation(taint.value, castExpr.getOp())) {
if (AnalysisUtil.isAssignable(taint.type, leftBase.getType())) {
return gen(taint.createAlias(leftBase, curr));
} else {
return identity();
}
}
}
// at assignments, propagate taint from right to left
if (taint.value.equivTo(rightBase) || AnalysisUtil.maybeSameLocation(taint.value, rightBase)) {
return gen(taint.createAlias(leftBase, curr));
}
}
return identity();
}
示例11: 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;
}
示例12: 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;
}