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

[ivette/eva] fix callstacks ids

parent 976a82cc
No related branches found
No related tags found
No related merge requests found
......@@ -128,7 +128,11 @@ function TableCell(props: TableCellProps) {
case 'values':
case 'callstack':
{
const { values } = model.values.getValues(probe.marker, callstack);
const { values } = model.values.getValues(
probe.marker,
probe.stmt,
callstack,
);
const { cols, rows } = sizeof(values);
contents = (
<SizedArea cols={cols} rows={rows}>
......
......@@ -89,7 +89,7 @@ export class ValueCache {
private readonly state: StateCallbacks;
private readonly probes = new Map<Ast.marker, Size>(); // Marker -> max in column
private readonly stacks = new Map<Values.callstack, Size>(); // Callstack -> max in row
private readonly stacks = new Map<string, Size>(); // Callstack -> max in row
private readonly vcache = new Map<string, EvaValues>(); // '<Marker><@Callstack>?' -> value
private smax = EMPTY; // max cell size
......@@ -113,18 +113,30 @@ export class ValueCache {
return this.probes.get(target) ?? EMPTY;
}
getStackSize(callstack: Values.callstack) {
return this.stacks.get(callstack) ?? EMPTY;
private static stackKey(stmt: string, callstack: Values.callstack) {
return `${stmt}::${callstack}`;
}
getStackSize(stmt: string, callstack: Values.callstack) {
const key = ValueCache.stackKey(stmt, callstack);
return this.stacks.get(key) ?? EMPTY;
}
// --- Cached Values & Request Update
getValues(target: Ast.marker, callstack?: Values.callstack): EvaValues {
const key = `${target}@${callstack ?? '*'}`;
getValues(
target: Ast.marker,
stmt: string | undefined,
callstack: Values.callstack | undefined,
): EvaValues {
const key = callstack !== undefined ? `${target}@${callstack}` : target;
const cache = this.vcache;
const cached = cache.get(key);
if (cached) return cached;
const newValue: EvaValues = { values: '', size: EMPTY };
if (callstack !== undefined && stmt === undefined)
return newValue;
// callstack !== undefined ==> stmt !== undefined)
cache.set(key, newValue);
Server
.send(Values.getValues, { target, callstack })
......@@ -135,7 +147,7 @@ export class ValueCache {
newValue.v_then = r.v_then;
newValue.v_else = r.v_else;
newValue.alarms = r.alarms;
if (this.updateLayout(target, callstack, newValue))
if (this.updateLayout(target, stmt, callstack, newValue))
this.state.forceLayout();
else
this.state.forceUpdate();
......@@ -151,6 +163,7 @@ export class ValueCache {
private updateLayout(
target: Ast.marker,
stmt: string | undefined,
callstack: Values.callstack | undefined,
v: EvaValues,
): boolean {
......@@ -172,10 +185,14 @@ export class ValueCache {
}
// max size for stack row
if (callstack !== undefined) {
const cs = this.getStackSize(callstack);
if (!leq(s, cs)) {
this.stacks.set(callstack, merge(cs, s));
small = false;
if (stmt === undefined) small = false;
else {
const key = ValueCache.stackKey(stmt, callstack);
const cs = this.stacks.get(key) ?? EMPTY;
if (!leq(s, cs)) {
this.stacks.set(key, merge(cs, s));
small = false;
}
}
}
// request new layout if not small enough
......
......@@ -106,13 +106,13 @@ export class LayoutEngine {
});
wcs.forEach((cs, k) => {
rs.push({
key: `C${cs}`,
key: `C${stmt}::${cs}`,
kind: 'callstack',
probes: ps,
stackIndex: k,
stacks: wcs.length,
callstack: cs,
hlines: this.values.getStackSize(cs).rows,
hlines: this.values.getStackSize(stmt, cs).rows,
});
});
} else {
......
......@@ -72,7 +72,7 @@ export class Model implements StateCallbacks {
// --- Rows
private forcedLayout = false;
private lock = false;
private layout: ModelLayout = { margin: 80 };
private rows: Row[] = [];
......@@ -99,14 +99,16 @@ export class Model implements StateCallbacks {
if (!equal(this.layout, ly)) {
this.layout = ly;
const target = Ast.jMarker(ly.target);
this.selected = target && this.getProbe(target);
this.forceUpdate();
this.selected = target ? this.getProbe(target) : undefined;
this.forceLayout();
}
}
// --- Recompute Layout
private computeLayout() {
if (this.lock) return;
this.lock = true;
const s = this.selected;
if (!s) {
this.focused = undefined;
......@@ -134,8 +136,8 @@ export class Model implements StateCallbacks {
);
toLayout.sort(Probe.order).forEach(engine.push);
this.rows = engine.flush();
this.forcedLayout = false;
this.laidout.emit();
this.lock = false;
}
// --- Force Reload (empty caches)
......@@ -155,10 +157,7 @@ export class Model implements StateCallbacks {
// --- Force Layout
forceLayout() {
if (!this.forcedLayout) {
this.forcedLayout = true;
setImmediate(this.computeLayout);
}
setImmediate(this.computeLayout);
}
// --- Foce Update
......
......@@ -115,6 +115,10 @@ export class Probe {
const rq = q.rank ?? 0;
if (rp < rq) return (-1);
if (rp > rq) return (+1);
const cp = p.byCallstacks;
const cq = q.byCallstacks;
if (!cp && cq) return (-1);
if (cp && !cq) return (+1);
if (p.marker < q.marker) return (-1);
if (p.marker > q.marker) return (+1);
return 0;
......
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