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 @@
*
* @constructor
*/
export function ConsArray() {
this.tail_ = new ConsArray.Cell(null, null);
this.currCell_ = this.tail_;
this.currCellPos_ = 0;
};
/**
* Concatenates another array for iterating. Empty arrays are ignored.
* This operation can be safely performed during ongoing ConsArray
* iteration.
*
* @param {Array} arr Array to concatenate.
*/
ConsArray.prototype.concat = function(arr) {
if (arr.length > 0) {
this.tail_.data = arr;
this.tail_ = this.tail_.next = new ConsArray.Cell(null, null);
export class ConsArray {
constructor() {
this.tail_ = new ConsArrayCell(null, null);
this.currCell_ = this.tail_;
this.currCellPos_ = 0;
}
/**
* Concatenates another array for iterating. Empty arrays are ignored.
* This operation can be safely performed during ongoing ConsArray
* iteration.
*
* @param {Array} arr Array to concatenate.
*/
concat(arr) {
if (arr.length > 0) {
this.tail_.data = arr;
this.tail_ = this.tail_.next = new ConsArrayCell(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.
*/
ConsArray.prototype.next = function() {
const result = this.currCell_.data[this.currCellPos_++];
if (this.currCellPos_ >= this.currCell_.data.length) {
this.currCell_ = this.currCell_.next;
this.currCellPos_ = 0;
/**
* Returns the current item, moves to the next one.
*/
next() {
const result = this.currCell_.data[this.currCellPos_++];
if (this.currCellPos_ >= this.currCell_.data.length) {
this.currCell_ = this.currCell_.next;
this.currCellPos_ = 0;
}
return result;
}
return result;
};
}
/**
......@@ -86,7 +84,9 @@ ConsArray.prototype.next = function() {
*
* @constructor
*/
ConsArray.Cell = function(data, next) {
this.data = data;
this.next = next;
};
class ConsArrayCell {
constructor(data, next) {
this.data = data;
this.next = next;
}
}
......@@ -5,10 +5,9 @@
import { LogReader, parseString } from "./logreader.mjs";
import { CodeMap, CodeEntry } from "./codemap.mjs";
export {
ArgumentsProcessor, UnixCppEntriesProvider,
ArgumentsProcessor, UnixCppEntriesProvider,
WindowsCppEntriesProvider, MacCppEntriesProvider,
} from "./tickprocessor.mjs";
import { inherits } from "./tickprocessor.mjs";
export class CppProcessor extends LogReader {
......@@ -29,7 +28,7 @@ export class CppProcessor extends LogReader {
*/
printError(str) {
print(str);
};
}
processLogFile(fileName) {
this.lastLogFileName_ = fileName;
......@@ -37,14 +36,14 @@ export class CppProcessor extends LogReader {
while (line = readline()) {
this.processLogLine(line);
}
};
}
processLogFileInTest(fileName) {
// Hack file name to avoid dealing with platform specifics.
this.lastLogFileName_ = 'v8.log';
const contents = readFile(fileName);
this.processLogChunk(contents);
};
}
processSharedLibrary(name, startAddr, endAddr, aslrSlide) {
const self = this;
......@@ -53,7 +52,7 @@ export class CppProcessor extends LogReader {
const entry = new CodeEntry(fEnd - fStart, fName, 'CPP');
self.codeMap_.addStaticCode(fStart, entry);
});
};
}
dumpCppSymbols() {
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