Local bufferLocal = Jimple.v().newLocal("buffer",
ArrayType.v(PtolemyUtilities.tokenType, 1));
body.getLocals().add(bufferLocal);
// The first argument is always the channel.
Value channelValue = expr.getArg(0);
// We have to repeat for all of the remote types.
Set typeSet = _getConnectedTypeListInside(port);
for (Iterator types = typeSet.iterator(); types.hasNext();) {
ptolemy.data.type.Type type = (ptolemy.data.type.Type) types.next();
Local typeLocal = null;
// if (!port.getType().equals(type)) {
typeLocal = PtolemyUtilities.buildConstantTypeLocal(body, stmt,
type);
// }
_getBuffer(_modelClass, body, stmt, port, port.getType(),
bufferLocal, _portToTypeNameToInsideBufferField);
// A local of type token
Local tokenLocal = Jimple.v().newLocal("tokenLocal",
PtolemyUtilities.tokenType);
body.getLocals().add(tokenLocal);
// A local of the appropriate type to store in the
// buffer.
Local outputTokenLocal = Jimple.v().newLocal("outputTokenLocal",
PtolemyUtilities.getSootTypeForTokenType(type));
body.getLocals().add(outputTokenLocal);
// If we are calling with just a channel, then write the value.
if (expr.getArgCount() == 2) {
Local sendTokenLocal = (Local) expr.getArg(1);
// Replace the put() with an array write.
body.getUnits().insertBefore(
_createBufferStoreInstructions(bufferLocal,
channelValue, sendTokenLocal, typeLocal,
tokenLocal, outputTokenLocal), stmt);
} else {
Local sendArrayLocal = (Local) expr.getArg(1);
/* Jimple.v().newLocal("sendArray",
ArrayType.v(PtolemyUtilities.tokenType, 1));
body.getLocals().add(sendArrayLocal);
// We must send an array of tokens.
body.getUnits().insertBefore(
Jimple.v().newAssignStmt(
sendArrayLocal,
expr.getArg(1)),
stmt);*/
Value countValue = expr.getArg(2);
Local sendTokenLocal = Jimple.v().newLocal("sendToken",
PtolemyUtilities.tokenType);
body.getLocals().add(sendTokenLocal);