• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef ES2PANDA_IR_AST_NODE_HISTORY_H
17 #define ES2PANDA_IR_AST_NODE_HISTORY_H
18 
19 #include "ir/astNode.h"
20 #include "util/doubleLinkedList.h"
21 
22 namespace ark::es2panda::ir {
23 
24 class AstNodeHistory {
25 public:
26     AstNodeHistory(AstNode *node, int32_t phaseId, ArenaAllocator *allocator);
27 
28     AstNode *At(int32_t phaseId);
29     AstNode *Get(int32_t phaseId);
30     void Set(AstNode *node, int32_t phaseId);
31 
32 private:
33     struct HistoryRecord {
34         AstNode *node;
35         int32_t phaseId;
36     };
37 
38     using HistoryList = util::ArenaDoubleLinkedList<HistoryRecord>;
39 
40     AstNode *FindBackwardEquals(int32_t phaseId);
41     AstNode *FindForwardEquals(int32_t phaseId);
42     HistoryList::Item *FindLessOrEquals(int32_t phaseId);
43 
44     HistoryList list_;                   // Node history list
45     HistoryList::Item *item_ {nullptr};  // Last accessed history record
46 };
47 }  // namespace ark::es2panda::ir
48 #endif
49