-
Notifications
You must be signed in to change notification settings - Fork 460
Expand file tree
/
Copy pathcode.tsx
More file actions
69 lines (63 loc) · 2.09 KB
/
code.tsx
File metadata and controls
69 lines (63 loc) · 2.09 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
/* 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/. */
import { createSelector } from 'reselect';
import type {
AssemblyCodeStatus,
Lib,
SourceCodeStatus,
Selector,
IndexIntoSourceTable,
} from 'firefox-profiler/types';
import {
getSourceViewSourceIndex,
getAssemblyViewNativeSymbol,
} from './url-state';
import { getProfileOrNull } from './profile';
export const getSourceCodeCache: Selector<
Map<IndexIntoSourceTable, SourceCodeStatus>
> = (state) => state.code.sourceCodeCache;
export const getSourceViewCode: Selector<SourceCodeStatus | void> =
createSelector(
getSourceCodeCache,
getSourceViewSourceIndex,
(sourceCodeCache, sourceIndex) =>
sourceIndex !== null ? sourceCodeCache.get(sourceIndex) : undefined
);
export const getAssemblyCodeCache: Selector<Map<string, AssemblyCodeStatus>> = (
state
) => state.code.assemblyCodeCache;
const getAssemblyViewNativeSymbolLib: Selector<Lib | null> = createSelector(
getAssemblyViewNativeSymbol,
getProfileOrNull,
(nativeSymbol, profile) => {
if (
profile === null ||
nativeSymbol === null ||
profile.libs.length === 0
) {
return null;
}
return profile.libs[nativeSymbol.libIndex];
}
);
export const getIsAssemblyViewAvailable: Selector<boolean> = createSelector(
getAssemblyViewNativeSymbol,
getAssemblyViewNativeSymbolLib,
(nativeSymbol, lib) => nativeSymbol !== null && lib !== null
);
export const getAssemblyViewCode: Selector<AssemblyCodeStatus | void> =
createSelector(
getAssemblyCodeCache,
getAssemblyViewNativeSymbol,
getAssemblyViewNativeSymbolLib,
(assemblyMap, nativeSymbol, lib) => {
if (nativeSymbol === null || lib === null) {
return undefined;
}
const { debugName, breakpadId } = lib;
const hexAddress = nativeSymbol.address.toString(16);
const nativeSymbolKey = `${debugName}/${breakpadId}/${hexAddress}`;
return assemblyMap.get(nativeSymbolKey);
}
);