final INamespaceReference namespaceReference = getNamespaceReference(name);
methodDef.setNamespaceReference(namespaceReference);
int paramTypesSize = method.getParamTypes().size();
final ParameterDefinition params[] = new ParameterDefinition[paramTypesSize + (method.needsRest() ? 1 : 0)];
if (params.length > 0)
{
ASScope methodScope = new FunctionScope(scope);
methodScope.setContainingDefinition(methodDef);
methodDef.setContainedScope(methodScope);
Vector<PooledValue> defaultValues = method.getDefaultValues();
int firstOptionalParam = paramTypesSize - defaultValues.size();
for (int i = 0; i < paramTypesSize; i++)
{
final Name paramType = method.getParamTypes().get(i);
final String paramName = i < method.getParamNames().size() ? method.getParamNames().get(i) : MethodInfo.UNKNOWN_PARAM_NAME;
params[i] = new ParameterDefinition(paramName);
params[i].setTypeReference(paramType == null ? TYPE_ANY : scopeBuilder.getReference(paramType));
if (i >= firstOptionalParam)
{
Object defaultValue = defaultValues.get(i - firstOptionalParam).getValue();
params[i].setDefaultValue(defaultValue);
}
methodScope.addDefinition(params[i]);
}
if( method.needsRest() )
{
ParameterDefinition rest = new ParameterDefinition(MethodInfo.UNKNOWN_PARAM_NAME);
rest.setRest();
rest.setTypeReference(ReferenceFactory.builtinReference(IASLanguageConstants.BuiltinType.ARRAY));
params[paramTypesSize] = rest;
}
}
methodDef.setParameters(params);