log.mjs 1.28 KB
Newer Older
1 2 3 4
// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5
export class LogEntry {
6
  constructor(type, time) {
7
    /** @type {number} */
8 9
    this._time = time;
    this._type = type;
10
    /** @type {?SourcePosition} */
11
    this.sourcePosition = undefined;
12
  }
13

14
  get time() {
15
    return this._time;
16
  }
17

18
  get type() {
19
    return this._type;
20
  }
21

22 23 24 25 26
  get script() {
    return this.sourcePosition?.script;
  }

  toString() {
27 28 29 30 31 32
    let name = this.constructor.name;
    const index = name.lastIndexOf('LogEntry');
    if (index > 0) {
      name = name.substr(0, index);
    }
    return `${name}(${this._type})`;
33 34
  }

35 36 37 38 39 40 41 42 43 44 45
  get toolTipDict() {
    const toolTipDescription = {
      __proto__: null,
      __this__: this,
      title: this.toString()
    };
    for (let key of this.constructor.propertyNames) {
      toolTipDescription[key] = this[key];
    }

    return toolTipDescription;
46 47
  }

48
  // Returns an Array of all possible #type values.
49
  /**  @return {string[]} */
50
  static get allTypes() {
51
    throw new Error('Not implemented.');
52
  }
53 54

  // Returns an array of public property names.
55
  /**  @return {string[]} */
56 57 58
  static get propertyNames() {
    throw new Error('Not implemented.');
  }
59
}