reserved functions + UI enhancements

This commit is contained in:
Kirill Zhumarin 2026-01-25 20:27:08 +00:00
parent 9656b3c07f
commit 4adf6c1e7a
20 changed files with 458 additions and 70 deletions

View file

@ -6,8 +6,8 @@
"scripts": {
"start": "vite",
"dev": "vite",
"build": "vite build",
"serve": "vite preview",
"build": "tsc && vite build",
"serve": "tsc && vite preview",
"gh-pages-build": "vite build --base=/web-dev-tools"
},
"license": "MIT",
@ -19,6 +19,13 @@
"vite-plugin-solid-svg": "^0.8.1"
},
"dependencies": {
"@codemirror/autocomplete": "^6.20.0",
"@codemirror/commands": "^6.10.1",
"@codemirror/language": "^6.12.1",
"@codemirror/lint": "^6.9.2",
"@codemirror/search": "^6.6.0",
"@codemirror/state": "^6.5.4",
"@codemirror/view": "^6.39.11",
"@material-design-icons/svg": "^0.14.15",
"@solid-primitives/context": "^0.3.2",
"@solidjs/router": "^0.15.4",

127
pnpm-lock.yaml generated
View file

@ -8,6 +8,27 @@ importers:
.:
dependencies:
'@codemirror/autocomplete':
specifier: ^6.20.0
version: 6.20.0
'@codemirror/commands':
specifier: ^6.10.1
version: 6.10.1
'@codemirror/language':
specifier: ^6.12.1
version: 6.12.1
'@codemirror/lint':
specifier: ^6.9.2
version: 6.9.2
'@codemirror/search':
specifier: ^6.6.0
version: 6.6.0
'@codemirror/state':
specifier: ^6.5.4
version: 6.5.4
'@codemirror/view':
specifier: ^6.39.11
version: 6.39.11
'@material-design-icons/svg':
specifier: ^0.14.15
version: 0.14.15
@ -175,6 +196,27 @@ packages:
resolution: {integrity: sha512-0ZrskXVEHSWIqZM/sQZ4EV3jZJXRkio/WCxaqKZP1g//CEWEPSfeZFcms4XeKBCHU0ZKnIkdJeU/kF+eRp5lBg==}
engines: {node: '>=6.9.0'}
'@codemirror/autocomplete@6.20.0':
resolution: {integrity: sha512-bOwvTOIJcG5FVo5gUUupiwYh8MioPLQ4UcqbcRf7UQ98X90tCa9E1kZ3Z7tqwpZxYyOvh1YTYbmZE9RTfTp5hg==}
'@codemirror/commands@6.10.1':
resolution: {integrity: sha512-uWDWFypNdQmz2y1LaNJzK7fL7TYKLeUAU0npEC685OKTF3KcQ2Vu3klIM78D7I6wGhktme0lh3CuQLv0ZCrD9Q==}
'@codemirror/language@6.12.1':
resolution: {integrity: sha512-Fa6xkSiuGKc8XC8Cn96T+TQHYj4ZZ7RdFmXA3i9xe/3hLHfwPZdM+dqfX0Cp0zQklBKhVD8Yzc8LS45rkqcwpQ==}
'@codemirror/lint@6.9.2':
resolution: {integrity: sha512-sv3DylBiIyi+xKwRCJAAsBZZZWo82shJ/RTMymLabAdtbkV5cSKwWDeCgtUq3v8flTaXS2y1kKkICuRYtUswyQ==}
'@codemirror/search@6.6.0':
resolution: {integrity: sha512-koFuNXcDvyyotWcgOnZGmY7LZqEOXZaaxD/j6n18TCLx2/9HieZJ5H6hs1g8FiRxBD0DNfs0nXn17g872RmYdw==}
'@codemirror/state@6.5.4':
resolution: {integrity: sha512-8y7xqG/hpB53l25CIoit9/ngxdfoG+fx+V3SHBrinnhOtLvKHRyAJJuHzkWrR4YXXLX8eXBsejgAAxHUOdW1yw==}
'@codemirror/view@6.39.11':
resolution: {integrity: sha512-bWdeR8gWM87l4DB/kYSF9A+dVackzDb/V56Tq7QVrQ7rn86W0rgZFtlL3g3pem6AeGcb9NQNoy3ao4WpW4h5tQ==}
'@esbuild/aix-ppc64@0.27.2':
resolution: {integrity: sha512-GZMB+a0mOMZs4MpDbj8RJp4cw+w1WV5NYD6xzgvzUJ5Ek2jerwfO2eADyI6ExDSUED+1X8aMbegahsJi+8mgpw==}
engines: {node: '>=18'}
@ -347,6 +389,18 @@ packages:
'@jridgewell/trace-mapping@0.3.31':
resolution: {integrity: sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==}
'@lezer/common@1.5.0':
resolution: {integrity: sha512-PNGcolp9hr4PJdXR4ix7XtixDrClScvtSCYW3rQG106oVMOOI+jFb+0+J3mbeL/53g1Zd6s0kJzaw6Ri68GmAA==}
'@lezer/highlight@1.2.3':
resolution: {integrity: sha512-qXdH7UqTvGfdVBINrgKhDsVTJTxactNNxLk7+UMwZhU13lMHaOBlJe9Vqp907ya56Y3+ed2tlqzys7jDkTmW0g==}
'@lezer/lr@1.4.7':
resolution: {integrity: sha512-wNIFWdSUfX9Jc6ePMzxSPVgTVB4EOfDIwLQLWASyiUdHKaMsiilj9bYiGkGQCKVodd0x6bgQCV207PILGFCF9Q==}
'@marijn/find-cluster-break@1.0.2':
resolution: {integrity: sha512-l0h88YhZFyKdXIFNfSWpyjStDjGHwZ/U7iobcK1cQQD8sejsONdQtTVU+1wVN1PBw40PiiHB1vA5S7VTfQiP9g==}
'@material-design-icons/svg@0.14.15':
resolution: {integrity: sha512-6nbjwGwyJnphwQUscJAYqw1Tk6+W8KvsgOAeyVgzIFXVsHfgX5XyplTUcZ29wbcTUysMMyCUi1LYpmFKA/e61g==}
@ -749,6 +803,9 @@ packages:
convert-source-map@2.0.0:
resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==}
crelt@1.0.6:
resolution: {integrity: sha512-VQ2MBenTq1fWZUH9DJNGti7kKv6EeAuYr3cLwxUWhIu1baTaXh4Ib5W2CqHVqib4/MqbYGJqiL3Zb8GJZr3l4g==}
css-select@5.2.2:
resolution: {integrity: sha512-TizTzUddG/xYLA3NXodFM0fSbNizXjOKhqiQQwvhlspadZokn1KDy0NZFS0wuEubIYAV5/c1/lAr0TaaFXEXzw==}
@ -1078,6 +1135,9 @@ packages:
resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==}
engines: {node: '>=0.10.0'}
style-mod@4.1.3:
resolution: {integrity: sha512-i/n8VsZydrugj3Iuzll8+x/00GH2vnYsk1eomD8QiRrSAeW6ItbCQDtfXCeJHd0iwiNagqjQkvpvREEPtW3IoQ==}
svgo@3.3.2:
resolution: {integrity: sha512-OoohrmuUlBs8B8o6MB2Aevn+pRIH9zDALSR+6hhqVfa6fRwG/Qw9VUMSMW9VNg2CFc/MTIfabtdOVl9ODIJjpw==}
engines: {node: '>=14.0.0'}
@ -1186,6 +1246,9 @@ packages:
vite:
optional: true
w3c-keyname@2.2.8:
resolution: {integrity: sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==}
yallist@3.1.1:
resolution: {integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==}
@ -1309,6 +1372,52 @@ snapshots:
'@babel/helper-string-parser': 7.27.1
'@babel/helper-validator-identifier': 7.28.5
'@codemirror/autocomplete@6.20.0':
dependencies:
'@codemirror/language': 6.12.1
'@codemirror/state': 6.5.4
'@codemirror/view': 6.39.11
'@lezer/common': 1.5.0
'@codemirror/commands@6.10.1':
dependencies:
'@codemirror/language': 6.12.1
'@codemirror/state': 6.5.4
'@codemirror/view': 6.39.11
'@lezer/common': 1.5.0
'@codemirror/language@6.12.1':
dependencies:
'@codemirror/state': 6.5.4
'@codemirror/view': 6.39.11
'@lezer/common': 1.5.0
'@lezer/highlight': 1.2.3
'@lezer/lr': 1.4.7
style-mod: 4.1.3
'@codemirror/lint@6.9.2':
dependencies:
'@codemirror/state': 6.5.4
'@codemirror/view': 6.39.11
crelt: 1.0.6
'@codemirror/search@6.6.0':
dependencies:
'@codemirror/state': 6.5.4
'@codemirror/view': 6.39.11
crelt: 1.0.6
'@codemirror/state@6.5.4':
dependencies:
'@marijn/find-cluster-break': 1.0.2
'@codemirror/view@6.39.11':
dependencies:
'@codemirror/state': 6.5.4
crelt: 1.0.6
style-mod: 4.1.3
w3c-keyname: 2.2.8
'@esbuild/aix-ppc64@0.27.2':
optional: true
@ -1406,6 +1515,18 @@ snapshots:
'@jridgewell/resolve-uri': 3.1.2
'@jridgewell/sourcemap-codec': 1.5.5
'@lezer/common@1.5.0': {}
'@lezer/highlight@1.2.3':
dependencies:
'@lezer/common': 1.5.0
'@lezer/lr@1.4.7':
dependencies:
'@lezer/common': 1.5.0
'@marijn/find-cluster-break@1.0.2': {}
'@material-design-icons/svg@0.14.15': {}
'@nothing-but/utils@0.17.0': {}
@ -1764,6 +1885,8 @@ snapshots:
convert-source-map@2.0.0: {}
crelt@1.0.6: {}
css-select@5.2.2:
dependencies:
boolbase: 1.0.0
@ -2111,6 +2234,8 @@ snapshots:
source-map-js@1.2.1: {}
style-mod@4.1.3: {}
svgo@3.3.2:
dependencies:
'@trysound/sax': 0.2.0
@ -2189,4 +2314,6 @@ snapshots:
optionalDependencies:
vite: 7.3.1(@types/node@25.0.10)(sass@1.97.3)
w3c-keyname@2.2.8: {}
yallist@3.1.1: {}

