forked from firefox-devtools/debugger
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate.js
More file actions
91 lines (81 loc) · 2.14 KB
/
create.js
File metadata and controls
91 lines (81 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// @flow
// This module converts Firefox specific types to the generic types
import type { Frame, Source, Location } from "../../types";
import type {
PausedPacket,
FramesResponse,
FramePacket,
SourcePayload
} from "./types";
export function createFrame(frame: FramePacket): ?Frame {
if (!frame) {
return null;
}
let title;
if (frame.type == "call") {
const c = frame.callee;
title =
c.name || c.userDisplayName || c.displayName || L10N.getStr("anonymous");
} else {
title = `(${frame.type})`;
}
const location = {
sourceId: frame.where.source.actor,
line: frame.where.line,
column: frame.where.column
};
return {
id: frame.actor,
displayName: title,
location,
generatedLocation: location,
this: frame.this,
scope: frame.environment
};
}
export function createSource(
source: SourcePayload,
{ supportsWasm }: { supportsWasm: boolean }
): Source {
return {
id: source.actor,
url: source.url,
isPrettyPrinted: false,
isWasm: supportsWasm && source.introductionType === "wasm",
sourceMapURL: source.sourceMapURL,
isBlackBoxed: false,
loadedState: "unloaded"
};
}
export function createPause(
packet: PausedPacket,
response: FramesResponse
): any {
// NOTE: useful when the debugger is already paused
const frame = packet.frame || response.frames[0];
return {
...packet,
frame: createFrame(frame),
frames: response.frames.map(createFrame)
};
}
// Firefox only returns `actualLocation` if it actually changed,
// but we want it always to exist. Format `actualLocation` if it
// exists, otherwise use `location`.
export function createBreakpointLocation(
location: Location,
actualLocation?: Object
): Location {
if (!actualLocation) {
return location;
}
return {
sourceId: actualLocation.source.actor,
sourceUrl: actualLocation.source.url,
line: actualLocation.line,
column: actualLocation.column
};
}