boolean isIDefined = false;
Iterator actorsToFire = schedule.firingIterator();
while (actorsToFire.hasNext()) {
Firing firing = (Firing) actorsToFire.next();
Actor actor = firing.getActor();
// FIXME: Before looking for a helper class, we should check to
// see whether the actor contains a code generator attribute.
// If it does, we should use that as the helper.
CodeGeneratorHelper helper = (CodeGeneratorHelper) _getHelper((NamedObj) actor);
if (inline) {
for (int i = 0; i < firing.getIterationCount(); i++) {
// generate fire code for the actor
code.append(helper.generateFireCode());
code.append(helper.generateTypeConvertFireCode());
// update buffer offset after firing each actor once
Iterator inputPorts = actor.inputPortList().iterator();
while (inputPorts.hasNext()) {
IOPort port = (IOPort) inputPorts.next();
int rate = DFUtilities.getRate(port);
_updatePortOffset(port, code, rate);
}
Iterator outputPorts = actor.outputPortList().iterator();
while (outputPorts.hasNext()) {
IOPort port = (IOPort) outputPorts.next();
int rate = DFUtilities.getRate(port);
_updateConnectedPortsOffset(port, code, rate);
}
}
} else {
int count = firing.getIterationCount();
if (count > 1) {
if (!isIDefined) {
code.append(CodeStream.indent("int i;" + _eol));
isIDefined = true;
}
code.append(CodeStream.indent("for (i = 0; i < " + count
+ " ; i++) {" + _eol));
CodeStream.setIndentLevel(2);
}
// code.append(CodeStream.indent(CodeGeneratorHelper
// .generateName((NamedObj) actor)
// + "();" + _eol));
// metroii
String actor_name = CodeGeneratorHelper.generateName((NamedObj) actor);
if(actor_name.startsWith("_"))
{
actor_name = actor_name.substring(1);
}
String actor_fire_func_name = actor_name + "();\n";
// FIXME only support top level director
actor_fire_func_name = "/*****FIRING_ACTOR:"+actor_name+"*****/\n"+actor_fire_func_name+"/*****done "+actor_name+"*****/\n\n";
code.append(actor_fire_func_name);
// update buffer offset after firing each actor once
Iterator inputPorts = actor.inputPortList().iterator();
while (inputPorts.hasNext()) {
IOPort port = (IOPort) inputPorts.next();
int rate = DFUtilities.getRate(port);
_updatePortOffset(port, code, rate);
}
Iterator outputPorts = actor.outputPortList().iterator();
while (outputPorts.hasNext()) {
IOPort port = (IOPort) outputPorts.next();
int rate = DFUtilities.getRate(port);
_updateConnectedPortsOffset(port, code, rate);
}