Commit a6356ac6 authored by Sigurd Schneider's avatar Sigurd Schneider Committed by Commit Bot

[turbolizer] Enable more tslint checks

 - Ban T[] array syntax
 - Format arrow function arguments consistently

Bug: v8:7327
Notry: true
Change-Id: I072a352ec9009948392a6bb5dd4381d4993af7be
Reviewed-on: https://chromium-review.googlesource.com/c/1405317
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58759}
parent 843535b8
This diff is collapsed.
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
"build": "rollup -c", "build": "rollup -c",
"watch": "rollup -c -w", "watch": "rollup -c -w",
"deploy": "./deploy.sh", "deploy": "./deploy.sh",
"format": "tsfmt -r",
"test": "ts-mocha -p tsconfig.test.json test/**/*-test.ts", "test": "ts-mocha -p tsconfig.test.json test/**/*-test.ts",
"dev-server": "ws" "dev-server": "ws",
"presubmit": "tslint --project ./tslint.json --fix"
}, },
"author": "The V8 team", "author": "The V8 team",
"license": "MIT", "license": "MIT",
...@@ -17,8 +17,7 @@ ...@@ -17,8 +17,7 @@
"d3": "^5.7.0", "d3": "^5.7.0",
"rollup": "^0.68.2", "rollup": "^0.68.2",
"rollup-plugin-node-resolve": "^4.0.0", "rollup-plugin-node-resolve": "^4.0.0",
"rollup-plugin-typescript2": "^0.18.1", "rollup-plugin-typescript2": "^0.18.1"
"tslint": "^5.12.0"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
...@@ -30,6 +29,6 @@ ...@@ -30,6 +29,6 @@
"mocha": "^5.2.0", "mocha": "^5.2.0",
"ts-mocha": "^2.0.0", "ts-mocha": "^2.0.0",
"typescript": "^3.2.2", "typescript": "^3.2.2",
"typescript-formatter": "^7.2.2" "tslint": "^5.12.0"
} }
} }
...@@ -18,10 +18,10 @@ const toolboxHTML = `<div id="disassembly-toolbox"> ...@@ -18,10 +18,10 @@ const toolboxHTML = `<div id="disassembly-toolbox">
export class DisassemblyView extends TextView { export class DisassemblyView extends TextView {
SOURCE_POSITION_HEADER_REGEX: any; SOURCE_POSITION_HEADER_REGEX: any;
addr_event_counts: any; addrEventCounts: any;
total_event_counts: any; totalEventCounts: any;
max_event_counts: any; maxEventCounts: any;
pos_lines: Array<any>; posLines: Array<any>;
instructionSelectionHandler: InstructionSelectionHandler; instructionSelectionHandler: InstructionSelectionHandler;
offsetSelection: MySelection; offsetSelection: MySelection;
showInstructionAddressHandler: () => void; showInstructionAddressHandler: () => void;
...@@ -77,7 +77,7 @@ export class DisassemblyView extends TextView { ...@@ -77,7 +77,7 @@ export class DisassemblyView extends TextView {
let OPCODE_ARGS = { let OPCODE_ARGS = {
associateData: function (text, fragment) { associateData: function (text, fragment) {
fragment.innerHTML = text; fragment.innerHTML = text;
const replacer = (match, hexOffset, stringOffset, string) => { 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>`
...@@ -154,7 +154,7 @@ export class DisassemblyView extends TextView { ...@@ -154,7 +154,7 @@ export class DisassemblyView extends TextView {
} }
view.divNode.addEventListener('click', linkHandler); view.divNode.addEventListener('click', linkHandler);
const linkHandlerBlock = (e) => { const linkHandlerBlock = e => {
const blockId = e.target.dataset.blockId; const blockId = e.target.dataset.blockId;
if (typeof blockId != "undefined" && !Number.isNaN(blockId)) { if (typeof blockId != "undefined" && !Number.isNaN(blockId)) {
e.stopPropagation(); e.stopPropagation();
...@@ -239,21 +239,21 @@ export class DisassemblyView extends TextView { ...@@ -239,21 +239,21 @@ export class DisassemblyView extends TextView {
initializeCode(sourceText, sourcePosition: number = 0) { initializeCode(sourceText, sourcePosition: number = 0) {
let view = this; let view = this;
view.addr_event_counts = null; view.addrEventCounts = null;
view.total_event_counts = null; view.totalEventCounts = null;
view.max_event_counts = null; view.maxEventCounts = null;
view.pos_lines = new Array(); view.posLines = new Array();
// Comment lines for line 0 include sourcePosition already, only need to // Comment lines for line 0 include sourcePosition already, only need to
// add sourcePosition for lines > 0. // add sourcePosition for lines > 0.
view.pos_lines[0] = sourcePosition; view.posLines[0] = sourcePosition;
if (sourceText && sourceText != "") { if (sourceText && sourceText != "") {
let base = sourcePosition; let base = sourcePosition;
let current = 0; let current = 0;
let source_lines = sourceText.split("\n"); let sourceLines = sourceText.split("\n");
for (let i = 1; i < source_lines.length; i++) { for (let i = 1; i < sourceLines.length; i++) {
// Add 1 for newline character that is split off. // Add 1 for newline character that is split off.
current += source_lines[i - 1].length + 1; current += sourceLines[i - 1].length + 1;
view.pos_lines[i] = base + current; view.posLines[i] = base + current;
} }
} }
} }
...@@ -261,20 +261,22 @@ export class DisassemblyView extends TextView { ...@@ -261,20 +261,22 @@ export class DisassemblyView extends TextView {
initializePerfProfile(eventCounts) { initializePerfProfile(eventCounts) {
let view = this; let view = this;
if (eventCounts !== undefined) { if (eventCounts !== undefined) {
view.addr_event_counts = eventCounts; view.addrEventCounts = eventCounts;
view.total_event_counts = {}; view.totalEventCounts = {};
view.max_event_counts = {}; view.maxEventCounts = {};
for (let ev_name in view.addr_event_counts) { for (let evName in view.addrEventCounts) {
let keys = Object.keys(view.addr_event_counts[ev_name]); if (view.addrEventCounts.hasOwnProperty(evName)) {
let values = keys.map(key => view.addr_event_counts[ev_name][key]); let keys = Object.keys(view.addrEventCounts[evName]);
view.total_event_counts[ev_name] = values.reduce((a, b) => a + b); let values = keys.map(key => view.addrEventCounts[evName][key]);
view.max_event_counts[ev_name] = values.reduce((a, b) => Math.max(a, b)); view.totalEventCounts[evName] = values.reduce((a, b) => a + b);
view.maxEventCounts[evName] = values.reduce((a, b) => Math.max(a, b));
}
} }
} else { } else {
view.addr_event_counts = null; view.addrEventCounts = null;
view.total_event_counts = null; view.totalEventCounts = null;
view.max_event_counts = null; view.maxEventCounts = null;
} }
} }
...@@ -296,16 +298,17 @@ export class DisassemblyView extends TextView { ...@@ -296,16 +298,17 @@ export class DisassemblyView extends TextView {
let fragments = super.processLine(line); let fragments = super.processLine(line);
// Add profiling data per instruction if available. // Add profiling data per instruction if available.
if (view.total_event_counts) { if (view.totalEventCounts) {
let matches = /^(0x[0-9a-fA-F]+)\s+\d+\s+[0-9a-fA-F]+/.exec(line); let matches = /^(0x[0-9a-fA-F]+)\s+\d+\s+[0-9a-fA-F]+/.exec(line);
if (matches) { if (matches) {
let newFragments = []; let newFragments = [];
for (let event in view.addr_event_counts) { for (let event in view.addrEventCounts) {
let count = view.addr_event_counts[event][matches[1]]; if (!view.addrEventCounts.hasOwnProperty(event)) continue;
let count = view.addrEventCounts[event][matches[1]];
let str = " "; let str = " ";
let css_cls = "prof"; let cssCls = "prof";
if (count !== undefined) { if (count !== undefined) {
let perc = count / view.total_event_counts[event] * 100; let perc = count / view.totalEventCounts[event] * 100;
let col = { r: 255, g: 255, b: 255 }; let col = { r: 255, g: 255, b: 255 };
for (let i = 0; i < PROF_COLS.length; i++) { for (let i = 0; i < PROF_COLS.length; i++) {
...@@ -328,13 +331,13 @@ export class DisassemblyView extends TextView { ...@@ -328,13 +331,13 @@ export class DisassemblyView extends TextView {
str = UNICODE_BLOCK; str = UNICODE_BLOCK;
let fragment = view.createFragment(str, css_cls); let fragment = view.createFragment(str, cssCls);
fragment.title = event + ": " + view.humanize(perc) + " (" + count + ")"; fragment.title = event + ": " + view.humanize(perc) + " (" + count + ")";
fragment.style.color = "rgb(" + col.r + ", " + col.g + ", " + col.b + ")"; fragment.style.color = "rgb(" + col.r + ", " + col.g + ", " + col.b + ")";
newFragments.push(fragment); newFragments.push(fragment);
} else { } else {
newFragments.push(view.createFragment(str, css_cls)); newFragments.push(view.createFragment(str, cssCls));
} }
} }
fragments = newFragments.concat(fragments); fragments = newFragments.concat(fragments);
......
...@@ -39,11 +39,11 @@ export class Edge { ...@@ -39,11 +39,11 @@ export class Edge {
var source = this.source; var source = this.source;
var target = this.target; var target = this.target;
var index = this.index; var index = this.index;
var input_x = target.x + target.getInputX(index); var inputX = target.x + target.getInputX(index);
var inputApproach = target.getInputApproach(this.index); var inputApproach = target.getInputApproach(this.index);
var outputApproach = source.getOutputApproach(showTypes); var outputApproach = source.getOutputApproach(showTypes);
if (inputApproach > outputApproach) { if (inputApproach > outputApproach) {
return input_x; return inputX;
} else { } else {
var inputOffset = MINIMUM_EDGE_SEPARATION * (index + 1); var inputOffset = MINIMUM_EDGE_SEPARATION * (index + 1);
return (target.x < source.x) return (target.x < source.x)
...@@ -55,20 +55,20 @@ export class Edge { ...@@ -55,20 +55,20 @@ export class Edge {
generatePath(graph: Graph, showTypes: boolean) { generatePath(graph: Graph, showTypes: boolean) {
var target = this.target; var target = this.target;
var source = this.source; var source = this.source;
var input_x = target.x + target.getInputX(this.index); var inputX = target.x + target.getInputX(this.index);
var arrowheadHeight = 7; var arrowheadHeight = 7;
var input_y = target.y - 2 * DEFAULT_NODE_BUBBLE_RADIUS - arrowheadHeight; var inputY = target.y - 2 * DEFAULT_NODE_BUBBLE_RADIUS - arrowheadHeight;
var output_x = source.x + source.getOutputX(); var outputX = source.x + source.getOutputX();
var output_y = source.y + source.getNodeHeight(showTypes) + DEFAULT_NODE_BUBBLE_RADIUS; var outputY = source.y + source.getNodeHeight(showTypes) + DEFAULT_NODE_BUBBLE_RADIUS;
var inputApproach = target.getInputApproach(this.index); var inputApproach = target.getInputApproach(this.index);
var outputApproach = source.getOutputApproach(showTypes); var outputApproach = source.getOutputApproach(showTypes);
var horizontalPos = this.getInputHorizontalPosition(graph, showTypes); var horizontalPos = this.getInputHorizontalPosition(graph, showTypes);
var result = "M" + output_x + "," + output_y + var result = "M" + outputX + "," + outputY +
"L" + output_x + "," + outputApproach + "L" + outputX + "," + outputApproach +
"L" + horizontalPos + "," + outputApproach; "L" + horizontalPos + "," + outputApproach;
if (horizontalPos != input_x) { if (horizontalPos != inputX) {
result += "L" + horizontalPos + "," + inputApproach; result += "L" + horizontalPos + "," + inputApproach;
} else { } else {
if (inputApproach < outputApproach) { if (inputApproach < outputApproach) {
...@@ -76,8 +76,8 @@ export class Edge { ...@@ -76,8 +76,8 @@ export class Edge {
} }
} }
result += "L" + input_x + "," + inputApproach + result += "L" + inputX + "," + inputApproach +
"L" + input_x + "," + input_y; "L" + inputX + "," + inputY;
return result; return result;
} }
......
...@@ -15,7 +15,7 @@ import { NodeSelectionHandler, ClearableHandler } from "./selection-handler"; ...@@ -15,7 +15,7 @@ import { NodeSelectionHandler, ClearableHandler } from "./selection-handler";
import { Graph } from "./graph"; import { Graph } from "./graph";
import { SelectionBroker } from "./selection-broker"; import { SelectionBroker } from "./selection-broker";
function nodeToStringKey(n) { function nodeToStringKey(n: GNode) {
return "" + n.id; return "" + n.id;
} }
...@@ -67,8 +67,8 @@ export class GraphView extends View implements PhaseView { ...@@ -67,8 +67,8 @@ export class GraphView extends View implements PhaseView {
// to be important even if it does nothing. // to be important even if it does nothing.
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;
...@@ -103,7 +103,7 @@ export class GraphView extends View implements PhaseView { ...@@ -103,7 +103,7 @@ export class GraphView extends View implements PhaseView {
}, },
brokeredNodeSelect: function (locations, selected: boolean) { brokeredNodeSelect: function (locations, selected: boolean) {
if (!view.graph) return; if (!view.graph) return;
let selection = view.graph.nodes((n) => { let selection = view.graph.nodes(n => {
return locations.has(nodeToStringKey(n)) return locations.has(nodeToStringKey(n))
&& (!view.state.hideDead || n.isLive()); && (!view.state.hideDead || n.isLive());
}); });
...@@ -112,10 +112,10 @@ export class GraphView extends View implements PhaseView { ...@@ -112,10 +112,10 @@ export class GraphView extends View implements PhaseView {
for (const n of view.graph.nodes()) { for (const n of view.graph.nodes()) {
if (view.state.selection.isSelected(n)) { if (view.state.selection.isSelected(n)) {
n.visible = true; n.visible = true;
n.inputs.forEach((e) => { n.inputs.forEach(e => {
e.visible = e.visible || view.state.selection.isSelected(e.source); e.visible = e.visible || view.state.selection.isSelected(e.source);
}); });
n.outputs.forEach((e) => { n.outputs.forEach(e => {
e.visible = e.visible || view.state.selection.isSelected(e.target); e.visible = e.visible || view.state.selection.isSelected(e.target);
}); });
} }
...@@ -330,7 +330,7 @@ export class GraphView extends View implements PhaseView { ...@@ -330,7 +330,7 @@ export class GraphView extends View implements PhaseView {
attachSelection(s) { attachSelection(s) {
if (!(s instanceof Set)) return; if (!(s instanceof Set)) return;
this.selectionHandler.clear(); this.selectionHandler.clear();
const selected = [...this.graph.nodes((n) => const selected = [...this.graph.nodes(n =>
s.has(this.state.selection.stringKey(n)) && (!this.state.hideDead || n.isLive()))]; s.has(this.state.selection.stringKey(n)) && (!this.state.hideDead || n.isLive()))];
this.selectionHandler.select(selected, true); this.selectionHandler.select(selected, true);
} }
...@@ -343,7 +343,7 @@ export class GraphView extends View implements PhaseView { ...@@ -343,7 +343,7 @@ export class GraphView extends View implements PhaseView {
if (!d3.event.shiftKey) { if (!d3.event.shiftKey) {
this.state.selection.clear(); this.state.selection.clear();
} }
const allVisibleNodes = [...this.graph.nodes((n) => n.visible)]; const allVisibleNodes = [...this.graph.nodes(n => n.visible)];
this.state.selection.select(allVisibleNodes, true); this.state.selection.select(allVisibleNodes, true);
this.updateGraphVisibility(); this.updateGraphVisibility();
} }
...@@ -423,7 +423,7 @@ export class GraphView extends View implements PhaseView { ...@@ -423,7 +423,7 @@ export class GraphView extends View implements PhaseView {
reg.exec(n.nodeLabel.opcode) != null); reg.exec(n.nodeLabel.opcode) != null);
}; };
const selection = [...this.graph.nodes((n) => { const selection = [...this.graph.nodes(n => {
if ((e.ctrlKey || n.visible) && filterFunction(n)) { if ((e.ctrlKey || n.visible) && filterFunction(n)) {
if (e.ctrlKey) n.visible = true; if (e.ctrlKey) n.visible = true;
return true; return true;
...@@ -614,7 +614,7 @@ export class GraphView extends View implements PhaseView { ...@@ -614,7 +614,7 @@ export class GraphView extends View implements PhaseView {
const newAndOldEdges = newEdges.merge(selEdges); const newAndOldEdges = newEdges.merge(selEdges);
newAndOldEdges.classed('hidden', (e) => !e.isVisible()); newAndOldEdges.classed('hidden', e => !e.isVisible());
// select existing nodes // select existing nodes
const filteredNodes = [...graph.nodes(n => n.visible)]; const filteredNodes = [...graph.nodes(n => n.visible)];
...@@ -658,7 +658,7 @@ export class GraphView extends View implements PhaseView { ...@@ -658,7 +658,7 @@ export class GraphView extends View implements PhaseView {
visibleNodes.data(adjNodes, nodeToStr).attr('relToHover', "none"); visibleNodes.data(adjNodes, nodeToStr).attr('relToHover', "none");
view.updateGraphVisibility(); view.updateGraphVisibility();
}) })
.on("click", (d) => { .on("click", d => {
if (!d3.event.shiftKey) view.selectionHandler.clear(); if (!d3.event.shiftKey) view.selectionHandler.clear();
view.selectionHandler.select([d], undefined); view.selectionHandler.select([d], undefined);
d3.event.stopPropagation(); d3.event.stopPropagation();
...@@ -821,7 +821,10 @@ export class GraphView extends View implements PhaseView { ...@@ -821,7 +821,10 @@ export class GraphView extends View implements PhaseView {
viewSelection() { viewSelection() {
const view = this; const view = this;
var minX, maxX, minY, maxY; var minX;
var maxX;
var minY;
var maxY;
let hasSelection = false; let hasSelection = false;
view.visibleNodes.selectAll<SVGGElement, GNode>("g").each(function (n) { view.visibleNodes.selectAll<SVGGElement, GNode>("g").each(function (n) {
if (view.state.selection.isSelected(n)) { if (view.state.selection.isSelected(n)) {
...@@ -836,12 +839,11 @@ export class GraphView extends View implements PhaseView { ...@@ -836,12 +839,11 @@ export class GraphView extends View implements PhaseView {
}); });
if (hasSelection) { if (hasSelection) {
view.viewGraphRegion(minX - NODE_INPUT_WIDTH, minY - 60, view.viewGraphRegion(minX - NODE_INPUT_WIDTH, minY - 60,
maxX + NODE_INPUT_WIDTH, maxY + 60, maxX + NODE_INPUT_WIDTH, maxY + 60);
true);
} }
} }
viewGraphRegion(minX, minY, maxX, maxY, transition) { viewGraphRegion(minX, minY, maxX, maxY) {
const [width, height] = this.getSvgViewDimensions(); const [width, height] = this.getSvgViewDimensions();
const dx = maxX - minX; const dx = maxX - minX;
const dy = maxY - minY; const dy = maxY - minY;
......
...@@ -22,8 +22,8 @@ export class Graph { ...@@ -22,8 +22,8 @@ export class Graph {
this.width = 1; this.width = 1;
this.height = 1; this.height = 1;
data.nodes.forEach((json_node: any) => { data.nodes.forEach((jsonNode: any) => {
this.nodeMap[json_node.id] = new GNode(json_node.nodeLabel); this.nodeMap[jsonNode.id] = new GNode(jsonNode.nodeLabel);
}); });
data.edges.forEach((e: any) => { data.edges.forEach((e: any) => {
......
...@@ -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 { GraphView } from "../src/graph-view" import { GraphView } from "../src/graph-view";
import { ScheduleView } from "../src/schedule-view" import { ScheduleView } from "../src/schedule-view";
import { SequenceView } from "../src/sequence-view" import { SequenceView } from "../src/sequence-view";
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 { View, PhaseView } from "../src/view" import { View, PhaseView } from "../src/view";
const multiviewID = "multiview"; const multiviewID = "multiview";
...@@ -29,7 +29,7 @@ const toolboxHTML = ` ...@@ -29,7 +29,7 @@ const toolboxHTML = `
<select id="display-selector"> <select id="display-selector">
<option disabled selected>(please open a file)</option> <option disabled selected>(please open a file)</option>
</select> </select>
</div>` </div>`;
export class GraphMultiView extends View { export class GraphMultiView extends View {
sourceResolver: SourceResolver; sourceResolver: SourceResolver;
...@@ -41,8 +41,8 @@ export class GraphMultiView extends View { ...@@ -41,8 +41,8 @@ export class GraphMultiView extends View {
currentPhaseView: View & PhaseView; currentPhaseView: View & PhaseView;
createViewElement() { createViewElement() {
const pane = document.createElement('div'); const pane = document.createElement("div");
pane.setAttribute('id', multiviewID); pane.setAttribute("id", multiviewID);
pane.className = "viewpane"; pane.className = "viewpane";
return pane; return pane;
} }
...@@ -59,7 +59,7 @@ export class GraphMultiView extends View { ...@@ -59,7 +59,7 @@ export class GraphMultiView extends View {
const searchInput = toolbox.querySelector("#search-input") as HTMLInputElement; const searchInput = toolbox.querySelector("#search-input") as HTMLInputElement;
searchInput.addEventListener("keyup", e => { searchInput.addEventListener("keyup", e => {
if (!view.currentPhaseView) return; if (!view.currentPhaseView) return;
view.currentPhaseView.searchInputAction(searchInput, e) view.currentPhaseView.searchInputAction(searchInput, e);
}); });
view.divNode.addEventListener("keyup", (e: KeyboardEvent) => { view.divNode.addEventListener("keyup", (e: KeyboardEvent) => {
if (e.keyCode == 191) { // keyCode == '/' if (e.keyCode == 191) { // keyCode == '/'
...@@ -67,17 +67,16 @@ export class GraphMultiView extends View { ...@@ -67,17 +67,16 @@ export class GraphMultiView extends View {
} }
}); });
searchInput.setAttribute("value", window.sessionStorage.getItem("lastSearch") || ""); searchInput.setAttribute("value", window.sessionStorage.getItem("lastSearch") || "");
this.graph = new GraphView(this.divNode, selectionBroker, this.graph = new GraphView(this.divNode, selectionBroker, phaseName => view.displayPhaseByName(phaseName));
(phaseName) => view.displayPhaseByName(phaseName));
this.schedule = new ScheduleView(this.divNode, selectionBroker); this.schedule = new ScheduleView(this.divNode, selectionBroker);
this.sequence = new SequenceView(this.divNode, selectionBroker); this.sequence = new SequenceView(this.divNode, selectionBroker);
this.selectMenu = toolbox.querySelector('#display-selector') as HTMLSelectElement; this.selectMenu = toolbox.querySelector("#display-selector") as HTMLSelectElement;
} }
initializeSelect() { initializeSelect() {
const view = this; const view = this;
view.selectMenu.innerHTML = ''; view.selectMenu.innerHTML = "";
view.sourceResolver.forEachPhase((phase) => { view.sourceResolver.forEachPhase(phase => {
const optionElement = document.createElement("option"); const optionElement = document.createElement("option");
let maxNodeId = ""; let maxNodeId = "";
if (phase.type == "graph" && phase.highestNodeId != 0) { if (phase.type == "graph" && phase.highestNodeId != 0) {
...@@ -104,11 +103,11 @@ export class GraphMultiView extends View { ...@@ -104,11 +103,11 @@ export class GraphMultiView extends View {
initializeContent() { } initializeContent() { }
displayPhase(phase) { displayPhase(phase) {
if (phase.type == 'graph') { if (phase.type == "graph") {
this.displayPhaseView(this.graph, phase.data); this.displayPhaseView(this.graph, phase.data);
} else if (phase.type == 'schedule') { } else if (phase.type == "schedule") {
this.displayPhaseView(this.schedule, phase); this.displayPhaseView(this.schedule, phase);
} else if (phase.type == 'sequence') { } else if (phase.type == "sequence") {
this.displayPhaseView(this.sequence, phase); this.displayPhaseView(this.sequence, phase);
} }
} }
......
...@@ -98,12 +98,12 @@ export class GNode { ...@@ -98,12 +98,12 @@ export class GNode {
return this.nodeLabel.type; return this.nodeLabel.type;
} }
getDisplayType() { getDisplayType() {
var type_string = this.nodeLabel.type; var typeString = this.nodeLabel.type;
if (type_string == undefined) return ""; if (typeString == undefined) return "";
if (type_string.length > 24) { if (typeString.length > 24) {
type_string = type_string.substr(0, 25) + "..."; typeString = typeString.substr(0, 25) + "...";
} }
return type_string; return typeString;
} }
deepestInputRank() { deepestInputRank() {
var deepestRank = 0; var deepestRank = 0;
......
...@@ -34,9 +34,9 @@ class Snapper { ...@@ -34,9 +34,9 @@ class Snapper {
this.setDisassemblyExpanded(this.getLastExpandedState("disassembly", false)); this.setDisassemblyExpanded(this.getLastExpandedState("disassembly", false));
} }
getLastExpandedState(type: string, default_state: boolean): boolean { getLastExpandedState(type: string, defaultState: boolean): boolean {
var state = window.sessionStorage.getItem("expandedState-" + type); var state = window.sessionStorage.getItem("expandedState-" + type);
if (state === null) return default_state; if (state === null) return defaultState;
return state === 'true'; return state === 'true';
} }
...@@ -51,11 +51,11 @@ class Snapper { ...@@ -51,11 +51,11 @@ class Snapper {
const resizer = this.resizer; const resizer = this.resizer;
this.sourceExpandUpdate(newState); this.sourceExpandUpdate(newState);
if (newState) { if (newState) {
resizer.sep_left = resizer.sep_left_snap; resizer.sepLeft = resizer.sepLeftSnap;
resizer.sep_left_snap = 0; resizer.sepLeftSnap = 0;
} else { } else {
resizer.sep_left_snap = resizer.sep_left; resizer.sepLeftSnap = resizer.sepLeft;
resizer.sep_left = 0; resizer.sepLeft = 0;
} }
} }
...@@ -70,94 +70,94 @@ class Snapper { ...@@ -70,94 +70,94 @@ class Snapper {
const resizer = this.resizer; const resizer = this.resizer;
this.disassemblyExpandUpdate(newState); this.disassemblyExpandUpdate(newState);
if (newState) { if (newState) {
resizer.sep_right = resizer.sep_right_snap; resizer.sepRight = resizer.sepRightSnap;
resizer.sep_right_snap = resizer.client_width; resizer.sepRightSnap = resizer.clientWidth;
} else { } else {
resizer.sep_right_snap = resizer.sep_right; resizer.sepRightSnap = resizer.sepRight;
resizer.sep_right = resizer.client_width; resizer.sepRight = resizer.clientWidth;
} }
} }
panesUpdated(): void { panesUpdated(): void {
this.sourceExpandUpdate(this.resizer.sep_left > this.resizer.dead_width); this.sourceExpandUpdate(this.resizer.sepLeft > this.resizer.deadWidth);
this.disassemblyExpandUpdate(this.resizer.sep_right < this.disassemblyExpandUpdate(this.resizer.sepRight <
(this.resizer.client_width - this.resizer.dead_width)); (this.resizer.clientWidth - this.resizer.deadWidth));
} }
} }
export class Resizer { export class Resizer {
snapper: Snapper; snapper: Snapper;
dead_width: number; deadWidth: number;
client_width: number; clientWidth: number;
left: HTMLElement; left: HTMLElement;
right: HTMLElement; right: HTMLElement;
middle: HTMLElement; middle: HTMLElement;
sep_left: number; sepLeft: number;
sep_right: number; sepRight: number;
sep_left_snap: number; sepLeftSnap: number;
sep_right_snap: number; sepRightSnap: number;
sep_width_offset: number; sepWidthOffset: number;
panes_updated_callback: () => void; panesUpdatedCallback: () => void;
resizer_right: d3.Selection<HTMLDivElement, any, any, any>; resizerRight: d3.Selection<HTMLDivElement, any, any, any>;
resizer_left: d3.Selection<HTMLDivElement, any, any, any>; resizerLeft: d3.Selection<HTMLDivElement, any, any, any>;
constructor(panes_updated_callback: () => void, dead_width: number) { constructor(panesUpdatedCallback: () => void, deadWidth: number) {
let resizer = this; let resizer = this;
resizer.panes_updated_callback = panes_updated_callback; resizer.panesUpdatedCallback = panesUpdatedCallback;
resizer.dead_width = dead_width 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);
resizer.resizer_left = d3.select('#resizer-left'); resizer.resizerLeft = d3.select('#resizer-left');
resizer.resizer_right = d3.select('#resizer-right'); resizer.resizerRight = d3.select('#resizer-right');
resizer.sep_left_snap = 0; resizer.sepLeftSnap = 0;
resizer.sep_right_snap = 0; resizer.sepRightSnap = 0;
// Offset to prevent resizers from sliding slightly over one another. // Offset to prevent resizers from sliding slightly over one another.
resizer.sep_width_offset = 7; resizer.sepWidthOffset = 7;
this.updateWidths(); this.updateWidths();
let dragResizeLeft = d3.drag() let dragResizeLeft = d3.drag()
.on('drag', function () { .on('drag', function () {
let x = d3.mouse(this.parentElement)[0]; let x = d3.mouse(this.parentElement)[0];
resizer.sep_left = Math.min(Math.max(0, x), resizer.sep_right - resizer.sep_width_offset); resizer.sepLeft = Math.min(Math.max(0, x), resizer.sepRight - resizer.sepWidthOffset);
resizer.updatePanes(); resizer.updatePanes();
}) })
.on('start', function () { .on('start', function () {
resizer.resizer_left.classed("dragged", true); resizer.resizerLeft.classed("dragged", true);
let x = d3.mouse(this.parentElement)[0]; let x = d3.mouse(this.parentElement)[0];
if (x > dead_width) { if (x > deadWidth) {
resizer.sep_left_snap = resizer.sep_left; resizer.sepLeftSnap = resizer.sepLeft;
} }
}) })
.on('end', function () { .on('end', function () {
if (!resizer.isRightSnapped()) { if (!resizer.isRightSnapped()) {
window.sessionStorage.setItem("source-pane-width", `${resizer.sep_left / resizer.client_width}`); window.sessionStorage.setItem("source-pane-width", `${resizer.sepLeft / resizer.clientWidth}`);
} }
resizer.resizer_left.classed("dragged", false); resizer.resizerLeft.classed("dragged", false);
}); });
resizer.resizer_left.call(dragResizeLeft); resizer.resizerLeft.call(dragResizeLeft);
let dragResizeRight = d3.drag() let dragResizeRight = d3.drag()
.on('drag', function () { .on('drag', function () {
let x = d3.mouse(this.parentElement)[0]; let x = d3.mouse(this.parentElement)[0];
resizer.sep_right = Math.max(resizer.sep_left + resizer.sep_width_offset, Math.min(x, resizer.client_width)); resizer.sepRight = Math.max(resizer.sepLeft + resizer.sepWidthOffset, Math.min(x, resizer.clientWidth));
resizer.updatePanes(); resizer.updatePanes();
}) })
.on('start', function () { .on('start', function () {
resizer.resizer_right.classed("dragged", true); resizer.resizerRight.classed("dragged", true);
let x = d3.mouse(this.parentElement)[0]; let x = d3.mouse(this.parentElement)[0];
if (x < (resizer.client_width - dead_width)) { if (x < (resizer.clientWidth - deadWidth)) {
resizer.sep_right_snap = resizer.sep_right; resizer.sepRightSnap = resizer.sepRight;
} }
}) })
.on('end', function () { .on('end', function () {
if (!resizer.isRightSnapped()) { if (!resizer.isRightSnapped()) {
console.log(`disassembly-pane-width ${resizer.sep_right}`) console.log(`disassembly-pane-width ${resizer.sepRight}`)
window.sessionStorage.setItem("disassembly-pane-width", `${resizer.sep_right / resizer.client_width}`); window.sessionStorage.setItem("disassembly-pane-width", `${resizer.sepRight / resizer.clientWidth}`);
} }
resizer.resizer_right.classed("dragged", false); resizer.resizerRight.classed("dragged", false);
}); });
resizer.resizer_right.call(dragResizeRight); resizer.resizerRight.call(dragResizeRight);
window.onresize = function () { window.onresize = function () {
resizer.updateWidths(); resizer.updateWidths();
resizer.updatePanes(); resizer.updatePanes();
...@@ -167,33 +167,33 @@ export class Resizer { ...@@ -167,33 +167,33 @@ export class Resizer {
} }
isLeftSnapped() { isLeftSnapped() {
return this.sep_left === 0; return this.sepLeft === 0;
} }
isRightSnapped() { isRightSnapped() {
return this.sep_right >= this.client_width - 1; return this.sepRight >= this.clientWidth - 1;
} }
updatePanes() { updatePanes() {
let left_snapped = this.isLeftSnapped(); let leftSnapped = this.isLeftSnapped();
let right_snapped = this.isRightSnapped(); let rightSnapped = this.isRightSnapped();
this.resizer_left.classed("snapped", left_snapped); this.resizerLeft.classed("snapped", leftSnapped);
this.resizer_right.classed("snapped", right_snapped); this.resizerRight.classed("snapped", rightSnapped);
this.left.style.width = this.sep_left + 'px'; this.left.style.width = this.sepLeft + 'px';
this.middle.style.width = (this.sep_right - this.sep_left) + 'px'; this.middle.style.width = (this.sepRight - this.sepLeft) + 'px';
this.right.style.width = (this.client_width - this.sep_right) + 'px'; this.right.style.width = (this.clientWidth - this.sepRight) + 'px';
this.resizer_left.style('left', this.sep_left + 'px'); this.resizerLeft.style('left', this.sepLeft + 'px');
this.resizer_right.style('right', (this.client_width - this.sep_right - 1) + 'px'); this.resizerRight.style('right', (this.clientWidth - this.sepRight - 1) + 'px');
this.snapper.panesUpdated(); this.snapper.panesUpdated();
this.panes_updated_callback(); this.panesUpdatedCallback();
} }
updateWidths() { updateWidths() {
this.client_width = document.body.getBoundingClientRect().width; this.clientWidth = document.body.getBoundingClientRect().width;
const sep_left = window.sessionStorage.getItem("source-pane-width"); const sepLeft = window.sessionStorage.getItem("source-pane-width");
this.sep_left = this.client_width * (sep_left ? Number.parseFloat(sep_left) : (1 / 3)); this.sepLeft = this.clientWidth * (sepLeft ? Number.parseFloat(sepLeft) : (1 / 3));
const sep_right = window.sessionStorage.getItem("disassembly-pane-width"); const sepRight = window.sessionStorage.getItem("disassembly-pane-width");
this.sep_right = this.client_width * (sep_right ? Number.parseFloat(sep_right) : (2 / 3)); this.sepRight = this.clientWidth * (sepRight ? Number.parseFloat(sepRight) : (2 / 3));
} }
} }
...@@ -92,21 +92,21 @@ export class ScheduleView extends TextView implements PhaseView { ...@@ -92,21 +92,21 @@ export class ScheduleView extends TextView implements PhaseView {
instrMarker.onclick = mkNodeLinkHandler(node.id); instrMarker.onclick = mkNodeLinkHandler(node.id);
nodeEl.appendChild(instrMarker); nodeEl.appendChild(instrMarker);
const node_id = createElement("div", "node-id tag clickable", node.id); const nodeId = createElement("div", "node-id tag clickable", node.id);
node_id.onclick = mkNodeLinkHandler(node.id); nodeId.onclick = mkNodeLinkHandler(node.id);
view.addHtmlElementForNodeId(node.id, node_id); view.addHtmlElementForNodeId(node.id, nodeId);
nodeEl.appendChild(node_id); nodeEl.appendChild(nodeId);
const node_label = createElement("div", "node-label", node.label); const nodeLabel = createElement("div", "node-label", node.label);
nodeEl.appendChild(node_label); nodeEl.appendChild(nodeLabel);
if (node.inputs.length > 0) { if (node.inputs.length > 0) {
const node_parameters = createElement("div", "parameter-list comma-sep-list"); const nodeParameters = createElement("div", "parameter-list comma-sep-list");
for (const param of node.inputs) { for (const param of node.inputs) {
const paramEl = createElement("div", "parameter tag clickable", param); const paramEl = createElement("div", "parameter tag clickable", param);
node_parameters.appendChild(paramEl); nodeParameters.appendChild(paramEl);
paramEl.onclick = mkNodeLinkHandler(param); paramEl.onclick = mkNodeLinkHandler(param);
view.addHtmlElementForNodeId(param, paramEl); view.addHtmlElementForNodeId(param, paramEl);
} }
nodeEl.appendChild(node_parameters); nodeEl.appendChild(nodeParameters);
} }
return nodeEl; return nodeEl;
...@@ -122,38 +122,38 @@ export class ScheduleView extends TextView implements PhaseView { ...@@ -122,38 +122,38 @@ export class ScheduleView extends TextView implements PhaseView {
}; };
} }
const schedule_block = createElement("div", "schedule-block"); const scheduleBlock = createElement("div", "schedule-block");
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);
schedule_block.appendChild(instrMarker); scheduleBlock.appendChild(instrMarker);
const block_id = createElement("div", "block-id com clickable", block.id); const blockId = createElement("div", "block-id com clickable", block.id);
block_id.onclick = mkBlockLinkHandler(block.id); blockId.onclick = mkBlockLinkHandler(block.id);
schedule_block.appendChild(block_id); scheduleBlock.appendChild(blockId);
const block_pred = createElement("div", "predecessor-list block-list comma-sep-list"); const blockPred = createElement("div", "predecessor-list block-list comma-sep-list");
for (const pred of block.pred) { for (const pred of block.pred) {
const predEl = createElement("div", "block-id com clickable", pred); const predEl = createElement("div", "block-id com clickable", pred);
predEl.onclick = mkBlockLinkHandler(pred); predEl.onclick = mkBlockLinkHandler(pred);
block_pred.appendChild(predEl); blockPred.appendChild(predEl);
} }
if (block.pred.length) schedule_block.appendChild(block_pred); if (block.pred.length) scheduleBlock.appendChild(blockPred);
const nodes = createElement("div", "nodes"); const nodes = createElement("div", "nodes");
for (const node of block.nodes) { for (const node of block.nodes) {
nodes.appendChild(createElementForNode(node)); nodes.appendChild(createElementForNode(node));
} }
schedule_block.appendChild(nodes); scheduleBlock.appendChild(nodes);
const block_succ = createElement("div", "successor-list block-list comma-sep-list"); const blockSucc = createElement("div", "successor-list block-list comma-sep-list");
for (const succ of block.succ) { for (const succ of block.succ) {
const succEl = createElement("div", "block-id com clickable", succ); const succEl = createElement("div", "block-id com clickable", succ);
succEl.onclick = mkBlockLinkHandler(succ); succEl.onclick = mkBlockLinkHandler(succ);
block_succ.appendChild(succEl); blockSucc.appendChild(succEl);
} }
if (block.succ.length) schedule_block.appendChild(block_succ); if (block.succ.length) scheduleBlock.appendChild(blockSucc);
this.addHtmlElementForBlockId(block.id, schedule_block); this.addHtmlElementForBlockId(block.id, scheduleBlock);
return schedule_block; return scheduleBlock;
} }
addBlocks(blocks) { addBlocks(blocks) {
......
...@@ -49,7 +49,7 @@ export class SelectionBroker { ...@@ -49,7 +49,7 @@ export class SelectionBroker {
} }
broadcastSourcePositionSelect(from, sourcePositions, selected) { broadcastSourcePositionSelect(from, sourcePositions, selected) {
sourcePositions = sourcePositions.filter((l) => { sourcePositions = sourcePositions.filter(l => {
if (!sourcePositionValid(l)) { if (!sourcePositionValid(l)) {
console.log("Warning: invalid source position"); console.log("Warning: invalid source position");
return false; return false;
......
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
// 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;
search_info: Array<any>; searchInfo: Array<any>;
createViewElement() { createViewElement() {
const pane = document.createElement('div'); const pane = document.createElement('div');
...@@ -39,7 +39,7 @@ export class SequenceView extends TextView implements PhaseView { ...@@ -39,7 +39,7 @@ export class SequenceView extends TextView implements PhaseView {
initializeContent(data, rememberedSelection) { initializeContent(data, rememberedSelection) {
this.divNode.innerHTML = ''; this.divNode.innerHTML = '';
this.sequence = data.sequence; this.sequence = data.sequence;
this.search_info = []; this.searchInfo = [];
this.divNode.addEventListener('click', (e: MouseEvent) => { this.divNode.addEventListener('click', (e: MouseEvent) => {
if (!(e.target instanceof HTMLElement)) return; if (!(e.target instanceof HTMLElement)) return;
const instructionId = Number.parseInt(e.target.dataset.instructionId, 10); const instructionId = Number.parseInt(e.target.dataset.instructionId, 10);
...@@ -82,25 +82,25 @@ export class SequenceView extends TextView implements PhaseView { ...@@ -82,25 +82,25 @@ export class SequenceView extends TextView implements PhaseView {
return mkLinkHandler(text, view.selectionHandler); return mkLinkHandler(text, view.selectionHandler);
} }
function elementForOperand(operand, search_info) { function elementForOperand(operand, searchInfo) {
var text = operand.text; var text = operand.text;
const operandEl = createElement("div", ["parameter", "tag", "clickable", operand.type], text); const operandEl = createElement("div", ["parameter", "tag", "clickable", operand.type], text);
if (operand.tooltip) { if (operand.tooltip) {
operandEl.setAttribute("title", operand.tooltip); operandEl.setAttribute("title", operand.tooltip);
} }
operandEl.onclick = mkOperandLinkHandler(text); operandEl.onclick = mkOperandLinkHandler(text);
search_info.push(text); searchInfo.push(text);
view.addHtmlElementForNodeId(text, operandEl); view.addHtmlElementForNodeId(text, operandEl);
return operandEl; return operandEl;
} }
function elementForInstruction(instruction, search_info) { function elementForInstruction(instruction, searchInfo) {
const instNodeEl = createElement("div", "instruction-node"); const instNodeEl = createElement("div", "instruction-node");
const inst_id = createElement("div", "instruction-id", instruction.id); const instId = createElement("div", "instruction-id", instruction.id);
inst_id.classList.add("clickable"); instId.classList.add("clickable");
inst_id.dataset.instructionId = instruction.id; instId.dataset.instructionId = instruction.id;
instNodeEl.appendChild(inst_id); instNodeEl.appendChild(instId);
const instContentsEl = createElement("div", "instruction-contents"); const instContentsEl = createElement("div", "instruction-contents");
instNodeEl.appendChild(instContentsEl); instNodeEl.appendChild(instContentsEl);
...@@ -112,11 +112,11 @@ export class SequenceView extends TextView implements PhaseView { ...@@ -112,11 +112,11 @@ export class SequenceView extends TextView implements PhaseView {
const moves = createElement("div", ["comma-sep-list", "gap-move"]); const moves = createElement("div", ["comma-sep-list", "gap-move"]);
for (const move of gap) { for (const move of gap) {
const moveEl = createElement("div", "move"); const moveEl = createElement("div", "move");
const destinationEl = elementForOperand(move[0], search_info); const destinationEl = elementForOperand(move[0], searchInfo);
moveEl.appendChild(destinationEl); moveEl.appendChild(destinationEl);
const assignEl = createElement("div", "assign", "="); const assignEl = createElement("div", "assign", "=");
moveEl.appendChild(assignEl); moveEl.appendChild(assignEl);
const sourceEl = elementForOperand(move[1], search_info); const sourceEl = elementForOperand(move[1], searchInfo);
moveEl.appendChild(sourceEl); moveEl.appendChild(sourceEl);
moves.appendChild(moveEl); moves.appendChild(moveEl);
} }
...@@ -129,7 +129,7 @@ export class SequenceView extends TextView implements PhaseView { ...@@ -129,7 +129,7 @@ export class SequenceView extends TextView implements PhaseView {
if (instruction.outputs.length > 0) { if (instruction.outputs.length > 0) {
const outputs = createElement("div", ["comma-sep-list", "input-output-list"]); const outputs = createElement("div", ["comma-sep-list", "input-output-list"]);
for (const output of instruction.outputs) { for (const output of instruction.outputs) {
const outputEl = elementForOperand(output, search_info); const outputEl = elementForOperand(output, searchInfo);
outputs.appendChild(outputEl); outputs.appendChild(outputEl);
} }
instEl.appendChild(outputs); instEl.appendChild(outputs);
...@@ -138,15 +138,15 @@ export class SequenceView extends TextView implements PhaseView { ...@@ -138,15 +138,15 @@ export class SequenceView extends TextView implements PhaseView {
} }
var text = instruction.opcode + instruction.flags; var text = instruction.opcode + instruction.flags;
const inst_label = createElement("div", "node-label", text); const instLabel = createElement("div", "node-label", text);
search_info.push(text); searchInfo.push(text);
view.addHtmlElementForNodeId(text, inst_label); view.addHtmlElementForNodeId(text, instLabel);
instEl.appendChild(inst_label); instEl.appendChild(instLabel);
if (instruction.inputs.length > 0) { if (instruction.inputs.length > 0) {
const inputs = createElement("div", ["comma-sep-list", "input-output-list"]); const inputs = createElement("div", ["comma-sep-list", "input-output-list"]);
for (const input of instruction.inputs) { for (const input of instruction.inputs) {
const inputEl = elementForOperand(input, search_info); const inputEl = elementForOperand(input, searchInfo);
inputs.appendChild(inputEl); inputs.appendChild(inputEl);
} }
instEl.appendChild(inputs); instEl.appendChild(inputs);
...@@ -155,7 +155,7 @@ export class SequenceView extends TextView implements PhaseView { ...@@ -155,7 +155,7 @@ export class SequenceView extends TextView implements PhaseView {
if (instruction.temps.length > 0) { if (instruction.temps.length > 0) {
const temps = createElement("div", ["comma-sep-list", "input-output-list", "temps"]); const temps = createElement("div", ["comma-sep-list", "input-output-list", "temps"]);
for (const temp of instruction.temps) { for (const temp of instruction.temps) {
const tempEl = elementForOperand(temp, search_info); const tempEl = elementForOperand(temp, searchInfo);
temps.appendChild(tempEl); temps.appendChild(tempEl);
} }
instEl.appendChild(temps); instEl.appendChild(temps);
...@@ -164,20 +164,20 @@ export class SequenceView extends TextView implements PhaseView { ...@@ -164,20 +164,20 @@ export class SequenceView extends TextView implements PhaseView {
return instNodeEl; return instNodeEl;
} }
const sequence_block = createElement("div", "schedule-block"); const sequenceBlock = createElement("div", "schedule-block");
const block_id = createElement("div", ["block-id", "com", "clickable"], block.id); const blockId = createElement("div", ["block-id", "com", "clickable"], block.id);
block_id.onclick = mkBlockLinkHandler(block.id); blockId.onclick = mkBlockLinkHandler(block.id);
sequence_block.appendChild(block_id); sequenceBlock.appendChild(blockId);
const block_pred = createElement("div", ["predecessor-list", "block-list", "comma-sep-list"]); const blockPred = createElement("div", ["predecessor-list", "block-list", "comma-sep-list"]);
for (const pred of block.predecessors) { for (const pred of block.predecessors) {
const predEl = createElement("div", ["block-id", "com", "clickable"], pred); const predEl = createElement("div", ["block-id", "com", "clickable"], pred);
predEl.onclick = mkBlockLinkHandler(pred); predEl.onclick = mkBlockLinkHandler(pred);
block_pred.appendChild(predEl); blockPred.appendChild(predEl);
} }
if (block.predecessors.length > 0) sequence_block.appendChild(block_pred); if (block.predecessors.length > 0) sequenceBlock.appendChild(blockPred);
const phis = createElement("div", "phis"); const phis = createElement("div", "phis");
sequence_block.appendChild(phis); sequenceBlock.appendChild(phis);
const phiLabel = createElement("div", "phi-label", "phi:"); const phiLabel = createElement("div", "phi-label", "phi:");
phis.appendChild(phiLabel); phis.appendChild(phiLabel);
...@@ -189,7 +189,7 @@ export class SequenceView extends TextView implements PhaseView { ...@@ -189,7 +189,7 @@ export class SequenceView extends TextView implements PhaseView {
const phiEl = createElement("div", "phi"); const phiEl = createElement("div", "phi");
phiContents.appendChild(phiEl); phiContents.appendChild(phiEl);
const outputEl = elementForOperand(phi.output, this.search_info); const outputEl = elementForOperand(phi.output, this.searchInfo);
phiEl.appendChild(outputEl); phiEl.appendChild(outputEl);
const assignEl = createElement("div", "assign", "="); const assignEl = createElement("div", "assign", "=");
...@@ -203,18 +203,18 @@ export class SequenceView extends TextView implements PhaseView { ...@@ -203,18 +203,18 @@ export class SequenceView extends TextView implements PhaseView {
const instructions = createElement("div", "instructions"); const instructions = createElement("div", "instructions");
for (const instruction of block.instructions) { for (const instruction of block.instructions) {
instructions.appendChild(elementForInstruction(instruction, this.search_info)); instructions.appendChild(elementForInstruction(instruction, this.searchInfo));
} }
sequence_block.appendChild(instructions); sequenceBlock.appendChild(instructions);
const block_succ = createElement("div", ["successor-list", "block-list", "comma-sep-list"]); const blockSucc = createElement("div", ["successor-list", "block-list", "comma-sep-list"]);
for (const succ of block.successors) { for (const succ of block.successors) {
const succEl = createElement("div", ["block-id", "com", "clickable"], succ); const succEl = createElement("div", ["block-id", "com", "clickable"], succ);
succEl.onclick = mkBlockLinkHandler(succ); succEl.onclick = mkBlockLinkHandler(succ);
block_succ.appendChild(succEl); blockSucc.appendChild(succEl);
} }
if (block.successors.length > 0) sequence_block.appendChild(block_succ); if (block.successors.length > 0) sequenceBlock.appendChild(blockSucc);
this.addHtmlElementForBlockId(block.id, sequence_block); this.addHtmlElementForBlockId(block.id, sequenceBlock);
return sequence_block; return sequenceBlock;
} }
addBlocks(blocks) { addBlocks(blocks) {
...@@ -232,7 +232,7 @@ export class SequenceView extends TextView implements PhaseView { ...@@ -232,7 +232,7 @@ export class SequenceView extends TextView implements PhaseView {
const select = []; const select = [];
window.sessionStorage.setItem("lastSearch", query); window.sessionStorage.setItem("lastSearch", query);
const reg = new RegExp(query); const reg = new RegExp(query);
for (const item of this.search_info) { for (const item of this.searchInfo) {
if (reg.exec(item) != null) { if (reg.exec(item) != null) {
select.push(item); select.push(item);
} }
......
...@@ -235,7 +235,7 @@ export class SourceResolver { ...@@ -235,7 +235,7 @@ export class SourceResolver {
return sourcePositionArray; return sourcePositionArray;
} }
forEachSource(f: (value: Source, index: number, array: Source[]) => void) { forEachSource(f: (value: Source, index: number, array: Array<Source>) => void) {
this.sources.forEach(f); this.sources.forEach(f);
} }
...@@ -294,8 +294,7 @@ export class SourceResolver { ...@@ -294,8 +294,7 @@ export class SourceResolver {
if (!this.sources[sourceId]) return []; if (!this.sources[sourceId]) return [];
const res = []; const res = [];
const list = this.sources[sourceId].sourcePositions; const list = this.sources[sourceId].sourcePositions;
for (let i = 0; i < list.length; i++) { for (const sourcePosition of list) {
const sourcePosition = list[i]
if (start <= sourcePosition.scriptOffset && sourcePosition.scriptOffset < end) { if (start <= sourcePosition.scriptOffset && sourcePosition.scriptOffset < end) {
res.push(sourcePosition); res.push(sourcePosition);
} }
...@@ -507,7 +506,7 @@ export class SourceResolver { ...@@ -507,7 +506,7 @@ export class SourceResolver {
return this.phaseNames.get(phaseName); return this.phaseNames.get(phaseName);
} }
forEachPhase(f: (value: Phase, index: number, array: Phase[]) => void) { forEachPhase(f: (value: Phase, index: number, array: Array<Phase>) => void) {
this.phases.forEach(f); this.phases.forEach(f);
} }
...@@ -534,12 +533,12 @@ export class SourceResolver { ...@@ -534,12 +533,12 @@ export class SourceResolver {
} }
parseSchedule(phase) { parseSchedule(phase) {
function createNode(state, match) { function createNode(state: any, match) {
let inputs = []; let inputs = [];
if (match.groups.args) { if (match.groups.args) {
const nodeIdsString = match.groups.args.replace(/\s/g, ''); const nodeIdsString = match.groups.args.replace(/\s/g, '');
const nodeIdStrings = nodeIdsString.split(','); const nodeIdStrings = nodeIdsString.split(',');
inputs = nodeIdStrings.map((n) => Number.parseInt(n, 10)); inputs = nodeIdStrings.map(n => Number.parseInt(n, 10));
} }
const node = { const node = {
id: Number.parseInt(match.groups.id, 10), id: Number.parseInt(match.groups.id, 10),
...@@ -549,7 +548,7 @@ export class SourceResolver { ...@@ -549,7 +548,7 @@ export class SourceResolver {
if (match.groups.blocks) { if (match.groups.blocks) {
const nodeIdsString = match.groups.blocks.replace(/\s/g, '').replace(/B/g, ''); const nodeIdsString = match.groups.blocks.replace(/\s/g, '').replace(/B/g, '');
const nodeIdStrings = nodeIdsString.split(','); const nodeIdStrings = nodeIdsString.split(',');
const successors = nodeIdStrings.map((n) => Number.parseInt(n, 10)); const successors = nodeIdStrings.map(n => Number.parseInt(n, 10));
state.currentBlock.succ = successors; state.currentBlock.succ = successors;
} }
state.nodes[node.id] = node; state.nodes[node.id] = node;
...@@ -560,7 +559,7 @@ export class SourceResolver { ...@@ -560,7 +559,7 @@ export class SourceResolver {
if (match.groups.in) { if (match.groups.in) {
const blockIdsString = match.groups.in.replace(/\s/g, '').replace(/B/g, ''); const blockIdsString = match.groups.in.replace(/\s/g, '').replace(/B/g, '');
const blockIdStrings = blockIdsString.split(','); const blockIdStrings = blockIdsString.split(',');
predecessors = blockIdStrings.map((n) => Number.parseInt(n, 10)); predecessors = blockIdStrings.map(n => Number.parseInt(n, 10));
} }
const block = { const block = {
id: Number.parseInt(match.groups.id, 10), id: Number.parseInt(match.groups.id, 10),
......
...@@ -59,7 +59,7 @@ export abstract class TextView extends View { ...@@ -59,7 +59,7 @@ export abstract class TextView extends View {
}; };
this.selectionHandler = selectionHandler; this.selectionHandler = selectionHandler;
broker.addNodeHandler(selectionHandler); broker.addNodeHandler(selectionHandler);
view.divNode.addEventListener('click', (e) => { view.divNode.addEventListener('click', e => {
if (!e.shiftKey) { if (!e.shiftKey) {
view.selectionHandler.clear(); view.selectionHandler.clear();
} }
......
...@@ -31,7 +31,7 @@ window.onload = function () { ...@@ -31,7 +31,7 @@ window.onload = function () {
txtRes += '{"name":"disassembly","type":"disassembly","data":""}]}'; txtRes += '{"name":"disassembly","type":"disassembly","data":""}]}';
} }
try { try {
sourceViews.forEach((sv) => sv.hide()); sourceViews.forEach(sv => sv.hide());
if (multiview) multiview.hide(); if (multiview) multiview.hide();
multiview = null; multiview = null;
if (disassemblyView) disassemblyView.hide(); if (disassemblyView) disassemblyView.hide();
...@@ -72,7 +72,7 @@ window.onload = function () { ...@@ -72,7 +72,7 @@ window.onload = function () {
sourceView.show(null, null); sourceView.show(null, null);
sourceViews.push(sourceView); sourceViews.push(sourceView);
sourceResolver.forEachSource((source) => { sourceResolver.forEachSource(source => {
let sourceView = new CodeView(sourceContainer, selectionBroker, sourceResolver, source, CodeMode.INLINED_SOURCE); let sourceView = new CodeView(sourceContainer, selectionBroker, sourceResolver, source, CodeMode.INLINED_SOURCE);
sourceView.show(null, null); sourceView.show(null, null);
sourceViews.push(sourceView); sourceViews.push(sourceView);
......
...@@ -60,8 +60,8 @@ export function sortUnique<T>(arr: Array<T>, f: (a: T, b: T) => number, equal: ( ...@@ -60,8 +60,8 @@ export function sortUnique<T>(arr: Array<T>, f: (a: T, b: T) => number, equal: (
} }
// Partial application without binding the receiver // Partial application without binding the receiver
export function partial(f: any, ...arguments1: any[]) { export function partial(f: any, ...arguments1: Array<any>) {
return function (this: any, ...arguments2: any[]) { return function (this: any, ...arguments2: Array<any>) {
f.apply(this, [...arguments1, ...arguments2]); f.apply(this, [...arguments1, ...arguments2]);
} }
} }
......
...@@ -19,7 +19,7 @@ export abstract class View { ...@@ -19,7 +19,7 @@ export abstract class View {
return false; return false;
} }
show(data, rememberedSelection): void { show(data: any, rememberedSelection: Selection): void {
this.initializeContent(data, rememberedSelection); this.initializeContent(data, rememberedSelection);
this.container.appendChild(this.divNode); this.container.appendChild(this.divNode);
} }
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
"limit": 80 "limit": 80
}], }],
"ordered-imports": false, "ordered-imports": false,
"array-type": [false, "generic"], "array-type": [true, "generic"],
"semicolon": false, "semicolon": false,
"member-access": false, "member-access": false,
"object-literal-shorthand": false, "object-literal-shorthand": false,
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
"trailing-comma": false, "trailing-comma": false,
"member-ordering": false, "member-ordering": false,
"no-string-literal": false, "no-string-literal": false,
"arrow-parens": false, "arrow-parens": [true, "ban-single-arg-parens"],
"no-console": false, "no-console": false,
"interface-name": false, "interface-name": false,
"no-bitwise": false, "no-bitwise": false,
......
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