diff --git a/src/renderer/renderer.ts b/src/renderer/renderer.ts index ca8ac956..95178f93 100644 --- a/src/renderer/renderer.ts +++ b/src/renderer/renderer.ts @@ -991,7 +991,8 @@ export class SDFGRenderer extends EventEmitter { this.sdfg_tree = {}; this.for_all_sdfg_elements( (otype: SDFGElementGroup, odict: any, obj: any) => { - if (obj.type === SDFGElementType.NestedSDFG) + if (obj.type === SDFGElementType.NestedSDFG && + obj.attributes.sdfg) this.sdfg_tree[obj.attributes.sdfg.sdfg_list_id] = odict.sdfg.sdfg_list_id; } @@ -1907,7 +1908,8 @@ export class SDFGRenderer extends EventEmitter { // If nested SDFG, traverse recursively if (node.data.node.type === - SDFGElementType.NestedSDFG) + SDFGElementType.NestedSDFG && + node.attributes().sdfg) traverseRecursive( node.data.graph, node.attributes().sdfg.attributes.name, @@ -2004,7 +2006,8 @@ export class SDFGRenderer extends EventEmitter { ); // If nested SDFG, traverse recursively - if (node.type === SDFGElementType.NestedSDFG) + if (node.type === SDFGElementType.NestedSDFG && + node.attributes.sdfg) traverse_recursive(node.attributes.sdfg); }); @@ -3739,7 +3742,7 @@ function relayoutSDFGState( const topleft = gnode.topleft(); // Offset nested SDFG. - if (node.type === SDFGElementType.NestedSDFG) { + if (node.type === SDFGElementType.NestedSDFG && node.attributes.sdfg) { offset_sdfg(node.attributes.sdfg, gnode.data.graph, { x: topleft.x + SDFV.LINEHEIGHT, diff --git a/src/renderer/renderer_elements.ts b/src/renderer/renderer_elements.ts index 44adbb7c..be2383fe 100644 --- a/src/renderer/renderer_elements.ts +++ b/src/renderer/renderer_elements.ts @@ -2087,7 +2087,9 @@ export class NestedSDFG extends SDFGNode { ctx.fillStyle = this.getCssProperty( renderer, '--node-foreground-color' ); - const label = this.data.node.attributes.label; + let label = this.data.node.attributes.label; + if (!this.data.node.attributes.sdfg) + label += ' (not loaded)'; const textmetrics = ctx.measureText(label); ctx.fillText( label, this.x - textmetrics.width / 2.0, @@ -2514,7 +2516,8 @@ export function offset_state( c.y += offset.y; }); - if (node.data.node.type === SDFGElementType.NestedSDFG) + if (node.data.node.type === SDFGElementType.NestedSDFG && + node.data.node.attributes.sdfg) offset_sdfg( node.data.node.attributes.sdfg, node.data.graph, offset ); diff --git a/src/sdfv.ts b/src/sdfv.ts index bac3f2fe..a46099df 100644 --- a/src/sdfv.ts +++ b/src/sdfv.ts @@ -326,7 +326,7 @@ export class SDFV { } // If nested SDFG, add SDFG information too - if (elem instanceof NestedSDFG) { + if (elem instanceof NestedSDFG && elem.attributes().sdfg) { const sdfg_sdfg = elem.attributes().sdfg; contents.append($('
')); contents.append($('

', { diff --git a/src/utils/sdfg/traversal.ts b/src/utils/sdfg/traversal.ts index 50e02b92..0fe45d37 100644 --- a/src/utils/sdfg/traversal.ts +++ b/src/utils/sdfg/traversal.ts @@ -279,7 +279,7 @@ export function memlet_tree_nested( const name = edge.dst_connector; const nested_sdfg = next_node.attributes.sdfg; - nested_sdfg.nodes.forEach((nstate: any) => { + nested_sdfg?.nodes.forEach((nstate: any) => { nstate.edges.forEach((e: any) => { const node = nstate.nodes[e.src]; if (node.type === SDFGElementType.AccessNode && @@ -328,7 +328,7 @@ export function memlet_tree_nested( const name = edge.src_connector; const nested_sdfg = next_node.attributes.sdfg; - nested_sdfg.nodes.forEach((nstate: JsonSDFGState) => { + nested_sdfg?.nodes.forEach((nstate: JsonSDFGState) => { nstate.edges.forEach((e: JsonSDFGEdge) => { const node = nstate.nodes[parseInt(e.dst)]; if (node.type === SDFGElementType.AccessNode && @@ -394,7 +394,7 @@ export function memlet_tree_recursive(root_sdfg: JsonSDFG): any[] { }); state.nodes.forEach((n: JsonSDFGNode) => { - if (n.type == SDFGElementType.NestedSDFG) { + if (n.type == SDFGElementType.NestedSDFG && n.attributes.sdfg) { const t = memlet_tree_recursive(n.attributes.sdfg); trees = trees.concat(t); }