Commit d5d45c61 authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[tools] Migrate more tools to ES6 classes

For simplicity this CL includes a first crude conversion of
tickprocessor.mjs. Later CLs will introduce more ES6 syntax and clean
up more code.

Bug: v8:10667
Change-Id: Ief2ca623f5562114fb976a95d156e2ab3f961114
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2611252Reviewed-by: 's avatarSathya Gunasekaran  <gsathya@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72013}
parent 73875e95
...@@ -36,49 +36,47 @@ ...@@ -36,49 +36,47 @@
* *
* @constructor * @constructor
*/ */
export function ConsArray() { export class ConsArray {
this.tail_ = new ConsArray.Cell(null, null); constructor() {
this.currCell_ = this.tail_; this.tail_ = new ConsArrayCell(null, null);
this.currCellPos_ = 0; this.currCell_ = this.tail_;
}; this.currCellPos_ = 0;
}
/**
/** * Concatenates another array for iterating. Empty arrays are ignored.
* Concatenates another array for iterating. Empty arrays are ignored. * This operation can be safely performed during ongoing ConsArray
* This operation can be safely performed during ongoing ConsArray * iteration.
* iteration. *
* * @param {Array} arr Array to concatenate.
* @param {Array} arr Array to concatenate. */
*/ concat(arr) {
ConsArray.prototype.concat = function(arr) { if (arr.length > 0) {
if (arr.length > 0) { this.tail_.data = arr;
this.tail_.data = arr; this.tail_ = this.tail_.next = new ConsArrayCell(null, null);
this.tail_ = this.tail_.next = new ConsArray.Cell(null, null); }
} }
};
/**
* Whether the end of iteration is reached.
*/
ConsArray.prototype.atEnd = function() {
return this.currCell_ === null ||
this.currCell_.data === null ||
this.currCellPos_ >= this.currCell_.data.length;
};
/**
* Whether the end of iteration is reached.
*/
atEnd() {
return this.currCell_ === null ||
this.currCell_.data === null ||
this.currCellPos_ >= this.currCell_.data.length;
}
/** /**
* Returns the current item, moves to the next one. * Returns the current item, moves to the next one.
*/ */
ConsArray.prototype.next = function() { next() {
const result = this.currCell_.data[this.currCellPos_++]; const result = this.currCell_.data[this.currCellPos_++];
if (this.currCellPos_ >= this.currCell_.data.length) { if (this.currCellPos_ >= this.currCell_.data.length) {
this.currCell_ = this.currCell_.next; this.currCell_ = this.currCell_.next;
this.currCellPos_ = 0; this.currCellPos_ = 0;
}
return result;
} }
return result; }
};
/** /**
...@@ -86,7 +84,9 @@ ConsArray.prototype.next = function() { ...@@ -86,7 +84,9 @@ ConsArray.prototype.next = function() {
* *
* @constructor * @constructor
*/ */
ConsArray.Cell = function(data, next) { class ConsArrayCell {
this.data = data; constructor(data, next) {
this.next = next; this.data = data;
}; this.next = next;
}
}
...@@ -5,10 +5,9 @@ ...@@ -5,10 +5,9 @@
import { LogReader, parseString } from "./logreader.mjs"; import { LogReader, parseString } from "./logreader.mjs";
import { CodeMap, CodeEntry } from "./codemap.mjs"; import { CodeMap, CodeEntry } from "./codemap.mjs";
export { export {
ArgumentsProcessor, UnixCppEntriesProvider, ArgumentsProcessor, UnixCppEntriesProvider,
WindowsCppEntriesProvider, MacCppEntriesProvider, WindowsCppEntriesProvider, MacCppEntriesProvider,
} from "./tickprocessor.mjs"; } from "./tickprocessor.mjs";
import { inherits } from "./tickprocessor.mjs";
export class CppProcessor extends LogReader { export class CppProcessor extends LogReader {
...@@ -29,7 +28,7 @@ export class CppProcessor extends LogReader { ...@@ -29,7 +28,7 @@ export class CppProcessor extends LogReader {
*/ */
printError(str) { printError(str) {
print(str); print(str);
}; }
processLogFile(fileName) { processLogFile(fileName) {
this.lastLogFileName_ = fileName; this.lastLogFileName_ = fileName;
...@@ -37,14 +36,14 @@ export class CppProcessor extends LogReader { ...@@ -37,14 +36,14 @@ export class CppProcessor extends LogReader {
while (line = readline()) { while (line = readline()) {
this.processLogLine(line); this.processLogLine(line);
} }
}; }
processLogFileInTest(fileName) { processLogFileInTest(fileName) {
// Hack file name to avoid dealing with platform specifics. // Hack file name to avoid dealing with platform specifics.
this.lastLogFileName_ = 'v8.log'; this.lastLogFileName_ = 'v8.log';
const contents = readFile(fileName); const contents = readFile(fileName);
this.processLogChunk(contents); this.processLogChunk(contents);
}; }
processSharedLibrary(name, startAddr, endAddr, aslrSlide) { processSharedLibrary(name, startAddr, endAddr, aslrSlide) {
const self = this; const self = this;
...@@ -53,7 +52,7 @@ export class CppProcessor extends LogReader { ...@@ -53,7 +52,7 @@ export class CppProcessor extends LogReader {
const entry = new CodeEntry(fEnd - fStart, fName, 'CPP'); const entry = new CodeEntry(fEnd - fStart, fName, 'CPP');
self.codeMap_.addStaticCode(fStart, entry); self.codeMap_.addStaticCode(fStart, entry);
}); });
}; }
dumpCppSymbols() { dumpCppSymbols() {
const staticEntries = this.codeMap_.getAllStaticEntriesWithAddresses(); const staticEntries = this.codeMap_.getAllStaticEntriesWithAddresses();
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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