public static void Compile(CompilerOptions compilerOptions, List<FileInfo> inputFiles) { var moduleLoader = new MosaModuleLoader(); moduleLoader.AddPrivatePath(GetInputFileNames(inputFiles)); foreach (string file in GetInputFileNames(inputFiles)) { moduleLoader.LoadModuleFromFile(file); } var typeSystem = TypeSystem.Load(moduleLoader.CreateMetadata()); MosaTypeLayout typeLayout = new MosaTypeLayout(typeSystem, compilerOptions.Architecture.NativePointerSize, compilerOptions.Architecture.NativeAlignment); ConfigurableTraceFilter filter = new ConfigurableTraceFilter(); filter.MethodMatch = MatchType.None; filter.Method = string.Empty; filter.StageMatch = MatchType.Any; filter.TypeMatch = MatchType.Any; filter.ExcludeInternalMethods = false; IInternalTrace internalTrace = new BasicInternalTrace(); internalTrace.TraceFilter = filter; AotCompiler aot = new AotCompiler(compilerOptions.Architecture, typeSystem, typeLayout, internalTrace, compilerOptions); var bootStage = compilerOptions.BootStageFactory != null ? compilerOptions.BootStageFactory() : null; aot.Pipeline.Add(new ICompilerStage[] { bootStage, compilerOptions.MethodPipelineExportDirectory != null ? new MethodPipelineExportStage(): null, new PlugStage(), new MethodCompilerSchedulerStage(), new TypeInitializerSchedulerStage(), bootStage, new TypeLayoutStage(), new MetadataStage(), new ObjectFileLayoutStage(), new LinkerFinalizationStage(), compilerOptions.MapFile != null ? new MapFileGenerationStage() : null }); aot.Run(); }
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 internalTrace = new BasicInternalTrace(); AotCompiler aot = new AotCompiler(compilerOptions.Architecture, compilerOptions.Linker, typeSystem, typeLayout, internalTrace, compilerOptions); aot.Pipeline.AddRange(new ICompilerStage[] { compilerOptions.BootCompilerStage, new MethodPipelineExportStage(), new PlugStage(), new MethodCompilerSchedulerStage(), new TypeInitializerSchedulerStage(), compilerOptions.BootCompilerStage, new TypeLayoutStage(), new MetadataStage(), new ObjectFileLayoutStage(), (ICompilerStage)compilerOptions.Linker, compilerOptions.MapFile != null ? new MapFileGenerationStage() : null }); aot.Run(); }