⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 basicblock.java

📁 该工具也是用于字节码插桩
💻 JAVA
字号:
/* * BasicBlock.java * * Created on July 24, 2001, 7:20 AM * * See LICENSE file for license conditions. */package residue.graph;import java.util.*;/** * This class represents a basic block in the flow control graph, * as an adjacent, ordered, series of Nodes. * * @author  chowells * @version  */public class BasicBlock implements Observer{	private List nodes = new ArrayList();		private Set edges = new HashSet();	private Set lines = new TreeSet();		private int pos = -1;		private int incomingEdges;		public void add(Node n)	{		if (pos == -1)			pos = n.getPosition();		nodes.add(n);				Iterator it = n.getEdges().iterator();		while (it.hasNext())		{			Node t = (Node)it.next();			BasicBlock bb = t.getBlock();						if (bb == this) continue;			if (bb == null) t.addObserver(this);			else			{				if (edges.add(bb)) bb.incomingEdges++;			}		} // while				lines.add(new Integer(n.getLine()));		n.setBlock(this);	} // add		public Set getLines()	{		return Collections.unmodifiableSet(lines);	} // getLines		public Set getEdges()	{		return Collections.unmodifiableSet(edges);	} // getEdges		/**	 * package visible mutator for edges, used by	 * reverse() in graph.	 */	void setEdges(Set s)	{		edges = s;	} // setEdges		public int getPosition()	{		return pos;	} // getPosition		public int getIncomingEdgeCount()	{		return incomingEdges;	} // getIncomingEdgeCount		public Node getFirstNode()	{		return (Node)nodes.get(0);	} // getFirstNode		public Node getLastNode()	{		return (Node)nodes.get(nodes.size() - 1);	} // getLastNode		/**	 * This method overrides update in the Observer interface.	 * The object it expects to get is a BasicBlock to include	 * in its internal set of edges.  If it doesn't get a	 * BasicBlock, it throws a ClassCastException	 */	public void update(Observable observable, Object obj)	{		if (obj != this)		{			BasicBlock b = (BasicBlock)obj; 			if (edges.add(b)) b.incomingEdges++;		}				observable.deleteObserver(this);	} // update	} // BasicBlock

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -