/// <summary> /// Compiles the source code in current file /// </summary> /// <returns>The file name of the assembly to execute</returns> private string Compile() { // select current tabs and stuff var currTab = docContent.SelectedItem as DocumentContent; var currEditor = currTab.Content as SyntaxHighlightBox.SyntaxHighlightBox; var currInfo = Documents[currTab]; // the file has not been saved? // save it to a tmp folder var path = currInfo.FullPath; if (path == "") path = SaveTmp(); else SaveFile(); var filePath = path.Substring(0, path.LastIndexOf(".")+1) + "exe"; // compile ShowCompileStart(); var compiler = new Mirelle.Compiler(); try { compiler.Process(path); // display info about successful compilation ShowCompileSuccess(); compiler.SaveAssembly(filePath); return filePath; } catch (Mirelle.CompilerException ex) { ShowCompileError(ex); return ""; } finally { // remove temp file if (currInfo.FullPath == "") new FileInfo(path).Delete(); } }
static void Main(string[] args) { try { if (args.Length == 0) Console.WriteLine("Mirelle console compiler\nUsage: mirellecc.exe filename.mr"); else { var arg = args[0]; var cpl = new Mirelle.Compiler(); cpl.Process(arg); var fi = new FileInfo(arg); cpl.SaveAssembly(fi.Name + ".exe"); Console.WriteLine("Compiled successfully."); } } catch (Mirelle.CompilerException ex) { Console.WriteLine(ex.FormattedMessage()); } }