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