Skip to content
Snippets Groups Projects
Commit 4ea2b010 authored by Loïc Correnson's avatar Loïc Correnson
Browse files

[region] styling memory view

parent 43ad9ac8
No related branches found
No related tags found
No related merge requests found
...@@ -42,7 +42,6 @@ function RegionAnalys(): JSX.Element { ...@@ -42,7 +42,6 @@ function RegionAnalys(): JSX.Element {
const [kfName, setName] = React.useState<string>(); const [kfName, setName] = React.useState<string>();
const [pinned, setPinned] = React.useState(false); const [pinned, setPinned] = React.useState(false);
const [running, setRunning] = React.useState(false); const [running, setRunning] = React.useState(false);
const [padding, setPadding] = React.useState(true);
const setComputing = Dome.useProtected(setRunning); const setComputing = Dome.useProtected(setRunning);
const scope = States.useCurrentScope(); const scope = States.useCurrentScope();
const { kind, name } = States.useDeclaration(scope); const { kind, name } = States.useDeclaration(scope);
...@@ -84,15 +83,8 @@ function RegionAnalys(): JSX.Element { ...@@ -84,15 +83,8 @@ function RegionAnalys(): JSX.Element {
selected={pinned} selected={pinned}
onClick={() => setPinned(!pinned)} onClick={() => setPinned(!pinned)}
/> />
<Tools.Filler />
<Tools.Button
icon='ITEMS.LIST'
title='Show non-accessed ranges in compounds'
selected={padding}
onClick={() => setPadding(!padding)}
/>
</Tools.ToolBar> </Tools.ToolBar>
<MemoryView padding={padding} regions={regions} /> <MemoryView regions={regions} />
</> </>
); );
} }
......
...@@ -32,7 +32,6 @@ function makeRecord( ...@@ -32,7 +32,6 @@ function makeRecord(
edges: Dot.Edge[], edges: Dot.Edge[],
source: string, source: string,
sizeof: number, sizeof: number,
padding: boolean,
ranges: Region.range[] ranges: Region.range[]
): Dot.Cell[] { ): Dot.Cell[] {
if (ranges.length === 0) return []; if (ranges.length === 0) return [];
...@@ -42,23 +41,20 @@ function makeRecord( ...@@ -42,23 +41,20 @@ function makeRecord(
const port = `r${i}`; const port = `r${i}`;
const target = `n${rg.data}`; const target = `n${rg.data}`;
edges.push({ source, sourcePort: port, target }); edges.push({ source, sourcePort: port, target });
if (padding && offset !== rg.offset) if (offset !== rg.offset)
cells.push(`${offset}..${rg.offset-1} ##`); cells.push(`${offset}..${rg.offset - 1} ##`);
offset = rg.offset + rg.length; offset = rg.offset + rg.length;
cells.push({ cells.push({
label: `${rg.offset}..${offset - 1} [${rg.cells}]`, label: `${rg.offset}..${offset - 1} [${rg.cells}]`,
port, port,
}); });
}); });
if (padding && offset !== sizeof) if (offset !== sizeof)
cells.push(`${offset}..${sizeof-1} ##`); cells.push(`${offset}..${sizeof - 1} ##`);
return cells; return cells;
} }
function makeDiagram( function makeDiagram(regions: readonly Region.region[]): Dot.DiagramProps {
regions: readonly Region.region[],
padding: boolean,
): Dot.DiagramProps {
const nodes: Dot.Node[] = []; const nodes: Dot.Node[] = [];
const edges: Dot.Edge[] = []; const edges: Dot.Edge[] = [];
regions.forEach(r => { regions.forEach(r => {
...@@ -71,13 +67,15 @@ function makeDiagram( ...@@ -71,13 +67,15 @@ function makeDiagram(
: (r.writes && r.reads) ? 'green' : : (r.writes && r.reads) ? 'green' :
r.writes ? 'pink' : r.reads ? 'grey' : 'white'; r.writes ? 'pink' : r.reads ? 'grey' : 'white';
// --- Shape // --- Shape
const cells = makeRecord(edges, id, r.sizeof, padding, r.ranges); const font = r.ranges.length > 0 ? 'mono' : 'sans';
const cells = makeRecord(edges, id, r.sizeof, r.ranges);
const shape = cells.length > 0 ? cells : undefined; const shape = cells.length > 0 ? cells : undefined;
nodes.push({ id: id, color, label: r.label, title: r.title, shape }); nodes.push({ id, font, color, label: r.label, title: r.title, shape });
// --- Roots // --- Roots
const R: Dot.Node = { id: '', shape: 'cds', font: 'mono', color: 'blue' };
r.roots.forEach(x => { r.roots.forEach(x => {
const xid = `X${x}`; const xid = `X${x}`;
nodes.push({ id: xid, label: x, shape: 'folder', color: 'blue' }); nodes.push({ ...R, id: xid, label: x });
edges.push({ source: xid, target: id }); edges.push({ source: xid, target: id });
}); });
// --- Pointed // --- Pointed
...@@ -91,14 +89,10 @@ function makeDiagram( ...@@ -91,14 +89,10 @@ function makeDiagram(
export interface MemoryViewProps { export interface MemoryViewProps {
regions: readonly Region.region[]; regions: readonly Region.region[];
padding?: boolean;
} }
export function MemoryView(props: MemoryViewProps): JSX.Element { export function MemoryView(props: MemoryViewProps): JSX.Element {
const { regions, padding=true } = props; const { regions } = props;
const diagram = React.useMemo( const diagram = React.useMemo(() => makeDiagram(regions), [regions]);
() => makeDiagram(regions, padding),
[regions, padding]
);
return <Dot.Diagram {...diagram} />; return <Dot.Diagram {...diagram} />;
} }
...@@ -112,7 +112,11 @@ struct ...@@ -112,7 +112,11 @@ struct
if m.writes <> [] then Buffer.add_char buffer 'W' ; if m.writes <> [] then Buffer.add_char buffer 'W' ;
if m.pointed <> None then Buffer.add_char buffer '*' if m.pointed <> None then Buffer.add_char buffer '*'
else if m.reads <> [] || m.writes <> [] then else if m.reads <> [] || m.writes <> [] then
Buffer.add_char buffer @@ typs_to_char m.types ; begin
Buffer.add_char buffer '(' ;
Buffer.add_char buffer @@ typs_to_char m.types ;
Buffer.add_char buffer ')' ;
end ;
Buffer.contents buffer Buffer.contents buffer
let pp_typ_layout s0 fmt ty = let pp_typ_layout s0 fmt ty =
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment