Commit 76c377a3 authored by Sigurd Schneider's avatar Sigurd Schneider Committed by Commit Bot

[turbolizer] Format turbolizer source

Change-Id: Iffd68156515948254e4ce38021c511596acc5788
Notry: true
Bug: v8:7327
Reviewed-on: https://chromium-review.googlesource.com/c/1400849
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58681}
parent 99749a74
This diff is collapsed.
......@@ -17,7 +17,8 @@
"d3": "^5.7.0",
"rollup": "^0.68.2",
"rollup-plugin-node-resolve": "^4.0.0",
"rollup-plugin-typescript2": "^0.18.1"
"rollup-plugin-typescript2": "^0.18.1",
"tslint": "^5.12.0"
},
"repository": {
"type": "git",
......@@ -25,10 +26,10 @@
},
"devDependencies": {
"chai": "^4.2.0",
"local-web-server": "^2.6.0",
"mocha": "^5.2.0",
"ts-mocha": "^2.0.0",
"typescript": "^3.2.2",
"typescript-formatter": "^7.2.2",
"local-web-server": "^2.6.0"
"typescript-formatter": "^7.2.2"
}
}
......@@ -136,7 +136,7 @@ export class DisassemblyView extends TextView {
const linkHandler = (e: MouseEvent) => {
if (!(e.target instanceof HTMLElement)) return;
const offsetAsString = e.target.dataset.pcOffset ? e.target.dataset.pcOffset : e.target.parentElement.dataset.pcOffset;
const offset = Number.parseInt(offsetAsString);
const offset = Number.parseInt(offsetAsString, 10);
if ((typeof offsetAsString) != "undefined" && !Number.isNaN(offset)) {
view.offsetSelection.select([offset], true);
const nodes = view.sourceResolver.nodesForPCOffset(offset)[0]
......@@ -271,8 +271,7 @@ export class DisassemblyView extends TextView {
view.total_event_counts[ev_name] = values.reduce((a, b) => a + b);
view.max_event_counts[ev_name] = values.reduce((a, b) => Math.max(a, b));
}
}
else {
} else {
view.addr_event_counts = null;
view.total_event_counts = null;
view.max_event_counts = null;
......@@ -313,8 +312,7 @@ export class DisassemblyView extends TextView {
if (perc === PROF_COLS[i].perc) {
col = PROF_COLS[i].col;
break;
}
else if (perc > PROF_COLS[i].perc && perc < PROF_COLS[i + 1].perc) {
} else if (perc > PROF_COLS[i].perc && perc < PROF_COLS[i + 1].perc) {
let col1 = PROF_COLS[i].col;
let col2 = PROF_COLS[i + 1].col;
......@@ -335,10 +333,9 @@ export class DisassemblyView extends TextView {
fragment.style.color = "rgb(" + col.r + ", " + col.g + ", " + col.b + ")";
newFragments.push(fragment);
}
else
} else {
newFragments.push(view.createFragment(str, css_cls));
}
}
fragments = newFragments.concat(fragments);
}
......
......@@ -11,7 +11,7 @@ export class Edge {
target: GNode;
source: GNode;
index: number;
type: String;
type: string;
backEdgeNumber: number;
visible: boolean;
......@@ -24,7 +24,6 @@ export class Edge {
this.visible = false;
}
stringID() {
return this.source.id + "," + this.index + "," + this.target.id;
};
......
......@@ -2,13 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import { MAX_RANK_SENTINEL } from "../src/constants"
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 { Graph } from "./graph";
const DEFAULT_NODE_ROW_SEPARATION = 130
const traceLayout = false;
......
......@@ -232,7 +232,6 @@ export class GraphView extends View implements PhaseView {
this.createGraph(data, rememberedSelection);
this.broker.addNodeHandler(this.selectionHandler);
if (rememberedSelection != null) {
this.attachSelection(rememberedSelection);
this.connectVisibleSelectedNodes();
......
......@@ -71,7 +71,7 @@ export class GraphMultiView extends View {
(phaseName) => view.displayPhaseByName(phaseName));
this.schedule = new ScheduleView(this.divNode, selectionBroker);
this.sequence = new SequenceView(this.divNode, selectionBroker);
this.selectMenu = (<HTMLSelectElement>toolbox.querySelector('#display-selector'));
this.selectMenu = toolbox.querySelector('#display-selector') as HTMLSelectElement;
}
initializeSelect() {
......
......@@ -3,76 +3,76 @@
// found in the LICENSE file.
function formatOrigin(origin) {
if (origin.nodeId) {
return `#${origin.nodeId} in phase ${origin.phase}/${origin.reducer}`;
}
if (origin.bytecodePosition) {
return `Bytecode line ${origin.bytecodePosition} in phase ${origin.phase}/${origin.reducer}`;
}
return "unknown origin";
if (origin.nodeId) {
return `#${origin.nodeId} in phase ${origin.phase}/${origin.reducer}`;
}
if (origin.bytecodePosition) {
return `Bytecode line ${origin.bytecodePosition} in phase ${origin.phase}/${origin.reducer}`;
}
return "unknown origin";
}
export class NodeLabel {
id: number;
label: string;
title: string;
live: boolean;
properties: string;
sourcePosition: any;
origin: any;
opcode: string;
control: boolean;
opinfo: string;
type: string;
id: number;
label: string;
title: string;
live: boolean;
properties: string;
sourcePosition: any;
origin: any;
opcode: string;
control: boolean;
opinfo: string;
type: string;
constructor(id: number, label: string, title: string, live: boolean, properties: string, sourcePosition: any, origin: any, opcode: string, control: boolean, opinfo: string, type: string) {
this.id = id;
this.label = label;
this.title = title;
this.live = live;
this.properties = properties;
this.sourcePosition = sourcePosition;
this.origin = origin;
this.opcode = opcode;
this.control = control;
this.opinfo = opinfo;
this.type = type;
}
constructor(id: number, label: string, title: string, live: boolean, properties: string, sourcePosition: any, origin: any, opcode: string, control: boolean, opinfo: string, type: string) {
this.id = id;
this.label = label;
this.title = title;
this.live = live;
this.properties = properties;
this.sourcePosition = sourcePosition;
this.origin = origin;
this.opcode = opcode;
this.control = control;
this.opinfo = opinfo;
this.type = type;
}
equals(that?: NodeLabel) {
if (!that) return false;
if (this.id != that.id) return false;
if (this.label != that.label) return false;
if (this.title != that.title) return false;
if (this.live != that.live) return false;
if (this.properties != that.properties) return false;
if (this.opcode != that.opcode) return false;
if (this.control != that.control) return false;
if (this.opinfo != that.opinfo) return false;
if (this.type != that.type) return false;
return true;
}
equals(that?: NodeLabel) {
if (!that) return false;
if (this.id != that.id) return false;
if (this.label != that.label) return false;
if (this.title != that.title) return false;
if (this.live != that.live) return false;
if (this.properties != that.properties) return false;
if (this.opcode != that.opcode) return false;
if (this.control != that.control) return false;
if (this.opinfo != that.opinfo) return false;
if (this.type != that.type) return false;
return true;
}
getTitle() {
let propsString = "";
if (this.properties === "") {
propsString = "no properties";
} else {
propsString = "[" + this.properties + "]";
}
let title = this.title + "\n" + propsString + "\n" + this.opinfo;
if (this.origin) {
title += `\nOrigin: ${formatOrigin(this.origin)}`;
}
return title;
getTitle() {
let propsString = "";
if (this.properties === "") {
propsString = "no properties";
} else {
propsString = "[" + this.properties + "]";
}
let title = this.title + "\n" + propsString + "\n" + this.opinfo;
if (this.origin) {
title += `\nOrigin: ${formatOrigin(this.origin)}`;
}
return title;
}
getDisplayLabel() {
const result = `${this.id}: ${this.label}`;
if (result.length > 40) {
return `${this.id}: ${this.opcode}`;
}
return result;
getDisplayLabel() {
const result = `${this.id}: ${this.label}`;
if (result.length > 40) {
return `${this.id}: ${this.opcode}`;
}
return result;
}
}
\ No newline at end of file
}
......@@ -156,7 +156,7 @@ export class Resizer {
window.sessionStorage.setItem("disassembly-pane-width", `${resizer.sep_right / resizer.client_width}`);
}
resizer.resizer_right.classed("dragged", false);
});;
});
resizer.resizer_right.call(dragResizeRight);
window.onresize = function () {
resizer.updateWidths();
......
......@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import {Schedule,SourceResolver} from "../src/source-resolver"
import {PhaseView} from "../src/view"
import {TextView} from "../src/text-view"
import { Schedule, SourceResolver } from "../src/source-resolver"
import { PhaseView } from "../src/view"
import { TextView } from "../src/text-view"
export class ScheduleView extends TextView implements PhaseView {
schedule: Schedule;
......@@ -71,13 +71,13 @@ export class ScheduleView extends TextView implements PhaseView {
function getMarker(start, end) {
if (start != end) {
return ["&#8857;", `This node generated instructions in range [${start},${end}). ` +
`This is currently unreliable for constants.`];
`This is currently unreliable for constants.`];
}
if (start != -1) {
return ["&#183;", `The instruction selector did not generate instructions ` +
`for this node, but processed the node at instruction ${start}. ` +
`This usually means that this node was folded into another node; ` +
`the highlighted machine code is a guess.`];
`for this node, but processed the node at instruction ${start}. ` +
`This usually means that this node was folded into another node; ` +
`the highlighted machine code is a guess.`];
}
return ["", `This not is not in the final schedule.`]
}
......@@ -92,7 +92,6 @@ export class ScheduleView extends TextView implements PhaseView {
instrMarker.onclick = mkNodeLinkHandler(node.id);
nodeEl.appendChild(instrMarker);
const node_id = createElement("div", "node-id tag clickable", node.id);
node_id.onclick = mkNodeLinkHandler(node.id);
view.addHtmlElementForNodeId(node.id, node_id);
......
......@@ -33,7 +33,7 @@ export class MySelection {
}
}
isSelected(i:any): boolean {
isSelected(i: any): boolean {
return this.selection.has(this.stringKey(i));
}
......
......@@ -40,7 +40,7 @@ export class SequenceView extends TextView implements PhaseView {
this.divNode.innerHTML = '';
this.sequence = data.sequence;
this.search_info = [];
this.divNode.addEventListener('click', (e:MouseEvent) => {
this.divNode.addEventListener('click', (e: MouseEvent) => {
if (!(e.target instanceof HTMLElement)) return;
const instructionId = Number.parseInt(e.target.dataset.instructionId, 10);
if (!instructionId) return;
......
......@@ -19,10 +19,12 @@ function sourcePositionEq(a, b) {
export function sourcePositionToStringKey(sourcePosition: AnyPosition): string {
if (!sourcePosition) return "undefined";
if ('inliningId' in sourcePosition && 'scriptOffset' in sourcePosition)
if ('inliningId' in sourcePosition && 'scriptOffset' in sourcePosition) {
return "SP:" + sourcePosition.inliningId + ":" + sourcePosition.scriptOffset;
if (sourcePosition.bytecodePosition)
}
if (sourcePosition.bytecodePosition) {
return "BCP:" + sourcePosition.bytecodePosition;
}
return "undefined";
}
......@@ -117,7 +119,6 @@ export class SourceResolver {
pcOffsetToInstructions: Map<number, Array<number>>;
pcOffsets: Array<number>;
constructor() {
// Maps node ids to source positions.
this.nodePositionMap = [];
......@@ -416,7 +417,7 @@ export class SourceResolver {
return offsets;
}
nodesForPCOffset(offset: number): [Array<String>, Array<String>] {
nodesForPCOffset(offset: number): [Array<string>, Array<string>] {
if (this.pcOffsets.length === 0) return [[], []];
for (const key of this.pcOffsets) {
if (key <= offset) {
......@@ -510,7 +511,7 @@ export class SourceResolver {
this.phases.forEach(f);
}
addAnyPositionToLine(lineNumber: number | String, sourcePosition: AnyPosition) {
addAnyPositionToLine(lineNumber: number | string, sourcePosition: AnyPosition) {
const lineNumberString = anyToString(lineNumber);
if (!this.lineToSourcePositions.has(lineNumberString)) {
this.lineToSourcePositions.set(lineNumberString, []);
......@@ -526,7 +527,7 @@ export class SourceResolver {
});
}
linetoSourcePositions(lineNumber: number | String) {
linetoSourcePositions(lineNumber: number | string) {
const positions = this.lineToSourcePositions.get(anyToString(lineNumber));
if (positions === undefined) return [];
return positions;
......
......@@ -114,8 +114,9 @@ window.onload = function () {
const filereader = new FileReader();
filereader.onload = () => {
const txtRes = filereader.result;
if (typeof txtRes == 'string')
if (typeof txtRes == 'string') {
loadFile(txtRes);
}
};
filereader.readAsText(uploadFile);
}
......
import {SourceResolver} from '../src/source-resolver';
import {expect} from 'chai';
import {describe, it} from 'mocha';
import { SourceResolver } from '../src/source-resolver';
import { expect } from 'chai';
import { describe, it } from 'mocha';
describe('SourceResolver', () => {
it('should be constructible', () => {
let a:SourceResolver = new SourceResolver();
let a: SourceResolver = new SourceResolver();
expect(a.sources.length).to.equal(0);
});
});
{
"defaultSeverity": "error",
"extends": "tslint:recommended",
"jsRules": {},
"rules": {
"curly": [true, "ignore-same-line"],
"quotemark": [false, "double", "avoid-escape", "avoid-template"],
"only-arrow-functions": [false],
"no-var-keyword": false,
"prefer-const": [false],
"max-line-length": [false, {
"limit": 80
}],
"ordered-imports": false,
"array-type": [false, "generic"],
"semicolon": false,
"member-access": false,
"object-literal-shorthand": false,
"object-literal-key-quotes": [true, "as-needed"],
"object-literal-sort-keys": false,
"space-before-function-paren": [true, {
"anonymous": "always"
}],
"triple-equals": false,
"no-string-throw": false,
"no-empty": [true, "allow-empty-catch", "allow-empty-functions"],
"trailing-comma": false,
"member-ordering": false,
"no-string-literal": false,
"arrow-parens": false,
"no-console": false,
"interface-name": false,
"no-bitwise": false,
"no-shadowed-variable": false,
"prefer-for-of": false,
"align": false,
"arrow-return-shorthand": false,
"max-classes-per-file": false,
"variable-name": false,
"forin": false,
"one-variable-per-declaration": false,
"no-consecutive-blank-lines": true
},
"rulesDirectory": []
}
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