Exemplo n.º 1
0
        internal override void CheckValid(ValidityContext vctxt, TypeEnvironment typeEnv)
        {
            if (Invalid != null || typeEnv.Type.Invalid != null)
            {
                return;
            }
            var ctxt = MessageContextBuilders.Member(vctxt.Global, typeEnv.Assembly, typeEnv.Type, this);

            if (Add != null)
            {
                Invalid = Add.CheckValid(vctxt, ctxt, typeEnv);
                if (Invalid != null)
                {
                    return;
                }
            }
            if (Remove != null)
            {
                Invalid = Remove.CheckValid(vctxt, ctxt, typeEnv);
                if (Invalid != null)
                {
                    return;
                }
            }
            Invalid = HandlerType.CheckValid(vctxt, ctxt, typeEnv);
            if (Invalid != null)
            {
                return;
            }

            vctxt.ImplementableMemberDef(typeEnv.Assembly, typeEnv.Type, this);
        }
Exemplo n.º 2
0
 internal override InvalidInfo AccumUsedTypeDefs(ValidityContext vctxt, MessageContext ctxt, Set <QualifiedTypeName> usedTypes)
 {
     Fixup(vctxt.Global);
     return
         (Parameters.Select(p => p.AccumUsedTypeDefs(vctxt, ctxt, usedTypes)).FirstOrDefault
              (v => v != null) ?? Result.AccumUsedTypeDefs(vctxt, ctxt, usedTypes));
 }
Exemplo n.º 3
0
        internal override void CheckValid(ValidityContext vctxt, TypeEnvironment typeEnv)
        {
            if (Invalid != null || typeEnv.Type.Invalid != null)
            {
                return;
            }
            var ctxt = MessageContextBuilders.Member(vctxt.Global, typeEnv.Assembly, typeEnv.Type, this);

            if (Get != null)
            {
                Invalid = Get.CheckValid(vctxt, ctxt, typeEnv);
                if (Invalid != null)
                {
                    return;
                }
            }
            if (Set != null)
            {
                Invalid = Set.CheckValid(vctxt, ctxt, typeEnv);
                if (Invalid != null)
                {
                    return;
                }
            }
            Invalid = FieldType.CheckValid(vctxt, ctxt, typeEnv);
            if (Invalid != null)
            {
                vctxt.ImplementableMemberDef(typeEnv.Assembly, typeEnv.Type, this);
            }
        }
Exemplo n.º 4
0
        internal override void AccumUsedTypeAndMemberDefs(ValidityContext vctxt, AssemblyDef assemblyDef, TypeDef typeDef)
        {
            base.AccumUsedTypeAndMemberDefs(vctxt, assemblyDef, typeDef);
            var ctxt = MessageContextBuilders.Member(vctxt.Global, assemblyDef, typeDef, this);

            Invalid = FieldType.AccumUsedTypeDefs(vctxt, ctxt, usedTypes);
        }
Exemplo n.º 5
0
        //
        // Validity
        //

        internal virtual InvalidInfo AccumUsedTypeDefs(ValidityContext vctxt, MessageContext ctxt, Set <QualifiedTypeName> usedTypes)
        {
            var v = DefiningType.AccumUsedTypeDefs(vctxt, ctxt, usedTypes);

            if (v != null)
            {
                return(v);
            }
            v = Signature.AccumUsedTypeDefs(vctxt, ctxt, usedTypes);
            if (v != null)
            {
                return(v);
            }
            var assemblyDef = default(AssemblyDef);
            var typeDef     = default(TypeDef);

            if (DefiningType.PrimTryResolve(vctxt.Global, out assemblyDef, out typeDef))
            {
                if (!typeDef.HasMember(Signature))
                {
                    vctxt.Log
                        (new InvalidMemberRef
                            (ctxt, this, "Defining type does not contain definition for matching member"));
                    return(new InvalidInfo(MessageContextBuilders.Member(vctxt.Global, this)));
                }
            }
            return(null);
        }
