if (value instanceof InstanceInvokeExpr) {
InstanceInvokeExpr r = (InstanceInvokeExpr) value;
if (r.getBase().getType() instanceof RefType) {
RefType type = (RefType) r.getBase().getType();
// Inline calls to connections changed.
if (r.getMethod().equals(
PtolemyUtilities.connectionsChangedMethod)) {
// If we are calling connections changed on one of the classes
// we are generating code for, then inline it.
if (type.getSootClass().isApplicationClass()) {
SootMethod inlinee = null;
if (r instanceof VirtualInvokeExpr) {
// Now inline the resulting call.
List methodList = Scene
.v()
.getActiveHierarchy()
.resolveAbstractDispatch(
type.getSootClass(),
PtolemyUtilities.connectionsChangedMethod);
if (methodList.size() == 1) {
// Inline the method.
inlinee = (SootMethod) methodList.get(0);
} else {
String string = "Can't inline " + stmt
+ " in method " + method + "\n";
for (int i = 0; i < methodList.size(); i++) {
string += ("target = "
+ methodList.get(i) + "\n");
}
System.out.println(string);
}
} else if (r instanceof SpecialInvokeExpr) {
inlinee = Scene.v().getActiveHierarchy()
.resolveSpecialDispatch(
(SpecialInvokeExpr) r, method);
}
if (inlinee != null
&& !inlinee.getDeclaringClass()
.isApplicationClass()) {
inlinee.getDeclaringClass().setLibraryClass();
}
inlinee.retrieveActiveBody();
if (debug) {
System.out
.println("Inlining method call: " + r);
}
SiteInliner.inlineSite(inlinee, stmt, method);
doneSomething = true;
} else {
// FIXME: this is a bit of a hack, but
// for right now it seems to work.
// How many things that aren't
// the actors we are generating
// code for do we really care about here?
// Can we do this without having to create
// a class for the port too????
body.getUnits().remove(stmt);
doneSomething = true;
}
}
// Statically evaluate constant arguments.
Value[] argValues = new Value[r.getArgCount()];
int constantArgCount = 0;
for (Iterator args = r.getArgs().iterator(); args.hasNext();) {
Value arg = (Value) args.next();
//System.out.println("arg = " + arg);
if (Evaluator.isValueConstantValued(arg)) {
argValues[constantArgCount++] = Evaluator
.getConstantValueOf(arg);
// System.out.println("argument = " + argValues[argCount-1]);
} else {
break;
}
}
//boolean allArgsAreConstant = (r.getArgCount() == constantArgCount);
if (SootUtilities.derivesFrom(type.getSootClass(),
PtolemyUtilities.componentPortClass)) {
// If we are invoking a method on a port
// class, then attempt to get the constant
// value of the port.
TypedIOPort port = (TypedIOPort) analysis