View file

@ -31,6 +31,7 @@ export interface SummarySwilibAnalysisEntry {
type: SwilibEntryType;
coverage: Record<string, number>;
patterns: Record<string, string>;
values: Record<string, number>;
targets: string[];
}
@ -103,11 +104,15 @@ export function getPatternsCoverage(patterns: Record<string, string>, coverage:
const patternsCoverage: Record<string, number> = {};
for (const platform of SWILIB_PLATFORMS) {
const platformCoverage = coverage[platform] ?? 0;
if (platformCoverage < 0 || platformCoverage > 100) {
patternsCoverage[platform] = platformCoverage;
} else {
patternsCoverage[platform] = patterns[platform] ? 100 : 0;
}
patternsCoverage[platform] = getCoverageValue(platformCoverage, platform in patterns);
}
return patternsCoverage;
}
export function getCoverageValue(platformCoverage: number, isExist: boolean) {
if (platformCoverage < 0 || platformCoverage > 100) {
return platformCoverage;
} else {
return isExist ? 100 : 0;
}
}

View file

@ -0,0 +1,98 @@
import { Component, onCleanup, onMount } from "solid-js";
import { EditorState } from "@codemirror/state";
import {
crosshairCursor,
drawSelection,
dropCursor,
EditorView,
highlightActiveLine,
highlightActiveLineGutter,
highlightSpecialChars,
keymap,
lineNumbers,
rectangularSelection
} from "@codemirror/view";
import {
bracketMatching,
defaultHighlightStyle,
foldGutter,
foldKeymap,
indentOnInput,
syntaxHighlighting
} from "@codemirror/language";
import { defaultKeymap, history, historyKeymap } from "@codemirror/commands";
import { highlightSelectionMatches, searchKeymap } from "@codemirror/search";
import { autocompletion, closeBrackets, closeBracketsKeymap, completionKeymap } from "@codemirror/autocomplete";
import { lintKeymap } from "@codemirror/lint";
export const CodeMirror: Component = () => {
let view: EditorView;
let parentRef!: HTMLDivElement;
onMount(() => {
view = new EditorView({
doc: "Start document",
parent: parentRef,
extensions: [
// A line number gutter
lineNumbers(),
// A gutter with code folding markers
foldGutter(),
// Replace non-printable characters with placeholders
highlightSpecialChars(),
// The undo history
history(),
// Replace the native cursor/selection with our own
drawSelection(),
// Show a drop cursor when dragging over the editor
dropCursor(),
// Allow multiple cursors/selections
EditorState.allowMultipleSelections.of(true),
// Re-indent lines when typing specific input
indentOnInput(),
// Highlight syntax with a default style
syntaxHighlighting(defaultHighlightStyle),
// Highlight matching brackets near the cursor
bracketMatching(),
// Automatically close brackets
closeBrackets(),
// Load the autocompletion system
autocompletion(),
// Allow alt-drag to select rectangular regions
rectangularSelection(),
// Change the cursor to a crosshair when holding alt
crosshairCursor(),
// Style the current line specially
highlightActiveLine(),
// Style the gutter for the current line specially
highlightActiveLineGutter(),
// Highlight text that matches the selected text
highlightSelectionMatches(),
// codemirrorVkpLanguageExtension(),
keymap.of([
// Closed-bracket-aware backspace
...closeBracketsKeymap,
// A large set of basic bindings
...defaultKeymap,
// Search-related keys
...searchKeymap,
// Redo/undo keys
...historyKeymap,
// Code folding bindings
...foldKeymap,
// Autocompletion keys
...completionKeymap,
// Keys related to the linter system
...lintKeymap
]),
EditorView.theme({ '&': { height: '100%' } })
]
});
});
onCleanup(() => view.destroy());
return (
<div ref={parentRef}></div>
);
}