Exemplo n.º 6
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.º 7
0
        internal override void AccumUsedTypeAndMemberDefs(ValidityContext vctxt, AssemblyDef assemblyDef, TypeDef typeDef)
        {
            base.AccumUsedTypeAndMemberDefs(vctxt, assemblyDef, typeDef);
            var ctxt = MessageContextBuilders.Member(vctxt.Global, assemblyDef, typeDef, this);

            for (var i = 0; i < TypeParameters.Count; i++)
            {
                var p = TypeParameters[i];
                p.AccumUsedTypeDefs(vctxt, assemblyDef, false);
                if (p.Invalid != null)
                {
                    Invalid = new InvalidInfo(MessageContextBuilders.TypeArg(ParameterFlavor.Method, i), p.Invalid);
                    return;
                }
            }
            foreach (var p in ValueParameters)
            {
                Invalid = p.Type.AccumUsedTypeDefs(vctxt, ctxt, usedTypes);
                if (Invalid != null)
                {
                    return;
                }
            }
            if (Result != null)
            {
                Invalid = Result.Type.AccumUsedTypeDefs(vctxt, ctxt, usedTypes);
                if (Invalid != null)
                {
                    return;
                }
            }

            if (vctxt.IgnoreMethodDefBody(assemblyDef, typeDef, this))
            {
                return;
            }

            foreach (var l in Locals)
            {
                Invalid = l.Type.AccumUsedTypeDefs(vctxt, ctxt, usedTypes);
                if (Invalid != null)
                {
                    return;
                }
            }
            var instructions = Instructions(vctxt.Global);

            if (instructions != null)
            {
                foreach (var i in instructions.Body)
                {
                    Invalid = i.AccumUsedTypeAndMemberDefs(vctxt, ctxt, usedTypes, usedMembers);
                    if (Invalid != null)
                    {
                        return;
                    }
                }
            }
        }
Exemplo n.º 8
0
        internal override InvalidInfo CheckValid(ValidityContext vctxt, MessageContext ctxt, RootEnvironment rootEnv)
        {
            if (Index >= rootEnv.SkolemDefs.Count)
            {
                vctxt.Log(new InvalidTypeRef(ctxt, this, "skolemized type index is out of range"));
                return(new InvalidInfo(MessageContextBuilders.Type(vctxt.Global, this)));
            }

            return(vctxt.ImplementableTypeRef(ctxt, rootEnv, this));
        }
Exemplo n.º 9
0
 internal override InvalidInfo AccumUsedTypeDefs(ValidityContext vctxt, MessageContext ctxt, Set <QualifiedTypeName> usedTypes)
 {
     if (!name.IsResolvable(vctxt.Global, vctxt.Log, ctxt))
     {
         return(new InvalidInfo(MessageContextBuilders.Type(vctxt.Global, this)));
     }
     usedTypes.Add(name);
     return(arguments.Select(a => a.AccumUsedTypeDefs(vctxt, ctxt, usedTypes)).FirstOrDefault
                (v => v != null));
 }
Exemplo n.º 10
0
        internal bool MarkAsUsed(ValidityContext vctxt, AssemblyDef assemblyDef, TypeDef typeDef)
        {
            if (IsUsed || Invalid != null || typeDef.Invalid != null)
            {
                return(false);
            }
            IsUsed = true;

            typeDef.MarkAsUsed(vctxt, assemblyDef);
            if (typeDef.Invalid != null)
            {
                return(true);
            }

            if (usedTypes == null)
            {
                AccumUsedTypeAndMemberDefs(vctxt, assemblyDef, typeDef);
                if (Invalid != null)
                {
                    return(true);
                }
            }

            foreach (var r in UsedTypes)
            {
                var usedAssemblyDef = default(AssemblyDef);
                var usedTypeDef     = default(TypeDef);
                if (r.PrimTryResolve(vctxt.Global, out usedAssemblyDef, out usedTypeDef))
                {
                    usedTypeDef.MarkAsUsed(vctxt, usedAssemblyDef);
                }
            }
            foreach (var r in UsedMembers)
            {
                var usedAssemblyDef = default(AssemblyDef);
                var usedTypeDef     = default(TypeDef);
                var usedMemberDef   = default(MemberDef);
                if (r.PrimTryResolve(vctxt.Global, out usedAssemblyDef, out usedTypeDef, out usedMemberDef))
                {
                    usedMemberDef.MarkAsUsed(vctxt, usedAssemblyDef, usedTypeDef);
                }
            }

            return(true);
        }
Exemplo n.º 11
0
        internal override InvalidInfo CheckValid(ValidityContext vctxt, MessageContext ctxt, RootEnvironment rootEnv)
        {
            var v = arguments.Select(a => a.CheckValid(vctxt, ctxt, rootEnv)).FirstOrDefault(v2 => v2 != null);

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

            var groundArguments = rootEnv.SubstituteTypes(arguments);
            var tyconEnv        = name.Enter(rootEnv);

            if (!tyconEnv.Type.PrimAreValidArguments(vctxt, ctxt, this, tyconEnv.ToGround(), groundArguments))
            {
                return(new InvalidInfo(MessageContextBuilders.Type(vctxt.Global, this)));
            }

            return(vctxt.ImplementableTypeRef(ctxt, rootEnv, this));
        }
