当前位置: 首页>>代码示例>>Java>>正文


Java ReturnStmt.getOp方法代码示例

本文整理汇总了Java中soot.jimple.ReturnStmt.getOp方法的典型用法代码示例。如果您正苦于以下问题:Java ReturnStmt.getOp方法的具体用法?Java ReturnStmt.getOp怎么用?Java ReturnStmt.getOp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在soot.jimple.ReturnStmt的用法示例。


在下文中一共展示了ReturnStmt.getOp方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: caseReturnStmt

import soot.jimple.ReturnStmt; //导入方法依赖的package包/类
@Override
public void caseReturnStmt(ReturnStmt stmt) {
	//in case of return CONSTANT, we do nothing; unfortunately, this is part of FlowDroid's path
	if(stmt.getOp() instanceof Constant)
		return;
	int index = jimpleDataFlowStatements.indexOf(stmt);
	AccessPath ap = accessPathPath.get(index);
	Local local = ap.getPlainValue();
			
	SMTBinding lhs = createNewBindingForValue(local);
	addValueBindingToVariableDeclaration(local, lhs);
	
	if(!hasBindingForValue(stmt.getOp()))
		throw new RuntimeException("There has to be a tainted value");
	SMTBinding rhs = getLatestBindingForValue(stmt.getOp());
	
	SMTSimpleAssignment simpleAss = new SMTSimpleAssignment(lhs, new SMTBindingValue(rhs));
	SMTAssertStatement assertStmt = new SMTAssertStatement(simpleAss);
	addAssertStmtToAllPrograms(assertStmt);	
}
 
开发者ID:srasthofer,项目名称:FuzzDroid,代码行数:21,代码来源:JimpleStmtVisitorImpl.java

示例2: caseReturnStmt

