示例#1
0
        public CompileState CompileSnippet(string snippet, string consoleBufferOutPath)
        {
            var executableSnippet = ActiveLanguageProvider.WrapSnippet(snippet, consoleBufferOutPath);
            var compilerResults = ActiveLanguageProvider.Compile(executableSnippet.Source);

            var result = new CompileState();
            result.CompilerResults = compilerResults;
            result.HasErrors = compilerResults.Errors.HasErrors;

            if (compilerResults.Errors.HasErrors)
                foreach (CompilerError err in compilerResults.Errors)
                    result.Errors.Add(string.Format("{0} at line {1} column {2} ", err.ErrorText, err.Line - executableSnippet.LineOffset, err.Column));

            return result;
        }
示例#2
0
        public CompileState CompileSnippet(string snippet, string consoleBufferOutPath)
        {
            var executableSnippet = ActiveLanguageProvider.WrapSnippet(snippet, consoleBufferOutPath);
            var compilerResults   = ActiveLanguageProvider.Compile(executableSnippet.Source);

            var result = new CompileState();

            result.CompilerResults = compilerResults;
            result.HasErrors       = compilerResults.Errors.HasErrors;

            if (compilerResults.Errors.HasErrors)
            {
                foreach (CompilerError err in compilerResults.Errors)
                {
                    result.Errors.Add(string.Format("{0} at line {1} column {2} ", err.ErrorText, err.Line - executableSnippet.LineOffset, err.Column));
                }
            }

            return(result);
        }
示例#3
0
        private void ReportCompileState(CompileState compileState)
        {
            if (compileState.HasErrors)
            {
                statusBar.BackColor = Color.Red;
                statusBar.ForeColor = Color.White;
                statusStrip1.BackColor = Color.Red;
                statusBar.Text = "Error during compiling";

                var sbErr = new StringBuilder("Compiling file: ");
                sbErr.AppendLine();
                sbErr.AppendLine();
                foreach (string error in compileState.Errors)
                    sbErr.AppendLine(error);

                errorWindow.Text = sbErr.ToString();
                tabControl.SelectedIndex = 1;
            }
            else
            {
                statusStrip1.BackColor = Color.Green;
                statusBar.BackColor = Color.Green;
                statusBar.ForeColor = Color.White;
                statusBar.Text = "Compiled Succesfully";
                errorWindow.Text = "";
            }
        }