Exemplo n.º 12
0
        internal override InvalidInfo CheckValid(ValidityContext vctxt, MessageContext ctxt, RootEnvironment rootEnv)
        {
            switch (ParameterFlavor)
            {
            case ParameterFlavor.Type:
            {
                var typeEnv = rootEnv as TypeEnvironment;
                if (typeEnv == null)
                {
                    throw new InvalidOperationException("not in type environment");
                }
                if (Index >= typeEnv.TypeBoundArguments.Count)
                {
                    vctxt.Log(new InvalidTypeRef(ctxt, this, "type-bound type parameter index is out of range"));
                    return(new InvalidInfo(MessageContextBuilders.Type(vctxt.Global, this)));
                }
                break;
            }

            case ParameterFlavor.Method:
            {
                var methEnv = rootEnv as MethodEnvironment;
                if (methEnv == null)
                {
                    throw new InvalidOperationException("not in method environment");
                }
                if (Index >= methEnv.MethodBoundArguments.Count)
                {
                    vctxt.Log(new InvalidTypeRef(ctxt, this, "method-bound type parameter index is out of range"));
                    return(new InvalidInfo(MessageContextBuilders.Type(vctxt.Global, this)));
                }
                break;
            }

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(vctxt.ImplementableTypeRef(ctxt, rootEnv, this));
        }
Exemplo n.º 13
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.º 14
0
        internal override void AccumUsedTypeAndMemberDefs(ValidityContext vctxt, AssemblyDef assemblyDef, TypeDef typeDef)
        {
            base.AccumUsedTypeAndMemberDefs(vctxt, assemblyDef, typeDef);
            var ctxt = MessageContextBuilders.Member(vctxt.Global, assemblyDef, typeDef, this);

            if (Add != null)
            {
                Invalid = Add.AccumUsedTypeDefs(vctxt, ctxt, usedTypes);
                if (Invalid != null)
                {
                    return;
                }
            }
            if (Remove != null)
            {
                Invalid = Remove.AccumUsedTypeDefs(vctxt, ctxt, usedTypes);
                if (Invalid != null)
                {
                    return;
                }
            }
            Invalid = HandlerType.AccumUsedTypeDefs(vctxt, ctxt, usedTypes);
        }
Exemplo n.º 15
0
        internal override void AccumUsedTypeAndMemberDefs(ValidityContext vctxt, AssemblyDef assemblyDef, TypeDef typeDef)
        {
            base.AccumUsedTypeAndMemberDefs(vctxt, assemblyDef, typeDef);
            var ctxt = MessageContextBuilders.Member(vctxt.Global, assemblyDef, typeDef, this);

            if (Get != null)
            {
                Invalid = Get.AccumUsedTypeDefs(vctxt, ctxt, usedTypes);
                if (Invalid != null)
                {
                    return;
                }
            }
            if (Set != null)
            {
                Invalid = Set.AccumUsedTypeDefs(vctxt, ctxt, usedTypes);
                if (Invalid != null)
                {
                    return;
                }
            }
            Invalid = FieldType.AccumUsedTypeDefs(vctxt, ctxt, usedTypes);
        }
Exemplo n.º 16
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.º 17
0
 internal override InvalidInfo AccumUsedTypeDefs(ValidityContext vctxt, MessageContext ctxt, Set <QualifiedTypeName> usedTypes)
 {
     return(null);
 }
Exemplo n.º 18
0
 internal abstract InvalidInfo CheckValid(ValidityContext vctxt, MessageContext ctxt, RootEnvironment rootEnv);
Exemplo n.º 19
0
 internal override InvalidInfo CheckValid(ValidityContext vctxt, MessageContext ctxt, RootEnvironment rootEnv)
 {
     return(Parameters.Select(p => p.CheckValid(vctxt, ctxt, rootEnv)).FirstOrDefault(v => v != null) ??
            Result.CheckValid(vctxt, ctxt, rootEnv));
 }
Exemplo n.º 20
0
 internal override InvalidInfo AccumUsedTypeDefs(ValidityContext vctxt, MessageContext ctxt, Set <QualifiedTypeName> usedTypes)
 {
     return(base.AccumUsedTypeDefs(vctxt, ctxt, usedTypes) ??
            MethodTypeArguments.Select(a => a.AccumUsedTypeDefs(vctxt, ctxt, usedTypes)).FirstOrDefault
                (v => v != null));
 }
Exemplo n.º 21
0
 internal virtual void AccumUsedTypeAndMemberDefs(ValidityContext vctxt, AssemblyDef assemblyDef, TypeDef typeDef)
 {
     usedTypes   = new Set <QualifiedTypeName>();
     usedMembers = new Set <QualifiedMemberName>();
 }
Exemplo n.º 22
0
 internal virtual InvalidInfo CheckValid(ValidityContext vctxt, MessageContext ctxt, RootEnvironment rootEnv)
 {
     return(DefiningType.CheckValid(vctxt, ctxt, rootEnv));
 }
Exemplo n.º 23
0
 internal abstract void CheckValid(ValidityContext vctxt, TypeEnvironment typeEnv);
Exemplo n.º 24
0
        internal bool MarkAsUsed(ValidityContext vctxt, AssemblyDef assemblyDef, TypeDef typeDef)
        {
            if (IsUsed || Invalid != null || typeDef.Invalid != null)
                return false;
            IsUsed = true;

            typeDef.MarkAsUsed(vctxt, assemblyDef);
            if (typeDef.Invalid != null)
                return true;

            if (usedTypes == null)
            {
                AccumUsedTypeAndMemberDefs(vctxt, assemblyDef, typeDef);
                if (Invalid != null)
                    return true;
            }

            foreach (var r in UsedTypes)
            {
                var usedAssemblyDef = default(AssemblyDef);
                var usedTypeDef = default(TypeDef);
                if (r.PrimTryResolve(vctxt.Global, out usedAssemblyDef, out usedTypeDef))
                    usedTypeDef.MarkAsUsed(vctxt, usedAssemblyDef);
            }
            foreach (var r in UsedMembers)
            {
                var usedAssemblyDef = default(AssemblyDef);
                var usedTypeDef = default(TypeDef);
                var usedMemberDef = default(MemberDef);
                if (r.PrimTryResolve(vctxt.Global, out usedAssemblyDef, out usedTypeDef, out usedMemberDef))
                    usedMemberDef.MarkAsUsed(vctxt, usedAssemblyDef, usedTypeDef);
            }

            return true;
        }
Exemplo n.º 25
0
 internal virtual void AccumUsedTypeAndMemberDefs(ValidityContext vctxt, AssemblyDef assemblyDef, TypeDef typeDef)
 {
     usedTypes = new Set<QualifiedTypeName>();
     usedMembers = new Set<QualifiedMemberName>();
 }
Exemplo n.º 26
0
 internal override void AccumUsedTypeAndMemberDefs(ValidityContext vctxt, AssemblyDef assemblyDef, TypeDef typeDef)
 {
     base.AccumUsedTypeAndMemberDefs(vctxt, assemblyDef, typeDef);
     var ctxt = MessageContextBuilders.Member(vctxt.Global, assemblyDef, typeDef, this);
     if (Add != null)
     {
         Invalid = Add.AccumUsedTypeDefs(vctxt, ctxt, usedTypes);
         if (Invalid != null)
             return;
     }
     if (Remove != null)
     {
         Invalid = Remove.AccumUsedTypeDefs(vctxt, ctxt, usedTypes);
         if (Invalid != null)
             return;
     }
     Invalid = HandlerType.AccumUsedTypeDefs(vctxt, ctxt, usedTypes);
 }
Exemplo n.º 27
0
        internal override void CheckValid(ValidityContext vctxt, TypeEnvironment typeEnv)
        {
            if (Invalid != null || typeEnv.Type.Invalid != null)
                return;

            var methEnv = typeEnv.AddMethod(this).AddSelfMethodBoundArguments();
            for (var i = 0; i < TypeParameters.Count; i++)
            {
                TypeParameters[i].CheckValid(vctxt, methEnv);
                if (TypeParameters[i].Invalid != null)
                {
                    Invalid = new InvalidInfo
                        (MessageContextBuilders.TypeArg(ParameterFlavor.Method, i), TypeParameters[i].Invalid);
                    return;
                }
            }
            var ctxt = MessageContextBuilders.Member(vctxt.Global, typeEnv.Assembly, typeEnv.Type, this);
            foreach (var p in ValueParameters)
            {
                Invalid = p.Type.CheckValid(vctxt, ctxt, methEnv);
                if (Invalid != null)
                    return;
            }
            if (Result != null)
            {
                Invalid = Result.Type.CheckValid(vctxt, ctxt, methEnv);
                if (Invalid != null)
                    return;
            }

            if (vctxt.IgnoreMethodDefBody(typeEnv.Assembly, typeEnv.Type, this))
                return;

            foreach (var l in Locals)
            {
                Invalid = l.Type.CheckValid(vctxt, ctxt, methEnv);
                if (Invalid != null)
                    return;
            }
            var instructions = Instructions(vctxt.Global);
            if (instructions != null)
            {
                foreach (var i in instructions.Body)
                {
                    Invalid = i.CheckValid(vctxt, ctxt, methEnv);
                    if (Invalid != null)
                        return;
                    Invalid = vctxt.ImplementableInstruction(ctxt, methEnv.Assembly, methEnv.Type, this, i);
                    if (Invalid != null)
                        return;
                }
            }

            vctxt.ImplementableMemberDef(typeEnv.Assembly, typeEnv.Type, this);
        }
Exemplo n.º 28
0
 internal override void AccumUsedTypeAndMemberDefs(ValidityContext vctxt, AssemblyDef assemblyDef, TypeDef typeDef)
 {
     base.AccumUsedTypeAndMemberDefs(vctxt, assemblyDef, typeDef);
     var ctxt = MessageContextBuilders.Member(vctxt.Global, assemblyDef, typeDef, this);
     if (Get != null)
     {
         Invalid = Get.AccumUsedTypeDefs(vctxt, ctxt, usedTypes);
         if (Invalid != null)
             return;
     }
     if (Set != null)
     {
         Invalid = Set.AccumUsedTypeDefs(vctxt, ctxt, usedTypes);
         if (Invalid != null)
             return;
     }
     Invalid = FieldType.AccumUsedTypeDefs(vctxt, ctxt, usedTypes);
 }
Exemplo n.º 29
0
        internal override void CheckValid(ValidityContext vctxt, TypeEnvironment typeEnv)
        {
            if (Invalid != null || typeEnv.Type.Invalid != null)
            {
                return;
            }

            var methEnv = typeEnv.AddMethod(this).AddSelfMethodBoundArguments();

            for (var i = 0; i < TypeParameters.Count; i++)
            {
                TypeParameters[i].CheckValid(vctxt, methEnv);
                if (TypeParameters[i].Invalid != null)
                {
                    Invalid = new InvalidInfo
                                  (MessageContextBuilders.TypeArg(ParameterFlavor.Method, i), TypeParameters[i].Invalid);
                    return;
                }
            }
            var ctxt = MessageContextBuilders.Member(vctxt.Global, typeEnv.Assembly, typeEnv.Type, this);

            foreach (var p in ValueParameters)
            {
                Invalid = p.Type.CheckValid(vctxt, ctxt, methEnv);
                if (Invalid != null)
                {
                    return;
                }
            }
            if (Result != null)
            {
                Invalid = Result.Type.CheckValid(vctxt, ctxt, methEnv);
                if (Invalid != null)
                {
                    return;
                }
            }

            if (vctxt.IgnoreMethodDefBody(typeEnv.Assembly, typeEnv.Type, this))
            {
                return;
            }

            foreach (var l in Locals)
            {
                Invalid = l.Type.CheckValid(vctxt, ctxt, methEnv);
                if (Invalid != null)
                {
                    return;
                }
            }
            var instructions = Instructions(vctxt.Global);

            if (instructions != null)
            {
                foreach (var i in instructions.Body)
                {
                    Invalid = i.CheckValid(vctxt, ctxt, methEnv);
                    if (Invalid != null)
                    {
                        return;
                    }
                    Invalid = vctxt.ImplementableInstruction(ctxt, methEnv.Assembly, methEnv.Type, this, i);
                    if (Invalid != null)
                    {
                        return;
                    }
                }
            }

            vctxt.ImplementableMemberDef(typeEnv.Assembly, typeEnv.Type, this);
        }
Exemplo n.º 30
0
 internal override void CheckValid(ValidityContext vctxt, TypeEnvironment typeEnv)
 {
     if (Invalid != null || typeEnv.Type.Invalid != null)
         return;
     var ctxt = MessageContextBuilders.Member(vctxt.Global, typeEnv.Assembly, typeEnv.Type, this);
     if (Get != null)
     {
         Invalid = Get.CheckValid(vctxt, ctxt, typeEnv);
         if (Invalid != null)
             return;
     }
     if (Set != null)
     {
         Invalid = Set.CheckValid(vctxt, ctxt, typeEnv);
         if (Invalid != null)
             return;
     }
     Invalid = FieldType.CheckValid(vctxt, ctxt, typeEnv);
     if (Invalid != null)
         vctxt.ImplementableMemberDef(typeEnv.Assembly, typeEnv.Type, this);
 }
Exemplo n.º 31
0
        //
        // Validity
        //

        // Accumulate all the type definitions used by type. Return a validity info if any type ref cannot be resolved
        // to a type def. Otherwise return null.
        internal abstract InvalidInfo AccumUsedTypeDefs(ValidityContext vctxt, MessageContext ctxt, Set <QualifiedTypeName> usedTypes);
Exemplo n.º 32
0
        internal override void AccumUsedTypeAndMemberDefs(ValidityContext vctxt, AssemblyDef assemblyDef, TypeDef typeDef)
        {
            base.AccumUsedTypeAndMemberDefs(vctxt, assemblyDef, typeDef);
            var ctxt = MessageContextBuilders.Member(vctxt.Global, assemblyDef, typeDef, this);
            for (var i = 0; i < TypeParameters.Count; i++)
            {
                var p = TypeParameters[i];
                p.AccumUsedTypeDefs(vctxt, assemblyDef, false);
                if (p.Invalid != null)
                {
                    Invalid = new InvalidInfo(MessageContextBuilders.TypeArg(ParameterFlavor.Method, i), p.Invalid);
                    return;
                }
            }
            foreach (var p in ValueParameters)
            {
                Invalid = p.Type.AccumUsedTypeDefs(vctxt, ctxt, usedTypes);
                if (Invalid != null)
                    return;
            }
            if (Result != null)
            {
                Invalid = Result.Type.AccumUsedTypeDefs(vctxt, ctxt, usedTypes);
                if (Invalid != null)
                    return;
            }

            if (vctxt.IgnoreMethodDefBody(assemblyDef, typeDef, this))
                return;

            foreach (var l in Locals)
            {
                Invalid = l.Type.AccumUsedTypeDefs(vctxt, ctxt, usedTypes);
                if (Invalid != null)
                    return;
            }
            var instructions = Instructions(vctxt.Global);
            if (instructions != null)
            {
                foreach (var i in instructions.Body)
                {
                    Invalid = i.AccumUsedTypeAndMemberDefs(vctxt, ctxt, usedTypes, usedMembers);
                    if (Invalid != null)
                        return;
                }
            }
        }
Exemplo n.º 33
0
 internal override InvalidInfo CheckValid(ValidityContext vctxt, MessageContext ctxt, RootEnvironment rootEnv)
 {
     return(null);
 }
Exemplo n.º 34
0
 internal override void AccumUsedTypeAndMemberDefs(ValidityContext vctxt, AssemblyDef assemblyDef, TypeDef typeDef)
 {
     base.AccumUsedTypeAndMemberDefs(vctxt, assemblyDef, typeDef);
     var ctxt = MessageContextBuilders.Member(vctxt.Global, assemblyDef, typeDef, this);
     Invalid = FieldType.AccumUsedTypeDefs(vctxt, ctxt, usedTypes);
 }
Exemplo n.º 35
0
 internal abstract void CheckValid(ValidityContext vctxt, TypeEnvironment typeEnv);
Exemplo n.º 36
0
        internal override void CheckValid(ValidityContext vctxt, TypeEnvironment typeEnv)
        {
            if (Invalid != null || typeEnv.Type.Invalid != null)
                return;
            var ctxt = MessageContextBuilders.Member(vctxt.Global, typeEnv.Assembly, typeEnv.Type, this);
            if (Add != null)
            {
                Invalid = Add.CheckValid(vctxt, ctxt, typeEnv);
                if (Invalid != null)
                    return;
            }
            if (Remove != null)
            {
                Invalid = Remove.CheckValid(vctxt, ctxt, typeEnv);
                if (Invalid != null)
                    return;
            }
            Invalid = HandlerType.CheckValid(vctxt, ctxt, typeEnv);
            if (Invalid != null)
                return;

            vctxt.ImplementableMemberDef(typeEnv.Assembly, typeEnv.Type, this);
        }
Exemplo n.º 37
0
 internal override InvalidInfo CheckValid(ValidityContext vctxt, MessageContext ctxt, RootEnvironment rootEnv)
 {
     return(FieldType.CheckValid(vctxt, ctxt, rootEnv));
 }