Example #1
0
        public static MethodDefinition GetMethodDefinition(IEmitter emitter, MethodDeclaration methodDeclaration, TypeDefinition type)
        {
            var parameters = methodDeclaration.Parameters.ToList();
            var methods    = type.Methods.Where(m => m.Name == methodDeclaration.Name && m.Parameters.Count == parameters.Count && m.GenericParameters.Count == methodDeclaration.TypeParameters.Count).ToList();

            if (methods.Count <= 1)
            {
                return(methods.Count == 1 ? methods[0] : null);
            }

            return(Helpers.FindMethodDefinitionInGroup(emitter, parameters, null, methods, methodDeclaration.ReturnType, type));
        }
Example #2
0
        public static MethodDefinition GetMethodDefinition(IEmitter emitter, OperatorDeclaration operatorDeclaration, TypeDefinition type)
        {
            var parameters = operatorDeclaration.Parameters.ToList();
            var ops        = type.Methods.Where(m => m.Name == operatorDeclaration.Name && m.Parameters.Count == parameters.Count).ToList();

            if (ops.Count <= 1)
            {
                return(ops.Count == 1 ? ops[0] : null);
            }

            return(Helpers.FindMethodDefinitionInGroup(emitter, parameters, null, ops, operatorDeclaration.ReturnType, type));
        }
Example #3
0
        public static MethodDefinition GetMethodDefinition(IEmitter emitter, IParameterizedMember member, TypeDefinition type)
        {
            var imethod    = member as IMethod;
            var parameters = member.Parameters.ToList();
            var methods    = type.Methods.Where(m => m.Name == member.Name && m.Parameters.Count == parameters.Count && ((imethod != null && m.GenericParameters.Count == imethod.TypeParameters.Count) || imethod == null)).ToList();

            if (methods.Count <= 1)
            {
                return(methods.Count == 1 ? methods[0] : null);
            }
            return(Helpers.FindMethodDefinitionInGroup(emitter, parameters, null, methods, member.ReturnType, type, member));
        }