1// Copyright 2016 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5/** @typedef {{
6        type: string,
7        object: !Object,
8        name: (string|undefined),
9        startLocation: (!RawLocation|undefined),
10        endLocation: (!RawLocation|undefined)
11    }} */
12var Scope;
13
14/** @typedef {{
15        scriptId: string,
16        lineNumber: number,
17        columnNumber: number
18    }} */
19var RawLocation;
20
21/** @typedef {{
22        functionName: string,
23        location: !RawLocation,
24        this: !Object,
25        scopeChain: !Array<!Scope>,
26        functionLocation: (RawLocation|undefined),
27        returnValue: (*|undefined)
28    }} */
29var JavaScriptCallFrameDetails;
30
31/** @typedef {{
32        contextId: function():number,
33        thisObject: !Object,
34        evaluate: function(string, boolean):*,
35        restart: function():undefined,
36        setVariableValue: function(number, string, *):undefined,
37        isAtReturn: boolean,
38        details: function():!JavaScriptCallFrameDetails
39    }} */
40var JavaScriptCallFrame;
41
42/**
43 * @const
44 */
45var Debug = {};
46
47Debug.clearAllBreakPoints = function() {}
48
49/** @return {!Array<!Script>} */
50Debug.scripts = function() {}
51
52/**
53 * @param {number} scriptId
54 * @param {number=} line
55 * @param {number=} column
56 * @param {string=} condition
57 * @param {string=} groupId
58 * @param {Debug.BreakPositionAlignment=} positionAlignment
59 */
60Debug.setScriptBreakPointById = function(scriptId, line, column, condition, groupId, positionAlignment) {}
61
62/**
63 * @param {number} breakId
64 * @return {!Array<!SourceLocation>}
65 */
66Debug.findBreakPointActualLocations = function(breakId) {}
67
68/**
69 * @param {number} breakId
70 * @param {boolean} remove
71 * @return {!BreakPoint|undefined}
72 */
73Debug.findBreakPoint = function(breakId, remove) {}
74
75/** @enum */
76const BreakPositionAlignment = {
77    Statement: 0,
78    BreakPosition: 1
79};
80Debug.BreakPositionAlignment = BreakPositionAlignment;
81
82/** @const */
83var LiveEdit = {}
84
85/**
86 * @param {!Script} script
87 * @param {string} newSource
88 * @param {boolean} previewOnly
89 * @return {!{stack_modified: (boolean|undefined)}}
90 */
91LiveEdit.SetScriptSource = function(script, newSource, previewOnly, change_log) {}
92
93/** @constructor */
94function Failure() {}
95LiveEdit.Failure = Failure;
96
97Debug.LiveEdit = LiveEdit;
98
99/** @typedef {{
100 *    type: string,
101 *    syntaxErrorMessage: string,
102 *    position: !{start: !{line: number, column: number}},
103 *  }}
104 */
105var LiveEditErrorDetails;
106
107/** @typedef {{
108 *    breakpointId: number,
109 *    sourceID: number,
110 *    lineNumber: (number|undefined),
111 *    columnNumber: (number|undefined),
112 *    condition: (string|undefined),
113 *    interstatementLocation: (boolean|undefined),
114 *    }}
115 */
116var BreakpointInfo;
117
118
119/** @interface */
120function BreakPoint() {}
121
122/** @return {!BreakPoint|undefined} */
123BreakPoint.prototype.script_break_point = function() {}
124
125/** @return {number} */
126BreakPoint.prototype.number = function() {}
127
128
129/** @interface */
130function ExecutionState() {}
131
132/**
133 * @param {string} source
134 */
135ExecutionState.prototype.evaluateGlobal = function(source) {}
136
137/** @return {number} */
138ExecutionState.prototype.frameCount = function() {}
139
140/**
141 * @param {number} index
142 * @return {!FrameMirror}
143 */
144ExecutionState.prototype.frame = function(index) {}
145
146/** @param {number} index */
147ExecutionState.prototype.setSelectedFrame = function(index) {}
148
149/** @return {number} */
150ExecutionState.prototype.selectedFrame = function() {}
151
152
153/** @enum */
154var ScopeType = { Global: 0,
155                  Local: 1,
156                  With: 2,
157                  Closure: 3,
158                  Catch: 4,
159                  Block: 5,
160                  Script: 6,
161                  Eval: 7,
162                  Module: 8};
163
164
165/** @typedef {{
166 *    script: number,
167 *    position: number,
168 *    line: number,
169 *    column:number,
170 *    start: number,
171 *    end: number,
172 *    }}
173 */
174var SourceLocation;
175
176/** @typedef{{
177 *    id: number,
178 *    context_data: (string|undefined),
179 *    }}
180 */
181var Script;
182
183/** @interface */
184function ScopeDetails() {}
185
186/** @return {!Object} */
187ScopeDetails.prototype.object = function() {}
188
189/** @return {string|undefined} */
190ScopeDetails.prototype.name = function() {}
191
192/** @return {number} */
193ScopeDetails.prototype.type = function() {}
194
195
196/** @interface */
197function FrameDetails() {}
198
199/** @return {!Object} */
200FrameDetails.prototype.receiver = function() {}
201
202/** @return {function()} */
203FrameDetails.prototype.func = function() {}
204
205/** @return {!Object} */
206FrameDetails.prototype.script = function() {}
207
208/** @return {boolean} */
209FrameDetails.prototype.isAtReturn = function() {}
210
211/** @return {number} */
212FrameDetails.prototype.sourcePosition = function() {}
213
214/** @return {*} */
215FrameDetails.prototype.returnValue = function() {}
216
217/** @return {number} */
218FrameDetails.prototype.scopeCount = function() {}
219
220/**
221 * @param {*} value
222 * @return {!Mirror}
223 */
224function MakeMirror(value) {}
225
226
227/** @interface */
228function Mirror() {}
229
230/** @return {boolean} */
231Mirror.prototype.isFunction = function() {}
232
233/** @return {boolean} */
234Mirror.prototype.isGenerator = function() {}
235
236/**
237 * @interface
238 * @extends {Mirror}
239 */
240function ObjectMirror() {}
241
242/** @return {!Array<!PropertyMirror>} */
243ObjectMirror.prototype.properties = function() {}
244
245
246/**
247 * @interface
248 * @extends {ObjectMirror}
249 */
250function FunctionMirror () {}
251
252/** @return {number} */
253FunctionMirror.prototype.scopeCount = function() {}
254
255/**
256 * @param {number} index
257 * @return {!ScopeMirror|undefined}
258 */
259FunctionMirror.prototype.scope = function(index) {}
260
261/** @return {boolean} */
262FunctionMirror.prototype.resolved = function() {}
263
264/** @return {function()} */
265FunctionMirror.prototype.value = function() {}
266
267/** @return {string} */
268FunctionMirror.prototype.debugName = function() {}
269
270/** @return {!ScriptMirror|undefined} */
271FunctionMirror.prototype.script = function() {}
272
273/** @return {!SourceLocation|undefined} */
274FunctionMirror.prototype.sourceLocation = function() {}
275
276/** @return {!ContextMirror|undefined} */
277FunctionMirror.prototype.context = function() {}
278
279/**
280 * @constructor
281 * @param {*} value
282 */
283function UnresolvedFunctionMirror(value) {}
284
285/**
286 * @interface
287 * @extends {ObjectMirror}
288 */
289function GeneratorMirror () {}
290
291/** @return {number} */
292GeneratorMirror.prototype.scopeCount = function() {}
293
294/**
295 * @param {number} index
296 * @return {!ScopeMirror|undefined}
297 */
298GeneratorMirror.prototype.scope = function(index) {}
299
300
301/**
302 * @interface
303 * @extends {Mirror}
304 */
305function PropertyMirror() {}
306
307/** @return {!Mirror} */
308PropertyMirror.prototype.value = function() {}
309
310/** @return {string} */
311PropertyMirror.prototype.name = function() {}
312
313/** @type {*} */
314PropertyMirror.prototype.value_;
315
316/**
317 * @interface
318 * @extends {Mirror}
319 */
320function FrameMirror() {}
321
322/**
323 * @param {boolean=} ignoreNestedScopes
324 * @return {!Array<!ScopeMirror>}
325 */
326FrameMirror.prototype.allScopes = function(ignoreNestedScopes) {}
327
328/** @return {!FrameDetails} */
329FrameMirror.prototype.details = function() {}
330
331/** @return {!ScriptMirror} */
332FrameMirror.prototype.script = function() {}
333
334/**
335 * @param {string} source
336 * @param {boolean} throwOnSideEffect
337 */
338FrameMirror.prototype.evaluate = function(source, throwOnSideEffect) {}
339
340FrameMirror.prototype.restart = function() {}
341
342/** @param {number} index */
343FrameMirror.prototype.scope = function(index) {}
344
345
346/**
347 * @interface
348 * @extends {Mirror}
349 */
350function ScriptMirror() {}
351
352/** @return {!Script} */
353ScriptMirror.prototype.value = function() {}
354
355/** @return {number} */
356ScriptMirror.prototype.id = function() {}
357
358/**
359 * @param {number} position
360 * @param {boolean=} includeResourceOffset
361 */
362ScriptMirror.prototype.locationFromPosition = function(position, includeResourceOffset) {}
363
364
365/**
366 * @interface
367 * @extends {Mirror}
368 */
369function ScopeMirror() {}
370
371/** @return {!ScopeDetails} */
372ScopeMirror.prototype.details = function() {}
373
374/**
375 * @param {string} name
376 * @param {*} newValue
377 */
378ScopeMirror.prototype.setVariableValue = function(name, newValue) {}
379
380/**
381 * @interface
382 * @extends {Mirror}
383 */
384function ContextMirror() {}
385
386/** @return {string|undefined} */
387ContextMirror.prototype.data = function() {}
388