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


Java DirectedGraph类代码示例

本文整理汇总了Java中soot.toolkits.graph.DirectedGraph的典型用法代码示例。如果您正苦于以下问题:Java DirectedGraph类的具体用法?Java DirectedGraph怎么用?Java DirectedGraph使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: SimpleVeryBusyAnalysis

import soot.toolkits.graph.DirectedGraph; //导入依赖的package包/类
public SimpleVeryBusyAnalysis(DirectedGraph<Unit> g) {
	// First obligation
	super(g);
	
	// NOTE: Would have expected to get the same results using a
	// regular ArraySparseSet, perhaps containing duplicates of
	// equivalent expressions. But that was not the case, results
	// are incorrect if using ArraySparseSet. This is because
	// we use intersection instead to merge sets,
	// and the ArraySparseSet.intersection implementation uses the method
	// contains to determine whether both sets contain the same element.
	// The contains method only compares references for equality.
	// (i.e. only if both sets contain the same reference is it included
	// in the intersecting set)
	emptySet = new ValueArraySparseSet();

	// NOTE: It's possible to build up the kill and gen sets of each of
	// the nodes in the graph in advance. But in order to do so we
	// would have to build the universe set first. This requires an
	// extra pass through the unit graph, so we generate the kill and
	// gen sets lazily instead.
	
	// Second obligation
	doAnalysis();
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:26,代码来源:SimpleVeryBusyExpressions.java

示例2: reachable

import soot.toolkits.graph.DirectedGraph; //导入依赖的package包/类
private <T> Set<T> reachable(T first, DirectedGraph<T> g) {
	if ( first == null || g == null ) {
		return Collections.<T>emptySet();
	}
	Set<T> visited = new HashSet<T>(g.size());
	Deque<T> q = new ArrayDeque<T>();
	q.addFirst(first);
	do {
		T t = q.removeFirst();
		if ( visited.add(t) ) {				
			q.addAll(g.getSuccsOf(t));
		}
	}
	while (!q.isEmpty());
	
	return visited;
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:18,代码来源:UnreachableCodeEliminator.java

示例3: SimpleLocalDefs

import soot.toolkits.graph.DirectedGraph; //导入依赖的package包/类
SimpleLocalDefs(DirectedGraph<Unit> graph, Local[] locals, boolean omitSSA) {
	if (Options.v().time())
		Timers.v().defsTimer.start();

	final int N = locals.length;
	
	// reassign local numbers
	int[] oldNumbers = new int[N];
	for (int i = 0; i < N; i++) {
		oldNumbers[i] = locals[i].getNumber();
		locals[i].setNumber(i);
	}

	init(graph, locals, omitSSA);

	// restore local numbering
	for (int i = 0; i < N; i++) {
		locals[i].setNumber(oldNumbers[i]);
	}

	if (Options.v().time())
		Timers.v().defsTimer.end();
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:24,代码来源:SimpleLocalDefs.java

示例4: findConditionalStatementForBooleanUnit

import soot.toolkits.graph.DirectedGraph; //导入依赖的package包/类
private static IfStmt findConditionalStatementForBooleanUnit(IInfoflowCFG cfg, Unit booleanUnit) {
	Stack<Unit> worklist = new Stack<Unit>();
	Set<Unit> processedUnits = new HashSet<Unit>();
	worklist.add(booleanUnit);	
		
	while(!worklist.isEmpty()) {
		Unit currentUnit = worklist.pop();
		//in case of a loop or recursion
		if(processedUnits.contains(currentUnit))
			continue;
		processedUnits.add(currentUnit);
		
		//skip our own instrumented code
		if(currentUnit.hasTag(InstrumentedCodeTag.name))
			continue;
		
		
		//we reached the condition
		if(currentUnit instanceof IfStmt) {
			return (IfStmt)currentUnit;		 	
		}
		
		SootMethod methodOfBooleanUnit = cfg.getMethodOf(booleanUnit);		
		DirectedGraph<Unit> graph = cfg.getOrCreateUnitGraph(methodOfBooleanUnit);
		//Comment: Steven said it should always be a UnitGraph + he will implement a more convenient way in the near future :-)
		UnitGraph unitGraph = (UnitGraph)graph;

		SimpleLocalDefs defs = new SimpleLocalDefs(unitGraph);
        SimpleLocalUses uses = new SimpleLocalUses(unitGraph, defs);	        
        List<UnitValueBoxPair> usesOfCurrentUnit = uses.getUsesOf(booleanUnit);
        for(UnitValueBoxPair valueBoxPair : usesOfCurrentUnit)
        	worklist.add(valueBoxPair.getUnit());
		
	}
	return null;
}
 
开发者ID:srasthofer,项目名称:FuzzDroid,代码行数:37,代码来源:UtilSMT.java

示例5: LocalMustNotAliasAnalysis

import soot.toolkits.graph.DirectedGraph; //导入依赖的package包/类
public LocalMustNotAliasAnalysis(DirectedGraph<Unit> directedGraph, Body b)
{
    super(directedGraph);
    locals = new HashSet<Local>(); locals.addAll(b.getLocals());

    for (Local l : b.getLocals()) {
        if (l.getType() instanceof RefLikeType)
            locals.add(l);
    }

    doAnalysis();
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:13,代码来源:LocalMustNotAliasAnalysis.java

示例6: getSuccsOf

import soot.toolkits.graph.DirectedGraph; //导入依赖的package包/类
@Override
public List<Unit> getSuccsOf(Unit u) {
	Body body = unitToOwner.get(u);
	if (body == null)
		return Collections.emptyList();
	DirectedGraph<Unit> unitGraph = getOrCreateUnitGraph(body);
	return unitGraph.getSuccsOf(u);
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:9,代码来源:AbstractJimpleBasedICFG.java

示例7: getStartPointsOf

import soot.toolkits.graph.DirectedGraph; //导入依赖的package包/类
@Override
public Collection<Unit> getStartPointsOf(SootMethod m) {
	if(m.hasActiveBody()) {
		Body body = m.getActiveBody();
		DirectedGraph<Unit> unitGraph = getOrCreateUnitGraph(body);
		return unitGraph.getHeads();
	}
	return Collections.emptySet();
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:10,代码来源:AbstractJimpleBasedICFG.java

示例8: getEndPointsOf

import soot.toolkits.graph.DirectedGraph; //导入依赖的package包/类
@Override
public Collection<Unit> getEndPointsOf(SootMethod m) {
	if(m.hasActiveBody()) {
		Body body = m.getActiveBody();
		DirectedGraph<Unit> unitGraph = getOrCreateUnitGraph(body);
		return unitGraph.getTails();
	}
	return Collections.emptySet();
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:10,代码来源:AbstractJimpleBasedICFG.java

示例9: print_cfg

import soot.toolkits.graph.DirectedGraph; //导入依赖的package包/类
protected void print_cfg(Body body) {
	DirectedGraph<Unit> graph = graphtype.buildGraph(body);
	DotGraph canvas = graphtype.drawGraph(drawer, graph, body);

	String methodname = body.getMethod().getSubSignature();
	String classname = body.getMethod().getDeclaringClass().getName().replaceAll("\\$", "\\.");
	String filename = soot.SourceLocator.v().getOutputDir();
	if (filename.length() > 0) {
		filename = filename + java.io.File.separator;
	}
	filename = filename + classname + " " + methodname.replace(java.io.File.separatorChar, '.') + DotGraph.DOT_EXTENSION;

	G.v().out.println("Generate dot file in " + filename);
	canvas.plot(filename);
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:16,代码来源:CFGViewer.java

示例10: AbstractFlowAnalysis

import soot.toolkits.graph.DirectedGraph; //导入依赖的package包/类
/** Constructs a flow analysis on the given <code>DirectedGraph</code>. */
public AbstractFlowAnalysis(DirectedGraph<N> graph)
{
    unitToBeforeFlow = new IdentityHashMap<N,A>(graph.size() * 2 + 1);
    this.graph = graph;
    if (Options.v().interactive_mode()){
        InteractionHandler.v().handleCfgEvent(graph);
    }
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:10,代码来源:AbstractFlowAnalysis.java

示例11: FlowAssignment

import soot.toolkits.graph.DirectedGraph; //导入依赖的package包/类
FlowAssignment(DirectedGraph<Unit> graph, Local[] locals, List<Unit>[] unitList, int units, boolean omitSSA) {
	super(graph);

	final int N = locals.length;

	this.locals = new HashMap<Local, Integer>((N*3)/2+7);
	this.unitList = unitList;

	universe = new Unit[units];
	indexOfUnit = new HashMap<Unit, Integer>(units);

	localRange = new int[N + 1];
	for (int j = 0, i = 0; i < N; localRange[++i] = j) {
		if (unitList[i].isEmpty())
			continue;

		this.locals.put(locals[i], i);

		if (unitList[i].size() >= 2) {
			for (Unit u : unitList[i]) {
				indexOfUnit.put(u, j);
				universe[j++] = u;
			}
		} else if (omitSSA) {
			universe[j++] = unitList[i].get(0);
		}
	}
	assert localRange[N] == units;
	
	doAnalysis();
	
	indexOfUnit.clear();
	indexOfUnit = null;
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:35,代码来源:SimpleLocalDefs.java

示例12: dumpGraph

import soot.toolkits.graph.DirectedGraph; //导入依赖的package包/类
/**
    * Asks the <code>PhaseDumper</code> to dump the passed {@link
    * DirectedGraph} if the current phase is being dumped.
    *
    * @param g the graph to dump.
    *
    * @param body the {@link Body} represented by <code>g</code>.
    */
   public void dumpGraph(DirectedGraph g, Body b) {
if (alreadyDumping) {
    return;
}
try {
    alreadyDumping = true;
    String phaseName = phaseStack.currentPhase();
    if (isCFGDumpingPhase(phaseName)) { 
	try {
	    String outputFile = nextGraphFileName(b, phaseName + "-" + 
						  getClassIdent(g) + "-");
	    DotGraph dotGraph = new CFGToDotGraph().drawCFG(g, b);
	    dotGraph.plot(outputFile);

	} catch (java.io.IOException e) {
	    // Don't abort execution because of an I/O error, but 
	    // report the error.
	    G.v().out.println("PhaseDumper.dumpBody() caught: " + 
			      e.toString());
	    e.printStackTrace(G.v().out);
	}
    }
} finally {
    alreadyDumping = false;
}
   }
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:35,代码来源:PhaseDumper.java

示例13: drawCFG

import soot.toolkits.graph.DirectedGraph; //导入依赖的package包/类
/**
  * Create a <code>DotGraph</code> whose nodes and edges depict 
  * a control flow graph without distinguished
  * exceptional edges.
  * 
  * @param graph a <code>DirectedGraph</code> representing a CFG
  *              (probably an instance of {@link UnitGraph}, {@link BlockGraph},
  *              or one of their subclasses).
  *
  * @param body the <code>Body</code> represented by <code>graph</code> (used
  * to format the text within nodes).  If no body is available, pass
  * <code>null</code>.
  *
  * @return a visualization of <code>graph</code>.
  */
 public <N> DotGraph drawCFG(DirectedGraph<N> graph, Body body) {
   DotGraph canvas = initDotGraph(body);
   DotNamer<N> namer = new DotNamer<N>((int)(graph.size()/0.7f), 0.7f);
   NodeComparator<N> comparator = new NodeComparator<N>(namer);

   // To facilitate comparisons between different graphs of the same
   // method, prelabel the nodes in the order they appear
   // in the iterator, rather than the order that they appear in the
   // graph traversal (so that corresponding nodes are more likely
   // to have the same label in different graphs of a given method).
   for (Iterator<N> nodesIt = graph.iterator(); nodesIt.hasNext(); ) {
     namer.getName(nodesIt.next());
   }

   for (Iterator<N> nodesIt = graph.iterator(); nodesIt.hasNext(); ) {
     N node = nodesIt.next();
     canvas.drawNode(namer.getName(node));
     for (Iterator<N> succsIt = sortedIterator(graph.getSuccsOf(node), comparator);
   succsIt.hasNext(); ) {
N succ = succsIt.next();
canvas.drawEdge(namer.getName(node), namer.getName(succ));
     }
   }
   setStyle(graph.getHeads(), canvas, namer,
     DotGraphConstants.NODE_STYLE_FILLED, headAttr);
   setStyle(graph.getTails(), canvas, namer, 
     DotGraphConstants.NODE_STYLE_FILLED, tailAttr);
   if (! isBrief) {
     formatNodeText(body, canvas, namer);
   }

   return canvas;
 }
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:49,代码来源:CFGToDotGraph.java

示例14: load

import soot.toolkits.graph.DirectedGraph; //导入依赖的package包/类
@Override
public UnitContainer load(Unit unit) throws Exception {
	SootMethod method = getMethodOf(unit);
	DirectedGraph<Unit> graph = bodyToUnitGraph.getUnchecked(method.getActiveBody());
	MHGPostDominatorsFinder<Unit> postdominatorFinder = new MHGPostDominatorsFinder<Unit>(graph);
	Unit postdom = postdominatorFinder.getImmediateDominator(unit);
	if (postdom == null)
		return new UnitContainer(method);
	else
		return new UnitContainer(postdom);
}
 
开发者ID:0-14N,项目名称:soot-inflow,代码行数:12,代码来源:InfoflowCFG.java

示例15: validUnitGraph

import soot.toolkits.graph.DirectedGraph; //导入依赖的package包/类
public static void validUnitGraph(DirectedGraph<Unit> g) throws Violation {

        /* Branching statements should not be exit nodes.
        This restriction ensures that we always get a non-null immediatePostdominator */
        for (Unit u : g) {
            if (g.getSuccsOf(u).size() > 1 && g.getTails().contains(u)) {
                throw new Violation(String.format("Branching statement is an exit node: %s" +
                        "\n in graph %s", u, g));
            }
        }

    }
 
开发者ID:proglang,项目名称:jgs,代码行数:13,代码来源:Assumptions.java


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