From bfd45a75dd8bcdc5b793c72da8e72244667153e0 Mon Sep 17 00:00:00 2001 From: Philipp Schaad Date: Tue, 24 Oct 2023 11:12:37 +0200 Subject: [PATCH] Adapt to change in naming --- src/renderer/renderer.ts | 28 ++++++++-------- src/renderer/renderer_elements.ts | 56 +++++++++++++++---------------- 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/src/renderer/renderer.ts b/src/renderer/renderer.ts index 2def3559..706906cb 100644 --- a/src/renderer/renderer.ts +++ b/src/renderer/renderer.ts @@ -47,13 +47,13 @@ import { deepCopy, intersectRect, showErrorModal } from '../utils/utils'; import { CanvasManager } from './canvas_manager'; import { AccessNode, Connector, - Edge, EntryNode, InterstateEdge, LoopScopeBlock, Memlet, NestedSDFG, + Edge, EntryNode, InterstateEdge, LoopRegion, Memlet, NestedSDFG, SDFG, SDFGElement, SDFGElementType, SDFGElements, SDFGNode, - ScopeBlock, + ControlFlowRegion, State, Tasklet, drawSDFG, @@ -2651,7 +2651,7 @@ export class SDFGRenderer extends EventEmitter { let sdfg_elem = null; if (foreground_elem instanceof State) sdfg_elem = foreground_elem.data.state; - else if (foreground_elem instanceof ScopeBlock) + else if (foreground_elem instanceof ControlFlowRegion) sdfg_elem = foreground_elem.data.block; else if (foreground_elem instanceof SDFGNode) { sdfg_elem = foreground_elem.data.node; @@ -3337,9 +3337,9 @@ function relayoutStateMachine( let blockGraph = null; if (block.attributes.is_collapsed) { blockInfo.height = SDFV.LINEHEIGHT; - if (blockElem instanceof LoopScopeBlock) { + if (blockElem instanceof LoopRegion) { const oldFont = ctx.font; - ctx.font = LoopScopeBlock.LOOP_STATEMENT_FONT; + ctx.font = LoopRegion.LOOP_STATEMENT_FONT; const labelWidths = [ ctx.measureText( (block.attributes.scope_condition?.string_data ?? '') + @@ -3358,7 +3358,7 @@ function relayoutStateMachine( ctx.font = oldFont; blockInfo.width = Math.max( maxLabelWidth, ctx.measureText(block.label).width - ) + 3 * LoopScopeBlock.META_LABEL_MARGIN; + ) + 3 * LoopRegion.META_LABEL_MARGIN; } else if (blockElem instanceof State) { blockInfo.width = ctx.measureText(blockInfo.label).width; } @@ -3373,16 +3373,16 @@ function relayoutStateMachine( blockInfo.width += 2 * BLOCK_MARGIN; blockInfo.height += 2 * BLOCK_MARGIN; - if (blockElem instanceof LoopScopeBlock) { + if (blockElem instanceof LoopRegion) { // Add spacing for the condition if the loop is not inverted. if (!block.attributes.inverted) - blockInfo.height += LoopScopeBlock.CONDITION_SPACING; + blockInfo.height += LoopRegion.CONDITION_SPACING; // If there's an init statement, add space for it. if (block.attributes.init_statement) - blockInfo.height += LoopScopeBlock.INIT_SPACING; + blockInfo.height += LoopRegion.INIT_SPACING; // If there's an update statement, also add space for it. if (block.attributes.update_statement) - blockInfo.height += LoopScopeBlock.UPDATE_SPACING; + blockInfo.height += LoopRegion.UPDATE_SPACING; } blockElem.data.layout = blockInfo; @@ -3454,13 +3454,13 @@ function relayoutStateMachine( // Base spacing for the inside. let topSpacing = BLOCK_MARGIN; - if (gBlock instanceof LoopScopeBlock) { + if (gBlock instanceof LoopRegion) { // Add spacing for the condition if the loop isn't inverted. if (!block.attributes.inverted) - topSpacing += LoopScopeBlock.CONDITION_SPACING; + topSpacing += LoopRegion.CONDITION_SPACING; // If there's an init statement, add space for it. if (block.attributes.init_statement) - topSpacing += LoopScopeBlock.INIT_SPACING; + topSpacing += LoopRegion.INIT_SPACING; } offset_sdfg(block as any, gBlock.data.graph, { x: topleft.x + BLOCK_MARGIN, @@ -3861,7 +3861,7 @@ function relayoutSDFGBlock( omitAccessNodes: boolean, parent: SDFGElement ): DagreSDFG | null { switch (block.type) { - case SDFGElementType.LoopScopeBlock: + case SDFGElementType.LoopRegion: return relayoutStateMachine( ctx, block as StateMachineType, sdfg, sdfgList, stateParentList, omitAccessNodes, parent diff --git a/src/renderer/renderer_elements.ts b/src/renderer/renderer_elements.ts index 0be4c07a..db6902a7 100644 --- a/src/renderer/renderer_elements.ts +++ b/src/renderer/renderer_elements.ts @@ -39,8 +39,8 @@ export enum SDFGElementType { Reduce = 'Reduce', BasicBlock = 'BasicBlock', ControlFlowBlock = 'ControlFlowBlock', - ScopeBlock = 'ScopeBlock', - LoopScopeBlock = 'LoopScopeBlock', + ControlFlowRegion = 'ControlFlowRegion', + LoopRegion = 'LoopRegion', } export class SDFGElement { @@ -232,7 +232,7 @@ export class ControlFlowBlock extends SDFGElement { export class BasicBlock extends SDFGElement { } -export class ScopeBlock extends ControlFlowBlock { +export class ControlFlowRegion extends ControlFlowBlock { } export class State extends BasicBlock { @@ -385,7 +385,7 @@ export class State extends BasicBlock { } -export class LoopScopeBlock extends ScopeBlock { +export class LoopRegion extends ControlFlowRegion { public static readonly META_LABEL_MARGIN: number = 5; @@ -458,22 +458,22 @@ export class LoopScopeBlock extends ScopeBlock { ); const oldFont = ctx.font; - let topSpacing = LoopScopeBlock.META_LABEL_MARGIN; + let topSpacing = LoopRegion.META_LABEL_MARGIN; let remainingHeight = this.height; // Draw the init statement if there is one. if (this.attributes().init_statement) { - topSpacing += LoopScopeBlock.INIT_SPACING; - const initBottomLineY = topleft.y + LoopScopeBlock.INIT_SPACING; + topSpacing += LoopRegion.INIT_SPACING; + const initBottomLineY = topleft.y + LoopRegion.INIT_SPACING; ctx.beginPath(); ctx.moveTo(topleft.x, initBottomLineY); ctx.lineTo(topleft.x + this.width, initBottomLineY); ctx.stroke(); - ctx.font = LoopScopeBlock.LOOP_STATEMENT_FONT; + ctx.font = LoopRegion.LOOP_STATEMENT_FONT; const initStatement = this.attributes().init_statement.string_data; const initTextY = ( - (topleft.y + (LoopScopeBlock.INIT_SPACING / 2)) + + (topleft.y + (LoopRegion.INIT_SPACING / 2)) + (SDFV.LINEHEIGHT / 2) ); const initTextMetrics = ctx.measureText(initStatement); @@ -482,7 +482,7 @@ export class LoopScopeBlock extends ScopeBlock { ctx.font = oldFont; ctx.fillText( - 'init', topleft.x + LoopScopeBlock.META_LABEL_MARGIN, initTextY + 'init', topleft.x + LoopRegion.META_LABEL_MARGIN, initTextY ); } @@ -491,24 +491,24 @@ export class LoopScopeBlock extends ScopeBlock { // (do-while-style) loop). If the condition is drawn on top, make sure // the init statement spacing is respected if there is one. let condTopY = topleft.y; - let condLineY = condTopY + LoopScopeBlock.CONDITION_SPACING; + let condLineY = condTopY + LoopRegion.CONDITION_SPACING; if (this.attributes().inverted) { condTopY = topleft.y + - (this.height - LoopScopeBlock.CONDITION_SPACING); - condLineY = condTopY - LoopScopeBlock.CONDITION_SPACING; + (this.height - LoopRegion.CONDITION_SPACING); + condLineY = condTopY - LoopRegion.CONDITION_SPACING; } else if (this.attributes().init_statement) { - condTopY += LoopScopeBlock.INIT_SPACING; - condLineY = condTopY + LoopScopeBlock.CONDITION_SPACING; + condTopY += LoopRegion.INIT_SPACING; + condLineY = condTopY + LoopRegion.CONDITION_SPACING; } - topSpacing += LoopScopeBlock.CONDITION_SPACING; + topSpacing += LoopRegion.CONDITION_SPACING; ctx.beginPath(); ctx.moveTo(topleft.x, condLineY); ctx.lineTo(topleft.x + this.width, condLineY); ctx.stroke(); - ctx.font = LoopScopeBlock.LOOP_STATEMENT_FONT; - const condStatement = this.attributes().scope_condition.string_data; + ctx.font = LoopRegion.LOOP_STATEMENT_FONT; + const condStatement = this.attributes().loop_condition.string_data; const condTextY = ( - (condTopY + (LoopScopeBlock.CONDITION_SPACING / 2)) + + (condTopY + (LoopRegion.CONDITION_SPACING / 2)) + (SDFV.LINEHEIGHT / 2) ); const condTextMetrics = ctx.measureText(condStatement); @@ -516,25 +516,25 @@ export class LoopScopeBlock extends ScopeBlock { ctx.fillText(condStatement, condTextX, condTextY); ctx.font = oldFont; ctx.fillText( - 'while', topleft.x + LoopScopeBlock.META_LABEL_MARGIN, condTextY + 'while', topleft.x + LoopRegion.META_LABEL_MARGIN, condTextY ); // Draw the update statement if there is one. if (this.attributes().update_statement) { - remainingHeight -= LoopScopeBlock.UPDATE_SPACING; + remainingHeight -= LoopRegion.UPDATE_SPACING; const updateTopY = topleft.y + ( - this.height - LoopScopeBlock.UPDATE_SPACING + this.height - LoopRegion.UPDATE_SPACING ); ctx.beginPath(); ctx.moveTo(topleft.x, updateTopY); ctx.lineTo(topleft.x + this.width, updateTopY); ctx.stroke(); - ctx.font = LoopScopeBlock.LOOP_STATEMENT_FONT; + ctx.font = LoopRegion.LOOP_STATEMENT_FONT; const updateStatement = this.attributes().update_statement.string_data; const updateTextY = ( - (updateTopY + (LoopScopeBlock.UPDATE_SPACING / 2)) + + (updateTopY + (LoopRegion.UPDATE_SPACING / 2)) + (SDFV.LINEHEIGHT / 2) ); const updateTextMetrics = ctx.measureText(updateStatement); @@ -542,7 +542,7 @@ export class LoopScopeBlock extends ScopeBlock { ctx.fillText(updateStatement, updateTextX, updateTextY); ctx.font = oldFont; ctx.fillText( - 'update', topleft.x + LoopScopeBlock.META_LABEL_MARGIN, + 'update', topleft.x + LoopRegion.META_LABEL_MARGIN, updateTextY ); } @@ -554,7 +554,7 @@ export class LoopScopeBlock extends ScopeBlock { visibleRect.y <= topleft.y + SDFV.LINEHEIGHT && SDFVSettings.showStateNames) ctx.fillText( - this.label(), topleft.x + LoopScopeBlock.META_LABEL_MARGIN, + this.label(), topleft.x + LoopRegion.META_LABEL_MARGIN, topleft.y + topSpacing + SDFV.LINEHEIGHT ); @@ -2661,6 +2661,6 @@ export const SDFGElements: { [name: string]: typeof SDFGElement } = { ControlFlowBlock, BasicBlock, State, - ScopeBlock, - LoopScopeBlock, + ControlFlowRegion: ControlFlowRegion, + LoopRegion: LoopRegion, };