// Now go over the function names and generate the helper functions and
// QualifiedName constant.
for (final Map.Entry<String, FunctionalAgent> entry : nameToFuncInfo.entrySet()) {
String calFuncName = entry.getKey();
FunctionalAgent functionalAgent = entry.getValue();
CALDocComment cdc = functionalAgent.getCALDocComment();
// We need to make sure the name for the helper function/qualified name field is
// a valid java name.
String javaFuncName = fixupVarName(calFuncName);
// Add a binding method for the CAL function.
// Essentially this method builds an application
// of the function to the supplied arguments using our
// source model.
// Build up the argument names and types.
TypeExpr te = functionalAgent.getTypeExpr();
int nArgs = te.getArity();
int nNamedArgs = functionalAgent.getNArgumentNames();
String paramNames[] = CALDocToJavaDocUtilities.getArgumentNamesFromCALDocComment(cdc, functionalAgent);
if (paramNames.length != nArgs) {
throw new NullPointerException ("Mismatch between arity and number of arguments for " + calFuncName);
}
String origParamNames[] = new String[paramNames.length];
System.arraycopy(paramNames, 0, origParamNames, 0, origParamNames.length);
JavaTypeName paramTypes[] = new JavaTypeName [paramNames.length];
// If we have named arguments we should use those names.
Set<String> paramNamesSet = new HashSet<String>();
for (int i = 0; i < paramNames.length; ++i) {
String name = paramNames[i];
if (name == null) {
if (i < nNamedArgs) {
name = functionalAgent.getArgumentName(i);
}
if (name == null || name.equals("")) {
name = null;
// There is no name for this argument in the functional entity. This