// in the generated C code.
code.append("[(" + writeOffset + " + "
+ (bufferSizeOfChannel - 1) + ")&"
+ (bufferSizeOfChannel - 1) + "]");
}
return new ObjectToken(code.toString());
}
// try the format: inputPortNameArray
found = false;
channelNumber = 0;
if (name.equals(inputPort.getName() + "Array")) {
found = true;
code.append(generateName(inputPort));
if (inputPort.isMultiport()) {
code.append("[0]");
}
} else {
for (int i = 0; i < inputPort.getWidth(); i++) {
// try the format: inputPortName_channelNumberArray
if (name
.equals(inputPort.getName() + "_" + i + "Array")) {
found = true;
channelNumber = i;
code.append(generateName(inputPort));
code.append("[" + i + "]");
break;
}
}
}
if (found) {
int bufferSize = getBufferSize(inputPort);
if (bufferSize > 1) {
int bufferSizeOfChannel = getBufferSize(inputPort,
channelNumber);
String writeOffset = (String) getWriteOffset(inputPort,
channelNumber);
// '@' represents the array index in the parsed expression.
// It will be replaced by actual array index in
// the method visitFunctionApplicationNode() in
// ParseTreeCodeGenerator.
// Note here inputPortNameArray(i) in the original expression
// is converted to
// inputPortVariable[(writeOffset - i - 1
// + bufferSizeOfChannel)&(bufferSizeOfChannel-1)]
// in the generated C code.
code.append("[(" + writeOffset + " - (@)" + " + "
+ (bufferSizeOfChannel - 1) + ")&"
+ (bufferSizeOfChannel - 1) + "]");
}
return new ObjectToken(code.toString());
}
}
// try variable