Exemplo n.º 1
0
        internal override InvalidInfo CheckValid(ValidityContext vctxt, MessageContext ctxt, RootEnvironment rootEnv)
        {
            var v = base.CheckValid(vctxt, ctxt, rootEnv);

            if (v != null)
            {
                return(v);
            }
            var typeEnv   = DefiningType.Enter(rootEnv);
            var methodDef = typeEnv.Type.ResolveMethod(signature);

            if (methodDef == null)
            {
                vctxt.Log(new InvalidMemberRef(ctxt, this, "No such method in defining type"));
                return(new InvalidInfo(MessageContextBuilders.Member(vctxt.Global, this)));
            }
            var methEnv = typeEnv.AddMethod(methodDef).AddSelfMethodBoundArguments();

            v = signature.CheckValid(vctxt, ctxt, methEnv);
            if (v != null)
            {
                return(v);
            }

            return(vctxt.ImplementableMemberRef(ctxt, rootEnv, this));
        }
Exemplo n.º 2
0
 /// <inheritdoc />
 public override int GetHashCode()
 {
     unchecked
     {
         var hash = DefiningType.GetHashCode() * 397;
         hash ^= StringComparer.Ordinal.GetHashCode(Name);
         return(hash);
     }
 }
Exemplo n.º 3
0
        public override MemberRef Generalize(RootEnvironment rootEnv)
        {
            var methodTypeArguments = default(Seq <TypeRef>);

            if (MethodTypeArguments.Count > 0)
            {
                methodTypeArguments = MethodTypeArguments.Select(t => t.Generalize(rootEnv)).ToSeq();
            }
            return(new MethodRef(Annotations, DefiningType.Generalize(rootEnv), signature, methodTypeArguments));
        }
Exemplo n.º 4
0
        public PropertyEnvironment Enter(RootEnvironment rootEnv)
        {
            var typeEnv = DefiningType.Enter(rootEnv);
            var propDef = typeEnv.Type.ResolveProperty(signature);

            if (propDef == null)
            {
                throw new InvalidOperationException("unable to resolve property reference");
            }
            return(typeEnv.AddProperty(propDef));
        }
