summaryrefslogtreecommitdiff
path: root/deps/v8/tools/turbolizer/src/edge.ts
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/tools/turbolizer/src/edge.ts')
-rw-r--r--deps/v8/tools/turbolizer/src/edge.ts70
1 files changed, 33 insertions, 37 deletions
diff --git a/deps/v8/tools/turbolizer/src/edge.ts b/deps/v8/tools/turbolizer/src/edge.ts
index 7ca6d9dba0..30d265c561 100644
--- a/deps/v8/tools/turbolizer/src/edge.ts
+++ b/deps/v8/tools/turbolizer/src/edge.ts
@@ -2,19 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-import {GNode, DEFAULT_NODE_BUBBLE_RADIUS} from "./node.js"
+import { GNode, DEFAULT_NODE_BUBBLE_RADIUS } from "../src/node";
+import { Graph } from "./graph";
export const MINIMUM_EDGE_SEPARATION = 20;
-export function isEdgeInitiallyVisible(target, index, source, type) {
- return type == "control" && (target.cfg || source.cfg);
-}
-
export class Edge {
target: GNode;
source: GNode;
index: number;
- type: String;
+ type: string;
backEdgeNumber: number;
visible: boolean;
@@ -24,55 +21,54 @@ export class Edge {
this.index = index;
this.type = type;
this.backEdgeNumber = 0;
- this.visible = isEdgeInitiallyVisible(target, index, source, type);
+ this.visible = false;
}
-
stringID() {
return this.source.id + "," + this.index + "," + this.target.id;
- };
+ }
isVisible() {
return this.visible && this.source.visible && this.target.visible;
- };
+ }
- getInputHorizontalPosition(graph) {
+ getInputHorizontalPosition(graph: Graph, showTypes: boolean) {
if (this.backEdgeNumber > 0) {
return graph.maxGraphNodeX + this.backEdgeNumber * MINIMUM_EDGE_SEPARATION;
}
- var source = this.source;
- var target = this.target;
- var index = this.index;
- var input_x = target.x + target.getInputX(index);
- var inputApproach = target.getInputApproach(this.index);
- var outputApproach = source.getOutputApproach(graph);
+ const source = this.source;
+ const target = this.target;
+ const index = this.index;
+ const inputX = target.x + target.getInputX(index);
+ const inputApproach = target.getInputApproach(this.index);
+ const outputApproach = source.getOutputApproach(showTypes);
if (inputApproach > outputApproach) {
- return input_x;
+ return inputX;
} else {
- var inputOffset = MINIMUM_EDGE_SEPARATION * (index + 1);
+ const inputOffset = MINIMUM_EDGE_SEPARATION * (index + 1);
return (target.x < source.x)
? (target.x + target.getTotalNodeWidth() + inputOffset)
- : (target.x - inputOffset)
+ : (target.x - inputOffset);
}
}
- generatePath(graph) {
- var target = this.target;
- var source = this.source;
- var input_x = target.x + target.getInputX(this.index);
- var arrowheadHeight = 7;
- var input_y = target.y - 2 * DEFAULT_NODE_BUBBLE_RADIUS - arrowheadHeight;
- var output_x = source.x + source.getOutputX();
- var output_y = source.y + graph.getNodeHeight(source) + DEFAULT_NODE_BUBBLE_RADIUS;
- var inputApproach = target.getInputApproach(this.index);
- var outputApproach = source.getOutputApproach(graph);
- var horizontalPos = this.getInputHorizontalPosition(graph);
-
- var result = "M" + output_x + "," + output_y +
- "L" + output_x + "," + outputApproach +
+ generatePath(graph: Graph, showTypes: boolean) {
+ const target = this.target;
+ const source = this.source;
+ const inputX = target.x + target.getInputX(this.index);
+ const arrowheadHeight = 7;
+ const inputY = target.y - 2 * DEFAULT_NODE_BUBBLE_RADIUS - arrowheadHeight;
+ const outputX = source.x + source.getOutputX();
+ const outputY = source.y + source.getNodeHeight(showTypes) + DEFAULT_NODE_BUBBLE_RADIUS;
+ let inputApproach = target.getInputApproach(this.index);
+ const outputApproach = source.getOutputApproach(showTypes);
+ const horizontalPos = this.getInputHorizontalPosition(graph, showTypes);
+
+ let result = "M" + outputX + "," + outputY +
+ "L" + outputX + "," + outputApproach +
"L" + horizontalPos + "," + outputApproach;
- if (horizontalPos != input_x) {
+ if (horizontalPos != inputX) {
result += "L" + horizontalPos + "," + inputApproach;
} else {
if (inputApproach < outputApproach) {
@@ -80,8 +76,8 @@ export class Edge {
}
}
- result += "L" + input_x + "," + inputApproach +
- "L" + input_x + "," + input_y;
+ result += "L" + inputX + "," + inputApproach +
+ "L" + inputX + "," + inputY;
return result;
}