From 6988be12ccd8a0bdca686149bc1233ca0f8fd3ad Mon Sep 17 00:00:00 2001 From: Philipp Schaad Date: Thu, 25 Jan 2024 08:59:28 +0100 Subject: [PATCH] Improve compatibility with hierarchical SDFGs --- src/overlays/memory_location_overlay.ts | 2 +- src/renderer/renderer_elements.ts | 6 +++--- src/sdfv.ts | 8 +++++--- src/utils/sdfg/traversal.ts | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/overlays/memory_location_overlay.ts b/src/overlays/memory_location_overlay.ts index 62f90ae6..7d492218 100644 --- a/src/overlays/memory_location_overlay.ts +++ b/src/overlays/memory_location_overlay.ts @@ -147,7 +147,7 @@ export class MemoryLocationOverlay extends GenericSdfgOverlay { if (node instanceof SDFGNode) { if (node.data?.node?.scope_entry !== undefined && node.parent_id !== null) { - scopeNode = node.sdfg.nodes[node.parent_id].nodes[ + scopeNode = node.parentElem?.data.state.nodes[ node.data.node.scope_entry ]; parentId = node.parent_id; diff --git a/src/renderer/renderer_elements.ts b/src/renderer/renderer_elements.ts index f84cc246..01387404 100644 --- a/src/renderer/renderer_elements.ts +++ b/src/renderer/renderer_elements.ts @@ -1685,7 +1685,7 @@ export class ScopeNode extends SDFGNode { public schedule_label(): string { let attrs = this.attributes(); if (this.scopeend() && this.parent_id !== null) { - const entry = this.sdfg.nodes[this.parent_id].nodes[ + const entry = this.parentElem?.data.state.nodes[ this.data.node.scope_entry ]; if (entry !== undefined) @@ -1715,7 +1715,7 @@ export class ScopeNode extends SDFGNode { let attrs = this.attributes(); if (this.scopeend() && this.parent_id !== null) { - const entry = this.sdfg.nodes[this.parent_id].nodes[ + const entry = this.parentElem?.data.state.nodes[ this.data.node.scope_entry ]; if (entry !== undefined) @@ -1753,7 +1753,7 @@ export class ScopeNode extends SDFGNode { let result = ''; if (this.scopeend() && this.parent_id !== null) { - const entry = this.sdfg.nodes[this.parent_id].nodes[ + const entry = this.parentElem?.data.state.nodes[ this.data.node.scope_entry ]; if (entry !== undefined) diff --git a/src/sdfv.ts b/src/sdfv.ts index 0bfd1947..893da1cd 100644 --- a/src/sdfv.ts +++ b/src/sdfv.ts @@ -180,7 +180,7 @@ export class SDFV { // If a scope has children, remove the name "Entry" from the type if (node.type().endsWith('Entry') && node.parent_id && node.id) { - const state = node.sdfg.nodes[node.parent_id]; + const state = node.parentElem?.data.state.nodes[node.parent_id]; if (state.scope_dict[node.id] !== undefined) { node_type = node_type.slice(0, -5); } @@ -194,7 +194,9 @@ export class SDFV { const nodes_to_display = [node]; if (node.type().endsWith('Entry') && node.parent_id && node.id) { - const state = node.sdfg.nodes[node.parent_id]; + const state = node.parentElem?.data.state.nodes[ + node.parent_id + ]; if (state.scope_dict[node.id] !== undefined) { for (const subnode_id of state.scope_dict[node.id]) nodes_to_display.push(parent.node(subnode_id)); @@ -241,7 +243,7 @@ export class SDFV { contents.html(''); if (elem instanceof Memlet && elem.parent_id && elem.id) { - const sdfg_edge = elem.sdfg.nodes[elem.parent_id].edges[elem.id]; + const sdfg_edge = elem.parentElem?.data.state.edges[elem.id]; contents.append($('

', { html: 'Connectors: ' + sdfg_edge.src_connector + ' → ' + sdfg_edge.dst_connector, diff --git a/src/utils/sdfg/traversal.ts b/src/utils/sdfg/traversal.ts index 0fe45d37..faa0ca70 100644 --- a/src/utils/sdfg/traversal.ts +++ b/src/utils/sdfg/traversal.ts @@ -48,7 +48,7 @@ import { // Traverse scopes recursively (if scope_dict provided). if (node.type().endsWith('Entry') && node.parent_id !== null && node.id !== null) { - const state = node.sdfg.nodes[node.parent_id]; + const state = node.parentElem?.data.state; if (state.scope_dict[node.id] !== undefined) scopesRecursive( graph, state.scope_dict[node.id], processedNodes