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

First demo version for Actors meeting in Lund.

parent fc7811c5
Branches
No related tags found
No related merge requests found
...@@ -27,7 +27,7 @@ public class MergeActors extends XdfParser { ...@@ -27,7 +27,7 @@ public class MergeActors extends XdfParser {
// } // }
ast.mergeActors(); ast.mergeActors();
ast.prettyPrint("",System.out); // ast.prettyPrint("",System.out);
} }
} }
...@@ -7,6 +7,9 @@ ...@@ -7,6 +7,9 @@
*/ */
import java.util.HashSet; import java.util.HashSet;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintStream;
aspect MergeActors { aspect MergeActors {
void Element.mergeActors() {} void Element.mergeActors() {}
...@@ -45,7 +48,10 @@ aspect MergeActors { ...@@ -45,7 +48,10 @@ aspect MergeActors {
} }
} }
// Now generate files for the newly merged actor instances. // Now generate files for the newly merged actor instances.
for (Instance i : getInstances()) {} System.out.println("** Merging finished, now generate files **");
for (Instance i : getInstances()) {
i.genFile();
}
} }
// void Connection.mergeActors() { // void Connection.mergeActors() {
// Instance src = getSource(); // Instance src = getSource();
...@@ -60,6 +66,18 @@ aspect MergeActors { ...@@ -60,6 +66,18 @@ aspect MergeActors {
xlimInstance().merge(inst.xlimInstance()); xlimInstance().merge(inst.xlimInstance());
} }
void Instance.genFile() {
System.out.println("generating actor: "+name());
try {
if (!(xlimInstance() instanceof xlimAST.EmptyStart)) {
System.out.println(" Writing");
xlimInstance().prettyPrint("",new PrintStream(new File(name()+".xlim")));
}
} catch (FileNotFoundException e) {
System.out.println("Could not print to file: "+name());
}
}
} }
aspect Misc { aspect Misc {
...@@ -79,6 +97,16 @@ aspect Misc { ...@@ -79,6 +97,16 @@ aspect Misc {
return getInstances(new HashSet<Instance>()); return getInstances(new HashSet<Instance>());
} }
syn HashSet<Instance> Element.getInstances(HashSet<Instance> inst) = inst; syn HashSet<Instance> Element.getInstances(HashSet<Instance> inst) = inst;
eq XDF.getInstances(HashSet<Instance> inst) {
for (Element e : getElements()) {
inst = e.getInstances(inst);
}
return inst;
}
eq Instance.getInstances(HashSet<Instance> inst) {
inst.add(this);
return inst;
}
} }
aspect Rewrites { aspect Rewrites {
......
...@@ -30,14 +30,14 @@ aspect SSR { ...@@ -30,14 +30,14 @@ aspect SSR {
aspect SDF { aspect SDF {
syn boolean Instance.isSDF() = xlimInstance().isSDF(); syn boolean Instance.isSDF() = xlimInstance().isSDF();
syn xlimAST.Start Instance.xlimInstance() { syn lazy xlimAST.Start 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(); return parser.Start();
} 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 new xlimAST.EmptyStart(); return new xlimAST.EmptyStart();
} }
} }
......
...@@ -215,7 +215,7 @@ aspect PrettyPrinter { ...@@ -215,7 +215,7 @@ aspect PrettyPrinter {
} }
public void actor_port.prettyPrint(String ind, PrintStream pStream) { public void actor_port.prettyPrint(String ind, PrintStream pStream) {
pStream.print(ind+"<actor_port "); pStream.print(ind+"<actor-port ");
for (int i=0; i<getNumAttribute(); i++) { for (int i=0; i<getNumAttribute(); i++) {
getAttribute(i).prettyPrint(ind,pStream); getAttribute(i).prettyPrint(ind,pStream);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment