Exemplo n.º 1
0
        private void ConstructionFound(ITypeDefinition t)
        {
            Contract.Requires(t != null);
            Contract.Requires(!(t is Dummy));
            Contract.Requires(GarbageCollectHelper.TypeDefinitionIsUnspecialized(t));
            Contract.Requires(GarbageCollectHelper.TypeIsConstructable(t));

            Contract.Ensures(this.constructed.Contains(t));

            //Console.WriteLine("Found construction of {0}", t);

            if (this.constructed.Contains(t))
            {
                return;
            }
            this.constructed.Add(t);

            // t-devinc: should change AllSuperTypes, etc. to include t
            foreach (var baseclass in new ITypeDefinition[] { t }.Concat(GarbageCollectHelper.AllSuperTypes(t)))
            {
                ITypeDefinition unspecializedBaseClass = GarbageCollectHelper.UnspecializeAndResolveTypeReference(baseclass);
                foreach (var m in unspecializedBaseClass.Methods)
                {
                    if (m.IsVirtual && VirtualMethodIsInDemand(m))
                    {
                        ICollection <IMethodDefinition> implementationsOfMForT = GarbageCollectHelper.Implements(t, unspecializedBaseClass, m);

                        Contract.Assert(implementationsOfMForT.Count() > 0);

                        foreach (IMethodDefinition mprime in implementationsOfMForT)
                        {
                            NoteDispatch(m, GarbageCollectHelper.UnspecializeAndResolveMethodReference(mprime), t);
                        }
                    }
                }
            }

            // If a type is constructed then its Finalize method may be called

            ICollection <IMethodDefinition> implementationsOfFinalizeForT = GarbageCollectHelper.Implements(t, systemObjectType, systemObjectFinalizeMethod);

            Contract.Assert(implementationsOfFinalizeForT.Count() == 1);

            // t-devinc: Need to to add reason for this

            this.AddToWorklist(GarbageCollectHelper.UnspecializeAndResolveMethodReference(implementationsOfFinalizeForT.First()));
        }