예제 #1
0
        // Initializes a substitution context. Returns false iff no substitutions will ever be performed.
        private void Init(TypeArray typeArgsCls, TypeArray typeArgsMeth, SubstTypeFlags grfst)
        {
            if (typeArgsCls != null)
            {
#if DEBUG
                typeArgsCls.AssertValid();
#endif
                ctypeCls   = typeArgsCls.size;
                prgtypeCls = typeArgsCls.ToArray();
            }
            else
            {
                ctypeCls   = 0;
                prgtypeCls = null;
            }

            if (typeArgsMeth != null)
            {
#if DEBUG
                typeArgsMeth.AssertValid();
#endif

                ctypeMeth   = typeArgsMeth.size;
                prgtypeMeth = typeArgsMeth.ToArray();
            }
            else
            {
                ctypeMeth   = 0;
                prgtypeMeth = null;
            }

            this.grfst = grfst;
        }
예제 #2
0
        // Initializes a substitution context. Returns false iff no substitutions will ever be performed.
        public void Init(TypeArray typeArgsCls, TypeArray typeArgsMeth, SubstTypeFlags grfst)
        {
            if (typeArgsCls != null)
            {
#if DEBUG
                typeArgsCls.AssertValid();
#endif
                ctypeCls = typeArgsCls.size;
                prgtypeCls = typeArgsCls.ToArray();
            }
            else
            {
                ctypeCls = 0;
                prgtypeCls = null;
            }

            if (typeArgsMeth != null)
            {
#if DEBUG
                typeArgsMeth.AssertValid();
#endif

                ctypeMeth = typeArgsMeth.size;
                prgtypeMeth = typeArgsMeth.ToArray();
            }
            else
            {
                ctypeMeth = 0;
                prgtypeMeth = null;
            }

            this.grfst = grfst;
        }
예제 #3
0
        // Initializes a substitution context. Returns false iff no substitutions will ever be performed.
        private void Init(TypeArray typeArgsCls, TypeArray typeArgsMeth, SubstTypeFlags grfst)
        {
            if (typeArgsCls != null)
            {
                typeArgsCls.AssertValid();
                ctypeCls   = typeArgsCls.Count;
                prgtypeCls = typeArgsCls.Items;
            }
            else
            {
                ctypeCls   = 0;
                prgtypeCls = null;
            }

            if (typeArgsMeth != null)
            {
                typeArgsMeth.AssertValid();
                ctypeMeth   = typeArgsMeth.Count;
                prgtypeMeth = typeArgsMeth.Items;
            }
            else
            {
                ctypeMeth   = 0;
                prgtypeMeth = null;
            }

            this.grfst = grfst;
        }
예제 #4
0
 public SubstContext(CType[] prgtypeCls, int ctypeCls, CType[] prgtypeMeth, int ctypeMeth, SubstTypeFlags grfst)
 {
     this.prgtypeCls = prgtypeCls;
     this.ctypeCls = ctypeCls;
     this.prgtypeMeth = prgtypeMeth;
     this.ctypeMeth = ctypeMeth;
     this.grfst = grfst;
 }
예제 #5
0
 private SubstContext(CType[] prgtypeCls, int ctypeCls, CType[] prgtypeMeth, int ctypeMeth, SubstTypeFlags grfst)
 {
     this.prgtypeCls  = prgtypeCls;
     this.ctypeCls    = ctypeCls;
     this.prgtypeMeth = prgtypeMeth;
     this.ctypeMeth   = ctypeMeth;
     this.grfst       = grfst;
 }
예제 #6
0
 private SubstContext(AggregateType type, TypeArray typeArgsMeth, SubstTypeFlags grfst)
 {
     Init(type?.GetTypeArgsAll(), typeArgsMeth, grfst);
 }
예제 #7
0
 public SubstContext(TypeArray typeArgsCls, TypeArray typeArgsMeth, SubstTypeFlags grfst)
 {
     Init(typeArgsCls, typeArgsMeth, grfst);
 }
예제 #8
0
 public SubstContext(AggregateType type, TypeArray typeArgsMeth, SubstTypeFlags grfst)
 {
     Init(type != null ? type.GetTypeArgsAll() : null, typeArgsMeth, grfst);
 }
예제 #9
0
        public bool SubstEqualTypeArrays(TypeArray taDst, TypeArray taSrc, TypeArray typeArgsCls, TypeArray typeArgsMeth, SubstTypeFlags grfst)
        {
            // Handle the simple common cases first.
            if (taDst == taSrc || (taDst != null && taDst.Equals(taSrc)))
            {
                // The following assertion is not always true and indicates a problem where
                // the signature of override method does not match the one inherited from
                // the base class. The method match we have found does not take the type
                // arguments of the base class into account. So actually we are not overriding
                // the method that we "intend" to.
                // Debug.Assert(taDst == SubstTypeArray(taSrc, typeArgsCls, typeArgsMeth, grfst));
                return(true);
            }
            if (taDst.Count != taSrc.Count)
            {
                return(false);
            }
            if (taDst.Count == 0)
            {
                return(true);
            }

            var ctx = new SubstContext(typeArgsCls, typeArgsMeth, grfst);

            if (ctx.FNop())
            {
                return(false);
            }

            for (int i = 0; i < taDst.Count; i++)
            {
                if (!SubstEqualTypesCore(taDst[i], taSrc[i], ctx))
                {
                    return(false);
                }
            }

            return(true);
        }
