public static TestAssemblyLinker Compile(ITypeSystem typeSystem)
        {
            IArchitecture architecture = x86.Architecture.CreateArchitecture(x86.ArchitectureFeatureFlags.AutoDetect);

            // FIXME: get from architecture
            TypeLayout typeLayout = new TypeLayout(typeSystem, 4, 4);

            IInternalTrace internalLog = new BasicInternalTrace();
            (internalLog.CompilerEventListener as BasicCompilerEventListener).DebugOutput = false;
            (internalLog.CompilerEventListener as BasicCompilerEventListener).ConsoleOutput = false;

            CompilerOptions compilerOptions = new CompilerOptions();

            TestCaseAssemblyCompiler compiler = new TestCaseAssemblyCompiler(architecture, typeSystem, typeLayout, internalLog, compilerOptions);
            compiler.Compile();

            return compiler.linker;
        }
예제 #2
0
        public static void Compile(CompilerOptions compilerOptions, List<FileInfo> inputFiles)
        {
            IAssemblyLoader assemblyLoader = new AssemblyLoader();
            assemblyLoader.InitializePrivatePaths(GetInputFileNames(inputFiles));

            foreach (string file in GetInputFileNames(inputFiles))
            {
                assemblyLoader.LoadModule(file);
            }

            ITypeSystem typeSystem = new TypeSystem();
            typeSystem.LoadModules(assemblyLoader.Modules);

            int nativePointerSize;
            int nativePointerAlignment;

            compilerOptions.Architecture.GetTypeRequirements(BuiltInSigType.IntPtr, out nativePointerSize, out nativePointerAlignment);

            TypeLayout typeLayout = new TypeLayout(typeSystem, nativePointerSize, nativePointerAlignment);

            IInternalTrace internalLog = new BasicInternalTrace();

            using (AotAssemblyCompiler aot = new AotAssemblyCompiler(compilerOptions.Architecture, compilerOptions.Linker, typeSystem, typeLayout, internalLog, compilerOptions))
            {
                aot.Pipeline.AddRange(new IAssemblyCompilerStage[]
                {
                    compilerOptions.BootCompilerStage,
                    new MethodPipelineExportStage(),
                    new DelegateTypePatchStage(),
                    new PlugStage(),
                    new AssemblyMemberCompilationSchedulerStage(),
                    new MethodCompilerSchedulerStage(),
                    new TypeInitializerSchedulerStage(),
                    new TypeLayoutStage(),
                    new MetadataStage(),
                    compilerOptions.BootCompilerStage,
                    new ObjectFileLayoutStage(),
                    (IAssemblyCompilerStage)compilerOptions.Linker,
                    compilerOptions.MapFile != null ? new MapFileGenerationStage() : null
                });

                aot.Run();
            }
        }