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

[region] view selected node

parent 823d1fc8
No related branches found
No related tags found
No related merge requests found
...@@ -149,7 +149,7 @@ const compute_internal: Server.ExecRequest<decl,null> = { ...@@ -149,7 +149,7 @@ const compute_internal: Server.ExecRequest<decl,null> = {
output: Json.jNull, output: Json.jNull,
signals: [], signals: [],
}; };
/** Compute region domain for the given declaration */ /** Compute regions for the given declaration */
export const compute: Server.ExecRequest<decl,null>= compute_internal; export const compute: Server.ExecRequest<decl,null>= compute_internal;
const regions_internal: Server.GetRequest<decl,region[]> = { const regions_internal: Server.GetRequest<decl,region[]> = {
...@@ -159,7 +159,7 @@ const regions_internal: Server.GetRequest<decl,region[]> = { ...@@ -159,7 +159,7 @@ const regions_internal: Server.GetRequest<decl,region[]> = {
output: Json.jArray(jRegion), output: Json.jArray(jRegion),
signals: [ { name: 'plugins.region.updated' } ], signals: [ { name: 'plugins.region.updated' } ],
}; };
/** Compute regions for the given declaration */ /** Returns computed regions for the given declaration */
export const regions: Server.GetRequest<decl,region[]>= regions_internal; export const regions: Server.GetRequest<decl,region[]>= regions_internal;
const regionsAt_internal: Server.GetRequest<[ marker, boolean ],region[]> = { const regionsAt_internal: Server.GetRequest<[ marker, boolean ],region[]> = {
......
...@@ -54,7 +54,12 @@ function makeRecord( ...@@ -54,7 +54,12 @@ function makeRecord(
return cells; return cells;
} }
function makeDiagram(regions: readonly Region.region[]): Dot.DiagramProps { interface Diagram {
nodes: Dot.Node[] ;
edges: Dot.Edge[] ;
}
function makeDiagram(regions: readonly Region.region[]): Diagram {
const nodes: Dot.Node[] = []; const nodes: Dot.Node[] = [];
const edges: Dot.Edge[] = []; const edges: Dot.Edge[] = [];
regions.forEach(r => { regions.forEach(r => {
...@@ -87,12 +92,24 @@ function makeDiagram(regions: readonly Region.region[]): Dot.DiagramProps { ...@@ -87,12 +92,24 @@ function makeDiagram(regions: readonly Region.region[]): Dot.DiagramProps {
return { nodes, edges }; return { nodes, edges };
} }
function addSelected(d: Diagram, label: string, node: Region.node): void {
d.nodes.push({
id: 'Selected', label, title: "Selected Marker", shape: 'note'
});
d.edges.push({ source: 'Selected', target: `n${node}` });
}
export interface MemoryViewProps { export interface MemoryViewProps {
regions: readonly Region.region[]; regions?: readonly Region.region[];
node?: Region.node | undefined;
label?: string;
} }
export function MemoryView(props: MemoryViewProps): JSX.Element { export function MemoryView(props: MemoryViewProps): JSX.Element {
const { regions } = props; const { regions=[], label, node } = props;
const diagram = React.useMemo(() => makeDiagram(regions), [regions]); const diagram = React.useMemo(() => makeDiagram(regions), [regions]);
if (label && node) addSelected(diagram, label, node);
return <Dot.Diagram {...diagram} />; return <Dot.Diagram {...diagram} />;
} }
// --------------------------------------------------------------------------
...@@ -211,7 +211,7 @@ let () = Analysis.add_hook (fun () -> Request.emit signal) ...@@ -211,7 +211,7 @@ let () = Analysis.add_hook (fun () -> Request.emit signal)
let () = let () =
Request.register Request.register
~package ~kind:`EXEC ~name:"compute" ~package ~kind:`EXEC ~name:"compute"
~descr:(Md.plain "Compute region domain for the given declaration") ~descr:(Md.plain "Compute regions for the given declaration")
~input:(module Kernel_ast.Decl) ~input:(module Kernel_ast.Decl)
~output:(module Data.Junit) ~output:(module Data.Junit)
(function SFunction kf -> Analysis.compute kf | _ -> ()) (function SFunction kf -> Analysis.compute kf | _ -> ())
...@@ -219,7 +219,7 @@ let () = ...@@ -219,7 +219,7 @@ let () =
let () = let () =
Request.register Request.register
~package ~kind:`GET ~name:"regions" ~package ~kind:`GET ~name:"regions"
~descr:(Md.plain "Compute regions for the given declaration") ~descr:(Md.plain "Returns computed regions for the given declaration")
~input:(module Kernel_ast.Decl) ~input:(module Kernel_ast.Decl)
~output:(module Regions) ~output:(module Regions)
~signals:[signal] ~signals:[signal]
......
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