Skip to content

Commit

Permalink
Enable rendering with undefined properties
Browse files Browse the repository at this point in the history
  • Loading branch information
tbennun committed Nov 28, 2023
1 parent 8961a69 commit 1f44437
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
6 changes: 3 additions & 3 deletions src/renderer/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3524,16 +3524,16 @@ function relayoutSDFGState(
node.attributes.layout = {};

// Set connectors prior to computing node size
node.attributes.layout.in_connectors = node.attributes.in_connectors;
node.attributes.layout.in_connectors = node.attributes.in_connectors ?? [];
if ('is_collapsed' in node.attributes && node.attributes.is_collapsed &&
node.type !== SDFGElementType.NestedSDFG &&
node.type !== SDFGElementType.ExternalNestedSDFG)
node.attributes.layout.out_connectors = find_exit_for_entry(
state.nodes, node
)?.attributes.out_connectors;
)?.attributes.out_connectors ?? [];
else
node.attributes.layout.out_connectors =
node.attributes.out_connectors;
node.attributes.out_connectors ?? [];

const nodeSize = calculateNodeSize(sdfg, node, ctx);
node.attributes.layout.width = nodeSize.width;
Expand Down
27 changes: 14 additions & 13 deletions src/renderer/renderer_elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ export class Memlet extends Edge {
const dsettings = renderer.view_settings();
const attr = this.attributes();

if (attr.subset === null) { // Empty memlet
if (attr.subset === null || attr.subset === undefined) { // Empty memlet
container.style.display = 'none';
return;
}
Expand Down Expand Up @@ -1369,10 +1369,10 @@ export class AccessNode extends SDFGNode {
}

// Non-transient (external) data is thicker
if (nodedesc && nodedesc.attributes.transient === false) {
ctx.lineWidth = 3.0;
} else {
if (nodedesc && nodedesc.attributes.transient === true) {
ctx.lineWidth = 1.0;
} else {
ctx.lineWidth = 3.0;
}
ctx.stroke();
ctx.lineWidth = 1.0;
Expand All @@ -1387,7 +1387,8 @@ export class AccessNode extends SDFGNode {
ctx.fillStyle = this.getCssProperty(
renderer, '--reference-background-color'
);
} else if (nodedesc && this.sdfg.attributes.constants_prop[name] !== undefined) {
} else if (nodedesc && this.sdfg.attributes.constants_prop &&
this.sdfg.attributes.constants_prop[name] !== undefined) {
ctx.fillStyle = this.getCssProperty(
renderer, '--connector-scoped-color'
);
Expand Down Expand Up @@ -1547,9 +1548,9 @@ export class ScopeNode extends SDFGNode {
SDFV.SCOPE_LOD, SDFV.DEFAULT_MAX_FONTSIZE, 0.7,
SDFV.DEFAULT_FAR_FONT_MULTIPLIER, true,
TextVAlign.BOTTOM, TextHAlign.RIGHT, {
bottom: 2.0,
right: this.height,
}
bottom: 2.0,
right: this.height,
}
);
}

Expand Down Expand Up @@ -1797,8 +1798,8 @@ export class Tasklet extends SDFGNode {
const code = this.attributes().code.string_data;

const sdfgSymbols = Object.keys(this.sdfg.attributes.symbols);
const inConnectors = Object.keys(this.attributes().in_connectors);
const outConnectors = Object.keys(this.attributes().out_connectors);
const inConnectors = Object.keys(this.attributes().in_connectors ?? []);
const outConnectors = Object.keys(this.attributes().out_connectors ?? []);

const lines = code.split('\n');
let maxline_len = 0;
Expand Down Expand Up @@ -1840,7 +1841,7 @@ export class Tasklet extends SDFGNode {
}
} else if (token.type.startsWith('number')) {
taskletToken.type = TaskletCodeTokenType.Number;
}
}

highlightedLine.push(taskletToken);
}
Expand Down Expand Up @@ -2143,10 +2144,10 @@ export class NestedSDFG extends SDFGNode {
const labelsize =
this.data.node.attributes.label.length * SDFV.LINEHEIGHT * 0.8;
const inconnsize = 2 * SDFV.LINEHEIGHT * Object.keys(
this.data.node.attributes.in_connectors
this.data.node.attributes.in_connectors ?? []
).length - SDFV.LINEHEIGHT;
const outconnsize = 2 * SDFV.LINEHEIGHT * Object.keys(
this.data.node.attributes.out_connectors
this.data.node.attributes.out_connectors ?? []
).length - SDFV.LINEHEIGHT;
const maxwidth = Math.max(labelsize, inconnsize, outconnsize);
let maxheight = 2 * SDFV.LINEHEIGHT;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/sdfg/display.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function sdfg_property_to_string(
prop: any,
settings: any = null
): string {
if (prop === null) return prop;
if (prop === null || prop === undefined) return prop;
if (typeof prop === 'boolean') {
if (prop)
return 'True';
Expand Down

0 comments on commit 1f44437

Please sign in to comment.