コード例 #1
0
        internal MetadataContext(string assemblyPath, bool readSymbols)
        {
            var resolver  = new BasePathAssemblyResolver(Path.GetDirectoryName(assemblyPath));
            var parameter = new ReaderParameters
            {
                AssemblyResolver = resolver,
                ReadSymbols      = readSymbols
            };

            var mainAssembly            = AssemblyDefinition.ReadAssembly(assemblyPath, parameter);
            var mainAssemblyInformation = new AssemblyInformation(mainAssembly, this);

            resolvedCoreModule   = mainAssembly.MainModule.TypeSystem.Object.Resolve().Module;
            resolvedCoreAssembly = resolvedCoreModule.Assembly;
            var resolvedCoreAssemblyInformation = new AssemblyInformation(
                resolvedCoreAssembly, this);
            var resolvedCoreModuleInformation = new ModuleInformation(
                resolvedCoreModule, resolvedCoreAssemblyInformation);

            this.MainAssembly = mainAssemblyInformation;
            assemblies.Add(mainAssembly, mainAssemblyInformation);
            assemblies.Add(resolvedCoreAssembly, resolvedCoreAssemblyInformation);
            modules.Add(resolvedCoreModule, resolvedCoreModuleInformation);
            assemblyByModule.Add(resolvedCoreModule, resolvedCoreAssembly);

            this.VoidType              = this.GetOrAddType(resolvedCoreModule.TypeSystem.Void);
            this.ObjectType            = this.GetOrAddType(resolvedCoreModule.TypeSystem.Object);
            this.ValueTypeType         = this.GetOrAddType(resolvedCoreModule.GetType("System.ValueType"));
            this.EnumType              = this.GetOrAddType(resolvedCoreModule.GetType("System.Enum"));
            this.DelegateType          = this.GetOrAddType(resolvedCoreModule.GetType("System.Delegate"));
            this.MulticastDelegateType = this.GetOrAddType(resolvedCoreModule.GetType("System.MulticastDelegate"));
            this.ArrayType             = this.GetOrAddType(resolvedCoreModule.GetType("System.Array"));
            this.ExceptionType         = this.GetOrAddType(resolvedCoreModule.GetType("System.Exception"));

            this.ByteType    = this.GetOrAddType(resolvedCoreModule.TypeSystem.Byte);
            this.SByteType   = this.GetOrAddType(resolvedCoreModule.TypeSystem.SByte);
            this.Int16Type   = this.GetOrAddType(resolvedCoreModule.TypeSystem.Int16);
            this.UInt16Type  = this.GetOrAddType(resolvedCoreModule.TypeSystem.UInt16);
            this.Int32Type   = this.GetOrAddType(resolvedCoreModule.TypeSystem.Int32);
            this.UInt32Type  = this.GetOrAddType(resolvedCoreModule.TypeSystem.UInt32);
            this.Int64Type   = this.GetOrAddType(resolvedCoreModule.TypeSystem.Int64);
            this.UInt64Type  = this.GetOrAddType(resolvedCoreModule.TypeSystem.UInt64);
            this.SingleType  = this.GetOrAddType(resolvedCoreModule.TypeSystem.Single);
            this.DoubleType  = this.GetOrAddType(resolvedCoreModule.TypeSystem.Double);
            this.IntPtrType  = this.GetOrAddType(resolvedCoreModule.TypeSystem.IntPtr);
            this.UIntPtrType = this.GetOrAddType(resolvedCoreModule.TypeSystem.UIntPtr);
            this.CharType    = this.GetOrAddType(resolvedCoreModule.TypeSystem.Char);
            this.StringType  = this.GetOrAddType(resolvedCoreModule.TypeSystem.String);
            this.BooleanType = this.GetOrAddType(resolvedCoreModule.TypeSystem.Boolean);

            this.RuntimeFieldHandle = this.GetOrAddType(resolvedCoreModule.GetType("System.RuntimeFieldHandle"));
        }
コード例 #2
0
        internal ModuleInformation GetOrAddModule(
            ModuleReference moduleReference)
        {
            if (moduleReference == null)
            {
                return(default(ModuleInformation));
            }

            lock (modules)
            {
                if (!modules.TryGetValue(moduleReference, out var module))
                {
                    var assembly = this.GetOrAddAssembly(moduleReference);
                    module = new ModuleInformation(moduleReference, assembly);
                    modules.Add(moduleReference, module);
                }
                return(module);
            }
        }
コード例 #3
0
 public MemberInformation(TReference member, ModuleInformation module)
     : base(member, module.MetadataContext)
 {
     this.DeclaringModule = module;
 }
コード例 #4
0
ファイル: FieldInformation.cs プロジェクト: khursia/IL2C
 public FieldInformation(FieldReference field, ModuleInformation module)
     : base(field, module)
 {
 }
コード例 #5
0
ファイル: MethodInformation.cs プロジェクト: molongwudi/IL2C
 public MethodInformation(MethodReference method, ModuleInformation module)
     : base(method, module)
 {
 }