BadScript 2
Loading...
Searching...
No Matches
BadConsoleDebugger.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3
6
11
16{
20 private static readonly List<string> s_IgnoredFiles = new List<string>();
21
25 private int m_LastLine = -1;
26
30 private string? m_LastSource;
31
32#region IBadDebugger Members
33
35 public void Step(BadDebuggerStep stepInfo)
36 {
37 string view = stepInfo.GetSourceView(Array.Empty<int>(), out int _, out int lineInSource);
38
39 if (m_LastSource == stepInfo.Position.Source && lineInSource == m_LastLine)
40 {
41 return;
42 }
43
44 m_LastLine = lineInSource;
45 m_LastSource = stepInfo.Position.Source;
46
47 if (stepInfo.Position.FileName != null && s_IgnoredFiles.Contains(stepInfo.Position.FileName))
48 {
49 return;
50 }
51
53 BadConsole.WriteLine("Press any key to continue");
54
55 bool exit = false;
56
57 do
58 {
59 string cmd = BadConsole.ReadLine();
60
61 if (cmd.StartsWith("ignore-file"))
62 {
63 string file = cmd.Remove(0, "ignore-file".Length)
64 .Trim();
65 s_IgnoredFiles.Add(file);
66
67 continue;
68 }
69
70 if (cmd.StartsWith("file"))
71 {
72 BadConsole.WriteLine(stepInfo.Position.FileName ?? "NULL");
73
74 continue;
75 }
76
77 exit = true;
78 }
79 while (!exit);
80 }
81
82#endregion
83}
Wrapper class for the console abstraction.
Definition BadConsole.cs:12
static string ReadLine()
Reads a line from the console.
Definition BadConsole.cs:87
static void WriteLine(string str)
Writes a string to the console and appends a newline.
Definition BadConsole.cs:78
Implements a Simple Console Debugger.
int m_LastLine
The last source line that was printed.
string? m_LastSource
The Last source code that was printed.
void Step(BadDebuggerStep stepInfo)
Gets called on every step when the Debugger is attached.
static readonly List< string > s_IgnoredFiles
The List of Ignored Files.
Defines the Debugging Interface.
Contains a Console Abstraction Layer to be able to Simulate Console Input/Output over the Network.
Definition BadConsole.cs:6
Contains the debugger implementations for the BadScript2 Runtime.
Contains the debugging abstractions for the BadScript2 Runtime.
Definition BadDebugger.cs:7
Represents a Debugging Step.
string GetSourceView(int[] breakpoints, out int topInSource, out int lineInSource, int lineDelta=4)
Returns a line listing of the Step.
readonly BadSourcePosition Position
The Source Position of the Step.