Skip to content

Commit

Permalink
April fixes 2 (#142)
Browse files Browse the repository at this point in the history
* Fix graph element retrieval by UUID

* Fix SDFG list -> CFG List compatibility layer

* Update version
  • Loading branch information
phschaad authored May 3, 2024
1 parent 8d5efa9 commit 4a5fbc7
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 22 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@spcl/sdfv",
"version": "1.2.0",
"version": "1.2.1",
"description": "A standalone viewer for SDFGs",
"homepage": "https://github.com/spcl/dace-webclient",
"main": "out/index.js",
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,10 @@ export class SDFGRenderer extends EventEmitter {
obj.attributes.sdfg) {
this.cfgTree[obj.attributes.sdfg.cfg_list_id] =
oInfo.sdfg.cfg_list_id;
this.cfgList[obj.attributes.sdfg.cfg_list_id] = {
jsonObj: obj.attributes.sdfg as JsonSDFG,
graph: null,
};
} else if (cfgId !== undefined && cfgId >= 0) {
this.cfgTree[cfgId] = oInfo.cfgId;
this.cfgList[cfgId] = {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/sdfg/json_serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ const propertyReplacements_0_16_0: { [key: string]: {
replaceWith: string,
recursive: boolean,
}} = {
'start_block': {
'start_state': {
replaceWith: 'start_block',
recursive: false,
},
'cfg_list_id': {
'sdfg_list_id': {
replaceWith: 'cfg_list_id',
recursive: true,
},
Expand Down
37 changes: 18 additions & 19 deletions src/utils/sdfg/sdfg_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,25 +120,24 @@ export function findGraphElementByUUID(
return null;

const graph = cfgList[cfgId].graph;
if (graph === null)
return null;

let state = null;
if (stateId !== '-1')
state = graph.node(stateId);

let element = null;
if (nodeId !== '-1' && state !== null && state.data.graph !== null)
element = state.data.graph.node(nodeId); // SDFG Dataflow graph node
else if (edgeId !== '-1' && state !== null && state.data.graph !== null)
element = state.data.graph.edge(edgeId); // Memlet
else if (edgeId !== '-1' && state === null)
element = graph.edge(edgeId as any); // Interstate edge

if (element)
return element;
if (state)
return state;
if (graph) {
let state = null;
if (stateId !== '-1')
state = graph.node(stateId);

let element = null;
if (nodeId !== '-1' && state !== null && state.data.graph !== null)
element = state.data.graph.node(nodeId); // SDFG Dataflow graph node
else if (edgeId !== '-1' && state !== null && state.data.graph !== null)
element = state.data.graph.edge(edgeId); // Memlet
else if (edgeId !== '-1' && state === null)
element = graph.edge(edgeId as any); // Interstate edge

if (element)
return element;
if (state)
return state;
}

const parentCfgId = cfgTree[Number(cfgId)];
if (parentCfgId === undefined || parentCfgId === null)
Expand Down

0 comments on commit 4a5fbc7

Please sign in to comment.