throw new RuntimeException(
"already created field for attribute" + attribute);
}
if (attribute instanceof Settable) {
Settable settable = (Settable) attribute;
if (debug) {
System.out.println("creating field for " + settable);
}
String fieldName = StringUtilities.sanitizeName(attribute
.getName(context));
SootField field;
// Create a field to contain the value of the attribute.
if (settable instanceof Variable) {
Variable variable = (Variable) settable;
ptolemy.data.type.Type type = variable.getType();
Type tokenType = PtolemyUtilities
.getSootTypeForTokenType(type);
boolean isConstant = constantAnalysis.getConstVariables(
context).contains(attribute);
int modifier;
if (isConstant) {
modifier = Modifier.PUBLIC | Modifier.FINAL;
} else {
modifier = Modifier.PUBLIC;
}
field = new SootField(fieldName + "_CGToken", tokenType,
modifier);
theClass.addField(field);
if (isConstant) {
try {
field.addTag(new ValueTag(variable.getToken()));
} catch (Exception ex) {
}
field.addTag(new TypeTag(type));
}
} else {
field = new SootField(fieldName + "_CGExpression",
stringType, Modifier.PUBLIC | Modifier.FINAL);
theClass.addField(field);
String expression = settable.getExpression();
field.addTag(new ValueTag(expression));
}
attributeToValueFieldMap.put(attribute, field);
}