コード例 #1
0
ファイル: ClrAssembly.cs プロジェクト: deepankarsharma/Flame
        /// <summary>
        /// Wraps a CIL assembly definition in a Flame assembly, setting
        /// up an assembly resolver and type system.
        /// </summary>
        /// <param name="definition">The assembly definition to wrap.</param>
        /// <returns>A Flame assembly.</returns>
        public static ClrAssembly Wrap(AssemblyDefinition definition)
        {
            // Bootstrap a type system resolver.
            var typeSystem = new MutableTypeEnvironment(null);
            var resolver   = new CecilAssemblyResolver(
                definition.MainModule.AssemblyResolver,
                typeSystem);
            var flameAsm = new ClrAssembly(definition, resolver.ReferenceResolver);

            var objectType = flameAsm.Resolve(definition.MainModule.TypeSystem.Object);
            var corlib     = objectType.Parent.Assembly;

            typeSystem.InnerEnvironment = new CorlibTypeEnvironment(corlib);

            return(flameAsm);
        }
コード例 #2
0
ファイル: ClrAssembly.cs プロジェクト: anthrax3/Flame
        /// <summary>
        /// Wraps a CIL assembly definition in a Flame assembly, setting
        /// up an assembly resolver and type system.
        /// </summary>
        /// <param name="definition">The assembly definition to wrap.</param>
        /// <returns>A Flame assembly.</returns>
        public static ClrAssembly Wrap(AssemblyDefinition definition)
        {
            // Bootstrap a type system resolver.
            var typeSystem = new MutableTypeEnvironment(null);
            var resolver   = new CecilAssemblyResolver(
                definition.MainModule.AssemblyResolver,
                typeSystem);
            var flameAsm = new ClrAssembly(definition, resolver.ReferenceResolver);

            // Register the assembly with its own resolver, so we don't get weirdness
            // where the assembly tries to resolve itself.
            resolver.ReferenceResolver.Register(definition.Name, flameAsm);

            var objectType = flameAsm.Resolve(definition.MainModule.TypeSystem.Object);
            var corlib     = objectType.Parent.Assembly;

            typeSystem.InnerEnvironment = new CorlibTypeEnvironment(corlib);

            return(flameAsm);
        }