BadScript 2
Loading...
Searching...
No Matches
BadScriptDebuggerExtension.cs
Go to the documentation of this file.
1using System;
2using System.Linq;
3
12
14
19{
21 protected override void AddExtensions(BadInteropExtensionProvider provider)
22 {
23 provider.RegisterObject<BadDebuggerStep>("Position", step => BadObject.Wrap(step.Position));
24 provider.RegisterObject<BadDebuggerStep>("Scope", step => step.Context.Scope);
26 "GetSourceView",
28 "GetSourceView",
29 (_, a) => GetSourceView(step, a.Select(int.Parse).ToArray()),
32 "breakpointLines",
33 true,
34 true,
35 false,
36 null,
38 )
39 )
40 );
42 "SourceView",
43 step => step.GetSourceView(Array.Empty<int>(), out int _, out int _)
44 );
46 "Line",
47 step =>
48 {
49 step.GetSourceView(Array.Empty<int>(), out int _, out int lineInSource);
50
51 return lineInSource;
52 }
53 );
55 "Evaluate",
57 "Evaluate",
58 (_, s) =>
59 {
61
62 foreach (BadObject o in step.Context.Execute(BadSourceParser.Create("<debugger>", s).Parse()))
63 {
64 obj = o;
65 }
66
67 return obj;
68 },
69 BadAnyPrototype.Instance
70 )
71 );
72
73 provider.RegisterObject<BadSourcePosition>("Index", pos => pos.Index);
74 provider.RegisterObject<BadSourcePosition>("Length", pos => pos.Length);
75 provider.RegisterObject<BadSourcePosition>("FileName", pos => pos.FileName ?? BadObject.Null);
76 provider.RegisterObject<BadSourcePosition>("Source", pos => pos.Source);
77 }
78
85 private static BadObject GetSourceView(BadDebuggerStep step, int[] breakpoints)
86 {
87 return step.GetSourceView(breakpoints, out int _, out int _);
88 }
89}
Describes a specific position inside a source file.
int Index
The Start Index of the Position.
int Length
The Length of the Position.
Implements Interop Extensions for the Debugger Objects.
override void AddExtensions(BadInteropExtensionProvider provider)
static BadObject GetSourceView(BadDebuggerStep step, int[] breakpoints)
Returns the Source View for the Debugger Step.
The Parser of the Language. It turns Source Code into an Expression Tree.
static BadSourceParser Create(string fileName, string source)
Creates a BadSourceParser Instance based on the source and filename provided.
static IEnumerable< BadExpression > Parse(string fileName, string source)
Parses a BadExpression from the Source Reader.
Public Extension API for the BS2 Runtime.
void RegisterObject(Type t, string propName, BadObject obj)
Registers the specified extension for the specified type.
The Base Class for all BadScript Objects.
Definition BadObject.cs:14
static readonly BadObject Null
The Null Value for the BadScript Language.
Definition BadObject.cs:28
Helper Class that Builds a Native Class from a Prototype.
static BadClassPrototype GetNative(string name)
Returns a Native Class Prototype for the given Native Type.
Contains Shared Data Structures and Functionality.
Contains the scriptable debugger implementation for the BadScript2 Runtime.
Contains the debugging abstractions for the BadScript2 Runtime.
Definition BadDebugger.cs:7
Contains the Parser for the BadScript2 Language.
Contains the Interop Function Classes for the BadScript2 Language.
Contains the Interop Abstractions and Implementations for the BadScript2 Language.
Contains Runtime Function Objects.
Contains the Runtime Objects.
Definition BadArray.cs:10
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 BadExecutionContext Context
The Execution Context of where the Step was executed.
readonly BadSourcePosition Position
The Source Position of the Step.