예제 #1
0
		public void Process (LinkContext context)
		{
			annotations = context.Annotations;

			ProcessCorlib (context);
			ProcessSystemCore (context);
		}
예제 #2
0
        public LinkContext(Pipeline pipeline, AssemblyResolver resolver, ReaderParameters readerParameters, UnintializedContextFactory factory)
        {
            _pipeline         = pipeline;
            _resolver         = resolver;
            _resolver.Context = this;
            _actions          = new Dictionary <string, AssemblyAction> ();
            _parameters       = new Dictionary <string, string> ();
            _readerParameters = readerParameters;

            SymbolReaderProvider = new DefaultSymbolReaderProvider(false);

            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            _annotations       = factory.CreateAnnotationStore(this);
            MarkingHelpers     = factory.CreateMarkingHelpers(this);
            Tracer             = factory.CreateTracer(this);
            MarkedKnownMembers = new KnownMembers();
            StripResources     = true;
        }
예제 #3
0
        public static IEnumerable <InterfaceImplementation> GetReferencedInterfaces(AnnotationStore annotations, MethodBody body)
        {
            var possibleStackTypes = AllPossibleStackTypes(body.Method);

            if (possibleStackTypes.Count == 0)
            {
                return(null);
            }

            var interfaceTypes = possibleStackTypes.Where(t => t.IsInterface).ToArray();

            if (interfaceTypes.Length == 0)
            {
                return(null);
            }

            var interfaceImplementations = new HashSet <InterfaceImplementation> ();

            // If a type could be on the stack in the body and an interface it implements could be on the stack on the body
            // then we need to mark that interface implementation.  When this occurs it is not safe to remove the interface implementation from the type
            // even if the type is never instantiated
            foreach (var type in possibleStackTypes)
            {
                // We only sweep interfaces on classes so that's why we only care about classes
                if (!type.IsClass)
                {
                    continue;
                }

                AddMatchingInterfaces(interfaceImplementations, type, interfaceTypes);
                var bases = annotations.GetClassHierarchy(type);
                foreach (var @base in bases)
                {
                    AddMatchingInterfaces(interfaceImplementations, @base, interfaceTypes);
                }
            }

            return(interfaceImplementations);
        }
예제 #4
0
파일: LinkContext.cs 프로젝트: GirlD/mono
		public LinkContext (Pipeline pipeline, AssemblyResolver resolver)
		{
			_pipeline = pipeline;
			_resolver = resolver;
			_actions = new Hashtable ();
			_parameters = new Hashtable ();
			_annotations = new AnnotationStore ();
			_readerParameters = new ReaderParameters {
				AssemblyResolver = _resolver,
			};
		}
예제 #5
0
        public static IEnumerable <(InterfaceImplementation, TypeDefinition)> GetReferencedInterfaces(AnnotationStore annotations, MethodBody body)
        {
            var possibleStackTypes = AllPossibleStackTypes(body.Method);

            if (possibleStackTypes.Count == 0)
            {
                return(null);
            }

            var interfaceTypes = possibleStackTypes.Where(t => t.IsInterface).ToArray();

            if (interfaceTypes.Length == 0)
            {
                return(null);
            }

            var interfaceImplementations = new HashSet <(InterfaceImplementation, TypeDefinition)> ();

            // If a type could be on the stack in the body and an interface it implements could be on the stack on the body
            // then we need to mark that interface implementation.  When this occurs it is not safe to remove the interface implementation from the type
            // even if the type is never instantiated
            foreach (var type in possibleStackTypes)
            {
                // We only sweep interfaces on classes so that's why we only care about classes
                if (!type.IsClass)
                {
                    continue;
                }

                TypeDefinition currentType = type;
                while (currentType?.BaseType != null)                 // Checking BaseType != null to skip System.Object
                {
                    AddMatchingInterfaces(interfaceImplementations, currentType, interfaceTypes);
                    currentType = currentType.BaseType.Resolve();
                }
            }

            return(interfaceImplementations);
        }
예제 #6
0
 public LinkContext(Pipeline pipeline, AssemblyResolver resolver, ReaderParameters readerParameters, AnnotationStore annotations)
 {
     _pipeline         = pipeline;
     _resolver         = resolver;
     _actions          = new Dictionary <string, AssemblyAction> ();
     _parameters       = new Dictionary <string, string> ();
     _annotations      = annotations;
     _readerParameters = readerParameters;
 }
예제 #7
0
        public static Dictionary <IMetadataTokenProvider, object> GetCustomAnnotations(this AnnotationStore self, string name)
        {
            var store = custom_annotations.GetOrCreateValue(self);

            if (!store.TryGetValue(name, out var dict))
            {
                store [name] = dict = new Dictionary <IMetadataTokenProvider, object> ();
            }
            return(dict);
        }