示例#1
0
        /// <summary>
        /// Returns a mutable Code Model module that is equivalent to the given Metadata Model module,
        /// except that in the new module method bodies also implement ISourceMethodBody.
        /// </summary>
        /// <param name="host">An object representing the application that is hosting this decompiler. It is used to obtain access to some global
        /// objects and services such as the shared name table and the table for interning references.</param>
        /// <param name="module">The root of the Metadata Model to be converted to a Code Model.</param>
        /// <param name="sourceLocationProvider">An object that can map some kinds of ILocation objects to IPrimarySourceLocation objects. May be null.</param>
        /// <param name="localScopeProvider">An object that can provide information about the local scopes of a method. May be null.</param>
        /// <param name="options">Set of options that control decompilation.</param>
        private static Module GetCodeModelFromMetadataModelHelper(IMetadataHost host, IModule module,
                                                                  ISourceLocationProvider /*?*/ sourceLocationProvider, ILocalScopeProvider /*?*/ localScopeProvider, DecompilerOptions options)
        {
            var result   = new MetadataDeepCopier(host).Copy(module);
            var replacer = new ReplaceMetadataMethodBodiesWithDecompiledMethodBodies(host, module, sourceLocationProvider, localScopeProvider, options);

            replacer.Traverse(result);
            var finder = new HelperTypeFinder(host, sourceLocationProvider);

            finder.Traverse(result);
            var remover = new RemoveUnnecessaryTypes(finder.helperTypes, finder.helperMethods, finder.helperFields);

            remover.Traverse(result);
            result.AllTypes.RemoveAll(td => finder.helperTypes.ContainsKey(td.InternedKey)); // depends on RemoveAll preserving order
            return(result);
        }
示例#2
0
 /// <summary>
 /// Returns a mutable Code Model module that is equivalent to the given Metadata Model module,
 /// except that in the new module method bodies also implement ISourceMethodBody.
 /// </summary>
 /// <param name="host">An object representing the application that is hosting this decompiler. It is used to obtain access to some global
 /// objects and services such as the shared name table and the table for interning references.</param>
 /// <param name="module">The root of the Metadata Model to be converted to a Code Model.</param>
 /// <param name="sourceLocationProvider">An object that can map some kinds of ILocation objects to IPrimarySourceLocation objects. May be null.</param>
 /// <param name="localScopeProvider">An object that can provide information about the local scopes of a method. May be null.</param>
 /// <param name="options">Set of options that control decompilation.</param>
 private static Module GetCodeModelFromMetadataModelHelper(IMetadataHost host, IModule module,
     ISourceLocationProvider/*?*/ sourceLocationProvider, ILocalScopeProvider/*?*/ localScopeProvider, DecompilerOptions options)
 {
     var result = new MetadataDeepCopier(host).Copy(module);
       var replacer = new ReplaceMetadataMethodBodiesWithDecompiledMethodBodies(host, module, sourceLocationProvider, localScopeProvider, options);
       replacer.Traverse(result);
       var finder = new HelperTypeFinder(host, sourceLocationProvider);
       finder.Traverse(result);
       var remover = new RemoveUnnecessaryTypes(finder.helperTypes, finder.helperMethods, finder.helperFields);
       remover.Traverse(result);
       result.AllTypes.RemoveAll(td => finder.helperTypes.ContainsKey(td.InternedKey)); // depends on RemoveAll preserving order
       return result;
 }