throw new IllegalActionException("The ID " + name
+ " does not have a value");
}
public Local getLocal(String name) throws IllegalActionException {
Local thisLocal = _body.getThisLocal();
if (name.equals("time")) {
throw new RuntimeException("time not supported");
} else if (name.equals("iteration")) {
throw new RuntimeException("iteration not supported");
}
// Local intLocal = Jimple.v().newLocal("intLocal",
// IntType.v());
// _body.getLocals().add(intLocal);
// _units.add(
// Jimple.v().newAssignStmt(intLocal,
// Jimple.v().newInstanceFieldRef(
// thisLocal,
// entityClass.getFieldByName("_iteration"))));
// Local tokenLocal =
// PtolemyUtilities.addTokenLocal(_body, "iterationLocal",
// PtolemyUtilities.intTokenClass,
// PtolemyUtilities.intTokenConstructor,
// intLocal);
// return tokenLocal;
// }
Object identifierReference = _nameToFieldOrLocal.get(name);
if (identifierReference instanceof Local) {
return (Local) identifierReference;
}
if (identifierReference instanceof SootField) {
SootField portField = (SootField) identifierReference;
Local portLocal = Jimple
.v()
.newLocal(
"portToken",
PtolemyUtilities
.getSootTypeForTokenType(getType(name)));
_body.getLocals().add(portLocal);
Local tokenLocal = Jimple.v().newLocal("portToken",
PtolemyUtilities.tokenType);
_body.getLocals().add(tokenLocal);
_units.insertBefore(Jimple.v().newAssignStmt(
tokenLocal,
Jimple.v().newInstanceFieldRef(thisLocal,
portField.makeRef())), _insertPoint);
_units
.insertBefore(
Jimple
.v()
.newAssignStmt(
portLocal,
Jimple
.v()
.newCastExpr(
tokenLocal,
PtolemyUtilities
.getSootTypeForTokenType(getType(name)))),
_insertPoint);
return portLocal;
}
// Look for parameter in actor.
Variable result = null;
if (_entity != null) {
result = getScopedVariable(null, _entity, name);
}
if (result != null) {
// Insert code to get a ref to the variable,
// and to get the token of that variable.
Local containerLocal = Jimple.v().newLocal("container",
RefType.v(PtolemyUtilities.namedObjClass));
_body.getLocals().add(containerLocal);
Local attributeLocal = Jimple.v().newLocal("attribute",
PtolemyUtilities.attributeType);
_body.getLocals().add(attributeLocal);
Local tokenLocal = Jimple.v().newLocal("token",
PtolemyUtilities.tokenType);
_body.getLocals().add(tokenLocal);
Entity entityContainer = FieldsForEntitiesTransformer
.getEntityContainerOfObject(result);
String deepName = result.getName(entityContainer);
_units.insertBefore(Jimple.v().newAssignStmt(containerLocal,
thisLocal), _insertPoint);
NamedObj container = _entity;
while (container != entityContainer) {
Local containerLocal2 = Jimple.v().newLocal("container",
RefType.v(PtolemyUtilities.namedObjClass));
_body.getLocals().add(containerLocal2);
_units.insertBefore(Jimple.v().newAssignStmt(
containerLocal2,
Jimple.v().newVirtualInvokeExpr(