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
import { SelectionBroker } from "../src/selection-broker"
import { View } from "../src/view"
import { MySelection } from "../src/selection"
import { anyToString, ViewElements } from "../src/util"
import { ViewElements } from "../src/util"
import { SelectionHandler } from "./selection-handler";
export enum CodeMode {
......@@ -118,7 +118,6 @@ export class CodeView extends View {
}
onSelectLine(lineNumber: number, doClear: boolean) {
const key = anyToString(lineNumber);
if (doClear) {
this.selectionHandler.clear();
}
......
......@@ -5,7 +5,6 @@
import { PROF_COLS, UNICODE_BLOCK } from "../src/constants"
import { SelectionBroker } from "../src/selection-broker"
import { TextView } from "../src/text-view"
import { SourceResolver } from "./source-resolver";
import { MySelection } from "./selection";
import { anyToString, interpolate } from "./util";
import { InstructionSelectionHandler } from "./selection-handler";
......@@ -139,7 +138,7 @@ export class DisassemblyView extends TextView {
const offset = e.target.dataset.pcOffset ? e.target.dataset.pcOffset : e.target.parentElement.dataset.pcOffset;
if ((typeof offset) != "undefined" && !Number.isNaN(Number(offset))) {
view.offsetSelection.select([offset], true);
const [nodes, blockId] = view.sourceResolver.nodesForPCOffset(offset)
const nodes = view.sourceResolver.nodesForPCOffset(offset)[0]
if (nodes.length > 0) {
e.stopPropagation();
if (!e.shiftKey) {
......@@ -210,7 +209,7 @@ export class DisassemblyView extends TextView {
const instructionBinaryInput: HTMLInputElement = view.divNode.querySelector("#show-instruction-binary");
const lastShowInstructionBinary = window.sessionStorage.getItem("show-instruction-binary");
instructionBinaryInput.checked = lastShowInstructionAddress == 'true';
instructionBinaryInput.checked = lastShowInstructionBinary == 'true';
const showInstructionBinaryHandler = () => {
window.sessionStorage.setItem("show-instruction-binary", `${instructionBinaryInput.checked}`);
for (const el of view.divNode.querySelectorAll(".instruction-binary")) {
......
......@@ -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) {
return Math.floor(pos / NODE_INPUT_WIDTH);
}
......@@ -43,10 +35,6 @@ function newGraphOccupation(graph:Graph) {
return slot * NODE_INPUT_WIDTH
}
function slotToRightPosition(slot) {
return (slot + 1) * NODE_INPUT_WIDTH
}
function findSpace(pos, width, direction) {
var widthSlots = Math.floor((width + NODE_INPUT_WIDTH - 1) /
NODE_INPUT_WIDTH);
......
......@@ -314,7 +314,6 @@ export class GraphView extends View implements PhaseView {
}).classed("halfFilledBubbleStyle", function (c) {
const components = this.id.split(',');
if (components[0] == "ib") {
const edge = g.nodeMap[components[3]].inputs[components[2]];
return false;
} else {
return g.nodeMap[components[1]].areAnyOutputsVisible() == 1;
......@@ -672,11 +671,9 @@ export class GraphView extends View implements PhaseView {
adjOutputEdges.attr('relToHover', "output");
const adjInputNodes = adjInputEdges.data().map(e => e.source);
const visibleNodes = view.visibleNodes.selectAll<SVGGElement, GNode>("g");
const input = visibleNodes.data<GNode>(adjInputNodes, nodeToStr)
.attr('relToHover', "input");
visibleNodes.data<GNode>(adjInputNodes, nodeToStr).attr('relToHover', "input");
const adjOutputNodes = adjOutputEdges.data().map(e => e.target);
const output = visibleNodes.data<GNode>(adjOutputNodes, nodeToStr)
.attr('relToHover', "output");
visibleNodes.data<GNode>(adjOutputNodes, nodeToStr).attr('relToHover', "output");
view.updateGraphVisibility();
})
.on('mouseleave', function (node) {
......@@ -685,8 +682,7 @@ export class GraphView extends View implements PhaseView {
adjEdges.attr('relToHover', "none");
const adjNodes = adjEdges.data().map(e => e.target).concat(adjEdges.data().map(e => e.source));
const visibleNodes = view.visibleNodes.selectAll<SVGPathElement, GNode>("g");
const nodes = visibleNodes.data(adjNodes, nodeToStr)
.attr('relToHover', "none");
visibleNodes.data(adjNodes, nodeToStr).attr('relToHover', "none");
view.updateGraphVisibility();
})
.on("click", (d) => {
......@@ -880,7 +876,6 @@ export class GraphView extends View implements PhaseView {
const x = (minX + maxX) / 2;
const y = (minY + maxY) / 2;
const scale = Math.min(width / (1.1 * dx), height / (1.1 * dy));
const transform = d3.zoomIdentity.translate(1500, 100).scale(0.75);
this.svg
.transition().duration(300).call(this.panZoom.translateTo, x, y)
.transition().duration(300).call(this.panZoom.scaleTo, scale)
......
......@@ -3,7 +3,6 @@
// found in the LICENSE file.
import {Schedule,SourceResolver} from "../src/source-resolver"
import {isIterable} from "../src/util"
import {PhaseView} from "../src/view"
import {TextView} from "../src/text-view"
......
......@@ -49,7 +49,6 @@ export class SelectionBroker {
}
broadcastSourcePositionSelect(from, sourcePositions, selected) {
let broker = this;
sourcePositions = sourcePositions.filter((l) => {
if (!sourcePositionValid(l)) {
console.log("Warning: invalid source position");
......@@ -67,7 +66,6 @@ export class SelectionBroker {
}
broadcastNodeSelect(from, nodes, selected) {
let broker = this;
for (const b of this.nodeHandlers) {
if (b != from) b.brokeredNodeSelect(nodes, selected);
}
......@@ -78,7 +76,6 @@ export class SelectionBroker {
}
broadcastBlockSelect(from, blocks, selected) {
let broker = this;
for (var b of this.blockHandlers) {
if (b != from) b.brokeredBlockSelect(blocks, selected);
}
......
......@@ -6,7 +6,6 @@ import {Sequence} from "../src/source-resolver"
import {isIterable} from "../src/util"
import {PhaseView} from "../src/view"
import {TextView} from "../src/text-view"
import { MySelection } from "./selection";
export class SequenceView extends TextView implements PhaseView {
sequence: Sequence;
......
......@@ -48,9 +48,9 @@ interface BytecodePosition {
bytecodePosition: number;
}
type Origin = NodeOrigin | BytecodePosition;
type TurboFanNodeOrigin = NodeOrigin & TurboFanOrigin;
type TurboFanBytecodeOrigin = BytecodePosition & TurboFanOrigin;
export type Origin = NodeOrigin | BytecodePosition;
export type TurboFanNodeOrigin = NodeOrigin & TurboFanOrigin;
export type TurboFanBytecodeOrigin = BytecodePosition & TurboFanOrigin;
type AnyPosition = SourcePosition | BytecodePosition;
......@@ -199,7 +199,7 @@ export class SourceResolver {
}
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,
sourcePositionLe, sourcePositionEq);
}
......@@ -435,7 +435,7 @@ export class SourceResolver {
}
parsePhases(phases) {
for (const [phaseId, phase] of Object.entries<Phase>(phases)) {
for (const [, phase] of Object.entries<Phase>(phases)) {
switch (phase.type) {
case 'disassembly':
this.disassemblyPhase = phase;
......
......@@ -168,7 +168,6 @@ export abstract class TextView extends View {
}
createFragment(text, style) {
let view = this;
let fragment = document.createElement("SPAN");
if (typeof style.associateData == 'function') {
......
......@@ -197,7 +197,6 @@ class Resizer {
}
window.onload = function () {
var svg = null;
var multiview = null;
var disassemblyView = null;
var sourceViews = [];
......
......@@ -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) {
if (arr.length == 0) return arr;
arr = arr.sort(f);
......
......@@ -7,7 +7,8 @@
"sourceMap": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"moduleResolution": "node"
"moduleResolution": "node",
"noUnusedLocals": true
},
"files": [
"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