diff --git a/examples/actors/MergeActors.java b/examples/actors/MergeActors.java index b67b8acf781d8b4727ada34259ba6516d32ddac6..263ff7f5847e6bb7b8712c75e352fad49683fd10 100644 --- a/examples/actors/MergeActors.java +++ b/examples/actors/MergeActors.java @@ -27,7 +27,7 @@ public class MergeActors extends XdfParser { // } ast.mergeActors(); - ast.prettyPrint("",System.out); +// ast.prettyPrint("",System.out); } } diff --git a/examples/actors/xdf/MergeActors.jrag b/examples/actors/xdf/MergeActors.jrag index 1b3388e8966680924318649817d2a7efbd69ddd2..6153a7d95e21e833ded20743a21ae4fd2d0a0094 100644 --- a/examples/actors/xdf/MergeActors.jrag +++ b/examples/actors/xdf/MergeActors.jrag @@ -26,11 +26,11 @@ aspect MergeActors { HashSet<Connection> cons = getConnections(new HashSet<Connection>()); for (Instance i : schedule) { while (i.next != null) { -// System.out.println("Searching connections for: "+i.name()+" "+i.next.name()); + System.out.println("Searching connections for: "+i.name()+" "+i.next.name()); for (Connection c : cons) { System.out.println(" "+c.getSource().name()+" "+c.getDest().name()); if (c.getSource() == i && c.getDest() == i.next) { -// System.out.println(" Found"); + System.out.println(" Found"); // Check port names and perform actual actor // merge. Then set remove_me flag so that this // connection will be removed from the actor @@ -41,8 +41,10 @@ aspect MergeActors { c.setSource(i.id()); } } + System.out.println("Merging "+i.name()+":"+i.next.name()); i.merge(i.next); i.setName(i.name()+"_"+i.next.name()); + i.isMerged(true); i.next.disabled = true; i.next = i.next.next; } @@ -55,21 +57,32 @@ aspect MergeActors { } void Instance.merge(Instance inst) { - xlimInstance().merge(inst.xlimInstance()); + if (isMerged()) { + 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()); - } + void Instance.genFile() { + if (isMerged()) { + 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()); + } + } } + private boolean Instance.isMerged = false; + public void Instance.isMerged(boolean b) { + isMerged = b; + } + public boolean Instance.isMerged() { + return isMerged; + } } aspect Misc { @@ -110,4 +123,4 @@ aspect Rewrites { return new ComplexElement(); } } -} \ No newline at end of file +} diff --git a/examples/actors/xlim/Merge.jrag b/examples/actors/xlim/Merge.jrag index 91b960394da5d21cc9a494db93e43fc151ba1d83..46dbf2fb1f2d96afad121135966f003296223a7d 100644 --- a/examples/actors/xlim/Merge.jrag +++ b/examples/actors/xlim/Merge.jrag @@ -15,35 +15,35 @@ aspect Merge { public void EmptyStart.merge(Start dest) {} public void design.merge(design dest) { - HashSet<operation> ops = getOperations(new HashSet<operation>()); - for (Element e : getElements()) { - if (e.isAction()) { - for (operation o : ops) { - ((module) e).addElement(o); - } - } + HashSet<module> ops = getActions(new HashSet<module>()); + System.out.println("Adding actions to: "+name()); + for (module o : ops) { + System.out.println(" Adding "+o.name()); + addElement(o); } } } -aspect Operations { - syn HashSet<operation> ASTNode.getOperations(HashSet<operation> ops) = ops; - eq Start.getOperations(HashSet<operation> ops) = - getSpecification().getOperations(ops); - eq Specification.getOperations(HashSet<operation> ops) { +aspect Actions { + syn HashSet<module> ASTNode.getActions(HashSet<module> ops) = ops; + eq Start.getActions(HashSet<module> ops) = + getSpecification().getActions(ops); + eq Specification.getActions(HashSet<module> ops) { for (Element e : getElements()) { - ops = e.getOperations(ops); + ops = e.getActions(ops); } return ops; } - eq ComplexElement.getOperations(HashSet<operation> ops) { + eq ComplexElement.getActions(HashSet<module> ops) { for (Element e : getElements()) { - ops = e.getOperations(ops); + ops = e.getActions(ops); } return ops; } - eq operation.getOperations(HashSet<operation> ops) { - ops.add(this); + eq module.getActions(HashSet<module> ops) { + if (isAction()) { + ops.add(this); + } return ops; } -} \ No newline at end of file +} diff --git a/examples/actors/xlim/SDF.jrag b/examples/actors/xlim/SDF.jrag index 2a14e1ef35bbca15a847551708bf5fe69afb7477..309375cf3e92fd5946a22923cf87e94dcb3704ea 100644 --- a/examples/actors/xlim/SDF.jrag +++ b/examples/actors/xlim/SDF.jrag @@ -45,6 +45,17 @@ aspect Misc { return ""; } + syn String Element.name() = "anonymous"; + eq ComplexElement.name() { + for (int i=0; i<getNumAttribute(); i++) { + Attribute a = getAttribute(i); + if (a instanceof name) { + return fix(a.getAttrValue().getLITERAL()); + } + } + return super.name(); + } + static String ASTNode.fix(String s) { if (s.indexOf('"') == 0) { return s.substring(1,s.length()-1); @@ -67,4 +78,4 @@ aspect Fixes { int ASTNode.numChildren() {return jjtGetNumChildren();} int List.getNumNoTransformChild() {return getNumChildNoTransform();} int Opt.getNumChildNoTransfrom() {return getNumChildNoTransform();} -} \ No newline at end of file +}