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
33 public void Step(BadDebuggerStep stepInfo)
34 {
35 string view = stepInfo.GetSourceView(Array.Empty<int>(), out int _, out int lineInSource);
36
37 if (m_LastSource == stepInfo.Position.Source && lineInSource == m_LastLine)
38 {
39 return;
40 }
41
42 m_LastLine = lineInSource;
43 m_LastSource = stepInfo.Position.Source;
44
45 if (stepInfo.Position.FileName != null && s_IgnoredFiles.Contains(stepInfo.Position.FileName))
46 {
47 return;
48 }
49
51 BadConsole.WriteLine("Press any key to continue");
52
53 bool exit = false;
54
55 do
56 {
57 string cmd = BadConsole.ReadLine();
58
59 if (cmd.StartsWith("ignore-file"))
60 {
61 string file = cmd.Remove(0, "ignore-file".Length).Trim();
62 s_IgnoredFiles.Add(file);
63
64 continue;
65 }
66
67 if (cmd.StartsWith("file"))
68 {
69 BadConsole.WriteLine(stepInfo.Position.FileName ?? "NULL");
70
71 continue;
72 }
73
74 exit = true;
75 }
76 while (!exit);
77 }
78}
Wrapper class for the console abstraction.
Definition BadConsole.cs:12
static string ReadLine()
Reads a line from the console.
Definition BadConsole.cs:85
static void WriteLine(string str)
Writes a string to the console and appends a newline.
Definition BadConsole.cs:76
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.