Skip to content
Snippets Groups Projects
Commit 8dc42211 authored by Anders Nilsson's avatar Anders Nilsson
Browse files

Can merge actor connections in an xdf (though only in very simple cases).

parent 6db494f9
No related branches found
No related tags found
No related merge requests found
...@@ -23,28 +23,35 @@ aspect MergeActors { ...@@ -23,28 +23,35 @@ aspect MergeActors {
HashSet<Connection> cons = getConnections(new HashSet<Connection>()); HashSet<Connection> cons = getConnections(new HashSet<Connection>());
for (Instance i : schedule) { for (Instance i : schedule) {
while (i.next != null) { while (i.next != null) {
// System.out.println("Searching connections for: "+i.name()+" "+i.next.name());
for (Connection c : cons) { for (Connection c : cons) {
System.out.println(" "+c.getSource().name()+" "+c.getDest().name());
if (c.getSource() == i && c.getDest() == i.next) { if (c.getSource() == i && c.getDest() == i.next) {
// System.out.println(" Found");
// Check port names and perform actual actor // Check port names and perform actual actor
// merge. Then set remove_me flag so that this // merge. Then set remove_me flag so that this
// connection will be removed from the actor // connection will be removed from the actor
// network. // network.
c.remove_me = true; c.remove_me = true;
c.is$Final(false);
} else if (c.getSource() == i.next) {
c.setSource(i.id());
} }
} }
i.merge(i.next);
i.setName(i.name()+"_"+i.next.name()); i.setName(i.name()+"_"+i.next.name());
i.next = i.next.next; i.next = i.next.next;
} }
} }
} }
void Connection.mergeActors() { // void Connection.mergeActors() {
Instance src = getSource(); // Instance src = getSource();
Instance dest = getDest(); // Instance dest = getDest();
if (dest.isSDF() && src.isSDF()) { // if (dest.isSDF() && src.isSDF()) {
src.merge(dest); // src.merge(dest);
src.setName(src.name()+"_"+dest.name()); // src.setName(src.name()+"_"+dest.name());
} // }
} // }
void Instance.merge(Instance inst) {} void Instance.merge(Instance inst) {}
} }
......
...@@ -28,15 +28,17 @@ aspect SSR { ...@@ -28,15 +28,17 @@ aspect SSR {
} }
aspect SDF { aspect SDF {
syn boolean Instance.isSDF() { syn boolean Instance.isSDF() = xlimInstance().isSDF();
syn xlimAST.design Instance.xlimInstance() {
try { try {
System.out.println("Trying to open: "+name()); System.out.println("Trying to open: "+name());
xlimAST.XmlParser parser = new xlimAST.XmlParser(new FileReader(name()+".xlim")); xlimAST.XmlParser parser = new xlimAST.XmlParser(new FileReader(name()+".xlim"));
return parser.Start().isSDF(); return (xlimAST.design) parser.Start().getSpecification().getElement(0);
} catch (Exception e) { } catch (Exception e) {
System.out.println( name()+".xlim not found"); System.out.println( name()+".xlim not found");
// e.printStackTrace(); // e.printStackTrace();
return false; return new xlimAST.design();
} }
} }
} }
...@@ -92,6 +94,14 @@ aspect ActorLookup { ...@@ -92,6 +94,14 @@ aspect ActorLookup {
return ""; return "";
} }
void Connection.setSource(String src) {
for (Attribute a : getAttributes()) {
if (a instanceof src) {
a.getAttrValue().setLITERAL(src);
}
}
}
syn Instance Connection.getDest() = root().getInstance(dest()); syn Instance Connection.getDest() = root().getInstance(dest());
String Connection.dest() { String Connection.dest() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment