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; }
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(); } }
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(); }