• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2021-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 // original_header.h
17 #ifndef FORWARD_DECL_FOR_PARSERIMPL_H
18 #define FORWARD_DECL_FOR_PARSERIMPL_H
19 
20 #include "ir/base/scriptFunctionSignature.h"
21 #include "parser/context/parserContext.h"
22 #include "varbinder/scope.h"
23 
24 namespace ark::es2panda::lexer {
25 enum class TokenFlags : uint32_t;
26 class LexerPosition;
27 class Token;
28 class Lexer;
29 }  // namespace ark::es2panda::lexer
30 
31 namespace ark::es2panda::ir {
32 class ArrowFunctionExpression;
33 class AstNode;
34 class BlockStatement;
35 class BreakStatement;
36 class CallExpression;
37 class ClassDeclaration;
38 class ClassDefinition;
39 class ContinueStatement;
40 class DoWhileStatement;
41 class ExportAllDeclaration;
42 class ExportDefaultDeclaration;
43 class ExportNamedDeclaration;
44 class ExportNamedDeclaration;
45 class Expression;
46 class FunctionDeclaration;
47 class FunctionExpression;
48 class Identifier;
49 class IfStatement;
50 class ImportDeclaration;
51 class LabelledStatement;
52 class NewExpression;
53 class ObjectExpression;
54 class ReturnStatement;
55 class ScriptFunction;
56 class SequenceExpression;
57 class SpreadElement;
58 class Statement;
59 class StringLiteral;
60 class SwitchCaseStatement;
61 class SwitchStatement;
62 class TemplateLiteral;
63 class ThrowStatement;
64 class TryStatement;
65 class VariableDeclaration;
66 class WhileStatement;
67 class WithStatement;
68 class MemberExpression;
69 class MethodDefinition;
70 class Property;
71 class YieldExpression;
72 class MetaProperty;
73 class EmptyStatement;
74 class DebuggerStatement;
75 class CatchClause;
76 class VariableDeclarator;
77 class ClassElement;
78 
79 enum class PropertyKind;
80 enum class MethodDefinitionKind;
81 enum class ModifierFlags : uint32_t;
82 enum class Primitives;
83 enum class ClassDefinitionModifiers : uint32_t;
84 enum class CatchClauseType;
85 enum class VariableDeclaratorFlag;
86 }  // namespace ark::es2panda::ir
87 
88 namespace ark::es2panda::parser {
89 
90 class ETSParser;
91 
92 using FunctionSignature = std::tuple<ir::FunctionSignature, ark::es2panda::ir::ScriptFunctionFlags>;
93 
94 // NOLINTBEGIN(modernize-avoid-c-arrays)
95 inline constexpr char const ARRAY_FORMAT_NODE = '[';
96 inline constexpr char const EXPRESSION_FORMAT_NODE = 'E';
97 inline constexpr char const STATEMENT_FORMAT_NODE = 'S';
98 // NOLINTEND(modernize-avoid-c-arrays)
99 
100 class ClassElementDescriptor {
101 public:
ClassElementDescriptor(ArenaAllocator * allocator)102     explicit ClassElementDescriptor(ArenaAllocator *allocator) : decorators(allocator->Adapter()) {}
103 
104     // NOLINTBEGIN(misc-non-private-member-variables-in-classes)
105     ArenaVector<ir::Decorator *> decorators;
106     ir::MethodDefinitionKind methodKind {};
107     ParserStatus newStatus {};
108     ir::ModifierFlags modifiers {};
109     lexer::SourcePosition methodStart {};
110     lexer::SourcePosition propStart {};
111     bool isPrivateIdent {};
112     bool hasSuperClass {};
113     bool isGenerator {};
114     bool invalidComputedProperty {};
115     bool isComputed {};
116     bool isIndexSignature {};
117     bool classMethod {};
118     bool classField {};
119     varbinder::LocalScope *staticFieldScope {};
120     varbinder::LocalScope *staticMethodScope {};
121     varbinder::LocalScope *instanceFieldScope {};
122     varbinder::LocalScope *instanceMethodScope {};
123     // NOLINTEND(misc-non-private-member-variables-in-classes)
124 };
125 
126 class ArrowFunctionDescriptor {
127 public:
ArrowFunctionDescriptor(ArenaVector<ir::Expression * > && p,lexer::SourcePosition sl,ParserStatus ns)128     explicit ArrowFunctionDescriptor(ArenaVector<ir::Expression *> &&p, lexer::SourcePosition sl, ParserStatus ns)
129         : params(p), startLoc(sl), newStatus(ns)
130     {
131     }
132 
133     // NOLINTBEGIN(misc-non-private-member-variables-in-classes)
134     ArenaVector<ir::Expression *> params;
135     lexer::SourcePosition startLoc;
136     ParserStatus newStatus;
137     // NOLINTEND(misc-non-private-member-variables-in-classes)
138 };
139 
140 class ArrowFunctionContext;
141 }  // namespace ark::es2panda::parser
142 #endif
143