@casual-simulation/js-interpreter 3.1.9-alpha.3340590989

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,218 @@
1
+ import { Agent, ManagedRealm, Value, ObjectValue, SourceTextModuleRecord, Completion, ExecutionContextStack, ECMAScriptNode, ManagedSourceTextModuleRecord } from '@casual-simulation/engine262';
2
+ export declare type PossibleBreakpointStates = ['before' | 'after'] | ['before', 'after'];
3
+ /**
4
+ * Defines a class that wraps common engine262 capabilities.
5
+ */
6
+ export declare class Interpreter {
7
+ private _valueSymbolMap;
8
+ private _realSymbolMap;
9
+ private _debugging;
10
+ private _breakpoints;
11
+ /**
12
+ * The agent that this interpreter is currently using.
13
+ */
14
+ agent: Agent;
15
+ /**
16
+ * The realm that this interpreter is using.
17
+ */
18
+ realm: ManagedRealm;
19
+ /**
20
+ * Gets whether this interpreter is currently debugging.
21
+ */
22
+ get debugging(): boolean;
23
+ /**
24
+ * Sets whether this interpreter is debugging.
25
+ */
26
+ set debugging(value: boolean);
27
+ /**
28
+ * Gets the list of breakpoints that have been set on this interpreter.
29
+ */
30
+ get breakpoints(): Breakpoint[];
31
+ constructor();
32
+ /**
33
+ * Creates a new ES6 module using the given code and name.
34
+ * @param moduleCode The code that the module is made up of.
35
+ * @param moduleId The ID of the module.
36
+ * @returns Returns the created module.
37
+ */
38
+ createAndLinkModule(moduleCode: string, moduleId: string): ManagedSourceTextModuleRecord;
39
+ /**
40
+ * Creates a new function in the global scope using the given function name, function code, and parameters names.
41
+ * @param functionName The name of the function.
42
+ * @param functionCode The code for the body of the function.
43
+ * @param paramNames The names of the parameters.
44
+ */
45
+ createFunction(functionName: string, functionCode: string, ...paramNames: string[]): ConstructedFunction;
46
+ /**
47
+ * Calls the given function
48
+ * @param func The function that should be called.
49
+ * @param args The arguments that should be provided to the function.
50
+ */
51
+ callFunction(func: ConstructedFunction, ...args: any[]): Generator<InterpreterStop, any, InterpreterContinuation>;
52
+ /**
53
+ * Runs the job queue and yields with any interpreter breaks that are encountered along the way.
54
+ */
55
+ runJobQueue(): Generator<InterpreterStop, void, InterpreterContinuation>;
56
+ private _handleBreakpoints;
57
+ /**
58
+ * Constructs a new interpreted object that proxies all of it's properties back to the given object.
59
+ * @param obj The object that should be proxied.
60
+ */
61
+ proxyObject(obj: Object): Completion<Value>;
62
+ /**
63
+ * Proxies the given interpreted value as a native JavaScript object.
64
+ * @param obj The interpreted object that should be proxied.
65
+ * @param allowBreakpointsInFunction Whether the object should yield breakpoints when it is called as a function or if it should execute normally. (Default true)
66
+ */
67
+ reverseProxyObject(obj: Value, allowBreakpointsInFunction?: boolean): any;
68
+ /**
69
+ * Sets the given breakpoint for execution.
70
+ * @param breakpoint The breakpoint that should be set.
71
+ */
72
+ setBreakpoint(breakpoint: Breakpoint): void;
73
+ /**
74
+ * Removes the breakpoint with the given ID.
75
+ * @param id The ID of the breakpoint that should be removed.
76
+ */
77
+ removeBreakpointById(id: string): void;
78
+ /**
79
+ * Lists the possible breakpoint locations for the given code.
80
+ * @param code The code.
81
+ */
82
+ listPossibleBreakpoints(code: ECMAScriptNode): PossibleBreakpointLocation[];
83
+ /**
84
+ * Copies the given value as a new interpreted object.
85
+ * @param value The value that should be copied.
86
+ */
87
+ copyToValue(value: any): Completion<Value>;
88
+ /**
89
+ * Copies the given value as a new regular JS object.
90
+ * @param value The value that should be copied.
91
+ * @param transformObject An optional function that can be used to transform objects.
92
+ */
93
+ copyFromValue(value: Value, transformObject?: (obj: Object) => void): any;
94
+ private _copyToObject;
95
+ private _copyFromObject;
96
+ private _getObjectInterpretedProto;
97
+ private _getObjectRealProto;
98
+ private _getInterpretedProxyConstructor;
99
+ private _getRealProxyConstructor;
100
+ private _getOrCreateSymbolFromReal;
101
+ private _getOrCreateSymbolFromValue;
102
+ /**
103
+ * Adds the given properties as properties of the global object.
104
+ * @param props The map of property names and values.
105
+ */
106
+ addGlobalProperties(props: Map<string, any | Value | Completion<Value>>): void;
107
+ private _setupGlobals;
108
+ }
109
+ export interface ConstructedFunction {
110
+ module: SourceTextModuleRecord;
111
+ func: ObjectValue;
112
+ name: string;
113
+ }
114
+ export declare type InterpreterContinuation = null | 'step-in' | 'step-out';
115
+ export declare type InterpreterStop = InterpreterBeforeStop | InterpreterAfterStop;
116
+ export interface InterpreterStopBase {
117
+ /**
118
+ * The node that the interpreter has stopped at.
119
+ */
120
+ node: any;
121
+ /**
122
+ * The breakpoint that triggered this stop.
123
+ */
124
+ breakpoint: Breakpoint;
125
+ /**
126
+ * The stack of execution contexts.
127
+ */
128
+ stack: ExecutionContextStack;
129
+ }
130
+ /**
131
+ * Defines an interface that contains information about the current stop state of the interpreter.
132
+ */
133
+ export interface InterpreterBeforeStop extends InterpreterStopBase {
134
+ /**
135
+ * Whether this stop occurred before or after the node.
136
+ */
137
+ state: 'before';
138
+ }
139
+ /**
140
+ * Defines an interface that contains information about the current stop state of the interpreter.
141
+ */
142
+ export interface InterpreterAfterStop extends InterpreterStopBase {
143
+ /**
144
+ * Whether this stop occurred before or after the node.
145
+ */
146
+ state: 'after';
147
+ /**
148
+ * The result of the expression/statement.
149
+ */
150
+ result: Completion<Value>;
151
+ }
152
+ /**
153
+ * Defines an interface for a possible breakpoint location.
154
+ */
155
+ export interface PossibleBreakpointLocation {
156
+ /**
157
+ * The line number that the breakpoint stops at.
158
+ */
159
+ lineNumber: number;
160
+ /**
161
+ * The column number that the breakpoint stops at.
162
+ */
163
+ columnNumber: number;
164
+ /**
165
+ * The states that are reasonable for this breakpoint to stop at.
166
+ */
167
+ possibleStates: PossibleBreakpointStates;
168
+ }
169
+ /**
170
+ * Defines an interface for a breakpoint.
171
+ * That is, a spot where code execution should be paused.
172
+ */
173
+ export interface Breakpoint {
174
+ /**
175
+ * The ID of the breakpoint.
176
+ */
177
+ id: string;
178
+ /**
179
+ * The function that the breakpoint applies to.
180
+ */
181
+ func: ConstructedFunction;
182
+ /**
183
+ * The line number that the breakpoint stops at.
184
+ */
185
+ lineNumber: number;
186
+ /**
187
+ * The column number that the breakpoint stops at.
188
+ */
189
+ columnNumber: number;
190
+ /**
191
+ * The list of states that the breakpoint applies for.
192
+ * - "before" indicates that the breakpoint stops before the node executes.
193
+ * - "after" indicates that the breakpoint stops after the node executes.
194
+ */
195
+ states: ('before' | 'after')[];
196
+ /**
197
+ * Whether the breakpoint is disabled.
198
+ * Defaults to false.
199
+ */
200
+ disabled?: boolean;
201
+ }
202
+ export interface BreakpointEntry {
203
+ breakpoint: Breakpoint;
204
+ location: ECMAScriptNode['location'];
205
+ }
206
+ /**
207
+ * Traverses over the given node.
208
+ * @param node The node.
209
+ */
210
+ export declare function traverse(node: ECMAScriptNode): Generator<VisitedNode, void, VisitorOption>;
211
+ export declare type VisitorOption = null | void | 'skip';
212
+ export interface VisitedNode {
213
+ node: ECMAScriptNode;
214
+ parent: VisitedNode;
215
+ key: string;
216
+ depth: number;
217
+ }
218
+ //# sourceMappingURL=Interpreter.d.ts.map