BadScript 2
Loading...
Searching...
No Matches
BadScript2.Debugging.BadDebuggerStep Struct Reference

Represents a Debugging Step. More...

Inheritance diagram for BadScript2.Debugging.BadDebuggerStep:

Public Member Functions

 BadDebuggerStep (BadExecutionContext context, BadSourcePosition position, object? stepSource)
 Creates a new Debugger Step.
 
string GetInfo ()
 Returns a string representation of the Step.
 
string GetSourceView (int[] breakpoints, out int topInSource, out int lineInSource, int lineDelta=4)
 Returns a line listing of the Step.
 
string GetSourceView (int top, int bottom, int[] breakpoints, out int topInSource, out int lineInSource)
 Returns a line listing of the Step.
 
override string ToString ()
 Returns string representation of the Step.
 
string[] GetLines (int top, int bottom, out int topInSource, out int lineInSource)
 Returns a line excerpt of the Step.
 
bool Equals (BadDebuggerStep other)
 Returns true if the Step is equal to another object.
 
override bool Equals (object? obj)
 Returns true if the Step is equal to another object.
 
override int GetHashCode ()
 Returns the Hash Code of the Step.
 

Static Public Member Functions

static bool operator== (BadDebuggerStep left, BadDebuggerStep right)
 Implements the == operator.
 
static bool operator!= (BadDebuggerStep left, BadDebuggerStep right)
 Implements the != operator.
 

Public Attributes

readonly? object StepSource
 The Source of the Step.
 
readonly BadExecutionContext Context
 The Execution Context of where the Step was executed.
 
readonly BadSourcePosition Position
 The Source Position of the Step.
 

Detailed Description

Represents a Debugging Step.

Definition at line 12 of file BadDebuggerStep.cs.

Constructor & Destructor Documentation

◆ BadDebuggerStep()

BadScript2.Debugging.BadDebuggerStep.BadDebuggerStep ( BadExecutionContext  context,
BadSourcePosition  position,
object?  stepSource 
)

Creates a new Debugger Step.

Parameters
contextThe Execution Context of where the Step was executed
positionThe Source Position of the Step
stepSourceThe Source of the Step

Definition at line 35 of file BadDebuggerStep.cs.

36 {
37 Context = context;
38 Position = position;
39 StepSource = stepSource;
40 }
readonly BadExecutionContext Context
The Execution Context of where the Step was executed.
readonly? object StepSource
The Source of the Step.
readonly BadSourcePosition Position
The Source Position of the Step.

Member Function Documentation

◆ Equals() [1/2]

bool BadScript2.Debugging.BadDebuggerStep.Equals ( BadDebuggerStep  other)

Returns true if the Step is equal to another object.

Parameters
otherThe other object
Returns
True if equal

Definition at line 156 of file BadDebuggerStep.cs.

157 {
158 return Equals(StepSource, other.StepSource) && Context.Equals(other.Context) && Position.Equals(other.Position);
159 }
bool Equals(BadDebuggerStep other)
Returns true if the Step is equal to another object.

◆ Equals() [2/2]

override bool BadScript2.Debugging.BadDebuggerStep.Equals ( object?  obj)

Returns true if the Step is equal to another object.

Parameters
objThe other object
Returns
True if equal

Definition at line 166 of file BadDebuggerStep.cs.

167 {
168 return obj is BadDebuggerStep other && Equals(other);
169 }
BadDebuggerStep(BadExecutionContext context, BadSourcePosition position, object? stepSource)
Creates a new Debugger Step.

◆ GetHashCode()

override int BadScript2.Debugging.BadDebuggerStep.GetHashCode ( )

Returns the Hash Code of the Step.

Returns

Definition at line 175 of file BadDebuggerStep.cs.

176 {
177 return BadHashCode.Combine(StepSource, Context, Position);
178 }
Implements Combination of HashCode Functions Taken from decompiled source of System....

◆ GetInfo()

string BadScript2.Debugging.BadDebuggerStep.GetInfo ( )

Returns a string representation of the Step.

Returns
String representation

Definition at line 46 of file BadDebuggerStep.cs.

47 {
48 return
49 $"######################################\nDebug Step at {Position.GetPositionInfo()}\n\nStepSource: {StepSource}\n\nContext: {Context.Scope.Name}: {Context.Scope}\n\n######################################\n";
50 }

◆ GetLines()

string[] BadScript2.Debugging.BadDebuggerStep.GetLines ( int  top,
int  bottom,
out int  topInSource,
out int  lineInSource 
)

Returns a line excerpt of the Step.

Parameters
topInSourceIndicates the start line of the excerpt
lineInSourceIndicates Current line of the code
topThe Amount of lines before the Source Position
bottomThe Amount of lines after the Source Position
Returns
String Representation

