[turbolizer] Enable even more tslint checks
- 'let' instead of 'var', and prefer 'const' - Prefer for-of over indexed interation - Variable names should be 'camel-case' or all-caps snake-case. - Only one variable declaration per line Change-Id: I645dd2333d6d9a993f24c29121f5f156249f1b71 Notry: true Bug: v8:7327 Reviewed-on: https://chromium-review.googlesource.com/c/1405320 Commit-Queue: Sigurd Schneider <sigurds@chromium.org> Reviewed-by: Georg Neis <neis@chromium.org> Cr-Commit-Position: refs/heads/master@{#58761}
This commit is contained in:
parent
45669e9bf1
commit
994dc1f249
@ -32,7 +32,7 @@ export class CodeView extends View {
|
|||||||
|
|
||||||
constructor(parent: HTMLElement, broker: SelectionBroker, sourceResolver: SourceResolver, sourceFunction: Source, codeMode: CodeMode) {
|
constructor(parent: HTMLElement, broker: SelectionBroker, sourceResolver: SourceResolver, sourceFunction: Source, codeMode: CodeMode) {
|
||||||
super(parent);
|
super(parent);
|
||||||
let view = this;
|
const view = this;
|
||||||
view.broker = broker;
|
view.broker = broker;
|
||||||
view.sourceResolver = sourceResolver;
|
view.sourceResolver = sourceResolver;
|
||||||
view.source = sourceFunction;
|
view.source = sourceFunction;
|
||||||
@ -48,7 +48,7 @@ export class CodeView extends View {
|
|||||||
},
|
},
|
||||||
select: function (sourcePositions, selected) {
|
select: function (sourcePositions, selected) {
|
||||||
const locations = [];
|
const locations = [];
|
||||||
for (var sourcePosition of sourcePositions) {
|
for (const sourcePosition of sourcePositions) {
|
||||||
locations.push(sourcePosition);
|
locations.push(sourcePosition);
|
||||||
sourceResolver.addInliningPositions(sourcePosition, locations);
|
sourceResolver.addInliningPositions(sourcePosition, locations);
|
||||||
}
|
}
|
||||||
@ -134,7 +134,7 @@ export class CodeView extends View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
initializeCode() {
|
initializeCode() {
|
||||||
var view = this;
|
const view = this;
|
||||||
const source = this.source;
|
const source = this.source;
|
||||||
const sourceText = source.sourceText;
|
const sourceText = source.sourceText;
|
||||||
if (!sourceText) return;
|
if (!sourceText) return;
|
||||||
@ -144,14 +144,14 @@ export class CodeView extends View {
|
|||||||
} else {
|
} else {
|
||||||
sourceContainer.classList.add("inlined-source");
|
sourceContainer.classList.add("inlined-source");
|
||||||
}
|
}
|
||||||
var codeHeader = document.createElement("div");
|
const codeHeader = document.createElement("div");
|
||||||
codeHeader.setAttribute("id", this.getCodeHeaderHtmlElementName());
|
codeHeader.setAttribute("id", this.getCodeHeaderHtmlElementName());
|
||||||
codeHeader.classList.add("code-header");
|
codeHeader.classList.add("code-header");
|
||||||
var codeFileFunction = document.createElement("div");
|
const codeFileFunction = document.createElement("div");
|
||||||
codeFileFunction.classList.add("code-file-function");
|
codeFileFunction.classList.add("code-file-function");
|
||||||
codeFileFunction.innerHTML = `${source.sourceName}:${source.functionName}`;
|
codeFileFunction.innerHTML = `${source.sourceName}:${source.functionName}`;
|
||||||
codeHeader.appendChild(codeFileFunction);
|
codeHeader.appendChild(codeFileFunction);
|
||||||
var codeModeDiv = document.createElement("div");
|
const codeModeDiv = document.createElement("div");
|
||||||
codeModeDiv.classList.add("code-mode");
|
codeModeDiv.classList.add("code-mode");
|
||||||
codeModeDiv.innerHTML = `${this.codeMode}`;
|
codeModeDiv.innerHTML = `${this.codeMode}`;
|
||||||
codeHeader.appendChild(codeModeDiv);
|
codeHeader.appendChild(codeModeDiv);
|
||||||
@ -159,7 +159,7 @@ export class CodeView extends View {
|
|||||||
clearDiv.style.clear = "both";
|
clearDiv.style.clear = "both";
|
||||||
codeHeader.appendChild(clearDiv);
|
codeHeader.appendChild(clearDiv);
|
||||||
sourceContainer.appendChild(codeHeader);
|
sourceContainer.appendChild(codeHeader);
|
||||||
var codePre = document.createElement("pre");
|
const codePre = document.createElement("pre");
|
||||||
codePre.setAttribute("id", this.getCodeHtmlElementName());
|
codePre.setAttribute("id", this.getCodeHtmlElementName());
|
||||||
codePre.classList.add("prettyprint");
|
codePre.classList.add("prettyprint");
|
||||||
sourceContainer.appendChild(codePre);
|
sourceContainer.appendChild(codePre);
|
||||||
@ -204,8 +204,7 @@ export class CodeView extends View {
|
|||||||
currentLineElement.id = "li" + i;
|
currentLineElement.id = "li" + i;
|
||||||
currentLineElement.dataset.lineNumber = "" + lineNumber;
|
currentLineElement.dataset.lineNumber = "" + lineNumber;
|
||||||
const spans = currentLineElement.childNodes;
|
const spans = currentLineElement.childNodes;
|
||||||
for (let j = 0; j < spans.length; ++j) {
|
for (const currentSpan of spans) {
|
||||||
const currentSpan = spans[j];
|
|
||||||
if (currentSpan instanceof HTMLSpanElement) {
|
if (currentSpan instanceof HTMLSpanElement) {
|
||||||
const pos = base + current;
|
const pos = base + current;
|
||||||
const end = pos + currentSpan.textContent.length;
|
const end = pos + currentSpan.textContent.length;
|
||||||
|
@ -41,8 +41,8 @@ export class DisassemblyView extends TextView {
|
|||||||
|
|
||||||
constructor(parentId, broker: SelectionBroker) {
|
constructor(parentId, broker: SelectionBroker) {
|
||||||
super(parentId, broker);
|
super(parentId, broker);
|
||||||
let view = this;
|
const view = this;
|
||||||
let ADDRESS_STYLE = {
|
const ADDRESS_STYLE = {
|
||||||
associateData: (text, fragment: HTMLElement) => {
|
associateData: (text, fragment: HTMLElement) => {
|
||||||
const matches = text.match(/(?<address>0?x?[0-9a-fA-F]{8,16})(?<addressSpace>\s+)(?<offset>[0-9a-f]+)(?<offsetSpace>\s*)/);
|
const matches = text.match(/(?<address>0?x?[0-9a-fA-F]{8,16})(?<addressSpace>\s+)(?<offset>[0-9a-f]+)(?<offsetSpace>\s*)/);
|
||||||
const offset = Number.parseInt(matches.groups["offset"], 16);
|
const offset = Number.parseInt(matches.groups["offset"], 16);
|
||||||
@ -65,16 +65,16 @@ export class DisassemblyView extends TextView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let UNCLASSIFIED_STYLE = {
|
const UNCLASSIFIED_STYLE = {
|
||||||
css: 'com'
|
css: 'com'
|
||||||
};
|
};
|
||||||
let NUMBER_STYLE = {
|
const NUMBER_STYLE = {
|
||||||
css: ['instruction-binary', 'lit']
|
css: ['instruction-binary', 'lit']
|
||||||
};
|
};
|
||||||
let COMMENT_STYLE = {
|
const COMMENT_STYLE = {
|
||||||
css: 'com'
|
css: 'com'
|
||||||
};
|
};
|
||||||
let OPCODE_ARGS = {
|
const OPCODE_ARGS = {
|
||||||
associateData: function (text, fragment) {
|
associateData: function (text, fragment) {
|
||||||
fragment.innerHTML = text;
|
fragment.innerHTML = text;
|
||||||
const replacer = (match, hexOffset) => {
|
const replacer = (match, hexOffset) => {
|
||||||
@ -86,12 +86,12 @@ export class DisassemblyView extends TextView {
|
|||||||
fragment.innerHTML = html;
|
fragment.innerHTML = html;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let OPCODE_STYLE = {
|
const OPCODE_STYLE = {
|
||||||
css: 'kwd'
|
css: 'kwd'
|
||||||
};
|
};
|
||||||
const BLOCK_HEADER_STYLE = {
|
const BLOCK_HEADER_STYLE = {
|
||||||
associateData: function (text, fragment) {
|
associateData: function (text, fragment) {
|
||||||
let matches = /\d+/.exec(text);
|
const matches = /\d+/.exec(text);
|
||||||
if (!matches) return;
|
if (!matches) return;
|
||||||
const blockId = matches[0];
|
const blockId = matches[0];
|
||||||
fragment.dataset.blockId = blockId;
|
fragment.dataset.blockId = blockId;
|
||||||
@ -103,7 +103,7 @@ export class DisassemblyView extends TextView {
|
|||||||
css: 'com'
|
css: 'com'
|
||||||
};
|
};
|
||||||
view.SOURCE_POSITION_HEADER_REGEX = /^\s*--[^<]*<.*(not inlined|inlined\((\d+)\)):(\d+)>\s*--/;
|
view.SOURCE_POSITION_HEADER_REGEX = /^\s*--[^<]*<.*(not inlined|inlined\((\d+)\)):(\d+)>\s*--/;
|
||||||
let patterns = [
|
const patterns = [
|
||||||
[
|
[
|
||||||
[/^0?x?[0-9a-fA-F]{8,16}\s+[0-9a-f]+\s+/, ADDRESS_STYLE, 1],
|
[/^0?x?[0-9a-fA-F]{8,16}\s+[0-9a-f]+\s+/, ADDRESS_STYLE, 1],
|
||||||
[view.SOURCE_POSITION_HEADER_REGEX, SOURCE_POSITION_HEADER_STYLE, -1],
|
[view.SOURCE_POSITION_HEADER_REGEX, SOURCE_POSITION_HEADER_STYLE, -1],
|
||||||
@ -223,7 +223,7 @@ export class DisassemblyView extends TextView {
|
|||||||
|
|
||||||
updateSelection(scrollIntoView: boolean = false) {
|
updateSelection(scrollIntoView: boolean = false) {
|
||||||
super.updateSelection(scrollIntoView);
|
super.updateSelection(scrollIntoView);
|
||||||
let keyPcOffsets = this.sourceResolver.nodesToKeyPcOffsets(this.selection.selectedKeys());
|
const keyPcOffsets = this.sourceResolver.nodesToKeyPcOffsets(this.selection.selectedKeys());
|
||||||
if (this.offsetSelection) {
|
if (this.offsetSelection) {
|
||||||
for (const key of this.offsetSelection.selectedKeys()) {
|
for (const key of this.offsetSelection.selectedKeys()) {
|
||||||
keyPcOffsets.push(Number(key));
|
keyPcOffsets.push(Number(key));
|
||||||
@ -238,7 +238,7 @@ export class DisassemblyView extends TextView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
initializeCode(sourceText, sourcePosition: number = 0) {
|
initializeCode(sourceText, sourcePosition: number = 0) {
|
||||||
let view = this;
|
const view = this;
|
||||||
view.addrEventCounts = null;
|
view.addrEventCounts = null;
|
||||||
view.totalEventCounts = null;
|
view.totalEventCounts = null;
|
||||||
view.maxEventCounts = null;
|
view.maxEventCounts = null;
|
||||||
@ -247,9 +247,9 @@ export class DisassemblyView extends TextView {
|
|||||||
// add sourcePosition for lines > 0.
|
// add sourcePosition for lines > 0.
|
||||||
view.posLines[0] = sourcePosition;
|
view.posLines[0] = sourcePosition;
|
||||||
if (sourceText && sourceText != "") {
|
if (sourceText && sourceText != "") {
|
||||||
let base = sourcePosition;
|
const base = sourcePosition;
|
||||||
let current = 0;
|
let current = 0;
|
||||||
let sourceLines = sourceText.split("\n");
|
const sourceLines = sourceText.split("\n");
|
||||||
for (let i = 1; i < sourceLines.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 += sourceLines[i - 1].length + 1;
|
current += sourceLines[i - 1].length + 1;
|
||||||
@ -259,16 +259,16 @@ export class DisassemblyView extends TextView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
initializePerfProfile(eventCounts) {
|
initializePerfProfile(eventCounts) {
|
||||||
let view = this;
|
const view = this;
|
||||||
if (eventCounts !== undefined) {
|
if (eventCounts !== undefined) {
|
||||||
view.addrEventCounts = eventCounts;
|
view.addrEventCounts = eventCounts;
|
||||||
|
|
||||||
view.totalEventCounts = {};
|
view.totalEventCounts = {};
|
||||||
view.maxEventCounts = {};
|
view.maxEventCounts = {};
|
||||||
for (let evName in view.addrEventCounts) {
|
for (const evName in view.addrEventCounts) {
|
||||||
if (view.addrEventCounts.hasOwnProperty(evName)) {
|
if (view.addrEventCounts.hasOwnProperty(evName)) {
|
||||||
let keys = Object.keys(view.addrEventCounts[evName]);
|
const keys = Object.keys(view.addrEventCounts[evName]);
|
||||||
let values = keys.map(key => view.addrEventCounts[evName][key]);
|
const values = keys.map(key => view.addrEventCounts[evName][key]);
|
||||||
view.totalEventCounts[evName] = values.reduce((a, b) => a + b);
|
view.totalEventCounts[evName] = values.reduce((a, b) => a + b);
|
||||||
view.maxEventCounts[evName] = values.reduce((a, b) => Math.max(a, b));
|
view.maxEventCounts[evName] = values.reduce((a, b) => Math.max(a, b));
|
||||||
}
|
}
|
||||||
@ -294,21 +294,21 @@ export class DisassemblyView extends TextView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
processLine(line) {
|
processLine(line) {
|
||||||
let view = this;
|
const view = this;
|
||||||
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.totalEventCounts) {
|
if (view.totalEventCounts) {
|
||||||
let matches = /^(0x[0-9a-fA-F]+)\s+\d+\s+[0-9a-fA-F]+/.exec(line);
|
const matches = /^(0x[0-9a-fA-F]+)\s+\d+\s+[0-9a-fA-F]+/.exec(line);
|
||||||
if (matches) {
|
if (matches) {
|
||||||
let newFragments = [];
|
const newFragments = [];
|
||||||
for (let event in view.addrEventCounts) {
|
for (const event in view.addrEventCounts) {
|
||||||
if (!view.addrEventCounts.hasOwnProperty(event)) continue;
|
if (!view.addrEventCounts.hasOwnProperty(event)) continue;
|
||||||
let count = view.addrEventCounts[event][matches[1]];
|
const count = view.addrEventCounts[event][matches[1]];
|
||||||
let str = " ";
|
let str = " ";
|
||||||
let cssCls = "prof";
|
const cssCls = "prof";
|
||||||
if (count !== undefined) {
|
if (count !== undefined) {
|
||||||
let perc = count / view.totalEventCounts[event] * 100;
|
const 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++) {
|
||||||
@ -316,11 +316,11 @@ export class DisassemblyView extends TextView {
|
|||||||
col = PROF_COLS[i].col;
|
col = PROF_COLS[i].col;
|
||||||
break;
|
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;
|
const col1 = PROF_COLS[i].col;
|
||||||
let col2 = PROF_COLS[i + 1].col;
|
const col2 = PROF_COLS[i + 1].col;
|
||||||
|
|
||||||
let val = perc - PROF_COLS[i].perc;
|
const val = perc - PROF_COLS[i].perc;
|
||||||
let max = PROF_COLS[i + 1].perc - PROF_COLS[i].perc;
|
const max = PROF_COLS[i + 1].perc - PROF_COLS[i].perc;
|
||||||
|
|
||||||
col.r = Math.round(interpolate(val, max, col1.r, col2.r));
|
col.r = Math.round(interpolate(val, max, col1.r, col2.r));
|
||||||
col.g = Math.round(interpolate(val, max, col1.g, col2.g));
|
col.g = Math.round(interpolate(val, max, col1.g, col2.g));
|
||||||
@ -331,7 +331,7 @@ export class DisassemblyView extends TextView {
|
|||||||
|
|
||||||
str = UNICODE_BLOCK;
|
str = UNICODE_BLOCK;
|
||||||
|
|
||||||
let fragment = view.createFragment(str, cssCls);
|
const 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 + ")";
|
||||||
|
|
||||||
|
@ -36,16 +36,16 @@ export class Edge {
|
|||||||
if (this.backEdgeNumber > 0) {
|
if (this.backEdgeNumber > 0) {
|
||||||
return graph.maxGraphNodeX + this.backEdgeNumber * MINIMUM_EDGE_SEPARATION;
|
return graph.maxGraphNodeX + this.backEdgeNumber * MINIMUM_EDGE_SEPARATION;
|
||||||
}
|
}
|
||||||
var source = this.source;
|
const source = this.source;
|
||||||
var target = this.target;
|
const target = this.target;
|
||||||
var index = this.index;
|
const index = this.index;
|
||||||
var inputX = target.x + target.getInputX(index);
|
const inputX = target.x + target.getInputX(index);
|
||||||
var inputApproach = target.getInputApproach(this.index);
|
const inputApproach = target.getInputApproach(this.index);
|
||||||
var outputApproach = source.getOutputApproach(showTypes);
|
const outputApproach = source.getOutputApproach(showTypes);
|
||||||
if (inputApproach > outputApproach) {
|
if (inputApproach > outputApproach) {
|
||||||
return inputX;
|
return inputX;
|
||||||
} else {
|
} else {
|
||||||
var inputOffset = MINIMUM_EDGE_SEPARATION * (index + 1);
|
const inputOffset = MINIMUM_EDGE_SEPARATION * (index + 1);
|
||||||
return (target.x < source.x)
|
return (target.x < source.x)
|
||||||
? (target.x + target.getTotalNodeWidth() + inputOffset)
|
? (target.x + target.getTotalNodeWidth() + inputOffset)
|
||||||
: (target.x - inputOffset);
|
: (target.x - inputOffset);
|
||||||
@ -53,18 +53,18 @@ export class Edge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
generatePath(graph: Graph, showTypes: boolean) {
|
generatePath(graph: Graph, showTypes: boolean) {
|
||||||
var target = this.target;
|
const target = this.target;
|
||||||
var source = this.source;
|
const source = this.source;
|
||||||
var inputX = target.x + target.getInputX(this.index);
|
const inputX = target.x + target.getInputX(this.index);
|
||||||
var arrowheadHeight = 7;
|
const arrowheadHeight = 7;
|
||||||
var inputY = target.y - 2 * DEFAULT_NODE_BUBBLE_RADIUS - arrowheadHeight;
|
const inputY = target.y - 2 * DEFAULT_NODE_BUBBLE_RADIUS - arrowheadHeight;
|
||||||
var outputX = source.x + source.getOutputX();
|
const outputX = source.x + source.getOutputX();
|
||||||
var outputY = source.y + source.getNodeHeight(showTypes) + DEFAULT_NODE_BUBBLE_RADIUS;
|
const outputY = source.y + source.getNodeHeight(showTypes) + DEFAULT_NODE_BUBBLE_RADIUS;
|
||||||
var inputApproach = target.getInputApproach(this.index);
|
let inputApproach = target.getInputApproach(this.index);
|
||||||
var outputApproach = source.getOutputApproach(showTypes);
|
const outputApproach = source.getOutputApproach(showTypes);
|
||||||
var horizontalPos = this.getInputHorizontalPosition(graph, showTypes);
|
const horizontalPos = this.getInputHorizontalPosition(graph, showTypes);
|
||||||
|
|
||||||
var result = "M" + outputX + "," + outputY +
|
let result = "M" + outputX + "," + outputY +
|
||||||
"L" + outputX + "," + outputApproach +
|
"L" + outputX + "," + outputApproach +
|
||||||
"L" + horizontalPos + "," + outputApproach;
|
"L" + horizontalPos + "," + outputApproach;
|
||||||
|
|
||||||
|
@ -141,10 +141,9 @@ function newGraphOccupation(graph: Graph) {
|
|||||||
let direction = -1;
|
let direction = -1;
|
||||||
let outputEdges = 0;
|
let outputEdges = 0;
|
||||||
let inputEdges = 0;
|
let inputEdges = 0;
|
||||||
for (let k = 0; k < n.outputs.length; ++k) {
|
for (const outputEdge of n.outputs) {
|
||||||
const outputEdge = n.outputs[k];
|
|
||||||
if (outputEdge.isVisible()) {
|
if (outputEdge.isVisible()) {
|
||||||
const output = n.outputs[k].target;
|
const output = outputEdge.target;
|
||||||
for (let l = 0; l < output.inputs.length; ++l) {
|
for (let l = 0; l < output.inputs.length; ++l) {
|
||||||
if (output.rank > n.rank) {
|
if (output.rank > n.rank) {
|
||||||
const inputEdge = output.inputs[l];
|
const inputEdge = output.inputs[l];
|
||||||
@ -202,8 +201,8 @@ function newGraphOccupation(graph: Graph) {
|
|||||||
source.outputs.forEach(function (edge) {
|
source.outputs.forEach(function (edge) {
|
||||||
if (edge.isVisible()) {
|
if (edge.isVisible()) {
|
||||||
const target = edge.target;
|
const target = edge.target;
|
||||||
for (let i = 0; i < target.inputs.length; ++i) {
|
for (const inputEdge of target.inputs) {
|
||||||
if (target.inputs[i].source === source) {
|
if (inputEdge.source === source) {
|
||||||
const horizontalPos = edge.getInputHorizontalPosition(graph, showTypes);
|
const horizontalPos = edge.getInputHorizontalPosition(graph, showTypes);
|
||||||
clearPositionRangeWithMargin(horizontalPos,
|
clearPositionRangeWithMargin(horizontalPos,
|
||||||
horizontalPos,
|
horizontalPos,
|
||||||
@ -332,8 +331,8 @@ export function layoutNodeGraph(graph: Graph, showTypes: boolean): void {
|
|||||||
const originalRank = n.rank;
|
const originalRank = n.rank;
|
||||||
let newRank = n.rank;
|
let newRank = n.rank;
|
||||||
let isFirstInput = true;
|
let isFirstInput = true;
|
||||||
for (let l = 0; l < n.outputs.length; ++l) {
|
for (const outputEdge of n.outputs) {
|
||||||
const output = n.outputs[l].target;
|
const output = outputEdge.target;
|
||||||
dfsFindRankLate(output);
|
dfsFindRankLate(output);
|
||||||
const outputRank = output.rank;
|
const outputRank = output.rank;
|
||||||
if (output.visible && (isFirstInput || outputRank <= newRank) &&
|
if (output.visible && (isFirstInput || outputRank <= newRank) &&
|
||||||
@ -353,10 +352,9 @@ export function layoutNodeGraph(graph: Graph, showTypes: boolean): void {
|
|||||||
function dfsRankOrder(n: GNode) {
|
function dfsRankOrder(n: GNode) {
|
||||||
if (visited[n.id]) return;
|
if (visited[n.id]) return;
|
||||||
visited[n.id] = true;
|
visited[n.id] = true;
|
||||||
for (let l = 0; l < n.outputs.length; ++l) {
|
for (const outputEdge of n.outputs) {
|
||||||
const edge = n.outputs[l];
|
if (outputEdge.isVisible()) {
|
||||||
if (edge.isVisible()) {
|
const output = outputEdge.target;
|
||||||
const output = edge.target;
|
|
||||||
dfsRankOrder(output);
|
dfsRankOrder(output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -391,8 +389,8 @@ export function layoutNodeGraph(graph: Graph, showTypes: boolean): void {
|
|||||||
|
|
||||||
rankSets.reverse().forEach(function (rankSet: Array<GNode>) {
|
rankSets.reverse().forEach(function (rankSet: Array<GNode>) {
|
||||||
|
|
||||||
for (let i = 0; i < rankSet.length; ++i) {
|
for (const node of rankSet) {
|
||||||
occupation.clearNodeOutputs(rankSet[i], showTypes);
|
occupation.clearNodeOutputs(node, showTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (traceLayout) {
|
if (traceLayout) {
|
||||||
@ -411,8 +409,7 @@ export function layoutNodeGraph(graph: Graph, showTypes: boolean): void {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
for (let i = 0; i < rankSet.length; ++i) {
|
for (const nodeToPlace of rankSet) {
|
||||||
const nodeToPlace = rankSet[i];
|
|
||||||
if (nodeToPlace.visible) {
|
if (nodeToPlace.visible) {
|
||||||
nodeToPlace.x = occupation.occupyNode(nodeToPlace);
|
nodeToPlace.x = occupation.occupyNode(nodeToPlace);
|
||||||
if (traceLayout) {
|
if (traceLayout) {
|
||||||
@ -438,8 +435,7 @@ export function layoutNodeGraph(graph: Graph, showTypes: boolean): void {
|
|||||||
occupation.print();
|
occupation.print();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < rankSet.length; ++i) {
|
for (const node of rankSet) {
|
||||||
const node = rankSet[i];
|
|
||||||
occupation.occupyNodeInputs(node, showTypes);
|
occupation.occupyNodeInputs(node, showTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ export class GraphView extends View implements PhaseView {
|
|||||||
view.updateGraphVisibility();
|
view.updateGraphVisibility();
|
||||||
},
|
},
|
||||||
select: function (nodes: Array<GNode>, selected: boolean) {
|
select: function (nodes: Array<GNode>, selected: boolean) {
|
||||||
let locations = [];
|
const locations = [];
|
||||||
for (const node of nodes) {
|
for (const node of nodes) {
|
||||||
if (node.nodeLabel.sourcePosition) {
|
if (node.nodeLabel.sourcePosition) {
|
||||||
locations.push(node.nodeLabel.sourcePosition);
|
locations.push(node.nodeLabel.sourcePosition);
|
||||||
@ -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 => {
|
const 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());
|
||||||
});
|
});
|
||||||
@ -177,10 +177,10 @@ export class GraphView extends View implements PhaseView {
|
|||||||
|
|
||||||
getEdgeFrontier(nodes: Iterable<GNode>, inEdges: boolean,
|
getEdgeFrontier(nodes: Iterable<GNode>, inEdges: boolean,
|
||||||
edgeFilter: (e: Edge, i: number) => boolean) {
|
edgeFilter: (e: Edge, i: number) => boolean) {
|
||||||
let frontier: Set<Edge> = new Set();
|
const frontier: Set<Edge> = new Set();
|
||||||
for (const n of nodes) {
|
for (const n of nodes) {
|
||||||
const edges = inEdges ? n.inputs : n.outputs;
|
const edges = inEdges ? n.inputs : n.outputs;
|
||||||
var edgeNumber = 0;
|
let edgeNumber = 0;
|
||||||
edges.forEach((edge: Edge) => {
|
edges.forEach((edge: Edge) => {
|
||||||
if (edgeFilter == undefined || edgeFilter(edge, edgeNumber)) {
|
if (edgeFilter == undefined || edgeFilter(edge, edgeNumber)) {
|
||||||
frontier.add(edge);
|
frontier.add(edge);
|
||||||
@ -470,7 +470,7 @@ export class GraphView extends View implements PhaseView {
|
|||||||
case 57:
|
case 57:
|
||||||
// '1'-'9'
|
// '1'-'9'
|
||||||
showSelectionFrontierNodes(true,
|
showSelectionFrontierNodes(true,
|
||||||
(edge: Edge, index: number) => { return index == (d3.event.keyCode - 49); },
|
(edge: Edge, index: number) => index == (d3.event.keyCode - 49),
|
||||||
!d3.event.ctrlKey);
|
!d3.event.ctrlKey);
|
||||||
break;
|
break;
|
||||||
case 97:
|
case 97:
|
||||||
@ -484,19 +484,19 @@ export class GraphView extends View implements PhaseView {
|
|||||||
case 105:
|
case 105:
|
||||||
// 'numpad 1'-'numpad 9'
|
// 'numpad 1'-'numpad 9'
|
||||||
showSelectionFrontierNodes(true,
|
showSelectionFrontierNodes(true,
|
||||||
(edge, index) => { return index == (d3.event.keyCode - 97); },
|
(edge, index) => index == (d3.event.keyCode - 97),
|
||||||
!d3.event.ctrlKey);
|
!d3.event.ctrlKey);
|
||||||
break;
|
break;
|
||||||
case 67:
|
case 67:
|
||||||
// 'c'
|
// 'c'
|
||||||
showSelectionFrontierNodes(d3.event.altKey,
|
showSelectionFrontierNodes(d3.event.altKey,
|
||||||
(edge, index) => { return edge.type == 'control'; },
|
(edge, index) => edge.type == 'control',
|
||||||
true);
|
true);
|
||||||
break;
|
break;
|
||||||
case 69:
|
case 69:
|
||||||
// 'e'
|
// 'e'
|
||||||
showSelectionFrontierNodes(d3.event.altKey,
|
showSelectionFrontierNodes(d3.event.altKey,
|
||||||
(edge, index) => { return edge.type == 'effect'; },
|
(edge, index) => edge.type == 'effect',
|
||||||
true);
|
true);
|
||||||
break;
|
break;
|
||||||
case 79:
|
case 79:
|
||||||
@ -638,8 +638,8 @@ export class GraphView extends View implements PhaseView {
|
|||||||
.classed("machine", function (n) { return n.isMachine(); })
|
.classed("machine", function (n) { return n.isMachine(); })
|
||||||
.on('mouseenter', function (node) {
|
.on('mouseenter', function (node) {
|
||||||
const visibleEdges = view.visibleEdges.selectAll<SVGPathElement, Edge>('path');
|
const visibleEdges = view.visibleEdges.selectAll<SVGPathElement, Edge>('path');
|
||||||
const adjInputEdges = visibleEdges.filter(e => { return e.target === node; });
|
const adjInputEdges = visibleEdges.filter(e => e.target === node);
|
||||||
const adjOutputEdges = visibleEdges.filter(e => { return e.source === node; });
|
const adjOutputEdges = visibleEdges.filter(e => e.source === node);
|
||||||
adjInputEdges.attr('relToHover', "input");
|
adjInputEdges.attr('relToHover', "input");
|
||||||
adjOutputEdges.attr('relToHover', "output");
|
adjOutputEdges.attr('relToHover', "output");
|
||||||
const adjInputNodes = adjInputEdges.data().map(e => e.source);
|
const adjInputNodes = adjInputEdges.data().map(e => e.source);
|
||||||
@ -651,7 +651,7 @@ export class GraphView extends View implements PhaseView {
|
|||||||
})
|
})
|
||||||
.on('mouseleave', function (node) {
|
.on('mouseleave', function (node) {
|
||||||
const visibleEdges = view.visibleEdges.selectAll<SVGPathElement, Edge>('path');
|
const visibleEdges = view.visibleEdges.selectAll<SVGPathElement, Edge>('path');
|
||||||
const adjEdges = visibleEdges.filter(e => { return e.target === node || e.source === node; });
|
const adjEdges = visibleEdges.filter(e => e.target === node || e.source === node);
|
||||||
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");
|
||||||
@ -821,10 +821,10 @@ export class GraphView extends View implements PhaseView {
|
|||||||
|
|
||||||
viewSelection() {
|
viewSelection() {
|
||||||
const view = this;
|
const view = this;
|
||||||
var minX;
|
let minX;
|
||||||
var maxX;
|
let maxX;
|
||||||
var minY;
|
let minY;
|
||||||
var maxY;
|
let 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)) {
|
||||||
|
@ -27,9 +27,9 @@ export class Graph {
|
|||||||
});
|
});
|
||||||
|
|
||||||
data.edges.forEach((e: any) => {
|
data.edges.forEach((e: any) => {
|
||||||
var t = this.nodeMap[e.target];
|
const t = this.nodeMap[e.target];
|
||||||
var s = this.nodeMap[e.source];
|
const s = this.nodeMap[e.source];
|
||||||
var newEdge = new Edge(t, e.index, s, e.type);
|
const newEdge = new Edge(t, e.index, s, e.type);
|
||||||
t.inputs.push(newEdge);
|
t.inputs.push(newEdge);
|
||||||
s.outputs.push(newEdge);
|
s.outputs.push(newEdge);
|
||||||
if (e.type == 'control') {
|
if (e.type == 'control') {
|
||||||
|
@ -85,7 +85,7 @@ export class GNode {
|
|||||||
this.isJavaScript() || this.isSimplified());
|
this.isJavaScript() || this.isSimplified());
|
||||||
}
|
}
|
||||||
getTotalNodeWidth() {
|
getTotalNodeWidth() {
|
||||||
var inputWidth = this.inputs.length * NODE_INPUT_WIDTH;
|
const inputWidth = this.inputs.length * NODE_INPUT_WIDTH;
|
||||||
return Math.max(inputWidth, this.width);
|
return Math.max(inputWidth, this.width);
|
||||||
}
|
}
|
||||||
getTitle() {
|
getTitle() {
|
||||||
@ -98,7 +98,7 @@ export class GNode {
|
|||||||
return this.nodeLabel.type;
|
return this.nodeLabel.type;
|
||||||
}
|
}
|
||||||
getDisplayType() {
|
getDisplayType() {
|
||||||
var typeString = this.nodeLabel.type;
|
let typeString = this.nodeLabel.type;
|
||||||
if (typeString == undefined) return "";
|
if (typeString == undefined) return "";
|
||||||
if (typeString.length > 24) {
|
if (typeString.length > 24) {
|
||||||
typeString = typeString.substr(0, 25) + "...";
|
typeString = typeString.substr(0, 25) + "...";
|
||||||
@ -106,7 +106,7 @@ export class GNode {
|
|||||||
return typeString;
|
return typeString;
|
||||||
}
|
}
|
||||||
deepestInputRank() {
|
deepestInputRank() {
|
||||||
var deepestRank = 0;
|
let deepestRank = 0;
|
||||||
this.inputs.forEach(function (e) {
|
this.inputs.forEach(function (e) {
|
||||||
if (e.isVisible() && !e.isBackEdge()) {
|
if (e.isVisible() && !e.isBackEdge()) {
|
||||||
if (e.source.rank > deepestRank) {
|
if (e.source.rank > deepestRank) {
|
||||||
@ -117,14 +117,14 @@ export class GNode {
|
|||||||
return deepestRank;
|
return deepestRank;
|
||||||
}
|
}
|
||||||
areAnyOutputsVisible() {
|
areAnyOutputsVisible() {
|
||||||
var visibleCount = 0;
|
let visibleCount = 0;
|
||||||
this.outputs.forEach(function (e) { if (e.isVisible())++visibleCount; });
|
this.outputs.forEach(function (e) { if (e.isVisible())++visibleCount; });
|
||||||
if (this.outputs.length == visibleCount) return 2;
|
if (this.outputs.length == visibleCount) return 2;
|
||||||
if (visibleCount != 0) return 1;
|
if (visibleCount != 0) return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
setOutputVisibility(v) {
|
setOutputVisibility(v) {
|
||||||
var result = false;
|
let result = false;
|
||||||
this.outputs.forEach(function (e) {
|
this.outputs.forEach(function (e) {
|
||||||
e.visible = v;
|
e.visible = v;
|
||||||
if (v) {
|
if (v) {
|
||||||
@ -137,7 +137,7 @@ export class GNode {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
setInputVisibility(i, v) {
|
setInputVisibility(i, v) {
|
||||||
var edge = this.inputs[i];
|
const edge = this.inputs[i];
|
||||||
edge.visible = v;
|
edge.visible = v;
|
||||||
if (v) {
|
if (v) {
|
||||||
if (!edge.source.visible) {
|
if (!edge.source.visible) {
|
||||||
@ -163,7 +163,7 @@ export class GNode {
|
|||||||
+ DEFAULT_NODE_BUBBLE_RADIUS;
|
+ DEFAULT_NODE_BUBBLE_RADIUS;
|
||||||
}
|
}
|
||||||
getInputX(index) {
|
getInputX(index) {
|
||||||
var result = this.getTotalNodeWidth() - (NODE_INPUT_WIDTH / 2) +
|
const result = this.getTotalNodeWidth() - (NODE_INPUT_WIDTH / 2) +
|
||||||
(index - this.inputs.length + 1) * NODE_INPUT_WIDTH;
|
(index - this.inputs.length + 1) * NODE_INPUT_WIDTH;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ class Snapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getLastExpandedState(type: string, defaultState: boolean): boolean {
|
getLastExpandedState(type: string, defaultState: boolean): boolean {
|
||||||
var state = window.sessionStorage.getItem("expandedState-" + type);
|
const state = window.sessionStorage.getItem("expandedState-" + type);
|
||||||
if (state === null) return defaultState;
|
if (state === null) return defaultState;
|
||||||
return state === 'true';
|
return state === 'true';
|
||||||
}
|
}
|
||||||
@ -102,7 +102,7 @@ export class Resizer {
|
|||||||
resizerLeft: d3.Selection<HTMLDivElement, any, any, any>;
|
resizerLeft: d3.Selection<HTMLDivElement, any, any, any>;
|
||||||
|
|
||||||
constructor(panesUpdatedCallback: () => void, deadWidth: number) {
|
constructor(panesUpdatedCallback: () => void, deadWidth: number) {
|
||||||
let resizer = this;
|
const resizer = this;
|
||||||
resizer.panesUpdatedCallback = panesUpdatedCallback;
|
resizer.panesUpdatedCallback = panesUpdatedCallback;
|
||||||
resizer.deadWidth = deadWidth;
|
resizer.deadWidth = deadWidth;
|
||||||
resizer.left = document.getElementById(C.SOURCE_PANE_ID);
|
resizer.left = document.getElementById(C.SOURCE_PANE_ID);
|
||||||
@ -116,15 +116,15 @@ export class Resizer {
|
|||||||
resizer.sepWidthOffset = 7;
|
resizer.sepWidthOffset = 7;
|
||||||
this.updateWidths();
|
this.updateWidths();
|
||||||
|
|
||||||
let dragResizeLeft = d3.drag()
|
const dragResizeLeft = d3.drag()
|
||||||
.on('drag', function () {
|
.on('drag', function () {
|
||||||
let x = d3.mouse(this.parentElement)[0];
|
const x = d3.mouse(this.parentElement)[0];
|
||||||
resizer.sepLeft = Math.min(Math.max(0, x), resizer.sepRight - resizer.sepWidthOffset);
|
resizer.sepLeft = Math.min(Math.max(0, x), resizer.sepRight - resizer.sepWidthOffset);
|
||||||
resizer.updatePanes();
|
resizer.updatePanes();
|
||||||
})
|
})
|
||||||
.on('start', function () {
|
.on('start', function () {
|
||||||
resizer.resizerLeft.classed("dragged", true);
|
resizer.resizerLeft.classed("dragged", true);
|
||||||
let x = d3.mouse(this.parentElement)[0];
|
const x = d3.mouse(this.parentElement)[0];
|
||||||
if (x > deadWidth) {
|
if (x > deadWidth) {
|
||||||
resizer.sepLeftSnap = resizer.sepLeft;
|
resizer.sepLeftSnap = resizer.sepLeft;
|
||||||
}
|
}
|
||||||
@ -137,15 +137,15 @@ export class Resizer {
|
|||||||
});
|
});
|
||||||
resizer.resizerLeft.call(dragResizeLeft);
|
resizer.resizerLeft.call(dragResizeLeft);
|
||||||
|
|
||||||
let dragResizeRight = d3.drag()
|
const dragResizeRight = d3.drag()
|
||||||
.on('drag', function () {
|
.on('drag', function () {
|
||||||
let x = d3.mouse(this.parentElement)[0];
|
const x = d3.mouse(this.parentElement)[0];
|
||||||
resizer.sepRight = Math.max(resizer.sepLeft + resizer.sepWidthOffset, Math.min(x, resizer.clientWidth));
|
resizer.sepRight = Math.max(resizer.sepLeft + resizer.sepWidthOffset, Math.min(x, resizer.clientWidth));
|
||||||
resizer.updatePanes();
|
resizer.updatePanes();
|
||||||
})
|
})
|
||||||
.on('start', function () {
|
.on('start', function () {
|
||||||
resizer.resizerRight.classed("dragged", true);
|
resizer.resizerRight.classed("dragged", true);
|
||||||
let x = d3.mouse(this.parentElement)[0];
|
const x = d3.mouse(this.parentElement)[0];
|
||||||
if (x < (resizer.clientWidth - deadWidth)) {
|
if (x < (resizer.clientWidth - deadWidth)) {
|
||||||
resizer.sepRightSnap = resizer.sepRight;
|
resizer.sepRightSnap = resizer.sepRight;
|
||||||
}
|
}
|
||||||
@ -175,8 +175,8 @@ export class Resizer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updatePanes() {
|
updatePanes() {
|
||||||
let leftSnapped = this.isLeftSnapped();
|
const leftSnapped = this.isLeftSnapped();
|
||||||
let rightSnapped = this.isRightSnapped();
|
const rightSnapped = this.isRightSnapped();
|
||||||
this.resizerLeft.classed("snapped", leftSnapped);
|
this.resizerLeft.classed("snapped", leftSnapped);
|
||||||
this.resizerRight.classed("snapped", rightSnapped);
|
this.resizerRight.classed("snapped", rightSnapped);
|
||||||
this.left.style.width = this.sepLeft + 'px';
|
this.left.style.width = this.sepLeft + 'px';
|
||||||
|
@ -44,7 +44,7 @@ export class ScheduleView extends TextView implements PhaseView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
createElementFromString(htmlString) {
|
createElementFromString(htmlString) {
|
||||||
var div = document.createElement('div');
|
const div = document.createElement('div');
|
||||||
div.innerHTML = htmlString.trim();
|
div.innerHTML = htmlString.trim();
|
||||||
return div.firstChild;
|
return div.firstChild;
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ export class SelectionBroker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
broadcastBlockSelect(from, blocks, selected) {
|
broadcastBlockSelect(from, blocks, selected) {
|
||||||
for (var b of this.blockHandlers) {
|
for (const b of this.blockHandlers) {
|
||||||
if (b != from) b.brokeredBlockSelect(blocks, selected);
|
if (b != from) b.brokeredBlockSelect(blocks, selected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,16 +42,16 @@ export class MySelection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
selectedKeys() {
|
selectedKeys() {
|
||||||
var result = new Set();
|
const result = new Set();
|
||||||
for (var i of this.selection.keys()) {
|
for (const i of this.selection.keys()) {
|
||||||
result.add(i);
|
result.add(i);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
detachSelection() {
|
detachSelection() {
|
||||||
var result = new Set();
|
const result = new Set();
|
||||||
for (var i of this.selection.keys()) {
|
for (const i of this.selection.keys()) {
|
||||||
result.add(i);
|
result.add(i);
|
||||||
}
|
}
|
||||||
this.clear();
|
this.clear();
|
||||||
|
@ -83,7 +83,7 @@ export class SequenceView extends TextView implements PhaseView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function elementForOperand(operand, searchInfo) {
|
function elementForOperand(operand, searchInfo) {
|
||||||
var text = operand.text;
|
const 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);
|
||||||
@ -137,7 +137,7 @@ export class SequenceView extends TextView implements PhaseView {
|
|||||||
instEl.appendChild(assignEl);
|
instEl.appendChild(assignEl);
|
||||||
}
|
}
|
||||||
|
|
||||||
var text = instruction.opcode + instruction.flags;
|
const text = instruction.opcode + instruction.flags;
|
||||||
const instLabel = createElement("div", "node-label", text);
|
const instLabel = createElement("div", "node-label", text);
|
||||||
searchInfo.push(text);
|
searchInfo.push(text);
|
||||||
view.addHtmlElementForNodeId(text, instLabel);
|
view.addHtmlElementForNodeId(text, instLabel);
|
||||||
|
@ -151,7 +151,7 @@ export class SourceResolver {
|
|||||||
|
|
||||||
setSources(sources, mainBackup) {
|
setSources(sources, mainBackup) {
|
||||||
if (sources) {
|
if (sources) {
|
||||||
for (let [sourceId, source] of Object.entries(sources)) {
|
for (const [sourceId, source] of Object.entries(sources)) {
|
||||||
this.sources[sourceId] = source;
|
this.sources[sourceId] = source;
|
||||||
this.sources[sourceId].sourcePositions = [];
|
this.sources[sourceId].sourcePositions = [];
|
||||||
}
|
}
|
||||||
@ -196,7 +196,7 @@ export class SourceResolver {
|
|||||||
this.sources[sourceId].sourcePositions.push(sourcePosition);
|
this.sources[sourceId].sourcePositions.push(sourcePosition);
|
||||||
}
|
}
|
||||||
this.nodePositionMap[nodeId] = sourcePosition;
|
this.nodePositionMap[nodeId] = sourcePosition;
|
||||||
let key = sourcePositionToStringKey(sourcePosition);
|
const key = sourcePositionToStringKey(sourcePosition);
|
||||||
if (!this.positionToNodes.has(key)) {
|
if (!this.positionToNodes.has(key)) {
|
||||||
this.positionToNodes.set(key, []);
|
this.positionToNodes.set(key, []);
|
||||||
}
|
}
|
||||||
@ -211,8 +211,8 @@ export class SourceResolver {
|
|||||||
sourcePositionsToNodeIds(sourcePositions) {
|
sourcePositionsToNodeIds(sourcePositions) {
|
||||||
const nodeIds = new Set();
|
const nodeIds = new Set();
|
||||||
for (const sp of sourcePositions) {
|
for (const sp of sourcePositions) {
|
||||||
let key = sourcePositionToStringKey(sp);
|
const key = sourcePositionToStringKey(sp);
|
||||||
let nodeIdsForPosition = this.positionToNodes.get(key);
|
const nodeIdsForPosition = this.positionToNodes.get(key);
|
||||||
if (!nodeIdsForPosition) continue;
|
if (!nodeIdsForPosition) continue;
|
||||||
for (const nodeId of nodeIdsForPosition) {
|
for (const nodeId of nodeIdsForPosition) {
|
||||||
nodeIds.add(nodeId);
|
nodeIds.add(nodeId);
|
||||||
@ -224,8 +224,8 @@ export class SourceResolver {
|
|||||||
nodeIdsToSourcePositions(nodeIds): Array<AnyPosition> {
|
nodeIdsToSourcePositions(nodeIds): Array<AnyPosition> {
|
||||||
const sourcePositions = new Map();
|
const sourcePositions = new Map();
|
||||||
for (const nodeId of nodeIds) {
|
for (const nodeId of nodeIds) {
|
||||||
let sp = this.nodePositionMap[nodeId];
|
const sp = this.nodePositionMap[nodeId];
|
||||||
let key = sourcePositionToStringKey(sp);
|
const key = sourcePositionToStringKey(sp);
|
||||||
sourcePositions.set(key, sp);
|
sourcePositions.set(key, sp);
|
||||||
}
|
}
|
||||||
const sourcePositionArray = [];
|
const sourcePositionArray = [];
|
||||||
@ -241,7 +241,7 @@ export class SourceResolver {
|
|||||||
|
|
||||||
translateToSourceId(sourceId: number, location?: SourcePosition) {
|
translateToSourceId(sourceId: number, location?: SourcePosition) {
|
||||||
for (const position of this.getInlineStack(location)) {
|
for (const position of this.getInlineStack(location)) {
|
||||||
let inlining = this.inlinings[position.inliningId];
|
const inlining = this.inlinings[position.inliningId];
|
||||||
if (!inlining) continue;
|
if (!inlining) continue;
|
||||||
if (inlining.sourceId == sourceId) {
|
if (inlining.sourceId == sourceId) {
|
||||||
return position;
|
return position;
|
||||||
@ -251,9 +251,9 @@ export class SourceResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addInliningPositions(sourcePosition: AnyPosition, locations: Array<SourcePosition>) {
|
addInliningPositions(sourcePosition: AnyPosition, locations: Array<SourcePosition>) {
|
||||||
let inlining = this.inliningsMap.get(sourcePositionToStringKey(sourcePosition));
|
const inlining = this.inliningsMap.get(sourcePositionToStringKey(sourcePosition));
|
||||||
if (!inlining) return;
|
if (!inlining) return;
|
||||||
let sourceId = inlining.sourceId;
|
const sourceId = inlining.sourceId;
|
||||||
const source = this.sources[sourceId];
|
const source = this.sources[sourceId];
|
||||||
for (const sp of source.sourcePositions) {
|
for (const sp of source.sourcePositions) {
|
||||||
locations.push(sp);
|
locations.push(sp);
|
||||||
@ -305,11 +305,11 @@ export class SourceResolver {
|
|||||||
getInlineStack(sourcePosition?: SourcePosition) {
|
getInlineStack(sourcePosition?: SourcePosition) {
|
||||||
if (!sourcePosition) return [];
|
if (!sourcePosition) return [];
|
||||||
|
|
||||||
let inliningStack = [];
|
const inliningStack = [];
|
||||||
let cur = sourcePosition;
|
let cur = sourcePosition;
|
||||||
while (cur && cur.inliningId != -1) {
|
while (cur && cur.inliningId != -1) {
|
||||||
inliningStack.push(cur);
|
inliningStack.push(cur);
|
||||||
let inlining = this.inlinings[cur.inliningId];
|
const inlining = this.inlinings[cur.inliningId];
|
||||||
if (!inlining) {
|
if (!inlining) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -329,7 +329,7 @@ export class SourceResolver {
|
|||||||
node.origin.bytecodePosition != undefined) {
|
node.origin.bytecodePosition != undefined) {
|
||||||
const position = { bytecodePosition: node.origin.bytecodePosition };
|
const position = { bytecodePosition: node.origin.bytecodePosition };
|
||||||
this.nodePositionMap[node.id] = position;
|
this.nodePositionMap[node.id] = position;
|
||||||
let key = sourcePositionToStringKey(position);
|
const key = sourcePositionToStringKey(position);
|
||||||
if (!this.positionToNodes.has(key)) {
|
if (!this.positionToNodes.has(key)) {
|
||||||
this.positionToNodes.set(key, []);
|
this.positionToNodes.set(key, []);
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ export abstract class TextView extends View {
|
|||||||
|
|
||||||
constructor(id, broker) {
|
constructor(id, broker) {
|
||||||
super(id);
|
super(id);
|
||||||
let view = this;
|
const view = this;
|
||||||
view.textListNode = view.divNode.getElementsByTagName('ul')[0];
|
view.textListNode = view.divNode.getElementsByTagName('ul')[0];
|
||||||
view.patterns = null;
|
view.patterns = null;
|
||||||
view.nodeIdToHtmlElementsMap = new Map();
|
view.nodeIdToHtmlElementsMap = new Map();
|
||||||
@ -161,14 +161,14 @@ export abstract class TextView extends View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
clearText() {
|
clearText() {
|
||||||
let view = this;
|
const view = this;
|
||||||
while (view.textListNode.firstChild) {
|
while (view.textListNode.firstChild) {
|
||||||
view.textListNode.removeChild(view.textListNode.firstChild);
|
view.textListNode.removeChild(view.textListNode.firstChild);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
createFragment(text, style) {
|
createFragment(text, style) {
|
||||||
let fragment = document.createElement("SPAN");
|
const fragment = document.createElement("SPAN");
|
||||||
|
|
||||||
if (typeof style.associateData == 'function') {
|
if (typeof style.associateData == 'function') {
|
||||||
style.associateData(text, fragment);
|
style.associateData(text, fragment);
|
||||||
@ -186,19 +186,19 @@ export abstract class TextView extends View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
processLine(line) {
|
processLine(line) {
|
||||||
let view = this;
|
const view = this;
|
||||||
let result = [];
|
const result = [];
|
||||||
let patternSet = 0;
|
let patternSet = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
let beforeLine = line;
|
const beforeLine = line;
|
||||||
for (let pattern of view.patterns[patternSet]) {
|
for (const pattern of view.patterns[patternSet]) {
|
||||||
let matches = line.match(pattern[0]);
|
const matches = line.match(pattern[0]);
|
||||||
if (matches != null) {
|
if (matches != null) {
|
||||||
if (matches[0] != '') {
|
if (matches[0] != '') {
|
||||||
let style = pattern[1] != null ? pattern[1] : {};
|
const style = pattern[1] != null ? pattern[1] : {};
|
||||||
let text = matches[0];
|
const text = matches[0];
|
||||||
if (text != '') {
|
if (text != '') {
|
||||||
let fragment = view.createFragment(matches[0], style);
|
const fragment = view.createFragment(matches[0], style);
|
||||||
result.push(fragment);
|
result.push(fragment);
|
||||||
}
|
}
|
||||||
line = line.substr(matches[0].length);
|
line = line.substr(matches[0].length);
|
||||||
@ -224,15 +224,15 @@ export abstract class TextView extends View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
processText(text) {
|
processText(text) {
|
||||||
let view = this;
|
const view = this;
|
||||||
let textLines = text.split(/[\n]/);
|
const textLines = text.split(/[\n]/);
|
||||||
let lineNo = 0;
|
let lineNo = 0;
|
||||||
for (let line of textLines) {
|
for (const line of textLines) {
|
||||||
let li = document.createElement("LI");
|
const li = document.createElement("LI");
|
||||||
li.className = "nolinenums";
|
li.className = "nolinenums";
|
||||||
li.dataset.lineNo = "" + lineNo++;
|
li.dataset.lineNo = "" + lineNo++;
|
||||||
let fragments = view.processLine(line);
|
const fragments = view.processLine(line);
|
||||||
for (let fragment of fragments) {
|
for (const fragment of fragments) {
|
||||||
li.appendChild(fragment);
|
li.appendChild(fragment);
|
||||||
}
|
}
|
||||||
view.textListNode.appendChild(li);
|
view.textListNode.appendChild(li);
|
||||||
@ -240,7 +240,7 @@ export abstract class TextView extends View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
initializeContent(data, rememberedSelection) {
|
initializeContent(data, rememberedSelection) {
|
||||||
let view = this;
|
const view = this;
|
||||||
view.clearText();
|
view.clearText();
|
||||||
view.processText(data);
|
view.processText(data);
|
||||||
}
|
}
|
||||||
|
@ -13,12 +13,12 @@ import { Resizer } from "../src/resizer";
|
|||||||
import * as C from "../src/constants";
|
import * as C from "../src/constants";
|
||||||
|
|
||||||
window.onload = function () {
|
window.onload = function () {
|
||||||
var multiview = null;
|
let multiview = null;
|
||||||
var disassemblyView = null;
|
let disassemblyView = null;
|
||||||
var sourceViews = [];
|
let sourceViews = [];
|
||||||
var selectionBroker = null;
|
let selectionBroker = null;
|
||||||
var sourceResolver = null;
|
let sourceResolver = null;
|
||||||
let resizer = new Resizer(panesUpdatedCallback, 100);
|
const resizer = new Resizer(panesUpdatedCallback, 100);
|
||||||
|
|
||||||
function panesUpdatedCallback() {
|
function panesUpdatedCallback() {
|
||||||
if (multiview) multiview.onresize();
|
if (multiview) multiview.onresize();
|
||||||
@ -68,12 +68,12 @@ window.onload = function () {
|
|||||||
sourceContainer.classList.add("viewpane", "scrollable");
|
sourceContainer.classList.add("viewpane", "scrollable");
|
||||||
sourceTabs.activateTab(sourceTab);
|
sourceTabs.activateTab(sourceTab);
|
||||||
sourceTabs.addTab("+").classList.add("open-tab");
|
sourceTabs.addTab("+").classList.add("open-tab");
|
||||||
let sourceView = new CodeView(sourceContainer, selectionBroker, sourceResolver, fnc, CodeMode.MAIN_SOURCE);
|
const sourceView = new CodeView(sourceContainer, selectionBroker, sourceResolver, fnc, CodeMode.MAIN_SOURCE);
|
||||||
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);
|
const sourceView = new CodeView(sourceContainer, selectionBroker, sourceResolver, source, CodeMode.INLINED_SOURCE);
|
||||||
sourceView.show(null, null);
|
sourceView.show(null, null);
|
||||||
sourceViews.push(sourceView);
|
sourceViews.push(sourceView);
|
||||||
});
|
});
|
||||||
|
@ -50,8 +50,8 @@ export class ViewElements {
|
|||||||
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);
|
||||||
let ret = [arr[0]];
|
const ret = [arr[0]];
|
||||||
for (var i = 1; i < arr.length; i++) {
|
for (let i = 1; i < arr.length; i++) {
|
||||||
if (!equal(arr[i - 1], arr[i])) {
|
if (!equal(arr[i - 1], arr[i])) {
|
||||||
ret.push(arr[i]);
|
ret.push(arr[i]);
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import { describe, it } from 'mocha';
|
|||||||
|
|
||||||
describe('SourceResolver', () => {
|
describe('SourceResolver', () => {
|
||||||
it('should be constructible', () => {
|
it('should be constructible', () => {
|
||||||
let a: SourceResolver = new SourceResolver();
|
const a: SourceResolver = new SourceResolver();
|
||||||
expect(a.sources.length).to.equal(0);
|
expect(a.sources.length).to.equal(0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
"curly": [true, "ignore-same-line"],
|
"curly": [true, "ignore-same-line"],
|
||||||
"quotemark": [false, "double", "avoid-escape", "avoid-template"],
|
"quotemark": [false, "double", "avoid-escape", "avoid-template"],
|
||||||
"only-arrow-functions": [false],
|
"only-arrow-functions": [false],
|
||||||
"no-var-keyword": false,
|
"no-var-keyword": true,
|
||||||
"prefer-const": [false],
|
"prefer-const": [true],
|
||||||
"max-line-length": [false, {
|
"max-line-length": [false, {
|
||||||
"limit": 80
|
"limit": 80
|
||||||
}],
|
}],
|
||||||
@ -32,13 +32,13 @@
|
|||||||
"interface-name": false,
|
"interface-name": false,
|
||||||
"no-bitwise": false,
|
"no-bitwise": false,
|
||||||
"no-shadowed-variable": false,
|
"no-shadowed-variable": false,
|
||||||
"prefer-for-of": false,
|
"prefer-for-of": true,
|
||||||
"align": false,
|
"align": true,
|
||||||
"arrow-return-shorthand": false,
|
"arrow-return-shorthand": true,
|
||||||
"max-classes-per-file": false,
|
"max-classes-per-file": false,
|
||||||
"variable-name": false,
|
"variable-name": true,
|
||||||
"forin": false,
|
"forin": false,
|
||||||
"one-variable-per-declaration": false,
|
"one-variable-per-declaration": true,
|
||||||
"no-consecutive-blank-lines": true
|
"no-consecutive-blank-lines": true
|
||||||
},
|
},
|
||||||
"rulesDirectory": []
|
"rulesDirectory": []
|
||||||
|
Loading…
Reference in New Issue
Block a user