Esempio 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));
        }
Esempio n. 2
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));
        }
Esempio n. 3
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));
        }
Esempio n. 4
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));
        }
Esempio 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));
        }
Esempio n. 6
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));
        }
Esempio n. 7
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));
        }
Esempio n. 8
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));
        }