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


Java Stmt.getFieldRef方法代码示例

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


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

示例1: flowThrough

import soot.jimple.Stmt; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected void flowThrough(AnalysisInfo in, Unit u, List<AnalysisInfo> fallOut, List<AnalysisInfo> branchOuts) {
	AnalysisInfo out = new AnalysisInfo(in);
	AnalysisInfo outBranch = new AnalysisInfo(in);
	
	Stmt s = (Stmt)u;
	
	//in case of an if statement, we neet to compute the branch-flow;
	//e.g. for a statement "if(x!=null) goto s" we have x==null for the fallOut and
	//x!=null for the branchOut
	//or for an instanceof expression
	if(s instanceof JIfStmt) {
		JIfStmt ifStmt = (JIfStmt) s;
		handleIfStmt(ifStmt, in, out, outBranch);
	}
	//in case of a monitor statement, we know that if it succeeds, we have a non-null value
	else if(s instanceof MonitorStmt) {
		MonitorStmt monitorStmt = (MonitorStmt) s;
		out.put(monitorStmt.getOp(), NON_NULL);
	}
	
	// if we have an array ref, set the base to non-null
	if(s.containsArrayRef()) {
		ArrayRef arrayRef = s.getArrayRef();
		handleArrayRef(arrayRef,out);
	}
	// for field refs, set the receiver object to non-null, if there is one
	if(s.containsFieldRef()) {
		FieldRef fieldRef = s.getFieldRef();
		handleFieldRef(fieldRef, out);
	}
	// for invoke expr, set the receiver object to non-null, if there is one
	if(s.containsInvokeExpr()) {
		InvokeExpr invokeExpr = s.getInvokeExpr();
		handleInvokeExpr(invokeExpr, out);
	}
	
	//if we have a definition (assignment) statement to a ref-like type, handle it,
	//i.e. assign it TOP, except in the following special cases:
	// x=null,               assign NULL
	// [email protected] or x= new...  assign NON_NULL
	// x=y,                  copy the info for y (for locals x,y)
	if(s instanceof DefinitionStmt) {
		DefinitionStmt defStmt = (DefinitionStmt) s;
		if(defStmt.getLeftOp().getType() instanceof RefLikeType) {
			handleRefTypeAssignment(defStmt, out);
		}
	}
	
	// now copy the computed info to all successors
	for( Iterator<AnalysisInfo> it = fallOut.iterator(); it.hasNext(); ) {
		copy( out, it.next() );
	}
	for( Iterator<AnalysisInfo> it = branchOuts.iterator(); it.hasNext(); ) {
		copy( outBranch, it.next() );
	}
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:61,代码来源:NullnessAnalysis.java

示例2: internalTransform

import soot.jimple.Stmt; //导入方法依赖的package包/类
protected void internalTransform(final Body body, String phaseName, @SuppressWarnings("rawtypes") Map options) {
//final ExceptionalUnitGraph g = new ExceptionalUnitGraph(body);
//final SmartLocalDefs localDefs = new SmartLocalDefs(g, new SimpleLiveLocals(g));
//final SimpleLocalUses localUses = new SimpleLocalUses(g, localDefs);


      for (Unit u: getRefCandidates(body)) {
        Stmt s = (Stmt)u;
        boolean hasField = false;
        FieldRef fr = null;
        SootField sf = null;
        if (s.containsFieldRef()) {
          fr = s.getFieldRef();
          sf = fr.getField();
          if (sf != null) {             
            hasField = true;
          }
        } else {
          throw new RuntimeException("Unit '"+ u +"' does not contain array ref nor field ref.");
        }
        
        if (!hasField) {
          Debug.printDbg("field ", fr ," '", fr ,"' has not been found!");
          System.out.println("Warning: add missing field '"+ fr +"' to class!");
          SootClass sc = null;
          String frStr = fr.toString();
          if (frStr.contains(".<")) {
           sc = Scene.v().getSootClass(frStr.split(".<")[1].split(" ")[0].split(":")[0]);
          } else {
           sc = Scene.v().getSootClass(frStr.split(":")[0].replaceAll("^<", ""));
          }
          String fname = fr.toString().split(">")[0].split(" ")[2];
          int modifiers = soot.Modifier.PUBLIC;
          Type ftype = fr.getType();
          Debug.printDbg("missing field: to class '", sc ,"' field name '", fname ,"' field modifiers '", modifiers ,"' field type '", ftype ,"'");
          sc.addField(new SootField(fname, ftype, modifiers));
        } else {
          //System.out.println("field "+ sf.getName() +" '"+ sf +"' phantom: "+ isPhantom +" declared: "+ isDeclared);
        }
        
      } // for if statements
  }
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:43,代码来源:DexRefsChecker.java


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