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


Java BasicBlockInContext.getDelegate方法代码示例

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


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

示例1: collectInitialSeeds

import com.ibm.wala.ipa.cfg.BasicBlockInContext; //导入方法依赖的package包/类
/**
 * collect the putstatic instructions in the call graph as {@link PathEdge} seeds for the analysis
 */
private Collection<PathEdge<BasicBlockInContext<IExplodedBasicBlock>>> collectInitialSeeds() {
  Collection<PathEdge<BasicBlockInContext<IExplodedBasicBlock>>> result = HashSetFactory.make();
  for (BasicBlockInContext<IExplodedBasicBlock> bb : supergraph) {
    IExplodedBasicBlock ebb = bb.getDelegate();
    SSAInstruction instruction = ebb.getInstruction();
    if (instruction instanceof SSAPutInstruction) {
      SSAPutInstruction putInstr = (SSAPutInstruction) instruction;
      if (putInstr.isStatic()) {
        final CGNode cgNode = bb.getNode();
        Pair<CGNode, Integer> fact = Pair.make(cgNode, ebb.getFirstInstructionIndex());
        int factNum = domain.add(fact);
        BasicBlockInContext<IExplodedBasicBlock> fakeEntry = getFakeEntry(cgNode);
        // note that the fact number used for the source of this path edge doesn't really matter
        result.add(PathEdge.createPathEdge(fakeEntry, factNum, bb, factNum));

      }
    }
  }
  return result;
}
 
开发者ID:wala,项目名称:WALA-start,代码行数:24,代码来源:ContextSensitiveReachingDefs.java

示例2: relevantPathSearch

import com.ibm.wala.ipa.cfg.BasicBlockInContext; //导入方法依赖的package包/类
/**
 * Adds every nodes ID to iDs, iff it is on a path between the entry and exit point. Uses recursive DFS
 * @param iDs
 * @param sg
 * @param sgNodes
 * @param sgNodesReverse
 * @param currentId
 * @param endId
 */
private static void relevantPathSearch(
    HashSet<Integer> iDs,
    ICFGSupergraph sg,
    HashMap<Integer, BasicBlockInContext<IExplodedBasicBlock>> sgNodes,
    HashMap<BasicBlockInContext<IExplodedBasicBlock>, Integer> sgNodesReverse,
    ArrayList<MethodReference> acceptedMethods,
    int currentId,
    int endId) {
    if(iDs.contains(currentId)) {
        return;
    }
    iDs.add(currentId);
    if(currentId == endId) {
        return;
    }
    BasicBlockInContext<IExplodedBasicBlock> bbic = sgNodes.get(currentId);
    boolean isInvoke = bbic.getLastInstruction() instanceof SSAInvokeInstruction;
    boolean isStringConcat = isInvoke && bbic.getLastInstruction().toString().contains("StringBuilder") && (bbic.getLastInstruction().toString().contains("append") | bbic.getLastInstruction().toString().contains("toString"));

    Iterator<BasicBlockInContext<IExplodedBasicBlock>> sucIt = sg.getSuccNodes(bbic);
    while(sucIt.hasNext()) {
        BasicBlockInContext<IExplodedBasicBlock> nextChild = sucIt.next();

        if(isStringConcat) {
            if(!sucIt.hasNext()) { // last association of a String concatenation is java intern
                continue;
            }
        }

        MethodReference method = nextChild.getMethod().getReference();
        if(isInvoke) {
            if(!acceptedMethods.contains(method)) {
                acceptedMethods.add(method);
            }
        } else {
            if(!acceptedMethods.contains(method)) {
                log.debug("supergraph cut at '" + bbic.getNumber() + " -> " + nextChild.getNumber() + " ("
                          + nextChild.toString() + ")'");
                continue;
            }
        }

        IExplodedBasicBlock del = nextChild.getDelegate();
        if(del.isEntryBlock() && del.toString().contains("init")) {
            log.debug("supergraph cut at '" + bbic.getNumber() + " -> " + nextChild.getNumber() + " (" + nextChild.toString() + ")'");
            continue;
        }
        relevantPathSearch(iDs, sg, sgNodes, sgNodesReverse, acceptedMethods, sgNodesReverse.get(nextChild), endId);
    }
}
 
开发者ID:logicalhacking,项目名称:DASCA,代码行数:60,代码来源:SuperGraphUtil.java


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