Select Git revision
Merge.jrag 1.99 KiB
/* -*-Java-*- */
/*
* Copyright (C) 2009 Anders Nilsson <anders.nilsson@cs.lth.se>
*
* This file is part of Actors model compiler.
*/
import java.util.HashSet;
aspect Merge {
public void Start.merge(Start dest) {
getSpecification().getDesign().merge(dest.getSpecification().getDesign());
}
public void EmptyStart.merge(Start dest) {}
public void design.merge(design dest) {
HashSet<module> ops = dest.getActions(new HashSet<module>());
System.out.println("Adding actions from: "+dest.name()+" to: "+name());
setName(name()+"_"+dest.name());
List<Element> eList = getElements();
for (module o : ops) {
o.setName(dest.name()+"_"+o.name());
System.out.println(" Adding "+o.name());
eList.insertChild(o,eList.getNumChild()-2);
actionScheduler().addTaskCall(o);
// eList.addChild(o);
}
}
}
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.getActions(ops);
}
return ops;
}
eq ComplexElement.getActions(HashSet<module> ops) {
for (Element e : getElements()) {
ops = e.getActions(ops);
}
return ops;
}
eq module.getActions(HashSet<module> ops) {
if (isAction()) {
ops.add(this);
}
return ops;
}
}
aspect ActionScheduler {
syn module Element.actionScheduler() = null;
eq ComplexElement.actionScheduler() {
for (Element e : getElements()) {
if (e.actionScheduler() != null) {
return e.actionScheduler();
}
}
return null;
}
eq module.actionScheduler() {
if (isActionScheduler()) {
return this;
}
return null;
}
boolean module.isActionScheduler() {
return kind().equals("action-scheduler");
}
void module.addTaskCall(module m) {
}
}