if (offset == null) {
if (attribute instanceof Variable) {
// FIXME: need to ensure that the returned string
// is correct syntax for the target language.
Variable variable = (Variable) attribute;
/*
if (_codeGenerator._modifiedVariables.contains(variable)) {
return generateVariableName(variable);
} else if (variable.isStringMode()) {
return "\"" + variable.getExpression() + "\"";
}
*/
ParseTreeCodeGenerator parseTreeCodeGenerator = getParseTreeCodeGenerator();
if (variable.isStringMode()) {
return _generateTypeConvertMethod("\""
+ parseTreeCodeGenerator
.escapeForTargetLanguage(variable
.getExpression()) + "\"", castType,
"String");
}
PtParser parser = new PtParser();
ASTPtRootNode parseTree = null;
try {
parseTree = parser.generateParseTree(variable
.getExpression());
} catch (Throwable throwable) {
throw new IllegalActionException(variable, throwable,
"Failed to generate parse tree for \"" + name
+ "\". in \"" + container + "\"");
}
parseTreeCodeGenerator.evaluateParseTree(parseTree,
new VariableScope(variable));
String fireCode = processCode(parseTreeCodeGenerator
.generateFireCode());
//if (castType == null && codeGenType(variable.getType()).equals("Array")) {
// FIXME: this is a gross hack necessary for Case.
// The problem is that if the refinement is named "{0}", then
// we get into trouble because {0} is "false"? sigh.
// return "Array_new(1, 1, " + fireCode + ");";
//}
return _generateTypeConvertMethod(fireCode, castType,
codeGenType(variable.getType()));
} else /* if (attribute instanceof Settable)*/{
return ((Settable) attribute).getExpression();
}