View file

@ -0,0 +1,5 @@
.main-content {
flex: 1;
min-width: 0;
padding: 1rem;
}

View file

@ -1,9 +1,10 @@
/* @refresh reload */
import './App.scss';
import { createSignal, ErrorBoundary, onCleanup, onMount, ParentComponent, Show } from "solid-js";
import { Header } from "@/components/Layout/Header";
import { Alert, Button, Container, Offcanvas } from "solid-bootstrap";
import { Sidebar } from "@/components/Layout/Sidebar/Sidebar";
import { ThemeProvider } from "@/context/ThemeProvider";
import { usePreventClickAfterSelection } from "@/hooks/usePreventClickAfterSelection";
export const App: ParentComponent = (props) => {
const [sidebarIsOffcanvas, setSidebarOffcanvas] = createSignal(false);
@ -24,6 +25,8 @@ export const App: ParentComponent = (props) => {
onCleanup(() => window.removeEventListener('resize', handleWindowResize));
});
usePreventClickAfterSelection(document.body);
return (
<ThemeProvider>
<Header
@ -47,7 +50,7 @@ export const App: ParentComponent = (props) => {
</Offcanvas>
</Show>
<main class="flex-fill p-3 pt-3">
<main class="main-content">
<ErrorBoundary fallback={(error, reset) => {
console.error(error);
return (

View file

@ -4,6 +4,7 @@ import { Navigate, Route, Router } from "@solidjs/router";
const SwilibSummaryAnalysisPage = lazy(() => import("@/pages/SwilibSummaryAnalysis/SwilibSummaryAnalysisPage"));
const SwilibTargetAnalysisPage = lazy(() => import("@/pages/SwilibTargetAnalysis/SwilibTargetAnalysisPage"));
const SwilibCheckPage = lazy(() => import("@/pages/SwilibCheck/SwilibCheckPage"));
const ReFilesPage = lazy(() => import("@/pages/ReFiles/ReFilesPage"));
export const Root: Component = () => {
@ -18,6 +19,7 @@ export const Root: Component = () => {
<Route path="/" component={() => <Navigate href={() => "/swilib/analysis/summary"} />} />
<Route path="/swilib/analysis/summary" component={SwilibSummaryAnalysisPage} />
<Route path="/swilib/analysis/target" component={SwilibTargetAnalysisPage} />
<Route path="/swilib/check" component={SwilibCheckPage} />
<Route path="/re/symbols" component={ReFilesPage} />
{/* Legacy routes */}

View file

@ -1,5 +1,6 @@
import { Component, Show } from 'solid-js';
import { SwilibEntryFlags } from "@/api/swilib";
import { Badge } from "solid-bootstrap";
interface SwilibEntryBadgesProps {
value: number;
@ -9,30 +10,30 @@ export const SwilibEntryBadges: Component<SwilibEntryBadgesProps> = (props) => {
return (
<>
<Show when={props.value & SwilibEntryFlags.FROM_PATCH}>
<span
class="badge small rounded-pill bg-danger"
<Badge
class="rounded-pill bg-danger"
title="Function from patch. Don't use in ELFs!"
>
PATCH
</span>
</Badge>
</Show>
<Show when={props.value & SwilibEntryFlags.BUILTIN}>
<span
class="badge small rounded-pill bg-info"
<Badge
class="rounded-pill bg-info"
title="Built-in function from ELFLoader."
>
LOADER
</span>
</Badge>
</Show>
<Show when={props.value & SwilibEntryFlags.DIRTY}>
<span
class="badge small rounded-pill bg-danger"
<Badge
class="rounded-pill bg-danger"
title="Some phone models define this entry in swilib.vkp."
>
DIRTY
</span>
</Badge>
</Show>
</>
);

View file

@ -1,12 +1,13 @@
import { Component, createMemo, Show } from 'solid-js';
import { SummarySwilibAnalysisEntry } from "@/api/swilib";
interface SwilibEntryNameProps {
signature: string | null;
entry: SummarySwilibAnalysisEntry;
}
export const SwilibEntryName: Component<SwilibEntryNameProps> = (props) => {
const signature = createMemo(() => {
const matched = props.signature?.trim().match(/^(.*?)\s+([*]+)?(\w+)\s*\((.+?)?\)$/is);
const matched = props.entry.name?.trim().match(/^(.*?)\s+([*]+)?(\w+)\s*\((.+?)?\)$/is);
if (matched) {
return {
returnType: `${matched[1]}\xA0${matched[2] || ""}`,
@ -16,8 +17,10 @@ export const SwilibEntryName: Component<SwilibEntryNameProps> = (props) => {
}
return undefined;
});
const unusedLabel = () => props.entry.file == 'swilib/unused.h' ? 'Unused' : 'Reserved by ELFLoader';
return (
<Show when={signature()} fallback={props.signature ?? <small class="text-muted">Unused.</small>}>
<Show when={signature()} fallback={props.entry.name ?? <small class="text-muted">{unusedLabel()}</small>}>
<small class="text-muted">
{signature()?.returnType}
</small>

View file

@ -0,0 +1,31 @@
import { onCleanup } from "solid-js";
export function usePreventClickAfterSelection() {
let cursorIsMoved = false;
const handleMouseDown = () => {
cursorIsMoved = false;
};
const handleMouseMove = () => {
cursorIsMoved = true;
};
const handleClick = (e: MouseEvent) => {
const selection = document.getSelection();
if (selection && selection.type === 'Range' && cursorIsMoved) {
if ((e.target as Node)?.contains(selection.focusNode)) {
e.stopPropagation();
e.preventDefault();
}
}
};
document.body.addEventListener('mousedown', handleMouseDown, { passive: true });
document.body.addEventListener('mousemove', handleMouseMove, { passive: true });
document.body.addEventListener('click', handleClick);
onCleanup(() => {
document.body.removeEventListener('mousedown', handleMouseDown);
document.body.removeEventListener('mousemove', handleMouseMove);
document.body.removeEventListener('click', handleClick);
});
}

View file

@ -0,0 +1,12 @@
import { Component } from "solid-js";
import { CodeMirror } from "@/components/Editor/CodeMirror";
const SwilibCheckPage: Component = () => {
return (
<div>
<CodeMirror />
</div>
);
};
export default SwilibCheckPage;

View file

@ -1,45 +1,72 @@
import { Component, createMemo, createSignal, For, Show } from "solid-js";
import { Modal } from "solid-bootstrap";
import { Component, createMemo, createSignal, For, Match, Show, Switch } from "solid-js";
import { Badge, Modal } from "solid-bootstrap";
import { SwilibEntryBadges } from "@/components/Swilib/SwilibEntryBadges";
import { SwilibEntryWarnings } from "@/components/Swilib/SwilibEntryWarnings";
import { SummarySwilibAnalysis, SummarySwilibAnalysisEntry, SWILIB_PLATFORMS, SwilibDevice } from "@/api/swilib";
import { formatId } from "@/utils/format";
import {
getCoverageValue,
SummarySwilibAnalysis,
SummarySwilibAnalysisEntry,
SWILIB_PLATFORMS,
SwilibDevice
} from "@/api/swilib";
import { formatAddress, formatId } from "@/utils/format";
import { HighlightCode } from "@/components/Utils/HighlightCode";
import clsx from "clsx";
interface SwilibEntryModalProps {
entry: SummarySwilibAnalysisEntry;
analysis: SummarySwilibAnalysis;
devices: SwilibDevice[];
target?: string;
onHide: () => void;
}
export const SwilibEntryModal: Component<SwilibEntryModalProps> = (props) => {
const coverageMatrix = createMemo(() => {
const coverage: Record<string, Array<{ target: string, isSupported: boolean }>> = {};
const matrix: Record<string, Array<{ target: string, coverage: number, value?: number }>> = {};
for (const device of props.devices) {
coverage[device.platform] = coverage[device.platform] ?? [];
coverage[device.platform].push({
const platformCoverage = props.entry.coverage[device.platform];
const value = props.entry.values[device.target];
const coverage = getCoverageValue(platformCoverage, props.entry.targets.includes(device.target));
matrix[device.platform] = matrix[device.platform] ?? [];
matrix[device.platform].push({
target: device.target,
isSupported: props.entry.targets.includes(device.target)
coverage,
value
});
}
return coverage;
return matrix;
});
const value = () => props.target ? props.entry.values[props.target] : undefined;
const coverageMatrixWidth = () => Math.max(...Object.values(coverageMatrix()).map((row) => row.length));
const [showModal, setShowModal] = createSignal(true);
const unusedLabel = () => props.entry.file == 'swilib/unused.h' ? 'Unused' : 'Reserved by ELFLoader';
const getClassByCoverage = (coverage: number) => {
const coverageToClass: Record<number, string> = {
[-200]: 'text-secondary',
[0]: 'text-danger',
[100]: 'text-success',
[200]: 'text-info'
};
return coverageToClass[coverage] ?? '';
};
return (
<Modal size="lg" centered show={showModal()} onHide={() => setShowModal(false)} onExited={props.onHide}>
<Modal.Header closeButton>
<Modal.Title class="d-flex align-items-center">
<span class="me-3">
<b>ID:</b> {formatId(props.entry.id)}, <b>offset:</b> {formatId(props.entry.id * 4)}
<Modal.Title class="d-flex align-items-center gap-3">
<span>
<b>ID:</b> {formatId(props.entry.id)} / +{formatId(props.entry.id * 4)}{' '}
</span>
<Show when={value()}>{(value) =>
<Badge class="bg-secondary">{formatAddress(value())}</Badge>
}</Show>
<SwilibEntryBadges value={props.entry.flags}/>
</Modal.Title>
</Modal.Header>
<Modal.Body>
<HighlightCode language="c" code={props.entry.name ?? "/* Unused */"} />
<HighlightCode language="c" code={props.entry.name ?? `/* ${unusedLabel()} */`} />
<div class="my-3">
<SwilibEntryWarnings value={props.entry.flags}/>
@ -61,16 +88,18 @@ export const SwilibEntryModal: Component<SwilibEntryModalProps> = (props) => {
<tr>
<th>{platform}</th>
<For each={coverageMatrix()[platform]}>{(row) =>
<td>
<Show when={row.isSupported} fallback={
<div class="text-danger">
<i class="bi bi-x-circle-fill"></i> {row.target}
</div>
<td class={clsx('text-center', getClassByCoverage(row.coverage))}>
<b>{row.target}</b><br />
<Switch fallback={
<small>{row.value != null ? formatAddress(row.value) : '-'}</small>
}>
<div class="text-success">
<i class="bi bi-check-circle-fill"></i> {row.target}
</div>
</Show>
<Match when={row.coverage == 200}>
<small>built-in</small>
</Match>
<Match when={row.coverage == -200}>
<small>not avail</small>
</Match>
</Switch>
</td>
}</For>
<Show when={coverageMatrix()[platform].length < coverageMatrixWidth()}>

View file

@ -16,6 +16,11 @@ const SwilibSummaryAnalysisPage: Component = () => {
const groups = () => tableOptions.groupByFile ? summaryAnalysis()?.files : ['swilib.h'];
const [selectedEntry, setSelectedEntry] = createSignal<SummarySwilibAnalysisEntry>();
const handleFilterByType = (e: Event & { currentTarget: HTMLInputElement }) => {
if (e.currentTarget.checked)
setTableOptions("filterByType", e.currentTarget.value);
};
return <>
<div class="mb-2">
<div class="mb-2">
@ -82,6 +87,41 @@ const SwilibSummaryAnalysisPage: Component = () => {
/>
</div>
<div class="d-flex flex-row mb-3">
<span class="me-3"><i class="bi bi-funnel"></i> Filter functions:</span>
<Form.Check
inline
type="radio"
name="filter-type"
id="filter-type-all"
label="All"
value="all"
checked={tableOptions.filterByType == 'all'}
onChange={handleFilterByType}
/>
<Form.Check
inline
type="radio"
name="filter-type"
id="filter-type-unused"
label="Unused"
value="unused"
checked={tableOptions.filterByType == 'unused'}
onChange={handleFilterByType}
/>
<Form.Check
inline
type="radio"
class="text-danger"
name="filter-type"
id="filter-type-dirty"
label="Dirty"
value="dirty"
checked={tableOptions.filterByType == 'dirty'}
onChange={handleFilterByType}
/>
</div>
<Show when={resourcesState.isLoading}>
<Spinner animation="border" role="status">
<span class="visually-hidden">Loading...</span>

View file

@ -1,8 +1,9 @@
import { Component, createEffect, createMemo, For, on } from "solid-js";
import { TableSortButton } from "@/components/TableSortButton";
import { SummarySwilibAnalysis, SummarySwilibAnalysisEntry, SWILIB_PLATFORMS } from "@/api/swilib";
import { SummarySwilibAnalysis, SummarySwilibAnalysisEntry, SWILIB_PLATFORMS, SwilibEntryFlags } from "@/api/swilib";
import { useSwilibTableOptionsStore } from "@/store/swilibTableOptionsStore";
import { SwilibTableRow } from "@/pages/SwilibSummaryAnalysis/SwilibTableRow";
import clsx from "clsx";
interface SwilibTableProps {
file: string;
@ -20,8 +21,20 @@ export const SwilibTable: Component<SwilibTableProps> = (props) => {
const entries = createMemo(() => {
const sortAsc = primarySortOrder() == 'ASC';
const filterByFile = props.file;
const entries = filterByFile != 'swilib.h' ?
props.analysis.entries.filter((entry) => entry.file == filterByFile) :
const filterByType = tableOptions.filterByType;
const filterEntries = (entry: SummarySwilibAnalysisEntry): boolean => {
if (filterByFile != 'swilib.h' && entry.file != filterByFile)
return false;
if (filterByType == 'unused' && entry.file != "swilib/unused.h")
return false;
if (filterByType == 'dirty' && !(entry.flags & SwilibEntryFlags.DIRTY))
return false;
return true;
};
const entries = filterByFile != 'swilib.h' || filterByType != 'all' ?
props.analysis.entries.filter(filterEntries) :
props.analysis.entries;
return entries.toSorted((a, b) => sortAsc ? a.id - b.id : b.id - a.id);
});
@ -33,7 +46,7 @@ export const SwilibTable: Component<SwilibTableProps> = (props) => {
));
return (
<div>
<div class={clsx(entries().length == 0 && 'd-none')}>
<h4 onClick={() => setCollapsed(!isCollapsed())} class="user-select-none cursor-pointer">
<i class={`bi ${isCollapsed() ? 'bi-plus-square' : 'bi-dash-square'}`}></i> {' '}
{props.file}

View file

@ -27,7 +27,13 @@ export const SwilibTableRow: Component<SwilibTableRowProps> = (props) => {
};
return (
<tr class="cursor-pointer" onClick={handleClick} onKeyDown={handleKeyDown} tabindex="0" role="button">
<tr
class="cursor-pointer"
onClick={handleClick}
onKeyDown={handleKeyDown}
tabindex="0"
role="button"
>
<td classList={{'text-muted': props.entry.name == null}}>
{formatId(props.entry.id)}
</td>
@ -36,7 +42,7 @@ export const SwilibTableRow: Component<SwilibTableRowProps> = (props) => {
<div class="d-flex justify-content-between align-items-center">
<div>
<SwilibEntryTypeBadge value={props.entry.type} />
<SwilibEntryName signature={props.entry.name} />
<SwilibEntryName entry={props.entry} />
</div>
<SwilibEntryBadges value={props.entry.flags}/>
</div>

View file

@ -26,21 +26,21 @@ export const SwilibTable: Component<SwilibTableProps> = (props) => {
const entries = createMemo(() => {
const sortAsc = primarySortOrder() == 'ASC';
const filterByFile = props.file;
const filterByType = tableOptions.filterByType;
const filterByErrors = tableOptions.filterByErrors;
const filterEntries = (entry: SummarySwilibAnalysisEntry): boolean => {
if (filterByFile != 'swilib.h' && entry.file != filterByFile)
return false;
const targetEntry = props.targetAnalysis.entries[entry.id];
if (filterByType == 'errors') {
if (filterByErrors == 'errors') {
return !!targetEntry?.error;
} else if (filterByType == 'errors-plus-missing') {
} else if (filterByErrors == 'errors-plus-missing') {
return !!targetEntry?.error || !!targetEntry?.missing;
}
return true;
};
const entries = filterByFile != 'swilib.h' || filterByType != 'all' ?
const entries = filterByFile != 'swilib.h' || filterByErrors != 'all' ?
props.analysis.entries.filter(filterEntries) :
props.analysis.entries;
return entries.toSorted((a, b) => sortAsc ? a.id - b.id : b.id - a.id);

View file

@ -60,7 +60,7 @@ export const SwilibTableRow: Component<SwilibTableRowProps> = (props) => {
<div class="d-flex justify-content-between align-items-center">
<div>
<SwilibEntryTypeBadge value={props.entry.type} />
<SwilibEntryName signature={props.entry.name} />
<SwilibEntryName entry={props.entry} />
</div>
<SwilibEntryBadges value={props.entry.flags} />
</div>

View file

@ -28,9 +28,9 @@ const SwilibTargetAnalysisPage: Component = () => {
const groups = () => tableOptions.groupByFile ? summaryAnalysis()?.files : ['swilib.h'];
const [selectedEntry, setSelectedEntry] = createSignal<SummarySwilibAnalysisEntry>();
const handleFilterByType = (e: Event & { currentTarget: HTMLInputElement }) => {
const handleFilterByErrors = (e: Event & { currentTarget: HTMLInputElement }) => {
if (e.currentTarget.checked)
setTableOptions("filterByType", e.currentTarget.value);
setTableOptions("filterByErrors", e.currentTarget.value);
};
const downloadLinks = createMemo(() => ([
@ -113,38 +113,38 @@ const SwilibTargetAnalysisPage: Component = () => {
</div>
<div class="d-flex flex-row mb-3">
<span class="me-3"><i class="bi bi-funnel"></i> Show functions:</span>
<span class="me-3"><i class="bi bi-funnel"></i> Filter functions:</span>
<Form.Check
inline
type="radio"
id="filter-type-all"
name="filter-type"
id="filter-errors-all"
name="filter-errors"
label="All"
value="all"
checked={tableOptions.filterByType == 'all'}
onChange={handleFilterByType}
checked={tableOptions.filterByErrors == 'all'}
onChange={handleFilterByErrors}
/>
<Form.Check
inline
type="radio"
class="text-danger"
id="filter-type-errors"
name="filter-type"
id="filter-errors-errors"
name="filter-errors"
label="With errors"
value="errors"
checked={tableOptions.filterByType == 'errors'}
onChange={handleFilterByType}
checked={tableOptions.filterByErrors == 'errors'}
onChange={handleFilterByErrors}
/>
<Form.Check
inline
type="radio"
class="text-danger"
id="filter-type-errors-missing"
name="filter-type"
id="filter-errors-errors-missing"
name="filter-errors"
label="With errors + missing"
value="errors-plus-missing"
checked={tableOptions.filterByType == 'errors-plus-missing'}
onChange={handleFilterByType}
checked={tableOptions.filterByErrors == 'errors-plus-missing'}
onChange={handleFilterByErrors}
/>
</div>
@ -200,6 +200,7 @@ const SwilibTargetAnalysisPage: Component = () => {
analysis={summaryAnalysis()!}
devices={devices()!}
onHide={() => setSelectedEntry(undefined)}
target={target()}
/>
}</Show>
</Show>

View file

@ -12,7 +12,8 @@ const tableOptionsStore = createRoot(() =>
coverageType: 'SWI',
groupIsCollapsed: {} as Record<string, boolean>,
groupPrimarySort: {} as Record<string, 'ASC' | 'DESC'>,
filterByType: 'all'
filterByErrors: 'all',
filterByType: 'all',
}), { name: 'swilibTableOptions' })
);

View file

@ -1,3 +1,7 @@
export function formatId(id: number) {
return id.toString(16).padStart(3, '0').toUpperCase();
}
export function formatAddress(address: number) {
return address.toString(16).padStart(8, '0').toUpperCase();
}