private static string Compile(NativeCompilerParameters parameters, bool installMetaAnnotations, IEnumerable <string> sourceFiles) { List <PathFileInInformation> fileIns = new List <PathFileInInformation>(); foreach (string sourceFile in sourceFiles) { SymbolDocumentInfo symbolDocument = null; if (parameters.EmitDebugSymbols) { symbolDocument = Expression.SymbolDocument(sourceFile, GlobalConstants.LanguageGuid, GlobalConstants.VendorGuid); } PathFileInInformation fileIn = new PathFileInInformation(sourceFile, System.Text.Encoding.UTF8, new FileInErrorSink(sourceFile), symbolDocument); fileIns.Add(fileIn); } if (fileIns.Count == 0) { return(null); } SmalltalkRuntime runtime; if (parameters.ExtensionScopeInitializer == null) { runtime = new SmalltalkRuntime(); } else { runtime = NativeLoadHelper.CreateRuntime(false, (rt, scope) => { parameters.ExtensionScopeInitializer.Invoke(null, new object[] { rt, scope }); }, (rt, scope) => { /* Nothing here */ }); } FileInService compilerService = new FileInService(runtime, installMetaAnnotations, fis => parameters.IsBaseLibrary ? new InternalInstallerContext(fis.Runtime) : new InterchangeInstallerContext(fis.Runtime)); InterchangeInstallerContext installer = compilerService.Read(fileIns); foreach (var fileIn in fileIns) { if (((FileInErrorSink)fileIn.ErrorSink).HadError) { return(null); // Some of the source file had errors, do not attempt the rest - it's meaningless } } installer.ErrorSink = new InstallErrorSink(); installer.InstallMetaAnnotations = compilerService.InstallMetaAnnotations; if (!installer.Install()) { return(null); } parameters.Runtime = runtime; return(NativeCompiler.NativeCompiler.GenerateNativeAssembly(parameters)); }
private void button1_Click(object sender, EventArgs e) { ErrorSink errorSink = new ErrorSink(this); var paths = this.textSourceFiles.Text.Split('\n').Concat(this.openFileDialog.FileNames); paths = paths.Select(s => s.Trim()).Where(s => s.Length > 0); this.textSourceFiles.Text = String.Join("\r\n", paths); Properties.Settings.Default.LastNativePaths = this.textSourceFiles.Text; Properties.Settings.Default.Save(); var fileIns = paths.Select(p => new PathFileInInformation(p, System.Text.Encoding.UTF8, errorSink, Expression.SymbolDocument(p, GlobalConstants.LanguageGuid, GlobalConstants.VendorGuid))); this.listErrors.Items.Clear(); if (!fileIns.Any()) { return; } //Dictionary<string, InterchangeVersionService> versionServicesMap = new Dictionary<string, InterchangeVersionService>(); //versionServicesMap.Add("1.0", new InterchangeVersionService10()); //versionServicesMap.Add("IronSmalltalk 1.0", new InterchangeVersionServiceIST10()); //IInterchangeFileInProcessor installer = new Installer(); //foreach (FileInInformation info in fileIns) //{ // using (TextReader souceCodeReader = info.GetTextReader()) // { // InterchangeFormatProcessor processor = new InterchangeFormatProcessor(info, souceCodeReader, installer, versionServicesMap); // processor.ProcessInterchangeFile(); // } //} var runtime = new SmalltalkRuntime(); var compilerService = new FileInService(runtime, true, fis => new InternalInstallerContext(fis.Runtime)); InterchangeInstallerContext installer = compilerService.Read(fileIns); installer.ErrorSink = new InstallErrorSink(); installer.InstallMetaAnnotations = compilerService.InstallMetaAnnotations; if (!installer.Install()) { return; } IronSmalltalk.NativeCompiler.NativeCompilerParameters parameters = new IronSmalltalk.NativeCompiler.NativeCompilerParameters(); parameters.AssemblyName = "IronSt"; parameters.Company = "Iron Company"; parameters.Copyright = "Copy(right)"; parameters.EmitDebugSymbols = true; parameters.AssemblyType = IronSmalltalk.NativeCompiler.NativeCompilerParameters.AssemblyTypeEnum.Dll; parameters.OutputDirectory = "c:\\temp"; parameters.Product = "Iron Smalltalk Product"; parameters.AssemblyVersion = "1.2.3.4"; parameters.FileVersion = "1.2.3.4"; parameters.ProductVersion = "1.2.3.4"; parameters.ProductTitle = "Iron Title"; parameters.ProductDescription = "Just a test of the Iron Smalltalk native compiler"; parameters.RootNamespace = "IronSmalltalk.Test"; parameters.Runtime = runtime; parameters.Trademark = "Iron(tm)"; IronSmalltalk.NativeCompiler.NativeCompiler.GenerateNativeAssembly(parameters); MessageBox.Show("SUCCESS!"); }