summaryrefslogtreecommitdiff
path: root/deps/v8/tools/turbolizer/src/selection/selection-storage.ts
blob: b3faf7862faa95e21ce7f315073dab7d933fc642 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Copyright 2022 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.

export class SelectionStorage {
  nodes: Map<string, any>;
  blocks: Map<string, any>;
  adaptedNodes: Set<string>;
  adaptedBocks: Set<string>;

  constructor(nodes?: Map<string, any>, blocks?: Map<string, any>) {
    this.nodes = nodes ?? new Map<string, any>();
    this.blocks = blocks ?? new Map<string, any>();
    this.adaptedNodes = new Set<string>();
    this.adaptedBocks = new Set<string>();
  }

  public adaptNode(nodeKey: string): void {
    this.adaptedNodes.add(nodeKey);
  }

  public adaptBlock(blockKey: string): void {
    this.adaptedBocks.add(blockKey);
  }

  public isAdapted(): boolean {
    return this.adaptedNodes.size != 0 || this.adaptedBocks.size != 0;
  }
}