/// <summary> /// Get the method with the specified name and parameter types. /// </summary> public override MethodRef GetMethod(string name, params TypeRefBase[] parameterTypes) { // Look for the method in the type declaration MethodDeclBase found = GetMethod <MethodDeclBase>(name, parameterTypes); if (found != null) { return((MethodRef)found.CreateRef()); } // Look for the method in any base types List <Expression> baseTypes = GetAllBaseTypes(); if (baseTypes != null) { foreach (Expression baseTypeExpression in baseTypes) { TypeRef typeRef = baseTypeExpression.SkipPrefixes() as TypeRef; if (typeRef != null) { MethodRef methodRef = typeRef.GetMethod(name, parameterTypes); if (methodRef != null) { return(methodRef); } } } } // Finally, look for the method in the 'object' base type return(TypeRef.ObjectRef.GetMethod(name, parameterTypes)); }
/// <summary> /// Deep-clone the code object. /// </summary> public override CodeObject Clone() { MethodDeclBase clone = (MethodDeclBase)base.Clone(); clone.CloneField(ref clone._returnType, _returnType); clone.CloneField(ref clone._name, _name); clone._parameters = ChildListHelpers.Clone(_parameters, clone); return(clone); }
/// <summary> /// Get the method with the specified name and parameter types. /// </summary> public virtual MethodRef GetMethod(string name, params TypeRefBase[] parameterTypes) { MethodDeclBase found = GetMethod <MethodDeclBase>(name, parameterTypes); if (found != null) { return((MethodRef)found.CreateRef()); } TypeRef baseRef = GetBaseType(); return(baseRef != null ? baseRef.GetMethod(name, parameterTypes) : null); }
/// <summary> /// Find the parameter on the specified <see cref="MethodDeclBase"/> with the specified name. /// </summary> /// <returns>A <see cref="ParameterRef"/> to the parameter, or an <see cref="UnresolvedRef"/> if no match was found.</returns> public static SymbolicRef Find(MethodDeclBase methodDeclBase, string name, bool isFirstOnLine) { if (methodDeclBase != null) { ParameterRef parameterRef = methodDeclBase.GetParameter(name); if (parameterRef != null) { parameterRef.IsFirstOnLine = isFirstOnLine; return(parameterRef); } } return(new UnresolvedRef(name, isFirstOnLine)); }
/// <summary> /// Get the full name of the <see cref="INamedCodeObject"/>, including any namespace name. /// </summary> /// <param name="descriptive">True to display type parameters and method parameters, otherwise false.</param> public override string GetFullName(bool descriptive) { string name; if (_name is Expression) { name = ((Expression)_name).AsString(); } else { name = ThisRef.ParseToken; } if (descriptive) { name += MethodDeclBase.GetParametersAsString(ParseTokenStart, ParseTokenEnd, _parameters); } if (_parent is TypeDecl) { name = ((TypeDecl)_parent).GetFullName(descriptive) + "." + name; } return(name); }
/// <summary> /// Find the parameter on the specified <see cref="MethodDeclBase"/> with the specified name. /// </summary> /// <returns>A <see cref="ParameterRef"/> to the parameter, or an <see cref="UnresolvedRef"/> if no match was found.</returns> public static SymbolicRef Find(MethodDeclBase methodDeclBase, string name) { return(Find(methodDeclBase, name, false)); }