|
Message
From: cvs at opencores.org<cvs@o...>
Date: Tue Jul 24 15:00:10 CEST 2007
Subject: [cvs-checkins] MODIFIED: jop ...
Date: 00/07/07 24:15:00 Added: jop/java/tools/src/wcet/framework/cfg BasicControlFlowGraph.java BasicEdge.java BasicVertex.java Log: Revision Changes Path 1.1 jop/java/tools/src/wcet/framework/cfg/BasicControlFlowGraph.java http://www.opencores.org/cvsweb.shtml/jop/java/tools/src/wcet/framework/cfg/BasicControlFlowGraph.java?rev=1.1&content-type=text/x-cvsweb-markup Index: BasicControlFlowGraph.java =================================================================== /** * */ package wcet.framework.cfg; import java.util.Collection; import java.util.HashMap; import wcet.framework.interfaces.cfg.IControlFlowGraph; import wcet.framework.interfaces.cfg.IEdge; import wcet.framework.interfaces.cfg.IVertex; import wcet.framework.interfaces.cfg.IVertexData; /** * @author Elena Axamitova * @version 0.2 */ public class BasicControlFlowGraph<T extends IVertexData> implements IControlFlowGraph { protected HashMap<Integer, IVertex<T>> indexVertexMap; protected HashMap<Integer, IEdge> indexEdgeMap; public BasicControlFlowGraph() { this.indexVertexMap = new HashMap<Integer, IVertex<T>>(); this.indexEdgeMap = new HashMap<Integer, IEdge>(); } /* * (non-Javadoc) * * @see wcet.interfaces.cfg.IControlFlowGraph#addEdge(wcet.interfaces.cfg.IVertex, * wcet.interfaces.cfg.IVertex) */ @SuppressWarnings("unchecked") public int addEdge(int from, int to) { IEdge newEdge = new BasicEdge(from, to); int newEdgeId = newEdge.getIndex(); this.indexEdgeMap.put(newEdgeId, newEdge); IVertex fromVertex = this.findVertexByIndex(from); IVertex toVertex = this.findVertexByIndex(to); fromVertex.addOutgoingEdge(newEdgeId); toVertex.addIngomingEdge(newEdgeId); return newEdgeId; } /* * (non-Javadoc) * * @see wcet.interfaces.cfg.IControlFlowGraph#findVertexByIndex(int) */ public IVertex<T> findVertexByIndex(int idx) { return this.indexVertexMap.get(Integer.valueOf(idx)); } /* (non-Javadoc) * @see wcet.framework.interfaces.cfg.IControlFlowGraph#findEdgeByIndex(int) */ public IEdge findEdgeByIndex(int idx) { return this.indexEdgeMap.get(Integer.valueOf(idx)); } /* * (non-Javadoc) * * @see wcet.interfaces.cfg.IControlFlowGraph#newVertex(wcet.interfaces.cfg.IVertexData) */ @SuppressWarnings("unchecked") public int addVertex(IVertexData data) { IVertex<T> newVertex = new BasicVertex<T>((T) data); this.indexVertexMap.put(Integer.valueOf(newVertex.getIndex()), newVertex); return newVertex.getIndex(); } public Collection<IVertex<T>> getAllVertices() { return this.indexVertexMap.values(); } public Collection<IEdge> getAllEdges() { return this.indexEdgeMap.values(); } public IVertex getRoot() { return this.findVertexByIndex(IControlFlowGraph.ROOT_ID); }
public int getEdgeCount() {
return this.indexEdgeMap.size();
}
public int getVeticesCount() {
return this.indexVertexMap.size();
}
}
1.1 jop/java/tools/src/wcet/framework/cfg/BasicEdge.java
http://www.opencores.org/cvsweb.shtml/jop/java/tools/src/wcet/framework/cfg/BasicEdge.java?rev=1.1&content-type=text/x-cvsweb-markup
Index: BasicEdge.java
===================================================================
/**
*
*/
package wcet.framework.cfg;
import wcet.framework.interfaces.cfg.IEdge;
/**
* @author Elena Axamitova
* @version 0.1
*/
public class BasicEdge implements IEdge {
private static int LAST_INDEX = 0;
protected int fromVertex;
protected int toVertex;
protected int index;
protected int frequency;
protected boolean exceptionEdge = false;
public BasicEdge(int v1, int v2){
this.fromVertex = v1;
this.toVertex = v2;
this.frequency = 1;
this.index = getNextIndex();
}
public BasicEdge(int v1, int v2, boolean exc){
this.fromVertex = v1;
this.toVertex = v2;
this.frequency = 1;
this.index = getNextIndex();
this.exceptionEdge = exc;
}
protected synchronized static int getNextIndex(){
return LAST_INDEX++;
}
/* (non-Javadoc)
* @see wcet.interfaces.cfg.IEdge#getFromVertex()
*/
public int getFromVertex() {
return this.fromVertex;
}
/* (non-Javadoc)
* @see wcet.interfaces.cfg.IEdge#getIndex()
*/
public int getIndex() {
return this.index;
}
/* (non-Javadoc)
* @see wcet.interfaces.cfg.IEdge#getToVertex()
*/
public int getToVertex() {
return this.toVertex;
}
/* (non-Javadoc)
* @see wcet.framework.interfaces.cfg.IEdge#getFrequency()
*/
public int getFrequency() {
return this.frequency;
}
/* (non-Javadoc)
* @see wcet.framework.interfaces.cfg.IEdge#setFrequency(int)
*/
public void setFrequency(int f) {
this.frequency = f;;
}
public String toString(){
return "f"+this.index;
}
public void setExceptionEdge(){
this.exceptionEdge = true;
}
public boolean isExceptionEdge(){
return this.exceptionEdge;
}
}
1.1 jop/java/tools/src/wcet/framework/cfg/BasicVertex.java
http://www.opencores.org/cvsweb.shtml/jop/java/tools/src/wcet/framework/cfg/BasicVertex.java?rev=1.1&content-type=text/x-cvsweb-markup
Index: BasicVertex.java
===================================================================
/**
*
*/
package wcet.framework.cfg;
import java.util.HashSet;
import wcet.framework.interfaces.cfg.IVertex;
import wcet.framework.interfaces.cfg.IVertexData;
/**
* @author Elena Axamitova
* @version 0.2
*/
public class BasicVertex<T extends IVertexData> implements IVertex {
private static int LAST_INDEX = 0;
protected HashSet<Integer> outgoingEdges;
protected HashSet<Integer> incomingEdges;
private T data;
private int index;
private int loopCount;
private HashSet<Integer> edgesToLoopBodyIds;
private HashSet<Integer> inNotLoopEdges;
private boolean isCatchHandler = false;
public BasicVertex(T data){
this.data = data;
this.index = getNextIndex();
this.outgoingEdges = new HashSet<Integer>();
this.incomingEdges = new HashSet<Integer>();
this.loopCount = -1;
}
protected synchronized static int getNextIndex(){
return LAST_INDEX++;
}
/* (non-Javadoc)
* @see wcet.interfaces.cfg.IVertex#getData()
*/
public T getData() {
return this.data;
}
/* (non-Javadoc)
* @see wcet.interfaces.cfg.IVertex#getIndex()
*/
public int getIndex() {
return this.index;
}
@Override
public String toString(){
return "B"+Integer.valueOf(this.index).toString()+" " + this.data.toString();
}
public void addIngomingEdge(int id) {
this.incomingEdges.add(id);
}
public void addOutgoingEdge(int id) {
this.outgoingEdges.add(id);
}
public HashSet<Integer> getIncomingEdges() {
return this.incomingEdges;
}
public HashSet<Integer> getOutgoingEdges() {
return this.outgoingEdges;
}
public void addInNotLoopEdge(int eid) {
if(this.inNotLoopEdges == null){
this.inNotLoopEdges = new HashSet<Integer>();
}
this.inNotLoopEdges.add(eid);
}
public void addEdgeToLoopBody(int eid) {
if(this.edgesToLoopBodyIds == null){
this.edgesToLoopBodyIds = new HashSet<Integer>();
}
this.edgesToLoopBodyIds.add(eid);
}
public HashSet<Integer> getEdgesToLoopBody() {
return this.edgesToLoopBodyIds;
}
public HashSet<Integer> getInNotLoopEdges() {
return this.inNotLoopEdges;
}
public int getLoopCount() {
return this.loopCount;
}
public void setLoopCount(int lc) {
this.loopCount = lc;
}
public boolean isLoopControler() {
return this.loopCount!=-1;
}
public boolean isCatchHandler() {
return this.isCatchHandler;
}
public void setCatchHandler() {
this.isCatchHandler=true;
}
}
|
 |