private static int Compile() { var frame = default(CodeFrame); try { var copt = CreateLinkerOptions(); copt.ForceRecompile = true; var el = new ElaLinker(copt, CreateCompilerOptions(), new FileInfo(opt.FileName)); var res = el.Build(); helper.PrintErrors(res.Messages); if (!res.Success) return R_ERR; frame = res.Assembly.GetRootModule(); } catch (ElaException ex) { helper.PrintInternalError(ex); return R_ERR; } var fi = default(FileInfo); if (!String.IsNullOrEmpty(opt.OutputFile)) { try { fi = new FileInfo(opt.OutputFile); } catch (Exception ex) { helper.PrintUnableWriteFile(opt.OutputFile, ex); return R_ERR; } } else fi = new FileInfo(Path.ChangeExtension(opt.FileName, ".elaobj")); if (!fi.Exists) { try { fi.Delete(); } catch (Exception ex) { helper.PrintUnableWriteFile(opt.OutputFile, ex); return R_ERR; } } var obj = new ObjectFileWriter(fi); try { obj.Write(frame); } catch (ElaException ex) { helper.PrintInternalError(ex); return R_ERR; } Console.WriteLine("Compilation completed. File '{0}' created.", fi.FullName); return R_OK; }
public void MakeObjectFile() { var asm = app.GetService<ICodeBuilderService>(). RunBuilder<CompiledAssembly>(sci.Text, app.Document(), BuildOptions.Output | BuildOptions.ErrorList, ElaCodeBuilder.ForceRecompile, ElaCodeBuilder.NoDebug); if (asm != null) { var fi = app.GetService<IDialogService>().ShowSaveDialog(app.Document().Title.Replace(".ela", String.Empty) + ".elaobj"); if (fi != null) { var wr = new ObjectFileWriter(fi); wr.Write(asm.Assembly.GetRootModule()); } } }