Exemple #1
0
        private void executionFinished(bool canceled, RuntimeError runtimeError)
        {
            removeRunToCursorBreakpoint();
            tabWatch.Controls.Clear();
            tabWatch.Controls.Add(notRunningLabel);

            var sel = txtSource.SelectionStart;
            var len = txtSource.SelectionLength;
            txtSource.Text = _env.OriginalSource;
            txtOutput.Text = _env.Output.UnifyLineEndings();
            if (canceled && runtimeError == null)
                txtOutput.Text += Environment.NewLine + Environment.NewLine + "Execution stopped.";

            _env = null;
            _currentPosition = null;

            ctTabs.SelectedTab = tabOutput;
            txtSource.Focus();
            txtSource.SelectionStart = sel;
            txtSource.SelectionLength = len;
            txtSource.ScrollToCaret();

            // In case the file has changed since the last time we ran the program
            checkFileChanged();

            if (runtimeError != null)
            {
                var msg = "A run-time error occurred:{0}{0}{1}".Fmt(Environment.NewLine, runtimeError.Message);
                txtOutput.Text += Environment.NewLine + Environment.NewLine + msg;
                txtSource.Focus();
                if (runtimeError.Position != null)
                {
                    txtSource.Focus();
                    txtSource.SelectionStart = runtimeError.Position.Index;
                    txtSource.SelectionLength = runtimeError.Position.Length;
                    txtSource.ScrollToCaret();
                }
                DlgMessage.Show(msg, "Run-time error", DlgType.Error, "&OK");
            }
        }
Exemple #2
0
 private void debuggerBreak(Position position)
 {
     removeRunToCursorBreakpoint();
     _currentPosition = position;
     _env.UpdateWatch();
     var newSource = _env.ModifiedSource;
     if (newSource != null)
         txtSource.Text = newSource;
     txtOutput.Text = _env.Output.UnifyLineEndings();
     ctTabs.SelectedTab = tabWatch;
     goToCurrentInstruction();
 }
 protected void fireDebuggerBreak(Position position)
 {
     if (DebuggerBreak != null) DebuggerBreak(position);
 }
Exemple #4
0
        private bool compile(ExecutionState state)
        {
            removeRunToCursorBreakpoint();
            _currentPosition = null;

            if (_env != null)
            {
                _env.State = state;
                return true;
            }

            if (_saveWhenRun)
                save();

            try
            {
                _env = _currentLanguage.Compile(txtSource.Text, _input ?? "");
                _env.OriginalSource = txtSource.Text;
                _env.State = state;
                _env.DebuggerBreak += p => { this.BeginInvoke(new Action(() => debuggerBreak(p))); };
                _env.ExecutionFinished += (c, e) => { this.BeginInvoke(new Action(() => executionFinished(c, e))); };
                foreach (int bp in lstBreakpoints.Items)
                    _env.AddBreakpoint(bp);
                _env.BreakpointsChanged += () => { this.BeginInvoke(new Action(() => breakpointsChanged())); };
                tabWatch.Controls.Clear();
                tabWatch.Controls.Add(_env.InitializeWatchWindow());
                if (EsotericIDEProgram.Settings.WatchFont != null)
                    _env.SetWatchWindowFont(EsotericIDEProgram.Settings.WatchFont);
                return true;
            }
            catch (CompileException e)
            {
                if (e.Index != null)
                {
                    txtSource.Focus();
                    txtSource.SelectionStart = e.Index.Value;
                    txtSource.SelectionLength = e.Length ?? 0;
                    txtSource.ScrollToCaret();
                }
                DlgMessage.Show("Compilation failed:" + Environment.NewLine + e.Message, "Esoteric IDE", DlgType.Error, "&OK");
                return false;
            }
            catch (Exception e)
            {
                DlgMessage.Show("Compilation failed:" + Environment.NewLine + e.Message + " (" + e.GetType().FullName + ")", "Esoteric IDE", DlgType.Error, "&OK");
                return false;
            }
        }
Exemple #5
0
 public RuntimeError(Position position, string message = null)
 {
     Position = position;
     Message = message;
 }