Example #1
0
        public static bool MethodMatch(MethodDefinition candidate, MethodDefinition method)
        {
            if (!candidate.IsVirtual)
            {
                return(false);
            }

            if (candidate.Name != method.Name)
            {
                return(false);
            }

            if (!Helpers.TypeMatch(candidate.ReturnType, method.ReturnType))
            {
                return(false);
            }

            if (candidate.Parameters.Count != method.Parameters.Count)
            {
                return(false);
            }

            for (int i = 0; i < candidate.Parameters.Count; i++)
            {
                if (!Helpers.TypeMatch(candidate.Parameters[i].ParameterType, method.Parameters[i].ParameterType))
                {
                    return(false);
                }
            }

            return(true);
        }
Example #2
0
        public static bool TypeMatch(GenericInstanceType a, GenericInstanceType b)
        {
            if (!Helpers.TypeMatch(a.ElementType, b.ElementType))
            {
                return(false);
            }

            if (a.GenericArguments.Count != b.GenericArguments.Count)
            {
                return(false);
            }

            if (a.GenericArguments.Count == 0)
            {
                return(true);
            }

            for (int i = 0; i < a.GenericArguments.Count; i++)
            {
                if (!Helpers.TypeMatch(a.GenericArguments[i], b.GenericArguments[i]))
                {
                    return(false);
                }
            }

            return(true);
        }
Example #3
0
        public static bool TypeMatch(IModifierType a, IModifierType b)
        {
            if (!Helpers.TypeMatch(a.ModifierType, b.ModifierType))
            {
                return(false);
            }

            return(TypeMatch(a.ElementType, b.ElementType));
        }
Example #4
0
        public static bool TypeMatch(TypeSpecification a, TypeSpecification b)
        {
            if (a is GenericInstanceType)
            {
                return(Helpers.TypeMatch((GenericInstanceType)a, (GenericInstanceType)b));
            }

            if (a is IModifierType)
            {
                return(Helpers.TypeMatch((IModifierType)a, (IModifierType)b));
            }

            return(Helpers.TypeMatch(a.ElementType, b.ElementType));
        }
Example #5
0
        public static bool TypeIsMatch(IEmitter emitter, ResolveResult resolveResult, AstType type, TypeReference typeRef)
        {
            if (typeRef.IsGenericParameter)
            {
                return(true);
            }

            var match = true;

            if (!(resolveResult is ErrorResolveResult) && resolveResult is TypeResolveResult)
            {
                if (((TypeResolveResult)resolveResult).Type.ReflectionName != typeRef.FullName.Replace("<", "[[").Replace(">", "]]").Replace(",", "],["))
                {
                    match = false;
                }
            }
            else
            {
                var isArray = typeRef.ToString().Contains("[]");

                var typeName = isArray ? typeRef.ToString().Replace("[]", "") : typeRef.ToString();
                var name     = emitter.ResolveType(typeName, type);

                var typeDef = emitter.TypeDefinitions[name];

                if ((typeDef.FullName + (isArray ? "[]" : "")) != typeRef.FullName)
                {
                    match = false;
                }
            }

            if (match)
            {
                return(true);
            }

            var type1 = emitter.GetTypeDefinition(type, true);

            if (type1 != null)
            {
                return(Helpers.TypeMatch(type1, typeRef));
            }

            return(true);
        }
Example #6
0
        public static bool TypeMatch(TypeReference a, TypeReference b)
        {
            if (a is GenericParameter)
            {
                return(true);
            }

            if (a is TypeSpecification || b is TypeSpecification)
            {
                if (a.GetType() != b.GetType())
                {
                    return(false);
                }

                return(Helpers.TypeMatch((TypeSpecification)a, (TypeSpecification)b));
            }

            return(a.FullName == b.FullName);
        }
Example #7
0
        public static bool TypeIsMatch(IEmitter emitter, IType type, TypeReference typeRef, IMember member, int index)
        {
            if (type.ReflectionName == typeRef.FullName.Replace("<", "[[").Replace(">", "]]").Replace(",", "],["))
            {
                return(true);
            }

            if (typeRef.IsGenericParameter)
            {
                return(true);
            }

            var type1 = emitter.GetTypeDefinition(type);

            if (type1 != null)
            {
                return(Helpers.TypeMatch(type1, typeRef));
            }

            return(true);
        }