Definition at line 122 of file BadDebuggerStep.cs.

123 {
124 lineInSource = 1;
125
126 for (int i = 0; i < Position.Index; i++)
127 {
128 if (Position.Source[i] == '\n')
129 {
130 lineInSource++;
131 }
132 }
133
134 topInSource = Math.Max(1, lineInSource - top);
135
136 string[] lines = Position.Source.Split('\n');
137
138
139 List<string> lns = new List<string>();
140
141 for (int i = topInSource - 1;
142 i < topInSource - 1 + Math.Min(top + bottom, lines.Length - (topInSource - 1));
143 i++)
144 {
145 lns.Add(lines[i]);
146 }
147
148 return lns.ToArray();
149 }
int Index
The Start Index of the Position.

◆ GetSourceView() [1/2]

string BadScript2.Debugging.BadDebuggerStep.GetSourceView ( int  top,
int  bottom,
int[]  breakpoints,
out int  topInSource,
out int  lineInSource 
)

Returns a line listing of the Step.

Parameters
breakpointsThe Line numbers of the breakpoints
topInSourceIndicates the start line of the excerpt
lineInSourceIndicates Current line of the code
topThe Amount of lines before the Source Position
bottomThe Amount of lines after the Source Position
Returns
String Representation

Definition at line 76 of file BadDebuggerStep.cs.

77 {
78 StringBuilder sb = new StringBuilder($"File: {Position.FileName}\n");
79 string[] lines = GetLines(top, bottom, out topInSource, out lineInSource);
80
81 for (int i = 0; i < lines.Length; i++)
82 {
83 int ln = topInSource + i;
84 string line = lines[i];
85 string prefix = ln.ToString();
86
87 if (ln == lineInSource)
88 {
89 prefix = ">>";
90 }
91 else
92 {
93 if (breakpoints.Any(breakpoint => ln == breakpoint))
94 {
95 prefix = "@";
96 }
97 }
98
99 sb.AppendLine($"{prefix}\t| {line}");
100 }
101
102 return sb.ToString();
103 }
string[] GetLines(int top, int bottom, out int topInSource, out int lineInSource)
Returns a line excerpt of the Step.

◆ GetSourceView() [2/2]

string BadScript2.Debugging.BadDebuggerStep.GetSourceView ( int[]  breakpoints,
out int  topInSource,
out int  lineInSource,
int  lineDelta = 4 
)

Returns a line listing of the Step.

Parameters
breakpointsThe Line numbers of the breakpoints
topInSourceIndicates the start line of the excerpt
lineInSourceIndicates Current line of the code
lineDeltaThe Amount of lines before and after the Source Position
Returns
String Representation

Definition at line 61 of file BadDebuggerStep.cs.

62 {
63 return GetSourceView(lineDelta, lineDelta, breakpoints, out topInSource, out lineInSource);
64 }
string GetSourceView(int[] breakpoints, out int topInSource, out int lineInSource, int lineDelta=4)
Returns a line listing of the Step.

◆ operator!=()

static bool BadScript2.Debugging.BadDebuggerStep.operator!= ( BadDebuggerStep  left,
BadDebuggerStep  right 
)
static

Implements the != operator.

Parameters
leftThe left side
rightThe right side
Returns
True if not equal

Definition at line 197 of file BadDebuggerStep.cs.

198 {
199 return !left.Equals(right);
200 }

◆ operator==()

static bool BadScript2.Debugging.BadDebuggerStep.operator== ( BadDebuggerStep  left,
BadDebuggerStep  right 
)
static

Implements the == operator.

Parameters
leftThe left side
rightThe right side
Returns
True if equal

Definition at line 186 of file BadDebuggerStep.cs.

187 {
188 return left.Equals(right);
189 }

◆ ToString()

override string BadScript2.Debugging.BadDebuggerStep.ToString ( )

Returns string representation of the Step.

Returns
String representation

Definition at line 109 of file BadDebuggerStep.cs.

110 {
111 return GetInfo();
112 }
string GetInfo()
Returns a string representation of the Step.

Member Data Documentation

◆ Context

readonly BadExecutionContext BadScript2.Debugging.BadDebuggerStep.Context

The Execution Context of where the Step was executed.

Definition at line 22 of file BadDebuggerStep.cs.

◆ Position

readonly BadSourcePosition BadScript2.Debugging.BadDebuggerStep.Position

The Source Position of the Step.

Definition at line 27 of file BadDebuggerStep.cs.

◆ StepSource

readonly? object BadScript2.Debugging.BadDebuggerStep.StepSource

The Source of the Step.

Definition at line 17 of file BadDebuggerStep.cs.


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