diff --git a/ets2panda/BUILD.gn b/ets2panda/BUILD.gn index b667d95f9c823069c447dd65a5c16d71363e7acb..de7ef04149e364cf5648c800e917b1cca5c41d83 100644 --- a/ets2panda/BUILD.gn +++ b/ets2panda/BUILD.gn @@ -159,6 +159,8 @@ libes2panda_sources = [ "compiler/function/generatorFunctionBuilder.cpp", "compiler/lowering/checkerPhase.cpp", "compiler/lowering/ets/defaultParameterLowering.cpp", + "compiler/lowering/ets/enumConstantExpressionLowering.cpp", + "compiler/lowering/ets/enumMemberDefaultValueLowering.cpp", "compiler/lowering/ets/expandBrackets.cpp", "compiler/lowering/ets/generateDeclarations.cpp", "compiler/lowering/ets/interfacePropertyDeclarations.cpp", diff --git a/ets2panda/CMakeLists.txt b/ets2panda/CMakeLists.txt index 04be788b8c546ea40a8acb52aad192a8aacd2b3f..d1ce1da3700c7719a4bec486ea5c501c1eb46747 100644 --- a/ets2panda/CMakeLists.txt +++ b/ets2panda/CMakeLists.txt @@ -150,6 +150,8 @@ set(ES2PANDA_LIB_SRC compiler/lowering/phase.cpp compiler/lowering/plugin_phase.cpp compiler/lowering/util.cpp + compiler/lowering/ets/enumConstantExpressionLowering.cpp + compiler/lowering/ets/enumMemberDefaultValueLowering.cpp compiler/lowering/ets/lambdaLowering.cpp compiler/lowering/ets/generateDeclarations.cpp compiler/lowering/ets/objectIndexAccess.cpp diff --git a/ets2panda/compiler/core/ASTVerifier.h b/ets2panda/compiler/core/ASTVerifier.h index a2481756d5e34e4ae9de2b351096bfbe49a8fc46..145cdd5107722526c25b000ece699e862e593dfc 100644 --- a/ets2panda/compiler/core/ASTVerifier.h +++ b/ets2panda/compiler/core/ASTVerifier.h @@ -125,7 +125,9 @@ public: "PromiseVoidInferencePhase", "TupleLowering", "UnionLowering", - "ExpandBracketsPhase"}; + "ExpandBracketsPhase", + "EnumConstantExpression", + "EnumMemberDefaultValue"}; if (withoutAdditionalChecks.count(phaseName.Mutf8()) > 0) { return {{}}; }; diff --git a/ets2panda/compiler/lowering/ets/enumConstantExpressionLowering.cpp b/ets2panda/compiler/lowering/ets/enumConstantExpressionLowering.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ad5aa0bd0cab38a2d5dd93a9964f4a9c50e3abf4 --- /dev/null +++ b/ets2panda/compiler/lowering/ets/enumConstantExpressionLowering.cpp @@ -0,0 +1,208 @@ +/** + * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "enumConstantExpressionLowering.h" + +#include "checker/ETSchecker.h" +#include "ir/astNode.h" +#include "compiler/core/compilerContext.h" + +namespace ark::es2panda::compiler { +namespace { +std::optional SearchInEnum(ArenaVector members, const util::StringView &name) +{ + for (auto &member : members) { + if (std::string(member->AsTSEnumMember()->Name()) == std::string(name)) { + return member->AsTSEnumMember()->Init()->AsNumberLiteral()->Number().GetInt(); + } + } + return {}; +} + +int32_t GetIntValFromNode(const ir::Expression *node, ir::AstNode *declNode) +{ + util::StringView name; + if (node->IsMemberExpression()) { + name = node->AsMemberExpression()->Property()->AsIdentifier()->Name(); + } else { + name = node->AsIdentifier()->Name(); + } + + if (declNode->IsClassProperty()) { + return declNode->AsClassProperty()->Value()->AsNumberLiteral()->Number().GetInt(); + } + if (declNode->IsTSEnumDeclaration()) { + auto val = SearchInEnum(declNode->AsTSEnumDeclaration()->Members(), name); + if (val.has_value()) { + return val.value(); + } + } + UNREACHABLE(); +} + +int32_t GetValFromNode(const ir::Expression *node, parser::Program *const program, ir::AstNode *ast) +{ + if (node->IsIdentifier()) { + // Search in current enum + std::optional val = SearchInEnum(ast->AsTSEnumMember()->Parent()->AsTSEnumDeclaration()->Members(), + node->AsIdentifier()->Name()); + if (val.has_value()) { + return val.value(); + } + + auto localScope = program->VarBinder() + ->GetScope() + ->Bindings() + .find(ast->AsTSEnumMember()->Parent()->AsTSEnumDeclaration()->Key()->Name()) + ->second; + for (auto &decl : localScope->GetScope()->Decls()) { + if (std::string(decl->Name()) == std::string(node->AsIdentifier()->Name())) { + return GetIntValFromNode(node, decl->Node()); + } + } + } else if (node->IsMemberExpression()) { + // Search in local scope variable + auto localScope = program->VarBinder() + ->GetScope() + ->Bindings() + .find(ast->AsTSEnumMember()->Parent()->AsTSEnumDeclaration()->Key()->Name()) + ->second; + for (auto &decl : localScope->GetScope()->Decls()) { + if (std::string(decl->Name()) == + std::string(node->AsMemberExpression()->Object()->AsIdentifier()->Name())) { + return GetIntValFromNode(node, decl->Node()); + } + } + } else if (node->IsNumberLiteral()) { + return node->AsNumberLiteral()->Number().GetInt(); + } + UNREACHABLE(); +} + +uint32_t ToUInt(double num) +{ + if (num >= std::numeric_limits::min() && num <= std::numeric_limits::max()) { + return static_cast(num); + } + return 0; +} + +int32_t ToInt(double num) +{ + if (num >= std::numeric_limits::min() && num <= std::numeric_limits::max()) { + return static_cast(num); + } + return 0; +} + +varbinder::EnumMemberResult GetOperationResulForDouble(lexer::TokenType type, varbinder::EnumMemberResult left, + varbinder::EnumMemberResult right) +{ + switch (type) { + case lexer::TokenType::PUNCTUATOR_BITWISE_OR: { + return static_cast(ToUInt(std::get(left)) | ToUInt(std::get(right))); + } + case lexer::TokenType::PUNCTUATOR_BITWISE_AND: { + return static_cast(ToUInt(std::get(left)) & ToUInt(std::get(right))); + } + case lexer::TokenType::PUNCTUATOR_BITWISE_XOR: { + return static_cast(ToUInt(std::get(left)) ^ ToUInt(std::get(right))); + } + case lexer::TokenType::PUNCTUATOR_LEFT_SHIFT: { // NOLINTNEXTLINE(hicpp-signed-bitwise) + return static_cast(ToInt(std::get(left)) << ToUInt(std::get(right))); + } + case lexer::TokenType::PUNCTUATOR_RIGHT_SHIFT: { // NOLINTNEXTLINE(hicpp-signed-bitwise) + return static_cast(ToInt(std::get(left)) >> ToUInt(std::get(right))); + } + case lexer::TokenType::PUNCTUATOR_UNSIGNED_RIGHT_SHIFT: { + return static_cast(ToUInt(std::get(left)) >> ToUInt(std::get(right))); + } + case lexer::TokenType::PUNCTUATOR_PLUS: { + return std::get(left) + std::get(right); + } + case lexer::TokenType::PUNCTUATOR_MINUS: { + return std::get(left) - std::get(right); + } + case lexer::TokenType::PUNCTUATOR_MULTIPLY: { + return std::get(left) * std::get(right); + } + case lexer::TokenType::PUNCTUATOR_DIVIDE: { + return std::get(left) / std::get(right); + } + case lexer::TokenType::PUNCTUATOR_MOD: { + return std::fmod(std::get(left), std::get(right)); + } + case lexer::TokenType::PUNCTUATOR_EXPONENTIATION: { + return std::pow(std::get(left), std::get(right)); + } + default: { + return false; + } + } +} +} // namespace + +bool EnumConstantExpressionLowering::Perform(public_lib::Context *const ctx, parser::Program *const program) +{ + for (auto &[_, ext_programs] : program->ExternalSources()) { + for (auto *extProg : ext_programs) { + Perform(ctx, extProg); + } + } + + checker::ETSChecker *checker = ctx->checker->AsETSChecker(); + program->Ast()->TransformChildrenRecursively([checker, program](ir::AstNode *ast) -> ir::AstNode* { + UNUSED_VAR(checker); + if (ast->IsTSEnumMember()) { + auto init = ast->AsTSEnumMember()->Init(); + auto *allocator = checker->Allocator(); + if (init->IsIdentifier()) { + auto number = + allocator->New(ark::es2panda::lexer::Number(GetValFromNode(init, program, ast))); + number->SetParent(ast); + ast->AsTSEnumMember()->SetInit(number); + return ast; + } + if (init->IsMemberExpression()) { + auto number = + allocator->New(ark::es2panda::lexer::Number(GetValFromNode(init, program, ast))); + number->SetParent(ast); + ast->AsTSEnumMember()->SetInit(number); + return ast; + } + if (init->IsBinaryExpression()) { + auto left = init->AsBinaryExpression()->Left(); + auto right = init->AsBinaryExpression()->Right(); + int32_t leftVal = GetValFromNode(left, program, ast); + int32_t rightVal = GetValFromNode(right, program, ast); + + varbinder::EnumMemberResult evalExpr = + GetOperationResulForDouble(init->AsBinaryExpression()->OperatorType(), static_cast(leftVal), + static_cast(rightVal)); + + auto number = allocator->New( + ark::es2panda::lexer::Number(std::holds_alternative(evalExpr))); + number->SetParent(ast); + ast->AsTSEnumMember()->SetInit(number); + return ast; + } + } + return ast; + }); + + return true; +} + +} // namespace ark::es2panda::compiler \ No newline at end of file diff --git a/ets2panda/compiler/lowering/ets/enumConstantExpressionLowering.h b/ets2panda/compiler/lowering/ets/enumConstantExpressionLowering.h new file mode 100644 index 0000000000000000000000000000000000000000..86afea0249117051ae31df5860aa5f132df61cc4 --- /dev/null +++ b/ets2panda/compiler/lowering/ets/enumConstantExpressionLowering.h @@ -0,0 +1,34 @@ +/** + * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ES2PANDA_COMPILER_LOWERING_ENUM_CONSTANT_EXPRESSION_LOWERING_H +#define ES2PANDA_COMPILER_LOWERING_ENUM_CONSTANT_EXPRESSION_LOWERING_H + +#include "compiler/lowering/phase.h" + +namespace ark::es2panda::compiler { + +class EnumConstantExpressionLowering : public Phase { +public: + std::string_view Name() const override + { + return "EnumConstantExpression"; + } + bool Perform(public_lib::Context *ctx, parser::Program *program) override; +}; + +} // namespace ark::es2panda::compiler + +#endif // ES2PANDA_COMPILER_LOWERING_ENUM_CONSTANT_EXPRESSION_LOWERING_H \ No newline at end of file diff --git a/ets2panda/compiler/lowering/ets/enumMemberDefaultValueLowering.cpp b/ets2panda/compiler/lowering/ets/enumMemberDefaultValueLowering.cpp new file mode 100644 index 0000000000000000000000000000000000000000..764f369b792e128746967307e5c5e736ccda14a7 --- /dev/null +++ b/ets2panda/compiler/lowering/ets/enumMemberDefaultValueLowering.cpp @@ -0,0 +1,65 @@ +/** + * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "enumMemberDefaultValueLowering.h" + +#include "checker/ETSchecker.h" +#include "ir/astNode.h" +#include "compiler/core/compilerContext.h" + +namespace ark::es2panda::compiler { + +namespace { +uint32_t GetMemberValue(size_t index, ArenaVector &members) +{ + if (index == 0) { + return 0; + } + return members[index - 1]->AsTSEnumMember()->Init()->AsNumberLiteral()->Number().GetInt() + 1; +} +} // namespace + +bool EnumMemberDefaultValueLowering::Perform(public_lib::Context *const ctx, parser::Program *const program) +{ + for (auto &[_, ext_programs] : program->ExternalSources()) { + for (auto *extProg : ext_programs) { + Perform(ctx, extProg); + } + } + + checker::ETSChecker *checker = ctx->checker->AsETSChecker(); + program->Ast()->TransformChildrenRecursively([checker](ir::AstNode *ast) -> ir::AstNode* { + UNUSED_VAR(checker); + + if (!ast->IsTSEnumDeclaration()) { + return ast; + } + auto enumMembers = ast->AsTSEnumDeclaration()->Members(); + for (size_t i = 0; i < enumMembers.size(); i++) { + if (!enumMembers[i]->AsTSEnumMember()->GetIsAssignment()) { + auto *allocator = checker->Allocator(); + auto number = allocator->New( + ark::es2panda::lexer::Number(GetMemberValue(i, enumMembers))); + number->SetParent(ast); + enumMembers[i]->AsTSEnumMember()->SetInit(number); + } + } + return ast; + }); + + return true; +} + +} // namespace ark::es2panda::compiler \ No newline at end of file diff --git a/ets2panda/compiler/lowering/ets/enumMemberDefaultValueLowering.h b/ets2panda/compiler/lowering/ets/enumMemberDefaultValueLowering.h new file mode 100644 index 0000000000000000000000000000000000000000..0935d331921f9b004a113a43f4db84ebe14b5769 --- /dev/null +++ b/ets2panda/compiler/lowering/ets/enumMemberDefaultValueLowering.h @@ -0,0 +1,34 @@ +/** + * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ES2PANDA_COMPILER_LOWERING_ENUM_LOWERING_H +#define ES2PANDA_COMPILER_LOWERING_ENUM_LOWERING_H + +#include "compiler/lowering/phase.h" + +namespace ark::es2panda::compiler { + +class EnumMemberDefaultValueLowering : public Phase { +public: + std::string_view Name() const override + { + return "EnumMemberDefaultValue"; + } + bool Perform(public_lib::Context *ctx, parser::Program *program) override; +}; + +} // namespace ark::es2panda::compiler + +#endif // ES2PANDA_COMPILER_LOWERING_ENUM_MEMBER_DEFAULT_VALUE_LOWERING_H \ No newline at end of file diff --git a/ets2panda/compiler/lowering/phase.cpp b/ets2panda/compiler/lowering/phase.cpp index 4867b44e67108056d4e15e58e91a5004ebe36ff7..21bc8039c37c74962d60e829240cfc5292c140f5 100644 --- a/ets2panda/compiler/lowering/phase.cpp +++ b/ets2panda/compiler/lowering/phase.cpp @@ -24,6 +24,8 @@ #include "compiler/lowering/plugin_phase.h" #include "compiler/lowering/scopesInit/scopesInitPhase.h" #include "compiler/lowering/ets/expandBrackets.h" +#include "compiler/lowering/ets/enumConstantExpressionLowering.h" +#include "compiler/lowering/ets/enumMemberDefaultValueLowering.h" #include "compiler/lowering/ets/generateDeclarations.h" #include "compiler/lowering/ets/lambdaLowering.h" #include "compiler/lowering/ets/interfacePropertyDeclarations.h" @@ -53,6 +55,8 @@ static GenerateTsDeclarationsPhase g_generateTsDeclarationsPhase; static LambdaConstructionPhase g_lambdaConstructionPhase; static OpAssignmentLowering g_opAssignmentLowering; static ObjectIndexLowering g_objectIndexLowering; +static EnumConstantExpressionLowering g_enumConstantLowering; +static EnumMemberDefaultValueLowering g_enumDefaultValueLowering; static TupleLowering g_tupleLowering; // Can be only applied after checking phase, and OP_ASSIGNMENT_LOWERING phase static UnionLowering g_unionLowering; static OptionalLowering g_optionalLowering; @@ -81,6 +85,8 @@ std::vector GetETSPhaseList() &g_promiseVoidInferencePhase, &g_structLowering, &g_lambdaConstructionPhase, + &g_enumConstantLowering, + &g_enumDefaultValueLowering, &g_interfacePropDeclPhase, &g_checkerPhase, &g_pluginsAfterCheck, diff --git a/ets2panda/ir/ts/tsEnumMember.h b/ets2panda/ir/ts/tsEnumMember.h index 20abe1528582af5118298179a8182e01415c33b1..afe00e375a2d46228f804ca91fc1afa8673deeab 100644 --- a/ets2panda/ir/ts/tsEnumMember.h +++ b/ets2panda/ir/ts/tsEnumMember.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -43,6 +43,31 @@ public: return init_; } + void SetInit(Expression *init) + { + init_ = init; + } + + bool GetIsAssignment() const noexcept + { + return isAssignment_; + } + + void SetIsAssignment(bool isassignment) + { + isAssignment_ = isassignment; + } + + bool GetIsExpression() const noexcept + { + return isExpression_; + } + + void SetIsExpression(bool isexpr) + { + isExpression_ = isexpr; + } + [[nodiscard]] util::StringView Name() const; void TransformChildren(const NodeTransformer &cb) override; @@ -62,6 +87,8 @@ public: private: Expression *key_; Expression *init_; + bool isAssignment_ = true; + bool isExpression_ = false; }; } // namespace ark::es2panda::ir diff --git a/ets2panda/parser/ETSparser.cpp b/ets2panda/parser/ETSparser.cpp index 7717532ded41dfd3e5df90c16fe2840047133ef3..bd8cdb48f5b7cb6ee187c878128efa38251ece02 100644 --- a/ets2panda/parser/ETSparser.cpp +++ b/ets2panda/parser/ETSparser.cpp @@ -26,7 +26,6 @@ #include "varbinder/ETSBinder.h" #include "lexer/lexer.h" #include "lexer/ETSLexer.h" -#include "checker/types/ets/etsEnumType.h" #include "ir/astNode.h" #include "ir/base/classDefinition.h" #include "ir/base/decorator.h" @@ -3973,61 +3972,71 @@ ir::TSEnumDeclaration *ETSParser::ParseEnumMembers(ir::Identifier *const key, co return enumDeclaration; } -void ETSParser::ParseNumberEnum(ArenaVector &members) +void ETSParser::ParseEnumMember(ArenaVector &members, checker::ETSEnumType::ValueType ¤tValue) { - checker::ETSEnumType::ValueType currentValue {}; + auto *const ident = ExpectIdentifier(false, true); - // Lambda to parse enum member (maybe with initializer) - auto const parseMember = [this, &members, ¤tValue]() { - auto *const ident = ExpectIdentifier(false, true); + ir::NumberLiteral *ordinal; + lexer::SourcePosition endLoc; - ir::NumberLiteral *ordinal; - lexer::SourcePosition endLoc; - - if (Lexer()->GetToken().Type() == lexer::TokenType::PUNCTUATOR_SUBSTITUTION) { - // Case when user explicitly set the value for enumeration constant - - bool minusSign = false; + bool isIdent = false; + bool isAssignment = false; + ir::Expression *identNode; + if (Lexer()->GetToken().Type() == lexer::TokenType::PUNCTUATOR_SUBSTITUTION) { + // Case when user explicitly set the value for enumeration constant + bool minusSign = false; + Lexer()->NextToken(); + if (Lexer()->GetToken().Type() == lexer::TokenType::PUNCTUATOR_PLUS) { Lexer()->NextToken(); - if (Lexer()->GetToken().Type() == lexer::TokenType::PUNCTUATOR_PLUS) { - Lexer()->NextToken(); - } else if (Lexer()->GetToken().Type() == lexer::TokenType::PUNCTUATOR_MINUS) { - minusSign = true; - Lexer()->NextToken(); - } + } else if (Lexer()->GetToken().Type() == lexer::TokenType::PUNCTUATOR_MINUS) { + minusSign = true; + Lexer()->NextToken(); + } - if (Lexer()->GetToken().Type() != lexer::TokenType::LITERAL_NUMBER) { - ThrowSyntaxError(INVALID_ENUM_TYPE); - } + if (Lexer()->GetToken().Type() != lexer::TokenType::LITERAL_NUMBER && + Lexer()->GetToken().Type() != lexer::TokenType::LITERAL_IDENT) { + ThrowSyntaxError(INVALID_ENUM_TYPE); + } + if (Lexer()->GetToken().Type() == lexer::TokenType::LITERAL_IDENT) { + isIdent = true; + identNode = ParseExpression(); + endLoc = identNode->End(); + } else { ordinal = ParseNumberLiteral()->AsNumberLiteral(); + isAssignment = true; + endLoc = ordinal->End(); + } + if (!isIdent) { if (!ordinal->Number().CanGetValue()) { ThrowSyntaxError(INVALID_ENUM_VALUE); } else if (minusSign) { ordinal->Number().Negate(); } - currentValue = ordinal->Number().GetValue(); - - endLoc = ordinal->End(); - } else { - // Default enumeration constant value. Equal to 0 for the first item and = previous_value + 1 for all - // the others. - - ordinal = AllocNode(lexer::Number(currentValue)); - - endLoc = ident->End(); } + } else { + // Default enumeration constant value. Equal to 0 for the first item and = previous_value + 1 for all + // the others. + ordinal = AllocNode(lexer::Number(currentValue)); + endLoc = ident->End(); + } - auto *const member = AllocNode(ident, ordinal); - member->SetRange({ident->Start(), endLoc}); - members.emplace_back(member); + ir::Expression *init = isIdent ? identNode : ordinal; + ir::TSEnumMember *member = AllocNode(ident, init); + member->SetIsExpression(isIdent); + member->SetIsAssignment(!isAssignment); + member->SetRange({ident->Start(), endLoc}); + members.emplace_back(member); - ++currentValue; - }; + ++currentValue; +} - parseMember(); +void ETSParser::ParseNumberEnum(ArenaVector &members) +{ + checker::ETSEnumType::ValueType currentValue {}; + ParseEnumMember(members, currentValue); while (Lexer()->GetToken().Type() != lexer::TokenType::PUNCTUATOR_RIGHT_BRACE) { if (Lexer()->GetToken().Type() != lexer::TokenType::PUNCTUATOR_COMMA) { @@ -4040,7 +4049,7 @@ void ETSParser::ParseNumberEnum(ArenaVector &members) break; } - parseMember(); + ParseEnumMember(members, currentValue); } } diff --git a/ets2panda/parser/ETSparser.h b/ets2panda/parser/ETSparser.h index fe94640be06cb8ab52ba3996beae028aaf2c9db6..7f14bb3b43e3d41b6683b37d874606ca0101b81e 100644 --- a/ets2panda/parser/ETSparser.h +++ b/ets2panda/parser/ETSparser.h @@ -18,6 +18,7 @@ #include #include "parserFlags.h" +#include "checker/types/ets/etsEnumType.h" #include "util/arktsconfig.h" #include "util/pathHandler.h" #include "TypedParser.h" @@ -283,6 +284,7 @@ private: ir::TSEnumDeclaration *ParseEnumMembers(ir::Identifier *key, const lexer::SourcePosition &enumStart, bool isConst, bool isStatic) override; void ParseNumberEnum(ArenaVector &members); + void ParseEnumMember(ArenaVector &members, checker::ETSEnumType::ValueType ¤tValue); void ParseStringEnum(ArenaVector &members); ir::Statement *ParseInterfaceDeclaration(bool isStatic) override;