for (int i = 0; i < node.jjtGetNumChildren(); i++) {
argTypes[i] = ((ASTPtRootNode) node.jjtGetChild(i)).getType();
}
// Find the method...
CachedMethod cachedMethod = CachedMethod.findMethod(node
.getMethodName(), argTypes, CachedMethod.METHOD);
if (!cachedMethod.isValid()) {
throw new IllegalActionException("Function " + cachedMethod
+ " not found.");
}
if (cachedMethod instanceof CachedMethod.ArrayMapCachedMethod
|| cachedMethod instanceof CachedMethod.MatrixMapCachedMethod) {
throw new IllegalActionException(
"CodeGeneration not supported for "
+ cachedMethod.getClass());
}
Method method = cachedMethod.getMethod();
// Find the corresponding soot method.
SootMethod sootMethod = SootUtilities.getSootMethodForMethod(method);
// System.out.println("generating code to invoke " + sootMethod);
Local originalBaseLocal = (Local) _nodeToLocal.get(node.jjtGetChild(0));
RefType baseType = RefType.v(sootMethod.getDeclaringClass());
Local baseLocal = Jimple.v().newLocal("base", baseType);
_body.getLocals().add(baseLocal);
if (cachedMethod instanceof CachedMethod.BaseConvertCachedMethod) {
/*RefType tempBaseType =*/PtolemyUtilities
.getSootTypeForTokenType(argTypes[0]);
Local tempBaseLocal = _convertTokenArgToJavaArg(originalBaseLocal,
argTypes[0],
((CachedMethod.BaseConvertCachedMethod) cachedMethod)
.getBaseConversion());
_units.insertBefore(Jimple.v().newAssignStmt(baseLocal,
Jimple.v().newCastExpr(tempBaseLocal, baseType)),
_insertPoint);
} else {
_units.insertBefore(Jimple.v().newAssignStmt(baseLocal,
Jimple.v().newCastExpr(originalBaseLocal, baseType)),
_insertPoint);
}
// The list of locals that are arguments to the function.
List args = new LinkedList();
CachedMethod.ArgumentConversion[] conversions = cachedMethod
.getConversions();
for (int i = 1; i < node.jjtGetNumChildren(); i++) {
Local tokenLocal = (Local) _nodeToLocal.get(node.jjtGetChild(i));