import soot.jimple.ReturnStmt; //导入方法依赖的package包/类
public void caseReturnStmt(ReturnStmt stmt) {
	if (stmt.getOp() instanceof Local) {
		if (((Local) stmt.getOp()).getType() instanceof IntegerType) {
			if (!ClassHierarchy
					.v()
					.typeNode(((Local) stmt.getOp()).getType())
					.hasAncestor_1(
							ClassHierarchy.v().typeNode(
									stmtBody.getMethod().getReturnType()))) {
				if (fix) {
					stmt.setOp(insertCast((Local) stmt.getOp(), stmtBody
							.getMethod().getReturnType(), stmt));
				} else {
					error("Type Error(19)");
				}
			}
		}
	}
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:20,代码来源:ConstraintChecker.java

示例3: caseReturnStmt

import soot.jimple.ReturnStmt; //导入方法依赖的package包/类
@Override
public void caseReturnStmt(ReturnStmt stmt) {
	Value returnValue = stmt.getOp();
	constantV.setOrigStmt(stmt);
	Register returnReg = regAlloc.asImmediate(returnValue, constantV);
	Opcode opc;
	Type retType = returnValue.getType();
	if (SootToDexUtils.isObject(retType)) {
		opc = Opcode.RETURN_OBJECT;
	} else if (SootToDexUtils.isWide(retType)) {
		opc = Opcode.RETURN_WIDE;
	} else {
		opc = Opcode.RETURN;
	}
       addInsn(new Insn11x(opc, returnReg), stmt);
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:17,代码来源:StmtVisitor.java

示例4: propagateCallFlow

import soot.jimple.ReturnStmt; //导入方法依赖的package包/类
@Override
public KillGenInfo propagateCallFlow(Trackable trackable, Unit callStmt, SootMethod destinationMethod) {
	Taint taint = (Taint) trackable;

	if (callStmt instanceof AssignStmt) {
		AssignStmt assignStmt = (AssignStmt) callStmt;
		if (taint.value.equals(assignStmt.getLeftOp())) {
			if (AnalysisUtil.isAssignable(taint.type, destinationMethod.getReturnType())) {
				for (Unit u : context.icfg.getStartPointsOf(destinationMethod)) {
					if (u instanceof ReturnStmt) {
						ReturnStmt returnStmt = (ReturnStmt) u;
						Value retValue = returnStmt.getOp();

						if (retValue instanceof Constant)
							continue;

						// There is at least one non constant return stmt
						return propagate(new ReturnValueTaint(callStmt, trackable, taint.type));
					}
				}
			}
		}
	}

	return kill();
}
 
开发者ID:johanneslerch,项目名称:FlowTwist,代码行数:27,代码来源:DefaultTaintPropagator.java

示例5: isReturnValue

import soot.jimple.ReturnStmt; //导入方法依赖的package包/类
public boolean isReturnValue(SootMethod method, Local base) {
  Collection<Unit> endPointsOf = icfg.getEndPointsOf(method);

  for (Unit eP : endPointsOf) {
    if (eP instanceof ReturnStmt) {
      ReturnStmt returnStmt = (ReturnStmt) eP;
      Value op = returnStmt.getOp();
      if (op.equals(base))
        return true;
    }
  }
  return false;
}
 
开发者ID:themaplelab,项目名称:boomerang,代码行数:14,代码来源:BoomerangContext.java

示例6: caseReturnStmt

import soot.jimple.ReturnStmt; //导入方法依赖的package包/类
public void caseReturnStmt(ReturnStmt stmt) {
	if (uses) {
		if (stmt.getOp() instanceof Local) {
			if (((Local) stmt.getOp()).getType() instanceof IntegerType) {
				resolver.typeVariable((Local) stmt.getOp()).addParent(
						resolver.typeVariable(stmtBody.getMethod().getReturnType()));
			}
		}
	}
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:11,代码来源:ConstraintCollector.java

示例7: caseReturnStmt

import soot.jimple.ReturnStmt; //导入方法依赖的package包/类
public void caseReturnStmt(ReturnStmt stmt) {
	if (uses) {
		if (stmt.getOp() instanceof Local) {
			resolver.typeVariable((Local) stmt.getOp()).addParent(
					resolver.typeVariable(stmtBody.getMethod().getReturnType()));
		}
	}
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:9,代码来源:ConstraintCollector.java

示例8: internalTransform

import soot.jimple.ReturnStmt; //导入方法依赖的package包/类
@Override
protected void internalTransform(Body body, String phaseName,
		Map<String, String> options) {
	Iterator<Unit> it = body.getUnits().snapshotIterator();
	while (it.hasNext()) {
		Unit u = it.next();
		if (u instanceof GotoStmt) {
			GotoStmt gtStmt = (GotoStmt) u;
			if (gtStmt.getTarget() instanceof AssignStmt) {
				AssignStmt assign = (AssignStmt) gtStmt.getTarget();
				if (assign.getRightOp() instanceof CastExpr) {
					CastExpr ce = (CastExpr) assign.getRightOp();
					// We have goto that ends up at a cast statement
					Unit nextStmt = body.getUnits().getSuccOf(assign);
					if (nextStmt instanceof ReturnStmt) {
						ReturnStmt retStmt = (ReturnStmt) nextStmt;
						if (retStmt.getOp() == assign.getLeftOp()) {
							// We need to replace the GOTO with the return
							ReturnStmt newStmt = (ReturnStmt) retStmt.clone();
							newStmt.setOp(ce.getOp());

							for (Trap t : body.getTraps())
								for (UnitBox ubox : t.getUnitBoxes())
									if (ubox.getUnit() == gtStmt)
										ubox.setUnit(newStmt);
							
							while (!gtStmt.getBoxesPointingToThis().isEmpty())
								gtStmt.getBoxesPointingToThis().get(0).setUnit(newStmt);
							body.getUnits().swapWith(gtStmt, newStmt);
						}
					}
				}
			}
		}
	}
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:37,代码来源:CastAndReturnInliner.java

示例9: caseReturnStmt

import soot.jimple.ReturnStmt; //导入方法依赖的package包/类
public final void caseReturnStmt(ReturnStmt s) {
statement = s; 
Value op = s.getOp();
if( op.getType() instanceof RefType 
|| op.getType() instanceof ArrayType ) { 
    if( op instanceof Constant ) {
	caseReturnConstStmt( (Constant) op );
    } else {
	caseReturnStmt( (Local) op );
    }
} else {
    caseReturnStmt( (Local) null );
}
  }
 
开发者ID:petablox-project,项目名称:petablox,代码行数:15,代码来源:FGStmtSwitch.java

示例10: instrumentOnBindMethod

import soot.jimple.ReturnStmt; //导入方法依赖的package包/类
public void instrumentOnBindMethod(SootClass sootClass, SootField ibinder_for_ipc)
{
	SootMethod onBindMethod = null;
	try
	{
		onBindMethod = sootClass.getMethodByName("onBind");
	}
	catch (RuntimeException ex)
	{
	}
	
	
	if (null == onBindMethod)
	{
		return;
	}
	
	Body body = onBindMethod.retrieveActiveBody();
	PatchingChain<Unit> units = body.getUnits();
	for (Iterator<Unit> iter = units.snapshotIterator(); iter.hasNext(); )
	{
		Stmt stmt = (Stmt) iter.next();
		
		if (stmt instanceof ReturnStmt)
		{
			ReturnStmt rtStmt = (ReturnStmt) stmt;
			Value rtValue = rtStmt.getOp();
			
			Unit setIBinderU = Jimple.v().newAssignStmt(
					Jimple.v().newStaticFieldRef(ibinder_for_ipc.makeRef()), 
					rtValue);
			
			units.insertBefore(setIBinderU, rtStmt);
		}
		
	}
	
	
}
 
开发者ID:lilicoding,项目名称:soot-infoflow-android-iccta,代码行数:40,代码来源:ICCInstrumentDestination.java

示例11: getReturnFlowFunction

import soot.jimple.ReturnStmt; //导入方法依赖的package包/类
@Override
public FlowFunction<AccessGraph> getReturnFlowFunction(IPathEdge<Unit, AccessGraph> edge,
    final Unit callStmt, final SootMethod callee, final Unit returnSite) {
  final Local[] paramLocals = new Local[callee.getParameterCount()];
  for (int i = 0; i < callee.getParameterCount(); i++)
    paramLocals[i] = callee.getActiveBody().getParameterLocal(i);
  final Unit exitStmt = edge.getTarget();
  final Local thisLocal = callee.isStatic() ? null : callee.getActiveBody().getThisLocal();
  return new FlowFunction<AccessGraph>() {
    @Override
    public Set<AccessGraph> computeTargets(AccessGraph source) {
      HashSet<AccessGraph> out = new HashSet<AccessGraph>();

      // mapping of fields of AccessPath those will be killed in
      // callToReturn
      if (context.trackStaticFields() && source.isStatic())
        return Collections.singleton(source);

      if (callStmt instanceof Stmt) {
        Stmt is = (Stmt) callStmt;

        if (is.containsInvokeExpr()) {
          InvokeExpr ie = is.getInvokeExpr();
          for (int i = 0; i < paramLocals.length; i++) {

            if (paramLocals[i] == source.getBase()) {
              Value arg = ie.getArg(i);
              if (arg instanceof Local) {
                if (typeCompatible(((Local) arg).getType(), source.getBaseType())) {
                  AccessGraph deriveWithNewLocal =
                      source.deriveWithNewLocal((Local) arg, source.getBaseType());
                  out.add(deriveWithNewLocal);
                }
              }

            }
          }
          if (!callee.isStatic() && ie instanceof InstanceInvokeExpr) {
            if (source.baseMatches(thisLocal)) {

              InstanceInvokeExpr iIExpr = (InstanceInvokeExpr) is.getInvokeExpr();
              Local newBase = (Local) iIExpr.getBase();
              if (typeCompatible(newBase.getType(), source.getBaseType())) {
                AccessGraph possibleAccessPath =
                    source.deriveWithNewLocal((Local) iIExpr.getBase(), source.getBaseType());
                out.add(possibleAccessPath);
              }
            }
          }
        }
      }

      if (callStmt instanceof AssignStmt && exitStmt instanceof ReturnStmt) {
        AssignStmt as = (AssignStmt) callStmt;
        Value leftOp = as.getLeftOp();
        // mapping of return value


        ReturnStmt returnStmt = (ReturnStmt) exitStmt;
        Value returns = returnStmt.getOp();
        // d = return out;
        if (leftOp instanceof Local) {
          if (returns instanceof Local && source.getBase() == returns) {
            out.add(source.deriveWithNewLocal((Local) leftOp, source.getBaseType()));
          }
        }
      }
      return out;
    }

  };
}
 
开发者ID:themaplelab,项目名称:boomerang,代码行数:73,代码来源:ForwardFlowFunctions.java

示例12: internalTransform

import soot.jimple.ReturnStmt; //导入方法依赖的package包/类
@Override
protected void internalTransform(Body body, String phaseName, Map<String, String> options) {
       ExceptionalUnitGraph graph = new ExceptionalUnitGraph(body, DalvikThrowAnalysis.v(), true);
       LocalDefs localDefs = LocalDefs.Factory.newLocalDefs(graph);
       LocalUses localUses = null;
       LocalCreation localCreation = null;
       
	// If a return statement's operand has only one definition and this is
	// a copy statement, we take the original operand
	for (Unit u : body.getUnits())
		if (u instanceof ReturnStmt) {
			ReturnStmt retStmt = (ReturnStmt) u;
			if (retStmt.getOp() instanceof Local) {
				List<Unit> defs = localDefs.getDefsOfAt((Local) retStmt.getOp(), retStmt);
				if (defs.size() == 1 && defs.get(0) instanceof AssignStmt) {
					AssignStmt assign = (AssignStmt) defs.get(0);
					final Value rightOp = assign.getRightOp();
					final Value leftOp = assign.getLeftOp();
					
					// Copy over the left side if it is a local
					if (rightOp instanceof Local) {
						// We must make sure that the definition we propagate to
						// the return statement is not overwritten in between
						// a = 1; b = a; a = 3; return b; may not be translated
						// to return a;
						if (!isRedefined((Local) rightOp, u, assign, graph))
							retStmt.setOp(rightOp);
					}
					else if (rightOp instanceof Constant) {
						retStmt.setOp(rightOp);
					}
					// If this is a field access which has no other uses,
					// we rename the local to help splitting
					else if (rightOp instanceof FieldRef) {
						if (localUses == null)
							localUses = LocalUses.Factory.newLocalUses(body, localDefs);
						if (localUses.getUsesOf(assign).size() == 1) {
							if (localCreation == null)
								localCreation = new LocalCreation(body.getLocals(), "ret");
							Local newLocal = localCreation.newLocal(leftOp.getType());
							assign.setLeftOp(newLocal);
							retStmt.setOp(newLocal);
						}
					}
				}
			}
		}
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:49,代码来源:DexReturnValuePropagator.java

示例13: handleInvokeExpression

import soot.jimple.ReturnStmt; //导入方法依赖的package包/类
/**
 * Returns the variable values that are associated with an call statement.
 * 
 * @param sourceStmt The statement at which we should start.
 * @param visitedStmts The set of visited statements.
 * @return The set of possible values.
 */
protected Set<Object> handleInvokeExpression(Stmt sourceStmt, Set<Stmt> visitedStmts) {
  if (visitedStmts.contains(sourceStmt)) {
    return Collections.emptySet();
  } else {
    visitedStmts.add(sourceStmt);
  }
  Iterator<Edge> edges = Scene.v().getCallGraph().edgesOutOf(sourceStmt);
  Set<Object> result = new HashSet<>();

  while (edges.hasNext()) {
    Edge edge = edges.next();
    SootMethod target = edge.getTgt().method();
    if (target.isConcrete()) {
      for (Unit unit : target.getActiveBody().getUnits()) {
        if (unit instanceof ReturnStmt) {
          ReturnStmt returnStmt = (ReturnStmt) unit;

          Value returnValue = returnStmt.getOp();
          if (returnValue instanceof StringConstant) {
            result.add(((StringConstant) returnValue).value);
          } else if (returnValue instanceof ClassConstant) {
            result.add(((ClassConstant) returnValue).value);
          } else if (returnValue instanceof Local) {
            List<DefinitionStmt> assignStmts =
                findAssignmentsForLocal(returnStmt, (Local) returnValue, true,
                    new HashSet<Pair<Unit, Local>>());
            Set<Object> classConstants = processClassAssignments(assignStmts, visitedStmts);
            if (classConstants == null || classConstants.contains(TOP_VALUE)
                || classConstants.contains(Constants.ANY_STRING)) {
              return null;
            } else {
              result.addAll(classConstants);
            }
          } else {
            return null;
          }
        }
      }
    }
  }

  return result;
}
 
开发者ID:serval-snt-uni-lu,项目名称:DroidRA,代码行数:51,代码来源:ClassValueAnalysis.java

示例14: extractBinderType

import soot.jimple.ReturnStmt; //导入方法依赖的package包/类
/**
 * To extract the real binder type,
 * Thus, a more precision way is to perform a type analysis for IBinder reference
 * 
 * @return
 */
public Type extractBinderType(SootClass sootClass)
{
	SootMethod onBindMethod = null;
	try
	{
		onBindMethod = sootClass.getMethodByName("onBind");
	}
	catch (RuntimeException ex)
	{
	}
	
	
	if (null == onBindMethod)
	{
		return null;
	}
	
	
	Body body = onBindMethod.retrieveActiveBody();
	PatchingChain<Unit> units = body.getUnits();
	for (Iterator<Unit> iter = units.snapshotIterator(); iter.hasNext(); )
	{
		Stmt stmt = (Stmt) iter.next();
		
		if (stmt instanceof ReturnStmt)
		{
			ReturnStmt rtStmt = (ReturnStmt) stmt;
			Value rtValue = rtStmt.getOp();
			
			if (rtValue.toString().equals("null"))
			{
				return onBindMethod.getReturnType();
			}
			
			return rtValue.getType();
		}
		
	}
	
	return onBindMethod.getReturnType();
}
 
开发者ID:lilicoding,项目名称:soot-infoflow-android-iccta,代码行数:48,代码来源:ICCInstrumentDestination.java

示例15: caseReturnStmt

import soot.jimple.ReturnStmt; //导入方法依赖的package包/类
/**
 * Method, which should process the given statement of type
 * {@link ReturnStmt}. Therefore the method looks up which
 * <em>security level</em> the returned value has and checks also whether
 * this level is weaker than the program counter level. If the program
 * counter <em>security level</em> is stronger, then this level will be
 * compared with the expected return <em>security level</em>, otherwise the
 * level of the returned value will be compared. In both cases the expected
 * return <em>security level</em> has to be stronger or equals, if not then
 * an error will be logged.
 * 
 * @param stmt
 *            Statement that should be processed to check for security
 *            violations.
 * @see soot.jimple.StmtSwitch#caseReturnStmt(soot.jimple.ReturnStmt)
 */
@Override
public void caseReturnStmt(ReturnStmt stmt) {
    ILevel expectedLevel = getAnalyzedEnvironment().getReturnLevel();
    Value value = stmt.getOp();
    ILevel level =
        takePCintoAccount(calculateLevel(value, stmt.toString()));
    if (!isWeakerOrEqualLevel(level, expectedLevel)) {
        logSecurity(getMsg("security.return.stronger",
                           getSignatureOfAnalyzedMethod(),
                           level.getName(),
                           getSourceLine(),
                           expectedLevel.getName()));
    }
}
 
开发者ID:proglang,项目名称:jgs,代码行数:31,代码来源:SecurityLevelStmtSwitch.java


注:本文中的soot.jimple.ReturnStmt.getOp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。