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

[turbolizer] Enable TypeScript warning noUnusedLocals

...and fix all related issues.

Change-Id: I3bd37ae038b9ea7c4305600958c1ae20e67e0f1f
Notry: true
Bug: v8:7327
Reviewed-on: https://chromium-review.googlesource.com/c/1396092Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58552}
parent e75a97cd
...@@ -6,7 +6,7 @@ import { Source, SourceResolver, sourcePositionToStringKey } from "../src/source ...@@ -6,7 +6,7 @@ import { Source, SourceResolver, sourcePositionToStringKey } from "../src/source
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 { anyToString, 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 {
...@@ -118,7 +118,6 @@ export class CodeView extends View { ...@@ -118,7 +118,6 @@ export class CodeView extends View {
} }
onSelectLine(lineNumber: number, doClear: boolean) { onSelectLine(lineNumber: number, doClear: boolean) {
const key = anyToString(lineNumber);
if (doClear) { if (doClear) {
this.selectionHandler.clear(); this.selectionHandler.clear();
} }
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
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 { SourceResolver } from "./source-resolver";
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";
...@@ -139,7 +138,7 @@ export class DisassemblyView extends TextView { ...@@ -139,7 +138,7 @@ export class DisassemblyView extends TextView {
const offset = e.target.dataset.pcOffset ? e.target.dataset.pcOffset : e.target.parentElement.dataset.pcOffset; const offset = e.target.dataset.pcOffset ? e.target.dataset.pcOffset : e.target.parentElement.dataset.pcOffset;
if ((typeof offset) != "undefined" && !Number.isNaN(Number(offset))) { if ((typeof offset) != "undefined" && !Number.isNaN(Number(offset))) {
view.offsetSelection.select([offset], true); view.offsetSelection.select([offset], true);
const [nodes, blockId] = view.sourceResolver.nodesForPCOffset(offset) 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) {
...@@ -210,7 +209,7 @@ export class DisassemblyView extends TextView { ...@@ -210,7 +209,7 @@ export class DisassemblyView extends TextView {
const instructionBinaryInput: HTMLInputElement = view.divNode.querySelector("#show-instruction-binary"); const instructionBinaryInput: HTMLInputElement = view.divNode.querySelector("#show-instruction-binary");
const lastShowInstructionBinary = window.sessionStorage.getItem("show-instruction-binary"); const lastShowInstructionBinary = window.sessionStorage.getItem("show-instruction-binary");
instructionBinaryInput.checked = lastShowInstructionAddress == 'true'; instructionBinaryInput.checked = lastShowInstructionBinary == 'true';
const showInstructionBinaryHandler = () => { const showInstructionBinaryHandler = () => {
window.sessionStorage.setItem("show-instruction-binary", `${instructionBinaryInput.checked}`); window.sessionStorage.setItem("show-instruction-binary", `${instructionBinaryInput.checked}`);
for (const el of view.divNode.querySelectorAll(".instruction-binary")) { for (const el of view.divNode.querySelectorAll(".instruction-binary")) {
......
...@@ -27,14 +27,6 @@ function newGraphOccupation(graph:Graph) { ...@@ -27,14 +27,6 @@ function newGraphOccupation(graph:Graph) {
} }
} }
function indexToSlot(index) {
if ((index % 0) == 0) {
return index / 2;
} else {
return -((index - 1) / 2);
}
}
function positionToSlot(pos) { function positionToSlot(pos) {
return Math.floor(pos / NODE_INPUT_WIDTH); return Math.floor(pos / NODE_INPUT_WIDTH);
} }
...@@ -43,10 +35,6 @@ function newGraphOccupation(graph:Graph) { ...@@ -43,10 +35,6 @@ function newGraphOccupation(graph:Graph) {
return slot * NODE_INPUT_WIDTH return slot * NODE_INPUT_WIDTH
} }
function slotToRightPosition(slot) {
return (slot + 1) * NODE_INPUT_WIDTH
}
function findSpace(pos, width, direction) { function findSpace(pos, width, direction) {
var widthSlots = Math.floor((width + NODE_INPUT_WIDTH - 1) / var widthSlots = Math.floor((width + NODE_INPUT_WIDTH - 1) /
NODE_INPUT_WIDTH); NODE_INPUT_WIDTH);
......
...@@ -314,7 +314,6 @@ export class GraphView extends View implements PhaseView { ...@@ -314,7 +314,6 @@ export class GraphView extends View implements PhaseView {
}).classed("halfFilledBubbleStyle", function (c) { }).classed("halfFilledBubbleStyle", function (c) {
const components = this.id.split(','); const components = this.id.split(',');
if (components[0] == "ib") { if (components[0] == "ib") {
const edge = g.nodeMap[components[3]].inputs[components[2]];
return false; return false;
} else { } else {
return g.nodeMap[components[1]].areAnyOutputsVisible() == 1; return g.nodeMap[components[1]].areAnyOutputsVisible() == 1;
...@@ -672,11 +671,9 @@ export class GraphView extends View implements PhaseView { ...@@ -672,11 +671,9 @@ export class GraphView extends View implements PhaseView {
adjOutputEdges.attr('relToHover', "output"); adjOutputEdges.attr('relToHover', "output");
const adjInputNodes = adjInputEdges.data().map(e => e.source); const adjInputNodes = adjInputEdges.data().map(e => e.source);
const visibleNodes = view.visibleNodes.selectAll<SVGGElement, GNode>("g"); const visibleNodes = view.visibleNodes.selectAll<SVGGElement, GNode>("g");
const input = visibleNodes.data<GNode>(adjInputNodes, nodeToStr) visibleNodes.data<GNode>(adjInputNodes, nodeToStr).attr('relToHover', "input");
.attr('relToHover', "input");
const adjOutputNodes = adjOutputEdges.data().map(e => e.target); const adjOutputNodes = adjOutputEdges.data().map(e => e.target);
const output = visibleNodes.data<GNode>(adjOutputNodes, nodeToStr) visibleNodes.data<GNode>(adjOutputNodes, nodeToStr).attr('relToHover', "output");
.attr('relToHover', "output");
view.updateGraphVisibility(); view.updateGraphVisibility();
}) })
.on('mouseleave', function (node) { .on('mouseleave', function (node) {
...@@ -685,8 +682,7 @@ export class GraphView extends View implements PhaseView { ...@@ -685,8 +682,7 @@ export class GraphView extends View implements PhaseView {
adjEdges.attr('relToHover', "none"); adjEdges.attr('relToHover', "none");
const adjNodes = adjEdges.data().map(e => e.target).concat(adjEdges.data().map(e => e.source)); const adjNodes = adjEdges.data().map(e => e.target).concat(adjEdges.data().map(e => e.source));
const visibleNodes = view.visibleNodes.selectAll<SVGPathElement, GNode>("g"); const visibleNodes = view.visibleNodes.selectAll<SVGPathElement, GNode>("g");
const nodes = visibleNodes.data(adjNodes, nodeToStr) visibleNodes.data(adjNodes, nodeToStr).attr('relToHover', "none");
.attr('relToHover', "none");
view.updateGraphVisibility(); view.updateGraphVisibility();
}) })
.on("click", (d) => { .on("click", (d) => {
...@@ -880,7 +876,6 @@ export class GraphView extends View implements PhaseView { ...@@ -880,7 +876,6 @@ export class GraphView extends View implements PhaseView {
const x = (minX + maxX) / 2; const x = (minX + maxX) / 2;
const y = (minY + maxY) / 2; const y = (minY + maxY) / 2;
const scale = Math.min(width / (1.1 * dx), height / (1.1 * dy)); const scale = Math.min(width / (1.1 * dx), height / (1.1 * dy));
const transform = d3.zoomIdentity.translate(1500, 100).scale(0.75);
this.svg this.svg
.transition().duration(300).call(this.panZoom.translateTo, x, y) .transition().duration(300).call(this.panZoom.translateTo, x, y)
.transition().duration(300).call(this.panZoom.scaleTo, scale) .transition().duration(300).call(this.panZoom.scaleTo, scale)
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
// 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 {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"
......
...@@ -49,7 +49,6 @@ export class SelectionBroker { ...@@ -49,7 +49,6 @@ export class SelectionBroker {
} }
broadcastSourcePositionSelect(from, sourcePositions, selected) { broadcastSourcePositionSelect(from, sourcePositions, selected) {
let broker = this;
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");
...@@ -67,7 +66,6 @@ export class SelectionBroker { ...@@ -67,7 +66,6 @@ export class SelectionBroker {
} }
broadcastNodeSelect(from, nodes, selected) { broadcastNodeSelect(from, nodes, selected) {
let broker = this;
for (const b of this.nodeHandlers) { for (const b of this.nodeHandlers) {
if (b != from) b.brokeredNodeSelect(nodes, selected); if (b != from) b.brokeredNodeSelect(nodes, selected);
} }
...@@ -78,7 +76,6 @@ export class SelectionBroker { ...@@ -78,7 +76,6 @@ export class SelectionBroker {
} }
broadcastBlockSelect(from, blocks, selected) { broadcastBlockSelect(from, blocks, selected) {
let broker = this;
for (var b of this.blockHandlers) { for (var b of this.blockHandlers) {
if (b != from) b.brokeredBlockSelect(blocks, selected); if (b != from) b.brokeredBlockSelect(blocks, selected);
} }
......
...@@ -6,7 +6,6 @@ import {Sequence} from "../src/source-resolver" ...@@ -6,7 +6,6 @@ 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"
import { MySelection } from "./selection";
export class SequenceView extends TextView implements PhaseView { export class SequenceView extends TextView implements PhaseView {
sequence: Sequence; sequence: Sequence;
......
...@@ -48,9 +48,9 @@ interface BytecodePosition { ...@@ -48,9 +48,9 @@ interface BytecodePosition {
bytecodePosition: number; bytecodePosition: number;
} }
type Origin = NodeOrigin | BytecodePosition; export type Origin = NodeOrigin | BytecodePosition;
type TurboFanNodeOrigin = NodeOrigin & TurboFanOrigin; export type TurboFanNodeOrigin = NodeOrigin & TurboFanOrigin;
type TurboFanBytecodeOrigin = BytecodePosition & TurboFanOrigin; export type TurboFanBytecodeOrigin = BytecodePosition & TurboFanOrigin;
type AnyPosition = SourcePosition | BytecodePosition; type AnyPosition = SourcePosition | BytecodePosition;
...@@ -199,7 +199,7 @@ export class SourceResolver { ...@@ -199,7 +199,7 @@ export class SourceResolver {
} }
this.positionToNodes.get(key).push(nodeId); this.positionToNodes.get(key).push(nodeId);
} }
for (const [sourceId, source] of Object.entries(this.sources)) { for (const [, source] of Object.entries(this.sources)) {
source.sourcePositions = sortUnique(source.sourcePositions, source.sourcePositions = sortUnique(source.sourcePositions,
sourcePositionLe, sourcePositionEq); sourcePositionLe, sourcePositionEq);
} }
...@@ -435,7 +435,7 @@ export class SourceResolver { ...@@ -435,7 +435,7 @@ export class SourceResolver {
} }
parsePhases(phases) { parsePhases(phases) {
for (const [phaseId, phase] of Object.entries<Phase>(phases)) { for (const [, phase] of Object.entries<Phase>(phases)) {
switch (phase.type) { switch (phase.type) {
case 'disassembly': case 'disassembly':
this.disassemblyPhase = phase; this.disassemblyPhase = phase;
......
...@@ -168,7 +168,6 @@ export abstract class TextView extends View { ...@@ -168,7 +168,6 @@ export abstract class TextView extends View {
} }
createFragment(text, style) { createFragment(text, style) {
let view = this;
let fragment = document.createElement("SPAN"); let fragment = document.createElement("SPAN");
if (typeof style.associateData == 'function') { if (typeof style.associateData == 'function') {
......
...@@ -197,7 +197,6 @@ class Resizer { ...@@ -197,7 +197,6 @@ class Resizer {
} }
window.onload = function () { window.onload = function () {
var svg = null;
var multiview = null; var multiview = null;
var disassemblyView = null; var disassemblyView = null;
var sourceViews = []; var sourceViews = [];
......
...@@ -47,45 +47,6 @@ export class ViewElements { ...@@ -47,45 +47,6 @@ export class ViewElements {
} }
} }
function lowerBound(a, value, compare, lookup) {
let first = 0;
let count = a.length;
while (count > 0) {
let step = Math.floor(count / 2);
let middle = first + step;
let middle_value = (lookup === undefined) ? a[middle] : lookup(a, middle);
let result = (compare === undefined) ? (middle_value < value) : compare(middle_value, value);
if (result) {
first = middle + 1;
count -= step + 1;
} else {
count = step;
}
}
return first;
}
function upperBound(a, value, compare, lookup) {
let first = 0;
let count = a.length;
while (count > 0) {
let step = Math.floor(count / 2);
let middle = first + step;
let middle_value = (lookup === undefined) ? a[middle] : lookup(a, middle);
let result = (compare === undefined) ? (value < middle_value) : compare(value, middle_value);
if (!result) {
first = middle + 1;
count -= step + 1;
} else {
count = step;
}
}
return first;
}
export function sortUnique<T>(arr: Array<T>, f: (a: T, b: T) => number, equal: (a: T, b: T) => boolean) { export function sortUnique<T>(arr: Array<T>, f: (a: T, b: T) => number, equal: (a: T, b: T) => boolean) {
if (arr.length == 0) return arr; if (arr.length == 0) return arr;
arr = arr.sort(f); arr = arr.sort(f);
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
"sourceMap": true, "sourceMap": true,
"experimentalDecorators": true, "experimentalDecorators": true,
"emitDecoratorMetadata": true, "emitDecoratorMetadata": true,
"moduleResolution": "node" "moduleResolution": "node",
"noUnusedLocals": true
}, },
"files": [ "files": [
"src/util.ts", "src/util.ts",
......
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