예제 #10
0
        public bool SubstEqualTypes(CType typeDst, CType typeSrc, TypeArray typeArgsCls, TypeArray typeArgsMeth, SubstTypeFlags grfst)
        {
            if (typeDst.Equals(typeSrc))
            {
                Debug.Assert(typeDst.Equals(SubstType(typeSrc, typeArgsCls, typeArgsMeth, grfst)));
                return(true);
            }

            var ctx = new SubstContext(typeArgsCls, typeArgsMeth, grfst);

            return(!ctx.FNop() && SubstEqualTypesCore(typeDst, typeSrc, ctx));
        }
예제 #11
0
 public SubstContext(AggregateType type, TypeArray typeArgsMeth, SubstTypeFlags grfst)
 {
     Init(type != null ? type.GetTypeArgsAll() : null, typeArgsMeth, grfst);
 }
예제 #12
0
        private CType SubstType(CType typeSrc, TypeArray typeArgsCls, TypeArray typeArgsMeth, SubstTypeFlags grfst)
        {
            if (typeSrc == null)
            {
                return(null);
            }

            var ctx = new SubstContext(typeArgsCls, typeArgsMeth, grfst);

            return(ctx.FNop() ? typeSrc : SubstTypeCore(typeSrc, ctx));
        }
예제 #13
0
        public bool SubstEqualTypeArrays(TypeArray taDst, TypeArray taSrc, TypeArray typeArgsCls, TypeArray typeArgsMeth, SubstTypeFlags grfst)
        {
            // Handle the simple common cases first.
            if (taDst == taSrc || (taDst != null && taDst.Equals(taSrc)))
            {
                // The following assertion is not always true and indicates a problem where
                // the signature of override method does not match the one inherited from
                // the base class. The method match we have found does not take the type 
                // arguments of the base class into account. So actually we are not overriding
                // the method that we "intend" to. 
                // Debug.Assert(taDst == SubstTypeArray(taSrc, typeArgsCls, typeArgsMeth, grfst));
                return true;
            }
            if (taDst.Size != taSrc.Size)
                return false;
            if (taDst.Size == 0)
                return true;

            var ctx = new SubstContext(typeArgsCls, typeArgsMeth, grfst);

            if (ctx.FNop())
                return false;

            for (int i = 0; i < taDst.size; i++)
            {
                if (!SubstEqualTypesCore(taDst.Item(i), taSrc.Item(i), ctx))
                    return false;
            }

            return true;
        }
예제 #14
0
        public bool SubstEqualTypes(CType typeDst, CType typeSrc, TypeArray typeArgsCls, TypeArray typeArgsMeth, SubstTypeFlags grfst)
        {
            if (typeDst.Equals(typeSrc))
            {
                Debug.Assert(typeDst.Equals(SubstType(typeSrc, typeArgsCls, typeArgsMeth, grfst)));
                return true;
            }

            var ctx = new SubstContext(typeArgsCls, typeArgsMeth, grfst);

            return !ctx.FNop() && SubstEqualTypesCore(typeDst, typeSrc, ctx);
        }
예제 #15
0
        public TypeArray SubstTypeArray(TypeArray taSrc, TypeArray typeArgsCls, TypeArray typeArgsMeth, SubstTypeFlags grfst)
        {
            if (taSrc == null || taSrc.Size == 0)
                return taSrc;

            var ctx = new SubstContext(typeArgsCls, typeArgsMeth, grfst);

            if (ctx.FNop())
                return taSrc;

            CType[] prgpts = new CType[taSrc.Size];
            for (int ipts = 0; ipts < taSrc.Size; ipts++)
            {
                prgpts[ipts] = SubstTypeCore(taSrc.Item(ipts), ctx);
            }
            return _BSymmgr.AllocParams(taSrc.Size, prgpts);
        }
예제 #16
0
        public CType SubstType(CType typeSrc, TypeArray typeArgsCls, TypeArray typeArgsMeth, SubstTypeFlags grfst)
        {
            if (typeSrc == null)
                return null;

            var ctx = new SubstContext(typeArgsCls, typeArgsMeth, grfst);
            return ctx.FNop() ? typeSrc : SubstTypeCore(typeSrc, ctx);
        }
예제 #17
0
        private TypeArray SubstTypeArray(TypeArray taSrc, TypeArray typeArgsCls, TypeArray typeArgsMeth, SubstTypeFlags grfst)
        {
            if (taSrc == null || taSrc.Count == 0)
            {
                return(taSrc);
            }

            var ctx = new SubstContext(typeArgsCls, typeArgsMeth, grfst);

            if (ctx.FNop())
            {
                return(taSrc);
            }

            CType[] prgpts = new CType[taSrc.Count];
            for (int ipts = 0; ipts < taSrc.Count; ipts++)
            {
                prgpts[ipts] = SubstTypeCore(taSrc[ipts], ctx);
            }
            return(_BSymmgr.AllocParams(taSrc.Count, prgpts));
        }
예제 #18
0
 public SubstContext(TypeArray typeArgsCls, TypeArray typeArgsMeth, SubstTypeFlags grfst)
 {
     Init(typeArgsCls, typeArgsMeth, grfst);
 }