Exemplo n.º 5
0
        public PolymorphicMethodEnvironment Enter(RootEnvironment rootEnv)
        {
            var typeEnv   = DefiningType.Enter(rootEnv);
            var methodDef = typeEnv.Type.ResolveMethod(signature);

            if (methodDef == null)
            {
                throw new InvalidOperationException("unable to resolve polymorphic method reference");
            }
            return(typeEnv.AddMethod(methodDef));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Determines whether this instance of <see cref="FieldId"/> refers to the same field as <paramref name="other"/>.
        /// </summary>
        public bool Equals(FieldId?other)
        {
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return(other != null &&
                   DefiningType.Equals(other.DefiningType) &&
                   StringComparer.Ordinal.Equals(Name, other.Name));
        }
Exemplo n.º 7
0
        public EventEnvironment Enter(RootEnvironment rootEnv)
        {
            var typeEnv  = DefiningType.Enter(rootEnv);
            var eventDef = typeEnv.Type.ResolveEvent(signature);

            if (eventDef == null)
            {
                throw new InvalidOperationException("unable to resolve event reference");
            }
            return(typeEnv.AddEvent(eventDef));
        }
Exemplo n.º 8
0
        public FieldEnvironment Enter(RootEnvironment rootEnv)
        {
            var typeEnv  = DefiningType.Enter(rootEnv);
            var fieldDef = typeEnv.Type.ResolveField(signature);

            if (fieldDef == null)
            {
                throw new InvalidOperationException("unable to resolve field reference");
            }
            return(typeEnv.AddField(fieldDef));
        }
Exemplo n.º 9
0
        public MethodEnvironment EnterMethod(RootEnvironment rootEnv)
        {
            var typeEnv   = DefiningType.Enter(rootEnv);
            var methodDef = typeEnv.Type.ResolveMethod(signature);

            if (methodDef == null)
            {
                throw new InvalidOperationException("unable to resolve method reference");
            }
            var groundArguments = rootEnv.SubstituteTypes(MethodTypeArguments);

            return(typeEnv.AddMethod(methodDef).AddMethodBoundArguments(groundArguments));
        }
Exemplo n.º 10
0
        /// <inheritdoc />
        public override int GetHashCode()
        {
            unchecked
            {
                var hash = DefiningType.GetHashCode() * 397;
                hash ^= StringComparer.Ordinal.GetHashCode(Name);

                foreach (var parameter in Parameters)
                {
                    hash ^= parameter.GetHashCode();
                }

                return(hash);
            }
        }
Exemplo n.º 11
0
        public override MemberRef PrimSubstitute(IImSeq <TypeRef> typeBoundArguments, IImSeq <TypeRef> methodBoundArguments)
        {
            var methodTypeArguments = default(Seq <TypeRef>);

            if (MethodTypeArguments.Count > 0)
            {
                methodTypeArguments =
                    MethodTypeArguments.Select(type => type.PrimSubstitute(typeBoundArguments, methodBoundArguments)).
                    ToSeq();
            }
            return(new MethodRef
                       (Annotations,
                       DefiningType.PrimSubstitute(typeBoundArguments, methodBoundArguments),
                       signature,
                       methodTypeArguments));
        }
Exemplo n.º 12
0
        /// <summary>
        /// Determines whether this instance of <see cref="PropertyId"/> refers to the same property of indexer as <paramref name="other"/>.
        /// </summary>
        public bool Equals(PropertyId?other)
        {
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            if (other == null)
            {
                return(false);
            }

            return(DefiningType.Equals(other.DefiningType) &&
                   StringComparer.Ordinal.Equals(Name, other.Name) &&
                   Parameters.Count == other.Parameters.Count &&
                   Parameters.SequenceEqual(other.Parameters));
        }
Exemplo n.º 13
0
        /// <summary>
        /// Determines whether this instance of <see cref="MethodId"/> refers to the same method as <paramref name="other"/>.
        /// </summary>
        public bool Equals(MethodId?other)
        {
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            if (other == null)
            {
                return(false);
            }

            return(DefiningType.Equals(other.DefiningType) &&
                   StringComparer.Ordinal.Equals(Name, other.Name) &&
                   Arity == other.Arity &&
                   Parameters.SequenceEqual(other.Parameters) &&
                   (
                       (ReturnType == null && other.ReturnType == null) ||
                       (ReturnType != null && ReturnType.Equals(other.ReturnType))
                   ));
        }
Exemplo n.º 14
0
        internal override InvalidInfo CheckValid(ValidityContext vctxt, MessageContext ctxt, RootEnvironment rootEnv)
        {
            var v = base.CheckValid(vctxt, ctxt, rootEnv);

            if (v != null)
            {
                return(v);
            }
            if (MethodTypeArguments.Count != MethodTypeArity)
            {
                vctxt.Log
                    (new InvalidMemberRef
                        (ctxt,
                        this,
                        String.Format
                            ("Polymorphic method has {0} type parameters but is applied to {1} type arguments",
                            MethodTypeArity,
                            MethodTypeArguments.Count)));
                return(new InvalidInfo(MessageContextBuilders.Member(vctxt.Global, this)));
            }

            v = MethodTypeArguments.Select(t => t.CheckValid(vctxt, ctxt, rootEnv)).FirstOrDefault(v2 => v2 != null);
            if (v != null)
            {
                return(v);
            }
            var groundMethodTypeArguments = rootEnv.SubstituteTypes(MethodTypeArguments);
            var typeEnv   = DefiningType.Enter(rootEnv);
            var methodDef = typeEnv.Type.ResolveMethod(signature);

            if (methodDef == null)
            {
                throw new InvalidOperationException("unable to resolve method");
            }
            var methEnv = typeEnv.AddMethod(methodDef).AddMethodBoundArguments(groundMethodTypeArguments);

            return(signature.CheckValid(vctxt, ctxt, methEnv));
        }
Exemplo n.º 15
0
        internal override InvalidInfo CheckValid(ValidityContext vctxt, MessageContext ctxt, RootEnvironment rootEnv)
        {
            var v = base.CheckValid(vctxt, ctxt, rootEnv);

            if (v != null)
            {
                return(v);
            }

            var typeEnv  = DefiningType.Enter(rootEnv);
            var eventDef = typeEnv.Type.ResolveMember(signature);

            if (eventDef == null)
            {
                throw new InvalidOperationException("unable to resolve event");
            }
            v = signature.CheckValid(vctxt, ctxt, typeEnv);
            if (v != null)
            {
                return(v);
            }

            return(vctxt.ImplementableMemberRef(ctxt, rootEnv, this));
        }
Exemplo n.º 16
0
 public override MemberRef ToConstructor()
 {
     return(new EventRef(Annotations, DefiningType.ToConstructor(), signature));
 }
Exemplo n.º 17
0
 public override MemberRef Generalize(RootEnvironment rootEnv)
 {
     return(new EventRef(Annotations, DefiningType.Generalize(rootEnv), signature));
 }
Exemplo n.º 18
0
 public override MemberRef PrimSubstitute(IImSeq <TypeRef> typeBoundArguments, IImSeq <TypeRef> methodBoundArguments)
 {
     return(new EventRef(Annotations, DefiningType.PrimSubstitute(typeBoundArguments, methodBoundArguments), signature));
 }
Exemplo n.º 19
0
 public override void Append(CSTWriter w)
 {
     DefiningType.Append(w);
     w.Append("::");
     signature.Append(w, MethodTypeArguments);
 }
Exemplo n.º 20
0
 public override MemberRef ToConstructor()
 {
     return(new PolymorphicMethodRef(Annotations, DefiningType.ToConstructor(), signature));
 }