private void CompileButton_Click(object sender, EventArgs e) { CompileButton.Enabled = false; LogQueue.Put(""); LogQueue.Put("Starting compilation..."); LogQueue.Put(""); CompilerWorker.RunWorkerAsync(); }
private void compileScriptBtn_Click(object sender, EventArgs e) { if (CompilerWorker.IsBusy) { MessageBox.Show(Convert.ToString(translations.MainForm_compileScriptBtn_Click_WaitForCompile)); } else { CompilerWorker.RunWorkerAsync(); //The file path is the parameter. } }
void CheckUniqueSymbols(CompilerWorker w) { foreach (var kv in w.file2symbols) { var symbols = kv.Value; var file = kv.Key; for (int i = 0; i < symbols.GetMembers().Count; ++i) { var s = symbols.GetMembers()[i]; string fpath; if (name2file.TryGetValue(s.name, out fpath)) { w.error = new BuildError(file, "symbol '" + s.name + "' is already declared in '" + fpath + "'"); break; } else { name2file.Add(s.name, file); } } } }
static List <CompilerWorker> StartAndWaitCompileWorkers(BuildConf conf, Types ts, List <ParseWorker> parse_workers) { var compiler_workers = new List <CompilerWorker>(); var cache = new Cache(); //1. waiting for parse workers to finish foreach (var pw in parse_workers) { pw.Join(); //let's create the shared interim result foreach (var kv in pw.file2interim) { cache.file2interim.Add(kv.Key, kv.Value); } } bool had_errors = false; foreach (var pw in parse_workers) { var cw = new CompilerWorker(); cw.id = pw.id; cw.cache = cache; cw.inc_dir = conf.inc_dir; cw.cache_dir = pw.cache_dir; cw.ts = ts; cw.files = pw.files; cw.start = pw.start; cw.count = pw.count; cw.postproc = conf.postproc; //passing parser error if any cw.error = pw.error; if (pw.error != null) { had_errors = true; } compiler_workers.Add(cw); } //2. starting workers which now actually compile the code // if there were no errors if (!had_errors) { foreach (var w in compiler_workers) { w.Start(); } foreach (var w in compiler_workers) { w.Join(); } } return(compiler_workers); }
private void CompilerWorker_DoWork(object sender, DoWorkEventArgs e) { CheckForIllegalCrossThreadCalls = false; //First of all, Try and save all docs. if (CurrentScintilla?.Modified ?? false) { var msgRslt = MessageBox.Show(translations.MainForm_CompilerWorker_DoWork_WouldYouLikeToSaveFiles, "", MessageBoxButtons.YesNoCancel); if (msgRslt == DialogResult.Cancel) { return; } if (msgRslt == DialogResult.Yes) { CompilerWorker.ReportProgress(1); //Save all files. } } else { CompilerWorker.ReportProgress(1); //Save all files. } //First of all, update the pawn.json compiler args. CurrentProject.SampCtlData.builds[0].args = Program.SettingsForm.GetCompilerArgs().Split(' ').ToList(); CurrentProject.SaveInfo(); CompilerWorker.ReportProgress(2); string errs = SampCtl.SendCommand(ApplicationFiles + "/sampctl.exe", CurrentProject.ProjectPath, "p build").Result; //Now, Get the errors/warning then parse them and return. //string errs = Convert.ToString(compiler.StandardError.ReadToEnd()); if (errs.Contains("success")) { e.Result = new List <ErrorsDock.ScriptErrorInfo>(); CompilerWorker.ReportProgress(5); //Done sucessfully. } else { //Parse the list for the errors and warnings first. var errorLevel = 0; List <ErrorsDock.ScriptErrorInfo> errorList = new List <ErrorsDock.ScriptErrorInfo>(); var matches = Regex.Matches(errs, @"(?<path>.+):(?<line>[0-9]+)\s\((?<type>fatal|error|warning)\)(?<text>.+)", RegexOptions.Multiline); if (matches.Count > 0) { foreach (Match match in matches) { ErrorsDock.ScriptErrorInfo err = new ErrorsDock.ScriptErrorInfo { FileName = Path.GetFileName(Convert.ToString(match.Groups["path"].Value)), LineNumber = match.Groups["line"].Value }; if (match.Groups["type"].Value == "error" || match.Groups["type"].Value == "fatal") { err.ErrorType = ErrorsDock.ScriptErrorInfo.ErrorTypes.Error; errorLevel = 2; } else { err.ErrorType = ErrorsDock.ScriptErrorInfo.ErrorTypes.Warning; if (errorLevel < 2) { errorLevel = 1; } } err.ErrorMessage = match.Groups["text"].Value; errorList.Add(err); } //Report status. if (errorLevel == 2) { CompilerWorker.ReportProgress(3); //Failed with errors and possible warnings. } else if (errorLevel == 1) { CompilerWorker.ReportProgress(4); //Sucess but warnings.. } } else { MessageBox.Show(errs, translations.MainForm_CompilerWorker_DoWork_CompilationFailed, MessageBoxButtons.OK, MessageBoxIcon.Asterisk); CompilerWorker.ReportProgress(3); } //Set result as the list. e.Result = errorList; } }