Commit 45669e9b authored by Sigurd Schneider's avatar Sigurd Schneider Committed by Commit Bot

[turbolizer] Add semicolons consistently after statements

Change-Id: I8e147bcb5d1e0b8e16874f0593a8ce4338dfc201
Notry: true
Bug: v8:7327
Reviewed-on: https://chromium-review.googlesource.com/c/1405319
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58760}
parent a6356ac6
...@@ -2,17 +2,17 @@ ...@@ -2,17 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import { Source, SourceResolver, sourcePositionToStringKey } from "../src/source-resolver" import { Source, SourceResolver, sourcePositionToStringKey } from "../src/source-resolver";
import { SelectionBroker } from "../src/selection-broker" import { SelectionBroker } from "../src/selection-broker";
import { View } from "../src/view" import { View } from "../src/view";
import { MySelection } from "../src/selection" import { MySelection } from "../src/selection";
import { ViewElements } from "../src/util" import { ViewElements } from "../src/util";
import { SelectionHandler } from "./selection-handler"; import { SelectionHandler } from "./selection-handler";
export enum CodeMode { export enum CodeMode {
MAIN_SOURCE = "main function", MAIN_SOURCE = "main function",
INLINED_SOURCE = "inlined function" INLINED_SOURCE = "inlined function"
}; }
export class CodeView extends View { export class CodeView extends View {
broker: SelectionBroker; broker: SelectionBroker;
...@@ -44,7 +44,7 @@ export class CodeView extends View { ...@@ -44,7 +44,7 @@ export class CodeView extends View {
clear: function () { clear: function () {
view.selection.clear(); view.selection.clear();
view.updateSelection(); view.updateSelection();
broker.broadcastClear(this) broker.broadcastClear(this);
}, },
select: function (sourcePositions, selected) { select: function (sourcePositions, selected) {
const locations = []; const locations = [];
...@@ -170,7 +170,7 @@ export class CodeView extends View { ...@@ -170,7 +170,7 @@ export class CodeView extends View {
} else { } else {
codePre.style.display = "none"; codePre.style.display = "none";
} }
} };
if (sourceText != "") { if (sourceText != "") {
codePre.classList.add("linenums"); codePre.classList.add("linenums");
codePre.textContent = sourceText; codePre.textContent = sourceText;
...@@ -191,7 +191,7 @@ export class CodeView extends View { ...@@ -191,7 +191,7 @@ export class CodeView extends View {
} else { } else {
view.selectionHandler.clear(); view.selectionHandler.clear();
} }
} };
const base: number = source.startPosition; const base: number = source.startPosition;
let current = 0; let current = 0;
...@@ -239,21 +239,21 @@ export class CodeView extends View { ...@@ -239,21 +239,21 @@ export class CodeView extends View {
const replacementNode = textnode.splitText(splitLength); const replacementNode = textnode.splitText(splitLength);
const span = document.createElement('span'); const span = document.createElement('span');
span.setAttribute("scriptOffset", sourcePosition.scriptOffset); span.setAttribute("scriptOffset", sourcePosition.scriptOffset);
span.classList.add("source-position") span.classList.add("source-position");
const marker = document.createElement('span'); const marker = document.createElement('span');
marker.classList.add("marker") marker.classList.add("marker");
span.appendChild(marker); span.appendChild(marker);
const inlining = this.sourceResolver.getInliningForPosition(sourcePosition); const inlining = this.sourceResolver.getInliningForPosition(sourcePosition);
if (inlining != undefined && view.showAdditionalInliningPosition) { if (inlining != undefined && view.showAdditionalInliningPosition) {
const sourceName = this.sourceResolver.getSourceName(inlining.sourceId); const sourceName = this.sourceResolver.getSourceName(inlining.sourceId);
const inliningMarker = document.createElement('span'); const inliningMarker = document.createElement('span');
inliningMarker.classList.add("inlining-marker") inliningMarker.classList.add("inlining-marker");
inliningMarker.setAttribute("data-descr", `${sourceName} was inlined here`) inliningMarker.setAttribute("data-descr", `${sourceName} was inlined here`);
span.appendChild(inliningMarker); span.appendChild(inliningMarker);
} }
span.onclick = function (e) { span.onclick = function (e) {
e.stopPropagation(); e.stopPropagation();
view.onSelectSourcePosition(sourcePosition, !e.shiftKey) view.onSelectSourcePosition(sourcePosition, !e.shiftKey);
}; };
view.addHtmlElementToSourcePosition(sourcePosition, span); view.addHtmlElementToSourcePosition(sourcePosition, span);
textnode.parentNode.insertBefore(span, replacementNode); textnode.parentNode.insertBefore(span, replacementNode);
...@@ -266,7 +266,7 @@ export class CodeView extends View { ...@@ -266,7 +266,7 @@ export class CodeView extends View {
lineNumberElement.classList.add("line-number"); lineNumberElement.classList.add("line-number");
lineNumberElement.dataset.lineNumber = `${lineNumber}`; lineNumberElement.dataset.lineNumber = `${lineNumber}`;
lineNumberElement.innerText = `${lineNumber}`; lineNumberElement.innerText = `${lineNumber}`;
lineElement.insertBefore(lineNumberElement, lineElement.firstChild) lineElement.insertBefore(lineNumberElement, lineElement.firstChild);
// Don't add lines to source positions of not in backwardsCompatibility mode. // Don't add lines to source positions of not in backwardsCompatibility mode.
if (this.source.backwardsCompatibility === true) { if (this.source.backwardsCompatibility === true) {
for (const sourcePosition of this.sourceResolver.linetoSourcePositions(lineNumber - 1)) { for (const sourcePosition of this.sourceResolver.linetoSourcePositions(lineNumber - 1)) {
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import { PROF_COLS, UNICODE_BLOCK } from "../src/constants" import { PROF_COLS, UNICODE_BLOCK } from "../src/constants";
import { SelectionBroker } from "../src/selection-broker" import { SelectionBroker } from "../src/selection-broker";
import { TextView } from "../src/text-view" import { TextView } from "../src/text-view";
import { MySelection } from "./selection"; import { MySelection } from "./selection";
import { anyToString, interpolate } from "./util"; import { anyToString, interpolate } from "./util";
import { InstructionSelectionHandler } from "./selection-handler"; import { InstructionSelectionHandler } from "./selection-handler";
...@@ -14,7 +14,7 @@ const toolboxHTML = `<div id="disassembly-toolbox"> ...@@ -14,7 +14,7 @@ const toolboxHTML = `<div id="disassembly-toolbox">
<input id="show-instruction-address" type="checkbox" name="instruction-address">Show addresses</input> <input id="show-instruction-address" type="checkbox" name="instruction-address">Show addresses</input>
<input id="show-instruction-binary" type="checkbox" name="instruction-binary">Show binary literal</input> <input id="show-instruction-binary" type="checkbox" name="instruction-binary">Show binary literal</input>
</form> </form>
</div>` </div>`;
export class DisassemblyView extends TextView { export class DisassemblyView extends TextView {
SOURCE_POSITION_HEADER_REGEX: any; SOURCE_POSITION_HEADER_REGEX: any;
...@@ -52,9 +52,9 @@ export class DisassemblyView extends TextView { ...@@ -52,9 +52,9 @@ export class DisassemblyView extends TextView {
const offsetElement = document.createElement("SPAN"); const offsetElement = document.createElement("SPAN");
offsetElement.innerText = matches.groups["offset"]; offsetElement.innerText = matches.groups["offset"];
fragment.appendChild(addressElement); fragment.appendChild(addressElement);
fragment.appendChild(document.createTextNode(matches.groups["addressSpace"])) fragment.appendChild(document.createTextNode(matches.groups["addressSpace"]));
fragment.appendChild(offsetElement); fragment.appendChild(offsetElement);
fragment.appendChild(document.createTextNode(matches.groups["offsetSpace"])) fragment.appendChild(document.createTextNode(matches.groups["offsetSpace"]));
fragment.classList.add('tag'); fragment.classList.add('tag');
if (!Number.isNaN(offset)) { if (!Number.isNaN(offset)) {
...@@ -79,10 +79,10 @@ export class DisassemblyView extends TextView { ...@@ -79,10 +79,10 @@ export class DisassemblyView extends TextView {
fragment.innerHTML = text; fragment.innerHTML = text;
const replacer = (match, hexOffset) => { const replacer = (match, hexOffset) => {
const offset = Number.parseInt(hexOffset, 16); const offset = Number.parseInt(hexOffset, 16);
const keyOffset = view.sourceResolver.getKeyPcOffset(offset) const keyOffset = view.sourceResolver.getKeyPcOffset(offset);
return `<span class="tag linkable-text" data-pc-offset="${keyOffset}">${match}</span>` return `<span class="tag linkable-text" data-pc-offset="${keyOffset}">${match}</span>`;
} };
const html = text.replace(/<.0?x?([0-9a-fA-F]+)>/g, replacer) const html = text.replace(/<.0?x?([0-9a-fA-F]+)>/g, replacer);
fragment.innerHTML = html; fragment.innerHTML = html;
} }
}; };
...@@ -139,7 +139,7 @@ export class DisassemblyView extends TextView { ...@@ -139,7 +139,7 @@ export class DisassemblyView extends TextView {
const offset = Number.parseInt(offsetAsString, 10); const offset = Number.parseInt(offsetAsString, 10);
if ((typeof offsetAsString) != "undefined" && !Number.isNaN(offset)) { if ((typeof offsetAsString) != "undefined" && !Number.isNaN(offset)) {
view.offsetSelection.select([offset], true); view.offsetSelection.select([offset], true);
const nodes = view.sourceResolver.nodesForPCOffset(offset)[0] const nodes = view.sourceResolver.nodesForPCOffset(offset)[0];
if (nodes.length > 0) { if (nodes.length > 0) {
e.stopPropagation(); e.stopPropagation();
if (!e.shiftKey) { if (!e.shiftKey) {
...@@ -151,7 +151,7 @@ export class DisassemblyView extends TextView { ...@@ -151,7 +151,7 @@ export class DisassemblyView extends TextView {
} }
} }
return undefined; return undefined;
} };
view.divNode.addEventListener('click', linkHandler); view.divNode.addEventListener('click', linkHandler);
const linkHandlerBlock = e => { const linkHandlerBlock = e => {
...@@ -162,8 +162,8 @@ export class DisassemblyView extends TextView { ...@@ -162,8 +162,8 @@ export class DisassemblyView extends TextView {
view.selectionHandler.clear(); view.selectionHandler.clear();
} }
view.blockSelectionHandler.select([blockId], true); view.blockSelectionHandler.select([blockId], true);
}; }
} };
view.divNode.addEventListener('click', linkHandlerBlock); view.divNode.addEventListener('click', linkHandlerBlock);
this.offsetSelection = new MySelection(anyToString); this.offsetSelection = new MySelection(anyToString);
...@@ -192,9 +192,9 @@ export class DisassemblyView extends TextView { ...@@ -192,9 +192,9 @@ export class DisassemblyView extends TextView {
this.instructionSelectionHandler = instructionSelectionHandler; this.instructionSelectionHandler = instructionSelectionHandler;
broker.addInstructionHandler(instructionSelectionHandler); broker.addInstructionHandler(instructionSelectionHandler);
const toolbox = document.createElement("div") const toolbox = document.createElement("div");
toolbox.id = "toolbox-anchor"; toolbox.id = "toolbox-anchor";
toolbox.innerHTML = toolboxHTML toolbox.innerHTML = toolboxHTML;
view.divNode.insertBefore(toolbox, view.divNode.firstChild); view.divNode.insertBefore(toolbox, view.divNode.firstChild);
const instructionAddressInput: HTMLInputElement = view.divNode.querySelector("#show-instruction-address"); const instructionAddressInput: HTMLInputElement = view.divNode.querySelector("#show-instruction-address");
const lastShowInstructionAddress = window.sessionStorage.getItem("show-instruction-address"); const lastShowInstructionAddress = window.sessionStorage.getItem("show-instruction-address");
...@@ -226,11 +226,11 @@ export class DisassemblyView extends TextView { ...@@ -226,11 +226,11 @@ export class DisassemblyView extends TextView {
let keyPcOffsets = this.sourceResolver.nodesToKeyPcOffsets(this.selection.selectedKeys()); let keyPcOffsets = this.sourceResolver.nodesToKeyPcOffsets(this.selection.selectedKeys());
if (this.offsetSelection) { if (this.offsetSelection) {
for (const key of this.offsetSelection.selectedKeys()) { for (const key of this.offsetSelection.selectedKeys()) {
keyPcOffsets.push(Number(key)) keyPcOffsets.push(Number(key));
} }
} }
for (const keyPcOffset of keyPcOffsets) { for (const keyPcOffset of keyPcOffsets) {
const elementsToSelect = this.divNode.querySelectorAll(`[data-pc-offset='${keyPcOffset}']`) const elementsToSelect = this.divNode.querySelectorAll(`[data-pc-offset='${keyPcOffset}']`);
for (const el of elementsToSelect) { for (const el of elementsToSelect) {
el.classList.toggle("selected", true); el.classList.toggle("selected", true);
} }
...@@ -281,11 +281,11 @@ export class DisassemblyView extends TextView { ...@@ -281,11 +281,11 @@ export class DisassemblyView extends TextView {
} }
initializeContent(data, rememberedSelection) { initializeContent(data, rememberedSelection) {
console.time("disassembly-view") console.time("disassembly-view");
super.initializeContent(data, rememberedSelection); super.initializeContent(data, rememberedSelection);
this.showInstructionAddressHandler(); this.showInstructionAddressHandler();
this.showInstructionBinaryHandler(); this.showInstructionBinaryHandler();
console.timeEnd("disassembly-view") console.timeEnd("disassembly-view");
} }
// Shorten decimals and remove trailing zeroes for readability. // Shorten decimals and remove trailing zeroes for readability.
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import { GNode, DEFAULT_NODE_BUBBLE_RADIUS } from "../src/node" import { GNode, DEFAULT_NODE_BUBBLE_RADIUS } from "../src/node";
import { Graph } from "./graph"; import { Graph } from "./graph";
export const MINIMUM_EDGE_SEPARATION = 20; export const MINIMUM_EDGE_SEPARATION = 20;
...@@ -26,11 +26,11 @@ export class Edge { ...@@ -26,11 +26,11 @@ export class Edge {
stringID() { stringID() {
return this.source.id + "," + this.index + "," + this.target.id; return this.source.id + "," + this.index + "," + this.target.id;
}; }
isVisible() { isVisible() {
return this.visible && this.source.visible && this.target.visible; return this.visible && this.source.visible && this.target.visible;
}; }
getInputHorizontalPosition(graph: Graph, showTypes: boolean) { getInputHorizontalPosition(graph: Graph, showTypes: boolean) {
if (this.backEdgeNumber > 0) { if (this.backEdgeNumber > 0) {
...@@ -48,7 +48,7 @@ export class Edge { ...@@ -48,7 +48,7 @@ export class Edge {
var inputOffset = MINIMUM_EDGE_SEPARATION * (index + 1); var inputOffset = MINIMUM_EDGE_SEPARATION * (index + 1);
return (target.x < source.x) return (target.x < source.x)
? (target.x + target.getTotalNodeWidth() + inputOffset) ? (target.x + target.getTotalNodeWidth() + inputOffset)
: (target.x - inputOffset) : (target.x - inputOffset);
} }
} }
......
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import { MAX_RANK_SENTINEL } from "../src/constants" import { MAX_RANK_SENTINEL } from "../src/constants";
import { MINIMUM_EDGE_SEPARATION, Edge } from "../src/edge" import { MINIMUM_EDGE_SEPARATION, Edge } from "../src/edge";
import { NODE_INPUT_WIDTH, MINIMUM_NODE_OUTPUT_APPROACH, DEFAULT_NODE_BUBBLE_RADIUS, GNode } from "../src/node" import { NODE_INPUT_WIDTH, MINIMUM_NODE_OUTPUT_APPROACH, DEFAULT_NODE_BUBBLE_RADIUS, GNode } from "../src/node";
import { Graph } from "./graph"; import { Graph } from "./graph";
const DEFAULT_NODE_ROW_SEPARATION = 130 const DEFAULT_NODE_ROW_SEPARATION = 130;
const traceLayout = false; const traceLayout = false;
function newGraphOccupation(graph: Graph) { function newGraphOccupation(graph: Graph) {
...@@ -29,7 +29,7 @@ function newGraphOccupation(graph: Graph) { ...@@ -29,7 +29,7 @@ function newGraphOccupation(graph: Graph) {
} }
function slotToLeftPosition(slot: number) { function slotToLeftPosition(slot: number) {
return slot * NODE_INPUT_WIDTH return slot * NODE_INPUT_WIDTH;
} }
function findSpace(pos: number, width: number, direction: number) { function findSpace(pos: number, width: number, direction: number) {
...@@ -45,9 +45,9 @@ function newGraphOccupation(graph: Graph) { ...@@ -45,9 +45,9 @@ function newGraphOccupation(graph: Graph) {
currentScanSlot = currentSlot + (mod ? -1 : 1) * (slotsChecked >> 1); currentScanSlot = currentSlot + (mod ? -1 : 1) * (slotsChecked >> 1);
if (!isSlotFilled[slotToIndex(currentScanSlot)]) { if (!isSlotFilled[slotToIndex(currentScanSlot)]) {
if (mod) { if (mod) {
if (direction <= 0)--widthSlotsRemainingLeft if (direction <= 0) --widthSlotsRemainingLeft;
} else { } else {
if (direction >= 0)--widthSlotsRemainingRight if (direction >= 0) --widthSlotsRemainingRight;
} }
if (widthSlotsRemainingLeft == 0 || if (widthSlotsRemainingLeft == 0 ||
widthSlotsRemainingRight == 0 || widthSlotsRemainingRight == 0 ||
...@@ -169,7 +169,7 @@ function newGraphOccupation(graph: Graph) { ...@@ -169,7 +169,7 @@ function newGraphOccupation(graph: Graph) {
direction = 0; direction = 0;
} }
return [direction, pos]; return [direction, pos];
} };
const width = node.getTotalNodeWidth(); const width = node.getTotalNodeWidth();
const margin = MINIMUM_EDGE_SEPARATION; const margin = MINIMUM_EDGE_SEPARATION;
const paddedWidth = width + 2 * margin; const paddedWidth = width + 2 * margin;
...@@ -233,7 +233,7 @@ function newGraphOccupation(graph: Graph) { ...@@ -233,7 +233,7 @@ function newGraphOccupation(graph: Graph) {
} }
console.log(s); console.log(s);
} }
} };
return occupation; return occupation;
} }
...@@ -248,7 +248,7 @@ export function layoutNodeGraph(graph: Graph, showTypes: boolean): void { ...@@ -248,7 +248,7 @@ export function layoutNodeGraph(graph: Graph, showTypes: boolean): void {
for (const n of graph.nodes()) { for (const n of graph.nodes()) {
endNodesHasNoOutputs[n.id] = true; endNodesHasNoOutputs[n.id] = true;
startNodesHasNoInputs[n.id] = true; startNodesHasNoInputs[n.id] = true;
}; }
graph.forEachEdge((e: Edge) => { graph.forEachEdge((e: Edge) => {
endNodesHasNoOutputs[e.source.id] = false; endNodesHasNoOutputs[e.source.id] = false;
startNodesHasNoInputs[e.target.id] = false; startNodesHasNoInputs[e.target.id] = false;
...@@ -271,7 +271,7 @@ export function layoutNodeGraph(graph: Graph, showTypes: boolean): void { ...@@ -271,7 +271,7 @@ export function layoutNodeGraph(graph: Graph, showTypes: boolean): void {
n.rank = 0; n.rank = 0;
n.visitOrderWithinRank = 0; n.visitOrderWithinRank = 0;
n.outputApproach = MINIMUM_NODE_OUTPUT_APPROACH; n.outputApproach = MINIMUM_NODE_OUTPUT_APPROACH;
}; }
if (traceLayout) { if (traceLayout) {
console.log(`layoutGraph init ${performance.now() - start}`); console.log(`layoutGraph init ${performance.now() - start}`);
...@@ -382,7 +382,7 @@ export function layoutNodeGraph(graph: Graph, showTypes: boolean): void { ...@@ -382,7 +382,7 @@ export function layoutNodeGraph(graph: Graph, showTypes: boolean): void {
rankSets[n.rank].push(n); rankSets[n.rank].push(n);
} }
} }
}; }
// Iterate backwards from highest to lowest rank, placing nodes so that they // Iterate backwards from highest to lowest rank, placing nodes so that they
// spread out from the "center" as much as possible while still being // spread out from the "center" as much as possible while still being
...@@ -403,7 +403,7 @@ export function layoutNodeGraph(graph: Graph, showTypes: boolean): void { ...@@ -403,7 +403,7 @@ export function layoutNodeGraph(graph: Graph, showTypes: boolean): void {
let placedCount = 0; let placedCount = 0;
rankSet = rankSet.sort((a: GNode, b: GNode) => { rankSet = rankSet.sort((a: GNode, b: GNode) => {
if (a.visitOrderWithinRank < b.visitOrderWithinRank) { if (a.visitOrderWithinRank < b.visitOrderWithinRank) {
return -1 return -1;
} else if (a.visitOrderWithinRank == b.visitOrderWithinRank) { } else if (a.visitOrderWithinRank == b.visitOrderWithinRank) {
return 0; return 0;
} else { } else {
...@@ -419,7 +419,7 @@ export function layoutNodeGraph(graph: Graph, showTypes: boolean): void { ...@@ -419,7 +419,7 @@ export function layoutNodeGraph(graph: Graph, showTypes: boolean): void {
console.log("Node " + nodeToPlace.id + " is placed between [" + nodeToPlace.x + ", " + (nodeToPlace.x + nodeToPlace.getTotalNodeWidth()) + ")"); console.log("Node " + nodeToPlace.id + " is placed between [" + nodeToPlace.x + ", " + (nodeToPlace.x + nodeToPlace.getTotalNodeWidth()) + ")");
} }
const staggeredFlooredI = Math.floor(placedCount++ % 3); const staggeredFlooredI = Math.floor(placedCount++ % 3);
const delta = MINIMUM_EDGE_SEPARATION * staggeredFlooredI const delta = MINIMUM_EDGE_SEPARATION * staggeredFlooredI;
nodeToPlace.outputApproach += delta; nodeToPlace.outputApproach += delta;
} else { } else {
nodeToPlace.x = 0; nodeToPlace.x = 0;
......
...@@ -2,15 +2,15 @@ ...@@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import * as d3 from "d3" import * as d3 from "d3";
import { layoutNodeGraph } from "../src/graph-layout" import { layoutNodeGraph } from "../src/graph-layout";
import { GNode, nodeToStr } from "../src/node" import { GNode, nodeToStr } from "../src/node";
import { NODE_INPUT_WIDTH } from "../src/node" import { NODE_INPUT_WIDTH } from "../src/node";
import { DEFAULT_NODE_BUBBLE_RADIUS } from "../src/node" import { DEFAULT_NODE_BUBBLE_RADIUS } from "../src/node";
import { Edge, edgeToStr } from "../src/edge" import { Edge, edgeToStr } from "../src/edge";
import { View, PhaseView } from "../src/view" import { View, PhaseView } from "../src/view";
import { MySelection } from "../src/selection" import { MySelection } from "../src/selection";
import { partial } from "../src/util" import { partial } from "../src/util";
import { NodeSelectionHandler, ClearableHandler } from "./selection-handler"; import { NodeSelectionHandler, ClearableHandler } from "./selection-handler";
import { Graph } from "./graph"; import { Graph } from "./graph";
import { SelectionBroker } from "./selection-broker"; import { SelectionBroker } from "./selection-broker";
...@@ -23,9 +23,9 @@ interface GraphState { ...@@ -23,9 +23,9 @@ interface GraphState {
showTypes: boolean; showTypes: boolean;
selection: MySelection; selection: MySelection;
mouseDownNode: any; mouseDownNode: any;
justDragged: boolean, justDragged: boolean;
justScaleTransGraph: boolean, justScaleTransGraph: boolean;
hideDead: boolean hideDead: boolean;
} }
export class GraphView extends View implements PhaseView { export class GraphView extends View implements PhaseView {
...@@ -59,7 +59,7 @@ export class GraphView extends View implements PhaseView { ...@@ -59,7 +59,7 @@ export class GraphView extends View implements PhaseView {
const svg = this.divElement.append("svg") const svg = this.divElement.append("svg")
.attr('version', '2.0') .attr('version', '2.0')
.attr("width", "100%") .attr("width", "100%")
.attr("height", "100%") .attr("height", "100%");
svg.on("click", function (d) { svg.on("click", function (d) {
view.selectionHandler.clear(); view.selectionHandler.clear();
}); });
...@@ -68,7 +68,7 @@ export class GraphView extends View implements PhaseView { ...@@ -68,7 +68,7 @@ export class GraphView extends View implements PhaseView {
svg svg
.attr("focusable", false) .attr("focusable", false)
.on("focus", e => {}) .on("focus", e => {})
.on("keydown", e => { view.svgKeyDown(); }) .on("keydown", e => { view.svgKeyDown(); });
view.svg = svg; view.svg = svg;
...@@ -119,7 +119,7 @@ export class GraphView extends View implements PhaseView { ...@@ -119,7 +119,7 @@ export class GraphView extends View implements PhaseView {
e.visible = e.visible || view.state.selection.isSelected(e.target); e.visible = e.visible || view.state.selection.isSelected(e.target);
}); });
} }
}; }
view.updateGraphVisibility(); view.updateGraphVisibility();
}, },
brokeredClear: function () { brokeredClear: function () {
...@@ -249,12 +249,12 @@ export class GraphView extends View implements PhaseView { ...@@ -249,12 +249,12 @@ export class GraphView extends View implements PhaseView {
deleteContent() { deleteContent() {
for (const n of this.graph.nodes()) { for (const n of this.graph.nodes()) {
n.visible = false; n.visible = false;
}; }
this.graph.forEachEdge((e: Edge) => { this.graph.forEachEdge((e: Edge) => {
e.visible = false; e.visible = false;
}); });
this.updateGraphVisibility(); this.updateGraphVisibility();
}; }
createGraph(data, rememberedSelection) { createGraph(data, rememberedSelection) {
this.graph = new Graph(data); this.graph = new Graph(data);
...@@ -263,7 +263,7 @@ export class GraphView extends View implements PhaseView { ...@@ -263,7 +263,7 @@ export class GraphView extends View implements PhaseView {
if (rememberedSelection != undefined && rememberedSelection.has(nodeToStringKey(n))) { if (rememberedSelection != undefined && rememberedSelection.has(nodeToStringKey(n))) {
n.visible = true; n.visible = true;
} }
}; }
this.graph.forEachEdge((e: Edge) => { this.graph.forEachEdge((e: Edge) => {
e.visible = e.type == 'control' && e.source.visible && e.target.visible; e.visible = e.type == 'control' && e.source.visible && e.target.visible;
}); });
...@@ -357,7 +357,7 @@ export class GraphView extends View implements PhaseView { ...@@ -357,7 +357,7 @@ export class GraphView extends View implements PhaseView {
showAllAction(view: GraphView) { showAllAction(view: GraphView) {
for (const n of view.graph.nodes()) { for (const n of view.graph.nodes()) {
n.visible = !view.state.hideDead || n.isLive(); n.visible = !view.state.hideDead || n.isLive();
}; }
view.graph.forEachEdge((e: Edge) => { view.graph.forEachEdge((e: Edge) => {
e.visible = e.source.visible || e.target.visible; e.visible = e.source.visible || e.target.visible;
}); });
...@@ -378,7 +378,7 @@ export class GraphView extends View implements PhaseView { ...@@ -378,7 +378,7 @@ export class GraphView extends View implements PhaseView {
n.visible = false; n.visible = false;
this.state.selection.select([n], false); this.state.selection.select([n], false);
} }
}; }
this.updateGraphVisibility(); this.updateGraphVisibility();
} }
...@@ -387,7 +387,7 @@ export class GraphView extends View implements PhaseView { ...@@ -387,7 +387,7 @@ export class GraphView extends View implements PhaseView {
if (!view.state.selection.isSelected(n)) { if (!view.state.selection.isSelected(n)) {
n.visible = false; n.visible = false;
} }
}; }
view.updateGraphVisibility(); view.updateGraphVisibility();
} }
...@@ -396,7 +396,7 @@ export class GraphView extends View implements PhaseView { ...@@ -396,7 +396,7 @@ export class GraphView extends View implements PhaseView {
if (view.state.selection.isSelected(n)) { if (view.state.selection.isSelected(n)) {
n.visible = false; n.visible = false;
} }
}; }
view.selectionHandler.clear(); view.selectionHandler.clear();
} }
...@@ -455,7 +455,7 @@ export class GraphView extends View implements PhaseView { ...@@ -455,7 +455,7 @@ export class GraphView extends View implements PhaseView {
} }
view.updateGraphVisibility(); view.updateGraphVisibility();
} }
} };
let eventHandled = true; // unless the below switch defaults let eventHandled = true; // unless the below switch defaults
switch (d3.event.keyCode) { switch (d3.event.keyCode) {
...@@ -663,7 +663,7 @@ export class GraphView extends View implements PhaseView { ...@@ -663,7 +663,7 @@ export class GraphView extends View implements PhaseView {
view.selectionHandler.select([d], undefined); view.selectionHandler.select([d], undefined);
d3.event.stopPropagation(); d3.event.stopPropagation();
}) })
.call(view.drag) .call(view.drag);
newGs.append("rect") newGs.append("rect")
.attr("rx", 10) .attr("rx", 10)
...@@ -673,7 +673,7 @@ export class GraphView extends View implements PhaseView { ...@@ -673,7 +673,7 @@ export class GraphView extends View implements PhaseView {
}) })
.attr('height', function (d) { .attr('height', function (d) {
return d.getNodeHeight(view.state.showTypes); return d.getNodeHeight(view.state.showTypes);
}) });
function appendInputAndOutputBubbles(g, d) { function appendInputAndOutputBubbles(g, d) {
for (let i = 0; i < d.inputs.length; ++i) { for (let i = 0; i < d.inputs.length; ++i) {
...@@ -744,7 +744,7 @@ export class GraphView extends View implements PhaseView { ...@@ -744,7 +744,7 @@ export class GraphView extends View implements PhaseView {
.append("title") .append("title")
.text(function (l) { .text(function (l) {
return d.getTitle(); return d.getTitle();
}) });
if (d.nodeLabel.type != undefined) { if (d.nodeLabel.type != undefined) {
d3.select(this).append("text") d3.select(this).append("text")
.classed("label", true) .classed("label", true)
...@@ -759,7 +759,7 @@ export class GraphView extends View implements PhaseView { ...@@ -759,7 +759,7 @@ export class GraphView extends View implements PhaseView {
.append("title") .append("title")
.text(function (l) { .text(function (l) {
return d.getType(); return d.getType();
}) });
} }
}); });
...@@ -807,8 +807,8 @@ export class GraphView extends View implements PhaseView { ...@@ -807,8 +807,8 @@ export class GraphView extends View implements PhaseView {
onresize() { onresize() {
const trans = d3.zoomTransform(this.svg.node()); const trans = d3.zoomTransform(this.svg.node());
const ctrans = this.panZoom.constrain()(trans, this.getSvgExtent(), this.panZoom.translateExtent()) const ctrans = this.panZoom.constrain()(trans, this.getSvgExtent(), this.panZoom.translateExtent());
this.panZoom.transform(this.svg, ctrans) this.panZoom.transform(this.svg, ctrans);
} }
toggleTypes() { toggleTypes() {
...@@ -860,6 +860,6 @@ export class GraphView extends View implements PhaseView { ...@@ -860,6 +860,6 @@ export class GraphView extends View implements PhaseView {
this.panZoom.scaleTo(this.svg, 0); this.panZoom.scaleTo(this.svg, 0);
this.panZoom.translateTo(this.svg, this.panZoom.translateTo(this.svg,
this.graph.minGraphX + this.graph.width / 2, this.graph.minGraphX + this.graph.width / 2,
this.graph.minGraphY + this.graph.height / 2) this.graph.minGraphY + this.graph.height / 2);
} }
} }
...@@ -52,9 +52,9 @@ export class GraphMultiView extends View { ...@@ -52,9 +52,9 @@ export class GraphMultiView extends View {
const view = this; const view = this;
view.sourceResolver = sourceResolver; view.sourceResolver = sourceResolver;
view.selectionBroker = selectionBroker; view.selectionBroker = selectionBroker;
const toolbox = document.createElement("div") const toolbox = document.createElement("div");
toolbox.className = "toolbox-anchor"; toolbox.className = "toolbox-anchor";
toolbox.innerHTML = toolboxHTML toolbox.innerHTML = toolboxHTML;
view.divNode.appendChild(toolbox); view.divNode.appendChild(toolbox);
const searchInput = toolbox.querySelector("#search-input") as HTMLInputElement; const searchInput = toolbox.querySelector("#search-input") as HTMLInputElement;
searchInput.addEventListener("keyup", e => { searchInput.addEventListener("keyup", e => {
...@@ -88,7 +88,7 @@ export class GraphMultiView extends View { ...@@ -88,7 +88,7 @@ export class GraphMultiView extends View {
this.selectMenu.onchange = function (this: HTMLSelectElement) { this.selectMenu.onchange = function (this: HTMLSelectElement) {
window.sessionStorage.setItem("lastSelectedPhase", this.selectedIndex.toString()); window.sessionStorage.setItem("lastSelectedPhase", this.selectedIndex.toString());
view.displayPhase(view.sourceResolver.getPhase(this.selectedIndex)); view.displayPhase(view.sourceResolver.getPhase(this.selectedIndex));
} };
} }
show(data, rememberedSelection) { show(data, rememberedSelection) {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import { MINIMUM_EDGE_SEPARATION, Edge } from "../src/edge" import { MINIMUM_EDGE_SEPARATION, Edge } from "../src/edge";
import { NodeLabel } from "./node-label"; import { NodeLabel } from "./node-label";
import { MAX_RANK_SENTINEL } from "./constants"; import { MAX_RANK_SENTINEL } from "./constants";
import { alignUp, measureText } from "./util"; import { alignUp, measureText } from "./util";
...@@ -149,7 +149,7 @@ export class GNode { ...@@ -149,7 +149,7 @@ export class GNode {
} }
getInputApproach(index) { getInputApproach(index) {
return this.y - MINIMUM_NODE_INPUT_APPROACH - return this.y - MINIMUM_NODE_INPUT_APPROACH -
(index % 4) * MINIMUM_EDGE_SEPARATION - DEFAULT_NODE_BUBBLE_RADIUS (index % 4) * MINIMUM_EDGE_SEPARATION - DEFAULT_NODE_BUBBLE_RADIUS;
} }
getNodeHeight(showTypes: boolean): number { getNodeHeight(showTypes: boolean): number {
if (showTypes) { if (showTypes) {
...@@ -175,6 +175,6 @@ export class GNode { ...@@ -175,6 +175,6 @@ export class GNode {
((this.nodeLabel.opcode == "Phi" || this.nodeLabel.opcode == "EffectPhi" || this.nodeLabel.opcode == "InductionVariablePhi") && ((this.nodeLabel.opcode == "Phi" || this.nodeLabel.opcode == "EffectPhi" || this.nodeLabel.opcode == "InductionVariablePhi") &&
this.inputs[this.inputs.length - 1].source.nodeLabel.opcode == "Loop"); this.inputs[this.inputs.length - 1].source.nodeLabel.opcode == "Loop");
} }
}; }
export const nodeToStr = (n: GNode) => "N" + n.id; export const nodeToStr = (n: GNode) => "N" + n.id;
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import * as d3 from "d3" import * as d3 from "d3";
import * as C from "../src/constants" import * as C from "../src/constants";
class Snapper { class Snapper {
resizer: Resizer; resizer: Resizer;
...@@ -104,7 +104,7 @@ export class Resizer { ...@@ -104,7 +104,7 @@ export class Resizer {
constructor(panesUpdatedCallback: () => void, deadWidth: number) { constructor(panesUpdatedCallback: () => void, deadWidth: number) {
let resizer = this; let resizer = this;
resizer.panesUpdatedCallback = panesUpdatedCallback; resizer.panesUpdatedCallback = panesUpdatedCallback;
resizer.deadWidth = deadWidth resizer.deadWidth = deadWidth;
resizer.left = document.getElementById(C.SOURCE_PANE_ID); resizer.left = document.getElementById(C.SOURCE_PANE_ID);
resizer.middle = document.getElementById(C.INTERMEDIATE_PANE_ID); resizer.middle = document.getElementById(C.INTERMEDIATE_PANE_ID);
resizer.right = document.getElementById(C.GENERATED_PANE_ID); resizer.right = document.getElementById(C.GENERATED_PANE_ID);
...@@ -152,7 +152,7 @@ export class Resizer { ...@@ -152,7 +152,7 @@ export class Resizer {
}) })
.on('end', function () { .on('end', function () {
if (!resizer.isRightSnapped()) { if (!resizer.isRightSnapped()) {
console.log(`disassembly-pane-width ${resizer.sepRight}`) console.log(`disassembly-pane-width ${resizer.sepRight}`);
window.sessionStorage.setItem("disassembly-pane-width", `${resizer.sepRight / resizer.clientWidth}`); window.sessionStorage.setItem("disassembly-pane-width", `${resizer.sepRight / resizer.clientWidth}`);
} }
resizer.resizerRight.classed("dragged", false); resizer.resizerRight.classed("dragged", false);
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import { Schedule, SourceResolver } from "../src/source-resolver" import { Schedule, SourceResolver } from "../src/source-resolver";
import { PhaseView } from "../src/view" import { PhaseView } from "../src/view";
import { TextView } from "../src/text-view" import { TextView } from "../src/text-view";
export class ScheduleView extends TextView implements PhaseView { export class ScheduleView extends TextView implements PhaseView {
schedule: Schedule; schedule: Schedule;
...@@ -38,7 +38,7 @@ export class ScheduleView extends TextView implements PhaseView { ...@@ -38,7 +38,7 @@ export class ScheduleView extends TextView implements PhaseView {
initializeContent(data, rememberedSelection) { initializeContent(data, rememberedSelection) {
this.divNode.innerHTML = ''; this.divNode.innerHTML = '';
this.schedule = data.schedule this.schedule = data.schedule;
this.addBlocks(data.schedule.blocks); this.addBlocks(data.schedule.blocks);
this.attachSelection(rememberedSelection); this.attachSelection(rememberedSelection);
} }
...@@ -53,7 +53,7 @@ export class ScheduleView extends TextView implements PhaseView { ...@@ -53,7 +53,7 @@ export class ScheduleView extends TextView implements PhaseView {
const view = this; const view = this;
function createElement(tag: string, cls: string, content?: string) { function createElement(tag: string, cls: string, content?: string) {
const el = document.createElement(tag); const el = document.createElement(tag);
el.className = cls el.className = cls;
if (content != undefined) el.innerHTML = content; if (content != undefined) el.innerHTML = content;
return el; return el;
} }
...@@ -79,7 +79,7 @@ export class ScheduleView extends TextView implements PhaseView { ...@@ -79,7 +79,7 @@ export class ScheduleView extends TextView implements PhaseView {
`This usually means that this node was folded into another node; ` + `This usually means that this node was folded into another node; ` +
`the highlighted machine code is a guess.`]; `the highlighted machine code is a guess.`];
} }
return ["", `This not is not in the final schedule.`] return ["", `This not is not in the final schedule.`];
} }
function createElementForNode(node) { function createElementForNode(node) {
...@@ -126,7 +126,7 @@ export class ScheduleView extends TextView implements PhaseView { ...@@ -126,7 +126,7 @@ export class ScheduleView extends TextView implements PhaseView {
const [start, end] = view.sourceResolver.getInstructionRangeForBlock(block.id); const [start, end] = view.sourceResolver.getInstructionRangeForBlock(block.id);
const instrMarker = createElement("div", "instr-marker com", "&#8857;"); const instrMarker = createElement("div", "instr-marker com", "&#8857;");
instrMarker.setAttribute("title", `Instructions range for this block is [${start}, ${end})`) instrMarker.setAttribute("title", `Instructions range for this block is [${start}, ${end})`);
instrMarker.onclick = mkBlockLinkHandler(block.id); instrMarker.onclick = mkBlockLinkHandler(block.id);
scheduleBlock.appendChild(instrMarker); scheduleBlock.appendChild(instrMarker);
...@@ -164,7 +164,7 @@ export class ScheduleView extends TextView implements PhaseView { ...@@ -164,7 +164,7 @@ export class ScheduleView extends TextView implements PhaseView {
} }
lineString(node) { lineString(node) {
return `${node.id}: ${node.label}(${node.inputs.join(", ")})` return `${node.id}: ${node.label}(${node.inputs.join(", ")})`;
} }
searchInputAction(searchBar, e) { searchInputAction(searchBar, e) {
...@@ -178,7 +178,7 @@ export class ScheduleView extends TextView implements PhaseView { ...@@ -178,7 +178,7 @@ export class ScheduleView extends TextView implements PhaseView {
for (const node of this.schedule.nodes) { for (const node of this.schedule.nodes) {
if (node === undefined) continue; if (node === undefined) continue;
if (reg.exec(this.lineString(node)) != null) { if (reg.exec(this.lineString(node)) != null) {
select.push(node.id) select.push(node.id);
} }
} }
this.selectionHandler.select(select, true); this.selectionHandler.select(select, true);
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import { SourceResolver, sourcePositionValid } from "../src/source-resolver" import { SourceResolver, sourcePositionValid } from "../src/source-resolver";
import { ClearableHandler, SelectionHandler, NodeSelectionHandler, BlockSelectionHandler, InstructionSelectionHandler } from "../src/selection-handler" import { ClearableHandler, SelectionHandler, NodeSelectionHandler, BlockSelectionHandler, InstructionSelectionHandler } from "../src/selection-handler";
export class SelectionBroker { export class SelectionBroker {
sourceResolver: SourceResolver; sourceResolver: SourceResolver;
...@@ -20,7 +20,7 @@ export class SelectionBroker { ...@@ -20,7 +20,7 @@ export class SelectionBroker {
this.blockHandlers = []; this.blockHandlers = [];
this.instructionHandlers = []; this.instructionHandlers = [];
this.sourceResolver = sourceResolver; this.sourceResolver = sourceResolver;
}; }
addSourcePositionHandler(handler: SelectionHandler & ClearableHandler) { addSourcePositionHandler(handler: SelectionHandler & ClearableHandler) {
this.allHandlers.push(handler); this.allHandlers.push(handler);
......
...@@ -10,22 +10,22 @@ export interface SelectionHandler { ...@@ -10,22 +10,22 @@ export interface SelectionHandler {
clear(): void; clear(): void;
select(nodeIds: any, selected: any): void; select(nodeIds: any, selected: any): void;
brokeredSourcePositionSelect(sourcePositions: any, selected: any): void; brokeredSourcePositionSelect(sourcePositions: any, selected: any): void;
}; }
export interface NodeSelectionHandler { export interface NodeSelectionHandler {
clear(): void; clear(): void;
select(nodeIds: any, selected: any): void; select(nodeIds: any, selected: any): void;
brokeredNodeSelect(nodeIds: any, selected: any): void; brokeredNodeSelect(nodeIds: any, selected: any): void;
}; }
export interface BlockSelectionHandler { export interface BlockSelectionHandler {
clear(): void; clear(): void;
select(nodeIds: any, selected: any): void; select(nodeIds: any, selected: any): void;
brokeredBlockSelect(blockIds: any, selected: any): void; brokeredBlockSelect(blockIds: any, selected: any): void;
}; }
export interface InstructionSelectionHandler { export interface InstructionSelectionHandler {
clear(): void; clear(): void;
select(instructionIds: any, selected: any): void; select(instructionIds: any, selected: any): void;
brokeredInstructionSelect(instructionIds: any, selected: any): void; brokeredInstructionSelect(instructionIds: any, selected: any): void;
}; }
...@@ -58,5 +58,5 @@ export class MySelection { ...@@ -58,5 +58,5 @@ export class MySelection {
return result; return result;
} }
[Symbol.iterator]() { return this.selection.values() } [Symbol.iterator]() { return this.selection.values(); }
} }
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import { Sequence } from "../src/source-resolver" import { Sequence } from "../src/source-resolver";
import { isIterable } from "../src/util" import { isIterable } from "../src/util";
import { PhaseView } from "../src/view" import { PhaseView } from "../src/view";
import { TextView } from "../src/text-view" import { TextView } from "../src/text-view";
export class SequenceView extends TextView implements PhaseView { export class SequenceView extends TextView implements PhaseView {
sequence: Sequence; sequence: Sequence;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import { sortUnique, anyToString } from "../src/util" import { sortUnique, anyToString } from "../src/util";
import { NodeLabel } from "./node-label"; import { NodeLabel } from "./node-label";
function sourcePositionLe(a, b) { function sourcePositionLe(a, b) {
...@@ -183,7 +183,7 @@ export class SourceResolver { ...@@ -183,7 +183,7 @@ export class SourceResolver {
alternativeMap[nodeId] = { scriptOffset: scriptOffset, inliningId: -1 }; alternativeMap[nodeId] = { scriptOffset: scriptOffset, inliningId: -1 };
} }
map = alternativeMap; map = alternativeMap;
}; }
for (const [nodeId, sourcePosition] of Object.entries<SourcePosition>(map)) { for (const [nodeId, sourcePosition] of Object.entries<SourcePosition>(map)) {
if (sourcePosition == undefined) { if (sourcePosition == undefined) {
...@@ -253,7 +253,7 @@ export class SourceResolver { ...@@ -253,7 +253,7 @@ export class SourceResolver {
addInliningPositions(sourcePosition: AnyPosition, locations: Array<SourcePosition>) { addInliningPositions(sourcePosition: AnyPosition, locations: Array<SourcePosition>) {
let inlining = this.inliningsMap.get(sourcePositionToStringKey(sourcePosition)); let inlining = this.inliningsMap.get(sourcePositionToStringKey(sourcePosition));
if (!inlining) return; if (!inlining) return;
let sourceId = inlining.sourceId let sourceId = inlining.sourceId;
const source = this.sources[sourceId]; const source = this.sources[sourceId];
for (const sp of source.sourcePositions) { for (const sp of source.sourcePositions) {
locations.push(sp); locations.push(sp);
...@@ -280,7 +280,7 @@ export class SourceResolver { ...@@ -280,7 +280,7 @@ export class SourceResolver {
} }
const list = this.sources[sourceId].sourcePositions; const list = this.sources[sourceId].sourcePositions;
for (let i = 0; i < list.length; i++) { for (let i = 0; i < list.length; i++) {
const sourcePosition = list[i] const sourcePosition = list[i];
const position = sourcePosition.scriptOffset; const position = sourcePosition.scriptOffset;
const nextPosition = list[Math.min(i + 1, list.length - 1)].scriptOffset; const nextPosition = list[Math.min(i + 1, list.length - 1)].scriptOffset;
if ((position <= scriptOffset && scriptOffset < nextPosition)) { if ((position <= scriptOffset && scriptOffset < nextPosition)) {
...@@ -324,7 +324,7 @@ export class SourceResolver { ...@@ -324,7 +324,7 @@ export class SourceResolver {
recordOrigins(phase: GraphPhase) { recordOrigins(phase: GraphPhase) {
if (phase.type != "graph") return; if (phase.type != "graph") return;
for (const node of phase.data.nodes) { for (const node of phase.data.nodes) {
phase.highestNodeId = Math.max(phase.highestNodeId, node.id) phase.highestNodeId = Math.max(phase.highestNodeId, node.id);
if (node.origin != undefined && if (node.origin != undefined &&
node.origin.bytecodePosition != undefined) { node.origin.bytecodePosition != undefined) {
const position = { bytecodePosition: node.origin.bytecodePosition }; const position = { bytecodePosition: node.origin.bytecodePosition };
...@@ -411,7 +411,7 @@ export class SourceResolver { ...@@ -411,7 +411,7 @@ export class SourceResolver {
for (const node of nodes) { for (const node of nodes) {
const range = this.nodeIdToInstructionRange[node]; const range = this.nodeIdToInstructionRange[node];
if (!range) continue; if (!range) continue;
offsets = offsets.concat(this.instructionRangeToKeyPcOffsets(range)) offsets = offsets.concat(this.instructionRangeToKeyPcOffsets(range));
} }
return offsets; return offsets;
} }
...@@ -495,7 +495,7 @@ export class SourceResolver { ...@@ -495,7 +495,7 @@ export class SourceResolver {
} }
repairPhaseId(anyPhaseId) { repairPhaseId(anyPhaseId) {
return Math.max(0, Math.min(anyPhaseId | 0, this.phases.length - 1)) return Math.max(0, Math.min(anyPhaseId | 0, this.phases.length - 1));
} }
getPhase(phaseId: number) { getPhase(phaseId: number) {
......
export class Tabs { export class Tabs {
container: HTMLElement container: HTMLElement;
tabBar: HTMLElement; tabBar: HTMLElement;
nextTabId: number; nextTabId: number;
mkTabBar(container: HTMLElement) { mkTabBar(container: HTMLElement) {
container.classList.add("nav-tabs-container") container.classList.add("nav-tabs-container");
this.tabBar = document.createElement("ul"); this.tabBar = document.createElement("ul");
this.tabBar.id = `tab-bar-${container.id}`; this.tabBar.id = `tab-bar-${container.id}`;
this.tabBar.className = "nav-tabs"; this.tabBar.className = "nav-tabs";
...@@ -16,7 +16,7 @@ export class Tabs { ...@@ -16,7 +16,7 @@ export class Tabs {
const defaultDiv = document.createElement("div"); const defaultDiv = document.createElement("div");
defaultDiv.className = "tab-content tab-default"; defaultDiv.className = "tab-content tab-default";
defaultDiv.id = `tab-content-${container.id}-default`; defaultDiv.id = `tab-content-${container.id}-default`;
container.insertBefore(defaultDiv, container.firstChild) container.insertBefore(defaultDiv, container.firstChild);
container.insertBefore(this.tabBar, container.firstChild); container.insertBefore(this.tabBar, container.firstChild);
} }
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import { View } from "../src/view" import { View } from "../src/view";
import { anyToString, ViewElements, isIterable } from "../src/util" import { anyToString, ViewElements, isIterable } from "../src/util";
import { MySelection } from "../src/selection" import { MySelection } from "../src/selection";
import { SourceResolver } from "./source-resolver"; import { SourceResolver } from "./source-resolver";
import { SelectionBroker } from "./selection-broker"; import { SelectionBroker } from "./selection-broker";
import { NodeSelectionHandler, BlockSelectionHandler } from "./selection-handler"; import { NodeSelectionHandler, BlockSelectionHandler } from "./selection-handler";
...@@ -136,7 +136,7 @@ export abstract class TextView extends View { ...@@ -136,7 +136,7 @@ export abstract class TextView extends View {
element.classList.toggle("selected", isSelected); element.classList.toggle("selected", isSelected);
} }
} }
const elementsToSelect = view.divNode.querySelectorAll(`[data-pc-offset]`) const elementsToSelect = view.divNode.querySelectorAll(`[data-pc-offset]`);
for (const el of elementsToSelect) { for (const el of elementsToSelect) {
el.classList.toggle("selected", false); el.classList.toggle("selected", false);
} }
......
...@@ -2,15 +2,15 @@ ...@@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import * as d3 from "d3" import * as d3 from "d3";
import { SourceResolver } from "../src/source-resolver" import { SourceResolver } from "../src/source-resolver";
import { SelectionBroker } from "../src/selection-broker" import { SelectionBroker } from "../src/selection-broker";
import { DisassemblyView } from "../src/disassembly-view" import { DisassemblyView } from "../src/disassembly-view";
import { GraphMultiView } from "../src/graphmultiview" import { GraphMultiView } from "../src/graphmultiview";
import { CodeMode, CodeView } from "../src/code-view" import { CodeMode, CodeView } from "../src/code-view";
import { Tabs } from "../src/tabs" import { Tabs } from "../src/tabs";
import { Resizer } from "../src/resizer" import { Resizer } from "../src/resizer";
import * as C from "../src/constants" import * as C from "../src/constants";
window.onload = function () { window.onload = function () {
var multiview = null; var multiview = null;
...@@ -41,7 +41,7 @@ window.onload = function () { ...@@ -41,7 +41,7 @@ window.onload = function () {
const jsonObj = JSON.parse(txtRes); const jsonObj = JSON.parse(txtRes);
let fnc = null let fnc = null;
// Backwards compatibility. // Backwards compatibility.
if (typeof jsonObj.function == 'string') { if (typeof jsonObj.function == 'string') {
fnc = { fnc = {
...@@ -58,13 +58,13 @@ window.onload = function () { ...@@ -58,13 +58,13 @@ window.onload = function () {
sourceResolver.setInlinings(jsonObj.inlinings); sourceResolver.setInlinings(jsonObj.inlinings);
sourceResolver.setSourceLineToBytecodePosition(jsonObj.sourceLineToBytecodePosition); sourceResolver.setSourceLineToBytecodePosition(jsonObj.sourceLineToBytecodePosition);
sourceResolver.setSources(jsonObj.sources, fnc) sourceResolver.setSources(jsonObj.sources, fnc);
sourceResolver.setNodePositionMap(jsonObj.nodePositions); sourceResolver.setNodePositionMap(jsonObj.nodePositions);
sourceResolver.parsePhases(jsonObj.phases); sourceResolver.parsePhases(jsonObj.phases);
const sourceTabsContainer = document.getElementById(C.SOURCE_PANE_ID); const sourceTabsContainer = document.getElementById(C.SOURCE_PANE_ID);
const sourceTabs = new Tabs(sourceTabsContainer); const sourceTabs = new Tabs(sourceTabsContainer);
const [sourceTab, sourceContainer] = sourceTabs.addTabAndContent("Source") const [sourceTab, sourceContainer] = sourceTabs.addTabAndContent("Source");
sourceContainer.classList.add("viewpane", "scrollable"); sourceContainer.classList.add("viewpane", "scrollable");
sourceTabs.activateTab(sourceTab); sourceTabs.activateTab(sourceTab);
sourceTabs.addTab("&#x2b;").classList.add("open-tab"); sourceTabs.addTab("&#x2b;").classList.add("open-tab");
...@@ -80,7 +80,7 @@ window.onload = function () { ...@@ -80,7 +80,7 @@ window.onload = function () {
const disassemblyTabsContainer = document.getElementById(C.GENERATED_PANE_ID); const disassemblyTabsContainer = document.getElementById(C.GENERATED_PANE_ID);
const disassemblyTabs = new Tabs(disassemblyTabsContainer); const disassemblyTabs = new Tabs(disassemblyTabsContainer);
const [disassemblyTab, disassemblyContainer] = disassemblyTabs.addTabAndContent("Disassembly") const [disassemblyTab, disassemblyContainer] = disassemblyTabs.addTabAndContent("Disassembly");
disassemblyContainer.classList.add("viewpane", "scrollable"); disassemblyContainer.classList.add("viewpane", "scrollable");
disassemblyTabs.activateTab(disassemblyTab); disassemblyTabs.activateTab(disassemblyTab);
disassemblyTabs.addTab("&#x2b;").classList.add("open-tab"); disassemblyTabs.addTab("&#x2b;").classList.add("open-tab");
......
...@@ -32,7 +32,7 @@ export class ViewElements { ...@@ -32,7 +32,7 @@ export class ViewElements {
if (!doConsider) return; if (!doConsider) return;
const newScrollTop = computeScrollTop(this.container, element); const newScrollTop = computeScrollTop(this.container, element);
if (isNaN(newScrollTop)) { if (isNaN(newScrollTop)) {
console.log("NOO") console.log("NOO");
} }
if (this.scrollTop === undefined) { if (this.scrollTop === undefined) {
this.scrollTop = newScrollTop; this.scrollTop = newScrollTop;
...@@ -63,7 +63,7 @@ export function sortUnique<T>(arr: Array<T>, f: (a: T, b: T) => number, equal: ( ...@@ -63,7 +63,7 @@ export function sortUnique<T>(arr: Array<T>, f: (a: T, b: T) => number, equal: (
export function partial(f: any, ...arguments1: Array<any>) { export function partial(f: any, ...arguments1: Array<any>) {
return function (this: any, ...arguments2: Array<any>) { return function (this: any, ...arguments2: Array<any>) {
f.apply(this, [...arguments1, ...arguments2]); f.apply(this, [...arguments1, ...arguments2]);
} };
} }
export function isIterable(obj: any): obj is Iterable<any> { export function isIterable(obj: any): obj is Iterable<any> {
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
}], }],
"ordered-imports": false, "ordered-imports": false,
"array-type": [true, "generic"], "array-type": [true, "generic"],
"semicolon": false, "semicolon": true,
"member-access": false, "member-access": false,
"object-literal-shorthand": false, "object-literal-shorthand": false,
"object-literal-key-quotes": [true, "as-needed"], "object-literal-key-quotes": [true, "as-needed"],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment