From d825656d22757dc9139cca7234690a931367cecf Mon Sep 17 00:00:00 2001 From: daizihan Date: Thu, 6 Feb 2025 11:28:35 +0800 Subject: [PATCH] Remove primitive enum type Description: 1. remove primitive enum types, and only kepp reference type 2. forbid stringenum casting to int 3. add missing scope for interface Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/IBMEXA?from=project-issue Signed-off-by: daizihan --- .../variableNameIdentifierNameSame.cpp | 13 +- ets2panda/checker/ETSAnalyzer.cpp | 65 +- ets2panda/checker/ETSAnalyzer.h | 1 - ets2panda/checker/ETSAnalyzerHelpers.cpp | 6 +- ets2panda/checker/ETSchecker.h | 14 +- ets2panda/checker/ets/arithmetic.cpp | 187 +- ets2panda/checker/ets/boxingConverter.cpp | 3 - ets2panda/checker/ets/boxingConverter.h | 2 +- ets2panda/checker/ets/helpers.cpp | 104 +- ets2panda/checker/ets/object.cpp | 4 +- ets2panda/checker/ets/typeCheckingHelpers.cpp | 43 +- ets2panda/checker/ets/typeCreation.cpp | 185 +- ets2panda/checker/ets/unboxingConverter.cpp | 4 +- ets2panda/checker/ets/validateHelpers.cpp | 4 +- ets2panda/checker/types/ets/etsArrayType.cpp | 4 +- ets2panda/checker/types/ets/etsEnumType.cpp | 376 +- ets2panda/checker/types/ets/etsEnumType.h | 216 +- ets2panda/checker/types/ets/etsObjectType.cpp | 4 - ets2panda/checker/types/ets/etsObjectType.h | 6 - .../types/ets/etsObjectTypeConstants.h | 4 +- ets2panda/checker/types/ets/etsStringType.cpp | 4 +- ets2panda/checker/types/ets/intType.cpp | 9 +- ets2panda/checker/types/ets/types.h | 3 +- ets2panda/checker/types/type.h | 1 + ets2panda/checker/types/typeFlag.h | 8 +- ets2panda/checker/types/typeRelation.cpp | 3 +- ets2panda/compiler/core/ETSCompiler.cpp | 90 - ets2panda/compiler/core/ETSCompiler.h | 4 +- .../compiler/core/ETSCompilerUnrechable.cpp | 5 + ets2panda/compiler/core/ETSGen.cpp | 45 - ets2panda/compiler/core/ETSemitter.cpp | 42 +- ets2panda/compiler/core/ETSemitter.h | 2 + .../compiler/lowering/ets/enumLowering.cpp | 538 +- .../compiler/lowering/ets/enumLowering.h | 44 +- .../lowering/ets/enumPostCheckLowering.cpp | 355 +- .../lowering/ets/enumPostCheckLowering.h | 30 +- .../compiler/lowering/ets/lambdaLowering.cpp | 5 - .../compiler/lowering/ets/unionLowering.cpp | 1 - .../lowering/scopesInit/scopesInitPhase.cpp | 18 +- ets2panda/declgen_ets2ts/declgenEts2Ts.cpp | 33 +- ets2panda/declgen_ets2ts/declgenEts2Ts.h | 2 +- ets2panda/ir/astNodeFlags.h | 8 +- ets2panda/ir/base/classDefinition.h | 17 + ets2panda/ir/base/classElement.h | 13 +- ets2panda/ir/expressions/memberExpression.cpp | 46 - ets2panda/ir/expressions/memberExpression.h | 2 - ets2panda/ir/statements/ifStatement.h | 10 +- .../ir/statements/switchCaseStatement.cpp | 7 +- ets2panda/ir/statements/switchCaseStatement.h | 9 + ets2panda/ir/statements/switchStatement.h | 9 + ets2panda/parser/ETSparserClasses.cpp | 2 - ets2panda/parser/ETSparserEnums.cpp | 1 - ets2panda/scripts/arkui-setup.sh | 3 +- .../complex_types.sts | 1 + .../ets/variable_declaretion_neg_1.sts | 1 - .../annotationDecl_enum_conflict.sts | 12 +- .../annotationUsage_bad_param_for_lambda.sts | 3 +- ets2panda/test/ast/parser/ets/enum10.sts | 7 +- ets2panda/test/ast/parser/ets/enum12.sts | 6 +- ets2panda/test/ast/parser/ets/enum13.sts | 13 +- ets2panda/test/ast/parser/ets/enum14.sts | 6 +- ets2panda/test/ast/parser/ets/enum20.sts | 10 +- ets2panda/test/ast/parser/ets/enum22.sts | 2 + ets2panda/test/ast/parser/ets/enum23.sts | 2 + ets2panda/test/ast/parser/ets/enum6.sts | 4 +- ets2panda/test/ast/parser/ets/enum7.sts | 4 +- ets2panda/test/ast/parser/ets/enum9.sts | 7 +- .../switch_readonly_member_different_enum.sts | 4 +- .../ets/switch_readonly_member_enum.sts | 9 +- .../switch_readonly_member_enum_duplicate.sts | 7 +- .../ast/parser/ets/unexpected_token_43.sts | 4 +- ...as_class_member_getValue_call-expected.txt | 11758 ++++++++-------- .../ets/import_tests/enum_export-expected.txt | 10367 ++++++-------- .../test/parser/ets/declare_enum-expected.txt | 1403 +- .../ets/switch_enum_string_case-expected.txt | 4943 ++++--- ets2panda/test/runtime/ets/Enum3.sts | 6 +- ets2panda/test/runtime/ets/Enum4.sts | 26 +- ets2panda/test/runtime/ets/Enum5.sts | 48 +- ets2panda/test/runtime/ets/Enum8.sts | 99 + .../runtime/ets/enum_as_expression_cast.sts | 4 +- .../ets/enum_as_type_alias.sts | 7 +- .../test/runtime/ets/enum_getOrdinal.sts | 24 + ets2panda/test/runtime/ets/enum_namespace.sts | 41 + ets2panda/test/runtime/ets/enum_reference.sts | 21 + ets2panda/test/runtime/ets/enum_switch.sts | 36 + ets2panda/test/runtime/ets/enum_union.sts | 66 + .../declgen-ets2ts-runtime-ignored.txt | 2 + ets2panda/test/unit/lsp/classifier_test.cpp | 3 +- ets2panda/test/unit/lsp/get_completions.cpp | 26 - ets2panda/test/unit/lsp/lsp_rename_test.cpp | 17 - ets2panda/test/unit/lsp/quick_info_test.cpp | 95 +- .../plugin_conversion_rule_part_iv.cpp | 19 - 92 files changed, 14456 insertions(+), 17271 deletions(-) create mode 100644 ets2panda/test/runtime/ets/Enum8.sts rename ets2panda/test/{ast/compiler => runtime}/ets/enum_as_type_alias.sts (75%) create mode 100644 ets2panda/test/runtime/ets/enum_getOrdinal.sts create mode 100644 ets2panda/test/runtime/ets/enum_namespace.sts create mode 100644 ets2panda/test/runtime/ets/enum_reference.sts create mode 100644 ets2panda/test/runtime/ets/enum_switch.sts create mode 100644 ets2panda/test/runtime/ets/enum_union.sts diff --git a/ets2panda/ast_verifier/variableNameIdentifierNameSame.cpp b/ets2panda/ast_verifier/variableNameIdentifierNameSame.cpp index 760994d887..7d321b3330 100644 --- a/ets2panda/ast_verifier/variableNameIdentifierNameSame.cpp +++ b/ets2panda/ast_verifier/variableNameIdentifierNameSame.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 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 @@ -15,7 +15,6 @@ #include "variableNameIdentifierNameSame.h" #include "ir/expressions/identifier.h" -#include "checker/types/ets/etsEnumType.h" #include "ir/expressions/memberExpression.h" #include "ir/ets/etsImportDeclaration.h" @@ -55,16 +54,6 @@ namespace ark::es2panda::compiler::ast_verifier { parent = parent->Parent(); } - parent = id->Parent(); - if (parent->IsMemberExpression() && parent->AsMemberExpression()->Object()->TsType()->IsETSStringEnumType()) { - const bool isValueOfMethod = (id->Name() == checker::ETSEnumType::VALUE_OF_METHOD_NAME); - const bool isToStringMethod = (variable->Name() == checker::ETSEnumType::TO_STRING_METHOD_NAME); - if (isValueOfMethod && isToStringMethod) { - // For string enums valueOf method calls toString method - return {CheckDecision::CORRECT, CheckAction::CONTINUE}; - } - } - AddCheckMessage("IDENTIFIER_NAME_DIFFERENCE", *id); return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; } diff --git a/ets2panda/checker/ETSAnalyzer.cpp b/ets2panda/checker/ETSAnalyzer.cpp index e6a94d951b..9316a14208 100644 --- a/ets2panda/checker/ETSAnalyzer.cpp +++ b/ets2panda/checker/ETSAnalyzer.cpp @@ -1612,22 +1612,6 @@ static void TypeErrorOnMissingProperty(ir::MemberExpression *expr, checker::Type expr->Object()->Start()); } -checker::Type *ETSAnalyzer::CheckEnumMemberExpression(ETSEnumType *const baseType, - ir::MemberExpression *const expr) const -{ - ETSChecker *checker = GetETSChecker(); - auto *const boxedClass = baseType->GetDecl()->BoxedClass(); - if (!boxedClass->IsClassDefinitionChecked()) { - // Check enum class first to set types and build signatures - checker->CheckClassDefinition(boxedClass); - } - - auto [memberType, memberVar] = expr->ResolveEnumMember(checker, baseType); - expr->SetPropVar(memberVar); - expr->Property()->SetTsType(memberType == nullptr ? checker->GlobalTypeError() : memberType); - return expr->AdjustType(checker, expr->Property()->TsType()); -} - checker::Type *ETSAnalyzer::ResolveMemberExpressionByBaseType(ETSChecker *checker, checker::Type *baseType, ir::MemberExpression *expr) const { @@ -1653,11 +1637,6 @@ checker::Type *ETSAnalyzer::ResolveMemberExpressionByBaseType(ETSChecker *checke checker, expr, expr->SetAndAdjustType(checker, baseType->AsETSObjectType()))); } - // NOTE(vpukhov): #20510 member access - if (baseType->IsETSEnumType()) { - return CheckEnumMemberExpression(baseType->AsETSEnumType(), expr); - } - if (baseType->IsETSUnionType()) { return expr->AdjustType(checker, expr->CheckUnionMember(checker, baseType)); } @@ -1986,10 +1965,6 @@ static checker::Type *GetTypeOfStringType(checker::Type *argType, ETSChecker *ch case TypeFlag::FLOAT: case TypeFlag::DOUBLE: return checker->CreateETSStringLiteralType("number"); - case TypeFlag::ETS_INT_ENUM: - return checker->CreateETSStringLiteralType(argType == unboxed ? "number" : "object"); - case TypeFlag::ETS_STRING_ENUM: - return checker->CreateETSStringLiteralType(argType == unboxed ? "string" : "object"); default: UNREACHABLE(); } @@ -2000,7 +1975,7 @@ static checker::Type *GetTypeOfStringType(checker::Type *argType, ETSChecker *ch if (argType->IsETSArrayType() || argType->IsETSNullType()) { return checker->CreateETSStringLiteralType("object"); } - if (argType->IsETSStringType() || argType->IsETSStringEnumType()) { + if (argType->IsETSStringType()) { return checker->CreateETSStringLiteralType("string"); } if (argType->IsETSBigIntType()) { @@ -2009,7 +1984,12 @@ static checker::Type *GetTypeOfStringType(checker::Type *argType, ETSChecker *ch if (argType->IsETSFunctionType()) { return checker->CreateETSStringLiteralType("function"); } - + if (argType->IsETSIntEnumType()) { + return checker->CreateETSStringLiteralType("number"); + } + if (argType->IsETSStringEnumType()) { + return checker->CreateETSStringLiteralType("string"); + } return checker->GlobalBuiltinETSStringType(); } @@ -2990,35 +2970,8 @@ checker::Type *ETSAnalyzer::Check(ir::TSAsExpression *expr) const checker::Type *ETSAnalyzer::Check(ir::TSEnumDeclaration *st) const { - ETSChecker *checker = GetETSChecker(); - varbinder::Variable *enumVar = st->Key()->Variable(); - if (enumVar == nullptr) { - ES2PANDA_ASSERT(checker->IsAnyError()); - return st->SetTsType(checker->GlobalTypeError()); - } - - if (enumVar->TsType() == nullptr) { - if (st->BoxedClass() == nullptr) { - ES2PANDA_ASSERT(checker->IsAnyError()); - enumVar->SetTsType(checker->GlobalTypeError()); - return st->SetTsType(checker->GlobalTypeError()); - } - - st->BoxedClass()->Check(checker); - if (auto *const itemInit = st->Members().front()->AsTSEnumMember()->Init(); itemInit->IsNumberLiteral()) { - checker->CreateEnumIntTypeFromEnumDeclaration(st); - } else if (itemInit->IsStringLiteral()) { - checker->CreateEnumStringTypeFromEnumDeclaration(st); - } else { - checker->LogError(diagnostic::ENUM_TYPE_INVALID, {}, st->Start()); - enumVar->SetTsType(checker->GlobalTypeError()); - st->SetTsType(checker->GlobalTypeError()); - } - } else if (st->TsType() == nullptr) { - st->SetTsType(enumVar->TsType()); - } - - return st->TsType(); + // Some invalid TSEnumDeclaration will not be transformed to class. + return ReturnTypeForStatement(st); } checker::Type *ETSAnalyzer::Check(ir::TSInterfaceDeclaration *st) const diff --git a/ets2panda/checker/ETSAnalyzer.h b/ets2panda/checker/ETSAnalyzer.h index 73bbaf3e27..28e145066b 100644 --- a/ets2panda/checker/ETSAnalyzer.h +++ b/ets2panda/checker/ETSAnalyzer.h @@ -62,7 +62,6 @@ private: ETSChecker *checker) const; void CheckClassProperty(ETSChecker *checker, ir::ScriptFunction *scriptFunc) const; - checker::Type *CheckEnumMemberExpression(ETSEnumType *const baseType, ir::MemberExpression *const expr) const; checker::Type *ResolveMemberExpressionByBaseType(ETSChecker *checker, checker::Type *baseType, ir::MemberExpression *expr) const; diff --git a/ets2panda/checker/ETSAnalyzerHelpers.cpp b/ets2panda/checker/ETSAnalyzerHelpers.cpp index fb2d13300a..e917c2ec5e 100644 --- a/ets2panda/checker/ETSAnalyzerHelpers.cpp +++ b/ets2panda/checker/ETSAnalyzerHelpers.cpp @@ -28,7 +28,7 @@ static bool IsValidReceiverParameter(Type *const thisType) return true; } - if (!thisType->IsETSObjectType()) { + if (!thisType->IsETSObjectType() || thisType->IsETSEnumType()) { return false; } @@ -544,7 +544,9 @@ void ProcessExclamationMark(ETSChecker *checker, ir::UnaryExpression *expr, chec expr->SetTsType(tsType); return; } - + if (operandType->IsETSEnumType()) { + expr->Argument()->AddAstNodeFlags(ir::AstNodeFlags::GENERATE_VALUE_OF); + } expr->SetTsType(checker->GlobalETSBooleanType()); } diff --git a/ets2panda/checker/ETSchecker.h b/ets2panda/checker/ETSchecker.h index fd22b11a7d..7ac9bd90bc 100644 --- a/ets2panda/checker/ETSchecker.h +++ b/ets2panda/checker/ETSchecker.h @@ -276,9 +276,6 @@ public: ETSBigIntType *CreateETSBigIntLiteralType(util::StringView value); ETSStringType *CreateETSStringLiteralType(util::StringView value); ETSArrayType *CreateETSArrayType(Type *elementType, bool isCachePolluting = false); - ETSIntEnumType *CreateEnumIntTypeFromEnumDeclaration(ir::TSEnumDeclaration *const enumDecl); - ETSStringEnumType *CreateEnumStringTypeFromEnumDeclaration(ir::TSEnumDeclaration *const enumDecl); - Type *CreateETSUnionType(Span constituentTypes); template Type *CreateETSUnionType(Type *const (&arr)[N]) // NOLINT(modernize-avoid-c-arrays) @@ -331,6 +328,10 @@ public: checker::Type *CheckBinaryOperatorMulDivMod( std::tuple op, bool isEqualOp, std::tuple types); + checker::Type *CheckBinaryOperatorForIntEnums(const checker::Type *const leftType, + const checker::Type *const rightType); + checker::Type *CheckBinaryBitwiseOperatorForIntEnums(const checker::Type *const leftType, + const checker::Type *const rightType); checker::Type *CheckBinaryOperatorPlusForEnums(const checker::Type *const leftType, const checker::Type *const rightType); checker::Type *CheckBinaryOperatorPlus( @@ -532,7 +533,6 @@ public: const ir::TSTypeParameterInstantiation *typeParams); static ir::TypeNode *ResolveTypeNodeForTypeArg(const ir::TSTypeAliasDeclaration *typeAliasNode, const ir::TSTypeParameterInstantiation *typeParams, size_t idx); - Type *GetTypeFromEnumReference(varbinder::Variable *var); Type *GetTypeFromTypeParameterReference(varbinder::LocalVariable *var, const lexer::SourcePosition &pos); Type *GetNonConstantType(Type *type); bool IsNullLikeOrVoidExpression(const ir::Expression *expr) const; @@ -804,9 +804,6 @@ public: void CollectReturnStatements(ir::AstNode *parent); ir::ETSParameterExpression *AddParam(util::StringView name, ir::TypeNode *type); - [[nodiscard]] ir::ScriptFunction *FindFunction(ir::TSEnumDeclaration const *const enumDecl, - const std::string_view &name); - evaluate::ScopedDebugInfoPlugin *GetDebugInfoPlugin(); const evaluate::ScopedDebugInfoPlugin *GetDebugInfoPlugin() const; @@ -844,9 +841,6 @@ public: } private: - ETSEnumType::Method MakeMethod(ir::TSEnumDeclaration const *const enumDecl, const std::string_view &name, - bool buildPorxyParam, Type *returnType, bool buildProxy = true); - std::pair GetTargetIdentifierAndType(ir::Identifier *ident); void NotResolvedError(ir::Identifier *const ident, const varbinder::Variable *classVar, const ETSObjectType *classType); diff --git a/ets2panda/checker/ets/arithmetic.cpp b/ets2panda/checker/ets/arithmetic.cpp index 5f42dd946a..9f7ccf3ed7 100644 --- a/ets2panda/checker/ets/arithmetic.cpp +++ b/ets2panda/checker/ets/arithmetic.cpp @@ -15,6 +15,7 @@ #include "arithmetic.h" +#include "checker/types/ts/nullType.h" #include "lexer/token/token.h" namespace ark::es2panda::checker { @@ -106,11 +107,26 @@ static Type *EffectiveTypeOfNumericOp(ETSChecker *checker, Type *left, Type *rig return checker->GlobalIntType(); } +static Type *TryConvertToPrimitiveType(ETSChecker *checker, Type *type) +{ + if (type == nullptr) { + return nullptr; + } + + if (type->IsETSIntEnumType()) { + return checker->GlobalIntType(); + } + if (type->IsETSStringEnumType()) { + return checker->GlobalETSStringLiteralType(); + } + return checker->MaybeUnboxInRelation(type); +} + static std::pair BinaryCoerceToPrimitives(ETSChecker *checker, Type *left, Type *right, bool const promote) { - Type *const unboxedL = checker->MaybeUnboxInRelation(left); - Type *const unboxedR = checker->MaybeUnboxInRelation(right); + Type *const unboxedL = TryConvertToPrimitiveType(checker, left); + Type *const unboxedR = TryConvertToPrimitiveType(checker, right); if (unboxedL == nullptr || unboxedR == nullptr) { return {nullptr, false}; } @@ -121,14 +137,6 @@ static std::pair BinaryCoerceToPrimitives(ETSChecker *checker, Typ return {unboxedR, bothConst}; } - if (unboxedL->IsETSEnumType() && unboxedR->IsETSEnumType()) { - if (!unboxedL->AsETSEnumType()->IsSameEnumType(unboxedR->AsETSEnumType())) { - return {nullptr, bothConst}; - } - return {unboxedL->IsETSIntEnumType() ? checker->GlobalIntType() : checker->GlobalBuiltinETSStringType(), - bothConst}; - } - if (unboxedL->HasTypeFlag(TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC) && unboxedR->HasTypeFlag(TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC)) { return {EffectiveTypeOfNumericOp(checker, unboxedL, unboxedR), bothConst}; @@ -318,6 +326,10 @@ checker::Type *ETSChecker::CheckBinaryOperatorMulDivMod( if (promotedType == nullptr || !unboxedL->HasTypeFlag(TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC) || !unboxedR->HasTypeFlag(TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC)) { + auto type = CheckBinaryOperatorForIntEnums(leftType, rightType); + if (type != nullptr) { + return type; + } LogError(diagnostic::OP_NONNUMERIC, {}, pos); return GlobalTypeError(); } @@ -329,8 +341,8 @@ checker::Type *ETSChecker::CheckBinaryOperatorMulDivMod( return (tsType != nullptr) ? tsType : promotedType; } -checker::Type *ETSChecker::CheckBinaryOperatorPlusForEnums(const checker::Type *const leftType, - const checker::Type *const rightType) +checker::Type *ETSChecker::CheckBinaryOperatorForIntEnums(const checker::Type *const leftType, + const checker::Type *const rightType) { if (leftType->HasTypeFlag(TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC) && rightType->HasTypeFlag(TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC)) { @@ -340,11 +352,45 @@ checker::Type *ETSChecker::CheckBinaryOperatorPlusForEnums(const checker::Type * if (leftType->IsFloatType() || rightType->IsFloatType()) { return GlobalFloatType(); } + if (leftType->IsDoubleType() || rightType->IsDoubleType()) { + return GlobalDoubleType(); + } + if (leftType->IsLongType() || rightType->IsLongType()) { + return GlobalLongType(); + } + return GlobalIntType(); + } + return nullptr; +} + +checker::Type *ETSChecker::CheckBinaryBitwiseOperatorForIntEnums(const checker::Type *const leftType, + const checker::Type *const rightType) +{ + if (leftType->HasTypeFlag(TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC) && + rightType->HasTypeFlag(TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC)) { + if (leftType->IsETSIntEnumType() && rightType->IsETSIntEnumType()) { + return GlobalIntType(); + } + if (leftType->IsFloatType() || rightType->IsFloatType()) { + return GlobalIntType(); + } + if (leftType->IsDoubleType() || rightType->IsDoubleType()) { + return GlobalLongType(); + } if (leftType->IsLongType() || rightType->IsLongType()) { return GlobalLongType(); } return GlobalIntType(); } + return nullptr; +} + +checker::Type *ETSChecker::CheckBinaryOperatorPlusForEnums(const checker::Type *const leftType, + const checker::Type *const rightType) +{ + if (auto numericType = CheckBinaryOperatorForIntEnums(leftType, rightType); numericType != nullptr) { + return numericType; + } if ((leftType->IsETSStringEnumType() && (rightType->IsETSStringType() || rightType->IsETSStringEnumType())) || (rightType->IsETSStringEnumType() && (leftType->IsETSStringType() || leftType->IsETSStringEnumType()))) { return GlobalETSStringLiteralType(); @@ -401,6 +447,33 @@ checker::Type *ETSChecker::CheckBinaryOperatorPlus( return promotedType; } +static checker::Type *GetBitwiseCompatibleType(ETSChecker *checker, Type *const type) +{ + switch (checker->ETSType(type)) { + case TypeFlag::BYTE: { + return checker->GlobalByteType(); + } + case TypeFlag::SHORT: { + return checker->GlobalShortType(); + } + case TypeFlag::CHAR: { + return checker->GlobalCharType(); + } + case TypeFlag::INT: + case TypeFlag::FLOAT: { + return checker->GlobalIntType(); + } + case TypeFlag::LONG: + case TypeFlag::DOUBLE: { + return checker->GlobalLongType(); + } + default: { + UNREACHABLE(); + } + } + return nullptr; +} + checker::Type *ETSChecker::CheckBinaryOperatorShift( std::tuple op, bool isEqualOp, std::tuple types) @@ -427,6 +500,10 @@ checker::Type *ETSChecker::CheckBinaryOperatorShift( if (promotedLeftType == nullptr || !promotedLeftType->HasTypeFlag(checker::TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC) || promotedRightType == nullptr || !promotedRightType->HasTypeFlag(checker::TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC)) { + auto type = CheckBinaryBitwiseOperatorForIntEnums(leftType, rightType); + if (type != nullptr) { + return type; + } LogError(diagnostic::OP_NONNUMERIC, {}, pos); return GlobalTypeError(); } @@ -434,30 +511,7 @@ checker::Type *ETSChecker::CheckBinaryOperatorShift( if (promotedLeftType->HasTypeFlag(TypeFlag::CONSTANT) && promotedRightType->HasTypeFlag(TypeFlag::CONSTANT)) { return HandleBitwiseOperationOnTypes(promotedLeftType, promotedRightType, operationType); } - - switch (ETSType(promotedLeftType)) { - case TypeFlag::BYTE: { - return GlobalByteType(); - } - case TypeFlag::SHORT: { - return GlobalShortType(); - } - case TypeFlag::CHAR: { - return GlobalCharType(); - } - case TypeFlag::INT: - case TypeFlag::FLOAT: { - return GlobalIntType(); - } - case TypeFlag::LONG: - case TypeFlag::DOUBLE: { - return GlobalLongType(); - } - default: { - UNREACHABLE(); - } - } - return nullptr; + return GetBitwiseCompatibleType(this, promotedLeftType); } checker::Type *ETSChecker::CheckBinaryOperatorBitwise( @@ -491,6 +545,10 @@ checker::Type *ETSChecker::CheckBinaryOperatorBitwise( if (promotedType == nullptr || !unboxedL->HasTypeFlag(TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC) || !unboxedR->HasTypeFlag(TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC)) { + auto type = CheckBinaryBitwiseOperatorForIntEnums(leftType, rightType); + if (type != nullptr) { + return type; + } LogError(diagnostic::OP_NONNUMERIC, {}, pos); return GlobalTypeError(); } @@ -511,12 +569,12 @@ checker::Type *ETSChecker::CheckBinaryOperatorLogical(ir::Expression *left, ir:: if (leftType->IsTypeError()) { // both are errors return GlobalTypeError(); } + // Don't do any boxing for primitive type when another operand is Enum. Enum will become primitive type later. if (leftType->IsETSEnumType() || rightType->IsETSEnumType()) { left->RemoveAstNodeFlags(ir::AstNodeFlags::GENERATE_VALUE_OF); right->RemoveAstNodeFlags(ir::AstNodeFlags::GENERATE_VALUE_OF); return CreateETSUnionType({MaybeBoxExpression(left), MaybeBoxExpression(right)}); } - if (right->IsNumberLiteral() && AdjustNumberLiteralType(right->AsNumberLiteral(), rightType, leftType)) { return leftType; } @@ -587,7 +645,8 @@ bool ETSChecker::CheckValidEqualReferenceType(checker::Type *const leftType, che } } - return true; + // 7.24.5 Enumeration Relational Operators + return leftType->IsETSEnumType() == rightType->IsETSEnumType(); } std::tuple ETSChecker::CheckBinaryOperatorStrictEqual(ir::Expression *left, @@ -656,6 +715,10 @@ static Type *HandelReferenceBinaryEquality(ETSChecker *checker, BinaryArithmOper (typeL->IsETSNullType() && typeR->IsETSPrimitiveType())) { return checker->CreateETSUnionType({typeL, typeR}); } + // Do not comparing reference equality for enum. + if (typeL->IsETSEnumType() && typeR->IsETSEnumType()) { + return nullptr; + } if (typeL->IsETSReferenceType() && typeR->IsETSReferenceType()) { checker->Relation()->SetNode(expr->Left()); @@ -684,7 +747,6 @@ static Type *CheckBinaryOperatorEqual(ETSChecker *checker, BinaryArithmOperands expr->Left()->RemoveAstNodeFlags(ir::AstNodeFlags::GENERATE_VALUE_OF); expr->Right()->RemoveAstNodeFlags(ir::AstNodeFlags::GENERATE_VALUE_OF); - if (typeL->IsTypeError()) { // both are errors return checker->GlobalTypeError(); } @@ -693,16 +755,6 @@ static Type *CheckBinaryOperatorEqual(ETSChecker *checker, BinaryArithmOperands return CheckOperatorEqualDynamic(checker, ops); } - if (reducedL->IsETSEnumType() && reducedR->IsETSEnumType()) { - if (!reducedL->AsETSEnumType()->IsSameEnumType(reducedR->AsETSEnumType())) { - // We still know that operation result should be boolean, so recover. - checker->LogError(diagnostic::BINOP_MISMATCHED_ENUMS, {}, expr->Start()); - return reducedL; - } - UnboxOperands(checker, ops); - return reducedL; - } - if (reducedL->IsETSBooleanType() && reducedR->IsETSBooleanType()) { if (reducedL->IsConstantType() && reducedR->IsConstantType()) { bool res = reducedL->AsETSBooleanType()->GetValue() == reducedR->AsETSBooleanType()->GetValue(); @@ -721,9 +773,21 @@ static bool NonNumericTypesAreAppropriateForComparison(ETSChecker *checker, Type { leftType = checker->MaybeUnboxType(leftType); rightType = checker->MaybeUnboxType(rightType); - return (rightType->IsETSStringType() && leftType->IsETSStringType()) || - (leftType->IsETSEnumType() && rightType->IsETSEnumType() && - leftType->AsETSEnumType()->IsSameEnumType(rightType->AsETSEnumType())); + if (rightType->IsETSStringType() && leftType->IsETSStringType()) { + return true; + } + if (leftType->IsETSEnumType() && rightType->IsETSEnumType()) { + return checker->Relation()->IsIdenticalTo(leftType, rightType); + } + if ((leftType->IsETSStringEnumType() && rightType->IsETSStringType()) || + (leftType->IsETSStringType() && rightType->IsETSStringEnumType())) { + return true; + } + if ((leftType->IsETSPrimitiveType() && rightType->IsETSIntEnumType()) || + (leftType->IsETSIntEnumType() && rightType->IsETSPrimitiveType())) { + return true; + } + return false; } std::tuple ETSChecker::CheckBinaryOperatorLessGreater(ir::Expression *left, ir::Expression *right, @@ -783,10 +847,6 @@ std::tuple ETSChecker::CheckBinaryOperatorInstanceOf(lexer::Sour return {GlobalETSBooleanType(), GlobalTypeError()}; } - // NOTE(vpukhov): #20510 lowering - if (rightType->IsETSEnumType()) { - rightType = MaybeBoxType(rightType); - } if (!IsReferenceType(leftType) || !IsReferenceType(rightType)) { LogError(diagnostic::BINOP_NOT_SAME, {}, pos); return {GlobalETSBooleanType(), leftType}; @@ -807,7 +867,7 @@ std::tuple ETSChecker::CheckBinaryOperatorInstanceOf(lexer::Sour bool ETSChecker::AdjustNumberLiteralType(ir::NumberLiteral *const literal, Type *literalType, Type *const otherType) { - if (otherType->IsETSObjectType()) { + if (otherType->IsETSObjectType() && !otherType->IsETSEnumType()) { auto *const objectType = otherType->AsETSObjectType(); if (objectType->HasObjectFlag(ETSObjectFlags::BUILTIN_TYPE) && !objectType->IsETSStringType()) { literal->RemoveBoxingUnboxingFlags(GetBoxingFlag(literalType)); @@ -1008,8 +1068,12 @@ bool CheckNumericOperatorContext(ir::Expression *expression, lexer::TokenType op void CheckStringOperatorContext(ir::Expression *expression, checker::Type *otherType, lexer::TokenType op) { + const bool isEquality = op == lexer::TokenType::PUNCTUATOR_EQUAL || op == lexer::TokenType::PUNCTUATOR_NOT_EQUAL; + const bool isRelational = + op == lexer::TokenType::PUNCTUATOR_GREATER_THAN || op == lexer::TokenType::PUNCTUATOR_GREATER_THAN_EQUAL || + op == lexer::TokenType::PUNCTUATOR_LESS_THAN || op == lexer::TokenType::PUNCTUATOR_LESS_THAN_EQUAL; if (IsStringEnum(expression) && (otherType->IsETSStringType() || otherType->IsETSStringEnumType())) { - if (op == lexer::TokenType::PUNCTUATOR_PLUS) { + if (op == lexer::TokenType::PUNCTUATOR_PLUS || isRelational || isEquality) { expression->AddAstNodeFlags(ir::AstNodeFlags::GENERATE_VALUE_OF); } } @@ -1202,12 +1266,13 @@ Type *ETSChecker::HandleBitwiseOperationOnTypes(Type *left, Type *right, lexer:: void ETSChecker::FlagExpressionWithUnboxing(Type *type, Type *unboxedType, ir::Expression *typeExpression) { + if (type->IsETSEnumType()) { + typeExpression->AddAstNodeFlags(ir::AstNodeFlags::GENERATE_VALUE_OF); + return; + } if (type->IsETSObjectType() && (unboxedType != nullptr)) { typeExpression->AddBoxingUnboxingFlags(GetUnboxingFlag(unboxedType)); } - if (unboxedType != nullptr && unboxedType->IsETSEnumType()) { - typeExpression->AddAstNodeFlags(ir::AstNodeFlags::GENERATE_VALUE_OF); - } } } // namespace ark::es2panda::checker diff --git a/ets2panda/checker/ets/boxingConverter.cpp b/ets2panda/checker/ets/boxingConverter.cpp index 7466956537..b0f1361a50 100644 --- a/ets2panda/checker/ets/boxingConverter.cpp +++ b/ets2panda/checker/ets/boxingConverter.cpp @@ -42,9 +42,6 @@ checker::ETSObjectType *BoxingConverter::Convert(ETSChecker const *checker, Type return typeHolder->GlobalFloatBuiltinType()->AsETSObjectType(); case checker::TypeFlag::DOUBLE: return typeHolder->GlobalDoubleBuiltinType()->AsETSObjectType(); - case checker::TypeFlag::ETS_INT_ENUM: - case checker::TypeFlag::ETS_STRING_ENUM: - return source->AsETSEnumType()->BoxedType()->AsETSObjectType(); default: UNREACHABLE(); } diff --git a/ets2panda/checker/ets/boxingConverter.h b/ets2panda/checker/ets/boxingConverter.h index 7d12dd5eb7..1adaa2493f 100644 --- a/ets2panda/checker/ets/boxingConverter.h +++ b/ets2panda/checker/ets/boxingConverter.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - 2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 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 diff --git a/ets2panda/checker/ets/helpers.cpp b/ets2panda/checker/ets/helpers.cpp index 70e5ade533..7b3f9215c6 100644 --- a/ets2panda/checker/ets/helpers.cpp +++ b/ets2panda/checker/ets/helpers.cpp @@ -22,6 +22,7 @@ #include "compiler/lowering/scopesInit/scopesInitPhase.h" #include "compiler/lowering/util.h" #include "utils/arena_containers.h" +#include "util/ustring.h" namespace ark::es2panda::checker { varbinder::Variable *ETSChecker::FindVariableInFunctionScope(const util::StringView name, @@ -402,7 +403,7 @@ std::tuple ETSChecker::IsResolvedAndValue(const ir::Expression *expr IsNullLikeOrVoidExpression(expr) ? std::make_tuple(true, false) : type->ResolveConditionExpr(); const Type *tsType = expr->TsType(); - if (tsType->DefinitelyNotETSNullish() && !type->IsETSPrimitiveType()) { + if (tsType->DefinitelyNotETSNullish() && !type->IsETSPrimitiveOrEnumType()) { isResolve = true; isValue = true; } @@ -473,7 +474,19 @@ bool ETSChecker::HandleLogicalPotentialResult(ir::Expression *left, ir::Expressi void ETSChecker::ResolveReturnStatement(checker::Type *funcReturnType, checker::Type *argumentType, ir::ScriptFunction *containingFunc, ir::ReturnStatement *st) { - if (funcReturnType->IsETSReferenceType() || argumentType->IsETSReferenceType()) { + if (funcReturnType->IsETSPrimitiveOrEnumType() && argumentType->IsETSPrimitiveOrEnumType()) { + // function return type is of primitive type (including enums): + Relation()->SetFlags(checker::TypeRelationFlag::DIRECT_RETURN | + checker::TypeRelationFlag::IN_ASSIGNMENT_CONTEXT | + checker::TypeRelationFlag::ASSIGNMENT_CONTEXT); + if (Relation()->IsAssignableTo(funcReturnType, argumentType)) { + funcReturnType = argumentType; + containingFunc->Signature()->SetReturnType(funcReturnType); + containingFunc->Signature()->AddSignatureFlag(checker::SignatureFlags::INFERRED_RETURN_TYPE); + } else if (!Relation()->IsAssignableTo(argumentType, funcReturnType)) { + LogError(diagnostic::RETURN_DIFFERENT_PRIM, {funcReturnType, argumentType}, st->Argument()->Start()); + } + } else if (funcReturnType->IsETSReferenceType() || argumentType->IsETSReferenceType()) { // function return type should be of reference (object) type Relation()->SetFlags(checker::TypeRelationFlag::NONE); @@ -497,18 +510,6 @@ void ETSChecker::ResolveReturnStatement(checker::Type *funcReturnType, checker:: containingFunc->Signature()->SetReturnType(funcReturnType); containingFunc->Signature()->AddSignatureFlag(checker::SignatureFlags::INFERRED_RETURN_TYPE); } - } else if (funcReturnType->IsETSPrimitiveType() && argumentType->IsETSPrimitiveType()) { - // function return type is of primitive type (including enums): - Relation()->SetFlags(checker::TypeRelationFlag::DIRECT_RETURN | - checker::TypeRelationFlag::IN_ASSIGNMENT_CONTEXT | - checker::TypeRelationFlag::ASSIGNMENT_CONTEXT); - if (Relation()->IsAssignableTo(funcReturnType, argumentType)) { - funcReturnType = argumentType; - containingFunc->Signature()->SetReturnType(funcReturnType); - containingFunc->Signature()->AddSignatureFlag(checker::SignatureFlags::INFERRED_RETURN_TYPE); - } else if (!Relation()->IsAssignableTo(argumentType, funcReturnType)) { - LogError(diagnostic::RETURN_DIFFERENT_PRIM, {funcReturnType, argumentType}, st->Argument()->Start()); - } } else { // Should never in this branch. UNREACHABLE(); @@ -1449,8 +1450,6 @@ Type *ETSChecker::ResolveReferencedType(varbinder::LocalVariable *refVar, const return GlobalTypeError(); } return GetTypeFromClassReference(refVar); - case ir::AstNodeType::TS_ENUM_DECLARATION: - return GetTypeFromEnumReference(refVar); case ir::AstNodeType::TS_TYPE_PARAMETER: return GetTypeFromTypeParameterReference(refVar, name->Start()); case ir::AstNodeType::TS_TYPE_ALIAS_DECLARATION: @@ -1706,8 +1705,8 @@ Type *ETSChecker::CheckSwitchDiscriminant(ir::Expression *discriminant) auto *discriminantType = GetNonConstantType(MaybeUnboxExpression(discriminant)); if (!discriminantType->HasTypeFlag(TypeFlag::VALID_SWITCH_TYPE)) { if (!(discriminantType->IsETSObjectType() && - discriminantType->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BUILTIN_STRING | - ETSObjectFlags::STRING | ETSObjectFlags::ENUM))) { + discriminantType->AsETSObjectType()->HasObjectFlag( + ETSObjectFlags::BUILTIN_STRING | ETSObjectFlags::STRING | ETSObjectFlags::ENUM_OBJECT))) { LogError(diagnostic::ENUM_INVALID_DISCRIMINANT, {discriminantType}, discriminant->Start()); } } @@ -1795,7 +1794,33 @@ bool IsConstantMemberOrIdentifierExpression(ir::Expression *expression) static bool IsValidSwitchType(checker::Type *caseType) { - return caseType->HasTypeFlag(checker::TypeFlag::VALID_SWITCH_TYPE) || caseType->IsETSStringType(); + return caseType->HasTypeFlag(checker::TypeFlag::VALID_SWITCH_TYPE) || caseType->IsETSStringType() || + caseType->IsETSEnumType(); +} + +void CheckEnumCaseUnqualified(ETSChecker *checker, ir::Expression const *const caseTest) +{ + if (!caseTest->IsMemberExpression()) { + checker->LogTypeError("Enum switch case must be unqualified name of an enum constant", caseTest->Start()); + return; + } + + auto caseMember = caseTest->AsMemberExpression(); + auto baseObject = caseMember->Object(); + + util::StringView enumName; + if (baseObject->IsIdentifier()) { + enumName = baseObject->AsIdentifier()->Name(); + } else if (baseObject->IsMemberExpression()) { + enumName = baseObject->AsMemberExpression()->Property()->AsIdentifier()->Name(); + } else { + checker->LogTypeError("Enum switch case must be unqualified name of an enum constant", caseTest->Start()); + } + + auto enumType = caseTest->TsType()->AsETSObjectType(); + if (enumName != enumType->Name()) { + checker->LogTypeError("Enum switch case must be unqualified name of an enum constant", caseTest->Start()); + } } void ETSChecker::CheckItemCasesConstant(ArenaVector const &cases) @@ -1809,7 +1834,9 @@ void ETSChecker::CheckItemCasesConstant(ArenaVector c if (caseType->HasTypeFlag(TypeFlag::TYPE_ERROR)) { continue; } + if (caseTest->TsType()->IsETSEnumType()) { + CheckEnumCaseUnqualified(this, caseTest); continue; } @@ -1826,19 +1853,28 @@ void ETSChecker::CheckItemCasesConstant(ArenaVector c } } -void CheckItemEnumType(ir::Expression const *const caseTest, ETSChecker *checker, ETSIntEnumType const *const type, - bool &isDup) +void CheckItemEnumType(ir::Expression const *const caseTest, ir::Expression const *const compareCaseTest, + ETSChecker *checker, bool &isDup) { - if (caseTest->TsType()->AsETSIntEnumType()->IsSameEnumLiteralType(type)) { - isDup = true; - checker->LogError(diagnostic::SWITCH_CASE_DUPLICATE, {}, caseTest->Start()); + // These case has logged error before, no need log error. + if (!caseTest->IsMemberExpression() || !compareCaseTest->IsMemberExpression()) { + return; + } + if (!caseTest->AsMemberExpression()->Object()->IsIdentifier() || + !compareCaseTest->AsMemberExpression()->Object()->IsIdentifier()) { + return; + } + if (caseTest->AsMemberExpression()->Object()->AsIdentifier()->Name() != + compareCaseTest->AsMemberExpression()->Object()->AsIdentifier()->Name()) { + return; } -} -void CheckItemStringEnumType(ir::Expression const *const caseTest, ETSChecker *checker, - ETSStringEnumType const *const type, bool &isDup) -{ - if (caseTest->TsType()->AsETSStringEnumType()->IsSameEnumLiteralType(type)) { + if (!caseTest->AsMemberExpression()->Property()->IsIdentifier() || + !compareCaseTest->AsMemberExpression()->Property()->IsIdentifier()) { + return; + } + if (caseTest->AsMemberExpression()->Property()->AsIdentifier()->Name() == + compareCaseTest->AsMemberExpression()->Property()->AsIdentifier()->Name()) { isDup = true; checker->LogError(diagnostic::SWITCH_CASE_DUPLICATE, {}, caseTest->Start()); } @@ -1856,14 +1892,8 @@ void ETSChecker::CheckItemCasesDuplicate(ArenaVector continue; } - if (caseTest->TsType()->IsETSIntEnumType()) { - CheckItemEnumType(caseTest, this, compareCaseTest->TsType()->AsETSIntEnumType(), isItemDuplicate); - continue; - } - - if (caseTest->TsType()->IsETSStringEnumType()) { - CheckItemStringEnumType(caseTest, this, compareCaseTest->TsType()->AsETSStringEnumType(), - isItemDuplicate); + if (caseTest->TsType()->IsETSEnumType() && compareCaseTest->TsType()->IsETSEnumType()) { + CheckItemEnumType(caseTest, compareCaseTest, this, isItemDuplicate); continue; } diff --git a/ets2panda/checker/ets/object.cpp b/ets2panda/checker/ets/object.cpp index 62e1094661..657c99eb3a 100644 --- a/ets2panda/checker/ets/object.cpp +++ b/ets2panda/checker/ets/object.cpp @@ -1802,7 +1802,7 @@ static bool ShouldRemoveStaticSearchFlag(const ir::MemberExpression *const membe if (object->IsMemberExpression()) { object = object->AsMemberExpression()->Property(); } - if (!object->IsIdentifier() || !object->AsIdentifier()->Variable() || + if (!object->IsIdentifier() || (object->AsIdentifier()->Variable() == nullptr) || object->AsIdentifier()->Variable()->HasFlag(varbinder::VariableFlags::INITIALIZED)) { return true; } @@ -1822,7 +1822,7 @@ PropertySearchFlags ETSChecker::GetSearchFlags(const ir::MemberExpression *const } if (targetRef != nullptr && - (targetRef->HasFlag(varbinder::VariableFlags::CLASS_OR_INTERFACE) || + (targetRef->HasFlag(varbinder::VariableFlags::CLASS_OR_INTERFACE_OR_ENUM) || // NOTE (DZ): need to investigate when and why `targetRef->TsType()->Variable()` can be `nullptr` // (see ast/parser/ets/union_static_method.sts) (targetRef->HasFlag(varbinder::VariableFlags::TYPE_ALIAS) && targetRef->TsType()->Variable() != nullptr && diff --git a/ets2panda/checker/ets/typeCheckingHelpers.cpp b/ets2panda/checker/ets/typeCheckingHelpers.cpp index 198a6b71ed..ed2be72a2c 100644 --- a/ets2panda/checker/ets/typeCheckingHelpers.cpp +++ b/ets2panda/checker/ets/typeCheckingHelpers.cpp @@ -67,6 +67,11 @@ void ETSChecker::CheckTruthinessOfType(ir::Expression *expr) if (conditionType->IsETSPrimitiveType()) { FlagExpressionWithUnboxing(testType, conditionType, expr); } + + // For T_S compatibility + if (conditionType->IsETSEnumType()) { + expr->AddAstNodeFlags(ir::AstNodeFlags::GENERATE_VALUE_OF); + } } bool ETSChecker::CheckNonNullish(ir::Expression const *expr) @@ -320,7 +325,7 @@ bool Type::IsETSMethodType() const TypeFlag::TYPE_ERROR | TypeFlag::ETS_NULL | TypeFlag::ETS_UNDEFINED | TypeFlag::ETS_OBJECT | TypeFlag::ETS_TYPE_PARAMETER | TypeFlag::WILDCARD | TypeFlag::ETS_NONNULLISH | TypeFlag::ETS_REQUIRED_TYPE_PARAMETER | TypeFlag::ETS_NEVER | TypeFlag::ETS_UNION | TypeFlag::ETS_ARRAY | - TypeFlag::FUNCTION | TypeFlag::ETS_PARTIAL_TYPE_PARAMETER | TypeFlag::ETS_TUPLE; + TypeFlag::FUNCTION | TypeFlag::ETS_PARTIAL_TYPE_PARAMETER | TypeFlag::ETS_TUPLE | TypeFlag::ETS_ENUM; // Issues if (type->IsETSVoidType()) { // NOTE(vpukhov): #19701 void refactoring @@ -337,14 +342,18 @@ bool Type::IsETSMethodType() const bool Type::IsETSPrimitiveType() const { - static constexpr TypeFlag ETS_PRIMITIVE = - TypeFlag::ETS_NUMERIC | TypeFlag::CHAR | TypeFlag::ETS_BOOLEAN | TypeFlag::ETS_ENUM; + static constexpr TypeFlag ETS_PRIMITIVE = TypeFlag::ETS_NUMERIC | TypeFlag::CHAR | TypeFlag::ETS_BOOLEAN; // Do not modify ES2PANDA_ASSERT(!HasTypeFlag(ETS_PRIMITIVE) == IsSaneETSReferenceType(this)); return HasTypeFlag(ETS_PRIMITIVE); } +bool Type::IsETSPrimitiveOrEnumType() const +{ + return IsETSPrimitiveType() || IsETSEnumType(); +} + bool Type::IsETSReferenceType() const { // Do not modify @@ -466,9 +475,6 @@ Type *ETSChecker::GetTypeFromVariableDeclaration(varbinder::Variable *const var) variableType = classDef->TsType(); break; } - - case varbinder::DeclType::ENUM_LITERAL: - [[fallthrough]]; case varbinder::DeclType::CONST: [[fallthrough]]; case varbinder::DeclType::READONLY: @@ -718,25 +724,6 @@ Type *ETSChecker::GetTypeFromClassReference(varbinder::Variable *var) return classType; } -Type *ETSChecker::GetTypeFromEnumReference([[maybe_unused]] varbinder::Variable *var) -{ - if (var->TsType() != nullptr) { - return var->TsType(); - } - - auto *const enumDecl = var->Declaration()->Node()->AsTSEnumDeclaration(); - if (enumDecl->BoxedClass()->TsType() == nullptr) { - BuildBasicClassProperties(enumDecl->BoxedClass()); - } - if (auto *const itemInit = enumDecl->Members().front()->AsTSEnumMember()->Init(); itemInit->IsNumberLiteral()) { - return CreateEnumIntTypeFromEnumDeclaration(enumDecl); - } else if (itemInit->IsStringLiteral()) { // NOLINT(readability-else-after-return) - return CreateEnumStringTypeFromEnumDeclaration(enumDecl); - } else { // NOLINT(readability-else-after-return) - return TypeError(var, "Invalid enumeration value type.", enumDecl->Start()); - } -} - Type *ETSChecker::GetTypeFromTypeParameterReference(varbinder::LocalVariable *var, const lexer::SourcePosition &pos) { ES2PANDA_ASSERT(var->Declaration()->Node()->IsTSTypeParameter()); @@ -1145,9 +1132,6 @@ ir::BoxingUnboxingFlags ETSChecker::GetBoxingFlag(Type *const boxingType) return ir::BoxingUnboxingFlags::BOX_TO_FLOAT; case TypeFlag::DOUBLE: return ir::BoxingUnboxingFlags::BOX_TO_DOUBLE; - case TypeFlag::ETS_INT_ENUM: - case TypeFlag::ETS_STRING_ENUM: - return ir::BoxingUnboxingFlags::BOX_TO_ENUM; default: UNREACHABLE(); } @@ -1173,9 +1157,6 @@ ir::BoxingUnboxingFlags ETSChecker::GetUnboxingFlag(Type const *const unboxingTy return ir::BoxingUnboxingFlags::UNBOX_TO_FLOAT; case TypeFlag::DOUBLE: return ir::BoxingUnboxingFlags::UNBOX_TO_DOUBLE; - case TypeFlag::ETS_INT_ENUM: - case TypeFlag::ETS_STRING_ENUM: - return ir::BoxingUnboxingFlags::UNBOX_TO_ENUM; default: UNREACHABLE(); } diff --git a/ets2panda/checker/ets/typeCreation.cpp b/ets2panda/checker/ets/typeCreation.cpp index 6ab02bbae8..a5ef57e129 100644 --- a/ets2panda/checker/ets/typeCreation.cpp +++ b/ets2panda/checker/ets/typeCreation.cpp @@ -15,6 +15,8 @@ #include "checker/ETSchecker.h" +#include "checker/types/ets/etsEnumType.h" +#include "checker/types/globalTypesHolder.h" #include "checker/types/ets/etsDynamicFunctionType.h" #include "checker/types/globalTypesHolder.h" #include "ir/statements/annotationDeclaration.h" @@ -117,175 +119,6 @@ ETSArrayType *ETSChecker::CreateETSArrayType(Type *elementType, bool isCachePoll return arrayType; } -namespace { -[[nodiscard]] checker::ETSFunctionType *MakeProxyFunctionType( - checker::ETSChecker *const checker, const util::StringView &name, - const std::initializer_list ¶ms, ir::ScriptFunction *const globalFunction, - checker::Type *const returnType) -{ - auto *const signatureInfo = checker->CreateSignatureInfo(); - signatureInfo->params.insert(signatureInfo->params.end(), params); - signatureInfo->minArgCount = signatureInfo->params.size(); - - auto *const signature = checker->CreateSignature(signatureInfo, returnType, globalFunction); - signature->SetInternalName(name); - signature->AddSignatureFlag(checker::SignatureFlags::PROXY); - - return checker->CreateETSMethodType(name, {{signature}, checker->Allocator()->Adapter()}); -} - -[[nodiscard]] checker::Signature *MakeGlobalSignature(checker::ETSChecker *const checker, - ir::ScriptFunction *const function, - checker::Type *const returnType) -{ - auto *const signatureInfo = checker->CreateSignatureInfo(); - signatureInfo->params.reserve(function->Params().size()); - for (const auto *const param : function->Params()) { - signatureInfo->params.push_back(param->AsETSParameterExpression()->Variable()->AsLocalVariable()); - } - signatureInfo->minArgCount = signatureInfo->params.size(); - - auto *const signature = checker->CreateSignature(signatureInfo, returnType, function); - signature->AddSignatureFlag(checker::SignatureFlags::PUBLIC | checker::SignatureFlags::STATIC); - function->SetSignature(signature); - - return signature; -} - -void SetTypesForScriptFunction(checker::ETSChecker *const checker, ir::ScriptFunction *function) -{ - for (auto *const p : function->Params()) { - auto *const param = p->AsETSParameterExpression(); - auto const paramType = param->TypeAnnotation()->Check(checker); - param->SetTsType(paramType); - param->Ident()->SetTsType(paramType); - param->Ident()->Variable()->SetTsType(paramType); - } -} - -} // namespace - -ETSEnumType::Method ETSChecker::MakeMethod(ir::TSEnumDeclaration const *const enumDecl, const std::string_view &name, - bool buildPorxyParam, Type *returnType, bool buildProxy) -{ - auto function = FindFunction(enumDecl, name); - if (function == nullptr) { - return {}; - } - - SetTypesForScriptFunction(this, function); - - if (buildPorxyParam) { - return {MakeGlobalSignature(this, function, returnType), - MakeProxyFunctionType( - this, name, {function->Params()[0]->AsETSParameterExpression()->Variable()->AsLocalVariable()}, - function, returnType)}; - } - return {MakeGlobalSignature(this, function, returnType), - buildProxy ? MakeProxyFunctionType(this, name, {}, function, returnType) : nullptr}; -} - -[[nodiscard]] ir::ScriptFunction *ETSChecker::FindFunction(ir::TSEnumDeclaration const *const enumDecl, - const std::string_view &name) -{ - if (enumDecl->BoxedClass() == nullptr) { - return nullptr; - } - - for (auto m : enumDecl->BoxedClass()->Body()) { - if (m->IsMethodDefinition()) { - if (m->AsMethodDefinition()->Id()->Name() == name) { - return m->AsMethodDefinition()->Function(); - } - } - } - return nullptr; -} - -template -// CC-OFFNXT(huge_method, G.FUN.01-CPP) solid logic -EnumType *ETSChecker::CreateEnumTypeFromEnumDeclaration(ir::TSEnumDeclaration const *const enumDecl) -{ - static_assert(std::is_same_v || std::is_same_v); - SavedCheckerContext savedContext(this, Context().Status(), Context().ContainingClass(), - Context().ContainingSignature()); - - varbinder::Variable *enumVar = enumDecl->Key()->Variable(); - ES2PANDA_ASSERT(enumVar != nullptr); - - checker::ETSEnumType::UType ordinal = -1; - auto *const enumType = Allocator()->New(enumDecl, ordinal++); - auto *const boxedEnumType = enumDecl->BoxedClass()->TsType(); - - enumType->SetVariable(enumVar); - enumVar->SetTsType(enumType); - - auto const getNameMethod = - MakeMethod(enumDecl, ETSEnumType::GET_NAME_METHOD_NAME, false, GlobalETSStringLiteralType()); - enumType->SetGetNameMethod(getNameMethod); - - auto getValueOfMethod = MakeMethod(enumDecl, ETSEnumType::GET_VALUE_OF_METHOD_NAME, true, enumType); - enumType->SetGetValueOfMethod(getValueOfMethod); - - auto const fromIntMethod = MakeMethod(enumDecl, ETSEnumType::FROM_INT_METHOD_NAME, false, enumType, false); - enumType->SetFromIntMethod(fromIntMethod); - - auto const boxedFromIntMethod = - MakeMethod(enumDecl, ETSEnumType::BOXED_FROM_INT_METHOD_NAME, false, boxedEnumType, false); - enumType->SetBoxedFromIntMethod(boxedFromIntMethod); - - auto const unboxMethod = MakeMethod(enumDecl, ETSEnumType::UNBOX_METHOD_NAME, false, enumType); - enumType->SetUnboxMethod(unboxMethod); - - auto const toStringMethod = - MakeMethod(enumDecl, ETSEnumType::TO_STRING_METHOD_NAME, false, GlobalETSStringLiteralType()); - enumType->SetToStringMethod(toStringMethod); - - ETSEnumType::Method valueOfMethod = toStringMethod; - if constexpr (std::is_same_v) { - valueOfMethod = MakeMethod(enumDecl, ETSEnumType::VALUE_OF_METHOD_NAME, false, GlobalIntType()); - } - enumType->SetValueOfMethod(valueOfMethod); - - auto const valuesMethod = - MakeMethod(enumDecl, ETSEnumType::VALUES_METHOD_NAME, false, CreateETSArrayType(enumType)); - enumType->SetValuesMethod(valuesMethod); - - for (auto *const member : enumType->GetMembers()) { - if (auto *const memberVar = member->AsTSEnumMember()->Key()->AsIdentifier()->Variable(); memberVar != nullptr) { - auto *const enumLiteralType = Allocator()->New(enumDecl, ordinal++, member->AsTSEnumMember()); - enumLiteralType->SetVariable(memberVar); - memberVar->SetTsType(enumLiteralType); - - enumLiteralType->SetGetNameMethod(getNameMethod); - enumLiteralType->SetGetValueOfMethod(getValueOfMethod); - enumLiteralType->SetFromIntMethod(fromIntMethod); - enumLiteralType->SetBoxedFromIntMethod(boxedFromIntMethod); - enumLiteralType->SetUnboxMethod(unboxMethod); - enumLiteralType->SetValueOfMethod(valueOfMethod); - enumLiteralType->SetToStringMethod(toStringMethod); - enumLiteralType->SetValuesMethod(valuesMethod); - } else { - ASSERT(IsAnyError()); - } - } - return enumType; -} - -ETSIntEnumType *ETSChecker::CreateEnumIntTypeFromEnumDeclaration(ir::TSEnumDeclaration *const enumDecl) -{ - auto etsEnumType = CreateEnumTypeFromEnumDeclaration(enumDecl); - enumDecl->SetTsType(etsEnumType); - return etsEnumType; -} - -ETSStringEnumType *ETSChecker::CreateEnumStringTypeFromEnumDeclaration(ir::TSEnumDeclaration *const enumDecl) -{ - auto etsEnumType = CreateEnumTypeFromEnumDeclaration(enumDecl); - enumDecl->SetTsType(etsEnumType); - return etsEnumType; -} - Type *ETSChecker::CreateETSUnionType(Span constituentTypes) { if (constituentTypes.empty()) { @@ -299,6 +132,7 @@ Type *ETSChecker::CreateETSUnionType(Span constituentTypes) if (newConstituentTypes.size() == 1) { return newConstituentTypes[0]; } + return Allocator()->New(this, std::move(newConstituentTypes)); } @@ -514,12 +348,17 @@ std::tuple ETSChecker::CheckForDynamicLang(ir::AstNode *declNode ETSObjectType *ETSChecker::CreateETSObjectType(ir::AstNode *declNode, ETSObjectFlags flags) { - if (declNode->IsClassDefinition() && (declNode->AsClassDefinition()->OrigEnumDecl() != nullptr)) { - flags |= ETSObjectFlags::BOXED_ENUM; - } - auto const [name, internalName] = GetObjectTypeDeclNames(declNode); + if (declNode->IsClassDefinition() && (declNode->AsClassDefinition()->IsEnumTransformed())) { + if (declNode->AsClassDefinition()->IsIntEnumTransformed()) { + return Allocator()->New(Allocator(), name, internalName, declNode, Relation()); + } else { + ES2PANDA_ASSERT(declNode->AsClassDefinition()->IsStringEnumTransformed()); + return Allocator()->New(Allocator(), name, internalName, declNode, Relation()); + } + } + if (auto [lang, hasDecl] = CheckForDynamicLang(declNode, internalName); lang.IsDynamic()) { return Allocator()->New(Allocator(), std::make_tuple(name, internalName, lang), std::make_tuple(declNode, flags, Relation()), hasDecl); diff --git a/ets2panda/checker/ets/unboxingConverter.cpp b/ets2panda/checker/ets/unboxingConverter.cpp index a98f951144..8c10b9170c 100644 --- a/ets2panda/checker/ets/unboxingConverter.cpp +++ b/ets2panda/checker/ets/unboxingConverter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 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 @@ -39,8 +39,6 @@ checker::Type *UnboxingConverter::Convert(checker::ETSChecker const *checker, ET return checker->GlobalFloatType(); case ETSObjectFlags::BUILTIN_DOUBLE: return checker->GlobalDoubleType(); - case ETSObjectFlags::BOXED_ENUM: - return type->GetDeclNode()->AsClassDefinition()->OrigEnumDecl()->TsType(); default: UNREACHABLE(); } diff --git a/ets2panda/checker/ets/validateHelpers.cpp b/ets2panda/checker/ets/validateHelpers.cpp index 6af16ea14b..68fca277ff 100644 --- a/ets2panda/checker/ets/validateHelpers.cpp +++ b/ets2panda/checker/ets/validateHelpers.cpp @@ -95,7 +95,9 @@ void ETSChecker::ValidateNewClassInstanceIdentifier(ir::Identifier *const ident) void ETSChecker::ValidateMemberIdentifier(ir::Identifier *const ident) { auto const resolved = ident->Variable(); - if (resolved->Declaration()->Node()->IsTSEnumDeclaration() && + // Handles Enum[enumVar] MemberExpression + if (resolved->Declaration()->Node()->IsClassDefinition() && + resolved->Declaration()->Node()->AsClassDefinition()->TsType()->IsETSEnumType() && ident->Parent()->AsMemberExpression()->HasMemberKind(ir::MemberExpressionKind::ELEMENT_ACCESS)) { return; } diff --git a/ets2panda/checker/types/ets/etsArrayType.cpp b/ets2panda/checker/types/ets/etsArrayType.cpp index db1b4d5ae4..5a52ef15c3 100644 --- a/ets2panda/checker/types/ets/etsArrayType.cpp +++ b/ets2panda/checker/types/ets/etsArrayType.cpp @@ -100,8 +100,8 @@ void ETSArrayType::AssignmentTarget(TypeRelation *relation, Type *source) return; } if (source->IsETSArrayType()) { - if (AsETSArrayType()->ElementType()->IsETSPrimitiveType() || - source->AsETSArrayType()->ElementType()->IsETSPrimitiveType()) { + if (ElementType()->IsETSPrimitiveOrEnumType() || + source->AsETSArrayType()->ElementType()->IsETSPrimitiveOrEnumType()) { return; } relation->IsAssignableTo(source->AsETSArrayType()->ElementType(), element_); diff --git a/ets2panda/checker/types/ets/etsEnumType.cpp b/ets2panda/checker/types/ets/etsEnumType.cpp index cf484970fe..6f9d01f6b4 100644 --- a/ets2panda/checker/types/ets/etsEnumType.cpp +++ b/ets2panda/checker/types/ets/etsEnumType.cpp @@ -15,54 +15,24 @@ #include "etsEnumType.h" -#include "checker/ETSchecker.h" #include "checker/ets/conversion.h" -#include "checker/ets/unboxingConverter.h" -#include "ir/expressions/identifier.h" -#include "ir/expressions/literals/numberLiteral.h" -#include "ir/expressions/memberExpression.h" -#include "ir/ts/tsEnumMember.h" +#include "checker/types/ets/etsUnionType.h" namespace ark::es2panda::checker { -ETSEnumType::ETSEnumType(const ir::TSEnumDeclaration *const enumDecl, UType ordinal, - const ir::TSEnumMember *const member, TypeFlag const typeFlag) - : Type(typeFlag), decl_(enumDecl), ordinal_ {ordinal}, member_(member) -{ -} -bool ETSEnumType::AssignmentSource(TypeRelation *const relation, Type *const target) +bool ETSStringEnumType::AssignmentSource(TypeRelation *relation, Type *target) { bool result = false; - - if (target->IsETSEnumType()) { - result = IsSameEnumType(target->AsETSEnumType()); + if (target->IsETSObjectType() && target->AsETSObjectType()->IsGlobalETSObjectType()) { + result = true; } else if (target->IsETSStringType()) { - result = IsETSStringEnumType(); - if (result) { - relation->GetNode()->AddAstNodeFlags(ir::AstNodeFlags::GENERATE_VALUE_OF); - } - } else if (target->IsETSObjectType()) { - if (target->AsETSObjectType()->IsGlobalETSObjectType()) { - result = true; - relation->GetNode()->AddBoxingUnboxingFlags(ir::BoxingUnboxingFlags::BOX_TO_ENUM); - } else if (target->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BUILTIN_NUMERIC) && IsETSIntEnumType()) { - result = true; - relation->GetNode()->AddAstNodeFlags(ir::AstNodeFlags::GENERATE_VALUE_OF); - } - } else if (target->HasTypeFlag(TypeFlag::ETS_NUMERIC)) { - result = IsETSIntEnumType(); - if (result) { - relation->GetNode()->AddAstNodeFlags(ir::AstNodeFlags::GENERATE_VALUE_OF); - } - } else if (target->IsETSBooleanType()) { result = true; relation->GetNode()->AddAstNodeFlags(ir::AstNodeFlags::GENERATE_VALUE_OF); } else if (target->IsETSUnionType()) { auto &unionConstituentTypes = target->AsETSUnionType()->ConstituentTypes(); for (auto *constituentType : unionConstituentTypes) { - if (constituentType == GetDecl()->BoxedClass()->TsType()) { + if (relation->IsIdenticalTo(this, constituentType)) { result = true; - relation->GetNode()->AddBoxingUnboxingFlags(ir::BoxingUnboxingFlags::BOX_TO_ENUM); break; } } @@ -71,319 +41,89 @@ bool ETSEnumType::AssignmentSource(TypeRelation *const relation, Type *const tar return relation->IsTrue(); } -void ETSEnumType::AssignmentTarget(TypeRelation *const relation, Type *const source) +void ETSStringEnumType::AssignmentTarget(TypeRelation *relation, Type *source) { - auto checker = relation->GetChecker()->AsETSChecker(); - - Type *const unboxedSource = checker->MaybeUnboxType(source); - if (unboxedSource != source && !relation->OnlyCheckBoxingUnboxing()) { - relation->GetNode()->AddBoxingUnboxingFlags(ir::BoxingUnboxingFlags::UNBOX_TO_ENUM); - } - - relation->Result(false); - if (unboxedSource->IsETSEnumType()) { - relation->Result(IsSameEnumType(unboxedSource->AsETSEnumType())); - } else if (unboxedSource->IsETSStringEnumType()) { - relation->Result(IsSameEnumType(unboxedSource->AsETSStringEnumType())); - } + relation->IsIdenticalTo(this, source) ? relation->Result(true) : relation->Result(false); } -void ETSEnumType::Cast(TypeRelation *relation, Type *target) +void ETSStringEnumType::Cast(TypeRelation *const relation, Type *const target) { - if (target->IsETSEnumType()) { - conversion::Identity(relation, this, target); - return; - } - - if (target->HasTypeFlag(TypeFlag::ETS_NUMERIC)) { + if (relation->IsIdenticalTo(this, target)) { relation->Result(true); return; } - - // NOTE(vpukhov): #20510 conversion rules - if (target->IsETSObjectType()) { - if (target->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BOXED_ENUM)) { - conversion::Boxing(relation, this); - return; - } - - if (target->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BUILTIN_TYPE)) { - auto unboxedTarget = relation->GetChecker()->AsETSChecker()->MaybeUnboxInRelation(target); - if (unboxedTarget == nullptr) { - conversion::Forbidden(relation); - return; - } - Cast(relation, unboxedTarget); - if (relation->IsTrue()) { - conversion::Boxing(relation, unboxedTarget); - return; - } - conversion::Forbidden(relation); - return; - } - - conversion::BoxingWideningReference(relation, this, target->AsETSObjectType()); + if (target->IsETSStringType()) { + relation->Result(true); return; } conversion::Forbidden(relation); } -Type *ETSEnumType::Instantiate([[maybe_unused]] ArenaAllocator *allocator, [[maybe_unused]] TypeRelation *relation, - [[maybe_unused]] GlobalTypesHolder *globalTypes) -{ - return this; -} - -void ETSEnumType::Identical(TypeRelation *const relation, Type *const other) -{ - relation->Result(other->IsETSEnumType() && IsSameEnumType(other->AsETSEnumType())); -} - -void ETSEnumType::ToAssemblerType(std::stringstream &ss) const -{ - ToAssemblerTypeImpl(ss); -} - -void ETSEnumType::ToDebugInfoType(std::stringstream &ss) const -{ - ToDebugInfoTypeImpl(ss); -} - -void ETSEnumType::ToString(std::stringstream &ss, [[maybe_unused]] bool precise) const -{ - ss << decl_->Key()->Name(); -} - -const ir::TSEnumDeclaration *ETSEnumType::GetDecl() const noexcept -{ - return decl_; -} - -Type *ETSEnumType::BoxedType() const noexcept -{ - return GetDecl()->BoxedClass()->TsType(); -} - -const ArenaVector &ETSEnumType::GetMembers() const noexcept -{ - return decl_->Members(); -} - -varbinder::LocalVariable *ETSEnumType::GetMemberVar() const noexcept -{ - ES2PANDA_ASSERT(IsLiteralType()); - return member_->Key()->AsIdentifier()->Variable()->AsLocalVariable(); -} - -util::StringView ETSEnumType::GetName() const noexcept -{ - return decl_->Key()->Name(); -} - -ETSEnumType::UType ETSEnumType::GetOrdinal() const noexcept +void ETSStringEnumType::CastTarget(TypeRelation *relation, Type *source) { - ES2PANDA_ASSERT(IsLiteralType()); - return ordinal_; -} - -ETSEnumType *ETSEnumType::LookupConstant(ETSChecker *const checker, const ir::Expression *const expression, - const ir::Identifier *const prop) const -{ - if (!IsEnumTypeExpression(expression)) { - if (expression->IsIdentifier() && - expression->AsIdentifier()->Variable()->HasFlag(varbinder::VariableFlags::TYPE_ALIAS)) { - checker->LogError(diagnostic::ENUM_REFERENCE_VIA_ALIAS, {}, prop->Start()); - } else if (IsLiteralType()) { - checker->LogError(diagnostic::ENUMB_REFERENCE_VIA_VAR, {}, prop->Start()); - } else { - checker->LogError(diagnostic::ENUM_CONST_MISSING_PROP, {prop->Name()}, prop->Start()); - } - return nullptr; - } - - auto *const member = FindMember(prop->Name()); - if (member == nullptr) { - checker->LogError(diagnostic::ENUM_NO_SUCH_CONST, {prop->Name(), this}, prop->Start()); - return nullptr; - } - - auto *const enumInterface = member->Key()->AsIdentifier()->Variable()->TsType()->AsETSEnumType(); - ES2PANDA_ASSERT(enumInterface->IsLiteralType()); - return enumInterface; -} - -ETSFunctionType *ETSEnumType::LookupMethod(ETSChecker *checker, const ir::Expression *const expression, - const ir::Identifier *const prop) const -{ - if (IsEnumTypeExpression(expression)) { - return LookupTypeMethod(checker, prop); - } - - ES2PANDA_ASSERT(IsEnumInstanceExpression(expression)); - return LookupConstantMethod(checker, prop); -} - -bool ETSEnumType::IsSameEnumType(const ETSEnumType *const other) const noexcept -{ - return other->decl_ == decl_; -} - -bool ETSEnumType::IsSameEnumLiteralType(const ETSEnumType *const other) const noexcept -{ - ES2PANDA_ASSERT(IsLiteralType() && IsSameEnumType(other)); - return member_ == other->member_; -} - -bool ETSEnumType::IsEnumInstanceExpression(const ir::Expression *const expression) const noexcept -{ - ES2PANDA_ASSERT(IsSameEnumType(expression->TsType()->AsETSEnumType())); - - return IsEnumLiteralExpression(expression) || !IsEnumTypeExpression(expression); -} - -bool ETSEnumType::IsEnumLiteralExpression(const ir::Expression *const expression) const noexcept -{ - ES2PANDA_ASSERT(IsSameEnumType(expression->TsType()->AsETSEnumType())); - - if (expression->IsMemberExpression()) { - const auto *const memberExpr = expression->AsMemberExpression(); - return memberExpr->Kind() == ir::MemberExpressionKind::PROPERTY_ACCESS && - IsEnumTypeExpression(memberExpr->Object()); + if (source->IsETSStringType()) { + relation->Result(true); + return; } - - return false; + conversion::Forbidden(relation); } -bool ETSEnumType::IsEnumTypeExpression(const ir::Expression *const expression) const noexcept +bool ETSIntEnumType::AssignmentSource(TypeRelation *relation, Type *target) { - if (expression->TsType()->IsETSEnumType()) { - ES2PANDA_ASSERT(IsSameEnumType(expression->TsType()->AsETSEnumType())); - } else { - return false; - } - - if (expression->IsCallExpression()) { - return false; - } - - // clang-format off - const auto *const localVar = [expression]() -> const varbinder::LocalVariable* { - if (expression->IsMemberExpression()) { - const auto *const memberExpr = expression->AsMemberExpression(); - return memberExpr->PropVar() != nullptr - ? memberExpr->PropVar() - : memberExpr->Object()->AsIdentifier()->Variable()->AsLocalVariable(); + bool result = false; + if (target->IsETSObjectType()) { + if (target->AsETSObjectType()->IsGlobalETSObjectType()) { + result = true; + } else if (target->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BUILTIN_NUMERIC)) { + result = true; + relation->GetNode()->AddAstNodeFlags(ir::AstNodeFlags::GENERATE_VALUE_OF); } - return expression->AsIdentifier()->Variable()->AsLocalVariable(); - }(); - // clang-format on - ES2PANDA_ASSERT(localVar->Declaration() == decl_->Key()->AsIdentifier()->Variable()->Declaration() || - !localVar->HasFlag(varbinder::VariableFlags::ENUM_LITERAL)); - return localVar->HasFlag(varbinder::VariableFlags::ENUM_LITERAL); -} - -ETSEnumType::Method ETSEnumType::FromIntMethod() const noexcept -{ - ES2PANDA_ASSERT(fromIntMethod_.globalSignature != nullptr && fromIntMethod_.memberProxyType == nullptr); - return fromIntMethod_; -} - -ETSEnumType::Method ETSEnumType::BoxedFromIntMethod() const noexcept -{ - ES2PANDA_ASSERT(boxedFromIntMethod_.globalSignature != nullptr && boxedFromIntMethod_.memberProxyType == nullptr); - return boxedFromIntMethod_; -} - -ETSEnumType::Method ETSEnumType::UnboxMethod() const noexcept -{ - ES2PANDA_ASSERT(unboxMethod_.globalSignature != nullptr && unboxMethod_.memberProxyType != nullptr); - return unboxMethod_; -} - -ETSEnumType::Method ETSEnumType::ValueOfMethod() const noexcept -{ - ES2PANDA_ASSERT(valueOfMethod_.globalSignature != nullptr && valueOfMethod_.memberProxyType != nullptr); - return valueOfMethod_; -} - -ETSEnumType::Method ETSEnumType::GetNameMethod() const noexcept -{ - ES2PANDA_ASSERT(getNameMethod_.globalSignature != nullptr && getNameMethod_.memberProxyType != nullptr); - return getNameMethod_; -} - -ETSEnumType::Method ETSEnumType::ToStringMethod() const noexcept -{ - ES2PANDA_ASSERT(toStringMethod_.globalSignature != nullptr && toStringMethod_.memberProxyType != nullptr); - return toStringMethod_; -} - -ETSEnumType::Method ETSEnumType::GetValueOfMethod() const noexcept -{ - ES2PANDA_ASSERT(getValueOfMethod_.globalSignature != nullptr && getValueOfMethod_.memberProxyType != nullptr); - return getValueOfMethod_; -} - -ETSEnumType::Method ETSEnumType::ValuesMethod() const noexcept -{ - ES2PANDA_ASSERT(valuesMethod_.globalSignature != nullptr && valuesMethod_.memberProxyType != nullptr); - return valuesMethod_; -} - -bool ETSEnumType::IsLiteralType() const noexcept -{ - return member_ != nullptr; + } else if (target->HasTypeFlag(TypeFlag::ETS_NUMERIC)) { + result = true; + relation->GetNode()->AddAstNodeFlags(ir::AstNodeFlags::GENERATE_VALUE_OF); + } else if (target->IsETSUnionType()) { + auto &unionConstituentTypes = target->AsETSUnionType()->ConstituentTypes(); + for (auto *constituentType : unionConstituentTypes) { + if (relation->IsIdenticalTo(this, constituentType)) { + result = true; + break; + } + } + } + relation->Result(result); + return relation->IsTrue(); } -ir::TSEnumMember *ETSEnumType::FindMember(const util::StringView &name) const noexcept +void ETSIntEnumType::AssignmentTarget(TypeRelation *relation, Type *source) { - ES2PANDA_ASSERT(!IsLiteralType()); - const auto &members = GetMembers(); - auto memberIt = std::find_if(members.begin(), members.end(), [name](const ir::AstNode *const node) { - return node->AsTSEnumMember()->Key()->AsIdentifier()->Name() == name; - }); - if (memberIt != members.end()) { - return (*memberIt)->AsTSEnumMember(); - } - - return nullptr; + relation->IsIdenticalTo(this, source) ? relation->Result(true) : relation->Result(false); } -ETSFunctionType *ETSEnumType::LookupConstantMethod(ETSChecker *const checker, const ir::Identifier *const prop) const +void ETSIntEnumType::Cast(TypeRelation *const relation, Type *const target) { - if (prop->Name() == TO_STRING_METHOD_NAME) { - ES2PANDA_ASSERT(toStringMethod_.memberProxyType != nullptr); - return toStringMethod_.memberProxyType; - } - - if (prop->Name() == VALUE_OF_METHOD_NAME) { - ES2PANDA_ASSERT(valueOfMethod_.memberProxyType != nullptr); - return valueOfMethod_.memberProxyType; + if (relation->IsIdenticalTo(this, target)) { + relation->Result(true); + return; } - - if (prop->Name() == GET_NAME_METHOD_NAME) { - ES2PANDA_ASSERT(getNameMethod_.memberProxyType != nullptr); - return getNameMethod_.memberProxyType; + if (target->HasTypeFlag(TypeFlag::ETS_NUMERIC) || + (target->IsETSObjectType() && target->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BUILTIN_NUMERIC))) { + relation->Result(true); + return; } - - checker->LogError(diagnostic::ENUM_NO_SUCH_METHOD, {prop->Name()}, prop->Start()); - return nullptr; + conversion::Forbidden(relation); } -ETSFunctionType *ETSEnumType::LookupTypeMethod(ETSChecker *const checker, const ir::Identifier *const prop) const +void ETSIntEnumType::CastTarget(TypeRelation *relation, Type *source) { - if (prop->Name() == VALUES_METHOD_NAME) { - ES2PANDA_ASSERT(valuesMethod_.memberProxyType != nullptr); - return valuesMethod_.memberProxyType; + if (source->IsIntType()) { + relation->Result(true); + return; } - - if (prop->Name() == GET_VALUE_OF_METHOD_NAME) { - ES2PANDA_ASSERT(getValueOfMethod_.memberProxyType != nullptr); - return getValueOfMethod_.memberProxyType; + if (source->IsETSObjectType() && source->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BUILTIN_NUMERIC)) { + relation->Result(true); + return; } - - checker->LogError(diagnostic::ENUM_NO_SUCH_STATIC_METHOD, {prop->Name()}, prop->Start()); - return nullptr; + conversion::Forbidden(relation); } -} // namespace ark::es2panda::checker +} // namespace ark::es2panda::checker \ No newline at end of file diff --git a/ets2panda/checker/types/ets/etsEnumType.h b/ets2panda/checker/types/ets/etsEnumType.h index a0ff66bd39..a5c6bdf33d 100644 --- a/ets2panda/checker/types/ets/etsEnumType.h +++ b/ets2panda/checker/types/ets/etsEnumType.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 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 @@ -16,30 +16,20 @@ #ifndef ES2PANDA_COMPILER_CHECKER_TYPES_ETS_ENUM_TYPE_H #define ES2PANDA_COMPILER_CHECKER_TYPES_ETS_ENUM_TYPE_H -#include "checker/types/type.h" -#include "ir/base/property.h" -#include "ir/ts/tsEnumDeclaration.h" - -template -// NOLINTNEXTLINE(readability-identifier-naming) -inline constexpr bool dependent_false_v = false; - -namespace ark::es2panda::varbinder { -class LocalVariable; -} // namespace ark::es2panda::varbinder +#include "checker/types/ets/etsObjectType.h" +#include "checker/types/ets/etsObjectTypeConstants.h" +#include "checker/types/typeFlag.h" namespace ark::es2panda::checker { -template -struct ETSEnumValueType { - using ValueType = T; -}; -class ETSEnumType : public Type { +class ETSEnumType : public ETSObjectType { public: - using UType = std::int32_t; - - explicit ETSEnumType(const ir::TSEnumDeclaration *enumDecl, UType ordinal, const ir::TSEnumMember *member, - TypeFlag typeFlag); + explicit ETSEnumType(ArenaAllocator *allocator, util::StringView name, util::StringView internalName, + ir::AstNode *declNode, TypeRelation *relation) + : ETSObjectType(allocator, name, internalName, + std::make_tuple(declNode, ETSObjectFlags::CLASS | ETSObjectFlags::ENUM_OBJECT, relation)) + { + } NO_COPY_SEMANTIC(ETSEnumType); NO_MOVE_SEMANTIC(ETSEnumType); @@ -47,169 +37,23 @@ public: ETSEnumType() = delete; ~ETSEnumType() override = default; - [[nodiscard]] bool AssignmentSource(TypeRelation *relation, Type *target) override; - - void AssignmentTarget(TypeRelation *relation, Type *source) override; - - void Cast(TypeRelation *relation, Type *target) override; - - Type *Instantiate(ArenaAllocator *allocator, TypeRelation *relation, GlobalTypesHolder *globalTypes) override; - - void Identical(TypeRelation *relation, Type *other) override; - - void ToAssemblerType(std::stringstream &ss) const override; - void ToDebugInfoType(std::stringstream &ss) const override; - - void ToString(std::stringstream &ss, [[maybe_unused]] bool precise) const override; - - [[nodiscard]] const ir::TSEnumDeclaration *GetDecl() const noexcept; - - [[nodiscard]] Type *BoxedType() const noexcept; - - [[nodiscard]] const ArenaVector &GetMembers() const noexcept; - - [[nodiscard]] varbinder::LocalVariable *GetMemberVar() const noexcept; - - [[nodiscard]] util::StringView GetName() const noexcept; - - [[nodiscard]] UType GetOrdinal() const noexcept; - - [[nodiscard]] ETSEnumType *LookupConstant(ETSChecker *checker, const ir::Expression *expression, - const ir::Identifier *prop) const; - - [[nodiscard]] ETSFunctionType *LookupMethod(ETSChecker *checker, const ir::Expression *expression, - const ir::Identifier *prop) const; - - [[nodiscard]] bool IsLiteralType() const noexcept; - - [[nodiscard]] bool IsSameEnumType(const ETSEnumType *const other) const noexcept; - - [[nodiscard]] bool IsSameEnumLiteralType(const ETSEnumType *const other) const noexcept; - - [[nodiscard]] bool IsEnumInstanceExpression(const ir::Expression *expression) const noexcept; - - [[nodiscard]] bool IsEnumLiteralExpression(const ir::Expression *expression) const noexcept; - - [[nodiscard]] bool IsEnumTypeExpression(const ir::Expression *expression) const noexcept; - static constexpr std::string_view const TO_STRING_METHOD_NAME {"toString"}; static constexpr std::string_view const VALUE_OF_METHOD_NAME {"valueOf"}; static constexpr std::string_view const GET_NAME_METHOD_NAME {"getName"}; static constexpr std::string_view const GET_VALUE_OF_METHOD_NAME {"getValueOf"}; + static constexpr std::string_view const FROM_VALUE_METHOD_NAME {"fromValue"}; static constexpr std::string_view const VALUES_METHOD_NAME {"values"}; - static constexpr std::string_view const FROM_INT_METHOD_NAME {"fromInt"}; - static constexpr std::string_view const BOXED_FROM_INT_METHOD_NAME {"boxedfromInt"}; - static constexpr std::string_view const UNBOX_METHOD_NAME {"unbox"}; - - struct Method { - Signature *globalSignature; - ETSFunctionType *memberProxyType; - }; - - [[nodiscard]] Method ToStringMethod() const noexcept; - void SetToStringMethod(Method const &method) noexcept - { - toStringMethod_ = method; - } - - [[nodiscard]] Method ValueOfMethod() const noexcept; - void SetValueOfMethod(Method const &method) noexcept - { - valueOfMethod_ = method; - } - - [[nodiscard]] Method GetNameMethod() const noexcept; - void SetGetNameMethod(Method const &method) noexcept - { - getNameMethod_ = method; - } - - [[nodiscard]] Method GetValueOfMethod() const noexcept; - void SetGetValueOfMethod(Method const &method) noexcept - { - getValueOfMethod_ = method; - } - - [[nodiscard]] Method ValuesMethod() const noexcept; - void SetValuesMethod(Method const &method) noexcept - { - valuesMethod_ = method; - } - - [[nodiscard]] Method FromIntMethod() const noexcept; - void SetFromIntMethod(Method const &method) noexcept - { - fromIntMethod_ = method; - } - - [[nodiscard]] Method BoxedFromIntMethod() const noexcept; - void SetBoxedFromIntMethod(Method const &method) noexcept - { - boxedFromIntMethod_ = method; - } - - [[nodiscard]] Method UnboxMethod() const noexcept; - void SetUnboxMethod(Method const &method) noexcept - { - unboxMethod_ = method; - } - - std::tuple ResolveConditionExpr() const override - { - return {false, false}; // NOTE (psiket) It should be true, int value != 0 | string value !empty() - } - -private: - const ir::TSEnumDeclaration *decl_; - const UType ordinal_; - const ir::TSEnumMember *member_; - - Method toStringMethod_ {}; - Method valueOfMethod_ {}; - Method getNameMethod_ {}; - Method getValueOfMethod_ {}; - Method valuesMethod_ {}; - Method fromIntMethod_ {}; - Method boxedFromIntMethod_ {}; - Method unboxMethod_ {}; - - [[nodiscard]] ir::TSEnumMember *FindMember(const util::StringView &name) const noexcept; - - [[nodiscard]] ETSFunctionType *LookupConstantMethod(ETSChecker *checker, const ir::Identifier *prop) const; - - [[nodiscard]] ETSFunctionType *LookupTypeMethod(ETSChecker *checker, const ir::Identifier *prop) const; - - template - void ToAssemblerTypeImpl(std::stringstream &ss) const noexcept - { - if constexpr (std::is_same_v) { - ss << compiler::Signatures::PRIMITIVE_LONG; - } else if constexpr (std::is_same_v) { - ss << compiler::Signatures::PRIMITIVE_INT; - } else { - static_assert(dependent_false_v, "Invalid underlying type for enumeration."); - } - } - - template - void ToDebugInfoTypeImpl(std::stringstream &ss) const noexcept - { - if constexpr (std::is_same_v) { - ss << compiler::Signatures::TYPE_DESCRIPTOR_LONG; - } else if constexpr (std::is_same_v) { - ss << compiler::Signatures::TYPE_DESCRIPTOR_INT; - } else { - static_assert(dependent_false_v, "Invalid underlying type for enumeration."); - } - } + static constexpr std::string_view const GET_ORDINAL_METHOD_NAME {"getOrdinal"}; + static constexpr std::string_view const DOLLAR_GET_METHOD_NAME {"$_get"}; }; -class ETSIntEnumType : public ETSEnumType, public ETSEnumValueType { +class ETSIntEnumType : public ETSEnumType { public: - explicit ETSIntEnumType(const ir::TSEnumDeclaration *enumDecl, UType ordinal, - const ir::TSEnumMember *member = nullptr) - : ETSEnumType(enumDecl, ordinal, member, TypeFlag::ETS_INT_ENUM) + explicit ETSIntEnumType(ArenaAllocator *allocator, util::StringView name, util::StringView internalName, + ir::AstNode *declNode, TypeRelation *relation) + : ETSEnumType(allocator, name, internalName, declNode, relation) { + AddTypeFlag(checker::TypeFlag::ETS_INT_ENUM); } NO_COPY_SEMANTIC(ETSIntEnumType); @@ -217,14 +61,20 @@ public: ETSIntEnumType() = delete; ~ETSIntEnumType() override = default; + + bool AssignmentSource(TypeRelation *relation, Type *target) override; + void AssignmentTarget(TypeRelation *relation, Type *source) override; + void Cast(TypeRelation *relation, Type *target) override; + void CastTarget(TypeRelation *relation, Type *source) override; }; -class ETSStringEnumType : public ETSEnumType, public ETSEnumValueType { +class ETSStringEnumType : public ETSEnumType { public: - explicit ETSStringEnumType(const ir::TSEnumDeclaration *enumDecl, UType ordinal, - const ir::TSEnumMember *member = nullptr) - : ETSEnumType(enumDecl, ordinal, member, TypeFlag::ETS_STRING_ENUM) + explicit ETSStringEnumType(ArenaAllocator *allocator, util::StringView name, util::StringView internalName, + ir::AstNode *declNode, TypeRelation *relation) + : ETSEnumType(allocator, name, internalName, declNode, relation) { + AddTypeFlag(checker::TypeFlag::ETS_STRING_ENUM); } NO_COPY_SEMANTIC(ETSStringEnumType); @@ -232,7 +82,13 @@ public: ETSStringEnumType() = delete; ~ETSStringEnumType() override = default; + + bool AssignmentSource(TypeRelation *relation, Type *target) override; + void AssignmentTarget(TypeRelation *relation, Type *source) override; + void Cast(TypeRelation *relation, Type *target) override; + void CastTarget(TypeRelation *relation, Type *source) override; }; + } // namespace ark::es2panda::checker -#endif +#endif \ No newline at end of file diff --git a/ets2panda/checker/types/ets/etsObjectType.cpp b/ets2panda/checker/types/ets/etsObjectType.cpp index bbba838227..a97a942ac3 100644 --- a/ets2panda/checker/types/ets/etsObjectType.cpp +++ b/ets2panda/checker/types/ets/etsObjectType.cpp @@ -630,10 +630,6 @@ bool ETSObjectType::CastNumericObject(TypeRelation *const relation, Type *const if (TryCastFloating(relation, target)) { return true; } - if (this->HasObjectFlag(ETSObjectFlags::BOXED_ENUM) && target->HasTypeFlag(TypeFlag::ETS_ENUM)) { - conversion::Unboxing(relation, this); - return true; - } if (this->HasObjectFlag(ETSObjectFlags::BUILTIN_BOOLEAN) && target->HasTypeFlag(TypeFlag::ETS_BOOLEAN)) { conversion::Unboxing(relation, this); return true; diff --git a/ets2panda/checker/types/ets/etsObjectType.h b/ets2panda/checker/types/ets/etsObjectType.h index 7a4c0c3b94..9a174689dd 100644 --- a/ets2panda/checker/types/ets/etsObjectType.h +++ b/ets2panda/checker/types/ets/etsObjectType.h @@ -276,12 +276,6 @@ public: return static_cast(flags_ & ETSObjectFlags::UNBOXABLE_TYPE); } - ETSEnumType *GetUnboxedEnumType() const - { - ES2PANDA_ASSERT(HasObjectFlag(ETSObjectFlags::BOXED_ENUM)); - return GetDeclNode()->AsClassDefinition()->OrigEnumDecl()->TsType()->AsETSEnumType(); - } - ETSObjectType *GetInstantiatedType(util::StringView hash) { auto found = instantiationMap_.find(hash); diff --git a/ets2panda/checker/types/ets/etsObjectTypeConstants.h b/ets2panda/checker/types/ets/etsObjectTypeConstants.h index 5c89fdb731..a0582dd235 100644 --- a/ets2panda/checker/types/ets/etsObjectTypeConstants.h +++ b/ets2panda/checker/types/ets/etsObjectTypeConstants.h @@ -55,13 +55,13 @@ enum class ETSObjectFlags : std::uint64_t { BUILTIN_FLOAT = 1U << 30U, BUILTIN_DOUBLE = 1U << 31U, - BOXED_ENUM = 1ULL << 32U, + ENUM_OBJECT = 1ULL << 32U, EXTENSION_FUNCTION = 1ULL << 33U, BUILTIN_NUMERIC = BUILTIN_BYTE | BUILTIN_SHORT | BUILTIN_INT | BUILTIN_LONG | BUILTIN_FLOAT | BUILTIN_DOUBLE, // Complete set includes null|undefined|Object VALUE_TYPED = BUILTIN_BOOLEAN | BUILTIN_CHAR | BUILTIN_NUMERIC | BUILTIN_BIGINT | STRING, - UNBOXABLE_TYPE = BUILTIN_BOOLEAN | BUILTIN_CHAR | BUILTIN_NUMERIC | BOXED_ENUM, + UNBOXABLE_TYPE = BUILTIN_BOOLEAN | BUILTIN_CHAR | BUILTIN_NUMERIC, BUILTIN_TYPE = BUILTIN_STRING | BUILTIN_BIGINT | UNBOXABLE_TYPE, GLOBAL_CLASS = CLASS | GLOBAL, diff --git a/ets2panda/checker/types/ets/etsStringType.cpp b/ets2panda/checker/types/ets/etsStringType.cpp index 8cc41634fc..648af3cc01 100644 --- a/ets2panda/checker/types/ets/etsStringType.cpp +++ b/ets2panda/checker/types/ets/etsStringType.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - 2024 Huawei Device Co., Ltd. + * Copyright (c) 2021 - 2025 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 @@ -54,7 +54,7 @@ bool ETSStringType::AssignmentSource(TypeRelation *relation, Type *target) return relation->IsTrue(); } -void ETSStringType::AssignmentTarget([[maybe_unused]] TypeRelation *relation, Type *source) +void ETSStringType::AssignmentTarget(TypeRelation *relation, Type *source) { relation->Result(source->IsETSStringType() && AreStringTypesAssignable(source, this)); } diff --git a/ets2panda/checker/types/ets/intType.cpp b/ets2panda/checker/types/ets/intType.cpp index da3ad3c4d5..c21e904b08 100644 --- a/ets2panda/checker/types/ets/intType.cpp +++ b/ets2panda/checker/types/ets/intType.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 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 @@ -34,7 +34,7 @@ void IntType::AssignmentTarget(TypeRelation *relation, [[maybe_unused]] Type *so NarrowingWideningConverter(relation->GetChecker()->AsETSChecker(), relation, this, source); } -bool IntType::AssignmentSource([[maybe_unused]] TypeRelation *relation, [[maybe_unused]] Type *target) +bool IntType::AssignmentSource(TypeRelation *relation, Type *target) { if (relation->InAssignmentContext()) { relation->GetChecker()->AsETSChecker()->CheckUnboxedTypeWidenable(relation, target, this); @@ -57,11 +57,6 @@ void IntType::Cast(TypeRelation *const relation, Type *const target) return; } - if (target->IsETSEnumType()) { - relation->Result(true); - return; - } - if (target->HasTypeFlag(TypeFlag::BYTE | TypeFlag::SHORT | TypeFlag::CHAR)) { conversion::NarrowingPrimitive(relation, this, target); return; diff --git a/ets2panda/checker/types/ets/types.h b/ets2panda/checker/types/ets/types.h index c9c656df74..89d59b801e 100644 --- a/ets2panda/checker/types/ets/types.h +++ b/ets2panda/checker/types/ets/types.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 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 @@ -24,7 +24,6 @@ #include "longType.h" #include "shortType.h" #include "etsBooleanType.h" -#include "etsEnumType.h" #include "etsExtensionFuncHelperType.h" #include "etsFunctionType.h" #include "etsUnionType.h" diff --git a/ets2panda/checker/types/type.h b/ets2panda/checker/types/type.h index 0bc7e8933e..b3253037fe 100644 --- a/ets2panda/checker/types/type.h +++ b/ets2panda/checker/types/type.h @@ -96,6 +96,7 @@ public: bool IsETSReferenceType() const; bool IsETSAsyncFuncReturnType() const; bool IsETSUnboxableObject() const; + bool IsETSPrimitiveOrEnumType() const; bool PossiblyETSNull() const; bool PossiblyETSUndefined() const; diff --git a/ets2panda/checker/types/typeFlag.h b/ets2panda/checker/types/typeFlag.h index 34a31ce83d..86e149f3a3 100644 --- a/ets2panda/checker/types/typeFlag.h +++ b/ets2panda/checker/types/typeFlag.h @@ -93,9 +93,9 @@ enum class TypeFlag : uint64_t { ETS_DYNAMIC_TYPE = ETS_OBJECT | ETS_DYNAMIC_FLAG, ETS_DYNAMIC_FUNCTION_TYPE = FUNCTION | ETS_DYNAMIC_FLAG, ETS_TYPE = BYTE | SHORT | INT | LONG | FLOAT | DOUBLE | CHAR | ETS_BOOLEAN | ETS_VOID | ETS_OBJECT | ETS_ARRAY | - FUNCTION | WILDCARD | ETS_TYPE_PARAMETER | ETS_INT_ENUM | ETS_STRING_ENUM | ETS_DYNAMIC_TYPE | - ETS_UNION | ETS_NULL | ETS_UNDEFINED | ETS_NONNULLISH | ETS_READONLY | ETS_REQUIRED_TYPE_PARAMETER | - ETS_PARTIAL_TYPE_PARAMETER | ETS_NEVER | ETS_TUPLE, + FUNCTION | WILDCARD | ETS_TYPE_PARAMETER | ETS_DYNAMIC_TYPE | ETS_UNION | ETS_NULL | ETS_UNDEFINED | + ETS_NONNULLISH | ETS_READONLY | ETS_REQUIRED_TYPE_PARAMETER | ETS_PARTIAL_TYPE_PARAMETER | ETS_NEVER | + ETS_TUPLE, ETS_INTEGRAL_NUMERIC = BYTE | SHORT | INT | LONG, ETS_FLOATING_POINT = FLOAT | DOUBLE, ETS_NUMERIC = ETS_INTEGRAL_NUMERIC | ETS_FLOATING_POINT, @@ -103,7 +103,7 @@ enum class TypeFlag : uint64_t { ETS_ENUM = ETS_INT_ENUM | ETS_STRING_ENUM, ETS_ARRAY_INDEX = BYTE | SHORT | INT, ETS_CONVERTIBLE_TO_NUMERIC = ETS_NUMERIC | CHAR | ETS_INT_ENUM, - VALID_SWITCH_TYPE = ETS_INTEGRAL | ETS_ENUM, + VALID_SWITCH_TYPE = ETS_INTEGRAL, ETS_ARRAY_OR_OBJECT = ETS_ARRAY | ETS_OBJECT, ANY_OR_UNKNOWN = ANY | UNKNOWN, ANY_OR_VOID = ANY | VOID, diff --git a/ets2panda/checker/types/typeRelation.cpp b/ets2panda/checker/types/typeRelation.cpp index 2fd626d91b..88ed2fd951 100644 --- a/ets2panda/checker/types/typeRelation.cpp +++ b/ets2panda/checker/types/typeRelation.cpp @@ -192,7 +192,8 @@ bool TypeRelation::IsCastableTo(Type *const source, Type *const target) // NOTE: Can't cache if the node has BoxingUnboxingFlags. These flags should be stored and restored on the node // on cache hit. - if (UncheckedCast() && node_->GetBoxingUnboxingFlags() == ir::BoxingUnboxingFlags::NONE) { + if (UncheckedCast() && node_->GetBoxingUnboxingFlags() == ir::BoxingUnboxingFlags::NONE && + !node_->HasAstNodeFlags(ir::AstNodeFlags::GENERATE_VALUE_OF)) { checker_->UncheckedCastableResult().cached.insert( {{source->Id(), target->Id()}, {result_, RelationType::UNCHECKED_CASTABLE}}); } diff --git a/ets2panda/compiler/core/ETSCompiler.cpp b/ets2panda/compiler/core/ETSCompiler.cpp index adc9128c3e..7492a4c55b 100644 --- a/ets2panda/compiler/core/ETSCompiler.cpp +++ b/ets2panda/compiler/core/ETSCompiler.cpp @@ -575,8 +575,6 @@ static void CompileInstanceof(compiler::ETSGen *etsg, const ir::BinaryExpression etsg->IsInstanceDynamic(expr, lhs, rhs); } else { auto target = expr->Right()->TsType(); - // NOTE(vpukhov): #20510 lowering - target = target->IsETSEnumType() ? etsg->Checker()->MaybeBoxType(target) : target; etsg->IsInstance(expr, lhs, target); } ES2PANDA_ASSERT(etsg->Checker()->Relation()->IsIdenticalTo(etsg->GetAccumulatorType(), expr->TsType())); @@ -740,53 +738,6 @@ void ETSCompiler::Compile(const ir::BlockExpression *expr) const expr->Scope()->SetParent(oldParent); } -bool ETSCompiler::IsSucceedCompilationProxyMemberExpr(const ir::CallExpression *expr) const -{ - ETSGen *etsg = GetETSGen(); - auto *const calleeObject = expr->callee_->AsMemberExpression()->Object(); - auto const *const enumInterface = [calleeType = calleeObject->TsType()]() -> checker::ETSEnumType const * { - if (calleeType == nullptr) { - return nullptr; - } - return calleeType->IsETSEnumType() ? calleeType->AsETSEnumType() : nullptr; - }(); - - if (enumInterface != nullptr) { - ArenaVector arguments(etsg->Allocator()->Adapter()); - - checker::Signature *const signature = [expr, calleeObject, enumInterface, &arguments]() { - const auto &memberProxyMethodName = expr->Signature()->InternalName(); - - if (memberProxyMethodName == checker::ETSIntEnumType::TO_STRING_METHOD_NAME) { - arguments.push_back(calleeObject); - return enumInterface->ToStringMethod().globalSignature; - } - if (memberProxyMethodName == checker::ETSIntEnumType::VALUE_OF_METHOD_NAME) { - arguments.push_back(calleeObject); - return enumInterface->ValueOfMethod().globalSignature; - } - if (memberProxyMethodName == checker::ETSIntEnumType::GET_NAME_METHOD_NAME) { - arguments.push_back(calleeObject); - return enumInterface->GetNameMethod().globalSignature; - } - if (memberProxyMethodName == checker::ETSIntEnumType::VALUES_METHOD_NAME) { - return enumInterface->ValuesMethod().globalSignature; - } - if (memberProxyMethodName == checker::ETSIntEnumType::GET_VALUE_OF_METHOD_NAME) { - arguments.push_back(expr->Arguments().front()); - return enumInterface->GetValueOfMethod().globalSignature; - } - UNREACHABLE(); - }(); - - ES2PANDA_ASSERT(signature->ReturnType() == expr->Signature()->ReturnType()); - etsg->CallExact(expr, signature, arguments); - etsg->SetAccumulatorType(expr->TsType()); - } - - return enumInterface != nullptr; -} - void ETSCompiler::CompileDynamic(const ir::CallExpression *expr, compiler::VReg &calleeReg) const { ETSGen *etsg = GetETSGen(); @@ -847,12 +798,6 @@ void ETSCompiler::Compile(const ir::CallExpression *expr) const auto const callee = expr->Callee(); checker::Signature *const signature = expr->Signature(); - if (signature->HasSignatureFlag(checker::SignatureFlags::PROXY) && callee->IsMemberExpression()) { - if (IsSucceedCompilationProxyMemberExpr(expr)) { - return; - } - } - ASSERT(!callee->TsType()->IsETSArrowType()); // should have been lowered bool const isStatic = signature->HasSignatureFlag(checker::SignatureFlags::STATIC); @@ -991,10 +936,6 @@ void ETSCompiler::Compile(const ir::MemberExpression *expr) const return; } - if (HandleEnumTypes(expr, etsg)) { - return; - } - if (HandleStaticProperties(expr, etsg)) { return; } @@ -1050,19 +991,6 @@ bool ETSCompiler::HandleArrayTypeLengthProperty(const ir::MemberExpression *expr return false; } -// NOTE(vpukhov): #20510 lowering -bool ETSCompiler::HandleEnumTypes(const ir::MemberExpression *expr, ETSGen *etsg) const -{ - auto *const exprType = etsg->Checker()->GetApparentType(expr->TsType()); - if (exprType->IsETSEnumType() && exprType->AsETSEnumType()->IsLiteralType()) { - auto ttctx = compiler::TargetTypeContext(etsg, expr->TsType()); - etsg->LoadAccumulatorInt(expr, exprType->AsETSEnumType()->GetOrdinal()); - etsg->ApplyConversion(expr, expr->TsType()); - return true; - } - return false; -} - bool ETSCompiler::HandleStaticProperties(const ir::MemberExpression *expr, ETSGen *etsg) const { auto &propName = expr->PropVar()->Name(); @@ -1806,23 +1734,6 @@ void ETSCompiler::CompileCast(const ir::TSAsExpression *expr) const etsg->CastToDynamic(expr, targetType->AsETSDynamicType()); break; } - // NOTE(vpukhov): #20510 lowering - case checker::TypeFlag::ETS_STRING_ENUM: - [[fallthrough]]; - case checker::TypeFlag::ETS_INT_ENUM: { - auto *const acuType = etsg->GetAccumulatorType(); - if (acuType->IsETSEnumType()) { - break; - } - ES2PANDA_ASSERT(acuType->IsIntType()); - auto *const signature = expr->TsType()->AsETSEnumType()->FromIntMethod().globalSignature; - compiler::RegScope rs(etsg); - auto arg = etsg->AllocReg(); - etsg->StoreAccumulator(expr, arg); - etsg->CallExact(expr, signature->InternalName(), arg); - etsg->SetAccumulatorType(signature->ReturnType()); - break; - } default: { CompileCastPrimitives(expr); } @@ -1888,6 +1799,5 @@ void ETSCompiler::Compile(const ir::TSNonNullExpression *expr) const } void ETSCompiler::Compile([[maybe_unused]] const ir::TSTypeAliasDeclaration *st) const {} -void ETSCompiler::Compile([[maybe_unused]] const ir::TSEnumDeclaration *st) const {} } // namespace ark::es2panda::compiler diff --git a/ets2panda/compiler/core/ETSCompiler.h b/ets2panda/compiler/core/ETSCompiler.h index 186d0d329c..e464f49c1b 100644 --- a/ets2panda/compiler/core/ETSCompiler.h +++ b/ets2panda/compiler/core/ETSCompiler.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 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 @@ -34,7 +34,6 @@ public: #undef DECLARE_ETSCOMPILER_COMPILE_METHOD private: - bool IsSucceedCompilationProxyMemberExpr(const ir::CallExpression *expr) const; void GetDynamicNameParts(const ir::CallExpression *expr, ArenaVector &parts) const; void CompileDynamic(const ir::CallExpression *expr, compiler::VReg &calleeReg) const; void CompileCastUnboxable(const ir::TSAsExpression *expr) const; @@ -42,7 +41,6 @@ private: void CompileCast(const ir::TSAsExpression *expr) const; void EmitCall(const ir::CallExpression *expr, compiler::VReg &calleeReg, checker::Signature *signature) const; bool HandleArrayTypeLengthProperty(const ir::MemberExpression *expr, ETSGen *etsg) const; - bool HandleEnumTypes(const ir::MemberExpression *expr, ETSGen *etsg) const; bool HandleStaticProperties(const ir::MemberExpression *expr, ETSGen *etsg) const; static bool CompileComputed(compiler::ETSGen *etsg, const ir::MemberExpression *expr); diff --git a/ets2panda/compiler/core/ETSCompilerUnrechable.cpp b/ets2panda/compiler/core/ETSCompilerUnrechable.cpp index 8b05cb4c9c..9f0c7cf28e 100644 --- a/ets2panda/compiler/core/ETSCompilerUnrechable.cpp +++ b/ets2panda/compiler/core/ETSCompilerUnrechable.cpp @@ -503,4 +503,9 @@ void ETSCompiler::Compile([[maybe_unused]] const ir::DummyNode *node) const { UNREACHABLE(); } + +void ETSCompiler::Compile([[maybe_unused]] const ir::TSEnumDeclaration *st) const +{ + UNREACHABLE(); +} } // namespace ark::es2panda::compiler diff --git a/ets2panda/compiler/core/ETSGen.cpp b/ets2panda/compiler/core/ETSGen.cpp index 829c6b22b4..d678810b54 100644 --- a/ets2panda/compiler/core/ETSGen.cpp +++ b/ets2panda/compiler/core/ETSGen.cpp @@ -1132,24 +1132,6 @@ void ETSGen::ApplyBoxingConversion(const ir::AstNode *node) static_cast(node->GetBoxingUnboxingFlags() & ~(ir::BoxingUnboxingFlags::BOXING_FLAG))); } -static checker::Type const *GetUnboxedTypeFromContext(checker::ETSChecker const *checker, const ir::AstNode *node) -{ - // A consequence of current enum type implementation, #20510 - checker::Type const *type; - if (node->IsExpression()) { - if (node->Parent()->IsTSAsExpression()) { - type = node->Parent()->AsTSAsExpression()->TsType(); - } else { - type = node->AsExpression()->TsType(); - } - } else { - UNREACHABLE(); - } - type = checker->MaybeUnboxType(const_cast(type)); - ES2PANDA_ASSERT(!type->IsETSReferenceType()); - return type; -} - void ETSGen::ApplyUnboxingConversion(const ir::AstNode *node) { auto const callUnbox = [this, node](std::string_view sig, checker::Type const *unboxedType) { @@ -1186,11 +1168,6 @@ void ETSGen::ApplyUnboxingConversion(const ir::AstNode *node) case ir::BoxingUnboxingFlags::UNBOX_TO_DOUBLE: callUnbox(Signatures::BUILTIN_DOUBLE_UNBOXED, Checker()->GlobalDoubleType()); return; - case ir::BoxingUnboxingFlags::UNBOX_TO_ENUM: { - auto enumType = GetUnboxedTypeFromContext(Checker(), node)->AsETSEnumType(); - callUnbox(enumType->UnboxMethod().globalSignature->InternalName().Utf8(), enumType); - return; - } default: UNREACHABLE(); } @@ -1342,11 +1319,6 @@ void ETSGen::EmitBoxingConversion(ir::BoxingUnboxingFlags boxingFlag, const ir:: case ir::BoxingUnboxingFlags::BOX_TO_DOUBLE: callBox(Signatures::BUILTIN_DOUBLE_VALUE_OF, Checker()->GlobalDoubleType()); return; - case ir::BoxingUnboxingFlags::BOX_TO_ENUM: { - const auto *const enumType = node->AsExpression()->TsType()->AsETSEnumType(); - callBox(enumType->BoxedFromIntMethod().globalSignature->InternalName().Utf8(), enumType); - return; - } default: UNREACHABLE(); } @@ -1719,8 +1691,6 @@ void ETSGen::CastToInt(const ir::AstNode *node) } case checker::TypeFlag::ETS_BOOLEAN: case checker::TypeFlag::CHAR: - case checker::TypeFlag::ETS_INT_ENUM: - case checker::TypeFlag::ETS_STRING_ENUM: case checker::TypeFlag::BYTE: case checker::TypeFlag::SHORT: { break; @@ -2458,8 +2428,6 @@ void ETSGen::BinaryEqualityCondition(const ir::AstNode *node, VReg lhs, Label *i BinaryNumberComparison(node, lhs, ifFalse); break; } - case checker::TypeFlag::ETS_INT_ENUM: - case checker::TypeFlag::ETS_STRING_ENUM: case checker::TypeFlag::ETS_BOOLEAN: case checker::TypeFlag::BYTE: case checker::TypeFlag::CHAR: @@ -3161,9 +3129,6 @@ void ETSGen::LoadArrayElement(const ir::AstNode *node, VReg objectReg) Ra().Emit(node, objectReg); break; } - case checker::TypeFlag::ETS_STRING_ENUM: - [[fallthrough]]; - case checker::TypeFlag::ETS_INT_ENUM: case checker::TypeFlag::INT: { Ra().Emit(node, objectReg); break; @@ -3207,9 +3172,6 @@ void ETSGen::StoreArrayElement(const ir::AstNode *node, VReg objectReg, VReg ind Ra().Emit(node, objectReg, index); break; } - case checker::TypeFlag::ETS_STRING_ENUM: - [[fallthrough]]; - case checker::TypeFlag::ETS_INT_ENUM: case checker::TypeFlag::INT: { Ra().Emit(node, objectReg, index); break; @@ -3503,13 +3465,6 @@ void ETSGen::SetAccumulatorTargetType(const ir::AstNode *node, checker::TypeFlag SetAccumulatorType(Checker()->GlobalDoubleType()); break; } - case checker::TypeFlag::ETS_STRING_ENUM: - [[fallthrough]]; - case checker::TypeFlag::ETS_INT_ENUM: { - Sa().Emit(node, static_cast(number)); - SetAccumulatorType(Checker()->GlobalIntType()); - break; - } default: { UNREACHABLE(); } diff --git a/ets2panda/compiler/core/ETSemitter.cpp b/ets2panda/compiler/core/ETSemitter.cpp index 27bf0db833..fdd65ae915 100644 --- a/ets2panda/compiler/core/ETSemitter.cpp +++ b/ets2panda/compiler/core/ETSemitter.cpp @@ -364,8 +364,6 @@ void ETSEmitter::GenClassField(const ir::ClassProperty *prop, pandasm::Record &c field.metadata->SetAttribute(Signatures::EXTERNAL); } else if (prop->TsType()->IsETSPrimitiveType() || prop->TsType()->IsETSStringType()) { EmitDefaultFieldValue(field, prop->Value()); - } else if (prop->TsType()->IsETSEnumType()) { - CreateEnumProp(prop, field); } classRecord.fieldList.emplace_back(std::move(field)); @@ -556,17 +554,15 @@ void ETSEmitter::CreateEnumProp(const ir::ClassProperty *prop, pandasm::Field &f if (prop->Value() == nullptr) { return; } - auto *init = prop->Value()->AsMemberExpression()->PropVar()->Declaration()->Node()->AsTSEnumMember()->Init(); field.metadata->SetFieldType(field.type); + auto declNode = prop->Value()->AsMemberExpression()->PropVar()->Declaration()->Node(); + auto *init = declNode->AsClassProperty()->OriginEnumMember()->Init(); if (init->IsNumberLiteral()) { auto value = init->AsNumberLiteral()->Number().GetInt(); field.metadata->SetValue(pandasm::ScalarValue::Create(value)); } else if (init->IsStringLiteral()) { auto value = init->AsStringLiteral()->Str().Mutf8(); field.metadata->SetValue(pandasm::ScalarValue::Create(value)); - } else if (init->IsUnaryExpression() && IsNegativeLiteralNode(init->AsUnaryExpression())) { - double doubleValue = (-1) * init->AsUnaryExpression()->Argument()->AsNumberLiteral()->Number().GetDouble(); - field.metadata->SetValue(pandasm::ScalarValue::Create(doubleValue)); } else { UNREACHABLE(); } @@ -592,7 +588,7 @@ static void ProcessEnumExpression(std::vector &l { auto *memberExpr = elem->IsCallExpression() ? elem->AsCallExpression()->Arguments()[0]->AsMemberExpression() : elem->AsMemberExpression(); - auto *init = memberExpr->PropVar()->Declaration()->Node()->AsTSEnumMember()->Init(); + auto *init = memberExpr->PropVar()->Declaration()->Node()->AsClassProperty()->OriginEnumMember()->Init(); if (init->IsNumberLiteral()) { auto enumValue = static_cast(init->AsNumberLiteral()->Number().GetInt()); literals.emplace_back(pandasm::LiteralArray::Literal {panda_file::LiteralTag::TAGVALUE, @@ -758,6 +754,22 @@ pandasm::AnnotationElement ETSEmitter::ProcessArrayType(const ir::ClassProperty std::string_view {litArrays.back().first}))}; } +pandasm::AnnotationElement ETSEmitter::ProcessETSEnumType(std::string &baseName, const ir::Expression *init, + const checker::Type *type) +{ + auto declNode = init->AsMemberExpression()->PropVar()->Declaration()->Node(); + auto *initValue = declNode->AsClassProperty()->OriginEnumMember()->Init(); + if (type->IsETSIntEnumType()) { + auto enumValue = static_cast(initValue->AsNumberLiteral()->Number().GetInt()); + auto intEnumValue = pandasm::ScalarValue::Create(enumValue); + return pandasm::AnnotationElement {baseName, std::make_unique(intEnumValue)}; + } + ASSERT(type->IsETSStringEnumType()); + auto enumValue = initValue->AsStringLiteral()->Str().Mutf8(); + auto stringValue = pandasm::ScalarValue::Create(enumValue); + return pandasm::AnnotationElement {baseName, std::make_unique(stringValue)}; +} + pandasm::AnnotationElement ETSEmitter::GenCustomAnnotationElement(const ir::ClassProperty *prop, std::string &baseName) { const auto *init = prop->Value(); @@ -767,6 +779,10 @@ pandasm::AnnotationElement ETSEmitter::GenCustomAnnotationElement(const ir::Clas if (type->IsETSArrayType()) { return ProcessArrayType(prop, baseName, init); } + + if (type->IsETSEnumType()) { + return ProcessETSEnumType(baseName, init, type); + } switch (checker::ETSChecker::TypeKind( Context()->checker->AsETSChecker()->MaybeUnboxType(const_cast(type)))) { case checker::TypeFlag::BYTE: @@ -787,18 +803,6 @@ pandasm::AnnotationElement ETSEmitter::GenCustomAnnotationElement(const ir::Clas return pandasm::AnnotationElement { propName, std::make_unique(CreateScalarValue(init->TsType(), typeKind))}; } - case checker::TypeFlag::ETS_INT_ENUM: { - auto *initValue = init->AsMemberExpression()->PropVar()->Declaration()->Node()->AsTSEnumMember()->Init(); - auto enumValue = static_cast(initValue->AsNumberLiteral()->Number().GetInt()); - auto intEnumValue = pandasm::ScalarValue::Create(enumValue); - return pandasm::AnnotationElement {propName, std::make_unique(intEnumValue)}; - } - case checker::TypeFlag::ETS_STRING_ENUM: { - auto *initValue = init->AsMemberExpression()->PropVar()->Declaration()->Node()->AsTSEnumMember()->Init(); - auto enumValue = initValue->AsStringLiteral()->Str().Mutf8(); - auto stringValue = pandasm::ScalarValue::Create(enumValue); - return pandasm::AnnotationElement {propName, std::make_unique(stringValue)}; - } default: UNREACHABLE(); } diff --git a/ets2panda/compiler/core/ETSemitter.h b/ets2panda/compiler/core/ETSemitter.h index 6b5dea3685..21061cc3ca 100644 --- a/ets2panda/compiler/core/ETSemitter.h +++ b/ets2panda/compiler/core/ETSemitter.h @@ -90,6 +90,8 @@ private: void GenClassRecord(const ir::ClassDefinition *classDef, bool external); pandasm::AnnotationElement ProcessArrayType(const ir::ClassProperty *prop, std::string &baseName, const ir::Expression *init); + pandasm::AnnotationElement ProcessETSEnumType(std::string &baseName, const ir::Expression *init, + const checker::Type *type); pandasm::AnnotationElement GenCustomAnnotationElement(const ir::ClassProperty *prop, std::string &baseName); pandasm::AnnotationData GenCustomAnnotation(ir::AnnotationUsage *anno, std::string &baseName); void CreateEnumProp(const ir::ClassProperty *prop, pandasm::Field &field); diff --git a/ets2panda/compiler/lowering/ets/enumLowering.cpp b/ets2panda/compiler/lowering/ets/enumLowering.cpp index 337ca72641..82dfb3ed0b 100644 --- a/ets2panda/compiler/lowering/ets/enumLowering.cpp +++ b/ets2panda/compiler/lowering/ets/enumLowering.cpp @@ -14,16 +14,18 @@ */ #include "enumLowering.h" -#include "checker/types/ets/etsEnumType.h" + #include "checker/ETSchecker.h" +#include "checker/types/ets/etsEnumType.h" #include "checker/types/type.h" #include "compiler/lowering/scopesInit/scopesInitPhase.h" #include "compiler/lowering/util.h" #include "varbinder/ETSBinder.h" -#include "varbinder/variable.h" namespace ark::es2panda::compiler { +using AstNodePtr = ir::AstNode *; + namespace { [[nodiscard]] ir::ETSParameterExpression *MakeFunctionParam(checker::ETSChecker *const checker, @@ -120,14 +122,6 @@ bool EnumLoweringPhase::CheckEnumMemberType(const ArenaVector &en return function; } -util::UString EnumLoweringPhase::GetEnumClassName(checker::ETSChecker *checker, - const ir::TSEnumDeclaration *const enumDecl) -{ - util::UString className(util::StringView("#"), checker->Allocator()); - className.Append(enumDecl->Key()->Name()); - return className; -} - template [[nodiscard]] ir::Identifier *EnumLoweringPhase::MakeArray(const ir::TSEnumDeclaration *const enumDecl, ir::ClassDefinition *const enumClass, @@ -144,21 +138,53 @@ template auto *const arrayIdent = checker_->AllocNode(name, Allocator()); auto *const arrayClassProp = checker_->AllocNode( arrayIdent, arrayExpr, typeAnnotation, - ir::ModifierFlags::STATIC | ir::ModifierFlags::PROTECTED | ir::ModifierFlags::READONLY, Allocator(), false); + ir::ModifierFlags::STATIC | ir::ModifierFlags::PRIVATE | ir::ModifierFlags::READONLY, Allocator(), false); arrayClassProp->SetParent(enumClass); enumClass->Body().push_back(arrayClassProp); return arrayIdent; } +void EnumLoweringPhase::CreateEnumItemFields(const ir::TSEnumDeclaration *const enumDecl, + ir::ClassDefinition *const enumClass) +{ + int32_t ordinal = 0; + auto createEnumItemField = [this, enumClass, &ordinal](ir::TSEnumMember *const member) { + auto *const enumMemberIdent = + checker_->AllocNode(member->AsTSEnumMember()->Key()->AsIdentifier()->Name(), Allocator()); + auto *const enumTypeAnnotation = MakeTypeReference(checker_, enumClass->Ident()->Name()); + + auto *const ordinalLiteral = checker_->AllocNode(lexer::Number(ordinal)); + ordinal++; + ArenaVector newExprArgs(Allocator()->Adapter()); + newExprArgs.push_back(ordinalLiteral); + auto enumTypeAnnotation1 = enumTypeAnnotation->Clone(Allocator(), nullptr); + auto *const newExpression = + checker_->AllocNode(enumTypeAnnotation1, std::move(newExprArgs)); + + auto *field = checker_->AllocNode( + enumMemberIdent, newExpression, enumTypeAnnotation, + ir::ModifierFlags::PUBLIC | ir::ModifierFlags::STATIC | ir::ModifierFlags::READONLY, Allocator(), false); + enumMemberIdent->SetRange(member->Key()->Range()); + newExpression->SetRange(member->Init()->Range()); + field->SetRange(member->Range()); + field->SetOrigEnumMember(member->AsTSEnumMember()); + field->SetParent(enumClass); + return field; + }; + for (auto *const member : enumDecl->Members()) { + enumClass->Body().push_back(createEnumItemField(member->AsTSEnumMember())); + } +} + ir::Identifier *EnumLoweringPhase::CreateEnumNamesArray(const ir::TSEnumDeclaration *const enumDecl, ir::ClassDefinition *const enumClass) { - auto *const stringTypeAnnotation = MakeTypeReference(checker_, "String"); // NOTE String -> Builtin? + auto *const stringTypeAnnotation = MakeTypeReference(checker_, STRING_REFERENCE_TYPE); // NOTE String -> Builtin? auto *const arrayTypeAnnotation = checker_->AllocNode(stringTypeAnnotation, Allocator()); // clang-format off - return MakeArray(enumDecl, enumClass, "NamesArray", arrayTypeAnnotation, + return MakeArray(enumDecl, enumClass, NAMES_ARRAY_NAME, arrayTypeAnnotation, [this](const ir::TSEnumMember *const member) { auto *const enumNameStringLiteral = checker_->AllocNode(member->Key()->AsIdentifier()->Name()); @@ -168,32 +194,28 @@ ir::Identifier *EnumLoweringPhase::CreateEnumNamesArray(const ir::TSEnumDeclarat } ir::ClassDeclaration *EnumLoweringPhase::CreateClass(ir::TSEnumDeclaration *const enumDecl, - const DeclarationFlags flags) + const DeclarationFlags flags, bool isIntEnum) { - auto *ident = Allocator()->New(GetEnumClassName(checker_, enumDecl).View(), Allocator()); + auto *ident = Allocator()->New(enumDecl->Key()->Name(), Allocator()); + ident->SetRange(enumDecl->Key()->Range()); + auto enumFlag = isIntEnum ? ir::ClassDefinitionModifiers::INT_ENUM_TRANSFORMED + : ir::ClassDefinitionModifiers::STRING_ENUM_TRANSFORMED; + auto baseClassDefinitionFlag = ir::ClassDefinitionModifiers::CLASS_DECL | enumFlag; auto *classDef = checker_->AllocNode( Allocator(), ident, - flags.isLocal ? ir::ClassDefinitionModifiers::CLASS_DECL | ir::ClassDefinitionModifiers::LOCAL - : ir::ClassDefinitionModifiers::CLASS_DECL, - enumDecl->IsDeclare() ? ir::ModifierFlags::DECLARE : ir::ModifierFlags::NONE, Language(Language::Id::ETS)); + flags.isLocal ? baseClassDefinitionFlag | ir::ClassDefinitionModifiers::LOCAL : baseClassDefinitionFlag, + enumDecl->IsDeclare() ? ir::ModifierFlags::FINAL | ir::ModifierFlags::DECLARE : ir::ModifierFlags::FINAL, + Language(Language::Id::ETS)); auto *classDecl = checker_->AllocNode(classDef, Allocator()); - if (flags.isLocal) { - enumDecl->Parent()->AsBlockStatement()->Statements().push_back(classDecl); - classDecl->SetParent(enumDecl->Parent()); - } else if (flags.isNamespace) { - enumDecl->Parent()->AsClassDefinition()->Body().push_back(classDecl); - classDecl->SetParent(enumDecl->Parent()); - } else if (flags.isTopLevel) { - program_->Ast()->Statements().push_back(classDecl); - classDecl->SetParent(program_->Ast()); - } else { // Maybe support local enums in the future - UNREACHABLE(); + if (enumDecl->IsExported()) { + classDecl->AddModifier(ir::ModifierFlags::EXPORT); + } else if (enumDecl->IsDefaultExported()) { + classDecl->AddModifier(ir::ModifierFlags::DEFAULT_EXPORT); } classDef->SetOrigEnumDecl(enumDecl); - enumDecl->SetBoxedClass(classDef); CreateOrdinalField(classDef); if (!enumDecl->IsDeclare()) { @@ -225,7 +247,7 @@ void EnumLoweringPhase::CreateCCtorForEnumClass(ir::ClassDefinition *const enumC auto *const identClone = id->Clone(Allocator(), nullptr); auto *const methodDef = checker_->AllocNode( - ir::MethodDefinitionKind::METHOD, identClone, funcExpr, ir::ModifierFlags::PUBLIC | ir::ModifierFlags::STATIC, + ir::MethodDefinitionKind::METHOD, identClone, funcExpr, ir::ModifierFlags::PRIVATE | ir::ModifierFlags::STATIC, Allocator(), false); methodDef->SetParent(enumClass); enumClass->Body().push_back(methodDef); @@ -233,10 +255,11 @@ void EnumLoweringPhase::CreateCCtorForEnumClass(ir::ClassDefinition *const enumC ir::ClassProperty *EnumLoweringPhase::CreateOrdinalField(ir::ClassDefinition *const enumClass) { - auto *const fieldIdent = Allocator()->New("ordinal", Allocator()); + auto *const fieldIdent = Allocator()->New(ORDINAL_NAME, Allocator()); auto *const intTypeAnnotation = Allocator()->New(ir::PrimitiveType::INT, Allocator()); auto *field = checker_->AllocNode(fieldIdent, nullptr, intTypeAnnotation, - ir::ModifierFlags::PROTECTED, Allocator(), false); + ir::ModifierFlags::PRIVATE | ir::ModifierFlags::READONLY, + Allocator(), false); enumClass->Body().push_back(field); field->SetParent(enumClass); @@ -248,7 +271,7 @@ ir::ScriptFunction *EnumLoweringPhase::CreateFunctionForCtorOfEnumClass(ir::Clas ArenaVector params(Allocator()->Adapter()); auto *const intTypeAnnotation = checker_->AllocNode(ir::PrimitiveType::INT, Allocator()); - auto *const inputOrdinalParam = MakeFunctionParam(checker_, "ordinal", intTypeAnnotation); + auto *const inputOrdinalParam = MakeFunctionParam(checker_, PARAM_ORDINAL, intTypeAnnotation); params.push_back(inputOrdinalParam); auto *id = checker_->AllocNode("constructor", Allocator()); @@ -262,17 +285,18 @@ ir::ScriptFunction *EnumLoweringPhase::CreateFunctionForCtorOfEnumClass(ir::Clas auto *func = checker_->AllocNode( Allocator(), ir::ScriptFunction::ScriptFunctionData {body, ir::FunctionSignature(nullptr, std::move(params), nullptr), - scriptFlags, // CC-OFF(G.FMT.02) project code style - ir::ModifierFlags::CONSTRUCTOR, // CC-OFF(G.FMT.02) project code style + scriptFlags, // CC-OFF(G.FMT.02) project code style + ir::ModifierFlags::CONSTRUCTOR | + ir::ModifierFlags::PRIVATE, // CC-OFF(G.FMT.02) project code style Language(Language::Id::ETS)}); // CC-OFF(G.FMT.02) project code style func->SetIdent(id); auto *thisExpr = Allocator()->New(); - auto *fieldIdentifier = Allocator()->New("ordinal", Allocator()); + auto *fieldIdentifier = Allocator()->New(ORDINAL_NAME, Allocator()); auto *leftHandSide = checker_->AllocNode( thisExpr, fieldIdentifier, ir::MemberExpressionKind::PROPERTY_ACCESS, false, false); - auto *rightHandSide = checker_->AllocNode("ordinal", Allocator()); + auto *rightHandSide = checker_->AllocNode(PARAM_ORDINAL, Allocator()); rightHandSide->SetVariable(inputOrdinalParam->Ident()->Variable()); auto *initializer = checker_->AllocNode(leftHandSide, rightHandSide, lexer::TokenType::PUNCTUATOR_SUBSTITUTION); @@ -298,91 +322,105 @@ void EnumLoweringPhase::CreateCtorForEnumClass(ir::ClassDefinition *const enumCl void EnumLoweringPhase::ProcessEnumClassDeclaration(ir::TSEnumDeclaration *const enumDecl, const DeclarationFlags &flags, ir::ClassDeclaration *enumClassDecl) { + varbinder::Variable *var = nullptr; + auto *ident = enumClassDecl->Definition()->Ident(); if (flags.isLocal) { - auto localCtx = varbinder::LexicalScope::Enter(varbinder_, NearestScope(enumDecl->Parent())); + auto *scope = NearestScope(enumDecl->Parent()); + auto localCtx = varbinder::LexicalScope::Enter(varbinder_, scope); InitScopesPhaseETS::RunExternalNode(enumClassDecl, varbinder_); + var = varbinder_->GetScope()->FindLocal(ident->Name(), varbinder::ResolveBindingOptions::ALL); } else if (flags.isTopLevel) { - auto localCtx = varbinder::LexicalScope::Enter(varbinder_, program_->GlobalScope()); + auto *scope = program_->GlobalClassScope(); + auto localCtx = varbinder::LexicalScope::Enter(varbinder_, scope); InitScopesPhaseETS::RunExternalNode(enumClassDecl, varbinder_); - auto *ident = enumClassDecl->Definition()->Ident(); - auto *var = varbinder_->GetScope()->FindLocal(ident->Name(), varbinder::ResolveBindingOptions::BINDINGS); - ident->SetVariable(var); + var = varbinder_->GetScope()->FindLocal(ident->Name(), varbinder::ResolveBindingOptions::ALL); + if (var != nullptr) { + program_->GlobalScope()->InsertBinding(ident->Name(), var); + } } else if (flags.isNamespace) { - auto localCtx = varbinder::LexicalScope::Enter(varbinder_, enumDecl->Parent()->Scope()); + auto *scope = enumDecl->Parent()->Scope(); + auto localCtx = varbinder::LexicalScope::Enter(varbinder_, scope); InitScopesPhaseETS::RunExternalNode(enumClassDecl, varbinder_); - auto *ident = enumClassDecl->Definition()->Ident(); - auto *var = varbinder_->GetScope()->FindLocal(ident->Name(), varbinder::ResolveBindingOptions::DECLARATION); - ident->SetVariable(var); + var = varbinder_->GetScope()->FindLocal(ident->Name(), varbinder::ResolveBindingOptions::DECLARATION); } else { UNREACHABLE(); } + if (var != nullptr) { + // Although it enum was transformed to class, it should still be regarded as enum. + var->RemoveFlag(varbinder::VariableFlags::CLASS); + var->AddFlag(varbinder::VariableFlags::ENUM_LITERAL); + } } -void EnumLoweringPhase::CreateEnumIntClassFromEnumDeclaration(ir::TSEnumDeclaration *const enumDecl, - const DeclarationFlags flags) +ir::ClassDeclaration *EnumLoweringPhase::CreateEnumIntClassFromEnumDeclaration(ir::TSEnumDeclaration *const enumDecl, + const DeclarationFlags flags) { - auto *const enumClassDecl = CreateClass(enumDecl, flags); + auto *const enumClassDecl = CreateClass(enumDecl, flags, true); auto *const enumClass = enumClassDecl->Definition(); + CreateEnumItemFields(enumDecl, enumClass); auto *const namesArrayIdent = CreateEnumNamesArray(enumDecl, enumClass); auto *const valuesArrayIdent = CreateEnumValuesArray(enumDecl, enumClass); auto *const stringValuesArrayIdent = CreateEnumStringValuesArray(enumDecl, enumClass); auto *const itemsArrayIdent = CreateEnumItemsArray(enumDecl, enumClass); - auto *const boxedItemsArrayIdent = CreateBoxedEnumItemsArray(enumDecl, enumClass); CreateEnumGetNameMethod(enumDecl, enumClass, namesArrayIdent); - CreateEnumGetValueOfMethod(enumDecl, enumClass, namesArrayIdent); + CreateEnumGetValueOfMethod(enumDecl, enumClass, namesArrayIdent, itemsArrayIdent); - CreateEnumValueOfMethod(enumDecl, enumClass, valuesArrayIdent); + CreateEnumFromValueMethod(enumDecl, enumClass, valuesArrayIdent, itemsArrayIdent, true); + + CreateEnumValueOfMethod(enumDecl, enumClass, valuesArrayIdent, true); CreateEnumToStringMethod(enumDecl, enumClass, stringValuesArrayIdent); CreateEnumValuesMethod(enumDecl, enumClass, itemsArrayIdent); - CreateEnumFromIntMethod(enumDecl, enumClass, itemsArrayIdent, checker::ETSEnumType::FROM_INT_METHOD_NAME, - enumDecl->Key()->Name()); - - CreateUnboxingMethod(enumDecl, enumClass, itemsArrayIdent); + CreateEnumGetOrdinalMethod(enumDecl, enumClass); - CreateEnumFromIntMethod(enumDecl, enumClass, boxedItemsArrayIdent, checker::ETSEnumType::BOXED_FROM_INT_METHOD_NAME, - GetEnumClassName(checker_, enumDecl).View()); + CreateEnumDollarGetMethod(enumDecl, enumClass); SetDefaultPositionInUnfilledClassNodes(enumClassDecl, enumDecl); + enumClassDecl->SetParent(enumDecl->Parent()); ProcessEnumClassDeclaration(enumDecl, flags, enumClassDecl); + + return enumClassDecl; } -void EnumLoweringPhase::CreateEnumStringClassFromEnumDeclaration(ir::TSEnumDeclaration *const enumDecl, - const DeclarationFlags flags) +ir::ClassDeclaration *EnumLoweringPhase::CreateEnumStringClassFromEnumDeclaration(ir::TSEnumDeclaration *const enumDecl, + const DeclarationFlags flags) { - auto *const enumClassDecl = CreateClass(enumDecl, flags); + auto *const enumClassDecl = CreateClass(enumDecl, flags, false); auto *const enumClass = enumClassDecl->Definition(); + CreateEnumItemFields(enumDecl, enumClass); auto *const namesArrayIdent = CreateEnumNamesArray(enumDecl, enumClass); auto *const stringValuesArrayIdent = CreateEnumStringValuesArray(enumDecl, enumClass); auto *const itemsArrayIdent = CreateEnumItemsArray(enumDecl, enumClass); - auto *const boxedItemsArrayIdent = CreateBoxedEnumItemsArray(enumDecl, enumClass); CreateEnumGetNameMethod(enumDecl, enumClass, namesArrayIdent); - CreateEnumGetValueOfMethod(enumDecl, enumClass, namesArrayIdent); + CreateEnumGetValueOfMethod(enumDecl, enumClass, namesArrayIdent, itemsArrayIdent); + + CreateEnumFromValueMethod(enumDecl, enumClass, stringValuesArrayIdent, itemsArrayIdent, false); + + CreateEnumValueOfMethod(enumDecl, enumClass, stringValuesArrayIdent, false); CreateEnumToStringMethod(enumDecl, enumClass, stringValuesArrayIdent); CreateEnumValuesMethod(enumDecl, enumClass, itemsArrayIdent); - CreateEnumFromIntMethod(enumDecl, enumClass, itemsArrayIdent, checker::ETSEnumType::FROM_INT_METHOD_NAME, - enumDecl->Key()->Name()); - - CreateUnboxingMethod(enumDecl, enumClass, itemsArrayIdent); + CreateEnumGetOrdinalMethod(enumDecl, enumClass); - CreateEnumFromIntMethod(enumDecl, enumClass, boxedItemsArrayIdent, checker::ETSEnumType::BOXED_FROM_INT_METHOD_NAME, - GetEnumClassName(checker_, enumDecl).View()); + CreateEnumDollarGetMethod(enumDecl, enumClass); SetDefaultPositionInUnfilledClassNodes(enumClassDecl, enumDecl); + enumClassDecl->SetParent(enumDecl->Parent()); ProcessEnumClassDeclaration(enumDecl, flags, enumClassDecl); + + return enumClassDecl; } static EnumLoweringPhase::DeclarationFlags GetDeclFlags(ir::TSEnumDeclaration *const enumDecl) @@ -405,30 +443,36 @@ bool EnumLoweringPhase::PerformForModule(public_lib::Context *ctx, parser::Progr checker_ = ctx->checker->AsETSChecker(); varbinder_ = ctx->parserProgram->VarBinder()->AsETSBinder(); program_ = program; - program->Ast()->IterateRecursively([this, &isPerformedSuccess](ir::AstNode *ast) -> void { - if (ast->IsTSEnumDeclaration()) { - auto *enumDecl = ast->AsTSEnumDeclaration(); - auto const flags = GetDeclFlags(enumDecl); - // Skip processing possibly invalid enum declaration (for multi-error reporting) - if (!flags.IsValid() || enumDecl->Members().empty()) { - return; - } - bool hasLoggedError = false; - if (auto *const itemInit = enumDecl->Members().front()->AsTSEnumMember()->Init(); - itemInit->IsNumberLiteral() && - CheckEnumMemberType(enumDecl->Members(), hasLoggedError)) { - CreateEnumIntClassFromEnumDeclaration(enumDecl, flags); - } else if (itemInit->IsStringLiteral() && - CheckEnumMemberType(enumDecl->Members(), hasLoggedError)) { - CreateEnumStringClassFromEnumDeclaration(enumDecl, flags); - } else if (!hasLoggedError) { - LogSyntaxError("Invalid enum initialization value", itemInit->Start()); - isPerformedSuccess = false; - } else { - isPerformedSuccess = false; + program->Ast()->TransformChildrenRecursively( + [this, &isPerformedSuccess](ir::AstNode *ast) -> AstNodePtr { + if (ast->IsTSEnumDeclaration()) { + auto *enumDecl = ast->AsTSEnumDeclaration(); + auto const flags = GetDeclFlags(enumDecl); + // Skip processing possibly invalid enum declaration (for multi-error reporting) + if (!flags.IsValid() || enumDecl->Members().empty()) { + return ast; + } + bool hasLoggedError = false; + auto *const itemInit = enumDecl->Members().front()->AsTSEnumMember()->Init(); + if (itemInit->IsNumberLiteral() && + CheckEnumMemberType(enumDecl->Members(), hasLoggedError)) { + return CreateEnumIntClassFromEnumDeclaration(enumDecl, flags); + } + if (itemInit->IsStringLiteral() && + CheckEnumMemberType(enumDecl->Members(), hasLoggedError)) { + return CreateEnumStringClassFromEnumDeclaration(enumDecl, flags); + } + if (!hasLoggedError) { + LogSyntaxError("Invalid enum initialization value", itemInit->Start()); + isPerformedSuccess = false; + } else { + isPerformedSuccess = false; + } + return ast; } - } - }); + return ast; + }, + Name()); return isPerformedSuccess; } @@ -438,14 +482,14 @@ ir::Identifier *EnumLoweringPhase::CreateEnumValuesArray(const ir::TSEnumDeclara auto *const intType = checker_->AllocNode(ir::PrimitiveType::INT, Allocator()); auto *const arrayTypeAnnotation = checker_->AllocNode(intType, Allocator()); // clang-format off - return MakeArray(enumDecl, enumClass, "ValuesArray", arrayTypeAnnotation, + return MakeArray(enumDecl, enumClass, VALUES_ARRAY_NAME, arrayTypeAnnotation, [this](const ir::TSEnumMember *const member) { auto *const enumValueLiteral = checker_->AllocNode( lexer::Number(member->AsTSEnumMember() ->Init() ->AsNumberLiteral() ->Number() - .GetValue())); + .GetValue())); return enumValueLiteral; }); // clang-format on @@ -454,11 +498,11 @@ ir::Identifier *EnumLoweringPhase::CreateEnumValuesArray(const ir::TSEnumDeclara ir::Identifier *EnumLoweringPhase::CreateEnumStringValuesArray(const ir::TSEnumDeclaration *const enumDecl, ir::ClassDefinition *const enumClass) { - auto *const stringTypeAnnotation = MakeTypeReference(checker_, "String"); // NOTE String -> Builtin? + auto *const stringTypeAnnotation = MakeTypeReference(checker_, STRING_REFERENCE_TYPE); // NOTE String -> Builtin? auto *const arrayTypeAnnotation = checker_->AllocNode(stringTypeAnnotation, Allocator()); // clang-format off - return MakeArray(enumDecl, enumClass, "StringValuesArray", arrayTypeAnnotation, + return MakeArray(enumDecl, enumClass, STRING_VALUES_ARRAY_NAME, arrayTypeAnnotation, [this](const ir::TSEnumMember *const member) { auto *const init = member->AsTSEnumMember()->Init(); util::StringView stringValue; @@ -467,7 +511,7 @@ ir::Identifier *EnumLoweringPhase::CreateEnumStringValuesArray(const ir::TSEnumD stringValue = init->AsStringLiteral()->Str(); } else { auto str = std::to_string( - init->AsNumberLiteral()->Number().GetValue()); + init->AsNumberLiteral()->Number().GetValue()); stringValue = util::UString(str, Allocator()).View(); } @@ -480,13 +524,13 @@ ir::Identifier *EnumLoweringPhase::CreateEnumStringValuesArray(const ir::TSEnumD ir::Identifier *EnumLoweringPhase::CreateEnumItemsArray(const ir::TSEnumDeclaration *const enumDecl, ir::ClassDefinition *const enumClass) { - auto *const enumTypeAnnotation = MakeTypeReference(checker_, enumDecl->Key()->Name()); + auto *const enumTypeAnnotation = MakeTypeReference(checker_, enumClass->Ident()->Name()); auto *const arrayTypeAnnotation = checker_->AllocNode(enumTypeAnnotation, Allocator()); // clang-format off - return MakeArray(enumDecl, enumClass, "ItemsArray", arrayTypeAnnotation, - [this, enumDecl](const ir::TSEnumMember *const member) { + return MakeArray(enumDecl, enumClass, ITEMS_ARRAY_NAME, arrayTypeAnnotation, + [this, enumClass, enumDecl](const ir::TSEnumMember *const member) { auto *const enumTypeIdent = - checker_->AllocNode(enumDecl->Key()->Name(), Allocator()); + checker_->AllocNode(enumClass->Ident()->Name(), Allocator()); enumTypeIdent->SetRange(enumDecl->Key()->Range()); auto *const enumMemberIdent = checker_->AllocNode( member->AsTSEnumMember()->Key()->AsIdentifier()->Name(), Allocator()); @@ -498,37 +542,13 @@ ir::Identifier *EnumLoweringPhase::CreateEnumItemsArray(const ir::TSEnumDeclarat // clang-format on } -ir::Identifier *EnumLoweringPhase::CreateBoxedEnumItemsArray(const ir::TSEnumDeclaration *const enumDecl, - ir::ClassDefinition *const enumClass) +ir::MemberExpression *EnumLoweringPhase::CreateOrdinalAccessExpression() { - auto boxedClassName = GetEnumClassName(checker_, enumDecl).View(); - auto *const enumTypeAnnotation = MakeTypeReference(checker_, boxedClassName); - auto *const arrayTypeAnnotation = checker_->AllocNode(enumTypeAnnotation, Allocator()); - // clang-format off - return MakeArray(enumDecl, enumClass, "BoxedItemsArray", arrayTypeAnnotation, - [this, enumDecl, &boxedClassName](const ir::TSEnumMember *const member) { - auto *const enumTypeIdent = - checker_->AllocNode(enumDecl->Key()->Name(), Allocator()); - enumTypeIdent->SetRange(enumDecl->Key()->Range()); - auto *const enumMemberIdent = checker_->AllocNode( - member->AsTSEnumMember()->Key()->AsIdentifier()->Name(), Allocator()); - enumMemberIdent->SetRange(member->AsTSEnumMember()->Key()->Range()); - auto *const enumMemberExpr = checker_->AllocNode( - enumTypeIdent, enumMemberIdent, ir::MemberExpressionKind::PROPERTY_ACCESS, false, false); - - auto intType = checker_->AllocNode(ir::PrimitiveType::INT, Allocator()); - auto asExpression = checker_->AllocNode(enumMemberExpr, intType, false); - - ArenaVector newExprArgs(Allocator()->Adapter()); - newExprArgs.push_back(asExpression); - - auto boxedTypeRef = MakeTypeReference(checker_, boxedClassName); - - auto *const newExpression = checker_->AllocNode( - boxedTypeRef, std::move(newExprArgs)); - return newExpression; - }); - // clang-format on + auto *thisExpr = checker_->AllocNode(); + auto *fieldIdentifier = checker_->AllocNode(ORDINAL_NAME, checker_->Allocator()); + auto *ordinalAccessExpr = checker_->AllocNode( + thisExpr, fieldIdentifier, ir::MemberExpressionKind::PROPERTY_ACCESS, false, false); + return ordinalAccessExpr; } namespace { @@ -544,34 +564,6 @@ ir::MemberExpression *CreateStaticAccessMemberExpression(checker::ETSChecker *ch ir::MemberExpressionKind::PROPERTY_ACCESS, false, false); } -ir::BinaryExpression *CreateIfTest(checker::ETSChecker *checker, ir::Identifier *const enumClassIdentifier, - ir::Identifier *const itemsArrayIdentifier, - ir::ETSParameterExpression *const parameter) -{ - auto *const lengthIdent = checker->AllocNode("length", checker->Allocator()); - auto *const propertyAccessExpr = - CreateStaticAccessMemberExpression(checker, enumClassIdentifier, itemsArrayIdentifier); - auto *const valuesArrayLengthExpr = checker->AllocNode( - propertyAccessExpr, lengthIdent, ir::MemberExpressionKind::PROPERTY_ACCESS, false, false); - auto *const paramRefIdent = MakeParamRefIdent(checker, parameter); - auto *const expr = checker->AllocNode(paramRefIdent, valuesArrayLengthExpr, - lexer::TokenType::PUNCTUATOR_LESS_THAN); - paramRefIdent->SetParent(expr); - return expr; -} -ir::ReturnStatement *CreateReturnEnumStatement(checker::ETSChecker *checker, ir::Identifier *const enumClassIdentifier, - ir::Identifier *const itemsArrayIdentifier, - ir::ETSParameterExpression *const parameter) -{ - auto *const paramRefIdent = MakeParamRefIdent(checker, parameter); - auto *const propertyAccessExpr = - CreateStaticAccessMemberExpression(checker, enumClassIdentifier, itemsArrayIdentifier); - auto *const arrayAccessExpr = checker->AllocNode( - propertyAccessExpr, paramRefIdent, ir::MemberExpressionKind::ELEMENT_ACCESS, true, false); - auto *const returnStatement = checker->AllocNode(arrayAccessExpr); - return returnStatement; -} - ir::ThrowStatement *CreateThrowStatement(checker::ETSChecker *checker, ir::ETSParameterExpression *const parameter, const util::UString &messageString) { @@ -584,84 +576,51 @@ ir::ThrowStatement *CreateThrowStatement(checker::ETSChecker *checker, ir::ETSPa ArenaVector newExprArgs(checker->Allocator()->Adapter()); newExprArgs.push_back(newExprArg); - auto *const exceptionReference = MakeTypeReference(checker, "Exception"); + auto *const exceptionReference = MakeTypeReference(checker, "Error"); auto *const newExpr = checker->AllocNode(exceptionReference, std::move(newExprArgs)); return checker->AllocNode(newExpr); } -ir::ReturnStatement *CreateReturnWitAsStatement(checker::ETSChecker *checker, ir::Identifier *const enumClassIdentifier, - ir::Identifier *const arrayIdentifier, - ir::ETSParameterExpression *const parameter) +ir::ReturnStatement *CreateReturnStatement(checker::ETSChecker *checker, ir::Identifier *const enumClassIdentifier, + ir::Identifier *const arrayIdentifier, ir::Expression *const parameter) { - auto *const paramRefIdent = MakeParamRefIdent(checker, parameter); - auto intType = checker->AllocNode(ir::PrimitiveType::INT, checker->Allocator()); - auto asExpression = checker->AllocNode(paramRefIdent, intType, false); - paramRefIdent->SetParent(asExpression); - auto *const propertyAccessExpr = CreateStaticAccessMemberExpression(checker, enumClassIdentifier, arrayIdentifier); auto *const arrayAccessExpr = checker->AllocNode( - propertyAccessExpr, asExpression, ir::MemberExpressionKind::ELEMENT_ACCESS, true, false); + propertyAccessExpr, parameter, ir::MemberExpressionKind::ELEMENT_ACCESS, true, false); return checker->AllocNode(arrayAccessExpr); } -} // namespace - -void EnumLoweringPhase::CreateEnumFromIntMethod(const ir::TSEnumDeclaration *const enumDecl, - ir::ClassDefinition *const enumClass, ir::Identifier *const arrayIdent, - const util::StringView &methodName, - const util::StringView &returnTypeName) +ir::CallExpression *CreateCallInstanceMethod(checker::ETSChecker *checker, std::string_view methodName, + ir::Expression *thisArg) { - auto *const intTypeAnnotation = checker_->AllocNode(ir::PrimitiveType::INT, Allocator()); - auto *const inputOrdinalParameter = MakeFunctionParam(checker_, "ordinal", intTypeAnnotation); - auto *const inArraySizeExpr = CreateIfTest(checker_, enumClass->Ident(), arrayIdent, inputOrdinalParameter); - auto *const returnEnumStmt = - CreateReturnEnumStatement(checker_, enumClass->Ident(), arrayIdent, inputOrdinalParameter); - auto *const ifOrdinalExistsStmt = checker_->AllocNode(inArraySizeExpr, returnEnumStmt, nullptr); - - auto const messageString = util::UString(std::string_view("No enum constant in "), Allocator()) - .Append(enumDecl->Key()->Name()) - .Append(" with ordinal value "); - - auto *const throwNoEnumStmt = CreateThrowStatement(checker_, inputOrdinalParameter, messageString); - - ArenaVector params(Allocator()->Adapter()); - params.push_back(inputOrdinalParameter); - - ArenaVector body(Allocator()->Adapter()); - body.push_back(ifOrdinalExistsStmt); - body.push_back(throwNoEnumStmt); - auto *const returnTypeAnnotation = MakeTypeReference(checker_, returnTypeName); - - auto *const function = MakeFunction({std::move(params), std::move(body), returnTypeAnnotation, enumDecl, - ir::ModifierFlags::PUBLIC | ir::ModifierFlags::STATIC}); - function->AddFlag(ir::ScriptFunctionFlags::THROWS); - auto *const ident = checker_->AllocNode(methodName, Allocator()); - - function->SetIdent(ident); + auto methodId = checker->AllocNode(methodName, checker->Allocator()); + auto callee = checker->AllocNode(thisArg, methodId, ir::MemberExpressionKind::PROPERTY_ACCESS, + false, false); - MakeMethodDef(checker_, enumClass, ident, function); + ArenaVector callArguments({}, checker->Allocator()->Adapter()); + return checker->AllocNode(callee, std::move(callArguments), nullptr, false); } +} // namespace + void EnumLoweringPhase::CreateEnumToStringMethod(const ir::TSEnumDeclaration *const enumDecl, ir::ClassDefinition *const enumClass, ir::Identifier *const stringValuesArrayIdent) { - auto *const enumTypeAnnotation = MakeTypeReference(checker_, enumDecl->Key()->Name()); - auto *const inputEnumIdent = MakeFunctionParam(checker_, "ordinal", enumTypeAnnotation); + auto *ordinalAccessExpr = CreateOrdinalAccessExpression(); auto *const returnStmt = - CreateReturnWitAsStatement(checker_, enumClass->Ident(), stringValuesArrayIdent, inputEnumIdent); + CreateReturnStatement(checker_, enumClass->Ident(), stringValuesArrayIdent, ordinalAccessExpr); ArenaVector body(Allocator()->Adapter()); body.push_back(returnStmt); ArenaVector params(Allocator()->Adapter()); - params.push_back(inputEnumIdent); - auto *const stringTypeAnnotation = MakeTypeReference(checker_, "String"); // NOTE String -> Builtin? - auto *const function = MakeFunction({std::move(params), std::move(body), stringTypeAnnotation, enumDecl, - ir::ModifierFlags::PUBLIC | ir::ModifierFlags::STATIC}); + auto *const stringTypeAnnotation = MakeTypeReference(checker_, STRING_REFERENCE_TYPE); // NOTE String -> Builtin? + auto *const function = + MakeFunction({std::move(params), std::move(body), stringTypeAnnotation, enumDecl, ir::ModifierFlags::PUBLIC}); auto *const functionIdent = checker_->AllocNode(checker::ETSEnumType::TO_STRING_METHOD_NAME, Allocator()); @@ -672,20 +631,20 @@ void EnumLoweringPhase::CreateEnumToStringMethod(const ir::TSEnumDeclaration *co void EnumLoweringPhase::CreateEnumValueOfMethod(const ir::TSEnumDeclaration *const enumDecl, ir::ClassDefinition *const enumClass, - ir::Identifier *const valuesArrayIdent) + ir::Identifier *const valuesArrayIdent, bool isIntEnum) { - auto *const enumTypeAnnotation = MakeTypeReference(checker_, enumDecl->Key()->Name()); - auto *const inputEnumIdent = MakeFunctionParam(checker_, "e", enumTypeAnnotation); - auto *const returnStmt = CreateReturnWitAsStatement(checker_, enumClass->Ident(), valuesArrayIdent, inputEnumIdent); + auto *ordinalAccessExpr = CreateOrdinalAccessExpression(); + auto *const returnStmt = CreateReturnStatement(checker_, enumClass->Ident(), valuesArrayIdent, ordinalAccessExpr); ArenaVector body(Allocator()->Adapter()); body.push_back(returnStmt); ArenaVector params(Allocator()->Adapter()); - params.push_back(inputEnumIdent); - auto *const intTypeAnnotation = checker_->AllocNode(ir::PrimitiveType::INT, Allocator()); - auto *const function = MakeFunction({std::move(params), std::move(body), intTypeAnnotation, enumDecl, - ir::ModifierFlags::PUBLIC | ir::ModifierFlags::STATIC}); + auto *const typeAnnotation = + isIntEnum ? checker_->AllocNode(ir::PrimitiveType::INT, Allocator())->AsTypeNode() + : MakeTypeReference(checker_, STRING_REFERENCE_TYPE)->AsTypeNode(); + auto *const function = + MakeFunction({std::move(params), std::move(body), typeAnnotation, enumDecl, ir::ModifierFlags::PUBLIC}); auto *const functionIdent = checker_->AllocNode(checker::ETSEnumType::VALUE_OF_METHOD_NAME, Allocator()); function->SetIdent(functionIdent); @@ -697,19 +656,17 @@ void EnumLoweringPhase::CreateEnumGetNameMethod(const ir::TSEnumDeclaration *con ir::ClassDefinition *const enumClass, ir::Identifier *const namesArrayIdent) { - auto *const enumTypeAnnotation = MakeTypeReference(checker_, enumDecl->Key()->Name()); - auto *const inputEnumIdent = MakeFunctionParam(checker_, "ordinal", enumTypeAnnotation); - auto *const returnStmt = CreateReturnWitAsStatement(checker_, enumClass->Ident(), namesArrayIdent, inputEnumIdent); + auto ordinalAccessExpr = CreateOrdinalAccessExpression(); + auto *const returnStmt = CreateReturnStatement(checker_, enumClass->Ident(), namesArrayIdent, ordinalAccessExpr); ArenaVector body(Allocator()->Adapter()); body.push_back(returnStmt); ArenaVector params(Allocator()->Adapter()); - params.push_back(inputEnumIdent); - auto *const stringTypeAnnotation = MakeTypeReference(checker_, "String"); // NOTE String -> Builtin? + auto *const stringTypeAnnotation = MakeTypeReference(checker_, STRING_REFERENCE_TYPE); // NOTE String -> Builtin? - auto *const function = MakeFunction({std::move(params), std::move(body), stringTypeAnnotation, enumDecl, - ir::ModifierFlags::PUBLIC | ir::ModifierFlags::STATIC}); + auto *const function = + MakeFunction({std::move(params), std::move(body), stringTypeAnnotation, enumDecl, ir::ModifierFlags::PUBLIC}); auto *const functionIdent = checker_->AllocNode(checker::ETSEnumType::GET_NAME_METHOD_NAME, Allocator()); @@ -758,8 +715,8 @@ ir::UpdateExpression *CreateForLoopUpdate(checker::ETSChecker *checker, ir::Iden return incrementExpr; } -ir::IfStatement *CreateIf(checker::ETSChecker *checker, const ir::TSEnumDeclaration *const enumDecl, - ir::MemberExpression *propertyAccessExpr, ir::Identifier *const loopIdentifier, +ir::IfStatement *CreateIf(checker::ETSChecker *checker, ir::MemberExpression *propertyAccessExpr, + ir::MemberExpression *itemAccessExpr, ir::Identifier *const loopIdentifier, ir::ETSParameterExpression *const parameter) { auto *const forLoopIdentClone1 = loopIdentifier->Clone(checker->Allocator(), nullptr); @@ -770,11 +727,13 @@ ir::IfStatement *CreateIf(checker::ETSChecker *checker, const ir::TSEnumDeclarat auto *const namesEqualExpr = checker->AllocNode(paramRefIdent, namesArrayElementExpr, lexer::TokenType::PUNCTUATOR_EQUAL); paramRefIdent->SetParent(namesEqualExpr); + auto *const forLoopIdentClone2 = loopIdentifier->Clone(checker->Allocator(), nullptr); - auto *const enumTypeAnnotation = MakeTypeReference(checker, enumDecl->Key()->Name()); - auto asExpression = checker->AllocNode(forLoopIdentClone2, enumTypeAnnotation, false); - auto *const returnStmt = checker->AllocNode(asExpression); + auto *const itemsArrayElementExpr = checker->AllocNode( + itemAccessExpr, forLoopIdentClone2, ir::MemberExpressionKind::ELEMENT_ACCESS, true, false); + + auto *const returnStmt = checker->AllocNode(itemsArrayElementExpr); return checker->AllocNode(namesEqualExpr, returnStmt, nullptr); } @@ -782,26 +741,28 @@ ir::IfStatement *CreateIf(checker::ETSChecker *checker, const ir::TSEnumDeclarat void EnumLoweringPhase::CreateEnumGetValueOfMethod(const ir::TSEnumDeclaration *const enumDecl, ir::ClassDefinition *const enumClass, - ir::Identifier *const namesArrayIdent) + ir::Identifier *const namesArrayIdent, + ir::Identifier *const itemsArrayIdent) { - auto *const forLoopIIdent = checker_->AllocNode("i", checker_->Allocator()); + auto *const forLoopIIdent = checker_->AllocNode(IDENTIFIER_I, checker_->Allocator()); auto *const forLoopInitVarDecl = CreateForLoopInitVariableDeclaration(checker_, forLoopIIdent); auto *const forLoopTest = CreateForLoopTest(checker_, enumClass->Ident(), namesArrayIdent, forLoopIIdent); auto *const forLoopUpdate = CreateForLoopUpdate(checker_, forLoopIIdent); - auto *const stringTypeAnnotation = MakeTypeReference(checker_, "String"); // NOTE String -> Builtin? - auto *const inputNameIdent = MakeFunctionParam(checker_, "name", stringTypeAnnotation); + auto *const stringTypeAnnotation = MakeTypeReference(checker_, STRING_REFERENCE_TYPE); // NOTE String -> Builtin? + auto *const inputNameIdent = MakeFunctionParam(checker_, PARAM_NAME, stringTypeAnnotation); auto *const ifStmt = - CreateIf(checker_, enumDecl, CreateStaticAccessMemberExpression(checker_, enumClass->Ident(), namesArrayIdent), - forLoopIIdent, inputNameIdent); + CreateIf(checker_, CreateStaticAccessMemberExpression(checker_, enumClass->Ident(), namesArrayIdent), + CreateStaticAccessMemberExpression(checker_, enumClass->Ident(), itemsArrayIdent), forLoopIIdent, + inputNameIdent); auto *const forLoop = checker_->AllocNode(forLoopInitVarDecl, forLoopTest, forLoopUpdate, ifStmt); util::UString messageString(util::StringView("No enum constant "), Allocator()); - messageString.Append(enumDecl->Key()->Name()); + messageString.Append(enumClass->Ident()->Name()); messageString.Append('.'); - [[maybe_unused]] auto *const throwStmt = CreateThrowStatement(checker_, inputNameIdent, messageString); + auto *const throwStmt = CreateThrowStatement(checker_, inputNameIdent, messageString); ArenaVector body(Allocator()->Adapter()); body.push_back(forLoop); @@ -809,11 +770,10 @@ void EnumLoweringPhase::CreateEnumGetValueOfMethod(const ir::TSEnumDeclaration * ArenaVector params(Allocator()->Adapter()); params.push_back(inputNameIdent); - auto *const enumTypeAnnotation = MakeTypeReference(checker_, enumDecl->Key()->Name()); + auto *const enumTypeAnnotation = MakeTypeReference(checker_, enumClass->Ident()->Name()); auto *const function = MakeFunction({std::move(params), std::move(body), enumTypeAnnotation, enumDecl, ir::ModifierFlags::PUBLIC | ir::ModifierFlags::STATIC}); - function->AddFlag(ir::ScriptFunctionFlags::THROWS); auto *const functionIdent = checker_->AllocNode(checker::ETSEnumType::GET_VALUE_OF_METHOD_NAME, Allocator()); @@ -821,6 +781,50 @@ void EnumLoweringPhase::CreateEnumGetValueOfMethod(const ir::TSEnumDeclaration * MakeMethodDef(checker_, enumClass, functionIdent, function); } +void EnumLoweringPhase::CreateEnumFromValueMethod(ir::TSEnumDeclaration const *const enumDecl, + ir::ClassDefinition *const enumClass, + ir::Identifier *const valuesArrayIdent, + ir::Identifier *const itemsArrayIdent, bool isIntEnum) +{ + auto *const forLoopIIdent = checker_->AllocNode(IDENTIFIER_I, checker_->Allocator()); + auto *const forLoopInitVarDecl = CreateForLoopInitVariableDeclaration(checker_, forLoopIIdent); + auto *const forLoopTest = CreateForLoopTest(checker_, enumClass->Ident(), valuesArrayIdent, forLoopIIdent); + auto *const forLoopUpdate = CreateForLoopUpdate(checker_, forLoopIIdent); + auto *const typeAnnotation = + isIntEnum ? checker_->AllocNode(ir::PrimitiveType::INT, Allocator())->AsTypeNode() + : MakeTypeReference(checker_, STRING_REFERENCE_TYPE)->AsTypeNode(); + auto *const inputValueIdent = MakeFunctionParam(checker_, PARAM_VALUE, typeAnnotation); + auto *const ifStmt = + CreateIf(checker_, CreateStaticAccessMemberExpression(checker_, enumClass->Ident(), valuesArrayIdent), + CreateStaticAccessMemberExpression(checker_, enumClass->Ident(), itemsArrayIdent), forLoopIIdent, + inputValueIdent); + + auto *const forLoop = + checker_->AllocNode(forLoopInitVarDecl, forLoopTest, forLoopUpdate, ifStmt); + + util::UString messageString(util::StringView("No enum "), Allocator()); + messageString.Append(enumClass->Ident()->Name()); + messageString.Append(" with value "); + + auto *const throwStmt = CreateThrowStatement(checker_, inputValueIdent, messageString); + + ArenaVector body(Allocator()->Adapter()); + body.push_back(forLoop); + body.push_back(throwStmt); + + ArenaVector params(Allocator()->Adapter()); + params.push_back(inputValueIdent); + auto *const enumTypeAnnotation = MakeTypeReference(checker_, enumClass->Ident()->Name()); + + auto *const function = MakeFunction({std::move(params), std::move(body), enumTypeAnnotation, enumDecl, + ir::ModifierFlags::PUBLIC | ir::ModifierFlags::STATIC}); + auto *const functionIdent = + checker_->AllocNode(checker::ETSEnumType::FROM_VALUE_METHOD_NAME, Allocator()); + + function->SetIdent(functionIdent); + MakeMethodDef(checker_, enumClass, functionIdent, function); +} + void EnumLoweringPhase::CreateEnumValuesMethod(const ir::TSEnumDeclaration *const enumDecl, ir::ClassDefinition *const enumClass, ir::Identifier *const itemsArrayIdent) @@ -832,7 +836,7 @@ void EnumLoweringPhase::CreateEnumValuesMethod(const ir::TSEnumDeclaration *cons ArenaVector params(Allocator()->Adapter()); auto *const enumArrayTypeAnnotation = - checker_->AllocNode(MakeTypeReference(checker_, enumDecl->Key()->Name()), Allocator()); + checker_->AllocNode(MakeTypeReference(checker_, enumClass->Ident()->Name()), Allocator()); auto *const function = MakeFunction({std::move(params), std::move(body), enumArrayTypeAnnotation, enumDecl, ir::ModifierFlags::PUBLIC | ir::ModifierFlags::STATIC}); @@ -843,34 +847,46 @@ void EnumLoweringPhase::CreateEnumValuesMethod(const ir::TSEnumDeclaration *cons MakeMethodDef(checker_, enumClass, functionIdent, function); } -void EnumLoweringPhase::CreateUnboxingMethod(ir::TSEnumDeclaration const *const enumDecl, - ir::ClassDefinition *const enumClass, - ir::Identifier *const itemsArrayIdent) - +void EnumLoweringPhase::CreateEnumGetOrdinalMethod(const ir::TSEnumDeclaration *const enumDecl, + ir::ClassDefinition *const enumClass) { + auto ordinalAccessExpr = CreateOrdinalAccessExpression(); + auto *const returnStmt = checker_->AllocNode(ordinalAccessExpr); ArenaVector body(Allocator()->Adapter()); - - auto *thisExpr = Allocator()->New(); - auto *fieldIdentifier = Allocator()->New("ordinal", Allocator()); - auto *arrayIndexExpr = checker_->AllocNode( - thisExpr, fieldIdentifier, ir::MemberExpressionKind::PROPERTY_ACCESS, false, false); - - auto *const propertyAccessExpr = CreateStaticAccessMemberExpression(checker_, enumClass->Ident(), itemsArrayIdent); - auto *const arrayAccessExpr = checker_->AllocNode( - propertyAccessExpr, arrayIndexExpr, ir::MemberExpressionKind::ELEMENT_ACCESS, true, false); - - auto *const returnStmt = checker_->AllocNode(arrayAccessExpr); body.push_back(returnStmt); ArenaVector params(Allocator()->Adapter()); - - auto *const returnTypeAnnotation = MakeTypeReference(checker_, enumDecl->Key()->Name()); + auto *const intTypeAnnotation = Allocator()->New(ir::PrimitiveType::INT, Allocator()); auto *const function = - MakeFunction({std::move(params), std::move(body), returnTypeAnnotation, enumDecl, ir::ModifierFlags::PUBLIC}); + MakeFunction({std::move(params), std::move(body), intTypeAnnotation, enumDecl, ir::ModifierFlags::PUBLIC}); + + auto *const functionIdent = + checker_->AllocNode(checker::ETSEnumType::GET_ORDINAL_METHOD_NAME, Allocator()); + function->SetIdent(functionIdent); + + MakeMethodDef(checker_, enumClass, functionIdent, function); +} +void EnumLoweringPhase::CreateEnumDollarGetMethod(ir::TSEnumDeclaration const *const enumDecl, + ir::ClassDefinition *const enumClass) +{ + auto *const inputTypeAnnotation = MakeTypeReference(checker_, enumClass->Ident()->Name()); + auto *const inputNameIdent = MakeFunctionParam(checker_, "e", inputTypeAnnotation); + auto *const paramRefIdent = MakeParamRefIdent(checker_, inputNameIdent); + auto *const callExpr = + CreateCallInstanceMethod(checker_, checker::ETSEnumType::GET_NAME_METHOD_NAME, paramRefIdent); + auto *const returnStmt = checker_->AllocNode(callExpr); + ArenaVector body(Allocator()->Adapter()); + body.push_back(returnStmt); + + ArenaVector params(Allocator()->Adapter()); + params.push_back(inputNameIdent); + auto *const stringTypeAnnotation = MakeTypeReference(checker_, STRING_REFERENCE_TYPE); + auto *const function = MakeFunction({std::move(params), std::move(body), stringTypeAnnotation, enumDecl, + ir::ModifierFlags::PUBLIC | ir::ModifierFlags::STATIC}); auto *const functionIdent = - checker_->AllocNode(checker::ETSEnumType::UNBOX_METHOD_NAME, Allocator()); + checker_->AllocNode(checker::ETSEnumType::DOLLAR_GET_METHOD_NAME, Allocator()); function->SetIdent(functionIdent); MakeMethodDef(checker_, enumClass, functionIdent, function); diff --git a/ets2panda/compiler/lowering/ets/enumLowering.h b/ets2panda/compiler/lowering/ets/enumLowering.h index 0c6f960a6f..3e003e02cb 100644 --- a/ets2panda/compiler/lowering/ets/enumLowering.h +++ b/ets2panda/compiler/lowering/ets/enumLowering.h @@ -16,12 +16,25 @@ #ifndef ES2PANDA_COMPILER_ENUM_PRE_CHECK_LOWERING_H #define ES2PANDA_COMPILER_ENUM_PRE_CHECK_LOWERING_H +#include +#include #include "compiler/lowering/phase.h" namespace ark::es2panda::compiler { class EnumLoweringPhase : public PhaseForDeclarations { public: + static constexpr std::string_view const STRING_REFERENCE_TYPE {"String"}; + static constexpr std::string_view const IDENTIFIER_I {"i"}; + static constexpr std::string_view const PARAM_NAME {"name"}; + static constexpr std::string_view const PARAM_VALUE {"value"}; + static constexpr std::string_view const PARAM_ORDINAL {"ordinal"}; + static constexpr std::string_view const STRING_VALUES_ARRAY_NAME {"#StringValuesArray"}; + static constexpr std::string_view const ITEMS_ARRAY_NAME {"#ItemsArray"}; + static constexpr std::string_view const NAMES_ARRAY_NAME {"#NamesArray"}; + static constexpr std::string_view const VALUES_ARRAY_NAME {"#ValuesArray"}; + static constexpr std::string_view const ORDINAL_NAME {"#ordinal"}; + struct DeclarationFlags { // NOLINTBEGIN(misc-non-private-member-variables-in-classes) bool isTopLevel; @@ -41,7 +54,6 @@ public: return "EnumLoweringPhase"; } bool PerformForModule(public_lib::Context *ctx, parser::Program *program) override; - static util::UString GetEnumClassName(checker::ETSChecker *checker, const ir::TSEnumDeclaration *const enumDecl); checker::ETSChecker *Checker() { return checker_; @@ -67,48 +79,48 @@ private: bool CheckEnumMemberType(const ArenaVector &enumMembers, bool &hasLoggedError); [[nodiscard]] ir::ScriptFunction *MakeFunction(FunctionInfo &&functionInfo); - ir::ClassDeclaration *CreateClass(ir::TSEnumDeclaration *const enumDecl, const DeclarationFlags flags); + ir::ClassDeclaration *CreateClass(ir::TSEnumDeclaration *const enumDecl, const DeclarationFlags flags, + bool isIntEnum); ir::ClassProperty *CreateOrdinalField(ir::ClassDefinition *const enumClass); + ir::MemberExpression *CreateOrdinalAccessExpression(); void CreateCCtorForEnumClass(ir::ClassDefinition *const enumClass); void CreateCtorForEnumClass(ir::ClassDefinition *const enumClass); ir::ScriptFunction *CreateFunctionForCtorOfEnumClass(ir::ClassDefinition *const enumClass); void ProcessEnumClassDeclaration(ir::TSEnumDeclaration *const enumDecl, const DeclarationFlags &flags, ir::ClassDeclaration *enumClassDecl); - void CreateEnumIntClassFromEnumDeclaration(ir::TSEnumDeclaration *const enumDecl, const DeclarationFlags flags); - void CreateEnumStringClassFromEnumDeclaration(ir::TSEnumDeclaration *const enumDecl, const DeclarationFlags flags); + ir::ClassDeclaration *CreateEnumIntClassFromEnumDeclaration(ir::TSEnumDeclaration *const enumDecl, + const DeclarationFlags flags); + ir::ClassDeclaration *CreateEnumStringClassFromEnumDeclaration(ir::TSEnumDeclaration *const enumDecl, + const DeclarationFlags flags); static void AppendParentNames(util::UString &qualifiedName, const ir::AstNode *const node); template [[nodiscard]] ir::Identifier *MakeArray(const ir::TSEnumDeclaration *const enumDecl, ir::ClassDefinition *enumClass, const util::StringView &name, ir::TypeNode *const typeAnnotation, ElementMaker &&elementMaker); - + void CreateEnumItemFields(const ir::TSEnumDeclaration *const enumDecl, ir::ClassDefinition *enumClass); ir::Identifier *CreateEnumNamesArray(const ir::TSEnumDeclaration *const enumDecl, ir::ClassDefinition *enumClass); ir::Identifier *CreateEnumValuesArray(const ir::TSEnumDeclaration *const enumDecl, ir::ClassDefinition *enumClass); ir::Identifier *CreateEnumStringValuesArray(const ir::TSEnumDeclaration *const enumDecl, ir::ClassDefinition *enumClass); ir::Identifier *CreateEnumItemsArray(const ir::TSEnumDeclaration *const enumDecl, ir::ClassDefinition *enumClass); - ir::Identifier *CreateBoxedEnumItemsArray(const ir::TSEnumDeclaration *const enumDecl, - ir::ClassDefinition *enumClass); - - void CreateEnumFromIntMethod(ir::TSEnumDeclaration const *const enumDecl, ir::ClassDefinition *const enumClass, - ir::Identifier *const arrayIdent, const util::StringView &methodName, - const util::StringView &returnTypeName); void CreateEnumToStringMethod(ir::TSEnumDeclaration const *const enumDecl, ir::ClassDefinition *const enumClass, ir::Identifier *const stringValuesArrayIdent); void CreateEnumValueOfMethod(ir::TSEnumDeclaration const *const enumDecl, ir::ClassDefinition *const enumClass, - ir::Identifier *const valuesArrayIdent); + ir::Identifier *const valuesArrayIdent, bool isIntEnum); void CreateEnumGetNameMethod(ir::TSEnumDeclaration const *const enumDecl, ir::ClassDefinition *const enumClass, ir::Identifier *const namesArrayIdent); void CreateEnumGetValueOfMethod(ir::TSEnumDeclaration const *const enumDecl, ir::ClassDefinition *const enumClass, - ir::Identifier *const namesArrayIdent); + ir::Identifier *const namesArrayIdent, ir::Identifier *const itemsArrayIdent); + void CreateEnumFromValueMethod(ir::TSEnumDeclaration const *const enumDecl, ir::ClassDefinition *const enumClass, + ir::Identifier *const valuesArrayIdent, ir::Identifier *const itemsArrayIdent, + bool isIntEnum); void CreateEnumValuesMethod(ir::TSEnumDeclaration const *const enumDecl, ir::ClassDefinition *const enumClass, ir::Identifier *const itemsArrayIdent); - void CreateUnboxingMethod(ir::TSEnumDeclaration const *const enumDecl, ir::ClassDefinition *const enumClass, - ir::Identifier *const itemsArrayIdent); + void CreateEnumGetOrdinalMethod(ir::TSEnumDeclaration const *const enumDecl, ir::ClassDefinition *const enumClass); + void CreateEnumDollarGetMethod(ir::TSEnumDeclaration const *const enumDecl, ir::ClassDefinition *const enumClass); void SetDefaultPositionInUnfilledClassNodes(const ir::ClassDeclaration *enumClassDecl, ir::TSEnumDeclaration const *const enumDecl); - ArenaAllocator *Allocator(); private: diff --git a/ets2panda/compiler/lowering/ets/enumPostCheckLowering.cpp b/ets2panda/compiler/lowering/ets/enumPostCheckLowering.cpp index 46968c9d85..cfbcab4cfb 100644 --- a/ets2panda/compiler/lowering/ets/enumPostCheckLowering.cpp +++ b/ets2panda/compiler/lowering/ets/enumPostCheckLowering.cpp @@ -14,10 +14,20 @@ */ #include "enumPostCheckLowering.h" -#include "checker/types/ets/etsEnumType.h" +#include +#include #include "checker/ETSchecker.h" #include "checker/types/type.h" +#include "checker/types/ets/etsEnumType.h" #include "compiler/lowering/util.h" +#include "ir/astNode.h" +#include "ir/expressions/identifier.h" +#include "ir/statements/ifStatement.h" +#include "ir/ts/tsAsExpression.h" +#include "macros.h" +#include "parser/ETSparser.h" +#include "util.h" +#include "util/ustring.h" #include "varbinder/ETSBinder.h" #include "varbinder/variable.h" @@ -33,14 +43,81 @@ static ir::ClassDeclaration *FindEnclosingClass(ir::AstNode *ast) UNREACHABLE(); } -static ir::CallExpression *CallStaticEnumMethod(checker::ETSChecker *checker, checker::ETSEnumType *enumType, - checker::ETSEnumType::Method (checker::ETSEnumType::*getMethod)() const, - ir::Expression *argument) +static std::string TypeToString(checker::Type *type) +{ + std::stringstream ss; + type->ToString(ss); + return ss.str(); +} + +static util::StringView TypeAnnotationToString(ir::ETSTypeReference *typeAnnotation, checker::ETSChecker *checker) +{ + std::stringstream ss; + std::function typeAnnoToStringImpl = [&ss, &typeAnnoToStringImpl](ir::AstNode *node) -> void { + if (node->IsIdentifier()) { + ss << node->AsIdentifier()->ToString() << "."; + } + node->Iterate(typeAnnoToStringImpl); + }; + typeAnnotation->Iterate(typeAnnoToStringImpl); + std::string res = ss.str(); + res.erase(res.size() - 1); + return util::UString {res, checker->Allocator()}.View(); +} + +static bool IsValidEnumCasting(checker::Type *type, EnumCastType castType) +{ + switch (castType) { + case EnumCastType::NONE: { + return false; + } + case EnumCastType::CAST_TO_STRING: { + return type->IsETSStringEnumType(); + } + case EnumCastType::CAST_TO_INT: { + return type->IsETSIntEnumType(); + } + case EnumCastType::CAST_TO_INT_ENUM: + case EnumCastType::CAST_TO_STRING_ENUM: { + return true; + } + default: { + UNREACHABLE(); + } + } +} + +static EnumCastType NeedHandleEnumCasting(ir::TSAsExpression *node) { - auto classDef = enumType->BoxedType()->AsETSObjectType()->GetDeclNode()->AsClassDefinition(); - auto methodName = (enumType->*getMethod)().memberProxyType->Name(); + auto type = node->TsType(); + EnumCastType castType = EnumCastType::NONE; + if (type->IsETSStringType()) { + castType = EnumCastType::CAST_TO_STRING; + } else if (type->HasTypeFlag(checker::TypeFlag::ETS_NUMERIC) || + (type->IsETSObjectType() && + type->AsETSObjectType()->HasObjectFlag(checker::ETSObjectFlags::BUILTIN_NUMERIC))) { + castType = EnumCastType::CAST_TO_INT; + } else if (type->IsETSEnumType()) { + castType = type->IsETSIntEnumType() ? EnumCastType::CAST_TO_INT_ENUM : EnumCastType::CAST_TO_STRING_ENUM; + } else { + return castType; + } + auto expr = node->Expr(); + if (expr->TsType()->IsETSUnionType()) { + for (auto *ct : expr->TsType()->AsETSUnionType()->ConstituentTypes()) { + if (ct->IsETSEnumType() && IsValidEnumCasting(ct, castType)) { + return castType; + } + } + } + return IsValidEnumCasting(expr->TsType(), castType) ? castType : EnumCastType::NONE; +} - auto classId = checker->AllocNode(classDef->Ident()->Name(), checker->Allocator()); +static ir::CallExpression *CallStaticEnumMethod(checker::ETSChecker *checker, parser::ETSParser *parser, + std::string_view className, std::string_view methodName, + ir::Expression *argument) +{ + auto classId = parser->CreateExpression(className); auto methodId = checker->AllocNode(methodName, checker->Allocator()); auto callee = checker->AllocNode(classId, methodId, ir::MemberExpressionKind::PROPERTY_ACCESS, false, false); @@ -49,42 +126,30 @@ static ir::CallExpression *CallStaticEnumMethod(checker::ETSChecker *checker, ch return checker->AllocNode(callee, std::move(callArguments), nullptr, false); } -static ir::CallExpression *CallInstanceEnumMethod(checker::ETSChecker *checker, checker::ETSEnumType *enumType, - checker::ETSEnumType::Method (checker::ETSEnumType::*getMethod)() - const, +static ir::CallExpression *CallInstanceEnumMethod(checker::ETSChecker *checker, std::string_view methodName, ir::Expression *thisArg) { - auto methodName = (enumType->*getMethod)().memberProxyType->Name(); - auto methodId = checker->AllocNode(methodName, checker->Allocator()); auto callee = checker->AllocNode(thisArg, methodId, ir::MemberExpressionKind::PROPERTY_ACCESS, false, false); ArenaVector callArguments({}, checker->Allocator()->Adapter()); - return checker->AllocNode(callee, std::move(callArguments), nullptr, false); + auto callExpr = checker->AllocNode(callee, std::move(callArguments), nullptr, false); + callExpr->SetRange(thisArg->Range()); + return callExpr; } -static ir::CallExpression *GenerateValueOfCall(checker::ETSChecker *checker, ir::AstNode *const node) +static ir::CallExpression *CreateCallInstanceEnumExpression(checker::ETSChecker *checker, ir::AstNode *const node, + std::string_view methodName) { ES2PANDA_ASSERT(node->IsExpression()); auto expr = node->AsExpression(); auto parent = expr->Parent(); - parent->AddAstNodeFlags(ir::AstNodeFlags::RECHECK); - checker::ETSEnumType *enumIf; - - if (!expr->TsType()->IsETSEnumType()) { - expr->RemoveBoxingUnboxingFlags(ir::BoxingUnboxingFlags::UNBOX_TO_ENUM); - enumIf = expr->TsType()->AsETSObjectType()->GetUnboxedEnumType(); - expr = CallInstanceEnumMethod(checker, enumIf, &checker::ETSEnumType::UnboxMethod, expr); - } else { - enumIf = expr->TsType()->AsETSEnumType(); - } - - auto *callExpr = CallStaticEnumMethod(checker, enumIf, &checker::ETSEnumType::ValueOfMethod, expr); + auto *callExpr = CallInstanceEnumMethod(checker, methodName, expr); callExpr->SetParent(parent); - auto *calleClass = FindEnclosingClass(expr); + auto *calleeClass = FindEnclosingClass(expr); auto *varBinder = checker->VarBinder()->AsETSBinder(); @@ -93,33 +158,235 @@ static ir::CallExpression *GenerateValueOfCall(checker::ETSChecker *checker, ir: varBinder->ResolveReferencesForScopeWithContext(callExpr, nearestScope); auto checkerCtx = checker::SavedCheckerContext(checker, checker::CheckerStatus::IN_CLASS, - calleClass->Definition()->TsType()->AsETSObjectType()); + calleeClass->Definition()->TsType()->AsETSObjectType()); auto scopeCtx = checker::ScopeContext(checker, nearestScope); callExpr->Check(checker); + return callExpr; +} + +[[nodiscard]] static ir::ETSTypeReference *MakeTypeReference(checker::ETSChecker *const checker, + const std::string &name) +{ + auto allocator = checker->Allocator(); + auto *const ident = checker->AllocNode(util::UString(name, allocator).View(), allocator); + auto *const referencePart = checker->AllocNode(ident, allocator); + return checker->AllocNode(referencePart, allocator); +} + +static ir::IfStatement *CreateEnumIfStatement(checker::ETSChecker *const checker, ir::Identifier *ident, + const std::string &enumName, ir::Statement *consequent) +{ + auto enumType = MakeTypeReference(checker, enumName); + auto clonedIdent = ident->Clone(checker->Allocator(), nullptr); + auto ifTestExpr = + checker->AllocNode(clonedIdent, enumType, lexer::TokenType::KEYW_INSTANCEOF); + return checker->AllocNode(ifTestExpr, consequent, nullptr); +} + +ir::Statement *EnumPostCheckLoweringPhase::CreateStatement(const std::string &src, ir::Expression *ident, + ir::Expression *init) +{ + std::vector nodes; + if (ident != nullptr) { + nodes.push_back(ident->Clone(checker_->Allocator(), nullptr)); + } + + if (init != nullptr) { + nodes.push_back(init->Clone(checker_->Allocator(), nullptr)); + } + + auto statements = parser_->CreateFormattedStatements(src, nodes); + if (!statements.empty()) { + return *statements.begin(); + } + + return nullptr; +} + +ir::Expression *EnumPostCheckLoweringPhase::HandleEnumTypeCasting(checker::Type *type, ir::Expression *expr, + ir::TSAsExpression *tsAsExpr) +{ + ir::Expression *transformedExpr = nullptr; + // Generate fromValue call; + if (type->IsETSEnumType()) { + auto exprType = expr->TsType(); + if (exprType->IsETSEnumType() || + (exprType->IsETSObjectType() && exprType->AsETSObjectType()->IsGlobalETSObjectType())) { + return expr; + } + auto name = TypeAnnotationToString(tsAsExpr->TypeAnnotation()->AsETSTypeReference(), checker_); + transformedExpr = GenerateFromValueCall(expr, name); + } else { + transformedExpr = CallInstanceEnumMethod(checker_, checker::ETSEnumType::VALUE_OF_METHOD_NAME, expr); + } + transformedExpr->SetRange(expr->Range()); + transformedExpr->SetParent(expr->Parent()); + return transformedExpr; +} + +// CC-OFFNXT(huge_method,G.FUD.05) +void EnumPostCheckLoweringPhase::CreateStatementForUnionConstituentType(EnumCastType castType, ir::Identifier *ident, + checker::Type *type, + ir::TSAsExpression *tsAsExpr, + ArenaVector &statements) +{ + auto createInstanceOfStatement = [this, &statements, &ident, &type](ir::Expression *callExpr) { + auto consequent = CreateStatement("@@I1 = @@E2;", ident, callExpr); + auto ifStatement = CreateEnumIfStatement(checker_, ident, TypeToString(type), consequent); + auto prevStatement = statements.back(); + if (prevStatement != nullptr && prevStatement->IsIfStatement()) { + prevStatement->AsIfStatement()->SetAlternate(ifStatement); + } + statements.push_back(ifStatement); + }; + switch (castType) { + case EnumCastType::CAST_TO_STRING: { + if (type->IsETSStringEnumType()) { + auto callExpr = CallInstanceEnumMethod(checker_, checker::ETSEnumType::VALUE_OF_METHOD_NAME, + ident->Clone(checker_->Allocator(), nullptr)->AsExpression()); + callExpr->SetRange(tsAsExpr->Expr()->Range()); + createInstanceOfStatement(callExpr); + } + break; + } + case EnumCastType::CAST_TO_INT: { + if (type->IsETSIntEnumType()) { + auto callExpr = CallInstanceEnumMethod(checker_, checker::ETSEnumType::VALUE_OF_METHOD_NAME, + ident->Clone(checker_->Allocator(), nullptr)->AsExpression()); + callExpr->SetRange(tsAsExpr->Expr()->Range()); + createInstanceOfStatement(callExpr); + } + break; + } + case EnumCastType::CAST_TO_INT_ENUM: { + // int and Boxed Int can be casted to int enum + if (type->IsIntType() || (type->IsETSObjectType() && + type->AsETSObjectType()->HasObjectFlag(checker::ETSObjectFlags::BUILTIN_INT))) { + auto name = TypeAnnotationToString(tsAsExpr->TypeAnnotation()->AsETSTypeReference(), checker_); + auto callExpr = + GenerateFromValueCall(ident->Clone(checker_->Allocator(), nullptr)->AsExpression(), name); + callExpr->SetRange(tsAsExpr->Expr()->Range()); + createInstanceOfStatement(callExpr); + } + break; + } + case EnumCastType::CAST_TO_STRING_ENUM: { + if (type->IsETSStringType()) { + auto name = TypeAnnotationToString(tsAsExpr->TypeAnnotation()->AsETSTypeReference(), checker_); + auto callExpr = + GenerateFromValueCall(ident->Clone(checker_->Allocator(), nullptr)->AsExpression(), name); + callExpr->SetRange(tsAsExpr->Expr()->Range()); + createInstanceOfStatement(callExpr); + } + break; + } + default: { + UNREACHABLE(); + } + } +} + +ir::Expression *EnumPostCheckLoweringPhase::HandleUnionTypeForCalls(checker::ETSUnionType *unionType, + ir::Expression *expr, ir::TSAsExpression *tsAsExpr, + EnumCastType castType) +{ + /* + * For given union type: number | string | Enum | otherTypes, this method generate instanceof trees to ensuring + * all union constituent types are handled correctly with enum related casting. + */ + auto *const allocator = checker_->Allocator(); + auto *genSymIdent = Gensym(allocator); + ArenaVector statements(checker_->Allocator()->Adapter()); + const std::string createSrc = "let @@I1 = @@E2"; + statements.push_back(CreateStatement(createSrc, genSymIdent, expr)); + for (auto type : unionType->ConstituentTypes()) { + CreateStatementForUnionConstituentType(castType, genSymIdent, type, tsAsExpr, statements); + } + statements.push_back(CreateStatement("@@I1", genSymIdent, nullptr)); + auto block = checker_->AllocNode(std::move(statements)); + return block; +} + +ir::AstNode *EnumPostCheckLoweringPhase::GenerateEnumCasting(ir::TSAsExpression *node, EnumCastType castType) +{ + auto expr = node->Expr(); + if (expr->TsType()->IsETSUnionType()) { + auto newExpr = HandleUnionTypeForCalls(expr->TsType()->AsETSUnionType(), node->Expr(), node, castType); + node->SetExpr(newExpr); + } else { + auto newExpr = HandleEnumTypeCasting(node->TsType(), node->Expr(), node); + node->SetExpr(newExpr); + } + node->SetTsType(nullptr); + auto *scope = NearestScope(node); + auto bscope = varbinder::LexicalScope::Enter(varbinder_, scope); + CheckLoweredNode(varbinder_, checker_, node); + return node; +} + +ir::AstNode *EnumPostCheckLoweringPhase::GenerateValueOfCall(ir::AstNode *const node) +{ + node->Parent()->AddAstNodeFlags(ir::AstNodeFlags::RECHECK); + if (!node->IsExpression()) { + node->RemoveAstNodeFlags(ir::AstNodeFlags::GENERATE_VALUE_OF); + return node; + } + auto *callExpr = CreateCallInstanceEnumExpression(checker_, node, checker::ETSEnumType::VALUE_OF_METHOD_NAME); node->RemoveAstNodeFlags(ir::AstNodeFlags::GENERATE_VALUE_OF); return callExpr; } +ir::Expression *EnumPostCheckLoweringPhase::GenerateFromValueCall(ir::Expression *const node, util::StringView name) +{ + auto *callExpr = + CallStaticEnumMethod(checker_, parser_, name.Utf8(), checker::ETSEnumType::FROM_VALUE_METHOD_NAME, node); + callExpr->SetRange(node->Range()); + return callExpr; +} + +ir::SwitchStatement *EnumPostCheckLoweringPhase::GenerateGetOrdinalCallForSwitch(ir::SwitchStatement *const node) +{ + node->AddAstNodeFlags(ir::AstNodeFlags::RECHECK); + auto *discrminant = + CreateCallInstanceEnumExpression(checker_, node->Discriminant(), checker::ETSEnumType::GET_ORDINAL_METHOD_NAME); + node->SetDiscriminant(discrminant); + + for (auto *ele : node->Cases()) { + // Default case will not handle. + if (ele->Test() == nullptr) { + continue; + } + auto *newTest = + CreateCallInstanceEnumExpression(checker_, ele->Test(), checker::ETSEnumType::GET_ORDINAL_METHOD_NAME); + ele->SetTest(newTest); + } + return node; +} + bool EnumPostCheckLoweringPhase::PerformForModule(public_lib::Context *ctx, parser::Program *program) { if (program->Extension() != ScriptExtension::STS) { return true; } + parser_ = ctx->parser->AsETSParser(); + checker_ = ctx->checker->AsETSChecker(); + varbinder_ = ctx->parserProgram->VarBinder()->AsETSBinder(); + program->Ast()->TransformChildrenRecursivelyPostorder( // clang-format off - [ctx](ir::AstNode *const node) -> ir::AstNode* { + [this](ir::AstNode *const node) -> ir::AstNode* { if (node->HasAstNodeFlags(ir::AstNodeFlags::RECHECK)) { if (node->IsExpression()) { node->AsExpression()->SetTsType(nullptr); // force recheck } - if (ctx->checker->AsETSChecker()->Context().ContainingClass() == nullptr) { + if (checker_->Context().ContainingClass() == nullptr) { auto *parentClass = util::Helpers::FindAncestorGivenByType(node, ir::AstNodeType::CLASS_DEFINITION); - ctx->checker->AsETSChecker()->Context().SetContainingClass( + checker_->Context().SetContainingClass( parentClass->AsClassDefinition()->TsType()->AsETSObjectType()); } - node->Check(ctx->checker->AsETSChecker()); + node->Check(checker_); node->RemoveAstNodeFlags(ir::AstNodeFlags::RECHECK); if (node->IsExpression() && node->AsExpression()->TsType() != nullptr && !node->AsExpression()->TsType()->IsETSIntEnumType()) { @@ -127,21 +394,17 @@ bool EnumPostCheckLoweringPhase::PerformForModule(public_lib::Context *ctx, pars } } if (node->HasAstNodeFlags(ir::AstNodeFlags::GENERATE_VALUE_OF)) { - return GenerateValueOfCall(ctx->checker->AsETSChecker(), node); + return GenerateValueOfCall(node); + } + if (node->IsTSAsExpression()) { + auto castFlag = NeedHandleEnumCasting(node->AsTSAsExpression()); + if (castFlag == EnumCastType::NONE) { + return node; + } + return GenerateEnumCasting(node->AsTSAsExpression(), castFlag); } - if (node->HasAstNodeFlags(ir::AstNodeFlags::GENERATE_GET_NAME)) { - ES2PANDA_ASSERT(node->IsMemberExpression()); - auto memberExpr = node->AsMemberExpression(); - - auto *enumIf = memberExpr->Object()->TsType()->AsETSEnumType(); - auto *callExpr = CallStaticEnumMethod(ctx->checker->AsETSChecker(), enumIf, - // CC-OFFNXT(G.FMT.06-CPP) project code style - &checker::ETSEnumType::GetNameMethod, memberExpr->Property()); - - callExpr->SetParent(node->Parent()); - callExpr->Check(ctx->checker->AsETSChecker()); - node->RemoveAstNodeFlags(ir::AstNodeFlags::GENERATE_GET_NAME); - return callExpr; + if (node->IsSwitchStatement() && node->AsSwitchStatement()->Discriminant()->TsType()->IsETSEnumType()) { + return GenerateGetOrdinalCallForSwitch(node->AsSwitchStatement()); } return node; }, diff --git a/ets2panda/compiler/lowering/ets/enumPostCheckLowering.h b/ets2panda/compiler/lowering/ets/enumPostCheckLowering.h index 80b28b581f..867cc73f8a 100644 --- a/ets2panda/compiler/lowering/ets/enumPostCheckLowering.h +++ b/ets2panda/compiler/lowering/ets/enumPostCheckLowering.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 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 @@ -17,11 +17,19 @@ #define ES2PANDA_COMPILER_ENUM_POST_CHECK_LOWERING_H #include "compiler/lowering/phase.h" -#include "checker/types/ets/etsEnumType.h" +#include "ir/ts/tsAsExpression.h" namespace ark::es2panda::compiler { -class EnumPostCheckLoweringPhase : public PhaseForDeclarations { +enum class EnumCastType { + NONE, + CAST_TO_STRING, + CAST_TO_INT, + CAST_TO_INT_ENUM, + CAST_TO_STRING_ENUM, +}; + +class EnumPostCheckLoweringPhase : public PhaseForBodies { public: EnumPostCheckLoweringPhase() noexcept = default; std::string_view Name() const override @@ -29,6 +37,22 @@ public: return "EnumPostCheckLoweringPhase"; } bool PerformForModule(public_lib::Context *ctx, parser::Program *program) override; + +private: + ir::Statement *CreateStatement(const std::string &src, ir::Expression *ident, ir::Expression *init); + void CreateStatementForUnionConstituentType(EnumCastType castType, ir::Identifier *ident, checker::Type *type, + ir::TSAsExpression *tsAsExpr, ArenaVector &statements); + ir::SwitchStatement *GenerateGetOrdinalCallForSwitch(ir::SwitchStatement *const node); + ir::AstNode *GenerateEnumCasting(ir::TSAsExpression *node, EnumCastType castType); + ir::AstNode *GenerateValueOfCall(ir::AstNode *const node); + ir::Expression *GenerateFromValueCall(ir::Expression *const node, util::StringView name); + ir::Expression *HandleEnumTypeCasting(checker::Type *type, ir::Expression *expr, ir::TSAsExpression *tsAsExpr); + ir::Expression *HandleUnionTypeForCalls(checker::ETSUnionType *unionType, ir::Expression *expr, + ir::TSAsExpression *tsAsExpr, EnumCastType castType); + + parser::ETSParser *parser_ {nullptr}; + checker::ETSChecker *checker_ {nullptr}; + varbinder::ETSBinder *varbinder_ {nullptr}; }; } // namespace ark::es2panda::compiler diff --git a/ets2panda/compiler/lowering/ets/lambdaLowering.cpp b/ets2panda/compiler/lowering/ets/lambdaLowering.cpp index e59a0596d3..6fbddca278 100644 --- a/ets2panda/compiler/lowering/ets/lambdaLowering.cpp +++ b/ets2panda/compiler/lowering/ets/lambdaLowering.cpp @@ -1027,11 +1027,6 @@ static bool IsFunctionOrMethodCall(ir::CallExpression const *node) return true; } - // NOTE(vpukhov): #20510 member access pattern Enum.Const.() - if (callee->IsMemberExpression() && (callee->AsMemberExpression()->Object()->TsType()->IsETSEnumType())) { - return true; - } - varbinder::Variable *var = nullptr; if (callee->IsMemberExpression() && callee->AsMemberExpression()->Kind() == ir::MemberExpressionKind::PROPERTY_ACCESS) { diff --git a/ets2panda/compiler/lowering/ets/unionLowering.cpp b/ets2panda/compiler/lowering/ets/unionLowering.cpp index fadea86a29..6df33d8f61 100644 --- a/ets2panda/compiler/lowering/ets/unionLowering.cpp +++ b/ets2panda/compiler/lowering/ets/unionLowering.cpp @@ -195,7 +195,6 @@ bool UnionLowering::PerformForModule(public_lib::Context *ctx, parser::Program * return ast; } } - if (ast->IsTSAsExpression() && ast->AsTSAsExpression()->Expr()->TsType() != nullptr && ast->AsTSAsExpression()->Expr()->TsType()->IsETSUnionType() && ast->AsTSAsExpression()->TsType() != nullptr && diff --git a/ets2panda/compiler/lowering/scopesInit/scopesInitPhase.cpp b/ets2panda/compiler/lowering/scopesInit/scopesInitPhase.cpp index 0885e637e1..95cf5790c4 100644 --- a/ets2panda/compiler/lowering/scopesInit/scopesInitPhase.cpp +++ b/ets2panda/compiler/lowering/scopesInit/scopesInitPhase.cpp @@ -1102,17 +1102,9 @@ void InitScopesPhaseETS::VisitTSInterfaceDeclaration(ir::TSInterfaceDeclaration void InitScopesPhaseETS::VisitTSEnumDeclaration(ir::TSEnumDeclaration *enumDecl) { - { - const auto enumCtx = LexicalScopeCreateOrEnter(VarBinder(), enumDecl); - BindScopeNode(enumCtx.GetScope(), enumDecl); - Iterate(enumDecl); - } - auto name = FormInterfaceOrEnumDeclarationIdBinding(enumDecl->Key()); - if (auto *decl = AddOrGetDecl(VarBinder(), name, enumDecl, enumDecl->Start(), name, - enumDecl, enumDecl->IsConst()); - decl != nullptr) { - decl->BindScope(enumDecl->Scope()); - } + const auto enumCtx = LexicalScopeCreateOrEnter(VarBinder(), enumDecl); + BindScopeNode(enumCtx.GetScope(), enumDecl); + Iterate(enumDecl); } void InitScopesPhaseETS::VisitTSTypeAliasDeclaration(ir::TSTypeAliasDeclaration *typeAlias) @@ -1327,10 +1319,6 @@ void InitScopesPhaseETS::AddGlobalDeclaration(ir::AstNode *node) isBuiltin = node->AsTSInterfaceDeclaration()->IsFromExternal(); break; } - case ir::AstNodeType::TS_ENUM_DECLARATION: { - ident = node->AsTSEnumDeclaration()->Key(); - break; - } case ir::AstNodeType::TS_TYPE_ALIAS_DECLARATION: { ident = node->AsTSTypeAliasDeclaration()->Id(); break; diff --git a/ets2panda/declgen_ets2ts/declgenEts2Ts.cpp b/ets2panda/declgen_ets2ts/declgenEts2Ts.cpp index ce03c8d81d..dee69ef4fc 100644 --- a/ets2panda/declgen_ets2ts/declgenEts2Ts.cpp +++ b/ets2panda/declgen_ets2ts/declgenEts2Ts.cpp @@ -140,12 +140,7 @@ void TSDeclGen::GenDeclarations() } else if (globalStatement->IsTSEnumDeclaration()) { GenEnumDeclaration(globalStatement->AsTSEnumDeclaration()); } else if (globalStatement->IsClassDeclaration()) { - // The classes generated for enums starts with '#' but those are invalid names and - // not requred for the ts code - if (globalStatement->AsClassDeclaration()->Definition()->Ident()->Name().Mutf8().find('#') == - std::string::npos) { - GenClassDeclaration(globalStatement->AsClassDeclaration()); - } + GenClassDeclaration(globalStatement->AsClassDeclaration()); } else if (globalStatement->IsTSInterfaceDeclaration()) { GenInterfaceDeclaration(globalStatement->AsTSInterfaceDeclaration()); } else if (globalStatement->IsTSTypeAliasDeclaration()) { @@ -219,6 +214,14 @@ void TSDeclGen::GenType(const checker::Type *checkerType) if (HandleBasicTypes(checkerType)) { return; } + if (checkerType->HasTypeFlag(checker::TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC)) { + OutDts("number"); + return; + } + if (checkerType->IsETSStringEnumType()) { + OutDts("string"); + return; + } if (checkerType->IsETSFunctionType()) { HandleFunctionType(checkerType); @@ -272,7 +275,6 @@ bool TSDeclGen::HandleETSSpecificTypes(const checker::Type *checkerType) case checker::TypeFlag::ETS_PARTIAL_TYPE_PARAMETER: case checker::TypeFlag::ETS_NEVER: case checker::TypeFlag::ETS_READONLY: - case checker::TypeFlag::ETS_INT_ENUM: OutDts(checkerType->ToString()); return true; @@ -477,11 +479,11 @@ void TSDeclGen::GenFunctionType(const checker::ETSFunctionType *etsFunctionType, } } -void TSDeclGen::GenEnumType(const checker::ETSEnumType *enumType) +void TSDeclGen::GenEnumMember(const ir::TSEnumDeclaration *enumDecl) { - for (auto *member : enumType->GetMembers()) { + for (auto *member : enumDecl->Members()) { auto indent = GetIndent(); - OutDts(indent); + OutDts(INDENT); OutTs(indent); if (!member->IsTSEnumMember()) { LogError(diagnostic::INCORRECT_ENUM_MEMBER, {}, member->Start()); @@ -857,10 +859,8 @@ void TSDeclGen::GenEnumDeclaration(const ir::TSEnumDeclaration *enumDecl) OutEndlDts(); OutTs("export const enum ", enumName, " {"); OutEndlTs(); - - ES2PANDA_ASSERT(enumDecl->TsType()->IsETSEnumType()); - GenEnumType(enumDecl->TsType()->AsETSEnumType()); - + ES2PANDA_ASSERT(enumDecl->TsType()->IsETSIntEnumType()); + GenEnumMember(enumDecl); OutTs("}"); OutEndlTs(); OutDts("}"); @@ -1181,6 +1181,11 @@ void TSDeclGen::GenPropDeclaration(const ir::ClassProperty *classProp) } const auto propName = GetKeyIdent(classProp->Key())->Name().Mutf8(); + // The class property generated for enums starts with "#" are invalid properties, and should not be generated. + if (propName.find('#') != std::string::npos) { + DebugPrint(" Skip Generate enum PropDeclaration: " + propName); + return; + } DebugPrint(" GenPropDeclaration: " + propName); ProcessIndent(); diff --git a/ets2panda/declgen_ets2ts/declgenEts2Ts.h b/ets2panda/declgen_ets2ts/declgenEts2Ts.h index 4fb14f8c1a..3a94434851 100644 --- a/ets2panda/declgen_ets2ts/declgenEts2Ts.h +++ b/ets2panda/declgen_ets2ts/declgenEts2Ts.h @@ -85,7 +85,6 @@ private: void GenType(const checker::Type *checkerType); void GenFunctionType(const checker::ETSFunctionType *functionType, const ir::MethodDefinition *methodDef = nullptr); void GenObjectType(const checker::ETSObjectType *objectType); - void GenEnumType(const checker::ETSEnumType *enumType); void GenUnionType(const checker::ETSUnionType *unionType); void GenTupleType(const checker::ETSTupleType *tupleType); @@ -93,6 +92,7 @@ private: void GenReExportDeclaration(const ir::ETSReExportDeclaration *reExportDeclaration); void GenTypeAliasDeclaration(const ir::TSTypeAliasDeclaration *typeAlias); void GenEnumDeclaration(const ir::TSEnumDeclaration *enumDecl); + void GenEnumMember(const ir::TSEnumDeclaration *enumDecl); void GenInterfaceDeclaration(const ir::TSInterfaceDeclaration *interfaceDecl); void GenClassDeclaration(const ir::ClassDeclaration *classDecl); void GenMethodDeclaration(const ir::MethodDefinition *methodDef); diff --git a/ets2panda/ir/astNodeFlags.h b/ets2panda/ir/astNodeFlags.h index ca4d1dcd89..8178b30ca4 100644 --- a/ets2panda/ir/astNodeFlags.h +++ b/ets2panda/ir/astNodeFlags.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 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 @@ -31,8 +31,7 @@ enum class AstNodeFlags { ALLOW_REQUIRED_INSTANTIATION = 1U << 2U, HAS_EXPORT_ALIAS = 1U << 3U, GENERATE_VALUE_OF = 1U << 4U, - GENERATE_GET_NAME = 1U << 5U, // Transform the Enum[enumVar] MemberExpression to enumVar.getName() call - RECHECK = 1U << 6U, + RECHECK = 1U << 5U, /* do not introduce new flags. all the existing to be removed */ }; @@ -127,11 +126,10 @@ enum class BoxingUnboxingFlags : uint32_t { UNBOX_TO_LONG = 1U << 14U, UNBOX_TO_FLOAT = 1U << 15U, UNBOX_TO_DOUBLE = 1U << 16U, - UNBOX_TO_ENUM = 1U << 17U, BOXING_FLAG = BOX_TO_BOOLEAN | BOX_TO_BYTE | BOX_TO_SHORT | BOX_TO_CHAR | BOX_TO_INT | BOX_TO_LONG | BOX_TO_FLOAT | BOX_TO_DOUBLE | BOX_TO_ENUM, UNBOXING_FLAG = UNBOX_TO_BOOLEAN | UNBOX_TO_BYTE | UNBOX_TO_SHORT | UNBOX_TO_CHAR | UNBOX_TO_INT | UNBOX_TO_LONG | - UNBOX_TO_FLOAT | UNBOX_TO_DOUBLE | UNBOX_TO_ENUM, + UNBOX_TO_FLOAT | UNBOX_TO_DOUBLE, }; } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/base/classDefinition.h b/ets2panda/ir/base/classDefinition.h index 1d61d14b08..ccf91b9925 100644 --- a/ets2panda/ir/base/classDefinition.h +++ b/ets2panda/ir/base/classDefinition.h @@ -52,6 +52,8 @@ enum class ClassDefinitionModifiers : uint32_t { LOCAL = 1U << 11U, CLASSDEFINITION_CHECKED = 1U << 12U, NAMESPACE_TRANSFORMED = 1U << 13U, + STRING_ENUM_TRANSFORMED = 1U << 14U, + INT_ENUM_TRANSFORMED = 1U << 15U, DECLARATION_ID_REQUIRED = DECLARATION | ID_REQUIRED, ETS_MODULE = NAMESPACE_TRANSFORMED | GLOBAL }; @@ -225,6 +227,21 @@ public: return (modifiers_ & ClassDefinitionModifiers::ANONYMOUS) != 0; } + [[nodiscard]] bool IsIntEnumTransformed() const noexcept + { + return (modifiers_ & ClassDefinitionModifiers::INT_ENUM_TRANSFORMED) != 0; + } + + [[nodiscard]] bool IsStringEnumTransformed() const noexcept + { + return (modifiers_ & ClassDefinitionModifiers::STRING_ENUM_TRANSFORMED) != 0; + } + + [[nodiscard]] bool IsEnumTransformed() const noexcept + { + return IsIntEnumTransformed() || IsStringEnumTransformed(); + } + [[nodiscard]] bool IsNamespaceTransformed() const noexcept { return (modifiers_ & ClassDefinitionModifiers::NAMESPACE_TRANSFORMED) != 0; diff --git a/ets2panda/ir/base/classElement.h b/ets2panda/ir/base/classElement.h index 5f41013eac..8a2c5ef6c9 100644 --- a/ets2panda/ir/base/classElement.h +++ b/ets2panda/ir/base/classElement.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 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 @@ -66,6 +66,16 @@ public: return value_; } + [[nodiscard]] const TSEnumMember *OriginEnumMember() const noexcept + { + return enumMember_; + } + + void SetOrigEnumMember(ir::TSEnumMember *enumMember) + { + enumMember_ = enumMember; + } + [[nodiscard]] bool IsPrivateElement() const noexcept; [[nodiscard]] const ArenaVector &Decorators() const noexcept @@ -108,6 +118,7 @@ protected: Expression *value_; ArenaVector decorators_; bool isComputed_; + TSEnumMember *enumMember_ {}; // NOLINTEND(misc-non-private-member-variables-in-classes) }; } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/expressions/memberExpression.cpp b/ets2panda/ir/expressions/memberExpression.cpp index d8c7af8c71..957d3f38a0 100644 --- a/ets2panda/ir/expressions/memberExpression.cpp +++ b/ets2panda/ir/expressions/memberExpression.cpp @@ -148,44 +148,6 @@ checker::Type *MemberExpression::Check(checker::TSChecker *checker) return checker->GetAnalyzer()->Check(this); } -static varbinder::LocalVariable *GetEnumMethodVariable(checker::ETSEnumType const *const enumInterface, - const util::StringView propName) -{ - varbinder::LocalVariable *methodVar = nullptr; - - const auto *const boxedClass = enumInterface->GetDecl()->BoxedClass(); - ES2PANDA_ASSERT(boxedClass->TsType()->IsETSObjectType()); - const auto *const obj = boxedClass->TsType()->AsETSObjectType(); - - std::string_view methodName = propName.Utf8(); - if (enumInterface->IsETSStringEnumType() && (propName == checker::ETSEnumType::VALUE_OF_METHOD_NAME)) { - // For string enums valueOf method calls toString method - methodName = checker::ETSEnumType::TO_STRING_METHOD_NAME; - } - - const auto searchFlags = - checker::PropertySearchFlags::SEARCH_METHOD | checker::PropertySearchFlags::DISALLOW_SYNTHETIC_METHOD_CREATION; - methodVar = obj->GetProperty(methodName, searchFlags); - - return methodVar; -} - -std::pair MemberExpression::ResolveEnumMember( - checker::ETSChecker *checker, checker::ETSEnumType *type) const -{ - if (parent_->Type() == ir::AstNodeType::CALL_EXPRESSION && parent_->AsCallExpression()->Callee() == this) { - auto *const memberType = type->LookupMethod(checker, object_, property_->AsIdentifier()); - varbinder::LocalVariable *const memberVar = GetEnumMethodVariable(type, property_->AsIdentifier()->Name()); - return {memberType, memberVar}; - } - - auto *const literalType = type->LookupConstant(checker, object_, property_->AsIdentifier()); - if (literalType == nullptr) { - return {nullptr, nullptr}; - } - return {literalType, literalType->GetMemberVar()}; -} - std::pair MemberExpression::ResolveObjectMember( checker::ETSChecker *checker) const { @@ -479,14 +441,6 @@ checker::Type *MemberExpression::CheckComputed(checker::ETSChecker *checker, che SetObjectType(baseType->AsETSObjectType()); return CheckIndexAccessMethod(checker); } - // NOTE(vpukhov): #20510 lowering - if (baseType->IsETSEnumType()) { - property_->Check(checker); - if (property_->TsType()->IsETSEnumType()) { - AddAstNodeFlags(ir::AstNodeFlags::GENERATE_GET_NAME); - return checker->GlobalBuiltinETSStringType(); - } - } checker->LogError(diagnostic::INDEX_ON_INVALID_TYPE, {}, Object()->Start()); return nullptr; } diff --git a/ets2panda/ir/expressions/memberExpression.h b/ets2panda/ir/expressions/memberExpression.h index f75bee5a37..bb72ee988b 100644 --- a/ets2panda/ir/expressions/memberExpression.h +++ b/ets2panda/ir/expressions/memberExpression.h @@ -235,8 +235,6 @@ protected: } private: - std::pair ResolveEnumMember(checker::ETSChecker *checker, - checker::ETSEnumType *type) const; std::pair ResolveObjectMember(checker::ETSChecker *checker) const; checker::Type *AdjustType(checker::ETSChecker *checker, checker::Type *type); checker::Type *SetAndAdjustType(checker::ETSChecker *checker, checker::ETSObjectType *objectType); diff --git a/ets2panda/ir/statements/ifStatement.h b/ets2panda/ir/statements/ifStatement.h index 13b70ff5c2..31860fefa6 100644 --- a/ets2panda/ir/statements/ifStatement.h +++ b/ets2panda/ir/statements/ifStatement.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 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 @@ -69,6 +69,14 @@ public: return alternate_; } + void SetAlternate(Statement *alternate) noexcept + { + if (alternate != nullptr) { + alternate->SetParent(this); + } + alternate_ = alternate; + } + void TransformChildren(const NodeTransformer &cb, std::string_view transformationName) override; void Iterate(const NodeTraverser &cb) const override; diff --git a/ets2panda/ir/statements/switchCaseStatement.cpp b/ets2panda/ir/statements/switchCaseStatement.cpp index 4872542ec5..eec65df177 100644 --- a/ets2panda/ir/statements/switchCaseStatement.cpp +++ b/ets2panda/ir/statements/switchCaseStatement.cpp @@ -108,11 +108,8 @@ void SwitchCaseStatement::CheckAndTestCase(checker::ETSChecker *checker, checker if (caseType->HasTypeFlag(checker::TypeFlag::CHAR)) { validCaseType = comparedExprType->HasTypeFlag(checker::TypeFlag::ETS_INTEGRAL); - } else if (caseType->IsETSIntEnumType() && comparedExprType->IsETSIntEnumType()) { - validCaseType = comparedExprType->AsETSIntEnumType()->IsSameEnumType(caseType->AsETSIntEnumType()); - } else if (caseType->IsETSStringEnumType() && comparedExprType->IsETSStringEnumType()) { - // CC-OFFNXT(G.FMT.06-CPP) project code style - validCaseType = comparedExprType->AsETSStringEnumType()->IsSameEnumType(caseType->AsETSStringEnumType()); + } else if (caseType->IsETSEnumType() || comparedExprType->IsETSEnumType()) { + validCaseType = checker->Relation()->IsIdenticalTo(caseType, comparedExprType); } else { if (!checker::AssignmentContext( // CC-OFFNXT(G.FMT.06-CPP) project code style diff --git a/ets2panda/ir/statements/switchCaseStatement.h b/ets2panda/ir/statements/switchCaseStatement.h index ac079a6f36..15dc89d788 100644 --- a/ets2panda/ir/statements/switchCaseStatement.h +++ b/ets2panda/ir/statements/switchCaseStatement.h @@ -16,6 +16,7 @@ #ifndef ES2PANDA_IR_STATEMENT_SWITCH_CASE_STATEMENT_H #define ES2PANDA_IR_STATEMENT_SWITCH_CASE_STATEMENT_H +#include "ir/expression.h" #include "ir/statement.h" namespace ark::es2panda::ir { @@ -44,6 +45,14 @@ public: return test_; } + void SetTest(Expression *test) noexcept + { + if (test != nullptr) { + test->SetParent(this); + } + test_ = test; + } + [[nodiscard]] const ArenaVector &Consequent() const noexcept { return consequent_; diff --git a/ets2panda/ir/statements/switchStatement.h b/ets2panda/ir/statements/switchStatement.h index a1e6afad69..7ded576550 100644 --- a/ets2panda/ir/statements/switchStatement.h +++ b/ets2panda/ir/statements/switchStatement.h @@ -17,6 +17,7 @@ #define ES2PANDA_IR_STATEMENT_SWITCH_STATEMENT_H #include "varbinder/scope.h" +#include "ir/expression.h" #include "ir/statement.h" namespace ark::es2panda::checker { @@ -51,6 +52,14 @@ public: return discriminant_; } + void SetDiscriminant(Expression *discriminant) noexcept + { + if (discriminant != nullptr) { + discriminant->SetParent(this); + } + discriminant_ = discriminant; + } + [[nodiscard]] const ArenaVector &Cases() const noexcept { return cases_; diff --git a/ets2panda/parser/ETSparserClasses.cpp b/ets2panda/parser/ETSparserClasses.cpp index c508daf8ba..4a2109f37d 100644 --- a/ets2panda/parser/ETSparserClasses.cpp +++ b/ets2panda/parser/ETSparserClasses.cpp @@ -16,7 +16,6 @@ #include "ETSparser.h" #include "ETSNolintParser.h" #include -#include "generated/diagnostic.h" #include "macros.h" #include "parser/parserFlags.h" #include "parser/parserStatusContext.h" @@ -27,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" diff --git a/ets2panda/parser/ETSparserEnums.cpp b/ets2panda/parser/ETSparserEnums.cpp index a130adccf5..43acc3081e 100644 --- a/ets2panda/parser/ETSparserEnums.cpp +++ b/ets2panda/parser/ETSparserEnums.cpp @@ -27,7 +27,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" diff --git a/ets2panda/scripts/arkui-setup.sh b/ets2panda/scripts/arkui-setup.sh index 6a90939b1e..33d07e9aa0 100644 --- a/ets2panda/scripts/arkui-setup.sh +++ b/ets2panda/scripts/arkui-setup.sh @@ -111,7 +111,8 @@ function do_checkout() { GIT_URL=https://gitee.com/rri_opensource/koala_projects.git DEST="${DEST:-koala-sig}" -do_checkout "${GIT_URL}" panda_rev_6 "${DEST}" + +do_checkout "${GIT_URL}" panda_rev_6-0-prepare_ordinal "${DEST}" cd "${DEST}" || exit 1 diff --git a/ets2panda/test/ast/compiler/ets/not_initialized_variable/complex_types.sts b/ets2panda/test/ast/compiler/ets/not_initialized_variable/complex_types.sts index 57e4926b98..2efce245ce 100644 --- a/ets2panda/test/ast/compiler/ets/not_initialized_variable/complex_types.sts +++ b/ets2panda/test/ast/compiler/ets/not_initialized_variable/complex_types.sts @@ -35,6 +35,7 @@ export let plug: Plug console.log(car, animal, mutant, jsvalue, plug) +/* @@? 36:13 Warning Warning: Variable 'car' is used before being assigned. */ /* @@? 36:18 Warning Warning: Variable 'animal' is used before being assigned. */ /* @@? 36:26 Warning Warning: Variable 'mutant' is used before being assigned. */ /* @@? 36:34 Warning Warning: Variable 'jsvalue' is used before being assigned. */ diff --git a/ets2panda/test/ast/compiler/ets/variable_declaretion_neg_1.sts b/ets2panda/test/ast/compiler/ets/variable_declaretion_neg_1.sts index 1d86cb4061..7e3e9315ce 100644 --- a/ets2panda/test/ast/compiler/ets/variable_declaretion_neg_1.sts +++ b/ets2panda/test/ast/compiler/ets/variable_declaretion_neg_1.sts @@ -19,6 +19,5 @@ let negative%%_ = 1 /* @@? 16:13 Error SyntaxError: Variable must be initialized or it's type must be declared. */ /* @@? 16:13 Error SyntaxError: Unexpected token '%'. */ /* @@? 16:13 Error SyntaxError: Unexpected token '%'. */ -/* @@? 16:13 Error TypeError: Bad operand type, the types of the operands must be numeric type. */ /* @@? 16:14 Error SyntaxError: Unexpected token '%'. */ /* @@? 16:15 Error TypeError: Unresolved reference _ */ diff --git a/ets2panda/test/ast/parser/ets/annotations_tests/annotationDecl_enum_conflict.sts b/ets2panda/test/ast/parser/ets/annotations_tests/annotationDecl_enum_conflict.sts index 731501c181..9fc03e1561 100644 --- a/ets2panda/test/ast/parser/ets/annotations_tests/annotationDecl_enum_conflict.sts +++ b/ets2panda/test/ast/parser/ets/annotations_tests/annotationDecl_enum_conflict.sts @@ -14,16 +14,6 @@ */ interface MyAnno {} -/* @@ label */enum MyAnno {one, two, three} +enum /* @@ label */MyAnno {one, two, three} /* @@@ label Error TypeError: Variable 'MyAnno' has already been declared. */ -/* @@? 17:28 Error TypeError: Property 'one' does not exist on type 'MyAnno' */ -/* @@? 17:28 Error TypeError: Property 'one' does not exist on type 'MyAnno' */ -/* @@? 17:33 Error TypeError: Property 'two' does not exist on type 'MyAnno' */ -/* @@? 17:33 Error TypeError: Property 'two' does not exist on type 'MyAnno' */ -/* @@? 17:38 Error TypeError: Property 'three' does not exist on type 'MyAnno' */ -/* @@? 17:38 Error TypeError: Property 'three' does not exist on type 'MyAnno' */ -/* @@? 17:15 Error TypeError: Cannot cast type 'MyAnno' to 'int' */ -/* @@? 17:15 Error TypeError: Cannot cast type 'int' to 'MyAnno' */ -/* @@? 17:15 Error TypeError: Cannot cast type 'MyAnno' to 'int' */ -/* @@? 17:15 Error TypeError: Cannot cast type 'MyAnno' to 'int' */ diff --git a/ets2panda/test/ast/parser/ets/annotations_tests/annotationUsage_bad_param_for_lambda.sts b/ets2panda/test/ast/parser/ets/annotations_tests/annotationUsage_bad_param_for_lambda.sts index 60fd68e098..7a6cad9d41 100644 --- a/ets2panda/test/ast/parser/ets/annotations_tests/annotationUsage_bad_param_for_lambda.sts +++ b/ets2panda/test/ast/parser/ets/annotations_tests/annotationUsage_bad_param_for_lambda.sts @@ -20,5 +20,4 @@ @ClassAuthor (x: 1) => x * 2; /* @@? 20:2 Error TypeError: Cannot find type 'ClassAuthor'. */ -/* @@? 20:18 Error SyntaxError: Invalid Type. */ -/* @@? 20:24 Error TypeError: Bad operand type, the types of the operands must be numeric type. */ \ No newline at end of file +/* @@? 20:18 Error SyntaxError: Invalid Type. */ \ No newline at end of file diff --git a/ets2panda/test/ast/parser/ets/enum10.sts b/ets2panda/test/ast/parser/ets/enum10.sts index ada0cdfa03..7afc83c3a6 100644 --- a/ets2panda/test/ast/parser/ets/enum10.sts +++ b/ets2panda/test/ast/parser/ets/enum10.sts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 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 @@ -17,7 +17,6 @@ enum Color { Red } function main(): void { let values: Color[] = Color.values(); - let valuesFail: Color[] = values[0]./* @@ label */values(); + // Note(daizihan): values() becomes static method in enum, so no CTE + let valuesFail: Color[] = values[0].values(); } - -/* @@@ label Error TypeError: No enum item method called 'values' */ diff --git a/ets2panda/test/ast/parser/ets/enum12.sts b/ets2panda/test/ast/parser/ets/enum12.sts index 8e697c0ba7..2a7a1dd7bb 100644 --- a/ets2panda/test/ast/parser/ets/enum12.sts +++ b/ets2panda/test/ast/parser/ets/enum12.sts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 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 @@ -17,11 +17,11 @@ enum Color { Red } function test(c: Color): void { let name: String = c.toString(); - let nameFail: int = Color./* @@ label */toString(); + let nameFail: String = Color./* @@ label */toString(); } function main(): void { test(Color.Red); } -/* @@@ label Error TypeError: No enum type method called 'toString' */ +/* @@@ label Error TypeError: 'toString' is an instance property of 'Color' */ diff --git a/ets2panda/test/ast/parser/ets/enum13.sts b/ets2panda/test/ast/parser/ets/enum13.sts index de7ffd2ea3..0a4828ea51 100644 --- a/ets2panda/test/ast/parser/ets/enum13.sts +++ b/ets2panda/test/ast/parser/ets/enum13.sts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 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 @@ -15,16 +15,13 @@ enum Color { Red } -function test(c: Color): void throws { - let red: Color = Color.valueOf("Red"); - let redFail: Color = c.valueOf("Red"); +function test(c: Color): void { + let red: int = c.valueOf(); + let redFail: int = Color.valueOf(); } function main(): void { test(Color.Red); } -/* @@? 19:26 Error TypeError: No enum type method called 'valueOf' */ -/* @@? 20:24 Error TypeError: Expected 0 arguments, got 1. */ -/* @@? 20:24 Error TypeError: No matching call signature for valueOf("Red") */ -/* @@? 24:3 Error TypeError: This statement can cause an exception, therefore it must be enclosed in a try statement with a default catch clause */ +/* @@? 20:28 Error TypeError: 'valueOf' is an instance property of 'Color' */ diff --git a/ets2panda/test/ast/parser/ets/enum14.sts b/ets2panda/test/ast/parser/ets/enum14.sts index 633946a059..d152c4368f 100644 --- a/ets2panda/test/ast/parser/ets/enum14.sts +++ b/ets2panda/test/ast/parser/ets/enum14.sts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 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 @@ -19,7 +19,9 @@ function main(): void { const red = Color.Red; switch (Color.Green) { case Color.Blue: break; - case red: break; + case /* @@ label */red: break; case Color.Green: break; } } + +/* @@@ label Error TypeError: Enum switch case must be unqualified name of an enum constant */ diff --git a/ets2panda/test/ast/parser/ets/enum20.sts b/ets2panda/test/ast/parser/ets/enum20.sts index ddf5fa25ca..3f79f66f30 100644 --- a/ets2panda/test/ast/parser/ets/enum20.sts +++ b/ets2panda/test/ast/parser/ets/enum20.sts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 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 @@ -22,7 +22,7 @@ function main(): void { let white = Color.White./* @@ label3 */ordinal(); } -/* @@@ label Error TypeError: No enum item method called 'ordinal' */ -/* @@@ label1 Error TypeError: No enum item method called 'ordinal' */ -/* @@@ label2 Error TypeError: No enum item method called 'ordinal' */ -/* @@@ label3 Error TypeError: No enum item method called 'ordinal' */ +/* @@@ label Error TypeError: Property 'ordinal' does not exist on type 'Color' */ +/* @@@ label1 Error TypeError: Property 'ordinal' does not exist on type 'Color' */ +/* @@@ label2 Error TypeError: Property 'ordinal' does not exist on type 'Color' */ +/* @@@ label3 Error TypeError: Property 'ordinal' does not exist on type 'Color' */ diff --git a/ets2panda/test/ast/parser/ets/enum22.sts b/ets2panda/test/ast/parser/ets/enum22.sts index b052216cad..518e1e39a8 100644 --- a/ets2panda/test/ast/parser/ets/enum22.sts +++ b/ets2panda/test/ast/parser/ets/enum22.sts @@ -18,3 +18,5 @@ enum duplicateKeysStringCase { /* @@ label */Gray = "#ff808080" } /* @@@ label Error TypeError: Variable 'Gray' has already been declared. */ +/* @@@ label Error TypeError: Variable 'Gray' has already been declared. */ +/* @@@ label Error TypeError: Static property 'Gray' must be accessed through it's class 'duplicateKeysStringCase' */ diff --git a/ets2panda/test/ast/parser/ets/enum23.sts b/ets2panda/test/ast/parser/ets/enum23.sts index 51f58a6c70..db791f543c 100644 --- a/ets2panda/test/ast/parser/ets/enum23.sts +++ b/ets2panda/test/ast/parser/ets/enum23.sts @@ -18,3 +18,5 @@ enum duplicateKeysNumCase { /* @@ label */Red = 1 } /* @@@ label Error TypeError: Variable 'Red' has already been declared. */ +/* @@@ label Error TypeError: Variable 'Red' has already been declared. */ +/* @@@ label Error TypeError: Static property 'Red' must be accessed through it's class 'duplicateKeysNumCase' */ diff --git a/ets2panda/test/ast/parser/ets/enum6.sts b/ets2panda/test/ast/parser/ets/enum6.sts index 27abfdade3..bea6774682 100644 --- a/ets2panda/test/ast/parser/ets/enum6.sts +++ b/ets2panda/test/ast/parser/ets/enum6.sts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 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 @@ -25,4 +25,4 @@ function main(): void { i = i./* @@ label */Blue; } -/* @@@ label Error TypeError: Enum constant does not have property 'Blue'. */ +/* @@@ label Error TypeError: 'Blue' is a static property of 'Color' */ diff --git a/ets2panda/test/ast/parser/ets/enum7.sts b/ets2panda/test/ast/parser/ets/enum7.sts index 08b0676581..0027570f04 100644 --- a/ets2panda/test/ast/parser/ets/enum7.sts +++ b/ets2panda/test/ast/parser/ets/enum7.sts @@ -18,7 +18,7 @@ enum Color2 { Red } function main(): void { // Is used 'assertTrue' due to #22840 - assertTrue(/* @@ label */Color.Red == Color2.Red); + assertTrue(/* @@ label */Color.Red != Color2.Red); } -/* @@@ label Error TypeError: Bad operand type, the types of the operands must be the same enum type. */ +/* @@@ label Error TypeError: Bad operand type, the types of the operands must be numeric, same enumeration, or boolean type. */ diff --git a/ets2panda/test/ast/parser/ets/enum9.sts b/ets2panda/test/ast/parser/ets/enum9.sts index fe95537020..bbb82339fc 100644 --- a/ets2panda/test/ast/parser/ets/enum9.sts +++ b/ets2panda/test/ast/parser/ets/enum9.sts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 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 @@ -16,7 +16,6 @@ enum Color { Red } function main(): void { - let red: Color = Color.Red./* @@ label */Red; + // Note(daizihan): Red becomes static property of the class, so no CTE happened. + let red: Color = Color.Red.Red; } - -/* @@@ label Error TypeError: Cannot refer to enum members through variable. */ diff --git a/ets2panda/test/ast/parser/ets/switch_readonly_member_different_enum.sts b/ets2panda/test/ast/parser/ets/switch_readonly_member_different_enum.sts index 9aa3ca20d1..7cc78ce5c9 100644 --- a/ets2panda/test/ast/parser/ets/switch_readonly_member_different_enum.sts +++ b/ets2panda/test/ast/parser/ets/switch_readonly_member_different_enum.sts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 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 @@ -41,4 +41,6 @@ function main() { } /* @@@ label Error TypeError: Switch case type 'A' is not comparable to discriminant type 'E' */ +/* @@@ label Error TypeError: Enum switch case must be unqualified name of an enum constant */ /* @@@ label1 Error TypeError: Switch case type 'A' is not comparable to discriminant type 'E' */ +/* @@@ label1 Error TypeError: Enum switch case must be unqualified name of an enum constant */ diff --git a/ets2panda/test/ast/parser/ets/switch_readonly_member_enum.sts b/ets2panda/test/ast/parser/ets/switch_readonly_member_enum.sts index 0fe68780d7..feec019073 100644 --- a/ets2panda/test/ast/parser/ets/switch_readonly_member_enum.sts +++ b/ets2panda/test/ast/parser/ets/switch_readonly_member_enum.sts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 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 @@ -32,10 +32,13 @@ class Sqr { function main() { let a = A.B switch (a) { - case Fgr.BR: + case /* @@ label */Fgr.BR: break; - case Sqr.BR: + case /* @@ label1 */Sqr.BR: break; default: break; } } + +/* @@@ label Error TypeError: Enum switch case must be unqualified name of an enum constant */ +/* @@@ label1 Error TypeError: Enum switch case must be unqualified name of an enum constant */ diff --git a/ets2panda/test/ast/parser/ets/switch_readonly_member_enum_duplicate.sts b/ets2panda/test/ast/parser/ets/switch_readonly_member_enum_duplicate.sts index 68f0f1f35b..7ca94b555b 100644 --- a/ets2panda/test/ast/parser/ets/switch_readonly_member_enum_duplicate.sts +++ b/ets2panda/test/ast/parser/ets/switch_readonly_member_enum_duplicate.sts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 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 @@ -34,10 +34,11 @@ function main() { switch (a) { case /* @@ label */Fgr.BR: break; - case Sqr.BR: + case /* @@ label1 */Sqr.BR: break; default: break; } } -/* @@@ label Error TypeError: Case duplicate */ +/* @@@ label Error TypeError: Enum switch case must be unqualified name of an enum constant */ +/* @@@ label1 Error TypeError: Enum switch case must be unqualified name of an enum constant */ diff --git a/ets2panda/test/ast/parser/ets/unexpected_token_43.sts b/ets2panda/test/ast/parser/ets/unexpected_token_43.sts index 38c21f4c69..5b223d199e 100644 --- a/ets2panda/test/ast/parser/ets/unexpected_token_43.sts +++ b/ets2panda/test/ast/parser/ets/unexpected_token_43.sts @@ -21,9 +21,7 @@ let v2 = `--- ${y + abc /* @@ label */${y} = ${ n*2 }!`/* @@ label1 */} ---`;` /* @@? 16:21 Error TypeError: Unresolved reference abc */ /* @@? 16:39 Error SyntaxError: Expected '}', got 'identification literal'. */ /* @@? 16:49 Error TypeError: Unresolved reference n */ -/* @@? 16:49 Error TypeError: Bad operand type, the types of the operands must be numeric type. */ /* @@? 16:49 Error TypeError: Unresolved reference n */ -/* @@? 16:49 Error TypeError: Bad operand type, the types of the operands must be numeric type. */ /* @@? 16:71 Error SyntaxError: Unexpected token '}'. */ /* @@? 16:76 Error TypeError: Bad operand type, the type of the operand must be numeric type. */ -/* @@? 30:1 Error SyntaxError: Invalid left-hand side in prefix operation. */ +/* @@? 28:1 Error SyntaxError: Invalid left-hand side in prefix operation. */ diff --git a/ets2panda/test/compiler/ets/enum_as_class_member_getValue_call-expected.txt b/ets2panda/test/compiler/ets/enum_as_class_member_getValue_call-expected.txt index 01ddf37a75..b9d3cdfa32 100644 --- a/ets2panda/test/compiler/ets/enum_as_class_member_getValue_call-expected.txt +++ b/ets2panda/test/compiler/ets/enum_as_class_member_getValue_call-expected.txt @@ -2,471 +2,437 @@ "type": "Program", "statements": [ { - "type": "TSEnumDeclaration", - "id": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 6, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 11, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "members": [ - { - "type": "TSEnumMember", - "id": { - "type": "Identifier", - "name": "Red", - "decorators": [], - "loc": { - "start": { - "line": 21, - "column": 5, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 21, - "column": 8, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "initializer": { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 21, - "column": 11, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 21, - "column": 12, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "Color", + "decorators": [], "loc": { "start": { - "line": 21, - "column": 5, + "line": 20, + "column": 6, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 21, - "column": 12, + "line": 20, + "column": 11, "program": "enum_as_class_member_getValue_call.sts" } } }, - { - "type": "TSEnumMember", - "id": { - "type": "Identifier", - "name": "Green", + "superClass": null, + "implements": [], + "body": [ + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "#ordinal", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "accessibility": "private", + "static": false, + "readonly": true, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "definite": false, "decorators": [], "loc": { "start": { - "line": 22, - "column": 5, + "line": 20, + "column": 1, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 22, - "column": 10, + "line": 20, + "column": 1, "program": "enum_as_class_member_getValue_call.sts" } } }, - "initializer": { - "type": "NumberLiteral", - "value": 1, - "loc": { - "start": { - "line": 22, - "column": 13, - "program": "enum_as_class_member_getValue_call.sts" + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "kind": "method", + "accessibility": "private", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } }, - "end": { - "line": 22, - "column": 14, - "program": "enum_as_class_member_getValue_call.sts" + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } } - } - }, - "loc": { - "start": { - "line": 22, - "column": 5, - "program": "enum_as_class_member_getValue_call.sts" }, - "end": { - "line": 22, - "column": 14, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - { - "type": "TSEnumMember", - "id": { - "type": "Identifier", - "name": "Blue", + "overloads": [], "decorators": [], "loc": { "start": { - "line": 23, - "column": 5, + "line": 20, + "column": 1, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 23, - "column": 9, + "line": 20, + "column": 1, "program": "enum_as_class_member_getValue_call.sts" } } }, - "initializer": { - "type": "NumberLiteral", - "value": 2, - "loc": { - "start": { - "line": 23, - "column": 12, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 23, - "column": 13, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 23, - "column": 5, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 23, - "column": 13, - "program": "enum_as_class_member_getValue_call.sts" - } - } - } - ], - "const": false, - "declare": false, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 24, - "column": 2, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - { - "type": "TSEnumDeclaration", - "id": { - "type": "Identifier", - "name": "Shape", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 6, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 11, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "members": [ - { - "type": "TSEnumMember", - "id": { - "type": "Identifier", - "name": "Circle", - "decorators": [], - "loc": { - "start": { - "line": 27, - "column": 5, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 27, - "column": 11, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "initializer": { - "type": "StringLiteral", - "value": "CIRCLE", - "loc": { - "start": { - "line": 27, - "column": 14, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 27, - "column": 22, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 27, - "column": 5, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 27, - "column": 22, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - { - "type": "TSEnumMember", - "id": { - "type": "Identifier", - "name": "Square", - "decorators": [], - "loc": { - "start": { - "line": 28, - "column": 5, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 28, - "column": 11, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "initializer": { - "type": "StringLiteral", - "value": "SQUARE", - "loc": { - "start": { - "line": 28, - "column": 14, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 28, - "column": 22, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 28, - "column": 5, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 28, - "column": 22, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - { - "type": "TSEnumMember", - "id": { - "type": "Identifier", - "name": "Triangle", - "decorators": [], - "loc": { - "start": { - "line": 29, - "column": 5, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 29, - "column": 13, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "initializer": { - "type": "StringLiteral", - "value": "TRIANGLE", - "loc": { - "start": { - "line": 29, - "column": 16, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 29, - "column": 26, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 29, - "column": 5, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 29, - "column": 26, - "program": "enum_as_class_member_getValue_call.sts" - } - } - } - ], - "const": false, - "declare": false, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 30, - "column": 2, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 32, - "column": 7, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 32, - "column": 8, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "sub", - "decorators": [], - "loc": { - "start": { - "line": 33, - "column": 12, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 33, - "column": 15, - "program": "enum_as_class_member_getValue_call.sts" - } + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } } }, + "kind": "constructor", "accessibility": "public", "static": false, - "readonly": false, - "declare": false, "optional": false, "computed": false, - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { "type": "Identifier", - "name": "Color", + "name": "constructor", "decorators": [], "loc": { "start": { - "line": 33, - "column": 17, + "line": 20, + "column": 1, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 33, - "column": 22, + "line": 20, + "column": 1, "program": "enum_as_class_member_getValue_call.sts" } } }, - "loc": { - "start": { - "line": 33, - "column": 17, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 33, - "column": 23, - "program": "enum_as_class_member_getValue_call.sts" + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } } - } - }, - "loc": { - "start": { - "line": 33, - "column": 17, - "program": "enum_as_class_member_getValue_call.sts" + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "#ordinal", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + } + ], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 33, - "column": 23, + "line": 20, + "column": 1, "program": "enum_as_class_member_getValue_call.sts" } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { - "line": 33, - "column": 12, + "line": 20, + "column": 1, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 33, - "column": 23, + "line": 20, + "column": 1, "program": "enum_as_class_member_getValue_call.sts" } } @@ -475,24 +441,104 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "shape", + "name": "Red", "decorators": [], "loc": { "start": { - "line": 34, - "column": 12, + "line": 21, + "column": 5, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 34, - "column": 17, + "line": 21, + "column": 8, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "value": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "arguments": [ + { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + } + ], + "loc": { + "start": { + "line": 21, + "column": 11, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 21, + "column": 12, "program": "enum_as_class_member_getValue_call.sts" } } }, "accessibility": "public", - "static": false, - "readonly": false, + "static": true, + "readonly": true, "declare": false, "optional": false, "computed": false, @@ -502,44 +548,44 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Shape", + "name": "Color", "decorators": [], "loc": { "start": { - "line": 34, - "column": 19, + "line": 20, + "column": 1, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 34, - "column": 24, + "line": 20, + "column": 1, "program": "enum_as_class_member_getValue_call.sts" } } }, "loc": { "start": { - "line": 34, - "column": 19, + "line": 20, + "column": 1, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 34, - "column": 25, + "line": 20, + "column": 1, "program": "enum_as_class_member_getValue_call.sts" } } }, "loc": { "start": { - "line": 34, - "column": 19, + "line": 20, + "column": 1, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 34, - "column": 25, - "program": "enum_as_class_member_getValue_call.sts" + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" } } }, @@ -547,1871 +593,477 @@ "decorators": [], "loc": { "start": { - "line": 34, - "column": 12, + "line": 21, + "column": 5, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 34, - "column": 25, + "line": 21, + "column": 12, "program": "enum_as_class_member_getValue_call.sts" } } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "constructor", + "name": "Green", "decorators": [], "loc": { "start": { - "line": 1, - "column": 1, - "program": null + "line": 22, + "column": 5, + "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 1, - "column": 1, - "program": null + "line": 22, + "column": 10, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "value": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "arguments": [ + { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + } + ], + "loc": { + "start": { + "line": 22, + "column": 13, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 22, + "column": 14, + "program": "enum_as_class_member_getValue_call.sts" } } }, - "kind": "constructor", "accessibility": "public", - "static": false, + "static": true, + "readonly": true, + "declare": false, "optional": false, "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { "type": "Identifier", - "name": "constructor", + "name": "Color", "decorators": [], "loc": { "start": { - "line": 1, + "line": 20, "column": 1, - "program": null + "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 1, + "line": 20, "column": 1, - "program": null + "program": "enum_as_class_member_getValue_call.sts" } } }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "sub", - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 36, - "column": 22, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 36, - "column": 27, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 36, - "column": 22, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 36, - "column": 28, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 36, - "column": 22, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 36, - "column": 28, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 36, - "column": 17, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 36, - "column": 28, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 5, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 22, + "column": 14, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "Blue", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 5, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 23, + "column": 9, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "value": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], "loc": { "start": { - "line": 36, - "column": 17, + "line": 20, + "column": 1, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 36, - "column": 28, + "line": 20, + "column": 1, "program": "enum_as_class_member_getValue_call.sts" } } }, - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "shape", - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Shape", - "decorators": [], - "loc": { - "start": { - "line": 36, - "column": 36, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 36, - "column": 41, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 36, - "column": 36, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 36, - "column": 42, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 36, - "column": 36, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 36, - "column": 42, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 36, - "column": 29, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 36, - "column": 42, - "program": "enum_as_class_member_getValue_call.sts" - } - } + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" }, - "loc": { - "start": { - "line": 36, - "column": 29, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 36, - "column": 42, - "program": "enum_as_class_member_getValue_call.sts" - } + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" } } - ], - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "MemberExpression", - "object": { - "type": "ThisExpression", - "loc": { - "start": { - "line": 37, - "column": 9, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 37, - "column": 13, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "sub", - "decorators": [], - "loc": { - "start": { - "line": 37, - "column": 14, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 37, - "column": 17, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 37, - "column": 9, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 37, - "column": 17, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "right": { - "type": "Identifier", - "name": "sub", - "decorators": [], - "loc": { - "start": { - "line": 37, - "column": 20, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 37, - "column": 23, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 37, - "column": 9, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 37, - "column": 23, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 37, - "column": 9, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 37, - "column": 24, - "program": "enum_as_class_member_getValue_call.sts" - } - } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "arguments": [ + { + "type": "NumberLiteral", + "value": 2, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" }, - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "MemberExpression", - "object": { - "type": "ThisExpression", - "loc": { - "start": { - "line": 38, - "column": 9, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 38, - "column": 13, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "shape", - "decorators": [], - "loc": { - "start": { - "line": 38, - "column": 14, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 38, - "column": 19, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 38, - "column": 9, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 38, - "column": 19, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "right": { - "type": "Identifier", - "name": "shape", - "decorators": [], - "loc": { - "start": { - "line": 38, - "column": 22, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 38, - "column": 27, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 38, - "column": 9, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 38, - "column": 27, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 38, - "column": 9, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 38, - "column": 28, - "program": "enum_as_class_member_getValue_call.sts" - } - } + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" } - ], + } + } + ], + "loc": { + "start": { + "line": 23, + "column": 12, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 23, + "column": 13, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "accessibility": "public", + "static": true, + "readonly": true, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], "loc": { "start": { - "line": 36, - "column": 43, + "line": 20, + "column": 1, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 39, - "column": 6, + "line": 20, + "column": 1, "program": "enum_as_class_member_getValue_call.sts" } } }, "loc": { "start": { - "line": 36, - "column": 16, + "line": 20, + "column": 1, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 39, - "column": 6, + "line": 20, + "column": 1, "program": "enum_as_class_member_getValue_call.sts" } } }, "loc": { "start": { - "line": 36, - "column": 16, + "line": 20, + "column": 1, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 39, - "column": 6, + "line": 20, + "column": 1, "program": "enum_as_class_member_getValue_call.sts" } } }, - "overloads": [], + "definite": false, "decorators": [], "loc": { "start": { - "line": 36, + "line": 23, "column": 5, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 39, - "column": 6, + "line": 23, + "column": 13, "program": "enum_as_class_member_getValue_call.sts" } } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "foo", + "name": "#NamesArray", "decorators": [], "loc": { "start": { - "line": 41, - "column": 5, + "line": 20, + "column": 1, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 41, - "column": 8, + "line": 20, + "column": 1, "program": "enum_as_class_member_getValue_call.sts" } } }, - "kind": "method", - "accessibility": "public", - "static": false, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "Red", + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + { + "type": "StringLiteral", + "value": "Green", + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + { + "type": "StringLiteral", + "value": "Blue", + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + } + ], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "accessibility": "private", + "static": true, + "readonly": true, + "declare": false, "optional": false, "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "foo", - "decorators": [], + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, "loc": { "start": { - "line": 41, - "column": 5, + "line": 20, + "column": 1, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 41, - "column": 8, + "line": 20, + "column": 1, "program": "enum_as_class_member_getValue_call.sts" } } }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "a", - "decorators": [], - "loc": { - "start": { - "line": 42, - "column": 13, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 42, - "column": 14, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "init": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "MemberExpression", - "object": { - "type": "ThisExpression", - "loc": { - "start": { - "line": 42, - "column": 17, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 42, - "column": 21, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "sub", - "decorators": [], - "loc": { - "start": { - "line": 42, - "column": 22, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 42, - "column": 25, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 42, - "column": 17, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 42, - "column": 25, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "valueOf", - "decorators": [], - "loc": { - "start": { - "line": 42, - "column": 26, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 42, - "column": 33, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 42, - "column": 17, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 42, - "column": 33, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "arguments": [], - "optional": false, - "loc": { - "start": { - "line": 42, - "column": 17, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 42, - "column": 35, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 42, - "column": 13, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 42, - "column": 35, - "program": "enum_as_class_member_getValue_call.sts" - } - } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 42, - "column": 9, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 42, - "column": 36, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "b", - "decorators": [], - "loc": { - "start": { - "line": 43, - "column": 13, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 43, - "column": 14, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "init": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "MemberExpression", - "object": { - "type": "ThisExpression", - "loc": { - "start": { - "line": 43, - "column": 17, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 43, - "column": 21, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "shape", - "decorators": [], - "loc": { - "start": { - "line": 43, - "column": 22, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 43, - "column": 27, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 43, - "column": 17, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 43, - "column": 27, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "valueOf", - "decorators": [], - "loc": { - "start": { - "line": 43, - "column": 28, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 43, - "column": 35, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 43, - "column": 17, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 43, - "column": 35, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "arguments": [], - "optional": false, - "loc": { - "start": { - "line": 43, - "column": 17, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 43, - "column": 37, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 43, - "column": 13, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 43, - "column": 37, - "program": "enum_as_class_member_getValue_call.sts" - } - } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 43, - "column": 9, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 43, - "column": 38, - "program": "enum_as_class_member_getValue_call.sts" - } - } - } - ], - "loc": { - "start": { - "line": 41, - "column": 11, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 44, - "column": 6, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 41, - "column": 8, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 44, - "column": 6, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 41, - "column": 8, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 44, - "column": 6, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 41, - "column": 5, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 44, - "column": 6, - "program": "enum_as_class_member_getValue_call.sts" - } - } - } - ], - "loc": { - "start": { - "line": 32, - "column": 9, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 47, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 32, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 47, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "ETSGLOBAL", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 1, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "main", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": null - }, - "end": { - "line": 1, - "column": 1, - "program": null - } - } - }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "main", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": null - }, - "end": { - "line": 1, - "column": 1, - "program": null - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "body": { - "type": "BlockStatement", - "statements": [], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": null - }, - "end": { - "line": 1, - "column": 1, - "program": null - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1, - "program": null - }, - "end": { - "line": 1, - "column": 1, - "program": null - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1, - "program": null - }, - "end": { - "line": 1, - "column": 1, - "program": null - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 1, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "_$init$_", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": null - }, - "end": { - "line": 1, - "column": 1, - "program": null - } - } - }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "_$init$_", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": null - }, - "end": { - "line": 1, - "column": 1, - "program": null - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "body": { - "type": "BlockStatement", - "statements": [], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": null - }, - "end": { - "line": 1, - "column": 1, - "program": null - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1, - "program": null - }, - "end": { - "line": 1, - "column": 1, - "program": null - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1, - "program": null - }, - "end": { - "line": 1, - "column": 1, - "program": null - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 1, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 1, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 1, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "#Color", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "accessibility": "protected", - "static": false, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "definite": false, - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "body": { - "type": "BlockStatement", - "statements": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "constructor", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "kind": "constructor", - "accessibility": "public", - "static": false, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "constructor", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - } - ], - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "MemberExpression", - "object": { - "type": "ThisExpression", - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "right": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - } - ], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "Red", - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - { - "type": "StringLiteral", - "value": "Green", - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - { - "type": "StringLiteral", - "value": "Blue", - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - } - ], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "accessibility": "protected", - "static": true, - "readonly": true, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "annotations": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "definite": false, - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "ValuesArray", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - { - "type": "NumberLiteral", - "value": 1, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - { - "type": "NumberLiteral", - "value": 2, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - } - ], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "accessibility": "protected", - "static": true, - "readonly": true, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSPrimitiveType", "loc": { "start": { "line": 20, @@ -2458,7 +1110,7 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "StringValuesArray", + "name": "#ValuesArray", "decorators": [], "loc": { "start": { @@ -2477,8 +1129,8 @@ "type": "ArrayExpression", "elements": [ { - "type": "StringLiteral", - "value": "0", + "type": "NumberLiteral", + "value": 0, "loc": { "start": { "line": 20, @@ -2493,8 +1145,8 @@ } }, { - "type": "StringLiteral", - "value": "1", + "type": "NumberLiteral", + "value": 1, "loc": { "start": { "line": 20, @@ -2509,8 +1161,8 @@ } }, { - "type": "StringLiteral", - "value": "2", + "type": "NumberLiteral", + "value": 2, "loc": { "start": { "line": 20, @@ -2538,7 +1190,7 @@ } } }, - "accessibility": "protected", + "accessibility": "private", "static": true, "readonly": true, "declare": false, @@ -2547,39 +1199,7 @@ "typeAnnotation": { "type": "TSArrayType", "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 20, @@ -2626,7 +1246,7 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "ItemsArray", + "name": "#StringValuesArray", "decorators": [], "loc": { "start": { @@ -2645,43 +1265,8 @@ "type": "ArrayExpression", "elements": [ { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 6, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 11, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "Red", - "decorators": [], - "loc": { - "start": { - "line": 21, - "column": 5, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 21, - "column": 8, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "computed": false, - "optional": false, + "type": "StringLiteral", + "value": "0", "loc": { "start": { "line": 20, @@ -2696,43 +1281,8 @@ } }, { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 6, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 11, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "Green", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 5, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 22, - "column": 10, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "computed": false, - "optional": false, + "type": "StringLiteral", + "value": "1", "loc": { "start": { "line": 20, @@ -2743,47 +1293,12 @@ "line": 20, "column": 1, "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 6, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 11, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "Blue", - "decorators": [], - "loc": { - "start": { - "line": 23, - "column": 5, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 23, - "column": 9, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "computed": false, - "optional": false, + } + } + }, + { + "type": "StringLiteral", + "value": "2", "loc": { "start": { "line": 20, @@ -2811,7 +1326,7 @@ } } }, - "accessibility": "protected", + "accessibility": "private", "static": true, "readonly": true, "declare": false, @@ -2825,7 +1340,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Color", + "name": "String", "decorators": [], "loc": { "start": { @@ -2899,7 +1414,7 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "BoxedItemsArray", + "name": "#ItemsArray", "decorators": [], "loc": { "start": { @@ -2918,137 +1433,43 @@ "type": "ArrayExpression", "elements": [ { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "#Color", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], "loc": { "start": { "line": 20, - "column": 1, + "column": 6, "program": "enum_as_class_member_getValue_call.sts" }, "end": { "line": 20, - "column": 1, + "column": 11, "program": "enum_as_class_member_getValue_call.sts" } } }, - "arguments": [ - { - "type": "TSAsExpression", - "expression": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 6, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 11, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "Red", - "decorators": [], - "loc": { - "start": { - "line": 21, - "column": 5, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 21, - "column": 8, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 5, + "program": "enum_as_class_member_getValue_call.sts" }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } + "end": { + "line": 21, + "column": 8, + "program": "enum_as_class_member_getValue_call.sts" } } - ], + }, + "computed": false, + "optional": false, "loc": { "start": { "line": 20, @@ -3063,137 +1484,43 @@ } }, { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "#Color", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], "loc": { "start": { "line": 20, - "column": 1, + "column": 6, "program": "enum_as_class_member_getValue_call.sts" }, "end": { "line": 20, - "column": 1, + "column": 11, "program": "enum_as_class_member_getValue_call.sts" } } }, - "arguments": [ - { - "type": "TSAsExpression", - "expression": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 6, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 11, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "Green", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 5, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 22, - "column": 10, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } + "property": { + "type": "Identifier", + "name": "Green", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 5, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 22, + "column": 10, + "program": "enum_as_class_member_getValue_call.sts" } } - ], + }, + "computed": false, + "optional": false, "loc": { "start": { "line": 20, @@ -3208,137 +1535,43 @@ } }, { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "#Color", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], "loc": { "start": { "line": 20, - "column": 1, + "column": 6, "program": "enum_as_class_member_getValue_call.sts" }, "end": { "line": 20, - "column": 1, + "column": 11, "program": "enum_as_class_member_getValue_call.sts" } } }, - "arguments": [ - { - "type": "TSAsExpression", - "expression": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 6, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 11, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "Blue", - "decorators": [], - "loc": { - "start": { - "line": 23, - "column": 5, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 23, - "column": 9, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } + "property": { + "type": "Identifier", + "name": "Blue", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 5, + "program": "enum_as_class_member_getValue_call.sts" }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } + "end": { + "line": 23, + "column": 9, + "program": "enum_as_class_member_getValue_call.sts" } } - ], + }, + "computed": false, + "optional": false, "loc": { "start": { "line": 20, @@ -3366,7 +1599,7 @@ } } }, - "accessibility": "protected", + "accessibility": "private", "static": true, "readonly": true, "declare": false, @@ -3380,7 +1613,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "#Color", + "name": "Color", "decorators": [], "loc": { "start": { @@ -3454,131 +1687,51 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "getName", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "getName", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } + "name": "getName", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "kind": "method", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getName", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" } } - ], + }, + "generator": false, + "async": false, + "expression": false, + "params": [], "returnType": { "type": "ETSTypeReference", "part": { @@ -3637,24 +1790,24 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color", + "name": "Color", "decorators": [], "loc": { "start": { "line": 20, - "column": 1, + "column": 6, "program": "enum_as_class_member_getValue_call.sts" }, "end": { "line": 20, - "column": 1, + "column": 11, "program": "enum_as_class_member_getValue_call.sts" } } }, "property": { "type": "Identifier", - "name": "NamesArray", + "name": "#NamesArray", "decorators": [], "loc": { "start": { @@ -3685,11 +1838,9 @@ } }, "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "ThisExpression", "loc": { "start": { "line": 20, @@ -3703,8 +1854,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "#ordinal", + "decorators": [], "loc": { "start": { "line": 20, @@ -3718,6 +1871,8 @@ } } }, + "computed": false, + "optional": false, "loc": { "start": { "line": 20, @@ -4087,24 +2242,24 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color", + "name": "Color", "decorators": [], "loc": { "start": { "line": 20, - "column": 1, + "column": 6, "program": "enum_as_class_member_getValue_call.sts" }, "end": { "line": 20, - "column": 1, + "column": 11, "program": "enum_as_class_member_getValue_call.sts" } } }, "property": { "type": "Identifier", - "name": "NamesArray", + "name": "#NamesArray", "decorators": [], "loc": { "start": { @@ -4241,24 +2396,24 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color", + "name": "Color", "decorators": [], "loc": { "start": { "line": 20, - "column": 1, + "column": 6, "program": "enum_as_class_member_getValue_call.sts" }, "end": { "line": 20, - "column": 1, + "column": 11, "program": "enum_as_class_member_getValue_call.sts" } } }, "property": { "type": "Identifier", - "name": "NamesArray", + "name": "#NamesArray", "decorators": [], "loc": { "start": { @@ -4336,8 +2491,59 @@ "consequent": { "type": "ReturnStatement", "argument": { - "type": "TSAsExpression", - "expression": { + "type": "MemberExpression", + "object": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 6, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 11, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "#ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "property": { "type": "Identifier", "name": "i", "decorators": [], @@ -4354,40 +2560,73 @@ } } }, - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "alternate": null, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Error", + "decorators": [], "loc": { "start": { "line": 20, @@ -4427,7 +2666,194 @@ } } }, - "alternate": null, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant Color.", + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "right": { + "type": "Identifier", + "name": "name", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + } + ], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + } + ], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "fromValue", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "fromValue", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "value", + "typeAnnotation": { + "type": "ETSPrimitiveType", "loc": { "start": { "line": 20, @@ -4441,6 +2867,42 @@ } } }, + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], "loc": { "start": { "line": 20, @@ -4454,17 +2916,45 @@ } } }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ { - "type": "ThrowStatement", - "argument": { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { + "type": "ForUpdateStatement", + "init": { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { "type": "Identifier", - "name": "Exception", + "name": "i", "decorators": [], "loc": { "start": { @@ -4479,6 +2969,22 @@ } } }, + "init": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, "loc": { "start": { "line": 20, @@ -4491,7 +2997,29 @@ "program": "enum_as_class_member_getValue_call.sts" } } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { + "type": "Identifier", + "name": "i", + "decorators": [], "loc": { "start": { "line": 20, @@ -4505,29 +3033,30 @@ } } }, - "arguments": [ - { - "type": "BinaryExpression", - "operator": "+", - "left": { - "type": "StringLiteral", - "value": "No enum constant Color.", + "right": { + "type": "MemberExpression", + "object": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], "loc": { "start": { "line": 20, - "column": 1, + "column": 6, "program": "enum_as_class_member_getValue_call.sts" }, "end": { "line": 20, - "column": 1, + "column": 11, "program": "enum_as_class_member_getValue_call.sts" } } }, - "right": { + "property": { "type": "Identifier", - "name": "name", + "name": "#ValuesArray", "decorators": [], "loc": { "start": { @@ -4542,6 +3071,25 @@ } } }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], "loc": { "start": { "line": 20, @@ -4554,8 +3102,22 @@ "program": "enum_as_class_member_getValue_call.sts" } } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } } - ], + }, "loc": { "start": { "line": 20, @@ -4569,136 +3131,48 @@ } } }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" + "update": { + "type": "UpdateExpression", + "operator": "++", + "prefix": true, + "argument": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } } - } - } - ], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "throwMarker": "throws", - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "valueOf", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "valueOf", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "e", - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { + }, + "body": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "==", + "left": { "type": "Identifier", - "name": "Color", + "name": "value", "decorators": [], "loc": { "start": { @@ -4713,6 +3187,91 @@ } } }, + "right": { + "type": "MemberExpression", + "object": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 6, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 11, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "#ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, "loc": { "start": { "line": 20, @@ -4726,92 +3285,80 @@ } } }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - } - ], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 6, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 11, + "program": "enum_as_class_member_getValue_call.sts" + } + } }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" + "property": { + "type": "Identifier", + "name": "#ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } } - } - }, - "property": { - "type": "Identifier", - "name": "ValuesArray", - "decorators": [], + }, + "property": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 20, @@ -4825,8 +3372,6 @@ } } }, - "computed": false, - "optional": false, "loc": { "start": { "line": 20, @@ -4840,27 +3385,58 @@ } } }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "e", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" + "alternate": null, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Error", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + }, "loc": { "start": { "line": 20, @@ -4887,8 +3463,57 @@ } } }, - "computed": true, - "optional": false, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum Color with value ", + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "right": { + "type": "Identifier", + "name": "value", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + } + ], "loc": { "start": { "line": 20, @@ -4974,7 +3599,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "toString", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -4991,7 +3616,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -5000,7 +3625,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "toString", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -5018,121 +3643,9 @@ "generator": false, "async": false, "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - } - ], + "params": [], "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 20, @@ -5157,24 +3670,24 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color", + "name": "Color", "decorators": [], "loc": { "start": { "line": 20, - "column": 1, + "column": 6, "program": "enum_as_class_member_getValue_call.sts" }, "end": { "line": 20, - "column": 1, + "column": 11, "program": "enum_as_class_member_getValue_call.sts" } } }, "property": { "type": "Identifier", - "name": "StringValuesArray", + "name": "#ValuesArray", "decorators": [], "loc": { "start": { @@ -5205,11 +3718,9 @@ } }, "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "ThisExpression", "loc": { "start": { "line": 20, @@ -5223,8 +3734,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "#ordinal", + "decorators": [], "loc": { "start": { "line": 20, @@ -5238,6 +3751,8 @@ } } }, + "computed": false, + "optional": false, "loc": { "start": { "line": 20, @@ -5338,7 +3853,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "values", + "name": "toString", "decorators": [], "loc": { "start": { @@ -5355,7 +3870,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -5364,7 +3879,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "values", + "name": "toString", "decorators": [], "loc": { "start": { @@ -5384,28 +3899,13 @@ "expression": false, "params": [], "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], "loc": { "start": { "line": 20, @@ -5432,7 +3932,6 @@ } } }, - "annotations": [], "loc": { "start": { "line": 20, @@ -5454,9 +3953,43 @@ "argument": { "type": "MemberExpression", "object": { - "type": "Identifier", - "name": "#Color", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 6, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 11, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "#StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "computed": false, + "optional": false, "loc": { "start": { "line": 20, @@ -5471,9 +4004,41 @@ } }, "property": { - "type": "Identifier", - "name": "ItemsArray", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "#ordinal", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "computed": false, + "optional": false, "loc": { "start": { "line": 20, @@ -5487,7 +4052,7 @@ } } }, - "computed": false, + "computed": true, "optional": false, "loc": { "start": { @@ -5574,7 +4139,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "fromInt", + "name": "values", "decorators": [], "loc": { "start": { @@ -5600,7 +4165,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "fromInt", + "name": "values", "decorators": [], "loc": { "start": { @@ -5618,14 +4183,17 @@ "generator": false, "async": false, "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSPrimitiveType", + "params": [], + "returnType": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], "loc": { "start": { "line": 20, @@ -5639,42 +4207,6 @@ } } }, - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], "loc": { "start": { "line": 20, @@ -5701,6 +4233,7 @@ } } }, + "annotations": [], "loc": { "start": { "line": 20, @@ -5718,199 +4251,30 @@ "type": "BlockStatement", "statements": [ { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "<", - "left": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "right": { - "type": "MemberExpression", - "object": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "length", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "consequent": { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 6, + "program": "enum_as_class_member_getValue_call.sts" }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } + "end": { + "line": 20, + "column": 11, + "program": "enum_as_class_member_getValue_call.sts" } - }, - "computed": true, - "optional": false, + } + }, + "property": { + "type": "Identifier", + "name": "#ItemsArray", + "decorators": [], "loc": { "start": { "line": 20, @@ -5924,6 +4288,8 @@ } } }, + "computed": false, + "optional": false, "loc": { "start": { "line": 20, @@ -5937,7 +4303,6 @@ } } }, - "alternate": null, "loc": { "start": { "line": 20, @@ -5950,109 +4315,167 @@ "program": "enum_as_class_member_getValue_call.sts" } } + } + ], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getOrdinal", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "kind": "method", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getOrdinal", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ { - "type": "ThrowStatement", + "type": "ReturnStatement", "argument": { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Exception", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "arguments": [ - { - "type": "BinaryExpression", - "operator": "+", - "left": { - "type": "StringLiteral", - "value": "No enum constant in Color with ordinal value ", - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "right": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" } } - ], + }, + "property": { + "type": "Identifier", + "name": "#ordinal", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "computed": false, + "optional": false, "loc": { "start": { "line": 20, @@ -6093,7 +4516,6 @@ } } }, - "throwMarker": "throws", "loc": { "start": { "line": 20, @@ -6139,7 +4561,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "unbox", + "name": "$_get", "decorators": [], "loc": { "start": { @@ -6156,7 +4578,7 @@ }, "kind": "method", "accessibility": "public", - "static": false, + "static": true, "optional": false, "computed": false, "value": { @@ -6165,7 +4587,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "unbox", + "name": "$_get", "decorators": [], "loc": { "start": { @@ -6183,14 +4605,94 @@ "generator": false, "async": false, "expression": false, - "params": [], + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "e", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + } + ], "returnType": { "type": "ETSTypeReference", "part": { "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Color", + "name": "String", "decorators": [], "loc": { "start": { @@ -6237,29 +4739,12 @@ { "type": "ReturnStatement", "argument": { - "type": "MemberExpression", - "object": { + "type": "CallExpression", + "callee": { "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "ItemsArray", + "name": "e", "decorators": [], "loc": { "start": { @@ -6274,41 +4759,9 @@ } } }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "property": { - "type": "MemberExpression", - "object": { - "type": "ThisExpression", - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, "property": { "type": "Identifier", - "name": "ordinal", + "name": "getName", "decorators": [], "loc": { "start": { @@ -6338,7 +4791,7 @@ } } }, - "computed": true, + "arguments": [], "optional": false, "loc": { "start": { @@ -6366,15 +4819,226 @@ } } } - ], + ], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + } + ], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1, + "program": null + }, + "end": { + "line": 1, + "column": 1, + "program": null + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "Shape", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 6, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 11, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "#ordinal", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "accessibility": "private", + "static": false, + "readonly": true, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "kind": "method", + "accessibility": "private", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], "loc": { "start": { - "line": 20, + "line": 26, "column": 1, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 20, + "line": 26, "column": 1, "program": "enum_as_class_member_getValue_call.sts" } @@ -6382,12 +5046,12 @@ }, "loc": { "start": { - "line": 20, + "line": 26, "column": 1, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 20, + "line": 26, "column": 1, "program": "enum_as_class_member_getValue_call.sts" } @@ -6395,12 +5059,12 @@ }, "loc": { "start": { - "line": 20, + "line": 26, "column": 1, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 20, + "line": 26, "column": 1, "program": "enum_as_class_member_getValue_call.sts" } @@ -6410,12 +5074,12 @@ "decorators": [], "loc": { "start": { - "line": 20, + "line": 26, "column": 1, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 20, + "line": 26, "column": 1, "program": "enum_as_class_member_getValue_call.sts" } @@ -6425,24 +5089,24 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "boxedfromInt", + "name": "constructor", "decorators": [], "loc": { "start": { - "line": 20, + "line": 26, "column": 1, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 20, + "line": 26, "column": 1, "program": "enum_as_class_member_getValue_call.sts" } } }, - "kind": "method", + "kind": "constructor", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -6450,468 +5114,156 @@ "function": { "type": "ScriptFunction", "id": { - "type": "Identifier", - "name": "boxedfromInt", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "#Color", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, + "type": "Identifier", + "name": "constructor", + "decorators": [], "loc": { "start": { - "line": 20, + "line": 26, "column": 1, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 20, + "line": 26, "column": 1, "program": "enum_as_class_member_getValue_call.sts" } } }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "<", - "left": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "right": { - "type": "MemberExpression", - "object": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "BoxedItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "length", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "consequent": { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "BoxedItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSPrimitiveType", "loc": { "start": { - "line": 20, + "line": 26, "column": 1, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 20, + "line": 26, "column": 1, "program": "enum_as_class_member_getValue_call.sts" } } }, - "alternate": null, + "decorators": [], "loc": { "start": { - "line": 20, + "line": 26, "column": 1, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 20, + "line": 26, "column": 1, "program": "enum_as_class_member_getValue_call.sts" } } }, - { - "type": "ThrowStatement", - "argument": { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Exception", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" } - }, + } + }, + "property": { + "type": "Identifier", + "name": "#ordinal", + "decorators": [], "loc": { "start": { - "line": 20, + "line": 26, "column": 1, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 20, + "line": 26, "column": 1, "program": "enum_as_class_member_getValue_call.sts" } } }, + "computed": false, + "optional": false, "loc": { "start": { - "line": 20, + "line": 26, "column": 1, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 20, + "line": 26, "column": 1, "program": "enum_as_class_member_getValue_call.sts" } } }, - "arguments": [ - { - "type": "BinaryExpression", - "operator": "+", - "left": { - "type": "StringLiteral", - "value": "No enum constant in Color with ordinal value ", - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "right": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" } } - ], + }, "loc": { "start": { - "line": 20, + "line": 26, "column": 1, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 20, + "line": 26, "column": 1, "program": "enum_as_class_member_getValue_call.sts" } @@ -6919,12 +5271,12 @@ }, "loc": { "start": { - "line": 20, + "line": 26, "column": 1, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 20, + "line": 26, "column": 1, "program": "enum_as_class_member_getValue_call.sts" } @@ -6933,26 +5285,192 @@ ], "loc": { "start": { - "line": 20, + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "Circle", + "decorators": [], + "loc": { + "start": { + "line": 27, + "column": 5, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 27, + "column": 11, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "value": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Shape", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "arguments": [ + { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + } + ], + "loc": { + "start": { + "line": 27, + "column": 14, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 27, + "column": 22, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "accessibility": "public", + "static": true, + "readonly": true, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Shape", + "decorators": [], + "loc": { + "start": { + "line": 26, "column": 1, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 20, + "line": 26, "column": 1, "program": "enum_as_class_member_getValue_call.sts" } } }, - "throwMarker": "throws", "loc": { "start": { - "line": 20, + "line": 26, "column": 1, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 20, + "line": 26, "column": 1, "program": "enum_as_class_member_getValue_call.sts" } @@ -6960,109 +5478,171 @@ }, "loc": { "start": { - "line": 20, + "line": 26, "column": 1, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 20, + "line": 26, "column": 1, "program": "enum_as_class_member_getValue_call.sts" } } }, - "overloads": [], + "definite": false, "decorators": [], "loc": { "start": { - "line": 20, - "column": 1, + "line": 27, + "column": 5, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 20, - "column": 1, + "line": 27, + "column": 22, "program": "enum_as_class_member_getValue_call.sts" } } - } - ], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" }, - "end": { - "line": 20, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1, - "program": null - }, - "end": { - "line": 1, - "column": 1, - "program": null - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "#Shape", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "superClass": null, - "implements": [], - "body": [ { "type": "ClassProperty", "key": { "type": "Identifier", - "name": "ordinal", + "name": "Square", "decorators": [], "loc": { "start": { - "line": 26, - "column": 1, + "line": 28, + "column": 5, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 26, - "column": 1, + "line": 28, + "column": 11, "program": "enum_as_class_member_getValue_call.sts" } } }, - "accessibility": "protected", - "static": false, - "readonly": false, + "value": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Shape", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "arguments": [ + { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + } + ], + "loc": { + "start": { + "line": 28, + "column": 14, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 28, + "column": 22, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "accessibility": "public", + "static": true, + "readonly": true, "declare": false, "optional": false, "computed": false, "typeAnnotation": { - "type": "ETSPrimitiveType", + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Shape", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, "loc": { "start": { "line": 26, @@ -7080,69 +5660,59 @@ "decorators": [], "loc": { "start": { - "line": 26, - "column": 1, + "line": 28, + "column": 5, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 26, - "column": 1, + "line": 28, + "column": 22, "program": "enum_as_class_member_getValue_call.sts" } } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "", + "name": "Triangle", "decorators": [], "loc": { "start": { - "line": 26, - "column": 1, + "line": 29, + "column": 5, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 26, - "column": 1, + "line": 29, + "column": 13, "program": "enum_as_class_member_getValue_call.sts" } } }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Shape", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "body": { - "type": "BlockStatement", - "statements": [], + }, "loc": { "start": { "line": 26, @@ -7169,65 +5739,50 @@ } } }, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" + "arguments": [ + { + "type": "NumberLiteral", + "value": 2, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "constructor", - "decorators": [], + ], "loc": { "start": { - "line": 26, - "column": 1, + "line": 29, + "column": 16, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 26, - "column": 1, + "line": 29, + "column": 26, "program": "enum_as_class_member_getValue_call.sts" } } }, - "kind": "constructor", "accessibility": "public", - "static": false, + "static": true, + "readonly": true, + "declare": false, "optional": false, "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { "type": "Identifier", - "name": "constructor", + "name": "Shape", "decorators": [], "loc": { "start": { @@ -7242,172 +5797,6 @@ } } }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - } - ], - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "MemberExpression", - "object": { - "type": "ThisExpression", - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "right": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - } - ], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, "loc": { "start": { "line": 26, @@ -7434,17 +5823,17 @@ } } }, - "overloads": [], + "definite": false, "decorators": [], "loc": { "start": { - "line": 26, - "column": 1, + "line": 29, + "column": 5, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 26, - "column": 1, + "line": 29, + "column": 26, "program": "enum_as_class_member_getValue_call.sts" } } @@ -7453,7 +5842,7 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "NamesArray", + "name": "#NamesArray", "decorators": [], "loc": { "start": { @@ -7533,7 +5922,7 @@ } } }, - "accessibility": "protected", + "accessibility": "private", "static": true, "readonly": true, "declare": false, @@ -7621,7 +6010,7 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "StringValuesArray", + "name": "#StringValuesArray", "decorators": [], "loc": { "start": { @@ -7701,7 +6090,7 @@ } } }, - "accessibility": "protected", + "accessibility": "private", "static": true, "readonly": true, "declare": false, @@ -7789,7 +6178,7 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "ItemsArray", + "name": "#ItemsArray", "decorators": [], "loc": { "start": { @@ -7974,7 +6363,7 @@ } } }, - "accessibility": "protected", + "accessibility": "private", "static": true, "readonly": true, "declare": false, @@ -8059,10 +6448,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "BoxedItemsArray", + "name": "getName", "decorators": [], "loc": { "start": { @@ -8077,141 +6466,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "#Shape", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "arguments": [ - { - "type": "TSAsExpression", - "expression": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Shape", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 6, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 11, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "Circle", - "decorators": [], - "loc": { - "start": { - "line": 27, - "column": 5, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 27, - "column": 11, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - } - ], + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getName", + "decorators": [], "loc": { "start": { "line": 26, @@ -8225,29 +6492,18 @@ } } }, - { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "#Shape", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], "loc": { "start": { "line": 26, @@ -8274,46 +6530,127 @@ } } }, - "arguments": [ + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ { - "type": "TSAsExpression", - "expression": { + "type": "ReturnStatement", + "argument": { "type": "MemberExpression", "object": { - "type": "Identifier", - "name": "Shape", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Shape", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 6, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 11, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "#NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "#ordinal", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "computed": false, + "optional": false, "loc": { "start": { "line": 26, - "column": 6, + "column": 1, "program": "enum_as_class_member_getValue_call.sts" }, "end": { "line": 26, - "column": 11, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "Square", - "decorators": [], - "loc": { - "start": { - "line": 28, - "column": 5, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 28, - "column": 11, + "column": 1, "program": "enum_as_class_member_getValue_call.sts" } } }, - "computed": false, + "computed": true, "optional": false, "loc": { "start": { @@ -8328,21 +6665,6 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, "loc": { "start": { "line": 26, @@ -8370,111 +6692,135 @@ } } }, - { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "#Shape", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getValueOf", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getValueOf", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" }, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" } - }, - "arguments": [ - { - "type": "TSAsExpression", - "expression": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Shape", - "decorators": [], + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "name", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, "loc": { "start": { "line": 26, - "column": 6, + "column": 1, "program": "enum_as_class_member_getValue_call.sts" }, "end": { "line": 26, - "column": 11, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "Triangle", - "decorators": [], - "loc": { - "start": { - "line": 29, - "column": 5, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 29, - "column": 13, + "column": 1, "program": "enum_as_class_member_getValue_call.sts" } } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + }, "loc": { "start": { "line": 26, @@ -8488,6 +6834,7 @@ } } }, + "decorators": [], "loc": { "start": { "line": 26, @@ -8500,8 +6847,55 @@ "program": "enum_as_class_member_getValue_call.sts" } } + }, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } } - ], + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Shape", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, "loc": { "start": { "line": 26, @@ -8514,166 +6908,238 @@ "program": "enum_as_class_member_getValue_call.sts" } } - } - ], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "accessibility": "protected", - "static": true, - "readonly": true, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "#Shape", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ForUpdateStatement", + "init": { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "init": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "right": { + "type": "MemberExpression", + "object": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Shape", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 6, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 11, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "#NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "annotations": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "definite": false, - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "getName", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "getName", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { + "update": { + "type": "UpdateExpression", + "operator": "++", + "prefix": true, + "argument": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "body": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "==", + "left": { "type": "Identifier", - "name": "Shape", + "name": "name", "decorators": [], "loc": { "start": { @@ -8688,6 +7154,91 @@ } } }, + "right": { + "type": "MemberExpression", + "object": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Shape", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 6, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 11, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "#NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, "loc": { "start": { "line": 26, @@ -8701,6 +7252,107 @@ } } }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Shape", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 6, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 11, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "#ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "alternate": null, "loc": { "start": { "line": 26, @@ -8714,42 +7366,6 @@ } } }, - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], "loc": { "start": { "line": 26, @@ -8763,62 +7379,31 @@ } } }, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ { - "type": "ReturnStatement", + "type": "ThrowStatement", "argument": { - "type": "MemberExpression", - "object": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Shape", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Error", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } } - } - }, - "property": { - "type": "Identifier", - "name": "NamesArray", - "decorators": [], + }, "loc": { "start": { "line": 26, @@ -8832,8 +7417,6 @@ } } }, - "computed": false, - "optional": false, "loc": { "start": { "line": 26, @@ -8847,27 +7430,43 @@ } } }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant Shape.", + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + }, + "right": { + "type": "Identifier", + "name": "name", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, "loc": { "start": { "line": 26, @@ -8880,22 +7479,8 @@ "program": "enum_as_class_member_getValue_call.sts" } } - }, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } } - }, - "computed": true, - "optional": false, + ], "loc": { "start": { "line": 26, @@ -8981,7 +7566,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "getValueOf", + "name": "fromValue", "decorators": [], "loc": { "start": { @@ -9007,7 +7592,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "getValueOf", + "name": "fromValue", "decorators": [], "loc": { "start": { @@ -9030,7 +7615,7 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "name", + "name": "value", "typeAnnotation": { "type": "ETSTypeReference", "part": { @@ -9250,24 +7835,24 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Shape", + "name": "Shape", "decorators": [], "loc": { "start": { "line": 26, - "column": 1, + "column": 6, "program": "enum_as_class_member_getValue_call.sts" }, "end": { "line": 26, - "column": 1, + "column": 11, "program": "enum_as_class_member_getValue_call.sts" } } }, "property": { "type": "Identifier", - "name": "NamesArray", + "name": "#StringValuesArray", "decorators": [], "loc": { "start": { @@ -9383,7 +7968,7 @@ "operator": "==", "left": { "type": "Identifier", - "name": "name", + "name": "value", "decorators": [], "loc": { "start": { @@ -9404,7 +7989,24 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Shape", + "name": "Shape", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 6, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 11, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "#StringValuesArray", "decorators": [], "loc": { "start": { @@ -9419,9 +8021,92 @@ } } }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Shape", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 6, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 11, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, "property": { "type": "Identifier", - "name": "NamesArray", + "name": "#ItemsArray", "decorators": [], "loc": { "start": { @@ -9451,9 +8136,152 @@ } } }, - "property": { + "property": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "alternate": null, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Error", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum Shape with value ", + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "right": { "type": "Identifier", - "name": "i", + "name": "value", "decorators": [], "loc": { "start": { @@ -9468,8 +8296,6 @@ } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 26, @@ -9482,88 +8308,264 @@ "program": "enum_as_class_member_getValue_call.sts" } } + } + ], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" }, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" } + } + }, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" }, - "consequent": { - "type": "ReturnStatement", - "argument": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Shape", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + } + ], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "valueOf", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "kind": "method", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "valueOf", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Shape", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 6, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 11, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "#StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" }, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "#ordinal", + "decorators": [], "loc": { "start": { "line": 26, @@ -9577,6 +8579,8 @@ } } }, + "computed": false, + "optional": false, "loc": { "start": { "line": 26, @@ -9590,7 +8594,8 @@ } } }, - "alternate": null, + "computed": true, + "optional": false, "loc": { "start": { "line": 26, @@ -9616,32 +8621,188 @@ "program": "enum_as_class_member_getValue_call.sts" } } + } + ], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "toString", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "kind": "method", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "toString", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ { - "type": "ThrowStatement", + "type": "ReturnStatement", "argument": { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Exception", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } + "type": "MemberExpression", + "object": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Shape", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 6, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 11, + "program": "enum_as_class_member_getValue_call.sts" } - }, + } + }, + "property": { + "type": "Identifier", + "name": "#StringValuesArray", + "decorators": [], "loc": { "start": { "line": 26, @@ -9655,6 +8816,8 @@ } } }, + "computed": false, + "optional": false, "loc": { "start": { "line": 26, @@ -9668,43 +8831,27 @@ } } }, - "arguments": [ - { - "type": "BinaryExpression", - "operator": "+", - "left": { - "type": "StringLiteral", - "value": "No enum constant Shape.", - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "right": { - "type": "Identifier", - "name": "name", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" } - }, + } + }, + "property": { + "type": "Identifier", + "name": "#ordinal", + "decorators": [], "loc": { "start": { "line": 26, @@ -9717,8 +8864,24 @@ "program": "enum_as_class_member_getValue_call.sts" } } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } } - ], + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 26, @@ -9759,7 +8922,6 @@ } } }, - "throwMarker": "throws", "loc": { "start": { "line": 26, @@ -9805,7 +8967,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "toString", + "name": "values", "decorators": [], "loc": { "start": { @@ -9831,7 +8993,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "toString", + "name": "values", "decorators": [], "loc": { "start": { @@ -9849,46 +9011,17 @@ "generator": false, "async": false, "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Shape", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, + "params": [], + "returnType": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Shape", + "decorators": [], "loc": { "start": { "line": 26, @@ -9902,42 +9035,6 @@ } } }, - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], "loc": { "start": { "line": 26, @@ -9964,6 +9061,7 @@ } } }, + "annotations": [], "loc": { "start": { "line": 26, @@ -9980,95 +9078,31 @@ "body": { "type": "BlockStatement", "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Shape", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "StringValuesArray", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Shape", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 6, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 11, + "program": "enum_as_class_member_getValue_call.sts" } - }, + } + }, + "property": { + "type": "Identifier", + "name": "#ItemsArray", + "decorators": [], "loc": { "start": { "line": 26, @@ -10082,7 +9116,7 @@ } } }, - "computed": true, + "computed": false, "optional": false, "loc": { "start": { @@ -10169,7 +9203,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "values", + "name": "getOrdinal", "decorators": [], "loc": { "start": { @@ -10186,7 +9220,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -10195,7 +9229,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "values", + "name": "getOrdinal", "decorators": [], "loc": { "start": { @@ -10215,55 +9249,7 @@ "expression": false, "params": [], "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Shape", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "annotations": [], + "type": "ETSPrimitiveType", "loc": { "start": { "line": 26, @@ -10285,9 +9271,7 @@ "argument": { "type": "MemberExpression", "object": { - "type": "Identifier", - "name": "#Shape", - "decorators": [], + "type": "ThisExpression", "loc": { "start": { "line": 26, @@ -10303,7 +9287,7 @@ }, "property": { "type": "Identifier", - "name": "ItemsArray", + "name": "#ordinal", "decorators": [], "loc": { "start": { @@ -10405,7 +9389,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "fromInt", + "name": "$_get", "decorators": [], "loc": { "start": { @@ -10431,7 +9415,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "fromInt", + "name": "$_get", "decorators": [], "loc": { "start": { @@ -10447,185 +9431,21 @@ } }, "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Shape", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "<", - "left": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "right": { - "type": "MemberExpression", - "object": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Shape", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "property": { + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "e", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { "type": "Identifier", - "name": "length", + "name": "Shape", "decorators": [], "loc": { "start": { @@ -10640,8 +9460,6 @@ } } }, - "computed": false, - "optional": false, "loc": { "start": { "line": 26, @@ -10668,107 +9486,42 @@ } } }, - "consequent": { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Shape", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" }, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" } + } + }, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" }, - "alternate": null, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], "loc": { "start": { "line": 26, @@ -10782,94 +9535,62 @@ } } }, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ { - "type": "ThrowStatement", + "type": "ReturnStatement", "argument": { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Exception", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "e", + "decorators": [], "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "arguments": [ - { - "type": "BinaryExpression", - "operator": "+", - "left": { - "type": "StringLiteral", - "value": "No enum constant in Shape with ordinal value ", - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "right": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" } - }, + } + }, + "property": { + "type": "Identifier", + "name": "getName", + "decorators": [], "loc": { "start": { "line": 26, @@ -10882,8 +9603,24 @@ "program": "enum_as_class_member_getValue_call.sts" } } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } } - ], + }, + "arguments": [], + "optional": false, "loc": { "start": { "line": 26, @@ -10924,7 +9661,6 @@ } } }, - "throwMarker": "throws", "loc": { "start": { "line": 26, @@ -10960,8 +9696,232 @@ "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 26, - "column": 1, + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + } + ], + "loc": { + "start": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 26, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1, + "program": null + }, + "end": { + "line": 1, + "column": 1, + "program": null + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 32, + "column": 7, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 32, + "column": 8, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "sub", + "decorators": [], + "loc": { + "start": { + "line": 33, + "column": 12, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 33, + "column": 15, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "accessibility": "public", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 33, + "column": 17, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 33, + "column": 22, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 33, + "column": 17, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 33, + "column": 23, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 33, + "column": 17, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 33, + "column": 23, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 33, + "column": 12, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 33, + "column": 23, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "shape", + "decorators": [], + "loc": { + "start": { + "line": 34, + "column": 12, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 34, + "column": 17, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "accessibility": "public", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Shape", + "decorators": [], + "loc": { + "start": { + "line": 34, + "column": 19, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 34, + "column": 24, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 34, + "column": 19, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 34, + "column": 25, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 34, + "column": 19, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 34, + "column": 25, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 34, + "column": 12, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 34, + "column": 25, "program": "enum_as_class_member_getValue_call.sts" } } @@ -10970,22 +9930,22 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "unbox", + "name": "constructor", "decorators": [], "loc": { "start": { - "line": 26, + "line": 1, "column": 1, - "program": "enum_as_class_member_getValue_call.sts" + "program": null }, "end": { - "line": 26, + "line": 1, "column": 1, - "program": "enum_as_class_member_getValue_call.sts" + "program": null } } }, - "kind": "method", + "kind": "constructor", "accessibility": "public", "static": false, "optional": false, @@ -10996,111 +9956,222 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "unbox", + "name": "constructor", "decorators": [], "loc": { "start": { - "line": 26, + "line": 1, "column": 1, - "program": "enum_as_class_member_getValue_call.sts" + "program": null }, "end": { - "line": 26, + "line": 1, "column": 1, - "program": "enum_as_class_member_getValue_call.sts" + "program": null } } }, "generator": false, "async": false, "expression": false, - "params": [], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", + "params": [ + { + "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "Shape", + "name": "sub", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 36, + "column": 22, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 36, + "column": 27, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 36, + "column": 22, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 36, + "column": 28, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 36, + "column": 22, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 36, + "column": 28, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, "decorators": [], "loc": { "start": { - "line": 26, - "column": 1, + "line": 36, + "column": 17, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 26, - "column": 1, + "line": 36, + "column": 28, "program": "enum_as_class_member_getValue_call.sts" } } }, "loc": { "start": { - "line": 26, - "column": 1, + "line": 36, + "column": 17, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 26, - "column": 1, + "line": 36, + "column": 28, "program": "enum_as_class_member_getValue_call.sts" } } }, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "shape", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Shape", + "decorators": [], + "loc": { + "start": { + "line": 36, + "column": 36, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 36, + "column": 41, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 36, + "column": 36, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 36, + "column": 42, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 36, + "column": 36, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 36, + "column": 42, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 36, + "column": 29, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 36, + "column": 42, + "program": "enum_as_class_member_getValue_call.sts" + } + } }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" + "loc": { + "start": { + "line": 36, + "column": 29, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 36, + "column": 42, + "program": "enum_as_class_member_getValue_call.sts" + } } } - }, + ], "body": { "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { "type": "MemberExpression", "object": { - "type": "Identifier", - "name": "#Shape", - "decorators": [], + "type": "ThisExpression", "loc": { "start": { - "line": 26, - "column": 1, + "line": 37, + "column": 9, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 26, - "column": 1, + "line": 37, + "column": 13, "program": "enum_as_class_member_getValue_call.sts" } } }, "property": { "type": "Identifier", - "name": "ItemsArray", + "name": "sub", "decorators": [], "loc": { "start": { - "line": 26, - "column": 1, + "line": 37, + "column": 14, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 26, - "column": 1, + "line": 37, + "column": 17, "program": "enum_as_class_member_getValue_call.sts" } } @@ -11109,47 +10180,95 @@ "optional": false, "loc": { "start": { - "line": 26, - "column": 1, + "line": 37, + "column": 9, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 26, - "column": 1, + "line": 37, + "column": 17, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "right": { + "type": "Identifier", + "name": "sub", + "decorators": [], + "loc": { + "start": { + "line": 37, + "column": 20, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 37, + "column": 23, "program": "enum_as_class_member_getValue_call.sts" } } }, - "property": { + "loc": { + "start": { + "line": 37, + "column": 9, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 37, + "column": 23, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 37, + "column": 9, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 37, + "column": 24, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { "type": "MemberExpression", "object": { "type": "ThisExpression", "loc": { "start": { - "line": 26, - "column": 1, + "line": 38, + "column": 9, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 26, - "column": 1, + "line": 38, + "column": 13, "program": "enum_as_class_member_getValue_call.sts" } } }, "property": { "type": "Identifier", - "name": "ordinal", + "name": "shape", "decorators": [], "loc": { "start": { - "line": 26, - "column": 1, + "line": 38, + "column": 14, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 26, - "column": 1, + "line": 38, + "column": 19, "program": "enum_as_class_member_getValue_call.sts" } } @@ -11158,41 +10277,56 @@ "optional": false, "loc": { "start": { - "line": 26, - "column": 1, + "line": 38, + "column": 9, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 26, - "column": 1, + "line": 38, + "column": 19, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "right": { + "type": "Identifier", + "name": "shape", + "decorators": [], + "loc": { + "start": { + "line": 38, + "column": 22, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 38, + "column": 27, "program": "enum_as_class_member_getValue_call.sts" } } }, - "computed": true, - "optional": false, "loc": { "start": { - "line": 26, - "column": 1, + "line": 38, + "column": 9, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 26, - "column": 1, + "line": 38, + "column": 27, "program": "enum_as_class_member_getValue_call.sts" } } }, "loc": { "start": { - "line": 26, - "column": 1, + "line": 38, + "column": 9, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 26, - "column": 1, + "line": 38, + "column": 28, "program": "enum_as_class_member_getValue_call.sts" } } @@ -11200,39 +10334,39 @@ ], "loc": { "start": { - "line": 26, - "column": 1, + "line": 36, + "column": 43, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 26, - "column": 1, + "line": 39, + "column": 6, "program": "enum_as_class_member_getValue_call.sts" } } }, "loc": { "start": { - "line": 26, - "column": 1, + "line": 36, + "column": 16, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 26, - "column": 1, + "line": 39, + "column": 6, "program": "enum_as_class_member_getValue_call.sts" } } }, "loc": { "start": { - "line": 26, - "column": 1, + "line": 36, + "column": 16, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 26, - "column": 1, + "line": 39, + "column": 6, "program": "enum_as_class_member_getValue_call.sts" } } @@ -11241,13 +10375,13 @@ "decorators": [], "loc": { "start": { - "line": 26, - "column": 1, + "line": 36, + "column": 5, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 26, - "column": 1, + "line": 39, + "column": 6, "program": "enum_as_class_member_getValue_call.sts" } } @@ -11256,24 +10390,24 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "boxedfromInt", + "name": "foo", "decorators": [], "loc": { "start": { - "line": 26, - "column": 1, + "line": 41, + "column": 5, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 26, - "column": 1, + "line": 41, + "column": 8, "program": "enum_as_class_member_getValue_call.sts" } } }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -11282,17 +10416,17 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "boxedfromInt", + "name": "foo", "decorators": [], "loc": { "start": { - "line": 26, - "column": 1, + "line": 41, + "column": 5, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 26, - "column": 1, + "line": 41, + "column": 8, "program": "enum_as_class_member_getValue_call.sts" } } @@ -11300,505 +10434,609 @@ "generator": false, "async": false, "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "#Shape", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, + "params": [], "body": { "type": "BlockStatement", "statements": [ { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "<", - "left": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "a", + "decorators": [], + "loc": { + "start": { + "line": 42, + "column": 13, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 42, + "column": 14, + "program": "enum_as_class_member_getValue_call.sts" + } } - } - }, - "right": { - "type": "MemberExpression", - "object": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Shape", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" + }, + "init": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "object": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 42, + "column": 17, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 42, + "column": 21, + "program": "enum_as_class_member_getValue_call.sts" + } + } }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" + "property": { + "type": "Identifier", + "name": "sub", + "decorators": [], + "loc": { + "start": { + "line": 42, + "column": 22, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 42, + "column": 25, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 42, + "column": 17, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 42, + "column": 25, + "program": "enum_as_class_member_getValue_call.sts" + } } - } - }, - "property": { - "type": "Identifier", - "name": "BoxedItemsArray", - "decorators": [], + }, + "property": { + "type": "Identifier", + "name": "valueOf", + "decorators": [], + "loc": { + "start": { + "line": 42, + "column": 26, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 42, + "column": 33, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "computed": false, + "optional": false, "loc": { "start": { - "line": 26, - "column": 1, + "line": 42, + "column": 17, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 26, - "column": 1, + "line": 42, + "column": 33, "program": "enum_as_class_member_getValue_call.sts" } } }, - "computed": false, + "arguments": [], "optional": false, "loc": { "start": { - "line": 26, - "column": 1, + "line": 42, + "column": 17, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 26, - "column": 1, + "line": 42, + "column": 35, "program": "enum_as_class_member_getValue_call.sts" } } }, - "property": { + "loc": { + "start": { + "line": 42, + "column": 13, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 42, + "column": 35, + "program": "enum_as_class_member_getValue_call.sts" + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 42, + "column": 9, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 42, + "column": 36, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { "type": "Identifier", - "name": "length", + "name": "b", "decorators": [], "loc": { "start": { - "line": 26, - "column": 1, + "line": 43, + "column": 13, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 26, - "column": 1, + "line": 43, + "column": 14, "program": "enum_as_class_member_getValue_call.sts" } } }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "consequent": { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Shape", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" + "init": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "object": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 43, + "column": 17, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 43, + "column": 21, + "program": "enum_as_class_member_getValue_call.sts" + } + } }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" + "property": { + "type": "Identifier", + "name": "shape", + "decorators": [], + "loc": { + "start": { + "line": 43, + "column": 22, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 43, + "column": 27, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 43, + "column": 17, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 43, + "column": 27, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "valueOf", + "decorators": [], + "loc": { + "start": { + "line": 43, + "column": 28, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 43, + "column": 35, + "program": "enum_as_class_member_getValue_call.sts" + } } - } - }, - "property": { - "type": "Identifier", - "name": "BoxedItemsArray", - "decorators": [], + }, + "computed": false, + "optional": false, "loc": { "start": { - "line": 26, - "column": 1, + "line": 43, + "column": 17, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 26, - "column": 1, + "line": 43, + "column": 35, "program": "enum_as_class_member_getValue_call.sts" } } }, - "computed": false, + "arguments": [], "optional": false, "loc": { "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, + "line": 43, + "column": 17, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 26, - "column": 1, + "line": 43, + "column": 37, "program": "enum_as_class_member_getValue_call.sts" } } }, - "computed": true, - "optional": false, "loc": { "start": { - "line": 26, - "column": 1, + "line": 43, + "column": 13, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 26, - "column": 1, + "line": 43, + "column": 37, "program": "enum_as_class_member_getValue_call.sts" } } - }, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } } - }, - "alternate": null, + ], + "kind": "let", "loc": { "start": { - "line": 26, - "column": 1, + "line": 43, + "column": 9, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 26, - "column": 1, + "line": 43, + "column": 38, "program": "enum_as_class_member_getValue_call.sts" } } + } + ], + "loc": { + "start": { + "line": 41, + "column": 11, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 44, + "column": 6, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 41, + "column": 8, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 44, + "column": 6, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 41, + "column": 8, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 44, + "column": 6, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 41, + "column": 5, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 44, + "column": 6, + "program": "enum_as_class_member_getValue_call.sts" + } + } + } + ], + "loc": { + "start": { + "line": 32, + "column": 9, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 47, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "loc": { + "start": { + "line": 32, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 47, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ETSGLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 1, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "main", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1, + "program": null + }, + "end": { + "line": 1, + "column": 1, + "program": null + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "main", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1, + "program": null + }, + "end": { + "line": 1, + "column": 1, + "program": null + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1, + "program": null + }, + "end": { + "line": 1, + "column": 1, + "program": null + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1, + "program": null + }, + "end": { + "line": 1, + "column": 1, + "program": null + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1, + "program": null + }, + "end": { + "line": 1, + "column": 1, + "program": null + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + }, + "end": { + "line": 1, + "column": 1, + "program": "enum_as_class_member_getValue_call.sts" + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1, + "program": null + }, + "end": { + "line": 1, + "column": 1, + "program": null + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1, + "program": null }, - { - "type": "ThrowStatement", - "argument": { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Exception", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "arguments": [ - { - "type": "BinaryExpression", - "operator": "+", - "left": { - "type": "StringLiteral", - "value": "No enum constant in Shape with ordinal value ", - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "right": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - } - ], - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - }, - "end": { - "line": 26, - "column": 1, - "program": "enum_as_class_member_getValue_call.sts" - } - } + "end": { + "line": 1, + "column": 1, + "program": null } - ], + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], "loc": { "start": { - "line": 26, + "line": 1, "column": 1, - "program": "enum_as_class_member_getValue_call.sts" + "program": null }, "end": { - "line": 26, + "line": 1, "column": 1, - "program": "enum_as_class_member_getValue_call.sts" + "program": null } } }, - "throwMarker": "throws", "loc": { "start": { - "line": 26, + "line": 1, "column": 1, - "program": "enum_as_class_member_getValue_call.sts" + "program": null }, "end": { - "line": 26, + "line": 1, "column": 1, - "program": "enum_as_class_member_getValue_call.sts" + "program": null } } }, "loc": { "start": { - "line": 26, + "line": 1, "column": 1, - "program": "enum_as_class_member_getValue_call.sts" + "program": null }, "end": { - "line": 26, + "line": 1, "column": 1, - "program": "enum_as_class_member_getValue_call.sts" + "program": null } } }, @@ -11806,12 +11044,12 @@ "decorators": [], "loc": { "start": { - "line": 26, + "line": 1, "column": 1, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 26, + "line": 1, "column": 1, "program": "enum_as_class_member_getValue_call.sts" } @@ -11820,12 +11058,12 @@ ], "loc": { "start": { - "line": 26, + "line": 1, "column": 1, "program": "enum_as_class_member_getValue_call.sts" }, "end": { - "line": 26, + "line": 1, "column": 1, "program": "enum_as_class_member_getValue_call.sts" } @@ -11835,12 +11073,12 @@ "start": { "line": 1, "column": 1, - "program": null + "program": "enum_as_class_member_getValue_call.sts" }, "end": { "line": 1, "column": 1, - "program": null + "program": "enum_as_class_member_getValue_call.sts" } } } diff --git a/ets2panda/test/compiler/ets/import_tests/enum_export-expected.txt b/ets2panda/test/compiler/ets/import_tests/enum_export-expected.txt index d1ef5eaecb..77cd873885 100644 --- a/ets2panda/test/compiler/ets/import_tests/enum_export-expected.txt +++ b/ets2panda/test/compiler/ets/import_tests/enum_export-expected.txt @@ -2,582 +2,104 @@ "type": "Program", "statements": [ { - "type": "TSEnumDeclaration", - "id": { - "type": "Identifier", - "name": "AmbientColor", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 14, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 26, - "program": "enum_export.sts" - } - } - }, - "members": [ - { - "type": "TSEnumMember", - "id": { - "type": "Identifier", - "name": "Yellow", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 30, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 36, - "program": "enum_export.sts" - } - } - }, - "initializer": { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 20, - "column": 36, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 36, - "program": "enum_export.sts" - } - } - }, + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "AmbientColor", + "decorators": [], "loc": { "start": { "line": 20, - "column": 30, + "column": 14, "program": "enum_export.sts" }, "end": { "line": 20, - "column": 36, + "column": 26, "program": "enum_export.sts" } } - } - ], - "const": false, - "declare": true, - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" }, - "end": { - "line": 20, - "column": 38, - "program": "enum_export.sts" - } - } - }, - { - "type": "TSEnumDeclaration", - "id": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 13, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 18, - "program": "enum_export.sts" - } - } - }, - "members": [ - { - "type": "TSEnumMember", - "id": { - "type": "Identifier", - "name": "Red", - "decorators": [], - "loc": { - "start": { - "line": 23, - "column": 5, - "program": "enum_export.sts" - }, - "end": { - "line": 23, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "initializer": { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 23, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 23, - "column": 8, - "program": "enum_export.sts" + "superClass": null, + "implements": [], + "body": [ + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "#ordinal", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + }, + "end": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + } } - } - }, - "loc": { - "start": { - "line": 23, - "column": 5, - "program": "enum_export.sts" }, - "end": { - "line": 23, - "column": 8, - "program": "enum_export.sts" - } - } - }, - { - "type": "TSEnumMember", - "id": { - "type": "Identifier", - "name": "Blue", - "decorators": [], - "loc": { - "start": { - "line": 23, - "column": 10, - "program": "enum_export.sts" - }, - "end": { - "line": 23, - "column": 14, - "program": "enum_export.sts" - } - } - }, - "initializer": { - "type": "NumberLiteral", - "value": 42, - "loc": { - "start": { - "line": 23, - "column": 17, - "program": "enum_export.sts" - }, - "end": { - "line": 23, - "column": 19, - "program": "enum_export.sts" + "accessibility": "private", + "static": false, + "readonly": true, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + }, + "end": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + } } - } - }, - "loc": { - "start": { - "line": 23, - "column": 10, - "program": "enum_export.sts" }, - "end": { - "line": 23, - "column": 19, - "program": "enum_export.sts" - } - } - }, - { - "type": "TSEnumMember", - "id": { - "type": "Identifier", - "name": "Green", + "definite": false, "decorators": [], "loc": { "start": { - "line": 23, - "column": 21, + "line": 20, + "column": 9, "program": "enum_export.sts" }, "end": { - "line": 23, - "column": 26, + "line": 20, + "column": 9, "program": "enum_export.sts" } } }, - "initializer": { - "type": "NumberLiteral", - "value": 43, - "loc": { - "start": { - "line": 23, - "column": 26, - "program": "enum_export.sts" - }, - "end": { - "line": 23, - "column": 26, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 23, - "column": 21, - "program": "enum_export.sts" - }, - "end": { - "line": 23, - "column": 26, - "program": "enum_export.sts" - } - } - } - ], - "const": false, - "declare": false, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 24, - "column": 2, - "program": "enum_export.sts" - } - } - }, - { - "type": "TSEnumDeclaration", - "id": { - "type": "Identifier", - "name": "Commands", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 13, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 21, - "program": "enum_export.sts" - } - } - }, - "members": [ - { - "type": "TSEnumMember", - "id": { - "type": "Identifier", - "name": "Open", - "decorators": [], - "loc": { - "start": { - "line": 27, - "column": 5, - "program": "enum_export.sts" - }, - "end": { - "line": 27, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "initializer": { - "type": "StringLiteral", - "value": "fopen", - "loc": { - "start": { - "line": 27, - "column": 12, - "program": "enum_export.sts" - }, - "end": { - "line": 27, - "column": 19, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 27, - "column": 5, - "program": "enum_export.sts" - }, - "end": { - "line": 27, - "column": 19, - "program": "enum_export.sts" - } - } - }, - { - "type": "TSEnumMember", - "id": { - "type": "Identifier", - "name": "Close", - "decorators": [], - "loc": { - "start": { - "line": 28, - "column": 5, - "program": "enum_export.sts" - }, - "end": { - "line": 28, - "column": 10, - "program": "enum_export.sts" - } - } - }, - "initializer": { - "type": "StringLiteral", - "value": "fclose", - "loc": { - "start": { - "line": 28, - "column": 13, - "program": "enum_export.sts" - }, - "end": { - "line": 28, - "column": 21, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 28, - "column": 5, - "program": "enum_export.sts" - }, - "end": { - "line": 28, - "column": 21, - "program": "enum_export.sts" - } - } - } - ], - "const": false, - "declare": false, - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 29, - "column": 2, - "program": "enum_export.sts" - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "C", - "decorators": [], - "loc": { - "start": { - "line": 31, - "column": 14, - "program": "enum_export.sts" - }, - "end": { - "line": 31, - "column": 15, - "program": "enum_export.sts" - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "a", - "decorators": [], - "loc": { - "start": { - "line": 32, - "column": 3, - "program": "enum_export.sts" - }, - "end": { - "line": 32, - "column": 4, - "program": "enum_export.sts" - } - } - }, - "value": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "AmbientColor", - "decorators": [], - "loc": { - "start": { - "line": 32, - "column": 22, - "program": "enum_export.sts" - }, - "end": { - "line": 32, - "column": 34, - "program": "enum_export.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "Yellow", - "decorators": [], - "loc": { - "start": { - "line": 32, - "column": 35, - "program": "enum_export.sts" - }, - "end": { - "line": 32, - "column": 41, - "program": "enum_export.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 32, - "column": 22, - "program": "enum_export.sts" - }, - "end": { - "line": 32, - "column": 41, - "program": "enum_export.sts" - } - } - }, - "accessibility": "public", - "static": false, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "AmbientColor", - "decorators": [], - "loc": { - "start": { - "line": 32, - "column": 7, - "program": "enum_export.sts" - }, - "end": { - "line": 32, - "column": 19, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 32, - "column": 7, - "program": "enum_export.sts" - }, - "end": { - "line": 32, - "column": 21, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 32, - "column": 7, - "program": "enum_export.sts" - }, - "end": { - "line": 32, - "column": 21, - "program": "enum_export.sts" - } - } - }, - "definite": false, - "decorators": [], - "loc": { - "start": { - "line": 32, - "column": 3, - "program": "enum_export.sts" - }, - "end": { - "line": 32, - "column": 41, - "program": "enum_export.sts" - } - } - }, - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "constructor", - "decorators": [], - "loc": { - "start": { - "line": 31, - "column": 17, - "program": "enum_export.sts" - }, - "end": { - "line": 31, - "column": 17, - "program": "enum_export.sts" - } + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + }, + "end": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + } } }, "kind": "constructor", + "accessibility": "public", "static": false, "optional": false, "computed": false, @@ -591,13 +113,13 @@ "decorators": [], "loc": { "start": { - "line": 31, - "column": 17, + "line": 20, + "column": 9, "program": "enum_export.sts" }, "end": { - "line": 31, - "column": 17, + "line": 20, + "column": 9, "program": "enum_export.sts" } } @@ -605,45 +127,191 @@ "generator": false, "async": false, "expression": false, - "params": [], - "body": { - "type": "BlockStatement", - "statements": [], + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + }, + "end": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + }, + "end": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + }, + "end": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + }, + "end": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "#ordinal", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + }, + "end": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + }, + "end": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + }, + "end": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + }, + "end": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + }, + "end": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + } + } + } + ], "loc": { "start": { - "line": 31, - "column": 17, + "line": 20, + "column": 9, "program": "enum_export.sts" }, "end": { - "line": 31, - "column": 17, + "line": 20, + "column": 9, "program": "enum_export.sts" } } }, "loc": { "start": { - "line": 31, - "column": 17, + "line": 20, + "column": 9, "program": "enum_export.sts" }, "end": { - "line": 31, - "column": 17, + "line": 20, + "column": 9, "program": "enum_export.sts" } } }, "loc": { "start": { - "line": 31, - "column": 17, + "line": 20, + "column": 9, "program": "enum_export.sts" }, "end": { - "line": 31, - "column": 17, + "line": 20, + "column": 9, "program": "enum_export.sts" } } @@ -652,334 +320,189 @@ "decorators": [], "loc": { "start": { - "line": 1, - "column": 1, - "program": null + "line": 20, + "column": 9, + "program": "enum_export.sts" }, "end": { - "line": 1, - "column": 1, - "program": null + "line": 20, + "column": 9, + "program": "enum_export.sts" } } - } - ], - "loc": { - "start": { - "line": 31, - "column": 16, - "program": "enum_export.sts" }, - "end": { - "line": 33, - "column": 3, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 31, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 33, - "column": 3, - "program": "enum_export.sts" - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "ETSGLOBAL", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "enum_export.sts" - }, - "end": { - "line": 1, - "column": 1, - "program": "enum_export.sts" - } - } - }, - "superClass": null, - "implements": [], - "body": [ { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "main", + "name": "Yellow", "decorators": [], "loc": { "start": { - "line": 1, - "column": 1, - "program": null + "line": 20, + "column": 30, + "program": "enum_export.sts" }, "end": { - "line": 1, - "column": 1, - "program": null + "line": 20, + "column": 36, + "program": "enum_export.sts" } } }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "main", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": null - }, - "end": { - "line": 1, - "column": 1, - "program": null + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "AmbientColor", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + }, + "end": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + } } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "body": { - "type": "BlockStatement", - "statements": [], + }, "loc": { "start": { - "line": 1, - "column": 1, - "program": null + "line": 20, + "column": 9, + "program": "enum_export.sts" }, "end": { - "line": 1, - "column": 1, - "program": null + "line": 20, + "column": 9, + "program": "enum_export.sts" } } }, "loc": { "start": { - "line": 1, - "column": 1, - "program": null + "line": 20, + "column": 9, + "program": "enum_export.sts" }, "end": { - "line": 1, - "column": 1, - "program": null + "line": 20, + "column": 9, + "program": "enum_export.sts" } } }, - "loc": { - "start": { - "line": 1, - "column": 1, - "program": null - }, - "end": { - "line": 1, - "column": 1, - "program": null + "arguments": [ + { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + }, + "end": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + } + } } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "enum_export.sts" - }, - "end": { - "line": 1, - "column": 1, - "program": "enum_export.sts" - } - } - }, - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "_$init$_", - "decorators": [], + ], "loc": { "start": { - "line": 1, - "column": 1, - "program": null + "line": 20, + "column": 36, + "program": "enum_export.sts" }, "end": { - "line": 1, - "column": 1, - "program": null + "line": 20, + "column": 36, + "program": "enum_export.sts" } } }, - "kind": "method", "accessibility": "public", "static": true, + "readonly": true, + "declare": false, "optional": false, "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { "type": "Identifier", - "name": "_$init$_", + "name": "AmbientColor", "decorators": [], "loc": { "start": { - "line": 1, - "column": 1, - "program": null - }, - "end": { - "line": 1, - "column": 1, - "program": null - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "body": { - "type": "BlockStatement", - "statements": [], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": null + "line": 20, + "column": 9, + "program": "enum_export.sts" }, "end": { - "line": 1, - "column": 1, - "program": null + "line": 20, + "column": 9, + "program": "enum_export.sts" } } }, "loc": { "start": { - "line": 1, - "column": 1, - "program": null + "line": 20, + "column": 9, + "program": "enum_export.sts" }, "end": { - "line": 1, - "column": 1, - "program": null + "line": 20, + "column": 9, + "program": "enum_export.sts" } } }, "loc": { "start": { - "line": 1, - "column": 1, - "program": null + "line": 20, + "column": 9, + "program": "enum_export.sts" }, "end": { - "line": 1, - "column": 1, - "program": null + "line": 20, + "column": 9, + "program": "enum_export.sts" } } }, - "overloads": [], + "definite": false, "decorators": [], "loc": { "start": { - "line": 1, - "column": 1, + "line": 20, + "column": 30, "program": "enum_export.sts" }, "end": { - "line": 1, - "column": 1, + "line": 20, + "column": 36, "program": "enum_export.sts" } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "enum_export.sts" }, - "end": { - "line": 1, - "column": 1, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "enum_export.sts" - }, - "end": { - "line": 1, - "column": 1, - "program": "enum_export.sts" - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "#AmbientColor", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "superClass": null, - "implements": [], - "body": [ { "type": "ClassProperty", "key": { "type": "Identifier", - "name": "ordinal", + "name": "#NamesArray", "decorators": [], "loc": { "start": { @@ -994,48 +517,26 @@ } } }, - "accessibility": "protected", - "static": false, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "Yellow", + "loc": { + "start": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + }, + "end": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + } + } } - } - }, - "definite": false, - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "constructor", - "decorators": [], + ], "loc": { "start": { "line": 20, @@ -1049,70 +550,22 @@ } } }, - "kind": "constructor", - "accessibility": "public", - "static": false, + "accessibility": "private", + "static": true, + "readonly": true, + "declare": false, "optional": false, "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "constructor", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], "loc": { "start": { "line": 20, @@ -1125,109 +578,7 @@ "program": "enum_export.sts" } } - } - ], - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "MemberExpression", - "object": { - "type": "ThisExpression", - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "right": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - } - ], + }, "loc": { "start": { "line": 20, @@ -1254,6 +605,7 @@ } } }, + "annotations": [], "loc": { "start": { "line": 20, @@ -1267,7 +619,7 @@ } } }, - "overloads": [], + "definite": false, "decorators": [], "loc": { "start": { @@ -1286,7 +638,7 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "NamesArray", + "name": "#ValuesArray", "decorators": [], "loc": { "start": { @@ -1305,8 +657,8 @@ "type": "ArrayExpression", "elements": [ { - "type": "StringLiteral", - "value": "Yellow", + "type": "NumberLiteral", + "value": 0, "loc": { "start": { "line": 20, @@ -1334,143 +686,7 @@ } } }, - "accessibility": "protected", - "static": true, - "readonly": true, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "annotations": [], - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "definite": false, - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "ValuesArray", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - } - ], - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "accessibility": "protected", + "accessibility": "private", "static": true, "readonly": true, "declare": false, @@ -1526,7 +742,7 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "StringValuesArray", + "name": "#StringValuesArray", "decorators": [], "loc": { "start": { @@ -1574,7 +790,7 @@ } } }, - "accessibility": "protected", + "accessibility": "private", "static": true, "readonly": true, "declare": false, @@ -1662,7 +878,7 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "ItemsArray", + "name": "#ItemsArray", "decorators": [], "loc": { "start": { @@ -1745,7 +961,7 @@ } } }, - "accessibility": "protected", + "accessibility": "private", "static": true, "readonly": true, "declare": false, @@ -1830,10 +1046,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "BoxedItemsArray", + "name": "getName", "decorators": [], "loc": { "start": { @@ -1848,32 +1064,44 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "#AmbientColor", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getName", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + }, + "end": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], "loc": { "start": { "line": 20, @@ -1900,145 +1128,6 @@ } } }, - "arguments": [ - { - "type": "TSAsExpression", - "expression": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "AmbientColor", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 14, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 26, - "program": "enum_export.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "Yellow", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 30, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 36, - "program": "enum_export.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - } - ], - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - } - ], - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "accessibility": "protected", - "static": true, - "readonly": true, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "#AmbientColor", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, "loc": { "start": { "line": 20, @@ -2052,6 +1141,7 @@ } } }, + "declare": true, "loc": { "start": { "line": 20, @@ -2065,7 +1155,6 @@ } } }, - "annotations": [], "loc": { "start": { "line": 20, @@ -2079,7 +1168,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2098,7 +1187,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "getName", + "name": "getValueOf", "decorators": [], "loc": { "start": { @@ -2124,7 +1213,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "getName", + "name": "getValueOf", "decorators": [], "loc": { "start": { @@ -2147,14 +1236,14 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "ordinal", + "name": "name", "typeAnnotation": { "type": "ETSTypeReference", "part": { "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "AmbientColor", + "name": "String", "decorators": [], "loc": { "start": { @@ -2229,7 +1318,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "AmbientColor", "decorators": [], "loc": { "start": { @@ -2316,7 +1405,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "getValueOf", + "name": "fromValue", "decorators": [], "loc": { "start": { @@ -2342,7 +1431,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "getValueOf", + "name": "fromValue", "decorators": [], "loc": { "start": { @@ -2365,41 +1454,9 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "name", + "name": "value", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 20, @@ -2489,7 +1546,6 @@ } }, "declare": true, - "throwMarker": "throws", "loc": { "start": { "line": 20, @@ -2552,7 +1608,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -2579,87 +1635,7 @@ "generator": false, "async": false, "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "e", - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "AmbientColor", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - } - ], + "params": [], "returnType": { "type": "ETSPrimitiveType", "loc": { @@ -2738,7 +1714,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -2765,94 +1741,14 @@ "generator": false, "async": false, "expression": false, - "params": [ - { - "type": "ETSParameterExpression", + "params": [], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "AmbientColor", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", + "name": "String", "decorators": [], "loc": { "start": { @@ -3093,7 +1989,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "fromInt", + "name": "getOrdinal", "decorators": [], "loc": { "start": { @@ -3110,7 +2006,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -3119,7 +2015,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "fromInt", + "name": "getOrdinal", "decorators": [], "loc": { "start": { @@ -3137,89 +2033,9 @@ "generator": false, "async": false, "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - } - ], + "params": [], "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "AmbientColor", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 20, @@ -3234,7 +2050,6 @@ } }, "declare": true, - "throwMarker": "throws", "loc": { "start": { "line": 20, @@ -3280,7 +2095,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "unbox", + "name": "$_get", "decorators": [], "loc": { "start": { @@ -3297,7 +2112,7 @@ }, "kind": "method", "accessibility": "public", - "static": false, + "static": true, "optional": false, "computed": false, "value": { @@ -3306,7 +2121,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "unbox", + "name": "$_get", "decorators": [], "loc": { "start": { @@ -3324,14 +2139,94 @@ "generator": false, "async": false, "expression": false, - "params": [], + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "e", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "AmbientColor", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + }, + "end": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + }, + "end": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + }, + "end": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + }, + "end": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + }, + "end": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + } + } + } + ], "returnType": { "type": "ETSTypeReference", "part": { "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "AmbientColor", + "name": "String", "decorators": [], "loc": { "start": { @@ -3413,254 +2308,67 @@ "program": "enum_export.sts" } } + } + ], + "loc": { + "start": { + "line": 20, + "column": 9, + "program": "enum_export.sts" }, + "end": { + "line": 20, + "column": 9, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1, + "program": null + }, + "end": { + "line": 1, + "column": 1, + "program": null + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 13, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 18, + "program": "enum_export.sts" + } + } + }, + "superClass": null, + "implements": [], + "body": [ { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "boxedfromInt", + "name": "#ordinal", "decorators": [], "loc": { "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "boxedfromInt", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "#AmbientColor", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "declare": true, - "throwMarker": "throws", - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - } - ], - "loc": { - "start": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - }, - "end": { - "line": 20, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1, - "program": null - }, - "end": { - "line": 1, - "column": 1, - "program": null - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "#Color", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, + "line": 22, + "column": 8, "program": "enum_export.sts" }, "end": { @@ -3670,9 +2378,9 @@ } } }, - "accessibility": "protected", + "accessibility": "private", "static": false, - "readonly": false, + "readonly": true, "declare": false, "optional": false, "computed": false, @@ -3726,7 +2434,7 @@ } }, "kind": "method", - "accessibility": "public", + "accessibility": "private", "static": true, "optional": false, "computed": false, @@ -3936,7 +2644,7 @@ }, "property": { "type": "Identifier", - "name": "ordinal", + "name": "#ordinal", "decorators": [], "loc": { "start": { @@ -4068,45 +2776,46 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "NamesArray", + "name": "Red", "decorators": [], "loc": { "start": { - "line": 22, - "column": 8, + "line": 23, + "column": 5, "program": "enum_export.sts" }, "end": { - "line": 22, + "line": 23, "column": 8, "program": "enum_export.sts" } } }, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "Red", - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - { - "type": "StringLiteral", - "value": "Blue", - "loc": { - "start": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { "line": 22, "column": 8, "program": "enum_export.sts" @@ -4118,9 +2827,23 @@ } } }, + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "arguments": [ { - "type": "StringLiteral", - "value": "Green", + "type": "NumberLiteral", + "value": 0, "loc": { "start": { "line": 22, @@ -4137,46 +2860,31 @@ ], "loc": { "start": { - "line": 22, + "line": 23, "column": 8, "program": "enum_export.sts" }, "end": { - "line": 22, + "line": 23, "column": 8, "program": "enum_export.sts" } } }, - "accessibility": "protected", + "accessibility": "public", "static": true, "readonly": true, "declare": false, "optional": false, "computed": false, "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], "loc": { "start": { "line": 22, @@ -4203,7 +2911,6 @@ } } }, - "annotations": [], "loc": { "start": { "line": 22, @@ -4221,12 +2928,12 @@ "decorators": [], "loc": { "start": { - "line": 22, - "column": 8, + "line": 23, + "column": 5, "program": "enum_export.sts" }, "end": { - "line": 22, + "line": 23, "column": 8, "program": "enum_export.sts" } @@ -4236,43 +2943,44 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "ValuesArray", + "name": "Blue", "decorators": [], "loc": { "start": { - "line": 22, - "column": 8, + "line": 23, + "column": 10, "program": "enum_export.sts" }, "end": { - "line": 22, - "column": 8, + "line": 23, + "column": 14, "program": "enum_export.sts" } } }, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } } - } - }, - { - "type": "NumberLiteral", - "value": 42, + }, "loc": { "start": { "line": 22, @@ -4286,9 +2994,23 @@ } } }, + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "arguments": [ { "type": "NumberLiteral", - "value": 43, + "value": 1, "loc": { "start": { "line": 22, @@ -4305,27 +3027,44 @@ ], "loc": { "start": { - "line": 22, - "column": 8, + "line": 23, + "column": 17, "program": "enum_export.sts" }, "end": { - "line": 22, - "column": 8, + "line": 23, + "column": 19, "program": "enum_export.sts" } } }, - "accessibility": "protected", + "accessibility": "public", "static": true, "readonly": true, "declare": false, "optional": false, "computed": false, "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSPrimitiveType", + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, "loc": { "start": { "line": 22, @@ -4339,7 +3078,6 @@ } } }, - "annotations": [], "loc": { "start": { "line": 22, @@ -4357,13 +3095,13 @@ "decorators": [], "loc": { "start": { - "line": 22, - "column": 8, + "line": 23, + "column": 10, "program": "enum_export.sts" }, "end": { - "line": 22, - "column": 8, + "line": 23, + "column": 19, "program": "enum_export.sts" } } @@ -4372,101 +3110,30 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "StringValuesArray", + "name": "Green", "decorators": [], "loc": { "start": { - "line": 22, - "column": 8, + "line": 23, + "column": 21, "program": "enum_export.sts" }, "end": { - "line": 22, - "column": 8, + "line": 23, + "column": 26, "program": "enum_export.sts" } } }, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "0", - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - { - "type": "StringLiteral", - "value": "42", - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - { - "type": "StringLiteral", - "value": "43", - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - } - ], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "accessibility": "protected", - "static": true, - "readonly": true, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { "type": "ETSTypeReference", "part": { "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "Color", "decorators": [], "loc": { "start": { @@ -4507,12 +3174,82 @@ } } }, - "annotations": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" + "arguments": [ + { + "type": "NumberLiteral", + "value": 2, + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + } + ], + "loc": { + "start": { + "line": 23, + "column": 26, + "program": "enum_export.sts" + }, + "end": { + "line": 23, + "column": 26, + "program": "enum_export.sts" + } + } + }, + "accessibility": "public", + "static": true, + "readonly": true, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" }, "end": { "line": 22, @@ -4525,13 +3262,13 @@ "decorators": [], "loc": { "start": { - "line": 22, - "column": 8, + "line": 23, + "column": 21, "program": "enum_export.sts" }, "end": { - "line": 22, - "column": 8, + "line": 23, + "column": 26, "program": "enum_export.sts" } } @@ -4540,7 +3277,7 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "ItemsArray", + "name": "#NamesArray", "decorators": [], "loc": { "start": { @@ -4559,43 +3296,8 @@ "type": "ArrayExpression", "elements": [ { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 13, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 18, - "program": "enum_export.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "Red", - "decorators": [], - "loc": { - "start": { - "line": 23, - "column": 5, - "program": "enum_export.sts" - }, - "end": { - "line": 23, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "computed": false, - "optional": false, + "type": "StringLiteral", + "value": "Red", "loc": { "start": { "line": 22, @@ -4610,43 +3312,8 @@ } }, { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 13, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 18, - "program": "enum_export.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "Blue", - "decorators": [], - "loc": { - "start": { - "line": 23, - "column": 10, - "program": "enum_export.sts" - }, - "end": { - "line": 23, - "column": 14, - "program": "enum_export.sts" - } - } - }, - "computed": false, - "optional": false, + "type": "StringLiteral", + "value": "Blue", "loc": { "start": { "line": 22, @@ -4661,43 +3328,8 @@ } }, { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 13, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 18, - "program": "enum_export.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "Green", - "decorators": [], - "loc": { - "start": { - "line": 23, - "column": 21, - "program": "enum_export.sts" - }, - "end": { - "line": 23, - "column": 26, - "program": "enum_export.sts" - } - } - }, - "computed": false, - "optional": false, + "type": "StringLiteral", + "value": "Green", "loc": { "start": { "line": 22, @@ -4725,7 +3357,7 @@ } } }, - "accessibility": "protected", + "accessibility": "private", "static": true, "readonly": true, "declare": false, @@ -4739,7 +3371,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Color", + "name": "String", "decorators": [], "loc": { "start": { @@ -4813,7 +3445,7 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "BoxedItemsArray", + "name": "#ValuesArray", "decorators": [], "loc": { "start": { @@ -4832,137 +3464,24 @@ "type": "ArrayExpression", "elements": [ { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "#Color", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" }, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" } - }, - "arguments": [ - { - "type": "TSAsExpression", - "expression": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 13, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 18, - "program": "enum_export.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "Red", - "decorators": [], - "loc": { - "start": { - "line": 23, - "column": 5, - "program": "enum_export.sts" - }, - "end": { - "line": 23, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - } - ], + } + }, + { + "type": "NumberLiteral", + "value": 42, "loc": { "start": { "line": 22, @@ -4977,137 +3496,8 @@ } }, { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "#Color", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "arguments": [ - { - "type": "TSAsExpression", - "expression": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 13, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 18, - "program": "enum_export.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "Blue", - "decorators": [], - "loc": { - "start": { - "line": 23, - "column": 10, - "program": "enum_export.sts" - }, - "end": { - "line": 23, - "column": 14, - "program": "enum_export.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - } - ], + "type": "NumberLiteral", + "value": 43, "loc": { "start": { "line": 22, @@ -5120,139 +3510,130 @@ "program": "enum_export.sts" } } + } + ], + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" }, - { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "#Color", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "arguments": [ - { - "type": "TSAsExpression", - "expression": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 13, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 18, - "program": "enum_export.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "Green", - "decorators": [], - "loc": { - "start": { - "line": 23, - "column": 21, - "program": "enum_export.sts" - }, - "end": { - "line": 23, - "column": 26, - "program": "enum_export.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "accessibility": "private", + "static": true, + "readonly": true, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "annotations": [], + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "#StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "0", + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" } - ], + } + }, + { + "type": "StringLiteral", + "value": "42", + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + { + "type": "StringLiteral", + "value": "43", "loc": { "start": { "line": 22, @@ -5280,7 +3661,7 @@ } } }, - "accessibility": "protected", + "accessibility": "private", "static": true, "readonly": true, "declare": false, @@ -5294,7 +3675,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "#Color", + "name": "String", "decorators": [], "loc": { "start": { @@ -5365,10 +3746,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "getName", + "name": "#ItemsArray", "decorators": [], "loc": { "start": { @@ -5383,19 +3764,47 @@ } } }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "getName", - "decorators": [], + "type": "ArrayExpression", + "elements": [ + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 13, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 18, + "program": "enum_export.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 5, + "program": "enum_export.sts" + }, + "end": { + "line": 23, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "computed": false, + "optional": false, "loc": { "start": { "line": 22, @@ -5409,111 +3818,138 @@ } } }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 13, + "program": "enum_export.sts" }, - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } + "end": { + "line": 22, + "column": 18, + "program": "enum_export.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "Blue", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 10, + "program": "enum_export.sts" + }, + "end": { + "line": 23, + "column": 14, + "program": "enum_export.sts" } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], "loc": { "start": { "line": 22, - "column": 8, + "column": 13, "program": "enum_export.sts" }, "end": { "line": 22, - "column": 8, + "column": 18, "program": "enum_export.sts" } } - } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } + }, + "property": { + "type": "Identifier", + "name": "Green", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 21, + "program": "enum_export.sts" + }, + "end": { + "line": 23, + "column": 26, + "program": "enum_export.sts" } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + } + ], + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "accessibility": "private", + "static": true, + "readonly": true, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], "loc": { "start": { "line": 22, @@ -5540,76 +3976,212 @@ } } }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "annotations": [], + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getName", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "kind": "method", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getName", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 13, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 18, + "program": "enum_export.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "#NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, "end": { "line": 22, "column": 8, @@ -5617,8 +4189,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "#ordinal", + "decorators": [], "loc": { "start": { "line": 22, @@ -5632,6 +4206,8 @@ } } }, + "computed": false, + "optional": false, "loc": { "start": { "line": 22, @@ -6001,24 +4577,24 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color", + "name": "Color", "decorators": [], "loc": { "start": { "line": 22, - "column": 8, + "column": 13, "program": "enum_export.sts" }, "end": { "line": 22, - "column": 8, + "column": 18, "program": "enum_export.sts" } } }, "property": { "type": "Identifier", - "name": "NamesArray", + "name": "#NamesArray", "decorators": [], "loc": { "start": { @@ -6155,24 +4731,24 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color", + "name": "Color", "decorators": [], "loc": { "start": { "line": 22, - "column": 8, + "column": 13, "program": "enum_export.sts" }, "end": { "line": 22, - "column": 8, + "column": 18, "program": "enum_export.sts" } } }, "property": { "type": "Identifier", - "name": "NamesArray", + "name": "#NamesArray", "decorators": [], "loc": { "start": { @@ -6250,45 +4826,30 @@ "consequent": { "type": "ReturnStatement", "argument": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } + "type": "MemberExpression", + "object": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 13, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 18, + "program": "enum_export.sts" } - }, + } + }, + "property": { + "type": "Identifier", + "name": "#ItemsArray", + "decorators": [], "loc": { "start": { "line": 22, @@ -6302,6 +4863,8 @@ } } }, + "computed": false, + "optional": false, "loc": { "start": { "line": 22, @@ -6315,12 +4878,31 @@ } } }, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, + "property": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, "end": { "line": 22, "column": 8, @@ -6378,7 +4960,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Exception", + "name": "Error", "decorators": [], "loc": { "start": { @@ -6510,7 +5092,6 @@ } } }, - "throwMarker": "throws", "loc": { "start": { "line": 22, @@ -6556,7 +5137,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "valueOf", + "name": "fromValue", "decorators": [], "loc": { "start": { @@ -6582,7 +5163,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "valueOf", + "name": "fromValue", "decorators": [], "loc": { "start": { @@ -6605,41 +5186,9 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "e", + "name": "value", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 22, @@ -6682,7 +5231,39 @@ } ], "returnType": { - "type": "ETSPrimitiveType", + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, "loc": { "start": { "line": 22, @@ -6700,32 +5281,45 @@ "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" + "type": "ForUpdateStatement", + "init": { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } } - } - }, - "property": { - "type": "Identifier", - "name": "ValuesArray", - "decorators": [], + }, + "init": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, "loc": { "start": { "line": 22, @@ -6738,9 +5332,29 @@ "program": "enum_export.sts" } } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" }, - "computed": false, - "optional": false, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { + "type": "Identifier", + "name": "i", + "decorators": [], "loc": { "start": { "line": 22, @@ -6754,12 +5368,46 @@ } } }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "e", - "decorators": [], + "right": { + "type": "MemberExpression", + "object": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 13, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 18, + "program": "enum_export.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "#ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "computed": false, + "optional": false, "loc": { "start": { "line": 22, @@ -6773,8 +5421,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], "loc": { "start": { "line": 22, @@ -6788,6 +5438,8 @@ } } }, + "computed": false, + "optional": false, "loc": { "start": { "line": 22, @@ -6801,8 +5453,6 @@ } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 22, @@ -6816,135 +5466,48 @@ } } }, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" + "update": { + "type": "UpdateExpression", + "operator": "++", + "prefix": true, + "argument": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } } - } - } - ], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "toString", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "toString", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { + }, + "body": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "==", + "left": { "type": "Identifier", - "name": "Color", + "name": "value", "decorators": [], "loc": { "start": { @@ -6959,6 +5522,91 @@ } } }, + "right": { + "type": "MemberExpression", + "object": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 13, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 18, + "program": "enum_export.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "#ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, "loc": { "start": { "line": 22, @@ -6972,173 +5620,80 @@ } } }, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 13, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 18, + "program": "enum_export.sts" + } + } }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "StringValuesArray", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" + "property": { + "type": "Identifier", + "name": "#ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" + "property": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 22, @@ -7165,8 +5720,7 @@ } } }, - "computed": true, - "optional": false, + "alternate": null, "loc": { "start": { "line": 22, @@ -7192,185 +5746,45 @@ "program": "enum_export.sts" } } - } - ], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "values", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "values", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "annotations": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ { - "type": "ReturnStatement", + "type": "ThrowStatement", "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color", - "decorators": [], + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Error", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, "loc": { "start": { "line": 22, @@ -7384,25 +5798,57 @@ } } }, - "property": { - "type": "Identifier", - "name": "ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum Color with value ", + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" + "right": { + "type": "Identifier", + "name": "value", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } } } - }, - "computed": false, - "optional": false, + ], "loc": { "start": { "line": 22, @@ -7488,7 +5934,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "fromInt", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -7505,7 +5951,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -7514,7 +5960,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "fromInt", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -7532,89 +5978,9 @@ "generator": false, "async": false, "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - } - ], + "params": [], "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 22, @@ -7632,83 +5998,31 @@ "type": "BlockStatement", "statements": [ { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "<", - "left": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "right": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { "type": "MemberExpression", "object": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "computed": false, - "optional": false, + "type": "Identifier", + "name": "Color", + "decorators": [], "loc": { "start": { "line": 22, - "column": 8, + "column": 13, "program": "enum_export.sts" }, "end": { "line": 22, - "column": 8, + "column": 18, "program": "enum_export.sts" } } }, "property": { "type": "Identifier", - "name": "length", + "name": "#ValuesArray", "decorators": [], "loc": { "start": { @@ -7738,61 +6052,10 @@ } } }, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "consequent": { - "type": "ReturnStatement", - "argument": { + "property": { "type": "MemberExpression", "object": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "computed": false, - "optional": false, + "type": "ThisExpression", "loc": { "start": { "line": 22, @@ -7808,7 +6071,7 @@ }, "property": { "type": "Identifier", - "name": "ordinal", + "name": "#ordinal", "decorators": [], "loc": { "start": { @@ -7823,7 +6086,7 @@ } } }, - "computed": true, + "computed": false, "optional": false, "loc": { "start": { @@ -7838,6 +6101,8 @@ } } }, + "computed": true, + "optional": false, "loc": { "start": { "line": 22, @@ -7851,7 +6116,6 @@ } } }, - "alternate": null, "loc": { "start": { "line": 22, @@ -7864,141 +6128,13 @@ "program": "enum_export.sts" } } - }, - { - "type": "ThrowStatement", - "argument": { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Exception", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "arguments": [ - { - "type": "BinaryExpression", - "operator": "+", - "left": { - "type": "StringLiteral", - "value": "No enum constant in Color with ordinal value ", - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "right": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - } - ], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - } - ], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" + } + ], + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" }, "end": { "line": 22, @@ -8007,7 +6143,6 @@ } } }, - "throwMarker": "throws", "loc": { "start": { "line": 22, @@ -8053,7 +6188,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "unbox", + "name": "toString", "decorators": [], "loc": { "start": { @@ -8079,7 +6214,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "unbox", + "name": "toString", "decorators": [], "loc": { "start": { @@ -8104,7 +6239,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Color", + "name": "String", "decorators": [], "loc": { "start": { @@ -8156,24 +6291,24 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color", + "name": "Color", "decorators": [], "loc": { "start": { "line": 22, - "column": 8, + "column": 13, "program": "enum_export.sts" }, "end": { "line": 22, - "column": 8, + "column": 18, "program": "enum_export.sts" } } }, "property": { "type": "Identifier", - "name": "ItemsArray", + "name": "#StringValuesArray", "decorators": [], "loc": { "start": { @@ -8222,7 +6357,7 @@ }, "property": { "type": "Identifier", - "name": "ordinal", + "name": "#ordinal", "decorators": [], "loc": { "start": { @@ -8339,7 +6474,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "boxedfromInt", + "name": "values", "decorators": [], "loc": { "start": { @@ -8365,7 +6500,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "boxedfromInt", + "name": "values", "decorators": [], "loc": { "start": { @@ -8383,14 +6518,17 @@ "generator": false, "async": false, "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSPrimitiveType", + "params": [], + "returnType": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], "loc": { "start": { "line": 22, @@ -8404,42 +6542,6 @@ } } }, - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "#Color", - "decorators": [], "loc": { "start": { "line": 22, @@ -8466,6 +6568,7 @@ } } }, + "annotations": [], "loc": { "start": { "line": 22, @@ -8483,99 +6586,30 @@ "type": "BlockStatement", "statements": [ { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "<", - "left": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { "type": "Identifier", - "name": "ordinal", + "name": "Color", "decorators": [], "loc": { "start": { "line": 22, - "column": 8, + "column": 13, "program": "enum_export.sts" }, "end": { "line": 22, - "column": 8, + "column": 18, "program": "enum_export.sts" } } }, - "right": { - "type": "MemberExpression", - "object": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "BoxedItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "length", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "computed": false, - "optional": false, + "property": { + "type": "Identifier", + "name": "#ItemsArray", + "decorators": [], "loc": { "start": { "line": 22, @@ -8589,6 +6623,8 @@ } } }, + "computed": false, + "optional": false, "loc": { "start": { "line": 22, @@ -8602,107 +6638,6 @@ } } }, - "consequent": { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "BoxedItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "alternate": null, "loc": { "start": { "line": 22, @@ -8715,45 +6650,135 @@ "program": "enum_export.sts" } } + } + ], + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getOrdinal", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "kind": "method", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getOrdinal", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ { - "type": "ThrowStatement", + "type": "ReturnStatement", "argument": { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Exception", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, + "type": "MemberExpression", + "object": { + "type": "ThisExpression", "loc": { "start": { "line": 22, @@ -8767,57 +6792,25 @@ } } }, - "arguments": [ - { - "type": "BinaryExpression", - "operator": "+", - "left": { - "type": "StringLiteral", - "value": "No enum constant in Color with ordinal value ", - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "right": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } + "property": { + "type": "Identifier", + "name": "#ordinal", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" }, - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" } } - ], + }, + "computed": false, + "optional": false, "loc": { "start": { "line": 22, @@ -8858,7 +6851,6 @@ } } }, - "throwMarker": "throws", "loc": { "start": { "line": 22, @@ -8899,126 +6891,21 @@ "program": "enum_export.sts" } } - } - ], - "loc": { - "start": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 22, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1, - "program": null - }, - "end": { - "line": 1, - "column": 1, - "program": null - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "#Commands", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "accessibility": "protected", - "static": false, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "definite": false, - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } }, { "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "", + "name": "$_get", "decorators": [], "loc": { "start": { - "line": 26, + "line": 22, "column": 8, "program": "enum_export.sts" }, "end": { - "line": 26, + "line": 22, "column": 8, "program": "enum_export.sts" } @@ -9035,122 +6922,16 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "body": { - "type": "BlockStatement", - "statements": [], - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "constructor", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "kind": "constructor", - "accessibility": "public", - "static": false, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "constructor", + "name": "$_get", "decorators": [], "loc": { "start": { - "line": 26, + "line": 22, "column": 8, "program": "enum_export.sts" }, "end": { - "line": 26, + "line": 22, "column": 8, "program": "enum_export.sts" } @@ -9164,17 +6945,49 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "ordinal", + "name": "e", "typeAnnotation": { - "type": "ETSPrimitiveType", + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, "loc": { "start": { - "line": 26, + "line": 22, "column": 8, "program": "enum_export.sts" }, "end": { - "line": 26, + "line": 22, "column": 8, "program": "enum_export.sts" } @@ -9183,12 +6996,12 @@ "decorators": [], "loc": { "start": { - "line": 26, + "line": 22, "column": 8, "program": "enum_export.sts" }, "end": { - "line": 26, + "line": 22, "column": 8, "program": "enum_export.sts" } @@ -9196,38 +7009,86 @@ }, "loc": { "start": { - "line": 26, + "line": 22, "column": 8, "program": "enum_export.sts" }, "end": { - "line": 26, + "line": 22, "column": 8, "program": "enum_export.sts" } } } ], - "body": { - "type": "BlockStatement", - "statements": [ + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { + "type": "ReturnStatement", + "argument": { + "type": "CallExpression", + "callee": { "type": "MemberExpression", "object": { - "type": "ThisExpression", + "type": "Identifier", + "name": "e", + "decorators": [], "loc": { "start": { - "line": 26, + "line": 22, "column": 8, "program": "enum_export.sts" }, "end": { - "line": 26, + "line": 22, "column": 8, "program": "enum_export.sts" } @@ -9235,16 +7096,16 @@ }, "property": { "type": "Identifier", - "name": "ordinal", + "name": "getName", "decorators": [], "loc": { "start": { - "line": 26, + "line": 22, "column": 8, "program": "enum_export.sts" }, "end": { - "line": 26, + "line": 22, "column": 8, "program": "enum_export.sts" } @@ -9254,42 +7115,27 @@ "optional": false, "loc": { "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "right": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 26, + "line": 22, "column": 8, "program": "enum_export.sts" }, "end": { - "line": 26, + "line": 22, "column": 8, "program": "enum_export.sts" } } }, + "arguments": [], + "optional": false, "loc": { "start": { - "line": 26, + "line": 22, "column": 8, "program": "enum_export.sts" }, "end": { - "line": 26, + "line": 22, "column": 8, "program": "enum_export.sts" } @@ -9297,12 +7143,12 @@ }, "loc": { "start": { - "line": 26, + "line": 22, "column": 8, "program": "enum_export.sts" }, "end": { - "line": 26, + "line": 22, "column": 8, "program": "enum_export.sts" } @@ -9311,12 +7157,12 @@ ], "loc": { "start": { - "line": 26, + "line": 22, "column": 8, "program": "enum_export.sts" }, "end": { - "line": 26, + "line": 22, "column": 8, "program": "enum_export.sts" } @@ -9324,17 +7170,101 @@ }, "loc": { "start": { - "line": 26, + "line": 22, "column": 8, "program": "enum_export.sts" }, "end": { - "line": 26, + "line": 22, "column": 8, "program": "enum_export.sts" } } }, + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + } + ], + "loc": { + "start": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 22, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1, + "program": null + }, + "end": { + "line": 1, + "column": 1, + "program": null + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "Commands", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 13, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 21, + "program": "enum_export.sts" + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "#ordinal", + "decorators": [], "loc": { "start": { "line": 26, @@ -9348,7 +7278,28 @@ } } }, - "overloads": [], + "accessibility": "private", + "static": false, + "readonly": true, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "definite": false, "decorators": [], "loc": { "start": { @@ -9364,10 +7315,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "NamesArray", + "name": "", "decorators": [], "loc": { "start": { @@ -9382,12 +7333,19 @@ } } }, + "kind": "method", + "accessibility": "private", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "Open", + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], "loc": { "start": { "line": 26, @@ -9401,9 +7359,13 @@ } } }, - { - "type": "StringLiteral", - "value": "Close", + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], "loc": { "start": { "line": 26, @@ -9416,8 +7378,20 @@ "program": "enum_export.sts" } } + }, + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } } - ], + }, "loc": { "start": { "line": 26, @@ -9431,22 +7405,104 @@ } } }, - "accessibility": "protected", - "static": true, - "readonly": true, - "declare": false, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "kind": "constructor", + "accessibility": "public", + "static": false, "optional": false, "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, "loc": { "start": { "line": 26, @@ -9459,7 +7515,109 @@ "program": "enum_export.sts" } } - }, + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "#ordinal", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + } + ], "loc": { "start": { "line": 26, @@ -9486,7 +7644,6 @@ } } }, - "annotations": [], "loc": { "start": { "line": 26, @@ -9500,7 +7657,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -9519,27 +7676,44 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "StringValuesArray", + "name": "Open", "decorators": [], "loc": { "start": { - "line": 26, - "column": 8, + "line": 27, + "column": 5, "program": "enum_export.sts" }, "end": { - "line": 26, - "column": 8, + "line": 27, + "column": 9, "program": "enum_export.sts" } } }, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "fopen", + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Commands", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, "loc": { "start": { "line": 26, @@ -9553,9 +7727,23 @@ } } }, + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "arguments": [ { - "type": "StringLiteral", - "value": "fclose", + "type": "NumberLiteral", + "value": 0, "loc": { "start": { "line": 26, @@ -9572,32 +7760,113 @@ ], "loc": { "start": { - "line": 26, - "column": 8, + "line": 27, + "column": 12, "program": "enum_export.sts" }, "end": { - "line": 26, - "column": 8, + "line": 27, + "column": 19, "program": "enum_export.sts" } } }, - "accessibility": "protected", + "accessibility": "public", "static": true, "readonly": true, "declare": false, "optional": false, "computed": false, "typeAnnotation": { - "type": "TSArrayType", - "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Commands", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 27, + "column": 5, + "program": "enum_export.sts" + }, + "end": { + "line": 27, + "column": 19, + "program": "enum_export.sts" + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "Close", + "decorators": [], + "loc": { + "start": { + "line": 28, + "column": 5, + "program": "enum_export.sts" + }, + "end": { + "line": 28, + "column": 10, + "program": "enum_export.sts" + } + } + }, + "value": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { "type": "ETSTypeReference", "part": { "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "Commands", "decorators": [], "loc": { "start": { @@ -9638,7 +7907,77 @@ } } }, - "annotations": [], + "arguments": [ + { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + } + ], + "loc": { + "start": { + "line": 28, + "column": 13, + "program": "enum_export.sts" + }, + "end": { + "line": 28, + "column": 21, + "program": "enum_export.sts" + } + } + }, + "accessibility": "public", + "static": true, + "readonly": true, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Commands", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, "loc": { "start": { "line": 26, @@ -9656,13 +7995,13 @@ "decorators": [], "loc": { "start": { - "line": 26, - "column": 8, + "line": 28, + "column": 5, "program": "enum_export.sts" }, "end": { - "line": 26, - "column": 8, + "line": 28, + "column": 21, "program": "enum_export.sts" } } @@ -9671,7 +8010,7 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "ItemsArray", + "name": "#NamesArray", "decorators": [], "loc": { "start": { @@ -9690,43 +8029,8 @@ "type": "ArrayExpression", "elements": [ { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Commands", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 13, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 21, - "program": "enum_export.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "Open", - "decorators": [], - "loc": { - "start": { - "line": 27, - "column": 5, - "program": "enum_export.sts" - }, - "end": { - "line": 27, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "computed": false, - "optional": false, + "type": "StringLiteral", + "value": "Open", "loc": { "start": { "line": 26, @@ -9741,43 +8045,8 @@ } }, { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Commands", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 13, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 21, - "program": "enum_export.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "Close", - "decorators": [], - "loc": { - "start": { - "line": 28, - "column": 5, - "program": "enum_export.sts" - }, - "end": { - "line": 28, - "column": 10, - "program": "enum_export.sts" - } - } - }, - "computed": false, - "optional": false, + "type": "StringLiteral", + "value": "Close", "loc": { "start": { "line": 26, @@ -9805,7 +8074,7 @@ } } }, - "accessibility": "protected", + "accessibility": "private", "static": true, "readonly": true, "declare": false, @@ -9819,7 +8088,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Commands", + "name": "String", "decorators": [], "loc": { "start": { @@ -9893,7 +8162,7 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "BoxedItemsArray", + "name": "#StringValuesArray", "decorators": [], "loc": { "start": { @@ -9912,137 +8181,8 @@ "type": "ArrayExpression", "elements": [ { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "#Commands", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "arguments": [ - { - "type": "TSAsExpression", - "expression": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Commands", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 13, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 21, - "program": "enum_export.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "Open", - "decorators": [], - "loc": { - "start": { - "line": 27, - "column": 5, - "program": "enum_export.sts" - }, - "end": { - "line": 27, - "column": 9, - "program": "enum_export.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - } - ], + "type": "StringLiteral", + "value": "fopen", "loc": { "start": { "line": 26, @@ -10057,137 +8197,8 @@ } }, { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "#Commands", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "arguments": [ - { - "type": "TSAsExpression", - "expression": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Commands", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 13, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 21, - "program": "enum_export.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "Close", - "decorators": [], - "loc": { - "start": { - "line": 28, - "column": 5, - "program": "enum_export.sts" - }, - "end": { - "line": 28, - "column": 10, - "program": "enum_export.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - } - ], + "type": "StringLiteral", + "value": "fclose", "loc": { "start": { "line": 26, @@ -10215,7 +8226,7 @@ } } }, - "accessibility": "protected", + "accessibility": "private", "static": true, "readonly": true, "declare": false, @@ -10229,7 +8240,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "#Commands", + "name": "String", "decorators": [], "loc": { "start": { @@ -10300,10 +8311,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "getName", + "name": "#ItemsArray", "decorators": [], "loc": { "start": { @@ -10318,137 +8329,141 @@ } } }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "getName", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, + "type": "ArrayExpression", + "elements": [ + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Commands", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 13, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 21, + "program": "enum_export.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "Open", + "decorators": [], + "loc": { + "start": { + "line": 27, + "column": 5, + "program": "enum_export.sts" + }, + "end": { + "line": 27, + "column": 9, + "program": "enum_export.sts" + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, "column": 8, "program": "enum_export.sts" } } }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Commands", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Commands", + "decorators": [], "loc": { "start": { "line": 26, - "column": 8, + "column": 13, "program": "enum_export.sts" }, "end": { "line": 26, - "column": 8, + "column": 21, "program": "enum_export.sts" } } - } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } + }, + "property": { + "type": "Identifier", + "name": "Close", + "decorators": [], + "loc": { + "start": { + "line": 28, + "column": 5, + "program": "enum_export.sts" + }, + "end": { + "line": 28, + "column": 10, + "program": "enum_export.sts" } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + } + ], + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "accessibility": "private", + "static": true, + "readonly": true, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Commands", + "decorators": [], "loc": { "start": { "line": 26, @@ -10475,55 +8490,193 @@ } } }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Commands", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 26, - "column": 8, + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "annotations": [], + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getName", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "kind": "method", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getName", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Commands", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 13, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 21, + "program": "enum_export.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "#NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 26, + "column": 8, "program": "enum_export.sts" }, "end": { @@ -10534,11 +8687,9 @@ } }, "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "ThisExpression", "loc": { "start": { "line": 26, @@ -10552,8 +8703,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "#ordinal", + "decorators": [], "loc": { "start": { "line": 26, @@ -10567,6 +8720,8 @@ } } }, + "computed": false, + "optional": false, "loc": { "start": { "line": 26, @@ -10936,24 +9091,24 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Commands", + "name": "Commands", "decorators": [], "loc": { "start": { "line": 26, - "column": 8, + "column": 13, "program": "enum_export.sts" }, "end": { "line": 26, - "column": 8, + "column": 21, "program": "enum_export.sts" } } }, "property": { "type": "Identifier", - "name": "NamesArray", + "name": "#NamesArray", "decorators": [], "loc": { "start": { @@ -11090,24 +9245,24 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Commands", + "name": "Commands", "decorators": [], "loc": { "start": { "line": 26, - "column": 8, + "column": 13, "program": "enum_export.sts" }, "end": { "line": 26, - "column": 8, + "column": 21, "program": "enum_export.sts" } } }, "property": { "type": "Identifier", - "name": "NamesArray", + "name": "#NamesArray", "decorators": [], "loc": { "start": { @@ -11185,45 +9340,30 @@ "consequent": { "type": "ReturnStatement", "argument": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Commands", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } + "type": "MemberExpression", + "object": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Commands", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 13, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 21, + "program": "enum_export.sts" } - }, + } + }, + "property": { + "type": "Identifier", + "name": "#ItemsArray", + "decorators": [], "loc": { "start": { "line": 26, @@ -11237,6 +9377,25 @@ } } }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "i", + "decorators": [], "loc": { "start": { "line": 26, @@ -11250,6 +9409,8 @@ } } }, + "computed": true, + "optional": false, "loc": { "start": { "line": 26, @@ -11313,7 +9474,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Exception", + "name": "Error", "decorators": [], "loc": { "start": { @@ -11445,7 +9606,6 @@ } } }, - "throwMarker": "throws", "loc": { "start": { "line": 26, @@ -11491,7 +9651,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "toString", + "name": "fromValue", "decorators": [], "loc": { "start": { @@ -11517,7 +9677,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "toString", + "name": "fromValue", "decorators": [], "loc": { "start": { @@ -11540,14 +9700,14 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "ordinal", + "name": "value", "typeAnnotation": { "type": "ETSTypeReference", "part": { "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Commands", + "name": "String", "decorators": [], "loc": { "start": { @@ -11622,7 +9782,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "Commands", "decorators": [], "loc": { "start": { @@ -11667,15 +9827,133 @@ "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { + "type": "ForUpdateStatement", + "init": { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "init": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "right": { "type": "MemberExpression", "object": { - "type": "Identifier", - "name": "#Commands", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Commands", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 13, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 21, + "program": "enum_export.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "#StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "computed": false, + "optional": false, "loc": { "start": { "line": 26, @@ -11691,7 +9969,7 @@ }, "property": { "type": "Identifier", - "name": "StringValuesArray", + "name": "length", "decorators": [], "loc": { "start": { @@ -11721,11 +9999,61 @@ } } }, - "property": { - "type": "TSAsExpression", - "expression": { + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "update": { + "type": "UpdateExpression", + "operator": "++", + "prefix": true, + "argument": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "body": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "==", + "left": { "type": "Identifier", - "name": "ordinal", + "name": "value", "decorators": [], "loc": { "start": { @@ -11740,8 +10068,78 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "right": { + "type": "MemberExpression", + "object": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Commands", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 13, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 21, + "program": "enum_export.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "#StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 26, @@ -11768,8 +10166,235 @@ } } }, - "computed": true, - "optional": false, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Commands", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 13, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 21, + "program": "enum_export.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "#ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "alternate": null, + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Error", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum Commands with value ", + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "right": { + "type": "Identifier", + "name": "value", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + } + ], "loc": { "start": { "line": 26, @@ -11855,7 +10480,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "values", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -11872,7 +10497,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -11881,7 +10506,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "values", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -11901,32 +10526,17 @@ "expression": false, "params": [], "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Commands", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 8, + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 8, "program": "enum_export.sts" }, "end": { @@ -11949,7 +10559,6 @@ } } }, - "annotations": [], "loc": { "start": { "line": 26, @@ -11971,9 +10580,43 @@ "argument": { "type": "MemberExpression", "object": { - "type": "Identifier", - "name": "#Commands", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Commands", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 13, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 21, + "program": "enum_export.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "#StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "computed": false, + "optional": false, "loc": { "start": { "line": 26, @@ -11988,9 +10631,41 @@ } }, "property": { - "type": "Identifier", - "name": "ItemsArray", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "#ordinal", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "computed": false, + "optional": false, "loc": { "start": { "line": 26, @@ -12004,7 +10679,7 @@ } } }, - "computed": false, + "computed": true, "optional": false, "loc": { "start": { @@ -12091,7 +10766,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "fromInt", + "name": "toString", "decorators": [], "loc": { "start": { @@ -12108,7 +10783,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -12117,7 +10792,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "fromInt", + "name": "toString", "decorators": [], "loc": { "start": { @@ -12135,62 +10810,14 @@ "generator": false, "async": false, "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - } - ], + "params": [], "returnType": { "type": "ETSTypeReference", "part": { "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Commands", + "name": "String", "decorators": [], "loc": { "start": { @@ -12235,14 +10862,47 @@ "type": "BlockStatement", "statements": [ { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "<", - "left": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Commands", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 13, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 21, + "program": "enum_export.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "#StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "computed": false, + "optional": false, "loc": { "start": { "line": 26, @@ -12256,46 +10916,10 @@ } } }, - "right": { + "property": { "type": "MemberExpression", "object": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Commands", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "computed": false, - "optional": false, + "type": "ThisExpression", "loc": { "start": { "line": 26, @@ -12311,7 +10935,7 @@ }, "property": { "type": "Identifier", - "name": "length", + "name": "#ordinal", "decorators": [], "loc": { "start": { @@ -12341,235 +10965,8 @@ } } }, - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "consequent": { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Commands", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "alternate": null, - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - { - "type": "ThrowStatement", - "argument": { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Exception", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "arguments": [ - { - "type": "BinaryExpression", - "operator": "+", - "left": { - "type": "StringLiteral", - "value": "No enum constant in Commands with ordinal value ", - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "right": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - } - ], + "computed": true, + "optional": false, "loc": { "start": { "line": 26, @@ -12610,7 +11007,6 @@ } } }, - "throwMarker": "throws", "loc": { "start": { "line": 26, @@ -12656,7 +11052,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "unbox", + "name": "values", "decorators": [], "loc": { "start": { @@ -12673,7 +11069,7 @@ }, "kind": "method", "accessibility": "public", - "static": false, + "static": true, "optional": false, "computed": false, "value": { @@ -12682,7 +11078,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "unbox", + "name": "values", "decorators": [], "loc": { "start": { @@ -12702,13 +11098,28 @@ "expression": false, "params": [], "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Commands", - "decorators": [], + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Commands", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, "loc": { "start": { "line": 26, @@ -12735,6 +11146,7 @@ } } }, + "annotations": [], "loc": { "start": { "line": 26, @@ -12756,92 +11168,26 @@ "argument": { "type": "MemberExpression", "object": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Commands", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" + "type": "Identifier", + "name": "Commands", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 13, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 21, + "program": "enum_export.sts" } } }, "property": { - "type": "MemberExpression", - "object": { - "type": "ThisExpression", - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "computed": false, - "optional": false, + "type": "Identifier", + "name": "#ItemsArray", + "decorators": [], "loc": { "start": { "line": 26, @@ -12855,7 +11201,7 @@ } } }, - "computed": true, + "computed": false, "optional": false, "loc": { "start": { @@ -12942,7 +11288,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "boxedfromInt", + "name": "getOrdinal", "decorators": [], "loc": { "start": { @@ -12959,7 +11305,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -12968,7 +11314,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "boxedfromInt", + "name": "getOrdinal", "decorators": [], "loc": { "start": { @@ -12986,89 +11332,9 @@ "generator": false, "async": false, "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - } - ], + "params": [], "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "#Commands", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 26, @@ -13086,14 +11352,11 @@ "type": "BlockStatement", "statements": [ { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "<", - "left": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", "loc": { "start": { "line": 26, @@ -13107,78 +11370,10 @@ } } }, - "right": { - "type": "MemberExpression", - "object": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Commands", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "BoxedItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "length", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "computed": false, - "optional": false, + "property": { + "type": "Identifier", + "name": "#ordinal", + "decorators": [], "loc": { "start": { "line": 26, @@ -13192,6 +11387,8 @@ } } }, + "computed": false, + "optional": false, "loc": { "start": { "line": 26, @@ -13205,64 +11402,135 @@ } } }, - "consequent": { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Commands", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "BoxedItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "property": { + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + } + ], + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "$_get", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "$_get", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "e", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { "type": "Identifier", - "name": "ordinal", + "name": "Commands", "decorators": [], "loc": { "start": { @@ -13277,8 +11545,6 @@ } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 26, @@ -13305,7 +11571,42 @@ } } }, - "alternate": null, + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], "loc": { "start": { "line": 26, @@ -13319,172 +11620,710 @@ } } }, - { - "type": "ThrowStatement", - "argument": { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Exception", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "arguments": [ - { - "type": "BinaryExpression", - "operator": "+", - "left": { - "type": "StringLiteral", - "value": "No enum constant in Commands with ordinal value ", - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "right": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - } - ], - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - }, - "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" - } - } + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "e", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "getName", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "arguments": [], + "optional": false, + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + } + ], + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + } + ], + "loc": { + "start": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 26, + "column": 8, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1, + "program": null + }, + "end": { + "line": 1, + "column": 1, + "program": null + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "C", + "decorators": [], + "loc": { + "start": { + "line": 31, + "column": 14, + "program": "enum_export.sts" + }, + "end": { + "line": 31, + "column": 15, + "program": "enum_export.sts" + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "a", + "decorators": [], + "loc": { + "start": { + "line": 32, + "column": 3, + "program": "enum_export.sts" + }, + "end": { + "line": 32, + "column": 4, + "program": "enum_export.sts" + } + } + }, + "value": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "AmbientColor", + "decorators": [], + "loc": { + "start": { + "line": 32, + "column": 22, + "program": "enum_export.sts" + }, + "end": { + "line": 32, + "column": 34, + "program": "enum_export.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "Yellow", + "decorators": [], + "loc": { + "start": { + "line": 32, + "column": 35, + "program": "enum_export.sts" + }, + "end": { + "line": 32, + "column": 41, + "program": "enum_export.sts" + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 32, + "column": 22, + "program": "enum_export.sts" + }, + "end": { + "line": 32, + "column": 41, + "program": "enum_export.sts" + } + } + }, + "accessibility": "public", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "AmbientColor", + "decorators": [], + "loc": { + "start": { + "line": 32, + "column": 7, + "program": "enum_export.sts" + }, + "end": { + "line": 32, + "column": 19, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 32, + "column": 7, + "program": "enum_export.sts" + }, + "end": { + "line": 32, + "column": 21, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 32, + "column": 7, + "program": "enum_export.sts" + }, + "end": { + "line": 32, + "column": 21, + "program": "enum_export.sts" + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 32, + "column": 3, + "program": "enum_export.sts" + }, + "end": { + "line": 32, + "column": 41, + "program": "enum_export.sts" + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 31, + "column": 17, + "program": "enum_export.sts" + }, + "end": { + "line": 31, + "column": 17, + "program": "enum_export.sts" + } + } + }, + "kind": "constructor", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 31, + "column": 17, + "program": "enum_export.sts" + }, + "end": { + "line": 31, + "column": 17, + "program": "enum_export.sts" + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 31, + "column": 17, + "program": "enum_export.sts" + }, + "end": { + "line": 31, + "column": 17, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 31, + "column": 17, + "program": "enum_export.sts" + }, + "end": { + "line": 31, + "column": 17, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 31, + "column": 17, + "program": "enum_export.sts" + }, + "end": { + "line": 31, + "column": 17, + "program": "enum_export.sts" + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1, + "program": null + }, + "end": { + "line": 1, + "column": 1, + "program": null + } + } + } + ], + "loc": { + "start": { + "line": 31, + "column": 16, + "program": "enum_export.sts" + }, + "end": { + "line": 33, + "column": 3, + "program": "enum_export.sts" + } + } + }, + "loc": { + "start": { + "line": 31, + "column": 8, + "program": "enum_export.sts" + }, + "end": { + "line": 33, + "column": 3, + "program": "enum_export.sts" + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ETSGLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1, + "program": "enum_export.sts" + }, + "end": { + "line": 1, + "column": 1, + "program": "enum_export.sts" + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "main", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1, + "program": null + }, + "end": { + "line": 1, + "column": 1, + "program": null + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "main", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1, + "program": null + }, + "end": { + "line": 1, + "column": 1, + "program": null + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1, + "program": null + }, + "end": { + "line": 1, + "column": 1, + "program": null + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1, + "program": null + }, + "end": { + "line": 1, + "column": 1, + "program": null + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1, + "program": null + }, + "end": { + "line": 1, + "column": 1, + "program": null + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1, + "program": "enum_export.sts" + }, + "end": { + "line": 1, + "column": 1, + "program": "enum_export.sts" + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1, + "program": null + }, + "end": { + "line": 1, + "column": 1, + "program": null + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1, + "program": null + }, + "end": { + "line": 1, + "column": 1, + "program": null } - ], + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], "loc": { "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" + "line": 1, + "column": 1, + "program": null }, "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" + "line": 1, + "column": 1, + "program": null } } }, - "throwMarker": "throws", "loc": { "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" + "line": 1, + "column": 1, + "program": null }, "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" + "line": 1, + "column": 1, + "program": null } } }, "loc": { "start": { - "line": 26, - "column": 8, - "program": "enum_export.sts" + "line": 1, + "column": 1, + "program": null }, "end": { - "line": 26, - "column": 8, - "program": "enum_export.sts" + "line": 1, + "column": 1, + "program": null } } }, @@ -13492,13 +12331,13 @@ "decorators": [], "loc": { "start": { - "line": 26, - "column": 8, + "line": 1, + "column": 1, "program": "enum_export.sts" }, "end": { - "line": 26, - "column": 8, + "line": 1, + "column": 1, "program": "enum_export.sts" } } @@ -13506,13 +12345,13 @@ ], "loc": { "start": { - "line": 26, - "column": 8, + "line": 1, + "column": 1, "program": "enum_export.sts" }, "end": { - "line": 26, - "column": 8, + "line": 1, + "column": 1, "program": "enum_export.sts" } } @@ -13521,12 +12360,12 @@ "start": { "line": 1, "column": 1, - "program": null + "program": "enum_export.sts" }, "end": { "line": 1, "column": 1, - "program": null + "program": "enum_export.sts" } } } diff --git a/ets2panda/test/parser/ets/declare_enum-expected.txt b/ets2panda/test/parser/ets/declare_enum-expected.txt index 1a2dce53cf..2264f687bf 100644 --- a/ets2panda/test/parser/ets/declare_enum-expected.txt +++ b/ets2panda/test/parser/ets/declare_enum-expected.txt @@ -1,203 +1,22 @@ { "type": "Program", "statements": [ - { - "type": "TSEnumDeclaration", - "id": { - "type": "Identifier", - "name": "Enum", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 14, - "program": "declare_enum.sts" - }, - "end": { - "line": 16, - "column": 18, - "program": "declare_enum.sts" - } - } - }, - "members": [ - { - "type": "TSEnumMember", - "id": { - "type": "Identifier", - "name": "AAA", - "decorators": [], - "loc": { - "start": { - "line": 17, - "column": 5, - "program": "declare_enum.sts" - }, - "end": { - "line": 17, - "column": 8, - "program": "declare_enum.sts" - } - } - }, - "initializer": { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 17, - "column": 8, - "program": "declare_enum.sts" - }, - "end": { - "line": 17, - "column": 8, - "program": "declare_enum.sts" - } - } - }, - "loc": { - "start": { - "line": 17, - "column": 5, - "program": "declare_enum.sts" - }, - "end": { - "line": 17, - "column": 8, - "program": "declare_enum.sts" - } - } - }, - { - "type": "TSEnumMember", - "id": { - "type": "Identifier", - "name": "BBB", - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 5, - "program": "declare_enum.sts" - }, - "end": { - "line": 18, - "column": 8, - "program": "declare_enum.sts" - } - } - }, - "initializer": { - "type": "NumberLiteral", - "value": 1, - "loc": { - "start": { - "line": 18, - "column": 8, - "program": "declare_enum.sts" - }, - "end": { - "line": 18, - "column": 8, - "program": "declare_enum.sts" - } - } - }, - "loc": { - "start": { - "line": 18, - "column": 5, - "program": "declare_enum.sts" - }, - "end": { - "line": 18, - "column": 8, - "program": "declare_enum.sts" - } - } - } - ], - "const": false, - "declare": true, - "loc": { - "start": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - }, - "end": { - "line": 19, - "column": 2, - "program": "declare_enum.sts" - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "ETSGLOBAL", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "declare_enum.sts" - }, - "end": { - "line": 1, - "column": 1, - "program": "declare_enum.sts" - } - } - }, - "superClass": null, - "implements": [], - "body": [], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "declare_enum.sts" - }, - "end": { - "line": 1, - "column": 1, - "program": "declare_enum.sts" - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "declare_enum.sts" - }, - "end": { - "line": 1, - "column": 1, - "program": "declare_enum.sts" - } - } - }, { "type": "ClassDeclaration", "definition": { "id": { "type": "Identifier", - "name": "#Enum", + "name": "Enum", "decorators": [], "loc": { "start": { "line": 16, - "column": 9, + "column": 14, "program": "declare_enum.sts" }, "end": { "line": 16, - "column": 9, + "column": 18, "program": "declare_enum.sts" } } @@ -209,7 +28,7 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "ordinal", + "name": "#ordinal", "decorators": [], "loc": { "start": { @@ -224,9 +43,9 @@ } } }, - "accessibility": "protected", + "accessibility": "private", "static": false, - "readonly": false, + "readonly": true, "declare": false, "optional": false, "computed": false, @@ -384,7 +203,7 @@ }, "property": { "type": "Identifier", - "name": "ordinal", + "name": "#ordinal", "decorators": [], "loc": { "start": { @@ -516,27 +335,44 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "NamesArray", + "name": "AAA", "decorators": [], "loc": { "start": { - "line": 16, - "column": 9, + "line": 17, + "column": 5, "program": "declare_enum.sts" }, "end": { - "line": 16, - "column": 9, + "line": 17, + "column": 8, "program": "declare_enum.sts" } } }, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "AAA", + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 9, + "program": "declare_enum.sts" + }, + "end": { + "line": 16, + "column": 9, + "program": "declare_enum.sts" + } + } + }, "loc": { "start": { "line": 16, @@ -550,9 +386,23 @@ } } }, + "loc": { + "start": { + "line": 16, + "column": 9, + "program": "declare_enum.sts" + }, + "end": { + "line": 16, + "column": 9, + "program": "declare_enum.sts" + } + } + }, + "arguments": [ { - "type": "StringLiteral", - "value": "BBB", + "type": "NumberLiteral", + "value": 0, "loc": { "start": { "line": 16, @@ -569,46 +419,31 @@ ], "loc": { "start": { - "line": 16, - "column": 9, + "line": 17, + "column": 8, "program": "declare_enum.sts" }, "end": { - "line": 16, - "column": 9, + "line": 17, + "column": 8, "program": "declare_enum.sts" } } }, - "accessibility": "protected", + "accessibility": "public", "static": true, "readonly": true, "declare": false, "optional": false, "computed": false, "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - }, - "end": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - } - } - }, + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Enum", + "decorators": [], "loc": { "start": { "line": 16, @@ -635,7 +470,6 @@ } } }, - "annotations": [], "loc": { "start": { "line": 16, @@ -653,13 +487,13 @@ "decorators": [], "loc": { "start": { - "line": 16, - "column": 9, + "line": 17, + "column": 5, "program": "declare_enum.sts" }, "end": { - "line": 16, - "column": 9, + "line": 17, + "column": 8, "program": "declare_enum.sts" } } @@ -668,27 +502,44 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "ValuesArray", + "name": "BBB", "decorators": [], "loc": { "start": { - "line": 16, - "column": 9, + "line": 18, + "column": 5, "program": "declare_enum.sts" }, "end": { - "line": 16, - "column": 9, + "line": 18, + "column": 8, "program": "declare_enum.sts" } } }, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumberLiteral", - "value": 0, + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 9, + "program": "declare_enum.sts" + }, + "end": { + "line": 16, + "column": 9, + "program": "declare_enum.sts" + } + } + }, "loc": { "start": { "line": 16, @@ -702,6 +553,20 @@ } } }, + "loc": { + "start": { + "line": 16, + "column": 9, + "program": "declare_enum.sts" + }, + "end": { + "line": 16, + "column": 9, + "program": "declare_enum.sts" + } + } + }, + "arguments": [ { "type": "NumberLiteral", "value": 1, @@ -721,27 +586,44 @@ ], "loc": { "start": { - "line": 16, - "column": 9, + "line": 18, + "column": 8, "program": "declare_enum.sts" }, "end": { - "line": 16, - "column": 9, + "line": 18, + "column": 8, "program": "declare_enum.sts" } } }, - "accessibility": "protected", + "accessibility": "public", "static": true, "readonly": true, "declare": false, "optional": false, "computed": false, "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSPrimitiveType", + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 9, + "program": "declare_enum.sts" + }, + "end": { + "line": 16, + "column": 9, + "program": "declare_enum.sts" + } + } + }, "loc": { "start": { "line": 16, @@ -755,7 +637,6 @@ } } }, - "annotations": [], "loc": { "start": { "line": 16, @@ -773,13 +654,13 @@ "decorators": [], "loc": { "start": { - "line": 16, - "column": 9, + "line": 18, + "column": 5, "program": "declare_enum.sts" }, "end": { - "line": 16, - "column": 9, + "line": 18, + "column": 8, "program": "declare_enum.sts" } } @@ -788,7 +669,7 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "StringValuesArray", + "name": "#NamesArray", "decorators": [], "loc": { "start": { @@ -808,7 +689,7 @@ "elements": [ { "type": "StringLiteral", - "value": "0", + "value": "AAA", "loc": { "start": { "line": 16, @@ -824,7 +705,7 @@ }, { "type": "StringLiteral", - "value": "1", + "value": "BBB", "loc": { "start": { "line": 16, @@ -852,7 +733,7 @@ } } }, - "accessibility": "protected", + "accessibility": "private", "static": true, "readonly": true, "declare": false, @@ -940,7 +821,7 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "ItemsArray", + "name": "#ValuesArray", "decorators": [], "loc": { "start": { @@ -959,43 +840,8 @@ "type": "ArrayExpression", "elements": [ { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Enum", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 14, - "program": "declare_enum.sts" - }, - "end": { - "line": 16, - "column": 18, - "program": "declare_enum.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "AAA", - "decorators": [], - "loc": { - "start": { - "line": 17, - "column": 5, - "program": "declare_enum.sts" - }, - "end": { - "line": 17, - "column": 8, - "program": "declare_enum.sts" - } - } - }, - "computed": false, - "optional": false, + "type": "NumberLiteral", + "value": 0, "loc": { "start": { "line": 16, @@ -1010,43 +856,128 @@ } }, { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Enum", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 14, - "program": "declare_enum.sts" - }, - "end": { - "line": 16, - "column": 18, - "program": "declare_enum.sts" - } + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 16, + "column": 9, + "program": "declare_enum.sts" + }, + "end": { + "line": 16, + "column": 9, + "program": "declare_enum.sts" } + } + } + ], + "loc": { + "start": { + "line": 16, + "column": 9, + "program": "declare_enum.sts" + }, + "end": { + "line": 16, + "column": 9, + "program": "declare_enum.sts" + } + } + }, + "accessibility": "private", + "static": true, + "readonly": true, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 16, + "column": 9, + "program": "declare_enum.sts" }, - "property": { - "type": "Identifier", - "name": "BBB", - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 5, - "program": "declare_enum.sts" - }, - "end": { - "line": 18, - "column": 8, - "program": "declare_enum.sts" - } + "end": { + "line": 16, + "column": 9, + "program": "declare_enum.sts" + } + } + }, + "annotations": [], + "loc": { + "start": { + "line": 16, + "column": 9, + "program": "declare_enum.sts" + }, + "end": { + "line": 16, + "column": 9, + "program": "declare_enum.sts" + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 9, + "program": "declare_enum.sts" + }, + "end": { + "line": 16, + "column": 9, + "program": "declare_enum.sts" + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "#StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 9, + "program": "declare_enum.sts" + }, + "end": { + "line": 16, + "column": 9, + "program": "declare_enum.sts" + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "0", + "loc": { + "start": { + "line": 16, + "column": 9, + "program": "declare_enum.sts" + }, + "end": { + "line": 16, + "column": 9, + "program": "declare_enum.sts" } - }, - "computed": false, - "optional": false, + } + }, + { + "type": "StringLiteral", + "value": "1", "loc": { "start": { "line": 16, @@ -1074,7 +1005,7 @@ } } }, - "accessibility": "protected", + "accessibility": "private", "static": true, "readonly": true, "declare": false, @@ -1088,7 +1019,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Enum", + "name": "String", "decorators": [], "loc": { "start": { @@ -1162,7 +1093,7 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "BoxedItemsArray", + "name": "#ItemsArray", "decorators": [], "loc": { "start": { @@ -1181,137 +1112,43 @@ "type": "ArrayExpression", "elements": [ { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "#Enum", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - }, - "end": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - } - } - }, - "loc": { - "start": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - }, - "end": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - } - } - }, + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Enum", + "decorators": [], "loc": { "start": { "line": 16, - "column": 9, + "column": 14, "program": "declare_enum.sts" }, "end": { "line": 16, - "column": 9, + "column": 18, "program": "declare_enum.sts" } } }, - "arguments": [ - { - "type": "TSAsExpression", - "expression": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Enum", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 14, - "program": "declare_enum.sts" - }, - "end": { - "line": 16, - "column": 18, - "program": "declare_enum.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "AAA", - "decorators": [], - "loc": { - "start": { - "line": 17, - "column": 5, - "program": "declare_enum.sts" - }, - "end": { - "line": 17, - "column": 8, - "program": "declare_enum.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - }, - "end": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - }, - "end": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - } - } + "property": { + "type": "Identifier", + "name": "AAA", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 5, + "program": "declare_enum.sts" }, - "loc": { - "start": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - }, - "end": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - } + "end": { + "line": 17, + "column": 8, + "program": "declare_enum.sts" } } - ], + }, + "computed": false, + "optional": false, "loc": { "start": { "line": 16, @@ -1326,137 +1163,43 @@ } }, { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "#Enum", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - }, - "end": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - } - } - }, - "loc": { - "start": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - }, - "end": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - } - } - }, + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Enum", + "decorators": [], "loc": { "start": { "line": 16, - "column": 9, + "column": 14, "program": "declare_enum.sts" }, "end": { "line": 16, - "column": 9, + "column": 18, "program": "declare_enum.sts" } } }, - "arguments": [ - { - "type": "TSAsExpression", - "expression": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Enum", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 14, - "program": "declare_enum.sts" - }, - "end": { - "line": 16, - "column": 18, - "program": "declare_enum.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "BBB", - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 5, - "program": "declare_enum.sts" - }, - "end": { - "line": 18, - "column": 8, - "program": "declare_enum.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - }, - "end": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - }, - "end": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - } - } + "property": { + "type": "Identifier", + "name": "BBB", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 5, + "program": "declare_enum.sts" }, - "loc": { - "start": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - }, - "end": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - } + "end": { + "line": 18, + "column": 8, + "program": "declare_enum.sts" } } - ], + }, + "computed": false, + "optional": false, "loc": { "start": { "line": 16, @@ -1484,7 +1227,7 @@ } } }, - "accessibility": "protected", + "accessibility": "private", "static": true, "readonly": true, "declare": false, @@ -1498,7 +1241,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "#Enum", + "name": "Enum", "decorators": [], "loc": { "start": { @@ -1589,7 +1332,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -1616,87 +1359,7 @@ "generator": false, "async": false, "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Enum", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - }, - "end": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - } - } - }, - "loc": { - "start": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - }, - "end": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - } - } - }, - "loc": { - "start": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - }, - "end": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - }, - "end": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - } - } - }, - "loc": { - "start": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - }, - "end": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - } - } - } - ], + "params": [], "returnType": { "type": "ETSTypeReference", "part": { @@ -1963,7 +1626,6 @@ } }, "declare": true, - "throwMarker": "throws", "loc": { "start": { "line": 16, @@ -2009,7 +1671,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "valueOf", + "name": "fromValue", "decorators": [], "loc": { "start": { @@ -2035,7 +1697,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "valueOf", + "name": "fromValue", "decorators": [], "loc": { "start": { @@ -2058,41 +1720,9 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "e", + "name": "value", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Enum", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - }, - "end": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - } - } - }, - "loc": { - "start": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - }, - "end": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 16, @@ -2135,7 +1765,39 @@ } ], "returnType": { - "type": "ETSPrimitiveType", + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 9, + "program": "declare_enum.sts" + }, + "end": { + "line": 16, + "column": 9, + "program": "declare_enum.sts" + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 9, + "program": "declare_enum.sts" + }, + "end": { + "line": 16, + "column": 9, + "program": "declare_enum.sts" + } + } + }, "loc": { "start": { "line": 16, @@ -2195,7 +1857,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "toString", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -2212,7 +1874,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -2221,7 +1883,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "toString", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -2231,129 +1893,17 @@ }, "end": { "line": 16, - "column": 9, - "program": "declare_enum.sts" - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Enum", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - }, - "end": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - } - } - }, - "loc": { - "start": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - }, - "end": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - } - } - }, - "loc": { - "start": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - }, - "end": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - }, - "end": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - } - } - }, - "loc": { - "start": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - }, - "end": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - } + "column": 9, + "program": "declare_enum.sts" } } - ], + }, + "generator": false, + "async": false, + "expression": false, + "params": [], "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - }, - "end": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - } - } - }, - "loc": { - "start": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - }, - "end": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 16, @@ -2413,7 +1963,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "values", + "name": "toString", "decorators": [], "loc": { "start": { @@ -2430,7 +1980,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -2439,7 +1989,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "values", + "name": "toString", "decorators": [], "loc": { "start": { @@ -2459,28 +2009,13 @@ "expression": false, "params": [], "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Enum", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - }, - "end": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - } - } - }, + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], "loc": { "start": { "line": 16, @@ -2507,7 +2042,6 @@ } } }, - "annotations": [], "loc": { "start": { "line": 16, @@ -2567,7 +2101,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "fromInt", + "name": "values", "decorators": [], "loc": { "start": { @@ -2593,7 +2127,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "fromInt", + "name": "values", "decorators": [], "loc": { "start": { @@ -2611,14 +2145,17 @@ "generator": false, "async": false, "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSPrimitiveType", + "params": [], + "returnType": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Enum", + "decorators": [], "loc": { "start": { "line": 16, @@ -2632,42 +2169,6 @@ } } }, - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - }, - "end": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - } - } - }, - "loc": { - "start": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - }, - "end": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - } - } - } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Enum", - "decorators": [], "loc": { "start": { "line": 16, @@ -2694,6 +2195,7 @@ } } }, + "annotations": [], "loc": { "start": { "line": 16, @@ -2708,7 +2210,6 @@ } }, "declare": true, - "throwMarker": "throws", "loc": { "start": { "line": 16, @@ -2754,7 +2255,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "unbox", + "name": "getOrdinal", "decorators": [], "loc": { "start": { @@ -2780,7 +2281,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "unbox", + "name": "getOrdinal", "decorators": [], "loc": { "start": { @@ -2800,39 +2301,7 @@ "expression": false, "params": [], "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Enum", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - }, - "end": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - } - } - }, - "loc": { - "start": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - }, - "end": { - "line": 16, - "column": 9, - "program": "declare_enum.sts" - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 16, @@ -2892,7 +2361,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "boxedfromInt", + "name": "$_get", "decorators": [], "loc": { "start": { @@ -2918,7 +2387,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "boxedfromInt", + "name": "$_get", "decorators": [], "loc": { "start": { @@ -2941,9 +2410,41 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "ordinal", + "name": "e", "typeAnnotation": { - "type": "ETSPrimitiveType", + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 9, + "program": "declare_enum.sts" + }, + "end": { + "line": 16, + "column": 9, + "program": "declare_enum.sts" + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 9, + "program": "declare_enum.sts" + }, + "end": { + "line": 16, + "column": 9, + "program": "declare_enum.sts" + } + } + }, "loc": { "start": { "line": 16, @@ -2991,7 +2492,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "#Enum", + "name": "String", "decorators": [], "loc": { "start": { @@ -3033,7 +2534,6 @@ } }, "declare": true, - "throwMarker": "throws", "loc": { "start": { "line": 16, @@ -3101,6 +2601,55 @@ "program": null } } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ETSGLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1, + "program": "declare_enum.sts" + }, + "end": { + "line": 1, + "column": 1, + "program": "declare_enum.sts" + } + } + }, + "superClass": null, + "implements": [], + "body": [], + "loc": { + "start": { + "line": 1, + "column": 1, + "program": "declare_enum.sts" + }, + "end": { + "line": 1, + "column": 1, + "program": "declare_enum.sts" + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1, + "program": "declare_enum.sts" + }, + "end": { + "line": 1, + "column": 1, + "program": "declare_enum.sts" + } + } } ], "loc": { diff --git a/ets2panda/test/parser/ets/switch_enum_string_case-expected.txt b/ets2panda/test/parser/ets/switch_enum_string_case-expected.txt index f1645839cf..4dbb5d899a 100644 --- a/ets2panda/test/parser/ets/switch_enum_string_case-expected.txt +++ b/ets2panda/test/parser/ets/switch_enum_string_case-expected.txt @@ -2,229 +2,104 @@ "type": "Program", "statements": [ { - "type": "TSEnumDeclaration", - "id": { - "type": "Identifier", - "name": "Enum", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 6, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 10, - "program": "switch_enum_string_case.sts" - } - } - }, - "members": [ - { - "type": "TSEnumMember", - "id": { - "type": "Identifier", - "name": "e1", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 12, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 14, - "program": "switch_enum_string_case.sts" - } - } - }, - "initializer": { - "type": "StringLiteral", - "value": "A", - "loc": { - "start": { - "line": 20, - "column": 17, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 20, - "program": "switch_enum_string_case.sts" - } - } - }, + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "Enum", + "decorators": [], "loc": { "start": { "line": 20, - "column": 12, + "column": 6, "program": "switch_enum_string_case.sts" }, "end": { "line": 20, - "column": 20, + "column": 10, "program": "switch_enum_string_case.sts" } } }, - { - "type": "TSEnumMember", - "id": { - "type": "Identifier", - "name": "e2", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 22, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 24, - "program": "switch_enum_string_case.sts" + "superClass": null, + "implements": [], + "body": [ + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "#ordinal", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } } - } - }, - "initializer": { - "type": "StringLiteral", - "value": "B", - "loc": { - "start": { - "line": 20, - "column": 27, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 30, - "program": "switch_enum_string_case.sts" + }, + "accessibility": "private", + "static": false, + "readonly": true, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } } - } - }, - "loc": { - "start": { - "line": 20, - "column": 22, - "program": "switch_enum_string_case.sts" }, - "end": { - "line": 20, - "column": 30, - "program": "switch_enum_string_case.sts" - } - } - }, - { - "type": "TSEnumMember", - "id": { - "type": "Identifier", - "name": "e3", + "definite": false, "decorators": [], "loc": { "start": { "line": 20, - "column": 32, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 34, - "program": "switch_enum_string_case.sts" - } - } - }, - "initializer": { - "type": "StringLiteral", - "value": "C", - "loc": { - "start": { - "line": 20, - "column": 37, + "column": 1, "program": "switch_enum_string_case.sts" }, "end": { "line": 20, - "column": 40, + "column": 1, "program": "switch_enum_string_case.sts" } } }, - "loc": { - "start": { - "line": 20, - "column": 32, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 40, - "program": "switch_enum_string_case.sts" - } - } - } - ], - "const": false, - "declare": false, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 41, - "program": "switch_enum_string_case.sts" - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "ETSGLOBAL", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 1, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "superClass": null, - "implements": [], - "body": [ { "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "_$init$_", + "name": "", "decorators": [], "loc": { "start": { - "line": 1, + "line": 20, "column": 1, - "program": null + "program": "switch_enum_string_case.sts" }, "end": { - "line": 1, + "line": 20, "column": 1, - "program": null + "program": "switch_enum_string_case.sts" } } }, "kind": "method", - "accessibility": "public", + "accessibility": "private", "static": true, "optional": false, "computed": false, @@ -234,18 +109,18 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "_$init$_", + "name": "", "decorators": [], "loc": { "start": { - "line": 1, + "line": 20, "column": 1, - "program": null + "program": "switch_enum_string_case.sts" }, "end": { - "line": 1, + "line": 20, "column": 1, - "program": null + "program": "switch_enum_string_case.sts" } } }, @@ -258,40 +133,40 @@ "statements": [], "loc": { "start": { - "line": 1, + "line": 20, "column": 1, - "program": null + "program": "switch_enum_string_case.sts" }, "end": { - "line": 1, + "line": 20, "column": 1, - "program": null + "program": "switch_enum_string_case.sts" } } }, "loc": { "start": { - "line": 1, + "line": 20, "column": 1, - "program": null + "program": "switch_enum_string_case.sts" }, "end": { - "line": 1, + "line": 20, "column": 1, - "program": null + "program": "switch_enum_string_case.sts" } } }, "loc": { "start": { - "line": 1, + "line": 20, "column": 1, - "program": null + "program": "switch_enum_string_case.sts" }, "end": { - "line": 1, + "line": 20, "column": 1, - "program": null + "program": "switch_enum_string_case.sts" } } }, @@ -299,12 +174,12 @@ "decorators": [], "loc": { "start": { - "line": 1, + "line": 20, "column": 1, "program": "switch_enum_string_case.sts" }, "end": { - "line": 1, + "line": 20, "column": 1, "program": "switch_enum_string_case.sts" } @@ -314,24 +189,24 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "main", + "name": "constructor", "decorators": [], "loc": { "start": { - "line": 22, - "column": 10, + "line": 20, + "column": 1, "program": "switch_enum_string_case.sts" }, "end": { - "line": 22, - "column": 14, + "line": 20, + "column": 1, "program": "switch_enum_string_case.sts" } } }, - "kind": "method", + "kind": "constructor", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -340,17 +215,17 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "main", + "name": "constructor", "decorators": [], "loc": { "start": { - "line": 22, - "column": 10, + "line": 20, + "column": 1, "program": "switch_enum_string_case.sts" }, "end": { - "line": 22, - "column": 14, + "line": 20, + "column": 1, "program": "switch_enum_string_case.sts" } } @@ -358,525 +233,151 @@ "generator": false, "async": false, "expression": false, - "params": [], - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "v", - "decorators": [], + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", "loc": { "start": { - "line": 23, - "column": 7, + "line": 20, + "column": 1, "program": "switch_enum_string_case.sts" }, "end": { - "line": 23, - "column": 8, + "line": 20, + "column": 1, "program": "switch_enum_string_case.sts" } } }, - "init": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Enum", - "decorators": [], - "loc": { - "start": { - "line": 23, - "column": 11, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 23, - "column": 15, - "program": "switch_enum_string_case.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "e3", - "decorators": [], - "loc": { - "start": { - "line": 23, - "column": 16, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 23, - "column": 18, - "program": "switch_enum_string_case.sts" - } - } - }, - "computed": false, - "optional": false, + "property": { + "type": "Identifier", + "name": "#ordinal", + "decorators": [], "loc": { "start": { - "line": 23, - "column": 11, + "line": 20, + "column": 1, "program": "switch_enum_string_case.sts" }, "end": { - "line": 23, - "column": 18, + "line": 20, + "column": 1, "program": "switch_enum_string_case.sts" } } }, + "computed": false, + "optional": false, "loc": { "start": { - "line": 23, - "column": 7, + "line": 20, + "column": 1, "program": "switch_enum_string_case.sts" }, "end": { - "line": 23, - "column": 18, + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, "program": "switch_enum_string_case.sts" } } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 23, - "column": 3, - "program": "switch_enum_string_case.sts" }, - "end": { - "line": 23, - "column": 18, - "program": "switch_enum_string_case.sts" - } - } - }, - { - "type": "SwitchStatement", - "discriminant": { - "type": "Identifier", - "name": "v", - "decorators": [], "loc": { "start": { - "line": 24, - "column": 11, + "line": 20, + "column": 1, "program": "switch_enum_string_case.sts" }, "end": { - "line": 24, - "column": 12, + "line": 20, + "column": 1, "program": "switch_enum_string_case.sts" } } }, - "cases": [ - { - "type": "SwitchCase", - "test": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Enum", - "decorators": [], - "loc": { - "start": { - "line": 25, - "column": 10, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 25, - "column": 14, - "program": "switch_enum_string_case.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "e2", - "decorators": [], - "loc": { - "start": { - "line": 25, - "column": 15, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 25, - "column": 17, - "program": "switch_enum_string_case.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 25, - "column": 10, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 25, - "column": 17, - "program": "switch_enum_string_case.sts" - } - } - }, - "consequent": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "assertTrue", - "decorators": [], - "loc": { - "start": { - "line": 25, - "column": 19, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 25, - "column": 29, - "program": "switch_enum_string_case.sts" - } - } - }, - "arguments": [ - { - "type": "BooleanLiteral", - "value": false, - "loc": { - "start": { - "line": 25, - "column": 30, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 25, - "column": 35, - "program": "switch_enum_string_case.sts" - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 25, - "column": 19, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 25, - "column": 36, - "program": "switch_enum_string_case.sts" - } - } - }, - "loc": { - "start": { - "line": 25, - "column": 19, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 25, - "column": 37, - "program": "switch_enum_string_case.sts" - } - } - }, - { - "type": "BreakStatement", - "label": null, - "loc": { - "start": { - "line": 25, - "column": 38, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 25, - "column": 44, - "program": "switch_enum_string_case.sts" - } - } - } - ], - "loc": { - "start": { - "line": 25, - "column": 5, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 25, - "column": 44, - "program": "switch_enum_string_case.sts" - } - } - }, - { - "type": "SwitchCase", - "test": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Enum", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 10, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 26, - "column": 14, - "program": "switch_enum_string_case.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "e1", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 15, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 26, - "column": 17, - "program": "switch_enum_string_case.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 26, - "column": 10, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 26, - "column": 17, - "program": "switch_enum_string_case.sts" - } - } - }, - "consequent": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "assertTrue", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 19, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 26, - "column": 29, - "program": "switch_enum_string_case.sts" - } - } - }, - "arguments": [ - { - "type": "BooleanLiteral", - "value": false, - "loc": { - "start": { - "line": 26, - "column": 30, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 26, - "column": 35, - "program": "switch_enum_string_case.sts" - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 26, - "column": 19, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 26, - "column": 36, - "program": "switch_enum_string_case.sts" - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 19, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 26, - "column": 37, - "program": "switch_enum_string_case.sts" - } - } - }, - { - "type": "BreakStatement", - "label": null, - "loc": { - "start": { - "line": 26, - "column": 38, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 26, - "column": 44, - "program": "switch_enum_string_case.sts" - } - } - } - ], - "loc": { - "start": { - "line": 26, - "column": 5, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 26, - "column": 44, - "program": "switch_enum_string_case.sts" - } - } - }, - { - "type": "SwitchCase", - "test": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Enum", - "decorators": [], - "loc": { - "start": { - "line": 27, - "column": 10, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 27, - "column": 14, - "program": "switch_enum_string_case.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "e3", - "decorators": [], - "loc": { - "start": { - "line": 27, - "column": 15, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 27, - "column": 17, - "program": "switch_enum_string_case.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 27, - "column": 10, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 27, - "column": 17, - "program": "switch_enum_string_case.sts" - } - } - }, - "consequent": [ - { - "type": "BreakStatement", - "label": null, - "loc": { - "start": { - "line": 27, - "column": 20, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 27, - "column": 26, - "program": "switch_enum_string_case.sts" - } - } - } - ], - "loc": { - "start": { - "line": 27, - "column": 5, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 27, - "column": 26, - "program": "switch_enum_string_case.sts" - } - } - } - ], "loc": { "start": { - "line": 24, - "column": 3, + "line": 20, + "column": 1, "program": "switch_enum_string_case.sts" }, "end": { - "line": 28, - "column": 4, + "line": 20, + "column": 1, "program": "switch_enum_string_case.sts" } } @@ -884,39 +385,39 @@ ], "loc": { "start": { - "line": 22, - "column": 17, + "line": 20, + "column": 1, "program": "switch_enum_string_case.sts" }, - "end": { - "line": 29, - "column": 2, + "end": { + "line": 20, + "column": 1, "program": "switch_enum_string_case.sts" } } }, "loc": { "start": { - "line": 22, - "column": 10, + "line": 20, + "column": 1, "program": "switch_enum_string_case.sts" }, "end": { - "line": 29, - "column": 2, + "line": 20, + "column": 1, "program": "switch_enum_string_case.sts" } } }, "loc": { "start": { - "line": 22, - "column": 10, + "line": 20, + "column": 1, "program": "switch_enum_string_case.sts" }, "end": { - "line": 29, - "column": 2, + "line": 20, + "column": 1, "program": "switch_enum_string_case.sts" } } @@ -925,94 +426,156 @@ "decorators": [], "loc": { "start": { - "line": 22, + "line": 20, "column": 1, "program": "switch_enum_string_case.sts" }, "end": { - "line": 29, - "column": 2, + "line": 20, + "column": 1, "program": "switch_enum_string_case.sts" } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "switch_enum_string_case.sts" }, - "end": { - "line": 1, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 1, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "#Enum", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "superClass": null, - "implements": [], - "body": [ { "type": "ClassProperty", "key": { "type": "Identifier", - "name": "ordinal", + "name": "e1", "decorators": [], "loc": { "start": { "line": 20, - "column": 1, + "column": 12, "program": "switch_enum_string_case.sts" }, "end": { "line": 20, - "column": 1, + "column": 14, "program": "switch_enum_string_case.sts" } } }, - "accessibility": "protected", - "static": false, - "readonly": false, + "value": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "arguments": [ + { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + } + ], + "loc": { + "start": { + "line": 20, + "column": 17, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 20, + "program": "switch_enum_string_case.sts" + } + } + }, + "accessibility": "public", + "static": true, + "readonly": true, "declare": false, "optional": false, "computed": false, "typeAnnotation": { - "type": "ETSPrimitiveType", + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, "loc": { "start": { "line": 20, @@ -1031,47 +594,128 @@ "loc": { "start": { "line": 20, - "column": 1, + "column": 12, "program": "switch_enum_string_case.sts" }, "end": { "line": 20, - "column": 1, + "column": 20, "program": "switch_enum_string_case.sts" } } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "", + "name": "e2", "decorators": [], "loc": { "start": { "line": 20, - "column": 1, + "column": 22, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 24, + "program": "switch_enum_string_case.sts" + } + } + }, + "value": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "arguments": [ + { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + } + ], + "loc": { + "start": { + "line": 20, + "column": 27, "program": "switch_enum_string_case.sts" }, "end": { "line": 20, - "column": 1, + "column": 30, "program": "switch_enum_string_case.sts" } } }, - "kind": "method", "accessibility": "public", "static": true, + "readonly": true, + "declare": false, "optional": false, "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { "type": "Identifier", - "name": "", + "name": "Enum", "decorators": [], "loc": { "start": { @@ -1086,26 +730,6 @@ } } }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "body": { - "type": "BlockStatement", - "statements": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, "loc": { "start": { "line": 20, @@ -1132,53 +756,63 @@ } } }, - "overloads": [], + "definite": false, "decorators": [], "loc": { "start": { "line": 20, - "column": 1, + "column": 22, "program": "switch_enum_string_case.sts" }, "end": { "line": 20, - "column": 1, + "column": 30, "program": "switch_enum_string_case.sts" } } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "constructor", + "name": "e3", "decorators": [], "loc": { "start": { "line": 20, - "column": 1, + "column": 32, "program": "switch_enum_string_case.sts" }, "end": { "line": 20, - "column": 1, + "column": 34, "program": "switch_enum_string_case.sts" } } }, - "kind": "constructor", - "accessibility": "public", - "static": false, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "constructor", - "decorators": [], + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, "loc": { "start": { "line": 20, @@ -1192,159 +826,64 @@ } } }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "arguments": [ + { + "type": "NumberLiteral", + "value": 2, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" } } - ], - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "MemberExpression", - "object": { - "type": "ThisExpression", - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "right": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - } - ], + } + ], + "loc": { + "start": { + "line": 20, + "column": 37, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 40, + "program": "switch_enum_string_case.sts" + } + } + }, + "accessibility": "public", + "static": true, + "readonly": true, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Enum", + "decorators": [], "loc": { "start": { "line": 20, @@ -1384,17 +923,17 @@ } } }, - "overloads": [], + "definite": false, "decorators": [], "loc": { "start": { "line": 20, - "column": 1, + "column": 32, "program": "switch_enum_string_case.sts" }, "end": { "line": 20, - "column": 1, + "column": 40, "program": "switch_enum_string_case.sts" } } @@ -1403,7 +942,7 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "NamesArray", + "name": "#NamesArray", "decorators": [], "loc": { "start": { @@ -1483,7 +1022,7 @@ } } }, - "accessibility": "protected", + "accessibility": "private", "static": true, "readonly": true, "declare": false, @@ -1571,7 +1110,7 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "StringValuesArray", + "name": "#StringValuesArray", "decorators": [], "loc": { "start": { @@ -1651,7 +1190,7 @@ } } }, - "accessibility": "protected", + "accessibility": "private", "static": true, "readonly": true, "declare": false, @@ -1739,7 +1278,7 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "ItemsArray", + "name": "#ItemsArray", "decorators": [], "loc": { "start": { @@ -1842,61 +1381,255 @@ "column": 24, "program": "switch_enum_string_case.sts" } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 6, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 10, + "program": "switch_enum_string_case.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "e3", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 32, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 34, + "program": "switch_enum_string_case.sts" + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + } + ], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "accessibility": "private", + "static": true, + "readonly": true, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "annotations": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getName", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "kind": "method", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getName", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Enum", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 6, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 10, - "program": "switch_enum_string_case.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "e3", - "decorators": [], "loc": { "start": { "line": 20, - "column": 32, + "column": 1, "program": "switch_enum_string_case.sts" }, "end": { "line": 20, - "column": 34, + "column": 1, "program": "switch_enum_string_case.sts" } } }, - "computed": false, - "optional": false, "loc": { "start": { "line": 20, @@ -1909,50 +1642,143 @@ "program": "switch_enum_string_case.sts" } } - } - ], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "accessibility": "protected", - "static": true, - "readonly": true, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Enum", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 6, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 10, + "program": "switch_enum_string_case.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "#NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "#ordinal", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } } } - }, + ], "loc": { "start": { "line": 20, @@ -1979,7 +1805,6 @@ } } }, - "annotations": [], "loc": { "start": { "line": 20, @@ -1993,7 +1818,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2009,10 +1834,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "BoxedItemsArray", + "name": "getValueOf", "decorators": [], "loc": { "start": { @@ -2020,26 +1845,82 @@ "column": 1, "program": "switch_enum_string_case.sts" }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "#Enum", - "decorators": [], + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getValueOf", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "name", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, "loc": { "start": { "line": 20, @@ -2053,6 +1934,7 @@ } } }, + "decorators": [], "loc": { "start": { "line": 20, @@ -2078,76 +1960,16 @@ "program": "switch_enum_string_case.sts" } } - }, - "arguments": [ - { - "type": "TSAsExpression", - "expression": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Enum", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 6, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 10, - "program": "switch_enum_string_case.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "e1", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 12, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 14, - "program": "switch_enum_string_case.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Enum", + "decorators": [], "loc": { "start": { "line": 20, @@ -2160,8 +1982,20 @@ "program": "switch_enum_string_case.sts" } } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } } - ], + }, "loc": { "start": { "line": 20, @@ -2175,16 +2009,64 @@ } } }, - { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "#Enum", - "decorators": [], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ForUpdateStatement", + "init": { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "init": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + } + ], + "kind": "let", "loc": { "start": { "line": 20, @@ -2198,73 +2080,111 @@ } } }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "arguments": [ - { - "type": "TSAsExpression", - "expression": { - "type": "MemberExpression", - "object": { + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { "type": "Identifier", - "name": "Enum", + "name": "i", "decorators": [], "loc": { "start": { "line": 20, - "column": 6, + "column": 1, "program": "switch_enum_string_case.sts" }, "end": { "line": 20, - "column": 10, + "column": 1, "program": "switch_enum_string_case.sts" } } }, - "property": { - "type": "Identifier", - "name": "e2", - "decorators": [], + "right": { + "type": "MemberExpression", + "object": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 6, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 10, + "program": "switch_enum_string_case.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "#NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "computed": false, + "optional": false, "loc": { "start": { "line": 20, - "column": 22, + "column": 1, "program": "switch_enum_string_case.sts" }, "end": { "line": 20, - "column": 24, + "column": 1, "program": "switch_enum_string_case.sts" } } }, - "computed": false, - "optional": false, "loc": { "start": { "line": 20, @@ -2278,58 +2198,27 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" + "update": { + "type": "UpdateExpression", + "operator": "++", + "prefix": true, + "argument": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - } - ], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "#Enum", - "decorators": [], "loc": { "start": { "line": 20, @@ -2343,288 +2232,200 @@ } } }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "arguments": [ - { - "type": "TSAsExpression", - "expression": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Enum", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 6, - "program": "switch_enum_string_case.sts" + "body": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "==", + "left": { + "type": "Identifier", + "name": "name", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "right": { + "type": "MemberExpression", + "object": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 6, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 10, + "program": "switch_enum_string_case.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "#NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } }, - "end": { - "line": 20, - "column": 10, - "program": "switch_enum_string_case.sts" + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } } - } - }, - "property": { - "type": "Identifier", - "name": "e3", - "decorators": [], + }, "loc": { "start": { "line": 20, - "column": 32, + "column": 1, "program": "switch_enum_string_case.sts" }, "end": { - "line": 20, - "column": 34, - "program": "switch_enum_string_case.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - } - ], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - } - ], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "accessibility": "protected", - "static": true, - "readonly": true, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "#Enum", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "annotations": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "definite": false, - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "getName", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "getName", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Enum", - "decorators": [], + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 6, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 10, + "program": "switch_enum_string_case.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "#ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 20, @@ -2651,6 +2452,7 @@ } } }, + "alternate": null, "loc": { "start": { "line": 20, @@ -2664,42 +2466,6 @@ } } }, - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], "loc": { "start": { "line": 20, @@ -2713,62 +2479,31 @@ } } }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ { - "type": "ReturnStatement", + "type": "ThrowStatement", "argument": { - "type": "MemberExpression", - "object": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Enum", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Error", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } } - } - }, - "property": { - "type": "Identifier", - "name": "NamesArray", - "decorators": [], + }, "loc": { "start": { "line": 20, @@ -2782,8 +2517,6 @@ } } }, - "computed": false, - "optional": false, "loc": { "start": { "line": 20, @@ -2797,27 +2530,43 @@ } } }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant Enum.", + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + }, + "right": { + "type": "Identifier", + "name": "name", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, "loc": { "start": { "line": 20, @@ -2830,22 +2579,8 @@ "program": "switch_enum_string_case.sts" } } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } } - }, - "computed": true, - "optional": false, + ], "loc": { "start": { "line": 20, @@ -2931,7 +2666,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "getValueOf", + "name": "fromValue", "decorators": [], "loc": { "start": { @@ -2957,7 +2692,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "getValueOf", + "name": "fromValue", "decorators": [], "loc": { "start": { @@ -2980,7 +2715,7 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "name", + "name": "value", "typeAnnotation": { "type": "ETSTypeReference", "part": { @@ -3200,24 +2935,24 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Enum", + "name": "Enum", "decorators": [], "loc": { "start": { "line": 20, - "column": 1, + "column": 6, "program": "switch_enum_string_case.sts" }, "end": { "line": 20, - "column": 1, + "column": 10, "program": "switch_enum_string_case.sts" } } }, "property": { "type": "Identifier", - "name": "NamesArray", + "name": "#StringValuesArray", "decorators": [], "loc": { "start": { @@ -3333,7 +3068,7 @@ "operator": "==", "left": { "type": "Identifier", - "name": "name", + "name": "value", "decorators": [], "loc": { "start": { @@ -3354,24 +3089,24 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Enum", + "name": "Enum", "decorators": [], "loc": { "start": { "line": 20, - "column": 1, + "column": 6, "program": "switch_enum_string_case.sts" }, "end": { "line": 20, - "column": 1, + "column": 10, "program": "switch_enum_string_case.sts" } } }, "property": { "type": "Identifier", - "name": "NamesArray", + "name": "#StringValuesArray", "decorators": [], "loc": { "start": { @@ -3449,45 +3184,30 @@ "consequent": { "type": "ReturnStatement", "argument": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Enum", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } + "type": "MemberExpression", + "object": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 6, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 10, + "program": "switch_enum_string_case.sts" } - }, + } + }, + "property": { + "type": "Identifier", + "name": "#ItemsArray", + "decorators": [], "loc": { "start": { "line": 20, @@ -3501,6 +3221,25 @@ } } }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "i", + "decorators": [], "loc": { "start": { "line": 20, @@ -3514,6 +3253,8 @@ } } }, + "computed": true, + "optional": false, "loc": { "start": { "line": 20, @@ -3577,7 +3318,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Exception", + "name": "Error", "decorators": [], "loc": { "start": { @@ -3624,7 +3365,7 @@ "operator": "+", "left": { "type": "StringLiteral", - "value": "No enum constant Enum.", + "value": "No enum Enum with value ", "loc": { "start": { "line": 20, @@ -3640,7 +3381,7 @@ }, "right": { "type": "Identifier", - "name": "name", + "name": "value", "decorators": [], "loc": { "start": { @@ -3709,7 +3450,6 @@ } } }, - "throwMarker": "throws", "loc": { "start": { "line": 20, @@ -3755,7 +3495,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "toString", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -3772,7 +3512,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -3781,7 +3521,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "toString", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -3799,87 +3539,7 @@ "generator": false, "async": false, "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Enum", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - } - ], + "params": [], "returnType": { "type": "ETSTypeReference", "part": { @@ -3938,24 +3598,24 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Enum", + "name": "Enum", "decorators": [], "loc": { "start": { "line": 20, - "column": 1, + "column": 6, "program": "switch_enum_string_case.sts" }, "end": { "line": 20, - "column": 1, + "column": 10, "program": "switch_enum_string_case.sts" } } }, "property": { "type": "Identifier", - "name": "StringValuesArray", + "name": "#StringValuesArray", "decorators": [], "loc": { "start": { @@ -3986,11 +3646,9 @@ } }, "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "ThisExpression", "loc": { "start": { "line": 20, @@ -4004,8 +3662,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "#ordinal", + "decorators": [], "loc": { "start": { "line": 20, @@ -4019,6 +3679,8 @@ } } }, + "computed": false, + "optional": false, "loc": { "start": { "line": 20, @@ -4119,7 +3781,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "values", + "name": "toString", "decorators": [], "loc": { "start": { @@ -4136,7 +3798,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -4145,7 +3807,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "values", + "name": "toString", "decorators": [], "loc": { "start": { @@ -4165,28 +3827,13 @@ "expression": false, "params": [], "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Enum", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], "loc": { "start": { "line": 20, @@ -4213,7 +3860,6 @@ } } }, - "annotations": [], "loc": { "start": { "line": 20, @@ -4235,9 +3881,43 @@ "argument": { "type": "MemberExpression", "object": { - "type": "Identifier", - "name": "#Enum", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 6, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 10, + "program": "switch_enum_string_case.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "#StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "computed": false, + "optional": false, "loc": { "start": { "line": 20, @@ -4249,12 +3929,44 @@ "column": 1, "program": "switch_enum_string_case.sts" } - } - }, - "property": { - "type": "Identifier", - "name": "ItemsArray", - "decorators": [], + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "property": { + "type": "Identifier", + "name": "#ordinal", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "computed": false, + "optional": false, "loc": { "start": { "line": 20, @@ -4268,7 +3980,7 @@ } } }, - "computed": false, + "computed": true, "optional": false, "loc": { "start": { @@ -4355,7 +4067,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "fromInt", + "name": "values", "decorators": [], "loc": { "start": { @@ -4381,7 +4093,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "fromInt", + "name": "values", "decorators": [], "loc": { "start": { @@ -4399,14 +4111,17 @@ "generator": false, "async": false, "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSPrimitiveType", + "params": [], + "returnType": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Enum", + "decorators": [], "loc": { "start": { "line": 20, @@ -4420,42 +4135,6 @@ } } }, - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Enum", - "decorators": [], "loc": { "start": { "line": 20, @@ -4482,6 +4161,7 @@ } } }, + "annotations": [], "loc": { "start": { "line": 20, @@ -4489,209 +4169,40 @@ "program": "switch_enum_string_case.sts" }, "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "<", - "left": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "right": { - "type": "MemberExpression", - "object": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Enum", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "length", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "consequent": { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Enum", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 6, + "program": "switch_enum_string_case.sts" }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } + "end": { + "line": 20, + "column": 10, + "program": "switch_enum_string_case.sts" } - }, - "computed": true, - "optional": false, + } + }, + "property": { + "type": "Identifier", + "name": "#ItemsArray", + "decorators": [], "loc": { "start": { "line": 20, @@ -4705,6 +4216,8 @@ } } }, + "computed": false, + "optional": false, "loc": { "start": { "line": 20, @@ -4718,7 +4231,6 @@ } } }, - "alternate": null, "loc": { "start": { "line": 20, @@ -4731,45 +4243,135 @@ "program": "switch_enum_string_case.sts" } } + } + ], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getOrdinal", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "kind": "method", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getOrdinal", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ { - "type": "ThrowStatement", + "type": "ReturnStatement", "argument": { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Exception", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, + "type": "MemberExpression", + "object": { + "type": "ThisExpression", "loc": { "start": { "line": 20, @@ -4782,58 +4384,26 @@ "program": "switch_enum_string_case.sts" } } - }, - "arguments": [ - { - "type": "BinaryExpression", - "operator": "+", - "left": { - "type": "StringLiteral", - "value": "No enum constant in Enum with ordinal value ", - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "right": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } + }, + "property": { + "type": "Identifier", + "name": "#ordinal", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" } } - ], + }, + "computed": false, + "optional": false, "loc": { "start": { "line": 20, @@ -4874,7 +4444,6 @@ } } }, - "throwMarker": "throws", "loc": { "start": { "line": 20, @@ -4920,7 +4489,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "unbox", + "name": "$_get", "decorators": [], "loc": { "start": { @@ -4937,7 +4506,7 @@ }, "kind": "method", "accessibility": "public", - "static": false, + "static": true, "optional": false, "computed": false, "value": { @@ -4946,7 +4515,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "unbox", + "name": "$_get", "decorators": [], "loc": { "start": { @@ -4964,14 +4533,94 @@ "generator": false, "async": false, "expression": false, - "params": [], + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "e", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + } + ], "returnType": { "type": "ETSTypeReference", "part": { "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Enum", + "name": "String", "decorators": [], "loc": { "start": { @@ -5018,29 +4667,12 @@ { "type": "ReturnStatement", "argument": { - "type": "MemberExpression", - "object": { + "type": "CallExpression", + "callee": { "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Enum", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "ItemsArray", + "name": "e", "decorators": [], "loc": { "start": { @@ -5055,41 +4687,9 @@ } } }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "property": { - "type": "MemberExpression", - "object": { - "type": "ThisExpression", - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, "property": { "type": "Identifier", - "name": "ordinal", + "name": "getName", "decorators": [], "loc": { "start": { @@ -5119,7 +4719,7 @@ } } }, - "computed": true, + "arguments": [], "optional": false, "loc": { "start": { @@ -5147,43 +4747,199 @@ } } } - ], + ], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + } + ], + "loc": { + "start": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 20, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1, + "program": null + }, + "end": { + "line": 1, + "column": 1, + "program": null + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ETSGLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 1, + "column": 1, + "program": "switch_enum_string_case.sts" + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1, + "program": null + }, + "end": { + "line": 1, + "column": 1, + "program": null + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1, + "program": null + }, + "end": { + "line": 1, + "column": 1, + "program": null + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], "loc": { "start": { - "line": 20, + "line": 1, "column": 1, - "program": "switch_enum_string_case.sts" + "program": null }, "end": { - "line": 20, + "line": 1, "column": 1, - "program": "switch_enum_string_case.sts" + "program": null } } }, "loc": { "start": { - "line": 20, + "line": 1, "column": 1, - "program": "switch_enum_string_case.sts" + "program": null }, "end": { - "line": 20, + "line": 1, "column": 1, - "program": "switch_enum_string_case.sts" + "program": null } } }, "loc": { "start": { - "line": 20, + "line": 1, "column": 1, - "program": "switch_enum_string_case.sts" + "program": null }, "end": { - "line": 20, + "line": 1, "column": 1, - "program": "switch_enum_string_case.sts" + "program": null } } }, @@ -5191,12 +4947,12 @@ "decorators": [], "loc": { "start": { - "line": 20, + "line": 1, "column": 1, "program": "switch_enum_string_case.sts" }, "end": { - "line": 20, + "line": 1, "column": 1, "program": "switch_enum_string_case.sts" } @@ -5206,17 +4962,17 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "boxedfromInt", + "name": "main", "decorators": [], "loc": { "start": { - "line": 20, - "column": 1, + "line": 22, + "column": 10, "program": "switch_enum_string_case.sts" }, "end": { - "line": 20, - "column": 1, + "line": 22, + "column": 14, "program": "switch_enum_string_case.sts" } } @@ -5232,17 +4988,17 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "boxedfromInt", + "name": "main", "decorators": [], "loc": { "start": { - "line": 20, - "column": 1, + "line": 22, + "column": 10, "program": "switch_enum_string_case.sts" }, "end": { - "line": 20, - "column": 1, + "line": 22, + "column": 14, "program": "switch_enum_string_case.sts" } } @@ -5250,161 +5006,64 @@ "generator": false, "async": false, "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "#Enum", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, + "params": [], "body": { "type": "BlockStatement", "statements": [ { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "<", - "left": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "v", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 7, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 23, + "column": 8, + "program": "switch_enum_string_case.sts" + } } - } - }, - "right": { - "type": "MemberExpression", - "object": { + }, + "init": { "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Enum", + "name": "Enum", "decorators": [], "loc": { "start": { - "line": 20, - "column": 1, + "line": 23, + "column": 11, "program": "switch_enum_string_case.sts" }, "end": { - "line": 20, - "column": 1, + "line": 23, + "column": 15, "program": "switch_enum_string_case.sts" } } }, "property": { "type": "Identifier", - "name": "BoxedItemsArray", + "name": "e3", "decorators": [], "loc": { "start": { - "line": 20, - "column": 1, + "line": 23, + "column": 16, "program": "switch_enum_string_case.sts" }, "end": { - "line": 20, - "column": 1, + "line": 23, + "column": 18, "program": "switch_enum_string_case.sts" } } @@ -5413,98 +5072,99 @@ "optional": false, "loc": { "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "property": { - "type": "Identifier", - "name": "length", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, + "line": 23, + "column": 11, "program": "switch_enum_string_case.sts" }, "end": { - "line": 20, - "column": 1, + "line": 23, + "column": 18, "program": "switch_enum_string_case.sts" } } }, - "computed": false, - "optional": false, "loc": { "start": { - "line": 20, - "column": 1, + "line": 23, + "column": 7, "program": "switch_enum_string_case.sts" }, "end": { - "line": 20, - "column": 1, + "line": 23, + "column": 18, "program": "switch_enum_string_case.sts" } } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 23, + "column": 3, + "program": "switch_enum_string_case.sts" }, + "end": { + "line": 23, + "column": 18, + "program": "switch_enum_string_case.sts" + } + } + }, + { + "type": "SwitchStatement", + "discriminant": { + "type": "Identifier", + "name": "v", + "decorators": [], "loc": { "start": { - "line": 20, - "column": 1, + "line": 24, + "column": 11, "program": "switch_enum_string_case.sts" }, "end": { - "line": 20, - "column": 1, + "line": 24, + "column": 12, "program": "switch_enum_string_case.sts" } } }, - "consequent": { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { + "cases": [ + { + "type": "SwitchCase", + "test": { "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Enum", + "name": "Enum", "decorators": [], "loc": { "start": { - "line": 20, - "column": 1, + "line": 25, + "column": 10, "program": "switch_enum_string_case.sts" }, "end": { - "line": 20, - "column": 1, + "line": 25, + "column": 14, "program": "switch_enum_string_case.sts" } } }, "property": { "type": "Identifier", - "name": "BoxedItemsArray", + "name": "e2", "decorators": [], "loc": { "start": { - "line": 20, - "column": 1, + "line": 25, + "column": 15, "program": "switch_enum_string_case.sts" }, "end": { - "line": 20, - "column": 1, + "line": 25, + "column": 17, "program": "switch_enum_string_case.sts" } } @@ -5513,200 +5173,358 @@ "optional": false, "loc": { "start": { - "line": 20, - "column": 1, + "line": 25, + "column": 10, "program": "switch_enum_string_case.sts" }, "end": { - "line": 20, - "column": 1, + "line": 25, + "column": 17, "program": "switch_enum_string_case.sts" } } }, - "property": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" + "consequent": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "assertTrue", + "decorators": [], + "loc": { + "start": { + "line": 25, + "column": 19, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 25, + "column": 29, + "program": "switch_enum_string_case.sts" + } + } + }, + "arguments": [ + { + "type": "BooleanLiteral", + "value": false, + "loc": { + "start": { + "line": 25, + "column": 30, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 25, + "column": 35, + "program": "switch_enum_string_case.sts" + } + } + } + ], + "optional": false, + "loc": { + "start": { + "line": 25, + "column": 19, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 25, + "column": 36, + "program": "switch_enum_string_case.sts" + } + } }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" + "loc": { + "start": { + "line": 25, + "column": 19, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 25, + "column": 37, + "program": "switch_enum_string_case.sts" + } + } + }, + { + "type": "BreakStatement", + "label": null, + "loc": { + "start": { + "line": 25, + "column": 38, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 25, + "column": 44, + "program": "switch_enum_string_case.sts" + } } } - }, - "computed": true, - "optional": false, + ], "loc": { "start": { - "line": 20, - "column": 1, + "line": 25, + "column": 5, "program": "switch_enum_string_case.sts" }, "end": { - "line": 20, - "column": 1, + "line": 25, + "column": 44, "program": "switch_enum_string_case.sts" } } }, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - "alternate": null, - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" - } - } - }, - { - "type": "ThrowStatement", - "argument": { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { + { + "type": "SwitchCase", + "test": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 10, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 26, + "column": 14, + "program": "switch_enum_string_case.sts" + } + } + }, + "property": { "type": "Identifier", - "name": "Exception", + "name": "e1", "decorators": [], "loc": { "start": { - "line": 20, - "column": 1, + "line": 26, + "column": 15, "program": "switch_enum_string_case.sts" }, "end": { - "line": 20, - "column": 1, + "line": 26, + "column": 17, "program": "switch_enum_string_case.sts" } } }, + "computed": false, + "optional": false, "loc": { "start": { - "line": 20, - "column": 1, + "line": 26, + "column": 10, "program": "switch_enum_string_case.sts" }, "end": { - "line": 20, - "column": 1, + "line": 26, + "column": 17, "program": "switch_enum_string_case.sts" } } }, + "consequent": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "assertTrue", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 19, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 26, + "column": 29, + "program": "switch_enum_string_case.sts" + } + } + }, + "arguments": [ + { + "type": "BooleanLiteral", + "value": false, + "loc": { + "start": { + "line": 26, + "column": 30, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 26, + "column": 35, + "program": "switch_enum_string_case.sts" + } + } + } + ], + "optional": false, + "loc": { + "start": { + "line": 26, + "column": 19, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 26, + "column": 36, + "program": "switch_enum_string_case.sts" + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 19, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 26, + "column": 37, + "program": "switch_enum_string_case.sts" + } + } + }, + { + "type": "BreakStatement", + "label": null, + "loc": { + "start": { + "line": 26, + "column": 38, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 26, + "column": 44, + "program": "switch_enum_string_case.sts" + } + } + } + ], "loc": { "start": { - "line": 20, - "column": 1, + "line": 26, + "column": 5, "program": "switch_enum_string_case.sts" }, "end": { - "line": 20, - "column": 1, + "line": 26, + "column": 44, "program": "switch_enum_string_case.sts" } } }, - "arguments": [ - { - "type": "BinaryExpression", - "operator": "+", - "left": { - "type": "StringLiteral", - "value": "No enum constant in Enum with ordinal value ", + { + "type": "SwitchCase", + "test": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Enum", + "decorators": [], "loc": { "start": { - "line": 20, - "column": 1, + "line": 27, + "column": 10, "program": "switch_enum_string_case.sts" }, "end": { - "line": 20, - "column": 1, + "line": 27, + "column": 14, "program": "switch_enum_string_case.sts" } } }, - "right": { + "property": { "type": "Identifier", - "name": "ordinal", + "name": "e3", "decorators": [], "loc": { "start": { - "line": 20, - "column": 1, + "line": 27, + "column": 15, "program": "switch_enum_string_case.sts" }, "end": { - "line": 20, - "column": 1, + "line": 27, + "column": 17, "program": "switch_enum_string_case.sts" } } }, + "computed": false, + "optional": false, "loc": { "start": { - "line": 20, - "column": 1, + "line": 27, + "column": 10, "program": "switch_enum_string_case.sts" }, "end": { - "line": 20, - "column": 1, + "line": 27, + "column": 17, "program": "switch_enum_string_case.sts" } } - } - ], - "loc": { - "start": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" }, - "end": { - "line": 20, - "column": 1, - "program": "switch_enum_string_case.sts" + "consequent": [ + { + "type": "BreakStatement", + "label": null, + "loc": { + "start": { + "line": 27, + "column": 20, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 27, + "column": 26, + "program": "switch_enum_string_case.sts" + } + } + } + ], + "loc": { + "start": { + "line": 27, + "column": 5, + "program": "switch_enum_string_case.sts" + }, + "end": { + "line": 27, + "column": 26, + "program": "switch_enum_string_case.sts" + } } } - }, + ], "loc": { "start": { - "line": 20, - "column": 1, + "line": 24, + "column": 3, "program": "switch_enum_string_case.sts" }, "end": { - "line": 20, - "column": 1, + "line": 28, + "column": 4, "program": "switch_enum_string_case.sts" } } @@ -5714,40 +5532,39 @@ ], "loc": { "start": { - "line": 20, - "column": 1, + "line": 22, + "column": 17, "program": "switch_enum_string_case.sts" }, "end": { - "line": 20, - "column": 1, + "line": 29, + "column": 2, "program": "switch_enum_string_case.sts" } } }, - "throwMarker": "throws", "loc": { "start": { - "line": 20, - "column": 1, + "line": 22, + "column": 10, "program": "switch_enum_string_case.sts" }, "end": { - "line": 20, - "column": 1, + "line": 29, + "column": 2, "program": "switch_enum_string_case.sts" } } }, "loc": { "start": { - "line": 20, - "column": 1, + "line": 22, + "column": 10, "program": "switch_enum_string_case.sts" }, "end": { - "line": 20, - "column": 1, + "line": 29, + "column": 2, "program": "switch_enum_string_case.sts" } } @@ -5756,13 +5573,13 @@ "decorators": [], "loc": { "start": { - "line": 20, + "line": 22, "column": 1, "program": "switch_enum_string_case.sts" }, "end": { - "line": 20, - "column": 1, + "line": 29, + "column": 2, "program": "switch_enum_string_case.sts" } } @@ -5770,12 +5587,12 @@ ], "loc": { "start": { - "line": 20, + "line": 1, "column": 1, "program": "switch_enum_string_case.sts" }, "end": { - "line": 20, + "line": 1, "column": 1, "program": "switch_enum_string_case.sts" } @@ -5785,12 +5602,12 @@ "start": { "line": 1, "column": 1, - "program": null + "program": "switch_enum_string_case.sts" }, "end": { "line": 1, "column": 1, - "program": null + "program": "switch_enum_string_case.sts" } } } diff --git a/ets2panda/test/runtime/ets/Enum3.sts b/ets2panda/test/runtime/ets/Enum3.sts index bfad9f472f..bd2ed174d6 100644 --- a/ets2panda/test/runtime/ets/Enum3.sts +++ b/ets2panda/test/runtime/ets/Enum3.sts @@ -53,9 +53,9 @@ function main(): void { try { let x = 5 as Color; - assertTrue(false) - } catch (e: Exception) { - assertTrue((e as Object).toString().startsWith("No enum constant in Color with ordinal value 5")) + assertTrue( false) + } catch (e: Error) { + assertTrue( (e as Object).toString().startsWith("Error: No enum Color with value 5")) } assertEQ(2 as Color as int, 2) diff --git a/ets2panda/test/runtime/ets/Enum4.sts b/ets2panda/test/runtime/ets/Enum4.sts index 2d6c6c62cc..d32d2d8018 100644 --- a/ets2panda/test/runtime/ets/Enum4.sts +++ b/ets2panda/test/runtime/ets/Enum4.sts @@ -62,12 +62,12 @@ function main(): void { //cons.print( "Ordinal (as int): Color.Red = " + Color.Red as int + ", = Red = " + red1 as int + ", ValueOf(Red) = " + red2 as int + "\n") //cons.print( "ToString: Color.Red = '" + Color.Red.toString() + "', = Red = '" + red1.toString() + "', ValueOf(Red) = '" + red2.toString() + "'\n") - assertEQ(red1 as int, 1) + assertEQ(red1 as int, 2) assertEQ(red1.valueOf(), 2) assertEQ(red1.getName(), "Red") assertEQ(red1.toString(), "2") - assertEQ(red2 as int, 1) + assertEQ(red2 as int, 2) assertEQ(red2.valueOf(), 2) assertEQ(red2.getName(), "Red") assertEQ(red2.toString(), "2") @@ -76,18 +76,18 @@ function main(): void { assertEQ(red2, Color.Red) assertEQ(red2, red1) - let ord: int = 2; + let ord: int = 3; blue = ord as Color; - assertEQ(blue as int, 2) + assertEQ(blue as int, 3) assertEQ(blue.valueOf(), 3) assertEQ(blue.getName(), "Blue") assertEQ(blue.toString(), "3") try { let yellow: Color = Color.getValueOf("Yellow"); - assertTrue(false) - } catch (e: Exception) { - assertTrue((e as Object).toString().startsWith("No enum constant Color.Yellow")) + assertTrue( false) + } catch (e: Error) { + assertTrue( (e as Object).toString().startsWith("Error: No enum constant Color.Yellow")) } catch (e) {} ord = 0; @@ -97,14 +97,14 @@ function main(): void { try { let x = 5 as Color; - assertTrue(false) - } catch (e: Exception) { - assertTrue((e as Object).toString().startsWith("No enum constant in Color with ordinal value 5")) + assertTrue( false) + } catch (e: Error) { + assertTrue( (e as Object).toString().startsWith("Error: No enum Color with value 5")) } - assertEQ(2 as Color as int, 2) - assertEQ(Color.Blue as int as Color, Color.Blue) - assertEQ((Color.Green as int + 1) as Color, (Color.Blue as int - 1) as Color) + assertEQ( 2 as Color as int, 2) + assertEQ( Color.Blue as int as Color, Color.Blue) + assertEQ( (Color.Green as int + 2) as Color, (Color.Blue as int - 1) as Color) try { assertEQ((Color.Green as int + 1) as Color, Color.getValueOf("Red")) } catch (e) { diff --git a/ets2panda/test/runtime/ets/Enum5.sts b/ets2panda/test/runtime/ets/Enum5.sts index 2500e55dbd..3f09399777 100644 --- a/ets2panda/test/runtime/ets/Enum5.sts +++ b/ets2panda/test/runtime/ets/Enum5.sts @@ -14,7 +14,6 @@ */ enum Color { Green = "red" , Red = "blue", Blue = "green" } -//let cons = new Console; function main(): void { @@ -23,7 +22,6 @@ function main(): void { let value:string = Color.getValueOf("Blue").toString(); assertEQ(name, "Blue") assertEQ(value, "green") - //cons.print(name + " = " + value + c'\n'); } catch (e) { assertTrue((e as Object).toString().startsWith("No enum constant Color.Blue")) } @@ -33,9 +31,8 @@ function main(): void { let blue = Color.Blue; let str = blue.getName(); - //cons.print("Color.Blue = '" + str + "'\n"); - assertEQ("Blue", str) - assertEQ(blue.valueOf(), blue.toString()) + assertEQ( "Blue", str) + assertEQ( blue.valueOf(), blue.toString()) let values = Color.values(); assertEQ(values.length, 3) @@ -45,30 +42,23 @@ function main(): void { let red1: Color = Color.Red; let red2: Color = Color.Green; - assertEQ(red2 as int, 0) + assertEQ(red2 as string, "red") assertEQ(red2.valueOf(), "red") assertEQ(red2.getName(), "Green") assertEQ(red2.toString(), "red") - //cons.print("\nDefault ordinal = " + red2 as int + ", value = " + red2.valueOf() + ", name: '" + red2.getName() + "', ToString: '" + red2.toString() + "'\n\n") - + try { red2 = Color.getValueOf("Red"); } catch (e) { - assertTrue((e as Object).toString().startsWith("No enum constant Color.Red")) - //cons.print(e.toString() + "\n"); + assertTrue( (e as Object).toString().startsWith("No enum constant Color.Red")) } - //cons.print( "GetName: Color.Red: '" + Color.Red.getName() + "', = Red: '" + red1.getName() + "', ValueOf(Red): '" + red2.getName() + "'\n") - //cons.print( "GetValue: Color.Red = " + Color.Red.valueOf() + ", = Red = " + red1.valueOf() + ", getValueOf(Red) = " + red2.valueOf() + "\n") - //cons.print( "Ordinal (as int): Color.Red = " + Color.Red as int + ", = Red = " + red1 as int + ", getValueOf(Red) = " + red2 as int + "\n") - //cons.print( "ToString: Color.Red = '" + Color.Red.toString() + "', = Red = '" + red1.toString() + "', getValueOf(Red) = '" + red2.toString() + "'\n") - - assertEQ(red1 as int, 1) + assertEQ(red1 as string, "blue") assertEQ(red1.valueOf(), "blue") assertEQ(red1.getName(), "Red") assertEQ(red1.toString(), "blue") - assertEQ(red2 as int, 1) + assertEQ(red2 as string, "blue") assertEQ(red2.valueOf(), "blue") assertEQ(red2.getName(), "Red") assertEQ(red2.toString(), "blue") @@ -77,9 +67,9 @@ function main(): void { assertEQ(red2, Color.Red) assertEQ(red2, red1) - let ord: int = 2; + let ord: string = "green"; blue = ord as Color; - assertEQ(blue as int, 2) + assertEQ(blue as string, "green") assertEQ(blue.valueOf(), "green") assertEQ(blue.getName(), "Blue") assertEQ(blue.toString(), "green") @@ -91,23 +81,21 @@ function main(): void { assertTrue((e as Object).toString().startsWith("No enum constant Color.Yellow")) } catch (e) {} - ord = 0; + ord = "red"; let green: Color = ord as Color; - //cons.print("Green = " + green as int + ", Color.Green = " + Color.Green as int + "\n") - assertEQ(green, Color.Green) + assertEQ( green, Color.Green) try { - let x = 5 as Color; - assertTrue(false) - } catch (e: Exception) { - assertTrue((e as Object).toString().startsWith("No enum constant in Color with ordinal value 5")) + let x = "a" as Color; + assertTrue( false) + } catch (e: Error) { + assertTrue( (e as Object).toString().startsWith("Error: No enum Color with value a")) } - assertEQ(2 as Color as int, 2) - assertEQ(Color.Blue as int as Color, Color.Blue) - assertEQ((Color.Green as int + 1) as Color, (Color.Blue as int - 1) as Color) + assertEQ( "red" as Color as string, "red") + assertEQ( Color.Blue as string as Color, Color.Blue) try { - assertEQ((Color.Green as int + 1) as Color, Color.getValueOf("Red")) + assertEQ( (Color.Green as string) as Color, Color.getValueOf("red")) } catch (e) { } } diff --git a/ets2panda/test/runtime/ets/Enum8.sts b/ets2panda/test/runtime/ets/Enum8.sts new file mode 100644 index 0000000000..48b348a017 --- /dev/null +++ b/ets2panda/test/runtime/ets/Enum8.sts @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2024-2025 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. + */ + +enum StringEnum { + A = "Apple", + B = "Banana", + C = "Cherry" +} + +enum IntEnum { + One = 1, + Two = 2, + Three = 3, + Four = 4 +} + +enum ColorEnum { + Red = 5, + Green = 10, + Blue = 15 +} + +enum StatusEnum { + Active = 1, + Inactive = 0 +} + +enum TemperatureEnum { + Cold = 0, + Warm = 20, + Hot = 40 +} + +enum PermissionEnum { + Read = 1, + Write = 2, + Execute = 4 +} + +enum NumberEnum { + Ten = 10, + Twenty = 20, + Thirty = 30 +} + +enum VolumeEnum { + Low = 1, + Medium = 2, + High = 3 +} + +function main() { + assertEQ(StringEnum.A + StringEnum.B, "AppleBanana"); + assertTrue(StringEnum.A < StringEnum.B); + assertTrue(StringEnum.A !== StringEnum.B); + assertTrue(StringEnum.C > StringEnum.A); + + assertEQ(IntEnum.One + IntEnum.Two, 3); + assertEQ(IntEnum.Three - IntEnum.One, 2); + assertEQ(IntEnum.Four * IntEnum.Two, 8); + assertEQ(IntEnum.Four / IntEnum.Two, 2); + + assertEQ(ColorEnum.Red + ColorEnum.Green, 15); + assertEQ(ColorEnum.Blue - ColorEnum.Green > 0 ? "Greater" : "Smaller", "Greater"); + + let status = StatusEnum.Active; + assertTrue(status === StatusEnum.Active); + assertTrue(status !== StatusEnum.Inactive); + + status = StatusEnum.Inactive; + assertTrue(status === StatusEnum.Inactive); + + assertEQ(Number(TemperatureEnum.Cold) + 10, 10); + assertEQ(Number(TemperatureEnum.Warm) * 2, 40); + + assertTrue((PermissionEnum.Read & PermissionEnum.Write) === 0); + assertTrue((PermissionEnum.Read | PermissionEnum.Execute) === 5); + assertTrue((PermissionEnum.Read ^ PermissionEnum.Write) === 3); + + assertEQ(NumberEnum.Ten + 10, 20); + assertEQ(NumberEnum.Twenty - 10, 10); + assertEQ(NumberEnum.Thirty * 2, 60); + assertEQ(NumberEnum.Twenty / 2, 10); + let volumeLevel = VolumeEnum.Medium; + let message = volumeLevel === VolumeEnum.Low ? "Low Volume" : (volumeLevel === VolumeEnum.Medium ? "Medium Volume" : "High Volume"); + assertEQ(message, "Medium Volume"); +} diff --git a/ets2panda/test/runtime/ets/enum_as_expression_cast.sts b/ets2panda/test/runtime/ets/enum_as_expression_cast.sts index 89ad094d4b..6ae7f5e5ce 100644 --- a/ets2panda/test/runtime/ets/enum_as_expression_cast.sts +++ b/ets2panda/test/runtime/ets/enum_as_expression_cast.sts @@ -20,9 +20,9 @@ enum E { function main() { assertEQ(E.A.toString(), "100") // E.A.toString() - assertEQ(E.A as int, 0) // cast(E.A) to int, E.A is a index + assertEQ(E.A as int, 100) // cast(E.A) to int, E.A is a index assertEQ(E.B.toString(), "200") // E.B.toString() - assertEQ(E.B as number, 1) // cast(E.B) to number, E.B is a index + assertEQ(E.B as number, 200) // cast(E.B) to number, E.B is a index assertEQ(E.A.valueOf() as int, 100) // get value of E.A assertEQ(E.B.valueOf() as number, 200) // get value of E.B } \ No newline at end of file diff --git a/ets2panda/test/ast/compiler/ets/enum_as_type_alias.sts b/ets2panda/test/runtime/ets/enum_as_type_alias.sts similarity index 75% rename from ets2panda/test/ast/compiler/ets/enum_as_type_alias.sts rename to ets2panda/test/runtime/ets/enum_as_type_alias.sts index 0b8bd8357c..cf2e08b678 100644 --- a/ets2panda/test/ast/compiler/ets/enum_as_type_alias.sts +++ b/ets2panda/test/runtime/ets/enum_as_type_alias.sts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2025 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 @@ -18,8 +18,7 @@ type BaseColor = Color; function main(): void { let a: Color = Color.Red; // OK - let v: BaseColor = BaseColor./* @@ label */Red; // TypeError, bc 'BaseColor' is type alias + let v: int = BaseColor.Red; + assertEQ(v, 0); } - -/* @@@ label Error TypeError: Cannot refer to enum members through type alias. */ diff --git a/ets2panda/test/runtime/ets/enum_getOrdinal.sts b/ets2panda/test/runtime/ets/enum_getOrdinal.sts new file mode 100644 index 0000000000..f1e0276697 --- /dev/null +++ b/ets2panda/test/runtime/ets/enum_getOrdinal.sts @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 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. + */ + +enum Color { + A, B, C +} + +function main() { + assertEQ(Color.A.getOrdinal(), 0); + assertEQ(Color.B.getOrdinal(), 1) + assertEQ(Color.C.getOrdinal(), 2) +} \ No newline at end of file diff --git a/ets2panda/test/runtime/ets/enum_namespace.sts b/ets2panda/test/runtime/ets/enum_namespace.sts new file mode 100644 index 0000000000..bdf8ddde58 --- /dev/null +++ b/ets2panda/test/runtime/ets/enum_namespace.sts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 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. + */ + +export namespace NSOuter { + export namespace NSInner { + export enum XXXType { + TAP = 0, + PAT = 1 + } + } +} +class A {} +class B {} + +type XXXType = A | B + +function foo(a : boolean) : NSOuter.NSInner.XXXType | number | string { + if (a) { + return NSOuter.NSInner.XXXType.TAP + } + return 0 +} + +function main() { + const res : NSOuter.NSInner.XXXType = foo(true) as NSOuter.NSInner.XXXType + assertEQ(res, NSOuter.NSInner.XXXType.TAP) + const res1 : NSOuter.NSInner.XXXType = 1 as NSOuter.NSInner.XXXType + assertEQ(res1, NSOuter.NSInner.XXXType.PAT) +} diff --git a/ets2panda/test/runtime/ets/enum_reference.sts b/ets2panda/test/runtime/ets/enum_reference.sts new file mode 100644 index 0000000000..e7951c5105 --- /dev/null +++ b/ets2panda/test/runtime/ets/enum_reference.sts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 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. + */ + +enum Color { Red } +enum Color2 { Red } + +function main(): void { + assertNE(Color.Red, Color2.Red) +} diff --git a/ets2panda/test/runtime/ets/enum_switch.sts b/ets2panda/test/runtime/ets/enum_switch.sts new file mode 100644 index 0000000000..be22757d0a --- /dev/null +++ b/ets2panda/test/runtime/ets/enum_switch.sts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 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. + */ + +namespace A { + export namespace B { + export enum Color { + A, B + } + } +} + +function main() { + switch(A.B.Color.A) { + case A.B.Color.A: + assertTrue(true) + break; + case A.B.Color.B: + assertTrue(false) + break; + default: + assertTrue(false) + break; + } +} diff --git a/ets2panda/test/runtime/ets/enum_union.sts b/ets2panda/test/runtime/ets/enum_union.sts new file mode 100644 index 0000000000..e24460420b --- /dev/null +++ b/ets2panda/test/runtime/ets/enum_union.sts @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2025 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. + */ + +enum Color { + Red = "aaa", + Yellow = "bbb", +} +enum ColorInt { + A = 1111, + B = 2222 +} + +function foo(b : boolean) : int | Color | string | ColorInt { + if (b) { + return 1111; + } + return Color.Red; +} + +function foo1(b : boolean) : int | Color | string | ColorInt { + if (b) { + return "bbb"; + } + return ColorInt.B; +} + +function testOptional(b ?: ColorInt | int | string) : int { + const v1 : int = b ? b as int : 0; + return v1; +} + +function main() { + const v1: Color = foo(false) as Color + const v2: ColorInt = foo(true) as ColorInt + const v3: string = foo(false) as string + const v4: int = foo1(false) as int + const v5: Color = foo1(true) as Color + const v6: ColorInt = foo1(false) as ColorInt + + assertEQ(v1, Color.Red) + assertEQ(v2, ColorInt.A) + assertEQ(v3, "aaa") + assertEQ(v4, 2222) + assertEQ(v5, Color.Yellow) + assertEQ(v6, ColorInt.B) + + const a : Color | string | boolean = Color.Red + const b : string | Color | boolean = Color.Red + assertEQ(a, Color.Red) + assertEQ(b, Color.Red) + + assertEQ(testOptional(ColorInt.A), 1111) + assertEQ(testOptional(), 0); +} diff --git a/ets2panda/test/test-lists/declgenets2ts/ets-runtime/declgen-ets2ts-runtime-ignored.txt b/ets2panda/test/test-lists/declgenets2ts/ets-runtime/declgen-ets2ts-runtime-ignored.txt index a6ff61e436..d4ab9cc516 100644 --- a/ets2panda/test/test-lists/declgenets2ts/ets-runtime/declgen-ets2ts-runtime-ignored.txt +++ b/ets2panda/test/test-lists/declgenets2ts/ets-runtime/declgen-ets2ts-runtime-ignored.txt @@ -33,6 +33,7 @@ enum-switch-statement.sts enum-to-string-conversion.sts enum-typeof.sts enum_string_init.sts +enum_switch.sts generics_1.sts # FailKind.TSC_FAIL @@ -71,6 +72,7 @@ DefaultParam_4.sts DefaultParam_5.sts Enum.sts Enum2.sts +enum_namespace.sts FunctionOverload.sts FunctionType.sts GenericArray_1.sts diff --git a/ets2panda/test/unit/lsp/classifier_test.cpp b/ets2panda/test/unit/lsp/classifier_test.cpp index 9aa145bac5..c630e764ea 100644 --- a/ets2panda/test/unit/lsp/classifier_test.cpp +++ b/ets2panda/test/unit/lsp/classifier_test.cpp @@ -379,7 +379,8 @@ TEST_F(LspClassificationTests, GetSemanticClassifications3) size_t const length = 5; auto result = ark::es2panda::lsp::GetSemanticClassifications(ctx, start, length); const size_t expectedCount = 1; - std::string expectedName = "enum name"; + // Enum was transformed to class before checker phase + std::string expectedName = "class name"; ASSERT_EQ(result.size(), expectedCount); ASSERT_EQ(result.at(0)->start, start); ASSERT_EQ(result.at(0)->length, length); diff --git a/ets2panda/test/unit/lsp/get_completions.cpp b/ets2panda/test/unit/lsp/get_completions.cpp index 82fa8db6b1..6b13fcd8d2 100644 --- a/ets2panda/test/unit/lsp/get_completions.cpp +++ b/ets2panda/test/unit/lsp/get_completions.cpp @@ -241,29 +241,3 @@ let numOfSpace: space.classi)delimiter"}; std::string(ark::es2panda::lsp::sort_text::MEMBER_DECLARED_BY_SPREAD_ASSIGNMENT)); ASSERT_EQ(entry1, entries[0]); } - -TEST_F(LSPCompletionsTests, MemberCompletionsForClassTest4) -{ - std::vector files = {"getCompletionsAtPosition6.sts"}; - std::vector texts = {R"delimiter( -enum Color { - Red = "red", - Blue = "blue" -} -let myColor: Color = Color.R)delimiter"}; - auto filePaths = CreateTempFile(files, texts); - int const expectedFileCount = 1; - ASSERT_EQ(filePaths.size(), expectedFileCount); - - LSPAPI const *lspApi = GetImpl(); - const size_t offset = 74; - auto res = lspApi->getCompletionsAtPosition(filePaths[0].c_str(), offset); - auto entries = res.GetEntries(); - ASSERT_TRUE(entries.size() == 1); - - std::string propertyName1 = "Red"; - CompletionEntry entry1 = - CompletionEntry(propertyName1, CompletionEntryKind::ENUM_MEMBER, - std::string(ark::es2panda::lsp::sort_text::MEMBER_DECLARED_BY_SPREAD_ASSIGNMENT)); - ASSERT_EQ(entry1, entries[0]); -} \ No newline at end of file diff --git a/ets2panda/test/unit/lsp/lsp_rename_test.cpp b/ets2panda/test/unit/lsp/lsp_rename_test.cpp index fc0df03512..663b7846fb 100644 --- a/ets2panda/test/unit/lsp/lsp_rename_test.cpp +++ b/ets2panda/test/unit/lsp/lsp_rename_test.cpp @@ -467,20 +467,3 @@ TEST_F(LspRenameInfoTests, RenameInfoNodeIsEligibleForRenameStringLiteral) ASSERT_TRUE(ark::es2panda::lsp::NodeIsEligibleForRename(targetNode)); initializer.DestroyContext(ctx); } - -TEST_F(LspRenameInfoTests, RenameInfoNodeIsEligibleForRenameNumberLiteralEnumMember) -{ - Initializer initializer = Initializer(); - es2panda_Context *ctx = initializer.CreateContext("trigger-span-literal.sts", ES2PANDA_STATE_CHECKED, - "enum MyEnum { FixedValue = 42 }"); - ASSERT_EQ(ContextState(ctx), ES2PANDA_STATE_CHECKED); - - auto ast = GetAstFromContext(ctx); - auto targetNode = ast->FindChild([](ark::es2panda::ir::AstNode *node) { - return node->IsNumberLiteral() && node->AsNumberLiteral()->Str() == "42"; - }); - - ASSERT_NE(targetNode, nullptr); - ASSERT_FALSE(ark::es2panda::lsp::NodeIsEligibleForRename(targetNode)); - initializer.DestroyContext(ctx); -} diff --git a/ets2panda/test/unit/lsp/quick_info_test.cpp b/ets2panda/test/unit/lsp/quick_info_test.cpp index d59eb2a218..f3f487eb4e 100644 --- a/ets2panda/test/unit/lsp/quick_info_test.cpp +++ b/ets2panda/test/unit/lsp/quick_info_test.cpp @@ -36,23 +36,21 @@ TEST_F(LspQuickInfoTests, GetQuickInfoAtPosition1) ASSERT_NE(quickInfo, QuickInfo()); std::vector tags {}; std::vector document {}; - const std::string kind; + const std::string kind = "property"; size_t const start = 17; size_t const length = 1; TextSpan span(start, length); - const std::string kindModifiers; + const std::string kindModifiers = "static public readonly"; const std::string expectedFileName = "/tmp/quick_info3.sts"; std::vector expected; - expected.emplace_back("MyStrings", "enumName"); + // Enum was transformed to class, enum member becomes class property MyStrings.A : MyStrings + expected.emplace_back("MyStrings", "className"); expected.emplace_back(".", "punctuation"); - expected.emplace_back("A", "enumMember"); - expected.emplace_back(" ", "space"); - expected.emplace_back("=", "operator"); + expected.emplace_back("A", "property"); + expected.emplace_back(":", "punctuation"); expected.emplace_back(" ", "space"); - expected.emplace_back("\"", "punctuation"); - expected.emplace_back("hello", "text"); - expected.emplace_back("\"", "punctuation"); + expected.emplace_back("MyStrings", "typeName"); auto expectedQuickInfo = QuickInfo(kind, kindModifiers, span, expected, document, tags, expectedFileName); ASSERT_EQ(quickInfo, expectedQuickInfo); @@ -260,88 +258,17 @@ TEST_F(LspQuickInfoTests, GetNodeAtLocationForQuickInfo5) ASSERT_NE(node, nullptr); auto nodeAtLocationForQuickInfo = ark::es2panda::lsp::GetNodeAtLocationForQuickInfo(node); ASSERT_NE(nodeAtLocationForQuickInfo, nullptr); - ASSERT_EQ(nodeAtLocationForQuickInfo->Type(), ark::es2panda::ir::AstNodeType::TS_ENUM_DECLARATION); + // Enum was transformed to class before checker phase + ASSERT_EQ(nodeAtLocationForQuickInfo->Type(), ark::es2panda::ir::AstNodeType::CLASS_DEFINITION); size_t const position = 70; node = ark::es2panda::lsp::GetTokenForQuickInfo(ctx, position); ASSERT_NE(node, nullptr); nodeAtLocationForQuickInfo = ark::es2panda::lsp::GetNodeAtLocationForQuickInfo(node); ASSERT_NE(nodeAtLocationForQuickInfo, nullptr); - ASSERT_EQ(nodeAtLocationForQuickInfo->Type(), ark::es2panda::ir::AstNodeType::TS_ENUM_DECLARATION); - - initializer.DestroyContext(ctx); -} - -TEST_F(LspQuickInfoTests, CreateDisplayForEnumMemberWithNumberLiteral) -{ - Initializer initializer = Initializer(); - es2panda_Context *ctx = initializer.CreateContext("enum-member-test.sts", ES2PANDA_STATE_CHECKED, - "enum MyEnum { First = 1, Second = 2 }"); - ASSERT_EQ(ContextState(ctx), ES2PANDA_STATE_CHECKED); - auto context = reinterpret_cast(ctx); - auto ast = reinterpret_cast(context->parserProgram->Ast()); - auto checkFunc = [](ark::es2panda::ir::AstNode *node) { - return node->Type() == ark::es2panda::ir::AstNodeType::TS_ENUM_MEMBER; - }; - auto found = ast->FindChild(checkFunc); - std::vector display = ark::es2panda::lsp::CreateDisplayForEnumMember(found); - std::vector expected; - expected.emplace_back("MyEnum", "enumName"); - expected.emplace_back(".", "punctuation"); - expected.emplace_back("First", "enumMember"); - expected.emplace_back(" ", "space"); - expected.emplace_back("=", "operator"); - expected.emplace_back(" ", "space"); - expected.emplace_back("1", "text"); - ASSERT_EQ(expected, display); - initializer.DestroyContext(ctx); -} - -TEST_F(LspQuickInfoTests, CreateDisplayForEnumMemberWithStringLiteral) -{ - Initializer initializer = Initializer(); - es2panda_Context *ctx = initializer.CreateContext("enum-member-string-test.sts", ES2PANDA_STATE_CHECKED, - "enum MyStrings { A = 'hello' }"); - ASSERT_EQ(ContextState(ctx), ES2PANDA_STATE_CHECKED); - auto context = reinterpret_cast(ctx); - auto ast = reinterpret_cast(context->parserProgram->Ast()); - auto checkFunc = [](ark::es2panda::ir::AstNode *node) { - return node->Type() == ark::es2panda::ir::AstNodeType::TS_ENUM_MEMBER; - }; - auto found = ast->FindChild(checkFunc); - std::vector display = ark::es2panda::lsp::CreateDisplayForEnumMember(found); - std::vector expected; - expected.emplace_back("MyStrings", "enumName"); - expected.emplace_back(".", "punctuation"); - expected.emplace_back("A", "enumMember"); - expected.emplace_back(" ", "space"); - expected.emplace_back("=", "operator"); - expected.emplace_back(" ", "space"); - expected.emplace_back("\"", "punctuation"); - expected.emplace_back("hello", "text"); - expected.emplace_back("\"", "punctuation"); - ASSERT_EQ(expected, display); - initializer.DestroyContext(ctx); -} + // Enum was transformed to class before checker phase + ASSERT_EQ(nodeAtLocationForQuickInfo->Type(), ark::es2panda::ir::AstNodeType::CLASS_DEFINITION); -TEST_F(LspQuickInfoTests, CreateDisplayForEnum) -{ - Initializer initializer = Initializer(); - es2panda_Context *ctx = - initializer.CreateContext("enum-test.sts", ES2PANDA_STATE_CHECKED, "enum MyEnum { A, B, C }"); - ASSERT_EQ(ContextState(ctx), ES2PANDA_STATE_CHECKED); - auto context = reinterpret_cast(ctx); - auto ast = reinterpret_cast(context->parserProgram->Ast()); - auto checkFunc = [](ark::es2panda::ir::AstNode *node) { - return node->Type() == ark::es2panda::ir::AstNodeType::TS_ENUM_DECLARATION; - }; - auto found = ast->FindChild(checkFunc); - std::vector display = ark::es2panda::lsp::CreateDisplayForEnum(found); - std::vector expected; - expected.emplace_back("enum", "keyword"); - expected.emplace_back(" ", "space"); - expected.emplace_back("MyEnum", "enumName"); - ASSERT_EQ(expected, display); initializer.DestroyContext(ctx); } diff --git a/ets2panda/test/unit/plugin_conversion_rule/plugin_conversion_rule_part_iv.cpp b/ets2panda/test/unit/plugin_conversion_rule/plugin_conversion_rule_part_iv.cpp index a18ad8971d..5b8286e4ae 100644 --- a/ets2panda/test/unit/plugin_conversion_rule/plugin_conversion_rule_part_iv.cpp +++ b/ets2panda/test/unit/plugin_conversion_rule/plugin_conversion_rule_part_iv.cpp @@ -462,23 +462,4 @@ TEST_F(PluginConversionRuleUnitTest, TSInterfaceDeclarationConstructorDataInputP std::string targetAPIWithNoSpace = RemoveWhitespace(targetCAPI); EXPECT_TRUE(HasMatched(targetAPIWithNoSpace)); } - -// apiName: ETSEnumTypeSetToStringMethod -TEST_F(PluginConversionRuleUnitTest, CheckerMethodInputParameter) -{ - std::string targetCAPI {R"( - extern "C" void ETSEnumTypeSetToStringMethod([[maybe_unused]] es2panda_Context *context, - es2panda_Type *classInstance, [[maybe_unused]] es2panda_Signature *globalSignature, - es2panda_Type *memberProxyType/*return_args:*/) - { - auto es2pandaGlobalSignature = reinterpret_cast(globalSignature); - auto es2pandaMemberProxyType = reinterpret_cast(memberProxyType); - - ((reinterpret_cast< checker::ETSEnumType *>(classInstance))->SetToStringMethod(checker::ETSEnumType::Method - {es2pandaGlobalSignature, es2pandaMemberProxyType})); - })"}; - - std::string targetAPIWithNoSpace = RemoveWhitespace(targetCAPI); - EXPECT_TRUE(HasMatched(targetAPIWithNoSpace)); -} } // namespace ark::es2panda -- Gitee