BadScript 2
Loading...
Searching...
No Matches
BadScript2.Debugger.BadConsoleDebugger Class Reference

Implements a Simple Console Debugger. More...

Inheritance diagram for BadScript2.Debugger.BadConsoleDebugger:
BadScript2.Debugging.IBadDebugger

Public Member Functions

void Step (BadDebuggerStep stepInfo)
 Gets called on every step when the Debugger is attached.
Parameters
stepInfoThe Current Step Information

 

Private Attributes

int m_LastLine = -1
 The last source line that was printed.
 
string? m_LastSource
 The Last source code that was printed.
 

Static Private Attributes

static readonly List< string > s_IgnoredFiles = new List<string>()
 The List of Ignored Files.
 

Detailed Description

Implements a Simple Console Debugger.

Definition at line 15 of file BadConsoleDebugger.cs.

Member Function Documentation

◆ Step()

void BadScript2.Debugger.BadConsoleDebugger.Step ( BadDebuggerStep  stepInfo)

Gets called on every step when the Debugger is attached.

Parameters
stepInfoThe Current Step Information

Implements BadScript2.Debugging.IBadDebugger.

Definition at line 35 of file BadConsoleDebugger.cs.

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 }
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
int m_LastLine
The last source line that was printed.
string? m_LastSource
The Last source code that was printed.
static readonly List< string > s_IgnoredFiles
The List of Ignored Files.
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.

Member Data Documentation

◆ m_LastLine

int BadScript2.Debugger.BadConsoleDebugger.m_LastLine = -1
private

The last source line that was printed.

Definition at line 25 of file BadConsoleDebugger.cs.

◆ m_LastSource

string? BadScript2.Debugger.BadConsoleDebugger.m_LastSource
private

The Last source code that was printed.

Definition at line 30 of file BadConsoleDebugger.cs.

◆ s_IgnoredFiles

readonly List<string> BadScript2.Debugger.BadConsoleDebugger.s_IgnoredFiles = new List<string>()
staticprivate

The List of Ignored Files.

Definition at line 20 of file BadConsoleDebugger.cs.


The documentation for this class was generated from the following file: