Local returnLocal = Jimple.v().newLocal("return",
PtolemyUtilities.tokenType);
body.getLocals().add(returnLocal);
SootField indexArrayField = (SootField) _portToIndexArrayField
.get(port);
if (indexArrayField == null) {
throw new RuntimeException("indexArrayField is null!");
}
// Load the array of indexes.
body.getUnits().insertBefore(
Jimple.v().newAssignStmt(
indexArrayLocal,
Jimple.v().newInstanceFieldRef(body.getThisLocal(),
indexArrayField.makeRef())), stmt);
Value bufferSizeValue = null;
// Refer directly to the buffer in the _model
int channel = 0;
for (Iterator relations = port.linkedRelationList().iterator(); relations
.hasNext();) {
TypedIORelation relation = (TypedIORelation) relations.next();
int bufferSize = _getBufferSize(relation);
// remember the size of the buffer.
bufferSizeValue = IntConstant.v(bufferSize);
for (int i = 0; i < relation.getWidth(); i++, channel++) {
Value channelValue = IntConstant.v(channel);
// Load the correct index into indexLocal
body.getUnits().insertBefore(
Jimple.v().newAssignStmt(
indexLocal,
Jimple.v().newArrayRef(indexArrayLocal,
channelValue)), stmt);
SootField arrayField = _modelClass
.getFieldByName(InlinePortTransformer
.getBufferFieldName(relation, i, port.getType()));
Local containerLocal = FieldsForEntitiesTransformer
.getLocalReferenceForEntity(_model, theClass, body
.getThisLocal(), body, stmt, _options);
// load the buffer array.
body.getUnits().insertBefore(
Jimple.v().newAssignStmt(
bufferLocal,
Jimple.v().newInstanceFieldRef(containerLocal,
arrayField.makeRef())), stmt);
// If we are calling with just a token, then send the token.
if (expr.getArgCount() == 1) {
// Write to the buffer.
body.getUnits().insertBefore(