Beispiel #1
0
        private static ClrAssembly ResolveCorlib()
        {
            var env = new MutableTypeEnvironment(null);
            var asm = new ClrAssembly(
                Mono.Cecil.ModuleDefinition
                .ReadModule(typeof(object).Module.FullyQualifiedName)
                .Assembly,
                NullAssemblyResolver.Instance,
                env);

            env.InnerEnvironment = new CorlibTypeEnvironment(asm);
            return(asm);
        }
Beispiel #2
0
        /// <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);
        }
Beispiel #3
0
        /// <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);
        }