diff --git a/ets2panda/BUILD.gn b/ets2panda/BUILD.gn index 14a3b74899ba38ec3d58bc74ee972a6d2b95b551..531a36858f38ece9bf54f3cf1d21feb68c8c6e28 100644 --- a/ets2panda/BUILD.gn +++ b/ets2panda/BUILD.gn @@ -27,6 +27,24 @@ config("libes2panda_public_config") { } libes2panda_sources = [ + "ast_verifier/ASTVerifier.cpp", + "ast_verifier/arithmeticOperationValid.cpp", + "ast_verifier/checkContext.cpp", + "ast_verifier/everyChildHasValidParent.cpp", + "ast_verifier/everyChildInParentRange.cpp", + "ast_verifier/forLoopCorrectlyInitialized.cpp", + "ast_verifier/helpers.cpp", + "ast_verifier/identifierHasVariable.cpp", + "ast_verifier/importExportAccessValid.cpp", + "ast_verifier/modifierAccessValid.cpp", + "ast_verifier/nodeHasParent.cpp", + "ast_verifier/nodeHasSourceRange.cpp", + "ast_verifier/nodeHasType.cpp", + "ast_verifier/referenceTypeAnnotationIsNull.cpp", + "ast_verifier/sequenceExpressionHasLastType.cpp", + "ast_verifier/variableHasEnclosingScope.cpp", + "ast_verifier/variableHasScope.cpp", + "ast_verifier/variableNameIdentifierNameSame.cpp", "checker/ASchecker.cpp", "checker/ETSAnalyzer.cpp", "checker/ETSAnalyzerHelpers.cpp", @@ -137,7 +155,6 @@ libes2panda_sources = [ "compiler/base/literals.cpp", "compiler/base/lreference.cpp", "compiler/base/optionalChain.cpp", - "compiler/core/ASTVerifier.cpp", "compiler/core/ETSCompiler.cpp", "compiler/core/ETSGen.cpp", "compiler/core/ETSemitter.cpp", @@ -174,8 +191,10 @@ libes2panda_sources = [ "compiler/lowering/ets/constStringToCharLowering.cpp", "compiler/lowering/ets/defaultParameterLowering.cpp", "compiler/lowering/ets/enumLowering.cpp", + "compiler/lowering/ets/enumPostCheckLowering.cpp", "compiler/lowering/ets/expandBrackets.cpp", "compiler/lowering/ets/expressionLambdaLowering.cpp", + "compiler/lowering/ets/interfaceObjectLiteralLowering.cpp", "compiler/lowering/ets/interfacePropertyDeclarations.cpp", "compiler/lowering/ets/lambdaLowering.cpp", "compiler/lowering/ets/localClassLowering.cpp", @@ -199,6 +218,7 @@ libes2panda_sources = [ "compiler/lowering/ets/unionLowering.cpp", "compiler/lowering/phase.cpp", "compiler/lowering/plugin_phase.cpp", + "compiler/lowering/resolveIdentifiers.cpp", "compiler/lowering/scopesInit/savedBindingsCtx.cpp", "compiler/lowering/scopesInit/scopesInitPhase.cpp", "compiler/lowering/util.cpp", @@ -401,6 +421,7 @@ libes2panda_sources = [ "util/arktsconfig.cpp", "util/bitset.cpp", "util/errorHandler.cpp", + "util/errorLogger.cpp", "util/helpers.cpp", "util/importPathManager.cpp", "util/path.cpp", diff --git a/ets2panda/CMakeLists.txt b/ets2panda/CMakeLists.txt index 270899a6b50bbf9379e0c090245d70ead6b8e745..925340ee002102df16d87f0efb51280d35be2dc4 100644 --- a/ets2panda/CMakeLists.txt +++ b/ets2panda/CMakeLists.txt @@ -110,6 +110,24 @@ panda_gen( ) set(ES2PANDA_LIB_SRC + ast_verifier/ASTVerifier.cpp + ast_verifier/arithmeticOperationValid.cpp + ast_verifier/checkContext.cpp + ast_verifier/everyChildHasValidParent.cpp + ast_verifier/everyChildInParentRange.cpp + ast_verifier/helpers.cpp + ast_verifier/identifierHasVariable.cpp + ast_verifier/importExportAccessValid.cpp + ast_verifier/nodeHasParent.cpp + ast_verifier/nodeHasSourceRange.cpp + ast_verifier/nodeHasType.cpp + ast_verifier/referenceTypeAnnotationIsNull.cpp + ast_verifier/forLoopCorrectlyInitialized.cpp + ast_verifier/modifierAccessValid.cpp + ast_verifier/sequenceExpressionHasLastType.cpp + ast_verifier/variableHasEnclosingScope.cpp + ast_verifier/variableHasScope.cpp + ast_verifier/variableNameIdentifierNameSame.cpp es2panda.cpp varbinder/ASBinder.cpp varbinder/TSBinder.cpp @@ -130,7 +148,6 @@ set(ES2PANDA_LIB_SRC compiler/base/literals.cpp compiler/base/lreference.cpp compiler/base/optionalChain.cpp - compiler/core/ASTVerifier.cpp compiler/core/codeGen.cpp compiler/core/compileJob.cpp compiler/core/compileQueue.cpp @@ -165,6 +182,7 @@ set(ES2PANDA_LIB_SRC compiler/lowering/scopesInit/scopesInitPhase.cpp compiler/lowering/phase.cpp compiler/lowering/plugin_phase.cpp + compiler/lowering/resolveIdentifiers.cpp compiler/lowering/util.cpp compiler/lowering/ets/topLevelStmts/importExportDecls.cpp compiler/lowering/ets/topLevelStmts/globalClassHandler.cpp @@ -192,9 +210,11 @@ set(ES2PANDA_LIB_SRC compiler/lowering/ets/structLowering.cpp compiler/lowering/ets/defaultParameterLowering.cpp compiler/lowering/ets/objectLiteralLowering.cpp + compiler/lowering/ets/interfaceObjectLiteralLowering.cpp compiler/lowering/ets/stringComparison.cpp compiler/lowering/ets/stringConstructorLowering.cpp compiler/lowering/ets/enumLowering.cpp + compiler/lowering/ets/enumPostCheckLowering.cpp ir/astDump.cpp ir/srcDump.cpp ir/astNode.cpp @@ -494,6 +514,7 @@ set(ES2PANDA_LIB_SRC util/arktsconfig.cpp util/bitset.cpp util/errorHandler.cpp + util/errorLogger.cpp util/helpers.cpp util/importPathManager.cpp util/path.cpp diff --git a/ets2panda/aot/main.cpp b/ets2panda/aot/main.cpp index d6db878c9a934d8555373b35e995c36d8ce2785b..2c916e6acad90692b4d4314b869cccb684fefa50 100644 --- a/ets2panda/aot/main.cpp +++ b/ets2panda/aot/main.cpp @@ -57,8 +57,11 @@ static int CompileFromSource(es2panda::Compiler &compiler, es2panda::SourceFile if (program == nullptr) { const auto &err = compiler.GetError(); - // Intentional exit or --parse-only option usage. if (err.Type() == ErrorType::INVALID) { + if (compiler.IsAnyError()) { + return 1; + } + // Intentional exit or --parse-only option usage. return 0; } diff --git a/ets2panda/ast_verifier/ASTVerifier.cpp b/ets2panda/ast_verifier/ASTVerifier.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ce6ccc59918913aa825799bd2934d2815d99b929 --- /dev/null +++ b/ets2panda/ast_verifier/ASTVerifier.cpp @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ASTVerifier.h" +#include "ast_verifier/helpers.h" +#include "ast_verifier/sequenceExpressionHasLastType.h" +#include "ast_verifier/checkContext.h" +#include "ast_verifier/everyChildHasValidParent.h" +#include "ast_verifier/everyChildInParentRange.h" +#include "ast_verifier/identifierHasVariable.h" +#include "ast_verifier/nodeHasParent.h" +#include "ast_verifier/nodeHasSourceRange.h" +#include "ast_verifier/nodeHasType.h" +#include "ast_verifier/referenceTypeAnnotationIsNull.h" +#include "ast_verifier/variableHasScope.h" +#include "ast_verifier/variableHasEnclosingScope.h" +#include "ast_verifier/forLoopCorrectlyInitialized.h" +#include "ast_verifier/modifierAccessValid.h" +#include "ast_verifier/importExportAccessValid.h" +#include "ast_verifier/arithmeticOperationValid.h" +#include "ast_verifier/variableNameIdentifierNameSame.h" + +namespace ark::es2panda::compiler::ast_verifier { + +ASTVerifier::ASTVerifier(ArenaAllocator *allocator) +{ + AddInvariant(allocator, "NodeHasParent"); + AddInvariant(allocator, "NodeHasSourceRange"); + AddInvariant(allocator, "NodeHasType"); + AddInvariant(allocator, "IdentifierHasVariable"); + AddInvariant(allocator, "VariableHasScope"); + AddInvariant(allocator, "EveryChildHasValidParent"); + AddInvariant(allocator, "EveryChildInParentRange"); + AddInvariant(allocator, "VariableHasEnclosingScope"); + AddInvariant(allocator, "ForLoopCorrectlyInitialized"); + AddInvariant(allocator, "ModifierAccessValid"); + AddInvariant(allocator, "ImportExportAccessValid"); + AddInvariant(allocator, "ArithmeticOperationValid"); + AddInvariant(allocator, "SequenceExpressionHasLastType"); + AddInvariant(allocator, "ReferenceTypeAnnotationIsNull"); + AddInvariant(allocator, "VariableNameIdentifierNameSame"); +} + +Messages ASTVerifier::VerifyFull(const ir::AstNode *ast) +{ + auto recursiveChecks = InvariantNameSet {}; + std::copy_if(invariantsNames_.begin(), invariantsNames_.end(), + std::inserter(recursiveChecks, recursiveChecks.end()), + [](const std::string &s) { return s.find(RECURSIVE_SUFFIX) != s.npos; }); + return Verify(ast, recursiveChecks); +} + +Messages ASTVerifier::Verify(const ir::AstNode *ast, const InvariantNameSet &invariantSet) +{ + CheckContext ctx {}; + const auto containsInvariants = + std::includes(invariantsNames_.begin(), invariantsNames_.end(), invariantSet.begin(), invariantSet.end()); + if (!containsInvariants) { + auto invalidInvariants = InvariantNameSet {}; + for (const auto &invariant : invariantSet) { + if (invariantsNames_.find(invariant) == invariantsNames_.end()) { + invalidInvariants.insert(invariant); + } + } + for (const auto &invariant : invalidInvariants) { + ctx.AddCheckMessage(std::string {"Invariant was not found: "} + invariant, *ast, lexer::SourcePosition {}); + } + } + + for (const auto &name : invariantSet) { + if (const auto &found = invariantsChecks_.find(name); found != invariantsChecks_.end()) { + if (ast == nullptr) { + continue; + } + + auto invariant = found->second; + ctx.SetCheckName(name.data()); + invariant(ctx, ast); + } + } + + return ctx.GetMessages(); +} + +} // namespace ark::es2panda::compiler::ast_verifier diff --git a/ets2panda/compiler/core/ASTVerifier.h b/ets2panda/ast_verifier/ASTVerifier.h similarity index 76% rename from ets2panda/compiler/core/ASTVerifier.h rename to ets2panda/ast_verifier/ASTVerifier.h index 31f586b5387bde1adf3ba013e4d3d1ab64b64127..cc24e60c0f4d599ae25318043039b540071b91b8 100644 --- a/ets2panda/compiler/core/ASTVerifier.h +++ b/ets2panda/ast_verifier/ASTVerifier.h @@ -22,68 +22,18 @@ #include #include +#include "ast_verifier/checkContext.h" + #include "ir/astNode.h" #include "ir/statements/blockStatement.h" #include "lexer/token/sourceLocation.h" #include "parser/program/program.h" #include "util/ustring.h" #include "utils/arena_containers.h" -#include "utils/json_builder.h" #include "varbinder/variable.h" namespace ark::es2panda::compiler::ast_verifier { -enum class CheckSeverity { ERROR, WARNING, UNKNOWN }; -inline std::string CheckSeverityString(CheckSeverity value) -{ - switch (value) { - case CheckSeverity::ERROR: - return "error"; - case CheckSeverity::WARNING: - return "warning"; - default: - UNREACHABLE(); - } -} - -class CheckMessage { -public: - explicit CheckMessage(util::StringView name, util::StringView cause, util::StringView message, size_t line) - : invariantName_ {name}, cause_ {cause}, message_ {message}, line_ {line} - { - } - - std::string Invariant() const - { - return invariantName_; - } - - std::function DumpJSON(CheckSeverity severity, const std::string &sourceName, - const std::string &phaseName) const - { - return [sourceName, phaseName, severity, this](JsonObjectBuilder &body) { - body.AddProperty("severity", CheckSeverityString(severity)); - body.AddProperty("invariant", invariantName_); - body.AddProperty("cause", cause_); - body.AddProperty("ast", message_); - body.AddProperty("line", line_ + 1); - body.AddProperty("source", sourceName); - body.AddProperty("phase", phaseName); - }; - } - -private: - std::string invariantName_; - std::string cause_; - std::string message_; - size_t line_; -}; -using Messages = std::vector; - -enum class CheckDecision { CORRECT, INCORRECT }; -enum class CheckAction { CONTINUE, SKIP_SUBTREE }; -using CheckResult = std::tuple; -class CheckContext; using InvariantCheck = std::function; using Invariants = std::map; diff --git a/ets2panda/ast_verifier/arithmeticOperationValid.cpp b/ets2panda/ast_verifier/arithmeticOperationValid.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9e6ec2ff9d32c1153f93e0d4147857da28506a53 --- /dev/null +++ b/ets2panda/ast_verifier/arithmeticOperationValid.cpp @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "arithmeticOperationValid.h" +#include "ir/expressions/binaryExpression.h" +#include "ir/base/classDefinition.h" +#include "ir/ts/tsInterfaceDeclaration.h" +#include "ir/ts/tsEnumDeclaration.h" +#include "ir/ts/tsInterfaceBody.h" +#include "helpers.h" + +namespace ark::es2panda::compiler::ast_verifier { + +[[nodiscard]] CheckResult ArithmeticOperationValid::operator()([[maybe_unused]] CheckContext &ctx, + const ir::AstNode *ast) +{ + if (auto [decision, action] = CheckCompound(ctx, ast); action == CheckAction::SKIP_SUBTREE) { + return {decision, action}; + } + if (!ast->IsBinaryExpression() || !ast->AsBinaryExpression()->IsArithmetic()) { + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; + } + if ((ast->AsBinaryExpression()->OperatorType() == lexer::TokenType::PUNCTUATOR_PLUS || + ast->AsBinaryExpression()->OperatorType() == lexer::TokenType::PUNCTUATOR_PLUS_EQUAL) && + (IsStringType(ast->AsBinaryExpression()->Left()) || IsStringType(ast->AsBinaryExpression()->Right()))) { + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; + } + auto result = std::make_tuple(CheckDecision::CORRECT, CheckAction::CONTINUE); + bool isBitwise = ast->AsBinaryExpression()->IsBitwise(); + ast->Iterate([&result, &ctx, &isBitwise](ir::AstNode *child) { + if (!IsValidTypeForBinaryOp(child, isBitwise)) { + ctx.AddCheckMessage("Not a numeric type", *child, child->Start()); + result = {CheckDecision::INCORRECT, CheckAction::CONTINUE}; + } + }); + return result; +} + +CheckResult ArithmeticOperationValid::CheckCompound(CheckContext &ctx, const ir::AstNode *ast) +{ + if (ast->IsTSInterfaceDeclaration()) { + for (const auto &member : ast->AsTSInterfaceDeclaration()->Body()->Body()) { + [[maybe_unused]] auto _ = (*this)(ctx, member); + } + return {CheckDecision::CORRECT, CheckAction::SKIP_SUBTREE}; + } + if (ast->IsTSEnumDeclaration()) { + for (const auto &member : ast->AsTSEnumDeclaration()->Members()) { + [[maybe_unused]] auto _ = (*this)(ctx, member); + } + return {CheckDecision::CORRECT, CheckAction::SKIP_SUBTREE}; + } + if (ast->IsClassDefinition()) { + for (const auto &member : ast->AsClassDefinition()->Body()) { + [[maybe_unused]] auto _ = (*this)(ctx, member); + } + return {CheckDecision::CORRECT, CheckAction::SKIP_SUBTREE}; + } + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; +} + +} // namespace ark::es2panda::compiler::ast_verifier diff --git a/ets2panda/ast_verifier/arithmeticOperationValid.h b/ets2panda/ast_verifier/arithmeticOperationValid.h new file mode 100644 index 0000000000000000000000000000000000000000..82c27a501b5560161838ac431ac0867c61f67486 --- /dev/null +++ b/ets2panda/ast_verifier/arithmeticOperationValid.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_ARITHMETICOPERATIONVALID_H +#define ES2PANDA_COMPILER_CORE_AST_VERIFIER_ARITHMETICOPERATIONVALID_H + +#include "checkContext.h" + +namespace ark::es2panda::compiler::ast_verifier { + +class ArithmeticOperationValid { +public: + explicit ArithmeticOperationValid([[maybe_unused]] ArenaAllocator &allocator) {} + [[nodiscard]] CheckResult operator()(CheckContext &ctx, const ir::AstNode *ast); + +private: + CheckResult CheckCompound(CheckContext &ctx, const ir::AstNode *ast); +}; + +} // namespace ark::es2panda::compiler::ast_verifier + +#endif // ES2PANDA_COMPILER_CORE_AST_VERIFIER_ARITHMETICOPERATIONVALID_H diff --git a/ets2panda/ast_verifier/checkContext.cpp b/ets2panda/ast_verifier/checkContext.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b022e14cd96475413ec74c1acedba18d703d1b7d --- /dev/null +++ b/ets2panda/ast_verifier/checkContext.cpp @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "checkContext.h" + +namespace ark::es2panda::compiler::ast_verifier { + +void CheckContext::AddCheckMessage(const std::string &cause, const ir::AstNode &node, const lexer::SourcePosition &from) +{ + const auto loc = from.line; + const auto &&dump = node.DumpJSON(); + messages_.emplace_back(checkName_, cause.data(), dump.data(), loc); +} + +void CheckContext::SetCheckName(util::StringView checkName) +{ + checkName_ = checkName; +} + +Messages CheckContext::GetMessages() +{ + return messages_; +} + +} // namespace ark::es2panda::compiler::ast_verifier diff --git a/ets2panda/ast_verifier/checkContext.h b/ets2panda/ast_verifier/checkContext.h new file mode 100644 index 0000000000000000000000000000000000000000..d384018a8d195073d8d0ed30d86aecad328e4abf --- /dev/null +++ b/ets2panda/ast_verifier/checkContext.h @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_CHECKCONTEXT_H +#define ES2PANDA_COMPILER_CORE_AST_VERIFIER_CHECKCONTEXT_H + +#include "ir/astNode.h" +#include "utils/json_builder.h" + +namespace ark::es2panda::compiler::ast_verifier { + +enum class CheckDecision { CORRECT, INCORRECT }; +enum class CheckAction { CONTINUE, SKIP_SUBTREE }; +using CheckResult = std::tuple; + +enum class CheckSeverity { ERROR, WARNING, UNKNOWN }; +inline std::string CheckSeverityString(CheckSeverity value) +{ + switch (value) { + case CheckSeverity::ERROR: + return "error"; + case CheckSeverity::WARNING: + return "warning"; + default: + UNREACHABLE(); + } +} + +class CheckMessage { +public: + explicit CheckMessage(util::StringView name, util::StringView cause, util::StringView message, size_t line) + : invariantName_ {name}, cause_ {cause}, message_ {message}, line_ {line} + { + } + + std::string Invariant() const + { + return invariantName_; + } + + std::function DumpJSON(CheckSeverity severity, const std::string &sourceName, + const std::string &phaseName) const + { + return [sourceName, phaseName, severity, this](JsonObjectBuilder &body) { + body.AddProperty("severity", CheckSeverityString(severity)); + body.AddProperty("invariant", invariantName_); + body.AddProperty("cause", cause_); + body.AddProperty("ast", message_); + body.AddProperty("line", line_ + 1); + body.AddProperty("source", sourceName); + body.AddProperty("phase", phaseName); + }; + } + +private: + std::string invariantName_; + std::string cause_; + std::string message_; + size_t line_; +}; + +using Messages = std::vector; + +class CheckContext { +public: + explicit CheckContext() : checkName_ {"Invalid"} {} + + void AddCheckMessage(const std::string &cause, const ir::AstNode &node, const lexer::SourcePosition &from); + void SetCheckName(util::StringView checkName); + Messages GetMessages(); + +private: + Messages messages_; + util::StringView checkName_; +}; + +} // namespace ark::es2panda::compiler::ast_verifier + +#endif // ES2PANDA_COMPILER_CORE_AST_VERIFIER_CHECKCONTEXT_H diff --git a/ets2panda/ast_verifier/everyChildHasValidParent.cpp b/ets2panda/ast_verifier/everyChildHasValidParent.cpp new file mode 100644 index 0000000000000000000000000000000000000000..30443fbc6550664815c1ad545b3bd78af14d354b --- /dev/null +++ b/ets2panda/ast_verifier/everyChildHasValidParent.cpp @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "everyChildHasValidParent.h" +#include "ir/base/methodDefinition.h" + +namespace ark::es2panda::compiler::ast_verifier { + +CheckResult EveryChildHasValidParent::operator()(CheckContext &ctx, const ir::AstNode *ast) +{ + auto result = std::make_tuple(CheckDecision::CORRECT, CheckAction::CONTINUE); + if (ast->IsETSScript()) { + return result; + } + + auto maybeOverloadMethod = [](const ir::AstNode *root, const ir::AstNode *node) -> bool { + if (root->IsClassDefinition() && node->IsMethodDefinition() && node->Parent()->IsMethodDefinition()) { + auto maybeBaseOverloadMethod = node->Parent()->AsMethodDefinition(); + auto overloads = maybeBaseOverloadMethod->Overloads(); + auto res = + std::find_if(overloads.begin(), overloads.end(), [node](ir::MethodDefinition *m) { return m == node; }); + return res != overloads.end(); + } + return false; + }; + + ast->Iterate([&](const ir::AstNode *node) { + if (ir::AstNode const *parent = node->Parent(); ast != parent) { + // NOTE: Temporary suppress. + // Should be removed after new ENUMs support will be implemented: #14443 + if (ast->IsClassDeclaration() && parent != nullptr && parent->IsETSNewClassInstanceExpression()) { + return; + } + + // NOTE: Temporary suppress. + // Should be removed after proper overload method's parent setting + // For now there is no right decision who is parent of overload method: + // baseOverloadMethod or ClassDefininiton, but the first is set + if (maybeOverloadMethod(ast, node)) { + return; + } + + ctx.AddCheckMessage("INCORRECT_PARENT_REF", *node, node->Start()); + result = {CheckDecision::INCORRECT, CheckAction::CONTINUE}; + } + }); + + return result; +} + +} // namespace ark::es2panda::compiler::ast_verifier diff --git a/ets2panda/ast_verifier/everyChildHasValidParent.h b/ets2panda/ast_verifier/everyChildHasValidParent.h new file mode 100644 index 0000000000000000000000000000000000000000..4634ed8e16fe646aedea53310bce8cf2be5dd7d9 --- /dev/null +++ b/ets2panda/ast_verifier/everyChildHasValidParent.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_EVERYCHILDHASVALIDPARENT_H +#define ES2PANDA_COMPILER_CORE_AST_VERIFIER_EVERYCHILDHASVALIDPARENT_H + +#include "checkContext.h" + +namespace ark::es2panda::compiler::ast_verifier { + +class EveryChildHasValidParent { +public: + explicit EveryChildHasValidParent([[maybe_unused]] ArenaAllocator &allocator) {} + [[nodiscard]] CheckResult operator()(CheckContext &ctx, const ir::AstNode *ast); +}; + +} // namespace ark::es2panda::compiler::ast_verifier + +#endif // ES2PANDA_COMPILER_CORE_AST_VERIFIER_EVERYCHILDHASVALIDPARENT_H diff --git a/ets2panda/ast_verifier/everyChildInParentRange.cpp b/ets2panda/ast_verifier/everyChildInParentRange.cpp new file mode 100644 index 0000000000000000000000000000000000000000..62032aef1d561206a06045bb26208da8e764d3d0 --- /dev/null +++ b/ets2panda/ast_verifier/everyChildInParentRange.cpp @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "everyChildInParentRange.h" + +namespace ark::es2panda::compiler::ast_verifier { + +CheckResult EveryChildInParentRange::operator()(CheckContext &ctx, const ir::AstNode *ast) +{ + auto result = std::make_tuple(CheckDecision::CORRECT, CheckAction::CONTINUE); + if (ast->Parent() == nullptr) { + return result; + } + ast->Iterate([&](const ir::AstNode *node) { + if (ast != node->Parent()) { + result = {CheckDecision::INCORRECT, CheckAction::CONTINUE}; + } + if (ast->Start().line > node->Start().line || ast->End().line < node->End().line) { + result = {CheckDecision::INCORRECT, CheckAction::CONTINUE}; + } + if (ast->Start().line == node->Start().line && ast->Start().index > node->Start().index) { + result = {CheckDecision::INCORRECT, CheckAction::CONTINUE}; + } + if (ast->End().line == node->End().line && ast->End().index < node->End().index) { + result = {CheckDecision::INCORRECT, CheckAction::CONTINUE}; + } + ctx.AddCheckMessage("INCORRECT_CHILD_RANGE", *node, node->Start()); + }); + return result; +} + +} // namespace ark::es2panda::compiler::ast_verifier diff --git a/ets2panda/ast_verifier/everyChildInParentRange.h b/ets2panda/ast_verifier/everyChildInParentRange.h new file mode 100644 index 0000000000000000000000000000000000000000..d3142a2b8f13d8f2c3ba2f24dd8c5d61eca30610 --- /dev/null +++ b/ets2panda/ast_verifier/everyChildInParentRange.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_EVERYCHILDINPARENTRANGE_H +#define ES2PANDA_COMPILER_CORE_AST_VERIFIER_EVERYCHILDINPARENTRANGE_H + +#include "checkContext.h" + +namespace ark::es2panda::compiler::ast_verifier { + +class EveryChildInParentRange { +public: + explicit EveryChildInParentRange([[maybe_unused]] ArenaAllocator &allocator) {} + [[nodiscard]] CheckResult operator()(CheckContext &ctx, const ir::AstNode *ast); +}; + +} // namespace ark::es2panda::compiler::ast_verifier + +#endif // ES2PANDA_COMPILER_CORE_AST_VERIFIER_EVERYCHILDINPARENTRANGE_H diff --git a/ets2panda/ast_verifier/forLoopCorrectlyInitialized.cpp b/ets2panda/ast_verifier/forLoopCorrectlyInitialized.cpp new file mode 100644 index 0000000000000000000000000000000000000000..22de67ef8483e2e645945fb3800511a4aafa22c3 --- /dev/null +++ b/ets2panda/ast_verifier/forLoopCorrectlyInitialized.cpp @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "forLoopCorrectlyInitialized.h" +#include "ir/statements/forInStatement.h" +#include "ir/statements/forOfStatement.h" +#include "ir/statements/forUpdateStatement.h" + +namespace ark::es2panda::compiler::ast_verifier { + +[[nodiscard]] CheckResult ForLoopCorrectlyInitialized::operator()(CheckContext &ctx, const ir::AstNode *ast) +{ + if (ast->IsForInStatement()) { + return HandleForInStatement(ctx, ast); + } + + if (ast->IsForOfStatement()) { + return HandleForOfStatement(ctx, ast); + } + + if (ast->IsForUpdateStatement()) { + return HandleForUpdateStatement(ctx, ast); + } + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; +} + +[[nodiscard]] CheckResult ForLoopCorrectlyInitialized::HandleForInStatement(CheckContext &ctx, const ir::AstNode *ast) +{ + auto const *left = ast->AsForInStatement()->Left(); + if (left == nullptr) { + ctx.AddCheckMessage("NULL FOR-IN-LEFT", *ast, ast->Start()); + return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; + } + + if (!left->IsIdentifier() && !left->IsVariableDeclaration()) { + ctx.AddCheckMessage("INCORRECT FOR-IN-LEFT", *ast, ast->Start()); + return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; + } + + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; +} + +[[nodiscard]] CheckResult ForLoopCorrectlyInitialized::HandleForOfStatement(CheckContext &ctx, const ir::AstNode *ast) +{ + auto const *left = ast->AsForOfStatement()->Left(); + if (left == nullptr) { + ctx.AddCheckMessage("NULL FOR-OF-LEFT", *ast, ast->Start()); + return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; + } + + if (!left->IsIdentifier() && !left->IsVariableDeclaration()) { + ctx.AddCheckMessage("INCORRECT FOR-OF-LEFT", *ast, ast->Start()); + return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; + } + + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; +} + +[[nodiscard]] CheckResult ForLoopCorrectlyInitialized::HandleForUpdateStatement(CheckContext &ctx, + const ir::AstNode *ast) +{ + // The most important part of for-loop is the test. + // But it also can be null. Then there must be break;(return) in the body. + auto const *test = ast->AsForUpdateStatement()->Test(); + if (test == nullptr) { + auto const *body = ast->AsForUpdateStatement()->Body(); + if (body == nullptr) { + ctx.AddCheckMessage("NULL FOR-TEST AND FOR-BODY", *ast, ast->Start()); + return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; + } + bool hasExit = body->IsBreakStatement() || body->IsReturnStatement(); + body->IterateRecursively( + [&hasExit](ir::AstNode *child) { hasExit |= child->IsBreakStatement() || child->IsReturnStatement(); }); + if (!hasExit) { + // an infinite loop + ctx.AddCheckMessage("NULL FOR-TEST AND FOR-BODY doesn't exit", *ast, ast->Start()); + } + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; + } + + if (!test->IsExpression()) { + ctx.AddCheckMessage("NULL FOR VAR", *ast, ast->Start()); + return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; + } + + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; +} + +} // namespace ark::es2panda::compiler::ast_verifier diff --git a/ets2panda/ast_verifier/forLoopCorrectlyInitialized.h b/ets2panda/ast_verifier/forLoopCorrectlyInitialized.h new file mode 100644 index 0000000000000000000000000000000000000000..63151eef6d6fe2cbea9231aeef1b9d049b7b96c0 --- /dev/null +++ b/ets2panda/ast_verifier/forLoopCorrectlyInitialized.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_FORLOOPCORRECTLYINITIALIZED_H +#define ES2PANDA_COMPILER_CORE_AST_VERIFIER_FORLOOPCORRECTLYINITIALIZED_H + +#include "checkContext.h" + +namespace ark::es2panda::compiler::ast_verifier { + +class ForLoopCorrectlyInitialized { +public: + explicit ForLoopCorrectlyInitialized([[maybe_unused]] ArenaAllocator &allocator) {} + [[nodiscard]] CheckResult operator()(CheckContext &ctx, const ir::AstNode *ast); + +private: + [[nodiscard]] CheckResult HandleForInStatement(CheckContext &ctx, const ir::AstNode *ast); + [[nodiscard]] CheckResult HandleForOfStatement(CheckContext &ctx, const ir::AstNode *ast); + [[nodiscard]] CheckResult HandleForUpdateStatement(CheckContext &ctx, const ir::AstNode *ast); +}; + +} // namespace ark::es2panda::compiler::ast_verifier + +#endif // ES2PANDA_COMPILER_CORE_AST_VERIFIER_FORLOOPCORRECTLYINITIALIZED_H diff --git a/ets2panda/ast_verifier/helpers.cpp b/ets2panda/ast_verifier/helpers.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d46449d304df1fad674f2ffd05be6ee14f501768 --- /dev/null +++ b/ets2panda/ast_verifier/helpers.cpp @@ -0,0 +1,331 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "helpers.h" + +#include "checker/types/typeFlag.h" +#include "checker/types/type.h" +#include "checker/types/ets/etsObjectType.h" +#include "ir/statements/blockStatement.h" +#include "ir/ets/etsScript.h" +#include "parser/program/program.h" +#include "ir/expressions/memberExpression.h" +#include "ir/expressions/callExpression.h" + +namespace ark::es2panda::compiler::ast_verifier { + +bool IsImportLike(const ir::AstNode *ast) +{ + return (ast->IsETSImportDeclaration() || ast->IsETSReExportDeclaration() || ast->IsImportExpression() || + ast->IsImportSpecifier() || ast->IsImportDefaultSpecifier() || ast->IsImportNamespaceSpecifier()); +} + +bool IsExportLike(const ir::AstNode *ast) +{ + return (ast->IsExportDefaultDeclaration() || ast->IsExportSpecifier() || ast->IsExportAllDeclaration() || + ast->IsExportNamedDeclaration() || ast->IsETSReExportDeclaration()); +} + +bool IsBooleanType(const ir::AstNode *ast) +{ + if (ast == nullptr) { + return false; + } + + if (!ast->IsTyped()) { + return false; + } + + auto typedAst = static_cast(ast); + + if (typedAst->TsType() == nullptr) { + return false; + } + + if (typedAst->TsType()->HasTypeFlag(checker::TypeFlag::ETS_OBJECT) && + ast->HasBoxingUnboxingFlags(ir::BoxingUnboxingFlags::UNBOXING_FLAG)) { + return typedAst->TsType()->AsETSObjectType()->HasObjectFlag(checker::ETSObjectFlags::BUILTIN_BOOLEAN); + } + + return typedAst->TsType()->HasTypeFlag(checker::TypeFlag::ETS_BOOLEAN) || + typedAst->TsType()->HasTypeFlag(checker::TypeFlag::BOOLEAN_LIKE); +} + +bool IsValidTypeForBinaryOp(const ir::AstNode *ast, bool isBitwise) +{ + if (ast == nullptr) { + std::cout << __LINE__ << std::endl; + return false; + } + + if (!ast->IsTyped()) { + std::cout << __LINE__ << std::endl; + return false; + } + + auto typedAst = static_cast(ast); + + if (typedAst->TsType() == nullptr) { + // std::cout << typedAst + std::cout << __LINE__ << std::endl; + return false; + } + + if (IsBooleanType(ast)) { + return isBitwise; + } + + if (typedAst->TsType()->HasTypeFlag(checker::TypeFlag::ETS_OBJECT) && + typedAst->TsType()->AsETSObjectType()->HasObjectFlag(checker::ETSObjectFlags::BUILTIN_BIGINT)) { + return true; + } + + if (typedAst->TsType()->HasTypeFlag(checker::TypeFlag::ETS_OBJECT) && + ast->HasBoxingUnboxingFlags(ir::BoxingUnboxingFlags::UNBOXING_FLAG)) { + return typedAst->TsType()->AsETSObjectType()->HasObjectFlag(checker::ETSObjectFlags::BUILTIN_TYPE) && + !typedAst->TsType()->AsETSObjectType()->HasObjectFlag(checker::ETSObjectFlags::BUILTIN_BOOLEAN); + } + + return typedAst->TsType()->HasTypeFlag(checker::TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC) || + typedAst->TsType()->HasTypeFlag(checker::TypeFlag::NUMBER_LITERAL) || + typedAst->TsType()->HasTypeFlag(checker::TypeFlag::BIGINT) || + typedAst->TsType()->HasTypeFlag(checker::TypeFlag::BIGINT_LITERAL); +} + +bool IsStringType(const ir::AstNode *ast) +{ + if (ast == nullptr) { + return false; + } + + if (!ast->IsTyped()) { + return false; + } + + auto typedAst = static_cast(ast); + + if (typedAst->TsType() == nullptr) { + return false; + } + + if (typedAst->TsType()->HasTypeFlag(checker::TypeFlag::ETS_OBJECT)) { + return typedAst->TsType()->AsETSObjectType()->HasObjectFlag(checker::ETSObjectFlags::STRING) || + typedAst->TsType()->AsETSObjectType()->HasObjectFlag(checker::ETSObjectFlags::BUILTIN_STRING); + } + + return typedAst->TsType()->HasTypeFlag(checker::TypeFlag::STRING_LIKE); +} + +bool IsVisibleInternalNode(const ir::AstNode *ast, const ir::AstNode *objTypeDeclNode) +{ + // NOTE(orlovskymaxim) This relies on the fact, that GetTopStatement has no bugs, that is not the case for now + if (!ast->GetTopStatement()->IsETSScript()) { + return false; + } + auto *currentTopStatement = (static_cast(ast->GetTopStatement())); + auto *currentProgram = currentTopStatement->Program(); + if (currentProgram == nullptr) { + return false; + } + util::StringView moduleNameCurrent = currentProgram->ModuleName(); + // NOTE(orlovskymaxim) This relies on the fact, that GetTopStatement has no bugs, that is not the case for now + if (!objTypeDeclNode->GetTopStatement()->IsETSScript()) { + return false; + } + auto *objectTopStatement = (static_cast(objTypeDeclNode->GetTopStatement())); + auto *objectProgram = objectTopStatement->Program(); + if (objectProgram == nullptr) { + return false; + } + util::StringView moduleNameObject = objectProgram->ModuleName(); + return currentTopStatement == objectTopStatement || moduleNameCurrent == moduleNameObject; +} + +const checker::Type *GetClassDefinitionType(const ir::AstNode *ast) +{ + const ir::AstNode *tmpNode = ast; + while (tmpNode->Parent() != nullptr && !tmpNode->IsClassDefinition()) { + tmpNode = tmpNode->Parent(); + } + if (!tmpNode->IsClassDefinition()) { + return nullptr; + } + auto *classDefinition = tmpNode->AsClassDefinition(); + return classDefinition->TsType(); +} + +const checker::Type *GetTSInterfaceDeclarationType(const ir::AstNode *ast) +{ + const ir::AstNode *tmpNode = ast; + while (tmpNode->Parent() != nullptr && !tmpNode->IsTSInterfaceDeclaration()) { + tmpNode = tmpNode->Parent(); + } + if (!tmpNode->IsTSInterfaceDeclaration()) { + return nullptr; + } + auto *tsInterfaceDeclaration = tmpNode->AsTSInterfaceDeclaration(); + return tsInterfaceDeclaration->TsType(); +} + +bool ValidateMethodAccessForClass(const ir::AstNode *ast, const ir::AstNode *ownerSignDeclNode, + checker::Signature *signature, const ir::AstNode *memberObjTypeDeclNode) +{ + // Check if the method is used where it is declared + if (IsContainedIn(ast, ownerSignDeclNode)) { + return true; + } + if (signature->HasSignatureFlag(checker::SignatureFlags::PRIVATE)) { + return false; + } + if (signature->HasSignatureFlag(checker::SignatureFlags::PROTECTED)) { + // Check if the method is inherited and is used in class in which it is inherited + auto *classDefinitionType = GetClassDefinitionType(ast); + if (classDefinitionType == nullptr || !classDefinitionType->IsETSObjectType()) { + return false; + } + auto *classObjectType = classDefinitionType->AsETSObjectType(); + return classObjectType->IsDescendantOf(signature->Owner()); + } + if (signature->HasSignatureFlag(checker::SignatureFlags::INTERNAL)) { + return IsVisibleInternalNode(ast, memberObjTypeDeclNode); + } + return true; +} + +bool ValidateMethodAccessForTSInterface(const ir::AstNode *ast, const ir::AstNode *ownerSignDeclNode, + checker::Signature *signature, const ir::AstNode *memberObjTypeDeclNode) +{ + // Check if the method is used where it is declared + if (IsContainedIn(ast, ownerSignDeclNode)) { + return true; + } + if (signature->HasSignatureFlag(checker::SignatureFlags::PRIVATE)) { + return false; + } + if (signature->HasSignatureFlag(checker::SignatureFlags::PROTECTED)) { + // Check if the method is inherited and is used in class in which it is inherited + auto *tsInterfaceDeclarationType = GetTSInterfaceDeclarationType(ast); + if (tsInterfaceDeclarationType == nullptr || !tsInterfaceDeclarationType->IsETSObjectType()) { + return false; + } + auto *tsInterfaceObjectType = tsInterfaceDeclarationType->AsETSObjectType(); + return tsInterfaceObjectType->IsDescendantOf(signature->Owner()); + } + if (signature->HasSignatureFlag(checker::SignatureFlags::INTERNAL)) { + return IsVisibleInternalNode(ast, memberObjTypeDeclNode); + } + return true; +} + +bool ValidatePropertyAccessForClass(const ir::AstNode *ast, const ir::AstNode *propVarDeclNode, + const ir::AstNode *propVarDeclNodeParent, const varbinder::LocalVariable *propVar, + const ir::AstNode *objTypeDeclNode) +{ + // Check if the variable is used where it is declared + if (IsContainedIn(ast, propVarDeclNodeParent)) { + return true; + } + if (propVarDeclNode->IsPrivate()) { + return false; + } + if (propVarDeclNode->IsProtected()) { + auto *classDefinitionType = GetClassDefinitionType(ast); + if (classDefinitionType == nullptr || !classDefinitionType->IsETSObjectType()) { + return false; + } + auto *classObjectType = classDefinitionType->AsETSObjectType(); + return classObjectType->IsPropertyOfAscendant(propVar); + } + if (propVarDeclNode->IsInternal()) { + return IsVisibleInternalNode(ast, objTypeDeclNode); + } + return true; +} + +bool ValidateVariableAccess(const varbinder::LocalVariable *propVar, const ir::MemberExpression *ast) +{ + const auto *propVarDecl = propVar->Declaration(); + if (propVarDecl == nullptr) { + return false; + } + const auto *propVarDeclNode = propVarDecl->Node(); + if (propVarDeclNode == nullptr) { + return false; + } + auto *objType = ast->ObjType(); + if (objType == nullptr) { + return false; + } + const auto *objTypeDeclNode = objType->GetDeclNode(); + if (objTypeDeclNode == nullptr) { + return false; + } + if (objTypeDeclNode->Parent() != nullptr && objTypeDeclNode->Parent()->IsImportNamespaceSpecifier()) { + return true; + } + const auto *propVarDeclNodeParent = propVarDeclNode->Parent(); + if (propVarDeclNodeParent == nullptr) { + return false; + } + if (propVarDeclNodeParent->IsClassDefinition() && objTypeDeclNode->IsClassDefinition()) { + return ValidatePropertyAccessForClass(ast, propVarDeclNode, propVarDeclNodeParent, propVar, objTypeDeclNode); + } + return false; +} + +bool ValidateMethodAccess(const ir::MemberExpression *memberExpression, const ir::CallExpression *ast) +{ + auto *memberObjType = memberExpression->ObjType(); + if (memberObjType == nullptr) { + return false; + } + if (memberObjType->HasObjectFlag(checker::ETSObjectFlags::RESOLVED_SUPER) && + memberObjType->SuperType() != nullptr && + memberObjType->SuperType()->HasObjectFlag(checker::ETSObjectFlags::BUILTIN_TYPE | + checker::ETSObjectFlags::GLOBAL)) { + return true; + } + const auto *memberObjTypeDeclNode = memberObjType->GetDeclNode(); + if (memberObjTypeDeclNode == nullptr) { + return false; + } + if (memberObjTypeDeclNode->Parent() != nullptr && memberObjTypeDeclNode->Parent()->IsImportNamespaceSpecifier()) { + return true; + } + auto *signature = ast->Signature(); + if (signature == nullptr) { + return false; + } + auto *ownerSign = signature->Owner(); + if (ownerSign == nullptr) { + return false; + } + auto *ownerSignDeclNode = ownerSign->GetDeclNode(); + if (ownerSignDeclNode == nullptr) { + return false; + } + if (!ownerSignDeclNode->IsClassDefinition() && !ownerSignDeclNode->IsTSInterfaceDeclaration()) { + return false; + } + bool ret = false; + if (memberObjTypeDeclNode->IsClassDefinition()) { + ret = ValidateMethodAccessForClass(ast, ownerSignDeclNode, signature, memberObjTypeDeclNode); + } else if (memberObjTypeDeclNode->IsTSInterfaceDeclaration()) { + ret = ValidateMethodAccessForTSInterface(ast, ownerSignDeclNode, signature, memberObjTypeDeclNode); + } + return ret; +} + +} // namespace ark::es2panda::compiler::ast_verifier diff --git a/ets2panda/ast_verifier/helpers.h b/ets2panda/ast_verifier/helpers.h new file mode 100644 index 0000000000000000000000000000000000000000..5537259ab93aa0d04a14f023462897dfb8236855 --- /dev/null +++ b/ets2panda/ast_verifier/helpers.h @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_HELPERS_H +#define ES2PANDA_COMPILER_CORE_AST_VERIFIER_HELPERS_H + +#include "ir/astNode.h" +#include "checker/types/signature.h" + +namespace ark::es2panda::compiler::ast_verifier { + +bool IsImportLike(const ir::AstNode *ast); +bool IsExportLike(const ir::AstNode *ast); +bool IsBooleanType(const ir::AstNode *ast); +bool IsValidTypeForBinaryOp(const ir::AstNode *ast, bool isBitwise); +bool IsStringType(const ir::AstNode *ast); +bool IsVisibleInternalNode(const ir::AstNode *ast, const ir::AstNode *objTypeDeclNode); +const checker::Type *GetClassDefinitionType(const ir::AstNode *ast); +const checker::Type *GetTSInterfaceDeclarationType(const ir::AstNode *ast); +bool ValidateMethodAccessForClass(const ir::AstNode *ast, const ir::AstNode *ownerSignDeclNode, + checker::Signature *signature, const ir::AstNode *memberObjTypeDeclNode); +bool ValidateMethodAccessForTSInterface(const ir::AstNode *ast, const ir::AstNode *ownerSignDeclNode, + checker::Signature *signature, const ir::AstNode *memberObjTypeDeclNode); +bool ValidatePropertyAccessForClass(const ir::AstNode *ast, const ir::AstNode *propVarDeclNode, + const ir::AstNode *propVarDeclNodeParent, const varbinder::LocalVariable *propVar, + const ir::AstNode *objTypeDeclNode); +bool ValidateVariableAccess(const varbinder::LocalVariable *propVar, const ir::MemberExpression *ast); +bool ValidateMethodAccess(const ir::MemberExpression *memberExpression, const ir::CallExpression *ast); + +template +bool IsContainedIn(const T *child, const T *parent) +{ + if (child == nullptr || parent == nullptr) { + return false; + } + + std::unordered_set savedNodes; + while (child != nullptr && child != parent) { + savedNodes.emplace(child); + child = child->Parent(); + if (savedNodes.find(child) != savedNodes.end()) { + return false; + } + } + return child == parent; +} + +} // namespace ark::es2panda::compiler::ast_verifier + +#endif // ES2PANDA_COMPILER_CORE_AST_VERIFIER_HELPERS_H diff --git a/ets2panda/ast_verifier/identifierHasVariable.cpp b/ets2panda/ast_verifier/identifierHasVariable.cpp new file mode 100644 index 0000000000000000000000000000000000000000..472087ee85c7e53a40b008250ff1505903e02326 --- /dev/null +++ b/ets2panda/ast_verifier/identifierHasVariable.cpp @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "helpers.h" +#include "identifierHasVariable.h" +#include "ir/base/scriptFunction.h" +#include "ir/expressions/memberExpression.h" +#include "ir/ts/tsEnumDeclaration.h" +#include "ir/typeNode.h" + +namespace ark::es2panda::compiler::ast_verifier { + +CheckResult IdentifierHasVariable::operator()(CheckContext &ctx, const ir::AstNode *ast) +{ + if (!ast->IsIdentifier()) { + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; + } + + if (ast->AsIdentifier()->Variable() != nullptr) { + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; + } + + const auto *id = ast->AsIdentifier(); + if (CheckAstExceptions(id)) { + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; + } + + // Another function with exceptions to reduce function size + if (CheckMoreAstExceptions(id)) { + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; + } + + ctx.AddCheckMessage("NULL_VARIABLE", *id, id->Start()); + return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; +} + +bool IdentifierHasVariable::CheckMoreAstExceptions(const ir::Identifier *ast) const +{ + // NOTE(kkonkuznetsov): skip async functions + auto parent = ast->Parent(); + while (parent != nullptr) { + if (parent->IsScriptFunction()) { + auto script = parent->AsScriptFunction(); + if (script->IsAsyncFunc()) { + return true; + } + + break; + } + + parent = parent->Parent(); + } + + // NOTE(kkonkuznetsov): skip reexport declarations + if (ast->Parent() != nullptr && ast->Parent()->Parent() != nullptr) { + parent = ast->Parent()->Parent(); + if (parent->IsETSReExportDeclaration()) { + return true; + } + } + + // NOTE(kkonkuznetsov): object expressions + parent = ast->Parent(); + while (parent != nullptr) { + if (parent->IsObjectExpression()) { + return true; + } + + parent = parent->Parent(); + } + + // NOTE(kkonkuznetsov): some identifiers have empty names + if (ast->Name().Empty()) { + return true; + } + + // NOTE(mmartin): find a better solution to handle utility type resolution + if (ast->Name().Is(Signatures::PARTIAL_TYPE_NAME) || ast->Name().Is(Signatures::REQUIRED_TYPE_NAME) || + ast->Name().Is(Signatures::READONLY_TYPE_NAME)) { + return true; + } + + return false; +} + +bool IdentifierHasVariable::CheckAstExceptions(const ir::Identifier *ast) const +{ + // NOTE(kkonkuznetsov): skip enums + if (ast->Parent()->IsMemberExpression() && + (ast->Parent()->AsMemberExpression()->Object()->TsType() == nullptr || + ast->Parent()->AsMemberExpression()->Object()->TsType()->IsETSEnumType() || + ast->Parent()->AsMemberExpression()->Object()->TsType()->IsETSStringEnumType())) { + return true; + } + + // NOTE(kkonkuznetsov): skip length property + if (ast->Parent()->IsMemberExpression() && ast->Name().Is("length")) { + return true; + } + + // NOTE(kkonkuznetsov): skip anonymous class id + if (ast->Parent()->Parent() != nullptr && ast->Parent()->Parent()->IsETSNewClassInstanceExpression()) { + return true; + } + + // NOTE(kkonkuznetsov): skip package declarations + auto parent = ast->Parent(); + while (parent != nullptr) { + if (parent->IsETSPackageDeclaration()) { + return true; + } + + parent = parent->Parent(); + } + + return false; +} + +} // namespace ark::es2panda::compiler::ast_verifier diff --git a/ets2panda/ast_verifier/identifierHasVariable.h b/ets2panda/ast_verifier/identifierHasVariable.h new file mode 100644 index 0000000000000000000000000000000000000000..ddef8d1b77fa9fd44fc3a0ae2d252401fffce5a6 --- /dev/null +++ b/ets2panda/ast_verifier/identifierHasVariable.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_IDENTIFIERHASVARIABLE_H +#define ES2PANDA_COMPILER_CORE_AST_VERIFIER_IDENTIFIERHASVARIABLE_H + +#include "checkContext.h" + +#include "ir/expressions/identifier.h" + +namespace ark::es2panda::compiler::ast_verifier { + +class IdentifierHasVariable { +public: + explicit IdentifierHasVariable([[maybe_unused]] ArenaAllocator &allocator) {} + [[nodiscard]] CheckResult operator()(CheckContext &ctx, const ir::AstNode *ast); + +private: + bool CheckMoreAstExceptions(const ir::Identifier *ast) const; + bool CheckAstExceptions(const ir::Identifier *ast) const; +}; + +} // namespace ark::es2panda::compiler::ast_verifier + +#endif // ES2PANDA_COMPILER_CORE_AST_VERIFIER_IDENTIFIERHASVARIABLE_H diff --git a/ets2panda/ast_verifier/importExportAccessValid.cpp b/ets2panda/ast_verifier/importExportAccessValid.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f2c43e5051eb12fc084d120b9c9e4e7de9b91609 --- /dev/null +++ b/ets2panda/ast_verifier/importExportAccessValid.cpp @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "importExportAccessValid.h" +#include "helpers.h" +#include "ir/expressions/callExpression.h" +#include "checker/types/ets/etsObjectType.h" +#include "ir/module/importSpecifier.h" +#include "ir/module/importNamespaceSpecifier.h" +#include "ir/module/importDefaultSpecifier.h" +#include "ir/expressions/identifier.h" +#include "ir/ets/etsImportDeclaration.h" +#include "checker/types/signature.h" + +namespace ark::es2panda::compiler::ast_verifier { + +[[nodiscard]] CheckResult ImportExportAccessValid::operator()(CheckContext &ctx, const ir::AstNode *ast) +{ + std::unordered_set importedVariables {}; + if (ast->IsETSImportDeclaration()) { + const auto importDecl = ast->AsETSImportDeclaration()->Specifiers(); + const auto name = [](ir::AstNode *const specifier) { + if (specifier->IsImportNamespaceSpecifier()) { + return specifier->AsImportNamespaceSpecifier()->Local()->Name(); + } + if (specifier->IsImportSpecifier()) { + return specifier->AsImportSpecifier()->Local()->Name(); + } + return specifier->AsImportDefaultSpecifier()->Local()->Name(); + }; + for (const auto import : importDecl) { + importedVariables.emplace(name(import)); + } + } + if (ast->IsCallExpression()) { + const auto *callExpr = ast->AsCallExpression(); + const auto *callee = callExpr->Callee(); + if (callee != nullptr && callee->IsIdentifier() && + !HandleImportExportIdentifier(importedVariables, callee->AsIdentifier(), callExpr)) { + ctx.AddCheckMessage("PROPERTY_NOT_VISIBLE_HERE(NOT_EXPORTED)", *callee, callee->Start()); + return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; + } + } + if (ast->IsIdentifier() && !HandleImportExportIdentifier(importedVariables, ast->AsIdentifier(), nullptr)) { + ctx.AddCheckMessage("PROPERTY_NOT_VISIBLE_HERE(NOT_EXPORTED)", *ast, ast->Start()); + return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; + } + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; +} + +bool ImportExportAccessValid::ValidateExport(const varbinder::Variable *var) +{ + const auto *decl = var->Declaration(); + if (decl == nullptr) { + return false; + } + const auto *node = decl->Node(); + if (node == nullptr) { + return false; + } + return node->IsExported() || node->IsExportedType(); +} + +bool ImportExportAccessValid::InvariantImportExportMethod(const std::unordered_set &importedVariables, + const varbinder::Variable *varCallee, + const ir::AstNode *callExpr, util::StringView name) +{ + auto *signature = callExpr->AsCallExpression()->Signature(); + if (signature->Owner() == nullptr) { + // NOTE(vpukhov): Add a synthetic owner for dynamic signatures + ASSERT(callExpr->AsCallExpression()->Callee()->TsType()->HasTypeFlag(checker::TypeFlag::ETS_DYNAMIC_FLAG)); + return true; + } + + if (signature != nullptr && varCallee->Declaration() != nullptr && varCallee->Declaration()->Node() != nullptr && + !IsContainedIn(varCallee->Declaration()->Node(), signature->Owner()->GetDeclNode()) && + varCallee->Declaration()->Node() != signature->Owner()->GetDeclNode()) { + if (importedVariables.find(name.Mutf8()) != importedVariables.end() || + importedVariables.find("") != importedVariables.end()) { + return ValidateExport(varCallee); + } + return false; + } + return true; +} + +bool ImportExportAccessValid::InvariantImportExportVariable(const std::unordered_set &importedVariables, + const varbinder::Variable *var, const ir::Identifier *ident, + util::StringView name) +{ + if (!var->HasFlag(varbinder::VariableFlags::LOCAL) && !var->HasFlag(varbinder::VariableFlags::VAR) && + var->HasFlag(varbinder::VariableFlags::INITIALIZED) && var->Declaration() != nullptr && + var->Declaration()->Node() != nullptr && !var->Declaration()->Node()->IsMethodDefinition() && + !var->Declaration()->Node()->IsClassProperty()) { + auto varParent = var->Declaration()->Node()->Parent(); + if (varParent != nullptr && !IsContainedIn(ident->Parent(), varParent) && ident->Parent() != varParent) { + if (var->GetScope() != nullptr && var->GetScope()->Parent() != nullptr && + var->GetScope()->Parent()->IsGlobalScope() && + ident->GetTopStatement() == varParent->GetTopStatement()) { + return true; + } + if (importedVariables.find(name.Mutf8()) != importedVariables.end() || + importedVariables.find("") != importedVariables.end()) { + return ValidateExport(var); + } + return false; + } + } + return true; +} + +bool ImportExportAccessValid::HandleImportExportIdentifier(std::unordered_set &importedVariables, + const ir::Identifier *ident, const ir::AstNode *callExpr) +{ + if (ident->IsReference()) { + const auto *var = ident->Variable(); + if (var != nullptr) { + if (var->HasFlag(varbinder::VariableFlags::METHOD) && callExpr != nullptr) { + return InvariantImportExportMethod(importedVariables, var, callExpr, ident->Name()); + } + return InvariantImportExportVariable(importedVariables, var, ident, ident->Name()); + } + } + return true; +} + +} // namespace ark::es2panda::compiler::ast_verifier diff --git a/ets2panda/ast_verifier/importExportAccessValid.h b/ets2panda/ast_verifier/importExportAccessValid.h new file mode 100644 index 0000000000000000000000000000000000000000..558ff0bcfef4c8fdae544abbd7d30bb4b7209992 --- /dev/null +++ b/ets2panda/ast_verifier/importExportAccessValid.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_IMPORTEXPORTACCESSVALID_H +#define ES2PANDA_COMPILER_CORE_AST_VERIFIER_IMPORTEXPORTACCESSVALID_H + +#include "checkContext.h" + +namespace ark::es2panda::compiler::ast_verifier { + +class ImportExportAccessValid { +public: + explicit ImportExportAccessValid([[maybe_unused]] ArenaAllocator &allocator) {} + [[nodiscard]] CheckResult operator()(CheckContext &ctx, const ir::AstNode *ast); + +private: + bool ValidateExport(const varbinder::Variable *var); + bool InvariantImportExportMethod(const std::unordered_set &importedVariables, + const varbinder::Variable *varCallee, const ir::AstNode *callExpr, + util::StringView name); + bool InvariantImportExportVariable(const std::unordered_set &importedVariables, + const varbinder::Variable *var, const ir::Identifier *ident, + util::StringView name); + bool HandleImportExportIdentifier(std::unordered_set &importedVariables, const ir::Identifier *ident, + const ir::AstNode *callExpr); +}; + +} // namespace ark::es2panda::compiler::ast_verifier + +#endif // ES2PANDA_COMPILER_CORE_AST_VERIFIER_IMPORTEXPORTACCESSVALID_H diff --git a/ets2panda/ast_verifier/modifierAccessValid.cpp b/ets2panda/ast_verifier/modifierAccessValid.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2b91bc56613fece601d628e9056fb8c4587660ef --- /dev/null +++ b/ets2panda/ast_verifier/modifierAccessValid.cpp @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "modifierAccessValid.h" +#include "helpers.h" +#include "varbinder/variableFlags.h" +#include "ir/expressions/memberExpression.h" +#include "ir/expressions/callExpression.h" + +namespace ark::es2panda::compiler::ast_verifier { + +[[nodiscard]] CheckResult ModifierAccessValid::operator()(CheckContext &ctx, const ir::AstNode *ast) +{ + if (auto [decision, action] = HandleMethodExpression(ctx, ast); decision == CheckDecision::INCORRECT) { + return {decision, action}; + } + if (auto [decision, action] = HandleCallExpression(ctx, ast); decision == CheckDecision::INCORRECT) { + return {decision, action}; + } + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; +} + +CheckResult ModifierAccessValid::HandleMethodExpression(CheckContext &ctx, const ir::AstNode *ast) +{ + if (!ast->IsMemberExpression()) { + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; + } + const auto *propVar = ast->AsMemberExpression()->PropVar(); + if (propVar != nullptr && propVar->HasFlag(varbinder::VariableFlags::PROPERTY) && + !ValidateVariableAccess(propVar, ast->AsMemberExpression())) { + ctx.AddCheckMessage("PROPERTY_NOT_VISIBLE_HERE", *ast, ast->Start()); + return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; + } + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; +} + +CheckResult ModifierAccessValid::HandleCallExpression(CheckContext &ctx, const ir::AstNode *ast) +{ + if (!ast->IsCallExpression()) { + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; + } + const auto *callExpr = ast->AsCallExpression(); + const auto *callee = callExpr->Callee(); + if (callee != nullptr && callee->IsMemberExpression()) { + const auto *calleeMember = callee->AsMemberExpression(); + const auto *propVarCallee = calleeMember->PropVar(); + if (propVarCallee != nullptr && propVarCallee->HasFlag(varbinder::VariableFlags::METHOD) && + !ValidateMethodAccess(calleeMember, ast->AsCallExpression())) { + ctx.AddCheckMessage("PROPERTY_NOT_VISIBLE_HERE", *callee, callee->Start()); + return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; + } + } + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; +} + +} // namespace ark::es2panda::compiler::ast_verifier diff --git a/ets2panda/ast_verifier/modifierAccessValid.h b/ets2panda/ast_verifier/modifierAccessValid.h new file mode 100644 index 0000000000000000000000000000000000000000..dbe24bfea0a14bc539b9c571cdcacc4638613a80 --- /dev/null +++ b/ets2panda/ast_verifier/modifierAccessValid.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_MODIFIERACCESSVALID_H +#define ES2PANDA_COMPILER_CORE_AST_VERIFIER_MODIFIERACCESSVALID_H + +#include "checkContext.h" + +namespace ark::es2panda::compiler::ast_verifier { + +class ModifierAccessValid { +public: + explicit ModifierAccessValid([[maybe_unused]] ArenaAllocator &allocator) {} + [[nodiscard]] CheckResult operator()(CheckContext &ctx, const ir::AstNode *ast); + +private: + CheckResult HandleMethodExpression(CheckContext &ctx, const ir::AstNode *ast); + CheckResult HandleCallExpression(CheckContext &ctx, const ir::AstNode *ast); +}; + +} // namespace ark::es2panda::compiler::ast_verifier + +#endif // ES2PANDA_COMPILER_CORE_AST_VERIFIER_MODIFIERACCESSVALID_H diff --git a/ets2panda/ast_verifier/nodeHasParent.cpp b/ets2panda/ast_verifier/nodeHasParent.cpp new file mode 100644 index 0000000000000000000000000000000000000000..94a78985d8d64c9aa36fb4439d4e8e2139f00e3a --- /dev/null +++ b/ets2panda/ast_verifier/nodeHasParent.cpp @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "nodeHasParent.h" + +#include "ir/statements/blockStatement.h" + +namespace ark::es2panda::compiler::ast_verifier { + +CheckResult NodeHasParent::operator()(CheckContext &ctx, const ir::AstNode *ast) +{ + const auto isEtsScript = ast->IsETSScript() || (ast->IsBlockStatement() && ast->AsBlockStatement()->IsProgram()); + const auto hasParent = ast->Parent() != nullptr; + if (!isEtsScript && !hasParent) { + ctx.AddCheckMessage("NULL_PARENT", *ast, ast->Start()); + return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; + } + + if (ast->IsProgram()) { + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; + } + + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; +} + +} // namespace ark::es2panda::compiler::ast_verifier diff --git a/ets2panda/ast_verifier/nodeHasParent.h b/ets2panda/ast_verifier/nodeHasParent.h new file mode 100644 index 0000000000000000000000000000000000000000..852feb718746eac92e88089123b46c3f3bd52206 --- /dev/null +++ b/ets2panda/ast_verifier/nodeHasParent.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_NODEHASPARENT_H +#define ES2PANDA_COMPILER_CORE_AST_VERIFIER_NODEHASPARENT_H + +#include "checkContext.h" + +namespace ark::es2panda::compiler::ast_verifier { + +class NodeHasParent { +public: + explicit NodeHasParent([[maybe_unused]] ArenaAllocator &allocator) {} + [[nodiscard]] CheckResult operator()(CheckContext &ctx, const ir::AstNode *ast); +}; + +} // namespace ark::es2panda::compiler::ast_verifier + +#endif // ES2PANDA_COMPILER_CORE_AST_VERIFIER_NODEHASPARENT_H diff --git a/ets2panda/ast_verifier/nodeHasSourceRange.cpp b/ets2panda/ast_verifier/nodeHasSourceRange.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f6bee31d65dabc79a594d7e5e9153413adfbfe22 --- /dev/null +++ b/ets2panda/ast_verifier/nodeHasSourceRange.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "nodeHasSourceRange.h" + +namespace ark::es2panda::compiler::ast_verifier { + +CheckResult NodeHasSourceRange::operator()(CheckContext &ctx, const ir::AstNode *ast) +{ + const auto hasRange = + ast->Start().line != 0 || ast->Start().index != 0 || ast->End().line != 0 || ast->End().index != 0; + if (!hasRange) { + ctx.AddCheckMessage("NULL_RANGE", *ast, ast->Start()); + return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; + } + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; +} + +} // namespace ark::es2panda::compiler::ast_verifier diff --git a/ets2panda/ast_verifier/nodeHasSourceRange.h b/ets2panda/ast_verifier/nodeHasSourceRange.h new file mode 100644 index 0000000000000000000000000000000000000000..d5fe280ee00de0d9fe5b31cefaa7998fce752d2d --- /dev/null +++ b/ets2panda/ast_verifier/nodeHasSourceRange.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_NODEHASSOURCERANGE_H +#define ES2PANDA_COMPILER_CORE_AST_VERIFIER_NODEHASSOURCERANGE_H + +#include "checkContext.h" + +namespace ark::es2panda::compiler::ast_verifier { + +class NodeHasSourceRange { +public: + explicit NodeHasSourceRange([[maybe_unused]] ArenaAllocator &allocator) {} + [[nodiscard]] CheckResult operator()(CheckContext &ctx, const ir::AstNode *ast); +}; + +} // namespace ark::es2panda::compiler::ast_verifier + +#endif // ES2PANDA_COMPILER_CORE_AST_VERIFIER_NODEHASSOURCERANGE_H diff --git a/ets2panda/ast_verifier/nodeHasType.cpp b/ets2panda/ast_verifier/nodeHasType.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d6f7c0e53466ebbff8357efcf702ada534f36cbf --- /dev/null +++ b/ets2panda/ast_verifier/nodeHasType.cpp @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "helpers.h" +#include "nodeHasType.h" +#include "ir/base/classDefinition.h" +#include "ir/expressions/identifier.h" +#include "ir/ts/tsEnumDeclaration.h" +#include "ir/ts/tsInterfaceBody.h" +#include "ir/ts/tsInterfaceDeclaration.h" + +namespace ark::es2panda::compiler::ast_verifier { + +CheckResult NodeHasType::operator()(CheckContext &ctx, const ir::AstNode *ast) +{ + // NOTE(orlovskymaxim) In TS some ETS constructs are expressions (i.e. class/interface definition) + // Because ETS uses some AST classes from TS this introduces semantical problem + // Solution for now - manually filter expressions that are statements in ETS + if (ast->IsETSPackageDeclaration()) { + return {CheckDecision::CORRECT, CheckAction::SKIP_SUBTREE}; + } + if (IsImportLike(ast)) { + return {CheckDecision::CORRECT, CheckAction::SKIP_SUBTREE}; + } + if (IsExportLike(ast)) { + return {CheckDecision::CORRECT, CheckAction::SKIP_SUBTREE}; + } + + if (ast->IsTSTypeAliasDeclaration()) { + return {CheckDecision::CORRECT, CheckAction::SKIP_SUBTREE}; + } + if (auto [decision, action] = CheckCompound(ctx, ast); action == CheckAction::SKIP_SUBTREE) { + return {decision, action}; + } + + if (ast->IsTyped() && ast->IsExpression()) { + if (ast->IsClassDefinition() && ast->AsClassDefinition()->Ident()->Name() == "ETSGLOBAL") { + return {CheckDecision::CORRECT, CheckAction::SKIP_SUBTREE}; + } + if (ast->IsIdentifier() && ast->AsIdentifier()->Name() == "") { + return {CheckDecision::CORRECT, CheckAction::SKIP_SUBTREE}; + } + const auto *typed = static_cast(ast); + if (typed->TsType() == nullptr) { + ctx.AddCheckMessage("NULL_TS_TYPE", *ast, ast->Start()); + return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; + } + } + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; +} + +CheckResult NodeHasType::CheckCompound(CheckContext &ctx, const ir::AstNode *ast) +{ + if (ast->IsTSInterfaceDeclaration()) { + for (const auto &member : ast->AsTSInterfaceDeclaration()->Body()->Body()) { + [[maybe_unused]] auto _ = (*this)(ctx, member); + } + return {CheckDecision::CORRECT, CheckAction::SKIP_SUBTREE}; + } + if (ast->IsTSEnumDeclaration()) { + for (const auto &member : ast->AsTSEnumDeclaration()->Members()) { + [[maybe_unused]] auto _ = (*this)(ctx, member); + } + return {CheckDecision::CORRECT, CheckAction::SKIP_SUBTREE}; + } + if (ast->IsClassDefinition()) { + for (const auto &member : ast->AsClassDefinition()->Body()) { + [[maybe_unused]] auto _ = (*this)(ctx, member); + } + return {CheckDecision::CORRECT, CheckAction::SKIP_SUBTREE}; + } + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; +} + +} // namespace ark::es2panda::compiler::ast_verifier diff --git a/ets2panda/ast_verifier/nodeHasType.h b/ets2panda/ast_verifier/nodeHasType.h new file mode 100644 index 0000000000000000000000000000000000000000..2d7427372eb759303bc13b6d546147c4c42f6a6e --- /dev/null +++ b/ets2panda/ast_verifier/nodeHasType.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_NODEHASTYPE_H +#define ES2PANDA_COMPILER_CORE_AST_VERIFIER_NODEHASTYPE_H + +#include "checkContext.h" + +namespace ark::es2panda::compiler::ast_verifier { + +class NodeHasType { +public: + explicit NodeHasType([[maybe_unused]] ArenaAllocator &allocator) {} + [[nodiscard]] CheckResult operator()(CheckContext &ctx, const ir::AstNode *ast); + +private: + CheckResult CheckCompound(CheckContext &ctx, const ir::AstNode *ast); +}; + +} // namespace ark::es2panda::compiler::ast_verifier + +#endif // ES2PANDA_COMPILER_CORE_AST_VERIFIER_NODEHASTYPE_H diff --git a/ets2panda/ast_verifier/referenceTypeAnnotationIsNull.cpp b/ets2panda/ast_verifier/referenceTypeAnnotationIsNull.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5770b83e92e4fbacfeb7f8757c00d1222ccfece9 --- /dev/null +++ b/ets2panda/ast_verifier/referenceTypeAnnotationIsNull.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "referenceTypeAnnotationIsNull.h" + +#include "ir/expressions/identifier.h" + +namespace ark::es2panda::compiler::ast_verifier { + +CheckResult ReferenceTypeAnnotationIsNull::operator()(CheckContext &ctx, const ir::AstNode *ast) +{ + auto result = std::make_tuple(CheckDecision::CORRECT, CheckAction::CONTINUE); + if (ast->IsIdentifier()) { + if (ast->AsIdentifier()->IsReference() && ast->AsIdentifier()->TypeAnnotation() != nullptr) { + ctx.AddCheckMessage("TYPE_ANNOTATION_NOT_NULLPTR", *ast, ast->Start()); + result = {CheckDecision::INCORRECT, CheckAction::CONTINUE}; + } + } + return result; +} + +} // namespace ark::es2panda::compiler::ast_verifier diff --git a/ets2panda/ast_verifier/referenceTypeAnnotationIsNull.h b/ets2panda/ast_verifier/referenceTypeAnnotationIsNull.h new file mode 100644 index 0000000000000000000000000000000000000000..0be6c7ef2baf24b49376b092d98639ca6cc93f28 --- /dev/null +++ b/ets2panda/ast_verifier/referenceTypeAnnotationIsNull.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_REFERENCETYPEANNOTATIONISNULL_H +#define ES2PANDA_COMPILER_CORE_AST_VERIFIER_REFERENCETYPEANNOTATIONISNULL_H + +#include "checkContext.h" + +namespace ark::es2panda::compiler::ast_verifier { + +class ReferenceTypeAnnotationIsNull { +public: + explicit ReferenceTypeAnnotationIsNull([[maybe_unused]] ArenaAllocator &allocator) {} + [[nodiscard]] CheckResult operator()(CheckContext &ctx, const ir::AstNode *ast); +}; + +} // namespace ark::es2panda::compiler::ast_verifier + +#endif // ES2PANDA_COMPILER_CORE_AST_VERIFIER_REFERENCETYPEANNOTATIONISNULL_H diff --git a/ets2panda/ast_verifier/sequenceExpressionHasLastType.cpp b/ets2panda/ast_verifier/sequenceExpressionHasLastType.cpp new file mode 100644 index 0000000000000000000000000000000000000000..28fc77836e999d0dbb687a51a152e4238c3614d1 --- /dev/null +++ b/ets2panda/ast_verifier/sequenceExpressionHasLastType.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "sequenceExpressionHasLastType.h" +#include "ir/expressions/sequenceExpression.h" + +namespace ark::es2panda::compiler::ast_verifier { + +[[nodiscard]] CheckResult SequenceExpressionHasLastType::operator()(CheckContext &ctx, const ir::AstNode *ast) +{ + if (!ast->IsSequenceExpression()) { + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; + } + const auto *expr = ast->AsSequenceExpression(); + const auto *last = expr->Sequence().back(); + if (expr->TsType() == nullptr) { + ctx.AddCheckMessage("Sequence expression type is null", *expr, expr->Start()); + return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; + } + if (last->TsType() == nullptr) { + ctx.AddCheckMessage("Sequence expression last type is null", *last, last->Start()); + return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; + } + if (expr->TsType() != last->TsType()) { + ctx.AddCheckMessage("Sequence expression type and last expression type are not the same", *expr, expr->Start()); + return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; + } + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; +} + +} // namespace ark::es2panda::compiler::ast_verifier diff --git a/ets2panda/ast_verifier/sequenceExpressionHasLastType.h b/ets2panda/ast_verifier/sequenceExpressionHasLastType.h new file mode 100644 index 0000000000000000000000000000000000000000..64087b3ac188b1af2f3eb88490cac1141cb0a342 --- /dev/null +++ b/ets2panda/ast_verifier/sequenceExpressionHasLastType.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_SEQUENCEEXPRESSIONHASLASTTYPE_H +#define ES2PANDA_COMPILER_CORE_AST_VERIFIER_SEQUENCEEXPRESSIONHASLASTTYPE_H + +#include "checkContext.h" + +namespace ark::es2panda::compiler::ast_verifier { + +class SequenceExpressionHasLastType { +public: + explicit SequenceExpressionHasLastType([[maybe_unused]] ArenaAllocator &allocator) {} + [[nodiscard]] CheckResult operator()(CheckContext &ctx, const ir::AstNode *ast); + +private: +}; + +} // namespace ark::es2panda::compiler::ast_verifier + +#endif // ES2PANDA_COMPILER_CORE_AST_VERIFIER_SEQUENCEEXPRESSIONHASLASTTYPE_H diff --git a/ets2panda/ast_verifier/variableHasEnclosingScope.cpp b/ets2panda/ast_verifier/variableHasEnclosingScope.cpp new file mode 100644 index 0000000000000000000000000000000000000000..98e963e16c1927b3c98333fe3731bd3e44e2962b --- /dev/null +++ b/ets2panda/ast_verifier/variableHasEnclosingScope.cpp @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "variableHasEnclosingScope.h" +#include "variableHasScope.h" +#include "helpers.h" +#include "ir/expressions/functionExpression.h" +#include "ir/base/scriptFunction.h" +#include "ir/expressions/identifier.h" +#include "ir/typeNode.h" + +namespace ark::es2panda::compiler::ast_verifier { + +[[nodiscard]] CheckResult VariableHasEnclosingScope::operator()(CheckContext &ctx, const ir::AstNode *ast) +{ + const auto maybeVar = VariableHasScope::GetLocalScopeVariable(allocator_, ctx, ast); + if (!maybeVar) { + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; + } + const auto var = *maybeVar; + const auto scope = var->GetScope(); + if (scope == nullptr) { + // already checked + return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; + } + const auto encloseScope = scope->EnclosingVariableScope(); + if (encloseScope == nullptr) { + ctx.AddCheckMessage("NO_ENCLOSING_VAR_SCOPE", *ast, ast->Start()); + return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; + } + const auto node = scope->Node(); + auto result = std::make_tuple(CheckDecision::CORRECT, CheckAction::CONTINUE); + if (!IsContainedIn(ast, node)) { + if (CheckCatchClause(ast, node)) { + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; + } + + if (CheckAstExceptions(ast)) { + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; + } + + result = {CheckDecision::INCORRECT, CheckAction::CONTINUE}; + ctx.AddCheckMessage("VARIABLE_NOT_ENCLOSE_SCOPE", *ast, ast->Start()); + } + + if (!IsContainedIn(scope, encloseScope)) { + result = {CheckDecision::INCORRECT, CheckAction::CONTINUE}; + ctx.AddCheckMessage("VARIABLE_NOT_ENCLOSE_SCOPE", *ast, ast->Start()); + } + + return result; +} + +bool VariableHasEnclosingScope::CheckCatchClause(const ir::AstNode *ast, const ir::AstNode *node) const +{ + if (node == nullptr) { + return false; + } + + // Check that ast node is contained within node parent for Catch Clause: + // Catch Clause { + // Catch Body { + // AST that we need to check + // } + // Param (Scope Node) { + // } + // } + if (node->Parent() != nullptr && node->Parent()->IsCatchClause()) { + return IsContainedIn(ast, node->Parent()); + } + + return false; +} + +bool VariableHasEnclosingScope::CheckAstExceptions(const ir::AstNode *ast) const +{ + // NOTE(kkonkuznetsov): skip parameter expression inside arrow function expression + auto parent = ast->Parent(); + while (parent != nullptr) { + if (parent->IsETSParameterExpression()) { + return true; + } + + parent = parent->Parent(); + } + + // Labels are attached to loop scopes, + // however label identifier is outside of loop. + // Example: + // + // loop: for (let i = 0; i < 10; i++) { + // } + return (ast->Parent()->IsLabelledStatement()); +} + +} // namespace ark::es2panda::compiler::ast_verifier diff --git a/ets2panda/ast_verifier/variableHasEnclosingScope.h b/ets2panda/ast_verifier/variableHasEnclosingScope.h new file mode 100644 index 0000000000000000000000000000000000000000..cce4c2e2f7fefa7406f5bf98973a925fdb3d7998 --- /dev/null +++ b/ets2panda/ast_verifier/variableHasEnclosingScope.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_VARIABLEHASENCLOSINGSCOPE_H +#define ES2PANDA_COMPILER_CORE_AST_VERIFIER_VARIABLEHASENCLOSINGSCOPE_H + +#include "checkContext.h" + +namespace ark::es2panda::compiler::ast_verifier { + +class VariableHasEnclosingScope { +public: + explicit VariableHasEnclosingScope(ArenaAllocator &allocator) : allocator_ {allocator} {} + [[nodiscard]] CheckResult operator()(CheckContext &ctx, const ir::AstNode *ast); + +private: + bool CheckCatchClause(const ir::AstNode *ast, const ir::AstNode *node) const; + bool CheckScopeNodeExceptions(const ir::AstNode *node) const; + bool CheckAstExceptions(const ir::AstNode *ast) const; + + ArenaAllocator &allocator_; +}; + +} // namespace ark::es2panda::compiler::ast_verifier + +#endif // ES2PANDA_COMPILER_CORE_AST_VERIFIER_VARIABLEHASENCLOSINGSCOPE_H diff --git a/ets2panda/ast_verifier/variableHasScope.cpp b/ets2panda/ast_verifier/variableHasScope.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3048d912609b376277acf1c4cd4edc811e8556e6 --- /dev/null +++ b/ets2panda/ast_verifier/variableHasScope.cpp @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "helpers.h" +#include "identifierHasVariable.h" +#include "variableHasScope.h" +#include "ir/base/scriptFunction.h" +#include "ir/ts/tsEnumDeclaration.h" +#include "ir/typeNode.h" + +namespace ark::es2panda::compiler::ast_verifier { + +CheckResult VariableHasScope::operator()(CheckContext &ctx, const ir::AstNode *ast) +{ + if (!ast->IsIdentifier()) { + // Check invariant of Identifier only + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; + } + + // we will check invariant for only local variables of identifiers + if (const auto maybeVar = GetLocalScopeVariable(allocator_, ctx, ast); maybeVar.has_value()) { + const auto var = *maybeVar; + const auto scope = var->GetScope(); + if (scope == nullptr) { + ctx.AddCheckMessage("NULL_SCOPE_LOCAL_VAR", *ast, ast->Start()); + return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; + } + + auto result = std::make_tuple(CheckDecision::CORRECT, CheckAction::CONTINUE); + if (!ScopeEncloseVariable(ctx, var)) { + result = {CheckDecision::INCORRECT, CheckAction::CONTINUE}; + } + + return result; + } + + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; +} + +std::optional VariableHasScope::GetLocalScopeVariable(ArenaAllocator &allocator, + CheckContext &ctx, + const ir::AstNode *ast) +{ + if (!ast->IsIdentifier()) { + return std::nullopt; + } + + auto invariantHasVariable = IdentifierHasVariable {allocator}; + const auto variable = ast->AsIdentifier()->Variable(); + const auto [decision, action] = invariantHasVariable(ctx, ast); + + if (variable == nullptr) { + // NOTE(kkonkuznetsov): variable should not be null + // but currently some identifiers do not have variables, + // see exceptions in IdentifierHasVariable check + return std::nullopt; + } + + if (decision == CheckDecision::CORRECT && variable->IsLocalVariable()) { + const auto localVar = variable->AsLocalVariable(); + if (localVar->HasFlag(varbinder::VariableFlags::LOCAL)) { + return localVar; + } + } + + return std::nullopt; +} + +bool VariableHasScope::ScopeEncloseVariable(CheckContext &ctx, const varbinder::LocalVariable *var) +{ + ASSERT(var); + + const auto scope = var->GetScope(); + if (scope == nullptr || var->Declaration() == nullptr) { + return true; + } + + const auto node = var->Declaration()->Node(); + if (node == nullptr) { + return true; + } + + const auto varStart = node->Start(); + bool isOk = true; + if (scope->Bindings().count(var->Name()) == 0) { + ctx.AddCheckMessage("SCOPE_DO_NOT_ENCLOSE_LOCAL_VAR", *node, varStart); + isOk = false; + } + + const auto scopeNode = scope->Node(); + const auto varNode = node; + bool skip = CheckAstExceptions(varNode); + + if (!IsContainedIn(varNode, scopeNode) || scopeNode == nullptr) { + if (!skip) { + ctx.AddCheckMessage("SCOPE_NODE_DONT_DOMINATE_VAR_NODE", *node, varStart); + isOk = false; + } + } + + const auto &decls = scope->Decls(); + const auto declDominate = std::count(decls.begin(), decls.end(), var->Declaration()); + if (declDominate == 0) { + if (!skip) { + ctx.AddCheckMessage("SCOPE_DECL_DONT_DOMINATE_VAR_DECL", *node, varStart); + isOk = false; + } + } + + return isOk; +} + +bool VariableHasScope::CheckAstExceptions(const ir::AstNode *ast) +{ + // NODE(kkonkuznetsov): scope warnings with async lambdas + if (ast->IsETSParameterExpression()) { + return true; + } + + // NOTE(kkonkuznetsov): in some cases with lambdas scope node is null + if (ast->Parent() != nullptr && ast->Parent()->IsETSFunctionType()) { + return true; + } + + if (ast->IsLabelledStatement()) { + // Labels are attached to loop scopes, + // however label identifier is outside of loop. + // Example: + // + // loop: for (let i = 0; i < 10; i++) { + // } + return true; + } + + return false; +} + +} // namespace ark::es2panda::compiler::ast_verifier diff --git a/ets2panda/ast_verifier/variableHasScope.h b/ets2panda/ast_verifier/variableHasScope.h new file mode 100644 index 0000000000000000000000000000000000000000..52cc7a91cdc7873b5f0b27213d1954f10a95bd06 --- /dev/null +++ b/ets2panda/ast_verifier/variableHasScope.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_VARIABLEHASSCOPE_H +#define ES2PANDA_COMPILER_CORE_AST_VERIFIER_VARIABLEHASSCOPE_H + +#include "checkContext.h" + +#include "varbinder/varbinder.h" + +namespace ark::es2panda::compiler::ast_verifier { + +class VariableHasScope { +public: + explicit VariableHasScope(ArenaAllocator &allocator) : allocator_ {allocator} {} + + [[nodiscard]] CheckResult operator()(CheckContext &ctx, const ir::AstNode *ast); + static std::optional GetLocalScopeVariable(ArenaAllocator &allocator, CheckContext &ctx, + const ir::AstNode *ast); + bool ScopeEncloseVariable(CheckContext &ctx, const varbinder::LocalVariable *var); + +private: + ArenaAllocator &allocator_; + bool CheckAstExceptions(const ir::AstNode *ast); +}; + +} // namespace ark::es2panda::compiler::ast_verifier + +#endif // ES2PANDA_COMPILER_CORE_AST_VERIFIER_VARIABLEHASSCOPE_H diff --git a/ets2panda/ast_verifier/variableNameIdentifierNameSame.cpp b/ets2panda/ast_verifier/variableNameIdentifierNameSame.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f2bb9f7d5f371b60eafea274b1c924add29186d4 --- /dev/null +++ b/ets2panda/ast_verifier/variableNameIdentifierNameSame.cpp @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "variableNameIdentifierNameSame.h" +#include "ir/expressions/identifier.h" +#include "ir/ets/etsImportDeclaration.h" + +namespace ark::es2panda::compiler::ast_verifier { + +[[nodiscard]] CheckResult VariableNameIdentifierNameSame::operator()(CheckContext &ctx, const ir::AstNode *ast) +{ + if (!ast->IsIdentifier()) { + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; + } + const auto *id = ast->AsIdentifier(); + const auto variable = ast->AsIdentifier()->Variable(); + if (variable == nullptr || variable->Declaration() == nullptr || variable->Declaration()->Node() == nullptr) { + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; + } + const auto variableNode = variable->Declaration()->Node(); + // NOTE(psaykerone): skip because, this exceptions need to be fixed in checker and lowering + if (variableNode->IsExported() || variableNode->IsExportedType() || variableNode->IsDefaultExported() || + id->Name().Utf8().find("field") == 0 || variable->Name().Utf8().find("field") == 0) { + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; + } + if (id->Name() == variable->Name()) { + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; + } + + // For dynamic imports imported identifier name does not match variable name + // Example: + // import { A as AA } from "dynamic_js_import_tests" + // Variable name will be AA + // But imported identifier name is A + auto parent = ast->Parent(); + while (parent != nullptr) { + if (parent->IsETSImportDeclaration() && parent->AsETSImportDeclaration()->IsPureDynamic()) { + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; + } + + parent = parent->Parent(); + } + + ctx.AddCheckMessage("IDENTIFIER_NAME_DIFFERENCE", *id, id->Start()); + return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; +} + +} // namespace ark::es2panda::compiler::ast_verifier diff --git a/ets2panda/ast_verifier/variableNameIdentifierNameSame.h b/ets2panda/ast_verifier/variableNameIdentifierNameSame.h new file mode 100644 index 0000000000000000000000000000000000000000..3fec3eb3f187812f4c1c62cdb5a1532cd36b557c --- /dev/null +++ b/ets2panda/ast_verifier/variableNameIdentifierNameSame.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_VARIABLENAMEIDENTIFIERNAMESAME_H +#define ES2PANDA_COMPILER_CORE_AST_VERIFIER_VARIABLENAMEIDENTIFIERNAMESAME_H + +#include "checkContext.h" + +namespace ark::es2panda::compiler::ast_verifier { + +class VariableNameIdentifierNameSame { +public: + explicit VariableNameIdentifierNameSame([[maybe_unused]] ArenaAllocator &allocator) {} + [[nodiscard]] CheckResult operator()(CheckContext &ctx, const ir::AstNode *ast); +}; + +} // namespace ark::es2panda::compiler::ast_verifier + +#endif // ES2PANDA_COMPILER_CORE_AST_VERIFIER_VARIABLENAMEIDENTIFIERNAMESAME_H diff --git a/ets2panda/checker/ETSAnalyzer.cpp b/ets2panda/checker/ETSAnalyzer.cpp index 3c2b0b35f595a679137b9e2ed17d638432819080..07ef75514b94a27f5dd162abc9c17ec2f0b57ffa 100644 --- a/ets2panda/checker/ETSAnalyzer.cpp +++ b/ets2panda/checker/ETSAnalyzer.cpp @@ -96,7 +96,7 @@ checker::Type *ETSAnalyzer::Check(ir::ClassProperty *st) const st->SetTsType(checker->CheckVariableDeclaration(st->Id(), st->TypeAnnotation(), st->Value(), st->Modifiers())); - return st->TsType(); + return st->TsTypeOrError(); } checker::Type *ETSAnalyzer::Check(ir::ClassStaticBlock *st) const @@ -782,8 +782,8 @@ checker::Type *ETSAnalyzer::Check(ir::ArrowFunctionExpression *expr) const checker::Type *ETSAnalyzer::Check(ir::AssignmentExpression *const expr) const { - if (expr->TsType() != nullptr) { - return expr->TsType(); + if (expr->TsTypeOrError() != nullptr) { + return expr->TsTypeOrError(); } ETSChecker *checker = GetETSChecker(); @@ -841,7 +841,7 @@ checker::Type *ETSAnalyzer::Check(ir::AssignmentExpression *const expr) const } expr->SetTsType(smartType); - return expr->TsType(); + return expr->TsTypeOrError(); } std::tuple ETSAnalyzer::CheckAssignmentExprOperatorType(ir::AssignmentExpression *expr, @@ -943,8 +943,8 @@ checker::Type *ETSAnalyzer::UnwrapPromiseType(checker::Type *type) const checker::Type *ETSAnalyzer::Check(ir::BinaryExpression *expr) const { - if (expr->TsType() != nullptr) { - return expr->TsType(); + if (expr->TsTypeOrError() != nullptr) { + return expr->TsTypeOrError(); } ETSChecker *checker = GetETSChecker(); @@ -955,7 +955,7 @@ checker::Type *ETSAnalyzer::Check(ir::BinaryExpression *expr) const checker->Context().CheckBinarySmartCastCondition(expr); - return expr->TsType(); + return expr->TsTypeOrError(); } checker::Type *ETSAnalyzer::Check(ir::BlockExpression *st) const @@ -1066,6 +1066,18 @@ checker::Type *ETSAnalyzer::GetReturnType(ir::CallExpression *expr, checker::Typ return returnType; } +static void CheckAbstractCall(ETSChecker *checker, ir::CallExpression *expr) +{ + if (expr->Callee()->IsMemberExpression()) { + auto obj = expr->Callee()->AsMemberExpression()->Object(); + if (obj != nullptr && obj->IsSuperExpression()) { + if ((expr->Signature() != nullptr) && (expr->Signature()->HasSignatureFlag(SignatureFlags::ABSTRACT))) { + checker->ThrowTypeError("Cannot call abstract method!", expr->Start()); + } + } + } +} + checker::Type *ETSAnalyzer::Check(ir::CallExpression *expr) const { ETSChecker *checker = GetETSChecker(); @@ -1121,6 +1133,7 @@ checker::Type *ETSAnalyzer::Check(ir::CallExpression *expr) const } CheckVoidTypeExpression(checker, expr); + CheckAbstractCall(checker, expr); return expr->TsType(); } @@ -1208,7 +1221,7 @@ checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::FunctionExpression *expr) checker::Type *ETSAnalyzer::Check(ir::Identifier *expr) const { - if (expr->TsType() == nullptr) { + if (expr->TsTypeOrError() == nullptr) { ETSChecker *checker = GetETSChecker(); auto *identType = checker->ResolveIdentifier(expr); @@ -1222,7 +1235,7 @@ checker::Type *ETSAnalyzer::Check(ir::Identifier *expr) const checker->Context().CheckIdentifierSmartCastCondition(expr); } - return expr->TsType(); + return expr->TsTypeOrError(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::ImportExpression *expr) const @@ -1368,7 +1381,18 @@ checker::Type *ETSAnalyzer::Check(ir::ObjectExpression *expr) const } checker::ETSObjectType *objType = expr->PreferredType()->AsETSObjectType(); - if (objType->HasObjectFlag(checker::ETSObjectFlags::ABSTRACT | checker::ETSObjectFlags::INTERFACE)) { + if (objType->HasObjectFlag(checker::ETSObjectFlags::INTERFACE)) { + // Object literal of interface tpye + // Further interfaceObjectLiteralLowering phase will resolve interface type + // and create corresponding anonymous class and class type + // Here we just set the type to pass the checker + CheckObjectExprProps(expr, checker::PropertySearchFlags::SEARCH_INSTANCE_METHOD | + checker::PropertySearchFlags::SEARCH_IN_INTERFACES); + expr->SetTsType(objType); + return objType; + } + + if (objType->HasObjectFlag(checker::ETSObjectFlags::ABSTRACT)) { checker->ThrowTypeError({"target type for class composite ", objType->Name(), " is not instantiable"}, expr->Start()); } @@ -1395,13 +1419,15 @@ checker::Type *ETSAnalyzer::Check(ir::ObjectExpression *expr) const checker->ThrowTypeError({"type ", objType->Name(), " has no parameterless constructor"}, expr->Start()); } - CheckObjectExprProps(expr); + CheckObjectExprProps(expr, checker::PropertySearchFlags::SEARCH_INSTANCE_FIELD | + checker::PropertySearchFlags::SEARCH_IN_BASE | + checker::PropertySearchFlags::SEARCH_INSTANCE_METHOD); expr->SetTsType(objType); return objType; } -void ETSAnalyzer::CheckObjectExprProps(const ir::ObjectExpression *expr) const +void ETSAnalyzer::CheckObjectExprProps(const ir::ObjectExpression *expr, checker::PropertySearchFlags searchFlags) const { ETSChecker *checker = GetETSChecker(); checker::ETSObjectType *objType = expr->PreferredType()->AsETSObjectType(); @@ -1421,9 +1447,7 @@ void ETSAnalyzer::CheckObjectExprProps(const ir::ObjectExpression *expr) const checker->ThrowTypeError({"key in class composite should be either identifier or string literal"}, expr->Start()); } - varbinder::LocalVariable *lv = objType->GetProperty( - pname, checker::PropertySearchFlags::SEARCH_INSTANCE_FIELD | checker::PropertySearchFlags::SEARCH_IN_BASE | - checker::PropertySearchFlags::SEARCH_INSTANCE_METHOD); + varbinder::LocalVariable *lv = objType->GetProperty(pname, searchFlags); if (lv == nullptr) { checker->ThrowTypeError({"type ", objType->Name(), " has no property named ", pname}, propExpr->Start()); } @@ -2325,7 +2349,7 @@ checker::Type *ETSAnalyzer::Check(ir::VariableDeclarator *st) const // Now try to define the actual type of Identifier so that smart cast can be used in further checker processing // NOTE: T_S and K_o_t_l_i_n don't act in such way, but we can try - why not? :) - if (auto *const initType = st->Init() != nullptr ? st->Init()->TsType() : nullptr; initType != nullptr) { + if (auto *const initType = st->Init() != nullptr ? st->Init()->TsTypeOrError() : nullptr; initType != nullptr) { smartType = checker->ResolveSmartType(initType, variableType); // Set smart type for identifier if it differs from annotated type // Top-level and captured variables are not processed here! @@ -2476,9 +2500,9 @@ checker::Type *ETSAnalyzer::Check(ir::TSEnumDeclaration *st) const if (enumVar->TsType() == nullptr) { checker::Type *etsEnumType = nullptr; if (auto *const itemInit = st->Members().front()->AsTSEnumMember()->Init(); itemInit->IsNumberLiteral()) { - etsEnumType = checker->CreateEnumIntClassFromEnumDeclaration(st); + etsEnumType = checker->CreateEnumIntTypeFromEnumDeclaration(st); } else if (itemInit->IsStringLiteral()) { - etsEnumType = checker->CreateEnumStringClassFromEnumDeclaration(st); + etsEnumType = checker->CreateEnumStringTypeFromEnumDeclaration(st); } else { checker->ThrowTypeError("Invalid enumeration value type.", st->Start()); } @@ -2658,10 +2682,14 @@ checker::Type *ETSAnalyzer::Check(ir::TSQualifiedName *expr) const // clang-format off auto searchName = importDecl->IsETSImportDeclaration() - ? checker->VarBinder()->AsETSBinder()->GetExportSelectiveAliasValue( + ? checker->VarBinder()->AsETSBinder()->FindNameInAliasMap( importDecl->AsETSImportDeclaration()->ResolvedSource()->Str(), expr->Right()->Name()) : expr->Right()->Name(); // clang-format on + // NOTE (oeotvos) This should be done differently in the follow-up patch. + if (searchName.Empty()) { + searchName = expr->Right()->Name(); + } varbinder::Variable *prop = baseType->AsETSObjectType()->GetProperty(searchName, checker::PropertySearchFlags::SEARCH_DECL); @@ -2669,7 +2697,7 @@ checker::Type *ETSAnalyzer::Check(ir::TSQualifiedName *expr) const checker->ThrowTypeError({"'", expr->Right()->Name(), "' type does not exist."}, expr->Right()->Start()); } - if (expr->Right()->Name().Is(searchName.Mutf8()) && prop->Declaration()->Node()->HasAliasExport()) { + if (expr->Right()->Name().Is(searchName.Mutf8()) && prop->Declaration()->Node()->HasExportAlias()) { checker->ThrowTypeError({"Cannot find imported element '", searchName, "' exported with alias"}, expr->Right()->Start()); } diff --git a/ets2panda/checker/ETSAnalyzer.h b/ets2panda/checker/ETSAnalyzer.h index 87a0d3b51249ab3873ab7e0919223f4599992002..13c86fc45ccb28243d02f89a0ccab2f67cdcc95d 100644 --- a/ets2panda/checker/ETSAnalyzer.h +++ b/ets2panda/checker/ETSAnalyzer.h @@ -38,7 +38,7 @@ public: #undef DECLARE_ETSANALYZER_CHECK_METHOD checker::Type *PreferredType(ir::ObjectExpression *expr) const; checker::Type *GetPreferredType(ir::ArrayExpression *expr) const; - void CheckObjectExprProps(const ir::ObjectExpression *expr) const; + void CheckObjectExprProps(const ir::ObjectExpression *expr, checker::PropertySearchFlags searchFlags) const; std::tuple CheckAssignmentExprOperatorType(ir::AssignmentExpression *expr, Type *leftType) const; diff --git a/ets2panda/checker/ETSAnalyzerHelpers.cpp b/ets2panda/checker/ETSAnalyzerHelpers.cpp index 40137fbd1a05caa6644d6ea471404b690d4154ea..fecc7a9b03fb892e35c498df6c726de7bde23cc4 100644 --- a/ets2panda/checker/ETSAnalyzerHelpers.cpp +++ b/ets2panda/checker/ETSAnalyzerHelpers.cpp @@ -171,7 +171,7 @@ void ComposeAsyncImplFuncReturnType(ETSChecker *checker, ir::ScriptFunction *scr void ComposeAsyncImplMethod(ETSChecker *checker, ir::MethodDefinition *node) { - auto *classDef = node->Parent()->AsClassDefinition(); + auto *classDef = checker->FindAncestorGivenByType(node, ir::AstNodeType::CLASS_DEFINITION)->AsClassDefinition(); auto *scriptFunc = node->Function(); ir::MethodDefinition *implMethod = checker->CreateAsyncProxy(node, classDef); diff --git a/ets2panda/checker/ETSchecker.cpp b/ets2panda/checker/ETSchecker.cpp index 8556428fab368b58762f763e3be2ecde65e43204..9fe7f675e13b9b9ba132df93b496def78aed6ae6 100644 --- a/ets2panda/checker/ETSchecker.cpp +++ b/ets2panda/checker/ETSchecker.cpp @@ -138,26 +138,14 @@ void ETSChecker::InitializeBuiltin(varbinder::Variable *var, const util::StringV GetGlobalTypesHolder()->InitializeBuiltin(name, type); } -bool ETSChecker::StartChecker([[maybe_unused]] varbinder::VarBinder *varbinder, const CompilerOptions &options) +bool ETSChecker::StartChecker(varbinder::VarBinder *varbinder, const CompilerOptions &options) { Initialize(varbinder); - if (options.dumpAst) { - std::cout << Program()->Dump() << std::endl; - } - - if (options.opDumpAstOnlySilent) { - Program()->DumpSilent(); - return false; - } - if (options.parseOnly) { return false; } - varbinder->SetGenStdLib(options.compilationMode == CompilationMode::GEN_STD_LIB); - varbinder->IdentifierAnalysis(); - auto *etsBinder = varbinder->AsETSBinder(); InitializeBuiltins(etsBinder); @@ -185,7 +173,7 @@ bool ETSChecker::StartChecker([[maybe_unused]] varbinder::VarBinder *varbinder, CheckWarnings(Program(), options); } - return true; + return !ErrorLogger()->IsAnyError(); } void ETSChecker::CheckProgram(parser::Program *program, bool runAnalysis) @@ -196,6 +184,8 @@ void ETSChecker::CheckProgram(parser::Program *program, bool runAnalysis) for (auto &[_, extPrograms] : program->ExternalSources()) { (void)_; for (auto *extProg : extPrograms) { + checker::SavedCheckerContext savedContext(this, Context().Status(), Context().ContainingClass()); + AddStatus(checker::CheckerStatus::IN_EXTERNAL); CheckProgram(extProg, VarBinder()->IsGenStdLib()); } } @@ -430,6 +420,11 @@ const GlobalArraySignatureMap &ETSChecker::GlobalArrayTypes() const return globalArraySignatures_; } +Type *ETSChecker::GlobalTypeError() const +{ + return GetGlobalTypesHolder()->GlobalTypeError(); +} + void ETSChecker::HandleUpdatedCallExpressionNode(ir::CallExpression *callExpr) { VarBinder()->AsETSBinder()->HandleCustomNodes(callExpr); diff --git a/ets2panda/checker/ETSchecker.h b/ets2panda/checker/ETSchecker.h index 51bd4b1f22822180c11f0fcd9f080d6bcdf84ec9..33260da9f4950fca1f81b0c1e46ed3cdcb68cd32 100644 --- a/ets2panda/checker/ETSchecker.h +++ b/ets2panda/checker/ETSchecker.h @@ -133,6 +133,8 @@ public: GlobalArraySignatureMap &GlobalArrayTypes(); const GlobalArraySignatureMap &GlobalArrayTypes() const; + Type *GlobalTypeError() const; + void InitializeBuiltins(varbinder::ETSBinder *varbinder); void InitializeBuiltin(varbinder::Variable *var, const util::StringView &name); bool StartChecker([[maybe_unused]] varbinder::VarBinder *varbinder, const CompilerOptions &options) override; @@ -241,8 +243,8 @@ public: ETSBigIntType *CreateETSBigIntLiteralType(util::StringView value); ETSStringType *CreateETSStringLiteralType(util::StringView value); ETSArrayType *CreateETSArrayType(Type *elementType); - ETSEnumType *CreateEnumIntClassFromEnumDeclaration(ir::TSEnumDeclaration const *const enumDecl); - ETSStringEnumType *CreateEnumStringClassFromEnumDeclaration(ir::TSEnumDeclaration const *const enumDecl); + ETSEnumType *CreateEnumIntTypeFromEnumDeclaration(ir::TSEnumDeclaration const *const enumDecl); + ETSStringEnumType *CreateEnumStringTypeFromEnumDeclaration(ir::TSEnumDeclaration const *const enumDecl); Type *CreateETSUnionType(Span constituentTypes); template @@ -278,8 +280,9 @@ public: Type *NegateNumericType(Type *type, ir::Expression *node); Type *BitwiseNegateNumericType(Type *type, ir::Expression *node); bool CheckBinaryOperatorForBigInt(Type *left, Type *right, lexer::TokenType op); - void CheckBinaryPlusMultDivOperandsForUnionType(const Type *leftType, const Type *rightType, - const ir::Expression *left, const ir::Expression *right); + [[nodiscard]] bool CheckBinaryPlusMultDivOperandsForUnionType(const Type *leftType, const Type *rightType, + const ir::Expression *left, + const ir::Expression *right); std::tuple CheckBinaryOperator(ir::Expression *left, ir::Expression *right, ir::Expression *expr, lexer::TokenType operationType, lexer::SourcePosition pos, bool forcePromotion = false); @@ -300,8 +303,9 @@ public: checker::Type *CheckBinaryOperatorLogical(ir::Expression *left, ir::Expression *right, ir::Expression *expr, lexer::SourcePosition pos, checker::Type *leftType, checker::Type *rightType, Type *unboxedL, Type *unboxedR); - std::tuple CheckBinaryOperatorStrictEqual(ir::Expression *left, lexer::SourcePosition pos, - checker::Type *leftType, checker::Type *rightType); + std::tuple CheckBinaryOperatorStrictEqual(ir::Expression *left, lexer::TokenType operationType, + lexer::SourcePosition pos, checker::Type *leftType, + checker::Type *rightType); std::optional> CheckBinaryOperatorEqualError(checker::Type *const leftType, checker::Type *const rightType, checker::Type *tsType, @@ -461,6 +465,7 @@ public: template void BindingsModuleObjectAddProperty(checker::ETSObjectType *moduleObjType, ir::ETSImportDeclaration *importDecl, const varbinder::Scope::VariableMap &bindings); + util::StringView FindPropNameForNamespaceImport(const util::StringView &originalName); void SetPropertiesForModuleObject(checker::ETSObjectType *moduleObjType, const util::StringView &importPath, ir::ETSImportDeclaration *importDecl = nullptr); void SetrModuleObjectTsType(ir::Identifier *local, checker::ETSObjectType *moduleObjType); @@ -589,14 +594,13 @@ public: varbinder::ClassScope *scope, bool isSetter, ETSChecker *checker); void GenerateGetterSetterPropertyAndMethod(ir::ClassProperty *originalProp, ETSObjectType *classType); - ir::MethodDefinition *GenerateSetterForProperty(ir::ClassProperty *originalProp, ir::ClassProperty *interfaceProp, - ir::ClassProperty *classProp, ETSObjectType *classType, - ir::MethodDefinition *getter); ETSObjectType *GetImportSpecifierObjectType(ir::ETSImportDeclaration *importDecl, ir::Identifier *ident); void ImportNamespaceObjectTypeAddReExportType(ir::ETSImportDeclaration *importDecl, checker::ETSObjectType *lastObjectType, ir::Identifier *ident); checker::ETSObjectType *CreateSyntheticType(util::StringView const &syntheticName, checker::ETSObjectType *lastObjectType, ir::Identifier *id); + bool CheckValidUnionEqual(checker::Type *const leftType, checker::Type *const rightType); + bool CheckValidEqualReferenceType(checker::Type *const leftType, checker::Type *const rightType); void CheckVoidAnnotation(const ir::ETSPrimitiveType *typeAnnotation); // Utility type handler functions @@ -667,7 +671,7 @@ public: // Static invoke void CheckInvokeMethodsLegitimacy(ETSObjectType *classType); - checker::Type *CheckArrayElements(ir::Identifier *ident, ir::ArrayExpression *init); + checker::Type *CheckArrayElements(ir::ArrayExpression *init); void ResolveReturnStatement(checker::Type *funcReturnType, checker::Type *argumentType, ir::ScriptFunction *containingFunc, ir::ReturnStatement *st); @@ -701,19 +705,30 @@ public: void CollectReturnStatements(ir::AstNode *parent); ir::ETSParameterExpression *AddParam(util::StringView name, ir::TypeNode *type); - [[nodiscard]] ir::ScriptFunction *FindFunction(const util::UString &name); + [[nodiscard]] ir::ScriptFunction *FindFunction(ir::TSEnumDeclaration const *const enumDecl, + const std::string_view &name); -private: using ClassBuilder = std::function *)>; using ClassInitializerBuilder = std::function *, ArenaVector *)>; using MethodBuilder = std::function *, ArenaVector *, Type **)>; - ETSEnumType::Method MakeMethod(ir::TSEnumDeclaration const *const enumDecl, const std::string_view &name, - bool buildPorxyParam, Type *returnType, bool buildProxy = true); + ir::ClassStaticBlock *CreateClassStaticInitializer(const ClassInitializerBuilder &builder, + ETSObjectType *type = nullptr); + ir::MethodDefinition *CreateClassInstanceInitializer(const ClassInitializerBuilder &builder, + ETSObjectType *type = nullptr); + ir::MethodDefinition *CreateClassMethod(std::string_view name, ir::ScriptFunctionFlags funcFlags, + ir::ModifierFlags modifierFlags, const MethodBuilder &builder); + ir::ClassDeclaration *BuildClass(util::StringView name, const ClassBuilder &builder); + +private: + ETSEnumInterface::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); [[noreturn]] void ThrowError(ir::Identifier *ident); + void LogOperatorCannotBeApplied(lexer::TokenType operationType, checker::Type *const leftType, + checker::Type *const rightType, lexer::SourcePosition pos); void WrongContextErrorClassifyByType(ir::Identifier *ident, varbinder::Variable *resolved); void CheckEtsFunctionType(ir::Identifier *ident, ir::Identifier const *id, ir::TypeNode const *annotation); [[noreturn]] void NotResolvedError(ir::Identifier *const ident, const varbinder::Variable *classVar, @@ -740,22 +755,17 @@ private: PropertySearchFlags GetSearchFlags(const ir::MemberExpression *memberExpr, const varbinder::Variable *targetRef); PropertySearchFlags GetInitialSearchFlags(const ir::MemberExpression *memberExpr); const varbinder::Variable *GetTargetRef(const ir::MemberExpression *memberExpr); - ir::ClassDeclaration *BuildClass(util::StringView name, const ClassBuilder &builder); Type *GetTypeOfSetterGetter([[maybe_unused]] varbinder::Variable *var); void IterateInVariableContext([[maybe_unused]] varbinder::Variable *const var); void CheckInit(ir::Identifier *ident, ir::TypeNode *typeAnnotation, ir::Expression *init, checker::Type *annotationType, varbinder::Variable *const bindingVar); - template - std::pair CreateScriptFunction(ClassInitializerBuilder const &builder); - - template - std::conditional_t CreateClassInitializer( - const ClassInitializerBuilder &builder, ETSObjectType *type = nullptr); + template + EnumType *CreateEnumTypeFromEnumDeclaration(ir::TSEnumDeclaration const *const enumDecl); - template - ir::MethodDefinition *CreateClassMethod(std::string_view name, ir::ModifierFlags modifierFlags, - const MethodBuilder &builder); + std::pair CreateStaticScriptFunction( + ClassInitializerBuilder const &builder); + std::pair CreateScriptFunction(ClassInitializerBuilder const &builder); template ir::MethodDefinition *CreateDynamicCallIntrinsic(ir::Expression *callee, const ArenaVector &arguments, diff --git a/ets2panda/checker/checker.cpp b/ets2panda/checker/checker.cpp index 74e8235f7d25088c1c661a218750bfd3499bbdae..58893d3ee39638c737c9159ff3b7322333ff35a1 100644 --- a/ets2panda/checker/checker.cpp +++ b/ets2panda/checker/checker.cpp @@ -88,6 +88,19 @@ void Checker::ThrowTypeError(std::string_view message, const lexer::SourcePositi throw Error {ErrorType::TYPE, program_->SourceFilePath().Utf8(), message, loc.line, loc.col}; } +void Checker::LogTypeError(std::initializer_list list, const lexer::SourcePosition &pos) +{ + LogTypeError(FormatMsg(list), pos); +} + +void Checker::LogTypeError(std::string_view message, const lexer::SourcePosition &pos) +{ + lexer::LineIndex index(program_->SourceCode()); + lexer::SourceLocation loc = index.GetLocation(pos); + + errorLogger_.WriteLog(Error {ErrorType::TYPE, program_->SourceFilePath().Utf8(), message, loc.line, loc.col}); +} + void Checker::Warning(const std::string_view message, const lexer::SourcePosition &pos) const { lexer::LineIndex index(program_->SourceCode()); diff --git a/ets2panda/checker/checker.h b/ets2panda/checker/checker.h index ca422d842870f546dda03d3215f5824b243ec129..a462f5105ca90db078725f82e2bf979b7919f2bf 100644 --- a/ets2panda/checker/checker.h +++ b/ets2panda/checker/checker.h @@ -20,6 +20,7 @@ #include "checker/checkerContext.h" #include "checker/SemanticAnalyzer.h" +#include "util/errorLogger.h" namespace ark::es2panda::parser { class Program; @@ -166,6 +167,8 @@ public: [[noreturn]] void ThrowTypeError(std::string_view message, const lexer::SourcePosition &pos); [[noreturn]] void ThrowTypeError(std::initializer_list list, const lexer::SourcePosition &pos); + void LogTypeError(std::string_view message, const lexer::SourcePosition &pos); + void LogTypeError(std::initializer_list list, const lexer::SourcePosition &pos); void Warning(std::string_view message, const lexer::SourcePosition &pos) const; void ReportWarning(std::initializer_list list, const lexer::SourcePosition &pos); @@ -195,6 +198,11 @@ public: varbinder::VarBinder *VarBinder() const; + util::ErrorLogger *ErrorLogger() + { + return &errorLogger_; + } + protected: void Initialize(varbinder::VarBinder *varbinder); parser::Program *Program() const; @@ -209,6 +217,7 @@ private: varbinder::VarBinder *varbinder_ {}; parser::Program *program_ {}; varbinder::Scope *scope_ {}; + util::ErrorLogger errorLogger_; RelationHolder identicalResults_ {{}, RelationType::IDENTICAL}; RelationHolder assignableResults_ {{}, RelationType::ASSIGNABLE}; diff --git a/ets2panda/checker/checkerContext.h b/ets2panda/checker/checkerContext.h index f50d37811a4ac2c5147783e34ae6e525968b1049..67d2a0cf5cc2e525d819f9e300965489f88f9aa6 100644 --- a/ets2panda/checker/checkerContext.h +++ b/ets2panda/checker/checkerContext.h @@ -53,6 +53,7 @@ enum class CheckerStatus : uint32_t { MEET_BREAK = 1U << 21U, MEET_CONTINUE = 1U << 22U, MEET_THROW = 1U << 23U, + IN_EXTERNAL = 1U << 24U, }; } // namespace ark::es2panda::checker diff --git a/ets2panda/checker/ets/arithmetic.cpp b/ets2panda/checker/ets/arithmetic.cpp index b14670ef8429292733fb44802854802ec0f6487d..ca9afb7b830eb66e43ce2887d24142e3cfd03d31 100644 --- a/ets2panda/checker/ets/arithmetic.cpp +++ b/ets2panda/checker/ets/arithmetic.cpp @@ -16,6 +16,24 @@ #include "arithmetic.h" namespace ark::es2panda::checker { + +static inline void RepairTypeErrorsInOperands(Type **left, Type **right) +{ + if (IsTypeError(*left)) { + *left = *right; + } + if (IsTypeError(*right)) { + *right = *left; + } +} + +static inline void RepairTypeErrorWithDefault(Type **type, Type *dflt) +{ + if (IsTypeError(*type)) { + *type = dflt; + } +} + Type *ETSChecker::NegateNumericType(Type *type, ir::Expression *node) { ASSERT(type->HasTypeFlag(TypeFlag::CONSTANT | TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC)); @@ -158,29 +176,39 @@ bool ETSChecker::CheckBinaryOperatorForBigInt(Type *left, Type *right, lexer::To return true; } -void ETSChecker::CheckBinaryPlusMultDivOperandsForUnionType(const Type *leftType, const Type *rightType, +bool ETSChecker::CheckBinaryPlusMultDivOperandsForUnionType(const Type *leftType, const Type *rightType, const ir::Expression *left, const ir::Expression *right) { std::stringstream ss; if (leftType->IsETSUnionType()) { leftType->AsETSUnionType()->ToString(ss, false); - ThrowTypeError("Bad operand type: multiple types left in the normalized union type (" + ss.str() + - "). Unions are not allowed in binary expressions except equality.", - left->Start()); + LogTypeError("Bad operand type: multiple types left in the normalized union type (" + ss.str() + + "). Unions are not allowed in binary expressions except equality.", + left->Start()); + return false; } if (rightType->IsETSUnionType()) { rightType->AsETSUnionType()->ToString(ss, false); - ThrowTypeError("Bad operand type: multiple types left in the normalized union type (" + ss.str() + - "). Unions are not allowed in binary expressions except equality.", - right->Start()); + LogTypeError("Bad operand type: multiple types left in the normalized union type (" + ss.str() + + "). Unions are not allowed in binary expressions except equality.", + right->Start()); + return false; } + return true; } checker::Type *ETSChecker::CheckBinaryOperatorMulDivMod(ir::Expression *left, ir::Expression *right, lexer::TokenType operationType, lexer::SourcePosition pos, - bool isEqualOp, checker::Type *const leftType, - checker::Type *const rightType, Type *unboxedL, Type *unboxedR) + bool isEqualOp, checker::Type *leftType, + checker::Type *rightType, Type *unboxedL, Type *unboxedR) { + // Try to handle errors on a lower level + RepairTypeErrorsInOperands(&leftType, &rightType); + RepairTypeErrorsInOperands(&unboxedL, &unboxedR); + if (leftType->IsTypeError()) { // both are errors + return GlobalTypeError(); + } + checker::Type *tsType {}; auto [promotedType, bothConst] = ApplyBinaryOperatorPromotion(unboxedL, unboxedR, TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC, !isEqualOp); @@ -188,10 +216,13 @@ checker::Type *ETSChecker::CheckBinaryOperatorMulDivMod(ir::Expression *left, ir FlagExpressionWithUnboxing(leftType, unboxedL, left); FlagExpressionWithUnboxing(rightType, unboxedR, right); - CheckBinaryPlusMultDivOperandsForUnionType(leftType, rightType, left, right); + if (!CheckBinaryPlusMultDivOperandsForUnionType(leftType, rightType, left, right)) { + return GlobalTypeError(); + } if (promotedType == nullptr && !bothConst) { - ThrowTypeError("Bad operand type, the types of the operands must be numeric type.", pos); + LogTypeError("Bad operand type, the types of the operands must be numeric type.", pos); + return GlobalTypeError(); } if (bothConst) { @@ -204,19 +235,29 @@ checker::Type *ETSChecker::CheckBinaryOperatorMulDivMod(ir::Expression *left, ir checker::Type *ETSChecker::CheckBinaryOperatorPlus(ir::Expression *left, ir::Expression *right, lexer::TokenType operationType, lexer::SourcePosition pos, - bool isEqualOp, checker::Type *const leftType, - checker::Type *const rightType, Type *unboxedL, Type *unboxedR) + bool isEqualOp, checker::Type *leftType, checker::Type *rightType, + Type *unboxedL, Type *unboxedR) { + // Try to handle errors on a lower level + RepairTypeErrorsInOperands(&leftType, &rightType); + RepairTypeErrorsInOperands(&unboxedL, &unboxedR); + if (leftType->IsTypeError()) { // both are errors + return GlobalTypeError(); + } + if (leftType->IsETSStringType() || rightType->IsETSStringType()) { if (operationType == lexer::TokenType::PUNCTUATOR_MINUS || operationType == lexer::TokenType::PUNCTUATOR_MINUS_EQUAL) { - ThrowTypeError("Bad operand type, the types of the operands must be numeric type.", pos); + LogTypeError("Bad operand type, the types of the operands must be numeric type.", pos); + return GlobalTypeError(); } return HandleStringConcatenation(leftType, rightType); } - CheckBinaryPlusMultDivOperandsForUnionType(leftType, rightType, left, right); + if (!CheckBinaryPlusMultDivOperandsForUnionType(leftType, rightType, left, right)) { + return GlobalTypeError(); + } auto [promotedType, bothConst] = ApplyBinaryOperatorPromotion(unboxedL, unboxedR, TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC, !isEqualOp); @@ -225,7 +266,8 @@ checker::Type *ETSChecker::CheckBinaryOperatorPlus(ir::Expression *left, ir::Exp FlagExpressionWithUnboxing(rightType, unboxedR, right); if (promotedType == nullptr && !bothConst) { - ThrowTypeError("Bad operand type, the types of the operands must be numeric type or String.", pos); + LogTypeError("Bad operand type, the types of the operands must be numeric type or String.", pos); + return GlobalTypeError(); } if (bothConst) { @@ -237,11 +279,17 @@ checker::Type *ETSChecker::CheckBinaryOperatorPlus(ir::Expression *left, ir::Exp checker::Type *ETSChecker::CheckBinaryOperatorShift(ir::Expression *left, ir::Expression *right, lexer::TokenType operationType, lexer::SourcePosition pos, - bool isEqualOp, checker::Type *const leftType, - checker::Type *const rightType, Type *unboxedL, Type *unboxedR) + bool isEqualOp, checker::Type *leftType, checker::Type *rightType, + Type *unboxedL, Type *unboxedR) { + RepairTypeErrorWithDefault(&leftType, GlobalIntType()); + RepairTypeErrorWithDefault(&rightType, GlobalIntType()); + RepairTypeErrorWithDefault(&unboxedL, GlobalIntType()); + RepairTypeErrorWithDefault(&unboxedR, GlobalIntType()); + if (leftType->IsETSUnionType() || rightType->IsETSUnionType()) { - ThrowTypeError("Bad operand type, unions are not allowed in binary expressions except equality.", pos); + LogTypeError("Bad operand type, unions are not allowed in binary expressions except equality.", pos); + return GlobalTypeError(); } auto promotedLeftType = ApplyUnaryOperatorPromotion(unboxedL, false, !isEqualOp); @@ -253,7 +301,8 @@ checker::Type *ETSChecker::CheckBinaryOperatorShift(ir::Expression *left, ir::Ex if (promotedLeftType == nullptr || !promotedLeftType->HasTypeFlag(checker::TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC) || promotedRightType == nullptr || !promotedRightType->HasTypeFlag(checker::TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC)) { - ThrowTypeError("Bad operand type, the types of the operands must be numeric type.", pos); + LogTypeError("Bad operand type, the types of the operands must be numeric type.", pos); + return GlobalTypeError(); } if (promotedLeftType->HasTypeFlag(TypeFlag::CONSTANT) && promotedRightType->HasTypeFlag(TypeFlag::CONSTANT)) { @@ -287,24 +336,18 @@ checker::Type *ETSChecker::CheckBinaryOperatorShift(ir::Expression *left, ir::Ex checker::Type *ETSChecker::CheckBinaryOperatorBitwise(ir::Expression *left, ir::Expression *right, lexer::TokenType operationType, lexer::SourcePosition pos, - bool isEqualOp, checker::Type *const leftType, - checker::Type *const rightType, Type *unboxedL, Type *unboxedR) + bool isEqualOp, checker::Type *leftType, checker::Type *rightType, + Type *unboxedL, Type *unboxedR) { - // NOTE (mmartin): These need to be done for other binary expressions, but currently it's not defined precisely when - // to apply this conversion - - if (leftType->IsETSEnumType()) { - left->AddAstNodeFlags(ir::AstNodeFlags::ENUM_GET_VALUE); - unboxedL = GlobalIntType(); - } - - if (rightType->IsETSEnumType()) { - right->AddAstNodeFlags(ir::AstNodeFlags::ENUM_GET_VALUE); - unboxedR = GlobalIntType(); + RepairTypeErrorsInOperands(&leftType, &rightType); + RepairTypeErrorsInOperands(&unboxedL, &unboxedR); + if (leftType->IsTypeError()) { // both are errors + return GlobalTypeError(); } if (leftType->IsETSUnionType() || rightType->IsETSUnionType()) { - ThrowTypeError("Bad operand type, unions are not allowed in binary expressions except equality.", pos); + LogTypeError("Bad operand type, unions are not allowed in binary expressions except equality.", pos); + return GlobalTypeError(); } if (unboxedL != nullptr && unboxedL->HasTypeFlag(checker::TypeFlag::ETS_BOOLEAN) && unboxedR != nullptr && @@ -321,7 +364,8 @@ checker::Type *ETSChecker::CheckBinaryOperatorBitwise(ir::Expression *left, ir:: FlagExpressionWithUnboxing(rightType, unboxedR, right); if (promotedType == nullptr && !bothConst) { - ThrowTypeError("Bad operand type, the types of the operands must be numeric type.", pos); + LogTypeError("Bad operand type, the types of the operands must be numeric type.", pos); + return GlobalTypeError(); } if (bothConst) { @@ -332,16 +376,24 @@ checker::Type *ETSChecker::CheckBinaryOperatorBitwise(ir::Expression *left, ir:: } checker::Type *ETSChecker::CheckBinaryOperatorLogical(ir::Expression *left, ir::Expression *right, ir::Expression *expr, - lexer::SourcePosition pos, checker::Type *const leftType, - checker::Type *const rightType, Type *unboxedL, Type *unboxedR) + lexer::SourcePosition pos, checker::Type *leftType, + checker::Type *rightType, Type *unboxedL, Type *unboxedR) { + RepairTypeErrorsInOperands(&leftType, &rightType); + RepairTypeErrorsInOperands(&unboxedL, &unboxedR); + if (leftType->IsTypeError()) { // both are errors + return GlobalTypeError(); + } + if (leftType->IsETSUnionType() || rightType->IsETSUnionType()) { - ThrowTypeError("Bad operand type, unions are not allowed in binary expressions except equality.", pos); + LogTypeError("Bad operand type, unions are not allowed in binary expressions except equality.", pos); + return GlobalTypeError(); } if (unboxedL == nullptr || !unboxedL->IsConditionalExprType() || unboxedR == nullptr || !unboxedR->IsConditionalExprType()) { - ThrowTypeError("Bad operand type, the types of the operands must be of possible condition type.", pos); + LogTypeError("Bad operand type, the types of the operands must be of possible condition type.", pos); + return GlobalTypeError(); } if (unboxedL->HasTypeFlag(checker::TypeFlag::ETS_PRIMITIVE)) { @@ -359,23 +411,81 @@ checker::Type *ETSChecker::CheckBinaryOperatorLogical(ir::Expression *left, ir:: UNREACHABLE(); } -std::tuple ETSChecker::CheckBinaryOperatorStrictEqual(ir::Expression *left, lexer::SourcePosition pos, - checker::Type *const leftType, - checker::Type *const rightType) +void ETSChecker::LogOperatorCannotBeApplied(lexer::TokenType operationType, checker::Type *const leftType, + checker::Type *const rightType, lexer::SourcePosition pos) +{ + LogTypeError({"Operator '", operationType, "' cannot be applied to types '", leftType, "' and '", rightType, "'."}, + pos); +} + +bool ETSChecker::CheckValidEqualReferenceType(checker::Type *const leftType, checker::Type *const rightType) +{ + auto isGlobalObjectType {[](checker::Type *const type) -> bool { + return type->IsETSObjectType() && type->AsETSObjectType()->IsGlobalETSObjectType(); + }}; + + // Equality expression is always allowed for Object, undefined and null + if (isGlobalObjectType(leftType) || isGlobalObjectType(rightType) || leftType->IsETSUndefinedType() || + rightType->IsETSUndefinedType() || leftType->IsETSNullType() || rightType->IsETSNullType()) { + return true; + } + + // NOTE (mxlgv): Skip for unions. Required implementation of the specification section: + // 7.25.6 Reference Equality Based on Actual Type (Union Equality Operators) + if (leftType->IsETSUnionType() || rightType->IsETSUnionType()) { + return true; + } + + // NOTE (mxlgv): Skip for generic. Required implementation of the specification section: + // 7.25.6 Reference Equality Based on Actual Type (Type Parameter Equality Operators) + if (leftType->HasTypeFlag(TypeFlag::GENERIC) || rightType->HasTypeFlag(TypeFlag::GENERIC)) { + return true; + } + + // Equality expression can only be applied to String and String, and BigInt and BigInt + if (leftType->IsETSStringType() || rightType->IsETSStringType() || leftType->IsETSBigIntType() || + rightType->IsETSBigIntType()) { + if (!Relation()->IsIdenticalTo(leftType, rightType) && !Relation()->IsIdenticalTo(rightType, leftType)) { + return false; + } + } + + return true; +} + +std::tuple ETSChecker::CheckBinaryOperatorStrictEqual(ir::Expression *left, + lexer::TokenType operationType, + lexer::SourcePosition pos, + checker::Type *leftType, checker::Type *rightType) { + RepairTypeErrorsInOperands(&leftType, &rightType); + if (leftType->IsTypeError()) { // both are errors + // We still know that operation result should be boolean, so recover. + return {GlobalETSBooleanType(), GlobalETSObjectType()}; + } + checker::Type *tsType {}; if (!IsReferenceType(leftType) || !IsReferenceType(rightType)) { - ThrowTypeError("Both operands have to be reference types", pos); + LogTypeError("Both operands have to be reference types", pos); + return {GlobalETSBooleanType(), GlobalETSObjectType()}; } Relation()->SetNode(left); + if (!CheckValidEqualReferenceType(leftType, rightType)) { + LogOperatorCannotBeApplied(operationType, leftType, rightType, pos); + return {GlobalETSBooleanType(), GlobalETSObjectType()}; + } + if (!Relation()->IsCastableTo(leftType, rightType) && !Relation()->IsCastableTo(rightType, leftType)) { - ThrowTypeError("The operands of strict equality are not compatible with each other", pos); + LogOperatorCannotBeApplied(operationType, leftType, rightType, pos); + return {GlobalETSBooleanType(), GlobalETSObjectType()}; } + tsType = GlobalETSBooleanType(); if (rightType->IsETSDynamicType() && leftType->IsETSDynamicType()) { return {tsType, GlobalBuiltinJSValueType()}; } + return {tsType, GlobalETSObjectType()}; } @@ -386,7 +496,9 @@ std::optional> ETSChecker::CheckBinaryOperatorEqualEr { if (leftType->IsETSEnumType() && rightType->IsETSEnumType()) { if (!leftType->AsETSEnumType()->IsSameEnumType(rightType->AsETSEnumType())) { - ThrowTypeError("Bad operand type, the types of the operands must be the same enum type.", pos); + // We still know that operation result should be boolean, so recover. + LogTypeError("Bad operand type, the types of the operands must be the same enum type.", pos); + return {{GlobalETSBooleanType(), leftType}}; } tsType = GlobalETSBooleanType(); @@ -395,7 +507,8 @@ std::optional> ETSChecker::CheckBinaryOperatorEqualEr if (leftType->IsETSStringEnumType() && rightType->IsETSStringEnumType()) { if (!leftType->AsETSStringEnumType()->IsSameEnumType(rightType->AsETSStringEnumType())) { - ThrowTypeError("Bad operand type, the types of the operands must be the same enum type.", pos); + LogTypeError("Bad operand type, the types of the operands must be the same enum type.", pos); + return {{GlobalETSBooleanType(), leftType}}; } tsType = GlobalETSBooleanType(); @@ -404,10 +517,18 @@ std::optional> ETSChecker::CheckBinaryOperatorEqualEr return std::nullopt; } -std::tuple ETSChecker::CheckBinaryOperatorEqual( - ir::Expression *left, ir::Expression *right, lexer::TokenType operationType, lexer::SourcePosition pos, - checker::Type *const leftType, checker::Type *const rightType, Type *unboxedL, Type *unboxedR) +std::tuple ETSChecker::CheckBinaryOperatorEqual(ir::Expression *left, ir::Expression *right, + lexer::TokenType operationType, + lexer::SourcePosition pos, checker::Type *leftType, + checker::Type *rightType, Type *unboxedL, + Type *unboxedR) { + RepairTypeErrorsInOperands(&leftType, &rightType); + RepairTypeErrorsInOperands(&unboxedL, &unboxedR); + if (leftType->IsTypeError()) { // both are errors + return {GlobalETSBooleanType(), GlobalTypeError()}; + } + checker::Type *tsType {}; auto checkError = CheckBinaryOperatorEqualError(leftType, rightType, tsType, pos); @@ -419,6 +540,12 @@ std::tuple ETSChecker::CheckBinaryOperatorEqual( } if (IsReferenceType(leftType) && IsReferenceType(rightType)) { + Relation()->SetNode(left); + if (!CheckValidEqualReferenceType(leftType, rightType)) { + LogOperatorCannotBeApplied(operationType, leftType, rightType, pos); + return {GlobalETSBooleanType(), leftType}; + } + tsType = GlobalETSBooleanType(); return {tsType, CreateETSUnionType({leftType, rightType})}; } @@ -467,17 +594,36 @@ std::tuple ETSChecker::CheckBinaryOperatorEqualDynamic(ir::Expre // have to prevent casting dyn_exp via ApplyCast without nullish flag return {GlobalETSBooleanType(), GlobalETSNullishObjectType()}; } - ThrowTypeError("Unimplemented case in dynamic type comparison.", pos); + LogTypeError("Unimplemented case in dynamic type comparison.", pos); + return {GlobalETSBooleanType(), GlobalETSNullishObjectType()}; +} + +// Satisfying the Chinese checker +static bool NonNumericTypesAreAppropriateForComparison(Type *leftType, Type *rightType) +{ + return (rightType->IsETSStringType() && leftType->IsETSStringType()) || + (((leftType->IsETSEnumType() && rightType->IsETSEnumType()) || + (leftType->IsETSStringEnumType() && rightType->IsETSStringEnumType())) && + leftType->AsEnumInterface()->IsSameEnumType(rightType->AsEnumInterface())); } -std::tuple ETSChecker::CheckBinaryOperatorLessGreater( - ir::Expression *left, ir::Expression *right, lexer::TokenType operationType, lexer::SourcePosition pos, - bool isEqualOp, checker::Type *const leftType, checker::Type *const rightType, Type *unboxedL, Type *unboxedR) +std::tuple ETSChecker::CheckBinaryOperatorLessGreater(ir::Expression *left, ir::Expression *right, + lexer::TokenType operationType, + lexer::SourcePosition pos, bool isEqualOp, + checker::Type *leftType, checker::Type *rightType, + Type *unboxedL, Type *unboxedR) { + RepairTypeErrorsInOperands(&leftType, &rightType); + RepairTypeErrorsInOperands(&unboxedL, &unboxedR); + if (leftType->IsTypeError()) { // both are errors + return {GlobalETSBooleanType(), GlobalTypeError()}; + } + if ((leftType->IsETSUnionType() || rightType->IsETSUnionType()) && operationType != lexer::TokenType::PUNCTUATOR_EQUAL && operationType != lexer::TokenType::PUNCTUATOR_NOT_EQUAL) { - ThrowTypeError("Bad operand type, unions are not allowed in binary expressions except equality.", pos); + LogTypeError("Bad operand type, unions are not allowed in binary expressions except equality.", pos); + return {GlobalETSBooleanType(), leftType}; } checker::Type *tsType {}; @@ -493,15 +639,18 @@ std::tuple ETSChecker::CheckBinaryOperatorLessGreater( if ((unboxedL != nullptr) && (unboxedR != nullptr) && (unboxedL->IsETSBooleanType() != unboxedR->IsETSBooleanType())) { - ThrowTypeError( - {"Operator '", operationType, "' cannot be applied to types '", leftType, "' and '", rightType, "'."}, pos); + LogOperatorCannotBeApplied(operationType, leftType, rightType, pos); + return {GlobalETSBooleanType(), leftType}; } if (promotedType == nullptr && !bothConst) { - if (rightType->IsETSStringType() && leftType->IsETSStringType()) { + if (NonNumericTypesAreAppropriateForComparison(leftType, rightType)) { return {GlobalETSBooleanType(), GlobalETSBooleanType()}; } - ThrowTypeError("Bad operand type, the types of the operands must be numeric or boolean type.", pos); + + LogTypeError("Bad operand type, the types of the operands must be numeric, same enumeration, or boolean type.", + pos); + return {GlobalETSBooleanType(), GlobalETSBooleanType()}; } if (bothConst) { @@ -514,17 +663,24 @@ std::tuple ETSChecker::CheckBinaryOperatorLessGreater( return {tsType, opType}; } -std::tuple ETSChecker::CheckBinaryOperatorInstanceOf(lexer::SourcePosition pos, - checker::Type *const leftType, - checker::Type *const rightType) +std::tuple ETSChecker::CheckBinaryOperatorInstanceOf(lexer::SourcePosition pos, checker::Type *leftType, + checker::Type *rightType) { + RepairTypeErrorsInOperands(&leftType, &rightType); + if (leftType->IsTypeError()) { // both are errors + return {GlobalETSBooleanType(), GlobalTypeError()}; + } + checker::Type *tsType {}; - if (!IsReferenceType(leftType) || !IsReferenceType(rightType)) { - ThrowTypeError("Bad operand type, the types of the operands must be same type.", pos); + if (!IsReferenceType(leftType) || + (!IsReferenceType(rightType) && !rightType->IsETSStringEnumType() && !rightType->IsETSEnumType())) { + LogTypeError("Bad operand type, the types of the operands must be same type.", pos); + return {GlobalETSBooleanType(), leftType}; } if (rightType->IsETSDynamicType() && !rightType->AsETSDynamicType()->HasDecl()) { - ThrowTypeError("Right-hand side of instanceof expression must represent a type.", pos); + LogTypeError("Right-hand side of instanceof expression must represent a type.", pos); + return {GlobalETSBooleanType(), leftType}; } tsType = GlobalETSBooleanType(); @@ -555,7 +711,8 @@ Type *ETSChecker::CheckBinaryOperatorNullishCoalescing(ir::Expression *left, ir: { auto *leftType = left->TsType(); if (!IsReferenceType(leftType)) { - ThrowTypeError("Left-hand side of nullish-coalescing expression must be a reference type.", pos); + LogTypeError("Left-hand side of nullish-coalescing expression must be a reference type.", pos); + return leftType; } leftType = GetNonNullishType(leftType); @@ -573,10 +730,10 @@ Type *ETSChecker::CheckBinaryOperatorNullishCoalescing(ir::Expression *left, ir: return CreateETSUnionType({leftType, rightType}); } -using CheckBinaryFunction = std::function; +using CheckBinaryFunction = + std::function; std::map &GetCheckMap() { @@ -646,7 +803,7 @@ static std::tuple CheckBinaryOperatorHelper(ETSChecker *checker, } case lexer::TokenType::PUNCTUATOR_STRICT_EQUAL: case lexer::TokenType::PUNCTUATOR_NOT_STRICT_EQUAL: { - return checker->CheckBinaryOperatorStrictEqual(left, pos, leftType, rightType); + return checker->CheckBinaryOperatorStrictEqual(left, binaryParams.operationType, pos, leftType, rightType); } case lexer::TokenType::PUNCTUATOR_EQUAL: case lexer::TokenType::PUNCTUATOR_NOT_EQUAL: { @@ -689,7 +846,9 @@ std::tuple ETSChecker::CheckBinaryOperator(ir::Expression *left, checker::Type *const leftType = left->Check(this); if (leftType == nullptr) { - ThrowTypeError("Unexpected type error in binary expression", left->Start()); + LogTypeError("Unexpected type error in binary expression", left->Start()); + auto rightType = right->Check(this); + return {rightType, rightType}; } if (operationType == lexer::TokenType::KEYW_INSTANCEOF) { @@ -704,7 +863,8 @@ std::tuple ETSChecker::CheckBinaryOperator(ir::Expression *left, } if (rightType == nullptr) { - ThrowTypeError("Unexpected type error in binary expression", pos); + LogTypeError("Unexpected type error in binary expression", pos); + return {leftType, leftType}; } const bool isLogicalExtendedOperator = (operationType == lexer::TokenType::PUNCTUATOR_LOGICAL_AND) || diff --git a/ets2panda/checker/ets/assignAnalyzer.cpp b/ets2panda/checker/ets/assignAnalyzer.cpp index 334bc7f86cc4a9881cb06646218df25ffa2e9498..70ae6482c83c7c49b9ae450f21b573c37afbffc4 100644 --- a/ets2panda/checker/ets/assignAnalyzer.cpp +++ b/ets2panda/checker/ets/assignAnalyzer.cpp @@ -1005,9 +1005,9 @@ void AssignAnalyzer::AnalyzeCond(const ir::AstNode *node) ASSERT(node->IsExpression()); const ir::Expression *expr = node->AsExpression(); - if (expr->TsType() != nullptr && expr->TsType()->IsETSBooleanType() && - expr->TsType()->HasTypeFlag(TypeFlag::CONSTANT)) { - const ETSBooleanType *condType = expr->TsType()->AsETSBooleanType(); + if (auto etype = expr->TsTypeOrError(); + etype != nullptr && etype->IsETSBooleanType() && etype->HasTypeFlag(TypeFlag::CONSTANT)) { + const ETSBooleanType *condType = etype->AsETSBooleanType(); if (inits_.IsReset()) { Merge(); } diff --git a/ets2panda/checker/ets/dynamic.cpp b/ets2panda/checker/ets/dynamic.cpp index bac901823677304edf6a992ac53aa0f4a6ae892e..b17a6e5aaa01e2640abdf07a2f8298969bc223df 100644 --- a/ets2panda/checker/ets/dynamic.cpp +++ b/ets2panda/checker/ets/dynamic.cpp @@ -225,8 +225,7 @@ template Signature *ETSChecker::ResolveDynamicCallExpression( template Signature *ETSChecker::ResolveDynamicCallExpression( ir::Expression *callee, const ArenaVector &arguments, Language lang, bool isConstruct); -template -std::pair ETSChecker::CreateScriptFunction( +std::pair ETSChecker::CreateStaticScriptFunction( ClassInitializerBuilder const &builder) { ArenaVector statements(Allocator()->Adapter()); @@ -235,69 +234,87 @@ std::pair ETSChecker::CreateScriptFuncti ir::ScriptFunction *func; ir::Identifier *id; - if constexpr (IS_STATIC) { - builder(&statements, nullptr); - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto *body = AllocNode(Allocator(), std::move(statements)); - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - id = AllocNode(compiler::Signatures::CCTOR, Allocator()); - auto signature = ir::FunctionSignature(nullptr, std::move(params), nullptr); - // clang-format off - func = AllocNode( - Allocator(), ir::ScriptFunction::ScriptFunctionData { - body, - std::move(signature), - ir::ScriptFunctionFlags::STATIC_BLOCK | ir::ScriptFunctionFlags::EXPRESSION, - ir::ModifierFlags::STATIC, - }); - // clang-format on - } else { - builder(&statements, ¶ms); - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto *body = AllocNode(Allocator(), std::move(statements)); - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - id = AllocNode(compiler::Signatures::CTOR, Allocator()); - auto funcSignature = ir::FunctionSignature(nullptr, std::move(params), nullptr); - func = AllocNode( - Allocator(), ir::ScriptFunction::ScriptFunctionData {body, std::move(funcSignature), - ir::ScriptFunctionFlags::CONSTRUCTOR | - ir::ScriptFunctionFlags::EXPRESSION, - ir::ModifierFlags::PUBLIC}); - } + builder(&statements, nullptr); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + auto *body = AllocNode(Allocator(), std::move(statements)); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + id = AllocNode(compiler::Signatures::CCTOR, Allocator()); + auto signature = ir::FunctionSignature(nullptr, std::move(params), nullptr); + // clang-format off + func = AllocNode( + Allocator(), ir::ScriptFunction::ScriptFunctionData { + body, + std::move(signature), + ir::ScriptFunctionFlags::STATIC_BLOCK | ir::ScriptFunctionFlags::EXPRESSION, + ir::ModifierFlags::STATIC, + }); + // clang-format on + func->SetIdent(id); + return std::make_pair(func, id); +} + +std::pair ETSChecker::CreateScriptFunction( + ClassInitializerBuilder const &builder) +{ + ArenaVector statements(Allocator()->Adapter()); + ArenaVector params(Allocator()->Adapter()); + + ir::ScriptFunction *func; + ir::Identifier *id; + + builder(&statements, ¶ms); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + auto *body = AllocNode(Allocator(), std::move(statements)); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + id = AllocNode(compiler::Signatures::CTOR, Allocator()); + auto funcSignature = ir::FunctionSignature(nullptr, std::move(params), nullptr); + func = AllocNode(Allocator(), + ir::ScriptFunction::ScriptFunctionData { + body, std::move(funcSignature), + ir::ScriptFunctionFlags::CONSTRUCTOR | ir::ScriptFunctionFlags::EXPRESSION, + ir::ModifierFlags::PUBLIC}); func->SetIdent(id); return std::make_pair(func, id); } -template -std::conditional_t ETSChecker::CreateClassInitializer( - const ClassInitializerBuilder &builder, [[maybe_unused]] ETSObjectType *type) +ir::ClassStaticBlock *ETSChecker::CreateClassStaticInitializer(const ClassInitializerBuilder &builder, + [[maybe_unused]] ETSObjectType *type) +{ + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + auto [func, id] = CreateStaticScriptFunction(builder); + + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + auto *funcExpr = AllocNode(func); + + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + auto *staticBlock = AllocNode(funcExpr, Allocator()); + staticBlock->AddModifier(ir::ModifierFlags::STATIC); + + return staticBlock; +} + +ir::MethodDefinition *ETSChecker::CreateClassInstanceInitializer(const ClassInitializerBuilder &builder, + [[maybe_unused]] ETSObjectType *type) { // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto [func, id] = CreateScriptFunction(builder); + auto [func, id] = CreateScriptFunction(builder); // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *funcExpr = AllocNode(func); - if constexpr (IS_STATIC) { + auto *ctor = // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto *staticBlock = AllocNode(funcExpr, Allocator()); - staticBlock->AddModifier(ir::ModifierFlags::STATIC); - return staticBlock; - } else { - auto *ctor = - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - AllocNode(ir::MethodDefinitionKind::CONSTRUCTOR, id->Clone(Allocator(), nullptr), - funcExpr, ir::ModifierFlags::NONE, Allocator(), false); - return ctor; - } + AllocNode(ir::MethodDefinitionKind::CONSTRUCTOR, id->Clone(Allocator(), nullptr), + funcExpr, ir::ModifierFlags::NONE, Allocator(), false); + return ctor; } ir::ClassStaticBlock *ETSChecker::CreateDynamicCallClassInitializer(Language lang, bool isConstruct) { // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - return CreateClassInitializer([this, lang, + return CreateClassStaticInitializer([this, lang, isConstruct](ArenaVector *statements, [[maybe_unused]] ArenaVector *params) { auto [builtin_class_name, builtin_method_name] = @@ -438,7 +455,7 @@ ir::ClassStaticBlock *ETSChecker::CreateDynamicModuleClassInitializer( const std::vector &imports) { // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - return CreateClassInitializer([this, imports](ArenaVector *statements, + return CreateClassStaticInitializer([this, imports](ArenaVector *statements, [[maybe_unused]] ArenaVector *params) { for (auto *import : imports) { ClassInitializerFromImport(import, statements); @@ -446,9 +463,8 @@ ir::ClassStaticBlock *ETSChecker::CreateDynamicModuleClassInitializer( }); } -template -ir::MethodDefinition *ETSChecker::CreateClassMethod(const std::string_view name, ir::ModifierFlags modifierFlags, - const MethodBuilder &builder) +ir::MethodDefinition *ETSChecker::CreateClassMethod(const std::string_view name, ir::ScriptFunctionFlags funcFlags, + ir::ModifierFlags modifierFlags, const MethodBuilder &builder) { ArenaVector params(Allocator()->Adapter()); auto *id = AllocNode(name, Allocator()); @@ -460,10 +476,10 @@ ir::MethodDefinition *ETSChecker::CreateClassMethod(const std::string_view name, // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *body = AllocNode(Allocator(), std::move(statements)); - auto funcSignature = ir::FunctionSignature(nullptr, std::move(params), nullptr); + auto funcSignature = ir::FunctionSignature( + nullptr, std::move(params), returnType == nullptr ? nullptr : AllocNode(returnType)); auto *func = AllocNode( - Allocator(), ir::ScriptFunction::ScriptFunctionData {body, std::move(funcSignature), - ir::ScriptFunctionFlags::METHOD, modifierFlags}); + Allocator(), ir::ScriptFunction::ScriptFunctionData {body, std::move(funcSignature), funcFlags, modifierFlags}); func->SetIdent(id); @@ -480,19 +496,19 @@ ir::MethodDefinition *ETSChecker::CreateClassMethod(const std::string_view name, ir::MethodDefinition *ETSChecker::CreateDynamicModuleClassInitMethod() { // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - return CreateClassMethod(compiler::Signatures::DYNAMIC_MODULE_CLASS_INIT, - ir::ModifierFlags::PUBLIC | ir::ModifierFlags::STATIC, - [this]([[maybe_unused]] ArenaVector *statements, - [[maybe_unused]] ArenaVector *params, - Type **returnType) { *returnType = GlobalVoidType(); }); + return CreateClassMethod(compiler::Signatures::DYNAMIC_MODULE_CLASS_INIT, ir::ScriptFunctionFlags::METHOD, + ir::ModifierFlags::PUBLIC | ir::ModifierFlags::STATIC, + [this]([[maybe_unused]] ArenaVector *statements, + [[maybe_unused]] ArenaVector *params, + Type **returnType) { *returnType = GlobalVoidType(); }); } ir::MethodDefinition *ETSChecker::CreateLambdaObjectClassInvokeMethod(Signature *invokeSignature, ir::TypeNode *retTypeAnnotation) { // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - return CreateClassMethod( - compiler::Signatures::LAMBDA_OBJECT_INVOKE, ir::ModifierFlags::PUBLIC, + return CreateClassMethod( + compiler::Signatures::LAMBDA_OBJECT_INVOKE, ir::ScriptFunctionFlags::METHOD, ir::ModifierFlags::PUBLIC, [this, invokeSignature, retTypeAnnotation](ArenaVector *statements, ArenaVector *params, Type **returnType) { util::UString thisParamName(std::string("this"), Allocator()); @@ -611,7 +627,7 @@ void ETSChecker::BuildDynamicImportClass() ir::MethodDefinition *ETSChecker::CreateLambdaObjectClassInitializer(ETSObjectType *functionalInterface) { // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - return CreateClassInitializer( + return CreateClassInstanceInitializer( [this](ArenaVector *statements, ArenaVector *params) { ir::ETSParameterExpression *thisParam = AddParam(varbinder::VarBinder::MANDATORY_PARAM_THIS, nullptr); params->push_back(thisParam); diff --git a/ets2panda/checker/ets/function.cpp b/ets2panda/checker/ets/function.cpp index c1bc7afee540830ac9c6951a65b3aae3526b4e29..f630b048cc020d45067788a10c6bbf4c2ccbbbb9 100644 --- a/ets2panda/checker/ets/function.cpp +++ b/ets2panda/checker/ets/function.cpp @@ -160,16 +160,8 @@ bool ETSChecker::EnhanceSubstitutionForType(const ArenaVector &typeParam ThrowTypeError({argumentType, " is not compatible with type ", tparam}, tparam->GetDeclNode()->Start()); } - if (!IsCompatibleTypeArgument(tparam, argumentType, substitution)) { - return false; - } - if (substitution->find(originalTparam) != substitution->end() && - substitution->at(originalTparam) != argumentType) { - ThrowTypeError({"Type parameter already instantiated with another type "}, - tparam->GetDeclNode()->Start()); - } ETSChecker::EmplaceSubstituted(substitution, originalTparam, argumentType); - return true; + return IsCompatibleTypeArgument(tparam, argumentType, substitution); } } @@ -1079,6 +1071,11 @@ SignatureInfo *ETSChecker::ComposeSignatureInfo(ir::ScriptFunction *func) ASSERT(paramVar); auto *const paramTypeAnnotation = param->TypeAnnotation(); + if (paramIdent->TsType() == nullptr && paramTypeAnnotation == nullptr) { + ThrowTypeError({"The type of parameter '", paramIdent->Name(), "' cannot be determined"}, + param->Start()); + } + if (paramIdent->TsType() == nullptr) { ASSERT(paramTypeAnnotation); diff --git a/ets2panda/checker/ets/function_helpers.h b/ets2panda/checker/ets/function_helpers.h index 69163d30474578bcd74e06924485bd05e6364520..a3b0c08ab777a3e2c34ff3662078c630b489cba7 100644 --- a/ets2panda/checker/ets/function_helpers.h +++ b/ets2panda/checker/ets/function_helpers.h @@ -87,6 +87,7 @@ static const Substitution *BuildImplicitSubstitutionForArguments(ETSChecker *che { Substitution *substitution = checker->NewSubstitution(); auto *sigInfo = signature->GetSignatureInfo(); + auto &sigParams = signature->GetSignatureInfo()->typeParams; for (size_t ix = 0; ix < arguments.size(); ix++) { auto *arg = arguments[ix]; @@ -111,16 +112,22 @@ static const Substitution *BuildImplicitSubstitutionForArguments(ETSChecker *che } } - if (substitution->size() != sigInfo->typeParams.size()) { - for (const auto it : sigInfo->typeParams) { - if (substitution->find(it->AsETSTypeParameter()) == substitution->end() && - it->AsETSTypeParameter()->GetDefaultType() != nullptr) { - ETSChecker::EmplaceSubstituted(substitution, it->AsETSTypeParameter(), - it->AsETSTypeParameter()->GetDefaultType()); + if (substitution->size() != sigParams.size()) { + for (const auto typeParam : sigParams) { + auto newTypeParam = typeParam->AsETSTypeParameter(); + if (auto it = substitution->find(newTypeParam); it != substitution->cend()) { + continue; + } + if (newTypeParam->GetDefaultType() == nullptr) { + return nullptr; + } + auto dflt = newTypeParam->GetDefaultType()->Substitute(checker->Relation(), substitution); + if (!checker->EnhanceSubstitutionForType(sigInfo->typeParams, newTypeParam, dflt, substitution)) { + return nullptr; } } - if (substitution->size() != sigInfo->typeParams.size() && + if (substitution->size() != sigParams.size() && (signature->Function()->ReturnTypeAnnotation() == nullptr || !checker->EnhanceSubstitutionForType(sigInfo->typeParams, signature->Function()->ReturnTypeAnnotation()->TsType(), @@ -139,10 +146,14 @@ static const Substitution *BuildExplicitSubstitutionForArguments(ETSChecker *che { auto &sigParams = signature->GetSignatureInfo()->typeParams; auto *substitution = checker->NewSubstitution(); + auto *constraintsSubstitution = checker->NewSubstitution(); ArenaVector instArgs {checker->Allocator()->Adapter()}; - for (auto *taExpr : params) { - instArgs.push_back(MaybeBoxedType(checker, taExpr->GetType(checker), taExpr)); + for (size_t ix = 0; ix < params.size(); ++ix) { + instArgs.push_back(MaybeBoxedType(checker, params[ix]->GetType(checker), params[ix])); + if (ix < sigParams.size()) { + ETSChecker::EmplaceSubstituted(constraintsSubstitution, sigParams[ix]->AsETSTypeParameter(), instArgs[ix]); + } } for (size_t ix = instArgs.size(); ix < sigParams.size(); ++ix) { auto *dflt = sigParams[ix]->AsETSTypeParameter()->GetDefaultType(); @@ -150,7 +161,9 @@ static const Substitution *BuildExplicitSubstitutionForArguments(ETSChecker *che break; } + dflt = dflt->Substitute(checker->Relation(), constraintsSubstitution); instArgs.push_back(dflt); + ETSChecker::EmplaceSubstituted(constraintsSubstitution, sigParams[ix]->AsETSTypeParameter(), instArgs[ix]); } if (sigParams.size() != instArgs.size()) { if ((flags & TypeRelationFlag::NO_THROW) != 0) { @@ -159,11 +172,6 @@ static const Substitution *BuildExplicitSubstitutionForArguments(ETSChecker *che checker->ThrowTypeError({"Expected ", sigParams.size(), " type arguments, got ", instArgs.size(), " ."}, pos); } - auto *constraintsSubstitution = checker->NewSubstitution(); - - for (size_t ix = 0; ix < sigParams.size(); ix++) { - ETSChecker::EmplaceSubstituted(constraintsSubstitution, sigParams[ix]->AsETSTypeParameter(), instArgs[ix]); - } for (size_t ix = 0; ix < sigParams.size(); ix++) { if (!checker->IsCompatibleTypeArgument(sigParams[ix]->AsETSTypeParameter(), instArgs[ix], constraintsSubstitution)) { @@ -186,9 +194,7 @@ static Signature *MaybeSubstituteTypeParameters(ETSChecker *checker, Signature * const Substitution *substitution = (typeArguments != nullptr) ? BuildExplicitSubstitutionForArguments(checker, signature, typeArguments->Params(), pos, flags) - : (signature->GetSignatureInfo()->params.empty() && signature->GetSignatureInfo()->restVar == nullptr - ? nullptr - : BuildImplicitSubstitutionForArguments(checker, signature, arguments)); + : BuildImplicitSubstitutionForArguments(checker, signature, arguments); return (substitution == nullptr) ? nullptr : signature->Substitute(checker->Relation(), substitution); } diff --git a/ets2panda/checker/ets/helpers.cpp b/ets2panda/checker/ets/helpers.cpp index 6fde4aa6325eb30bcec4ff31014a876e46ee6215..4a08f2567521f146b8ffb76a30da264b38641b29 100644 --- a/ets2panda/checker/ets/helpers.cpp +++ b/ets2panda/checker/ets/helpers.cpp @@ -63,7 +63,7 @@ bool ETSChecker::IsVariableStatic(const varbinder::Variable *var) bool ETSChecker::IsVariableGetterSetter(const varbinder::Variable *var) { - return var->TsType() != nullptr && var->TsType()->HasTypeFlag(TypeFlag::GETTER_SETTER); + return var->TsTypeOrError() != nullptr && var->TsTypeOrError()->HasTypeFlag(TypeFlag::GETTER_SETTER); } void ETSChecker::ThrowError(ir::Identifier *const ident) @@ -537,37 +537,24 @@ void ETSChecker::ResolveReturnStatement(checker::Type *funcReturnType, checker:: } } -checker::Type *ETSChecker::CheckArrayElements(ir::Identifier *ident, ir::ArrayExpression *init) +checker::Type *ETSChecker::CheckArrayElements(ir::ArrayExpression *init) { - ArenaVector elements = init->AsArrayExpression()->Elements(); - checker::Type *annotationType = nullptr; - if (elements.empty()) { - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - annotationType = Allocator()->New(GlobalETSObjectType()); - } else { - auto type = elements[0]->Check(this); - auto const primType = ETSBuiltinTypeAsPrimitiveType(type); - for (auto element : elements) { - auto const eType = element->Check(this); - auto const primEType = ETSBuiltinTypeAsPrimitiveType(eType); - if (primEType != nullptr && primType != nullptr && - primEType->HasTypeFlag(TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC) && - primType->HasTypeFlag(TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC)) { - type = GlobalDoubleType(); - } else if (IsTypeIdenticalTo(type, eType)) { - continue; - } else if (type->IsETSEnumType() && eType->IsETSEnumType() && - type->AsETSEnumType()->IsSameEnumType(eType->AsETSEnumType())) { - continue; - } else { - // NOTE: Create union type when implemented here - ThrowTypeError({"Union type is not implemented yet!"}, ident->Start()); - } - } + ArenaVector elementTypes(Allocator()->Adapter()); + for (auto e : init->AsArrayExpression()->Elements()) { + elementTypes.push_back(e->Check(this)); + } + + if (elementTypes.empty()) { // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - annotationType = Allocator()->New(type); + return Allocator()->New(GlobalETSObjectType()); } - return annotationType; + auto const isNumeric = [](checker::Type *ct) { return ct->HasTypeFlag(TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC); }; + auto const elementType = std::all_of(elementTypes.begin(), elementTypes.end(), isNumeric) + ? GlobalDoubleType() + : CreateETSUnionType(std::move(elementTypes)); + + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + return Allocator()->New(elementType); } void ETSChecker::InferAliasLambdaType(ir::TypeNode *localTypeAnnotation, ir::ArrowFunctionExpression *init) @@ -604,7 +591,7 @@ void ETSChecker::InferAliasLambdaType(ir::TypeNode *localTypeAnnotation, ir::Arr checker::Type *ETSChecker::FixOptionalVariableType(varbinder::Variable *const bindingVar, ir::ModifierFlags flags) { if ((flags & ir::ModifierFlags::OPTIONAL) != 0) { - auto type = bindingVar->TsType(); + auto type = bindingVar->TsTypeOrError(); if (type->IsETSUnionType()) { auto constituentTypes = type->AsETSUnionType()->ConstituentTypes(); constituentTypes.push_back(GlobalETSUndefinedType()); @@ -614,7 +601,7 @@ checker::Type *ETSChecker::FixOptionalVariableType(varbinder::Variable *const bi } bindingVar->SetTsType(type); } - return bindingVar->TsType(); + return bindingVar->TsTypeOrError(); } checker::Type *PreferredObjectTypeFromAnnotation(checker::Type *annotationType) @@ -641,7 +628,7 @@ void ETSChecker::CheckInit(ir::Identifier *ident, ir::TypeNode *typeAnnotation, { if (typeAnnotation == nullptr) { if (init->IsArrayExpression()) { - annotationType = CheckArrayElements(ident, init->AsArrayExpression()); + annotationType = CheckArrayElements(init->AsArrayExpression()); bindingVar->SetTsType(annotationType); } @@ -1243,9 +1230,25 @@ void ETSChecker::BindingsModuleObjectAddProperty(checker::ETSObjectType *moduleO if (!aliasedName.Empty()) { moduleObjType->AddReExportAlias(var->Declaration()->Name(), aliasedName); } - moduleObjType->AddProperty(var->AsLocalVariable()); + moduleObjType->AddProperty(var->AsLocalVariable(), + FindPropNameForNamespaceImport(var->AsLocalVariable()->Name())); + } + } +} + +util::StringView ETSChecker::FindPropNameForNamespaceImport(const util::StringView &originalName) +{ + if (auto relatedMapItem = + VarBinder()->AsETSBinder()->GetSelectiveExportAliasMultimap().find(Program()->SourceFilePath()); + relatedMapItem != VarBinder()->AsETSBinder()->GetSelectiveExportAliasMultimap().end()) { + if (auto result = std::find_if(relatedMapItem->second.begin(), relatedMapItem->second.end(), + [originalName](const auto &item) { return item.second == originalName; }); + result != relatedMapItem->second.end()) { + return result->first; } } + + return originalName; } void ETSChecker::SetPropertiesForModuleObject(checker::ETSObjectType *moduleObjType, const util::StringView &importPath, @@ -1265,6 +1268,9 @@ void ETSChecker::SetPropertiesForModuleObject(checker::ETSObjectType *moduleObjT BindingsModuleObjectAddProperty( moduleObjType, importDecl, programList.front()->GlobalClassScope()->StaticMethodScope()->Bindings()); + BindingsModuleObjectAddProperty( + moduleObjType, importDecl, programList.front()->GlobalClassScope()->StaticDeclScope()->Bindings()); + BindingsModuleObjectAddProperty( moduleObjType, importDecl, programList.front()->GlobalClassScope()->InstanceDeclScope()->Bindings()); @@ -2109,7 +2115,7 @@ void ETSChecker::InferTypesForLambda(ir::ScriptFunction *lambda, ir::ETSFunction } } if (lambda->ReturnTypeAnnotation() == nullptr) { - lambda->SetReturnTypeAnnotation(calleeType->ReturnType()); + lambda->SetReturnTypeAnnotation(calleeType->ReturnType()->Clone(Allocator(), lambda)); } } @@ -2247,8 +2253,6 @@ ir::MethodDefinition *ETSChecker::GenerateDefaultGetterSetter(ir::ClassProperty functionScope->BindParamScope(paramScope); paramScope->BindFunctionScope(functionScope); - auto flags = ir::ModifierFlags::PUBLIC; - ArenaVector params(checker->Allocator()->Adapter()); ArenaVector stmts(checker->Allocator()->Adapter()); checker->GenerateGetterSetterBody(stmts, params, field, paramScope, isSetter); @@ -2262,7 +2266,7 @@ ir::MethodDefinition *ETSChecker::GenerateDefaultGetterSetter(ir::ClassProperty auto *func = checker->AllocNode( checker->Allocator(), ir::ScriptFunction::ScriptFunctionData {body, ir::FunctionSignature(nullptr, std::move(params), returnTypeAnn), - funcFlags, flags, true}); + funcFlags, ir::ModifierFlags::PUBLIC, true}); if (!isSetter) { func->AddFlag(ir::ScriptFunctionFlags::HAS_RETURN); @@ -2272,20 +2276,20 @@ ir::MethodDefinition *ETSChecker::GenerateDefaultGetterSetter(ir::ClassProperty body->SetScope(functionScope); // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *methodIdent = property->Key()->AsIdentifier()->Clone(checker->Allocator(), nullptr); - auto *decl = checker->Allocator()->New( - checker->Allocator(), property->Key()->AsIdentifier()->Name(), - property->Key()->AsIdentifier()->Variable()->Declaration()->Node()); - auto *var = checker->Allocator()->New(decl, varbinder::VariableFlags::VAR); - var->AddFlag(varbinder::VariableFlags::METHOD); - - methodIdent->SetVariable(var); // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *funcExpr = checker->AllocNode(func); funcExpr->SetRange(func->Range()); func->AddFlag(ir::ScriptFunctionFlags::METHOD); // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *method = checker->AllocNode(ir::MethodDefinitionKind::METHOD, methodIdent, funcExpr, - flags, checker->Allocator(), false); + ir::ModifierFlags::PUBLIC, checker->Allocator(), false); + + auto *decl = checker->Allocator()->New(checker->Allocator(), + property->Key()->AsIdentifier()->Name(), method); + auto *var = checker->Allocator()->New(decl, varbinder::VariableFlags::VAR); + var->AddFlag(varbinder::VariableFlags::METHOD); + + methodIdent->SetVariable(var); method->Id()->SetMutator(); method->SetRange(field->Range()); @@ -2330,13 +2334,38 @@ ir::ClassProperty *GetImplementationClassProp(ETSChecker *checker, ir::ClassProp return classProp; } +static void SetupGetterSetterFlags(ir::ClassProperty *originalProp, ETSObjectType *classType, + ir::ClassDefinition *classDef, ir::MethodDefinition *getter, + ir::MethodDefinition *setter, const bool inExternal) +{ + for (auto &method : {getter, setter}) { + if (method == nullptr) { + continue; + } + + const auto mflag = method == getter ? ir::ModifierFlags::GETTER : ir::ModifierFlags::SETTER; + const auto tflag = method == getter ? TypeFlag::GETTER : TypeFlag::SETTER; + + method->TsType()->AddTypeFlag(tflag); + method->Variable()->SetTsType(method->TsType()); + if (((originalProp->Modifiers() & mflag) != 0U)) { + method->Function()->AddModifier(ir::ModifierFlags::OVERRIDE); + } + + if (inExternal) { + method->Function()->AddFlag(ir::ScriptFunctionFlags::EXTERNAL); + } + method->SetParent(classDef); + classType->AddProperty(method->Variable()->AsLocalVariable()); + } +} + void ETSChecker::GenerateGetterSetterPropertyAndMethod(ir::ClassProperty *originalProp, ETSObjectType *classType) { auto *const classDef = classType->GetDeclNode()->AsClassDefinition(); auto *interfaceProp = originalProp->Clone(Allocator(), originalProp->Parent()); - interfaceProp->ClearModifier(ir::ModifierFlags::GETTER_SETTER | ir::ModifierFlags::EXTERNAL); + interfaceProp->ClearModifier(ir::ModifierFlags::GETTER_SETTER); - ASSERT(Scope()->IsClassScope()); auto *const scope = Scope()->AsClassScope(); scope->InstanceFieldScope()->EraseBinding(interfaceProp->Key()->AsIdentifier()->Name()); interfaceProp->SetRange(originalProp->Range()); @@ -2345,60 +2374,41 @@ void ETSChecker::GenerateGetterSetterPropertyAndMethod(ir::ClassProperty *origin // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) ir::MethodDefinition *getter = GenerateDefaultGetterSetter(interfaceProp, classProp, scope, false, this); - if (((originalProp->Modifiers() & ir::ModifierFlags::GETTER) != 0U)) { - getter->Function()->AddModifier(ir::ModifierFlags::OVERRIDE); - } classDef->Body().push_back(getter); - getter->SetParent(classDef); - getter->TsType()->AddTypeFlag(TypeFlag::GETTER); - getter->Variable()->SetTsType(getter->TsType()); - classType->AddProperty(getter->Variable()->AsLocalVariable()); - auto *const methodScope = scope->InstanceMethodScope(); - auto name = getter->Key()->AsIdentifier()->Name(); + const auto &name = getter->Key()->AsIdentifier()->Name(); + + ir::MethodDefinition *setter = + !classProp->IsConst() + ? GenerateDefaultGetterSetter(interfaceProp, classProp, Scope()->AsClassScope(), true, this) + : nullptr; + auto *const methodScope = scope->InstanceMethodScope(); auto *const decl = Allocator()->New(Allocator(), name, getter); auto *var = methodScope->AddDecl(Allocator(), decl, ScriptExtension::ETS); - ir::MethodDefinition *setter = GenerateSetterForProperty(originalProp, interfaceProp, classProp, classType, getter); - if (var == nullptr) { auto *const prevDecl = methodScope->FindDecl(name); - prevDecl->Node()->AsMethodDefinition()->AddOverload(getter); - prevDecl->Node()->AsMethodDefinition()->AddOverload(setter); + for (const auto &method : {getter, setter}) { + if (method != nullptr) { + prevDecl->Node()->AsMethodDefinition()->AddOverload(method); + } + } var = methodScope->FindLocal(name, varbinder::ResolveBindingOptions::BINDINGS); } - - if ((originalProp->Modifiers() & ir::ModifierFlags::EXTERNAL) != 0U) { - getter->Function()->AddFlag(ir::ScriptFunctionFlags::EXTERNAL); - } - var->AddFlag(varbinder::VariableFlags::METHOD); - getter->Function()->Id()->SetVariable(var); -} -ir::MethodDefinition *ETSChecker::GenerateSetterForProperty(ir::ClassProperty *originalProp, - ir::ClassProperty *interfaceProp, - ir::ClassProperty *classProp, ETSObjectType *classType, - ir::MethodDefinition *getter) -{ - ir::MethodDefinition *setter = - GenerateDefaultGetterSetter(interfaceProp, classProp, Scope()->AsClassScope(), true, this); - if (((originalProp->Modifiers() & ir::ModifierFlags::SETTER) != 0U)) { - setter->Function()->AddModifier(ir::ModifierFlags::OVERRIDE); - } + SetupGetterSetterFlags(originalProp, classType, classDef, getter, setter, HasStatus(CheckerStatus::IN_EXTERNAL)); - if ((originalProp->Modifiers() & ir::ModifierFlags::EXTERNAL) != 0U) { - setter->Function()->AddFlag(ir::ScriptFunctionFlags::EXTERNAL); + if (setter != nullptr) { + getter->Variable()->TsType()->AsETSFunctionType()->AddCallSignature( + setter->TsType()->AsETSFunctionType()->CallSignatures()[0]); } - setter->SetParent(classType->GetDeclNode()->AsClassDefinition()); - setter->TsType()->AddTypeFlag(TypeFlag::SETTER); - getter->Variable()->TsType()->AsETSFunctionType()->AddCallSignature( - setter->TsType()->AsETSFunctionType()->CallSignatures()[0]); - classType->AddProperty(setter->Variable()->AsLocalVariable()); - getter->AddOverload(setter); - return setter; + getter->Function()->Id()->SetVariable(var); + if (setter != nullptr) { + getter->AddOverload(setter); + } } const Type *ETSChecker::TryGettingFunctionTypeFromInvokeFunction(const Type *type) const diff --git a/ets2panda/checker/ets/narrowingConverter.h b/ets2panda/checker/ets/narrowingConverter.h index 111d84dcd600dba0f805c1111d875d34d3fa8d36..690e756fa920cc7d2dd02cde4d3c088a4fbb4fb3 100644 --- a/ets2panda/checker/ets/narrowingConverter.h +++ b/ets2panda/checker/ets/narrowingConverter.h @@ -103,21 +103,6 @@ private: } } - template - int CalculateIntValue(SType value) - { - if (std::isinf(value)) { - if (std::signbit(value)) { - return std::numeric_limits::min(); - } - return std::numeric_limits::max(); - } - if (std::isnan(value)) { - return 0; - } - return static_cast(value); - } - template To CastFloatingPointToIntOrLong(From value) { @@ -153,7 +138,10 @@ private: case TypeFlag::BYTE: case TypeFlag::CHAR: case TypeFlag::SHORT: { - return CalculateIntValue(value); + if (source->HasTypeFlag(checker::TypeFlag::DOUBLE) || source->HasTypeFlag(checker::TypeFlag::FLOAT)) { + return static_cast(CastFloatingPointToIntOrLong(value)); + } + return static_cast(value); } case TypeFlag::INT: case TypeFlag::LONG: { diff --git a/ets2panda/checker/ets/object.cpp b/ets2panda/checker/ets/object.cpp index a9b6d01793ff5aea9ead183f69c689507fe1d1f5..4f6dbe929819c5a3fba3692cc7d0437887afd296 100644 --- a/ets2panda/checker/ets/object.cpp +++ b/ets2panda/checker/ets/object.cpp @@ -306,8 +306,7 @@ ETSObjectType *ETSChecker::BuildBasicInterfaceProperties(ir::TSInterfaceDeclarat checker::ETSObjectType *interfaceType {}; if (var->TsType() == nullptr) { - interfaceType = CreateETSObjectType(var->Name(), interfaceDecl, - checker::ETSObjectFlags::INTERFACE | checker::ETSObjectFlags::ABSTRACT); + interfaceType = CreateETSObjectType(var->Name(), interfaceDecl, checker::ETSObjectFlags::INTERFACE); interfaceType->SetVariable(var); var->SetTsType(interfaceType); } else { @@ -584,7 +583,6 @@ void ETSChecker::CreateFunctionTypesFromAbstracts(const std::vector } auto *created = CreateETSFunctionType(it); - created->AddTypeFlag(TypeFlag::SYNTHETIC); target->push_back(created); } } @@ -850,10 +848,6 @@ void ETSChecker::ApplyModifiersAndRemoveImplementedAbstracts(ArenaVectorFields()) { if (field->Name() == (*it)->Name()) { - if (isGetSetExternal.isExternal) { - field->Declaration()->Node()->AddModifier(ir::ModifierFlags::EXTERNAL); - } - field->Declaration()->Node()->AddModifier(isGetSetExternal.isGetter && isGetSetExternal.isSetter ? ir::ModifierFlags::GETTER_SETTER : isGetSetExternal.isGetter ? ir::ModifierFlags::GETTER @@ -999,7 +993,9 @@ void ETSChecker::CheckClassDefinition(ir::ClassDefinition *classDef) } auto newStatus = checker::CheckerStatus::IN_CLASS; - classType->SetEnclosingType(Context().ContainingClass()); + if (Context().ContainingClass() != classType) { + classType->SetEnclosingType(Context().ContainingClass()); + } if (classDef->IsInner()) { newStatus |= CheckerStatus::INNER_CLASS; diff --git a/ets2panda/checker/ets/typeCheckingHelpers.cpp b/ets2panda/checker/ets/typeCheckingHelpers.cpp index 156f758237e8ddb3da540272df282b4c361382d9..c89fd1832ed207b9d2cc559efc7d7fe72dbd5b70 100644 --- a/ets2panda/checker/ets/typeCheckingHelpers.cpp +++ b/ets2panda/checker/ets/typeCheckingHelpers.cpp @@ -57,19 +57,21 @@ void ETSChecker::CheckTruthinessOfType(ir::Expression *expr) auto *const testType = expr->Check(this); auto *const conditionType = ETSBuiltinTypeAsConditionalType(testType); - if (conditionType == nullptr || !conditionType->IsConditionalExprType()) { - ThrowTypeError("Condition must be of possible condition type", expr->Start()); + expr->SetTsType(conditionType); + + if (conditionType == nullptr || (!conditionType->IsTypeError() && !conditionType->IsConditionalExprType())) { + LogTypeError("Condition must be of possible condition type", expr->Start()); + return; } if (conditionType->IsETSVoidType()) { - ThrowTypeError("An expression of type 'void' cannot be tested for truthiness", expr->Start()); + LogTypeError("An expression of type 'void' cannot be tested for truthiness", expr->Start()); + return; } if (conditionType->HasTypeFlag(TypeFlag::ETS_PRIMITIVE)) { FlagExpressionWithUnboxing(testType, conditionType, expr); } - - expr->SetTsType(conditionType); } void ETSChecker::CheckNonNullish(ir::Expression const *expr) @@ -399,8 +401,8 @@ Type *ETSChecker::GetTypeOfVariable(varbinder::Variable *const var) return GetTypeOfSetterGetter(var); } - if (var->TsType() != nullptr) { - return var->TsType(); + if (var->TsTypeOrError() != nullptr) { + return var->TsTypeOrError(); } // NOTE: kbaladurin. forbid usage of imported entities as types without declarations @@ -578,11 +580,9 @@ Type *ETSChecker::GetTypeFromEnumReference([[maybe_unused]] varbinder::Variable auto *const enumDecl = var->Declaration()->Node()->AsTSEnumDeclaration(); if (auto *const itemInit = enumDecl->Members().front()->AsTSEnumMember()->Init(); itemInit->IsNumberLiteral()) { - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - return CreateEnumIntClassFromEnumDeclaration(enumDecl); + return CreateEnumIntTypeFromEnumDeclaration(enumDecl); } else if (itemInit->IsStringLiteral()) { // NOLINT(readability-else-after-return) - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - return CreateEnumStringClassFromEnumDeclaration(enumDecl); + return CreateEnumStringTypeFromEnumDeclaration(enumDecl); } else { // NOLINT(readability-else-after-return) ThrowTypeError("Invalid enumeration value type.", enumDecl->Start()); } @@ -648,6 +648,10 @@ Type *ETSChecker::ETSBuiltinTypeAsPrimitiveType(Type *objectType) Type *ETSChecker::ETSBuiltinTypeAsConditionalType(Type *const objectType) { + if (objectType->IsTypeError()) { + return objectType; + } + if ((objectType == nullptr) || !objectType->IsConditionalExprType()) { return nullptr; } diff --git a/ets2panda/checker/ets/typeCreation.cpp b/ets2panda/checker/ets/typeCreation.cpp index ef6a39028468320eea82e21dfa892b91e656c5b0..019c41b5b30232319abb24b58087789b16767f48 100644 --- a/ets2panda/checker/ets/typeCreation.cpp +++ b/ets2panda/checker/ets/typeCreation.cpp @@ -184,10 +184,11 @@ void SetTypesForScriptFunction(checker::ETSChecker *const checker, ir::ScriptFun } // namespace -ETSEnumType::Method ETSChecker::MakeMethod(ir::TSEnumDeclaration const *const enumDecl, const std::string_view &name, - bool buildPorxyParam, Type *returnType, bool buildProxy) +ETSEnumInterface::Method ETSChecker::MakeMethod(ir::TSEnumDeclaration const *const enumDecl, + const std::string_view &name, bool buildPorxyParam, Type *returnType, + bool buildProxy) { - auto function = FindFunction(compiler::EnumLoweringPhase::GetQualifiedName(this, enumDecl, name)); + auto function = FindFunction(enumDecl, name); if (function == nullptr) { return {}; } @@ -204,12 +205,16 @@ ETSEnumType::Method ETSChecker::MakeMethod(ir::TSEnumDeclaration const *const en buildProxy ? MakeProxyFunctionType(this, name, {}, function, returnType) : nullptr}; } -[[nodiscard]] ir::ScriptFunction *ETSChecker::FindFunction(const util::UString &name) +[[nodiscard]] ir::ScriptFunction *ETSChecker::FindFunction(ir::TSEnumDeclaration const *const enumDecl, + const std::string_view &name) { - auto globalClass = Program()->GlobalClass(); - for (auto m : globalClass->Body()) { // NOTE: Temporal solution until the methods are moved to separate classes. + if (enumDecl->BoxedClass() == nullptr) { + return nullptr; + } + + for (auto m : enumDecl->BoxedClass()->Body()) { if (m->IsMethodDefinition()) { - if (m->AsMethodDefinition()->Id()->Name() == name.View()) { + if (m->AsMethodDefinition()->Id()->Name() == name) { return m->AsMethodDefinition()->Function(); } } @@ -217,7 +222,8 @@ ETSEnumType::Method ETSChecker::MakeMethod(ir::TSEnumDeclaration const *const en return nullptr; } -ETSEnumType *ETSChecker::CreateEnumIntClassFromEnumDeclaration(ir::TSEnumDeclaration const *const enumDecl) +template +EnumType *ETSChecker::CreateEnumTypeFromEnumDeclaration(ir::TSEnumDeclaration const *const enumDecl) { SavedCheckerContext savedContext(this, Context().Status(), Context().ContainingClass(), Context().ContainingSignature()); @@ -225,87 +231,70 @@ ETSEnumType *ETSChecker::CreateEnumIntClassFromEnumDeclaration(ir::TSEnumDeclara varbinder::Variable *enumVar = enumDecl->Key()->Variable(); ASSERT(enumVar != nullptr); - checker::ETSEnumType::UType ordinal = -1; - auto *const enumType = Allocator()->New(enumDecl, ordinal++); + checker::ETSEnumInterface::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()); + MakeMethod(enumDecl, ETSEnumInterface::GET_NAME_METHOD_NAME, false, GlobalETSStringLiteralType()); enumType->SetGetNameMethod(getNameMethod); - auto valueOfMethod = MakeMethod(enumDecl, ETSEnumType::VALUE_OF_METHOD_NAME, true, enumType); + auto valueOfMethod = MakeMethod(enumDecl, ETSEnumInterface::VALUE_OF_METHOD_NAME, true, enumType); enumType->SetValueOfMethod(valueOfMethod); - auto const fromIntMethod = MakeMethod(enumDecl, ETSEnumType::FROM_INT_METHOD_NAME, false, enumType, false); + auto const fromIntMethod = MakeMethod(enumDecl, ETSEnumInterface::FROM_INT_METHOD_NAME, false, enumType, false); enumType->SetFromIntMethod(fromIntMethod); - auto const getValueMethod = MakeMethod(enumDecl, ETSEnumType::GET_VALUE_METHOD_NAME, false, GlobalIntType()); - enumType->SetGetValueMethod(getValueMethod); + auto const boxedFromIntMethod = + MakeMethod(enumDecl, ETSEnumInterface::BOXED_FROM_INT_METHOD_NAME, false, boxedEnumType, false); + enumType->SetBoxedFromIntMethod(boxedFromIntMethod); + + auto const unboxMethod = MakeMethod(enumDecl, ETSEnumInterface::UNBOX_METHOD_NAME, false, enumType, false); + enumType->SetUnboxMethod(unboxMethod); auto const toStringMethod = - MakeMethod(enumDecl, ETSEnumType::TO_STRING_METHOD_NAME, false, GlobalETSStringLiteralType()); + MakeMethod(enumDecl, ETSEnumInterface::TO_STRING_METHOD_NAME, false, GlobalETSStringLiteralType()); enumType->SetToStringMethod(toStringMethod); + ETSEnumInterface::Method getValueMethod = toStringMethod; + if (IS_INT_ENUM) { + getValueMethod = MakeMethod(enumDecl, ETSEnumInterface::GET_VALUE_METHOD_NAME, false, GlobalIntType()); + } + enumType->SetGetValueMethod(getValueMethod); + auto const valuesMethod = - MakeMethod(enumDecl, ETSEnumType::VALUES_METHOD_NAME, false, CreateETSArrayType(enumType)); + MakeMethod(enumDecl, ETSEnumInterface::VALUES_METHOD_NAME, false, CreateETSArrayType(enumType)); enumType->SetValuesMethod(valuesMethod); for (auto *const member : enumType->GetMembers()) { auto *const memberVar = member->AsTSEnumMember()->Key()->AsIdentifier()->Variable(); - auto *const enumLiteralType = - Allocator()->New(enumDecl, ordinal++, member->AsTSEnumMember()); + auto *const enumLiteralType = Allocator()->New(enumDecl, ordinal++, member->AsTSEnumMember()); enumLiteralType->SetVariable(memberVar); memberVar->SetTsType(enumLiteralType); - enumLiteralType->SetGetValueMethod(getValueMethod); enumLiteralType->SetGetNameMethod(getNameMethod); + enumLiteralType->SetValueOfMethod(valueOfMethod); + enumLiteralType->SetFromIntMethod(fromIntMethod); + enumLiteralType->SetBoxedFromIntMethod(boxedFromIntMethod); + enumLiteralType->SetUnboxMethod(unboxMethod); + enumLiteralType->SetGetValueMethod(getValueMethod); enumLiteralType->SetToStringMethod(toStringMethod); + enumLiteralType->SetValuesMethod(valuesMethod); } return enumType; } -ETSStringEnumType *ETSChecker::CreateEnumStringClassFromEnumDeclaration(ir::TSEnumDeclaration const *const enumDecl) +ETSEnumType *ETSChecker::CreateEnumIntTypeFromEnumDeclaration(ir::TSEnumDeclaration const *const enumDecl) { - varbinder::Variable *enumVar = enumDecl->Key()->Variable(); - ASSERT(enumVar != nullptr); - - checker::ETSEnumType::UType ordinal = -1; - auto *const enumType = Allocator()->New(enumDecl, ordinal++); - enumType->SetVariable(enumVar); - enumVar->SetTsType(enumType); - - auto const getNameMethod = - MakeMethod(enumDecl, ETSEnumType::GET_NAME_METHOD_NAME, false, GlobalETSStringLiteralType()); - enumType->SetGetNameMethod(getNameMethod); - - auto valueOfMethod = MakeMethod(enumDecl, ETSEnumType::VALUE_OF_METHOD_NAME, true, enumType); - enumType->SetValueOfMethod(valueOfMethod); - - auto const fromIntMethod = MakeMethod(enumDecl, ETSEnumType::FROM_INT_METHOD_NAME, false, enumType, false); - enumType->SetFromIntMethod(fromIntMethod); - - auto const toStringMethod = - MakeMethod(enumDecl, ETSEnumType::TO_STRING_METHOD_NAME, false, GlobalETSStringLiteralType()); - enumType->SetGetValueMethod(toStringMethod); - enumType->SetToStringMethod(toStringMethod); - - auto const valuesMethod = - MakeMethod(enumDecl, ETSEnumType::VALUES_METHOD_NAME, false, CreateETSArrayType(enumType)); - enumType->SetValuesMethod(valuesMethod); - - for (auto *const member : enumType->GetMembers()) { - auto *const memberVar = member->AsTSEnumMember()->Key()->AsIdentifier()->Variable(); - auto *const enumLiteralType = - Allocator()->New(enumDecl, ordinal++, member->AsTSEnumMember()); - enumLiteralType->SetVariable(memberVar); - memberVar->SetTsType(enumLiteralType); + return CreateEnumTypeFromEnumDeclaration(enumDecl); +} - enumLiteralType->SetGetValueMethod(toStringMethod); - enumLiteralType->SetGetNameMethod(getNameMethod); - enumLiteralType->SetToStringMethod(toStringMethod); - } - return enumType; +ETSStringEnumType *ETSChecker::CreateEnumStringTypeFromEnumDeclaration(ir::TSEnumDeclaration const *const enumDecl) +{ + return CreateEnumTypeFromEnumDeclaration(enumDecl); } Type *ETSChecker::CreateETSUnionType(Span constituentTypes) diff --git a/ets2panda/checker/ets/typeRelationContext.cpp b/ets2panda/checker/ets/typeRelationContext.cpp index bd0834d6fe7b12ebf983fabdd1fa09bd0d9b072f..557db5e37a8b07dfd79e942a78a115a86c8ae34d 100644 --- a/ets2panda/checker/ets/typeRelationContext.cpp +++ b/ets2panda/checker/ets/typeRelationContext.cpp @@ -60,24 +60,6 @@ bool InstantiationContext::ValidateTypeArguments(ETSObjectType *type, ir::TSType return false; } -bool InstantiationContext::ValidateTypeArg(Type *constraintType, Type *typeArg) -{ - // NOTE: #14993 enforce IsETSReferenceType - if (typeArg->IsWildcardType()) { - return true; - } - - if (typeArg->IsETSVoidType() && constraintType->IsETSUnionType()) { - for (auto const it : constraintType->AsETSUnionType()->ConstituentTypes()) { - if (it->IsETSUndefinedType() || it->IsETSVoidType()) { - return true; - } - } - } - - return checker_->Relation()->IsAssignableTo(typeArg, constraintType); -} - void InstantiationContext::InstantiateType(ETSObjectType *type, ir::TSTypeParameterInstantiation *typeArgs) { ArenaVector typeArgTypes(checker_->Allocator()->Adapter()); diff --git a/ets2panda/checker/ets/typeRelationContext.h b/ets2panda/checker/ets/typeRelationContext.h index 8924087a3ccada1ce8dba041733f0fd71f60f6ce..a48e8e5423f338c11b0f92df42ea929f21a145a5 100644 --- a/ets2panda/checker/ets/typeRelationContext.h +++ b/ets2panda/checker/ets/typeRelationContext.h @@ -193,8 +193,6 @@ private: bool ValidateTypeArguments(ETSObjectType *type, ir::TSTypeParameterInstantiation *typeArgs, const lexer::SourcePosition &pos); - bool ValidateTypeArg(Type *constraintType, Type *typeArg); - void InstantiateType(ETSObjectType *type, ir::TSTypeParameterInstantiation *typeArgs); void InstantiateType(ETSObjectType *type, ArenaVector &&typeArgTypes, const lexer::SourcePosition &pos); diff --git a/ets2panda/checker/types/ets/etsEnumType.cpp b/ets2panda/checker/types/ets/etsEnumType.cpp index d9f78c18ccb958b4ae965a0fe173177020ac30f2..32f6a29b40d754d790cfa094e0fa1421963ba509 100644 --- a/ets2panda/checker/types/ets/etsEnumType.cpp +++ b/ets2panda/checker/types/ets/etsEnumType.cpp @@ -31,9 +31,16 @@ ETSEnumInterface::ETSEnumInterface(const ir::TSEnumDeclaration *const enumDecl, bool ETSEnumInterface::AssignmentSource(TypeRelation *const relation, Type *const target) { - auto const result = target->IsETSEnumType() - ? IsSameEnumType(target->AsETSEnumType()) - : (target->IsETSStringEnumType() ? IsSameEnumType(target->AsETSStringEnumType()) : false); + bool result = false; + + if (target->IsETSEnumType()) { + result = IsSameEnumType(target->AsETSEnumType()); + } else if (target->IsETSStringEnumType()) { + result = IsSameEnumType(target->AsETSStringEnumType()); + } else if (target->IsETSObjectType()) { + result = true; + relation->GetNode()->AddBoxingUnboxingFlags(ir::BoxingUnboxingFlags::BOX_TO_ENUM); + } relation->Result(result); return relation->IsTrue(); } @@ -57,7 +64,9 @@ void ETSEnumInterface::Cast(TypeRelation *relation, Type *target) relation->Result(true); return; } - + if (target->IsETSObjectType()) { + conversion::Boxing(relation, this); + } conversion::Forbidden(relation); } @@ -242,6 +251,18 @@ ETSEnumInterface::Method ETSEnumInterface::FromIntMethod() const noexcept return fromIntMethod_; } +ETSEnumInterface::Method ETSEnumInterface::BoxedFromIntMethod() const noexcept +{ + ASSERT(boxedFromIntMethod_.globalSignature != nullptr && boxedFromIntMethod_.memberProxyType == nullptr); + return boxedFromIntMethod_; +} + +ETSEnumInterface::Method ETSEnumInterface::UnboxMethod() const noexcept +{ + ASSERT(unboxMethod_.globalSignature != nullptr && unboxMethod_.memberProxyType == nullptr); + return unboxMethod_; +} + ETSEnumInterface::Method ETSEnumInterface::GetValueMethod() const noexcept { ASSERT(getValueMethod_.globalSignature != nullptr && getValueMethod_.memberProxyType != nullptr); diff --git a/ets2panda/checker/types/ets/etsEnumType.h b/ets2panda/checker/types/ets/etsEnumType.h index 2125b1ad763f65d9b816de9f70682b43ab8a5a39..6a4b776208bf5a931937e76c6004770a5648eec9 100644 --- a/ets2panda/checker/types/ets/etsEnumType.h +++ b/ets2panda/checker/types/ets/etsEnumType.h @@ -96,6 +96,8 @@ public: static constexpr std::string_view const VALUE_OF_METHOD_NAME {"valueOf"}; 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; @@ -138,6 +140,18 @@ public: 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 {true, !GetMembers().empty()}; @@ -154,6 +168,8 @@ private: Method valueOfMethod_ {}; Method valuesMethod_ {}; Method fromIntMethod_ {}; + Method boxedFromIntMethod_ {}; + Method unboxMethod_ {}; [[nodiscard]] ir::TSEnumMember *FindMember(const util::StringView &name) const noexcept; diff --git a/ets2panda/checker/types/ets/etsObjectType.cpp b/ets2panda/checker/types/ets/etsObjectType.cpp index cb96ccd8be625820d15391f93a9388b74c8a9ca3..de6006a18be9d99dcdaa9e2bdc32c31f170a9bae 100644 --- a/ets2panda/checker/types/ets/etsObjectType.cpp +++ b/ets2panda/checker/types/ets/etsObjectType.cpp @@ -157,7 +157,6 @@ varbinder::LocalVariable *ETSObjectType::CreateSyntheticVarFromEverySignature(co varbinder::LocalVariable *res = allocator_->New(varbinder::VariableFlags::SYNTHETIC | varbinder::VariableFlags::METHOD); ETSFunctionType *funcType = CreateETSFunctionType(name); - funcType->AddTypeFlag(TypeFlag::SYNTHETIC); varbinder::LocalVariable *functionalInterface = CollectSignaturesForSyntheticType(funcType, name, flags); @@ -183,6 +182,10 @@ varbinder::LocalVariable *ETSObjectType::CollectSignaturesForSyntheticType(ETSFu const util::StringView &name, PropertySearchFlags flags) const { + if (funcType == nullptr) { + return nullptr; + } + auto const addSignature = [funcType, flags](varbinder::LocalVariable *found) -> void { for (auto *it : found->TsType()->AsETSFunctionType()->CallSignatures()) { if (((flags & PropertySearchFlags::IGNORE_ABSTRACT) != 0) && @@ -606,6 +609,11 @@ void ETSObjectType::Cast(TypeRelation *const relation, Type *const target) } } + if (target->IsETSEnumType() || target->IsETSStringEnumType()) { + relation->GetNode()->AddBoxingUnboxingFlags(ir::BoxingUnboxingFlags::UNBOX_TO_ENUM); + relation->Result(true); + return; + } conversion::Forbidden(relation); } diff --git a/ets2panda/checker/types/ets/etsObjectType.h b/ets2panda/checker/types/ets/etsObjectType.h index e78d1c94e57734bc69b09522af6a4df2229d4fad..3861d5eaec5ae29f91c278a4bddae2b59b9ef263 100644 --- a/ets2panda/checker/types/ets/etsObjectType.h +++ b/ets2panda/checker/types/ets/etsObjectType.h @@ -337,6 +337,19 @@ public: propertiesInstantiated_ = true; } + template + void AddProperty(varbinder::LocalVariable *prop, util::StringView localName) const + { + util::StringView nameToAccess = prop->Name(); + + if (!localName.Empty()) { + nameToAccess = localName; + } + + properties_[static_cast(TYPE)].emplace(nameToAccess, prop); + propertiesInstantiated_ = true; + } + template void RemoveProperty(varbinder::LocalVariable *prop) { diff --git a/ets2panda/checker/types/ets/etsUnionType.cpp b/ets2panda/checker/types/ets/etsUnionType.cpp index d71bf503d22e2d6ba0c2b578fe710738be2b11af..31f3c493e4559af5a180fa3e722ad5e0a09e520b 100644 --- a/ets2panda/checker/types/ets/etsUnionType.cpp +++ b/ets2panda/checker/types/ets/etsUnionType.cpp @@ -649,8 +649,9 @@ Type *ETSUnionType::FindUnboxableType() const bool ETSUnionType::HasObjectType(ETSObjectFlags flag) const { - auto it = std::find_if(constituentTypes_.begin(), constituentTypes_.end(), - [flag](Type *t) { return t->AsETSObjectType()->HasObjectFlag(flag); }); + auto it = std::find_if(constituentTypes_.begin(), constituentTypes_.end(), [flag](Type *t) { + return t->IsETSObjectType() && t->AsETSObjectType()->HasObjectFlag(flag); + }); return it != constituentTypes_.end(); } diff --git a/ets2panda/checker/types/globalTypesHolder.cpp b/ets2panda/checker/types/globalTypesHolder.cpp index 1948e5c421dbc09857cc232747ec76c4e9b81d62..f99e2aefaf6967e3e06caa24f27e4fa526d5d907 100644 --- a/ets2panda/checker/types/globalTypesHolder.cpp +++ b/ets2panda/checker/types/globalTypesHolder.cpp @@ -15,6 +15,7 @@ #include "globalTypesHolder.h" +#include "checker/types/typeError.h" #include "checker/types/ts/numberType.h" #include "checker/types/ts/anyType.h" #include "checker/types/ts/stringType.h" @@ -117,6 +118,7 @@ GlobalTypesHolder::GlobalTypesHolder(ArenaAllocator *allocator) : builtinNameMap globalTypes_[static_cast(GlobalTypeId::ETS_NULL)] = allocator->New(); globalTypes_[static_cast(GlobalTypeId::ETS_UNDEFINED)] = allocator->New(); globalTypes_[static_cast(GlobalTypeId::ETS_WILDCARD)] = allocator->New(); + globalTypes_[static_cast(GlobalTypeId::TYPE_ERROR)] = allocator->New(); builtinNameMappings_.emplace("Boolean", GlobalTypeId::ETS_BOOLEAN_BUILTIN); builtinNameMappings_.emplace("Byte", GlobalTypeId::ETS_BYTE_BUILTIN); @@ -161,6 +163,8 @@ GlobalTypesHolder::GlobalTypesHolder(ArenaAllocator *allocator) : builtinNameMap // ETS escompat layer AddETSEscompatLayer(); + builtinNameMappings_.emplace("TYPE ERROR", GlobalTypeId::TYPE_ERROR); + // ETS functional types for (size_t id = static_cast(GlobalTypeId::ETS_FUNCTION0_CLASS), nargs = 0; id < static_cast(GlobalTypeId::ETS_FUNCTIONN_CLASS); id++, nargs++) { @@ -642,6 +646,11 @@ Type *GlobalTypesHolder::GlobalFunctionBuiltinType(size_t nargs) return globalTypes_.at(static_cast(GlobalTypeId::ETS_FUNCTION0_CLASS) + nargs); } +Type *GlobalTypesHolder::GlobalTypeError() +{ + return globalTypes_.at(static_cast(GlobalTypeId::TYPE_ERROR)); +} + void GlobalTypesHolder::InitializeBuiltin(const util::StringView name, Type *type) { const auto typeId = builtinNameMappings_.find(name); diff --git a/ets2panda/checker/types/globalTypesHolder.h b/ets2panda/checker/types/globalTypesHolder.h index 9f6d37f94b188c3694fc60f4793401ed5c038372..98e71c037eb1edcd5bb781519f6ef570aebc7d2f 100644 --- a/ets2panda/checker/types/globalTypesHolder.h +++ b/ets2panda/checker/types/globalTypesHolder.h @@ -131,6 +131,8 @@ enum class GlobalTypeId : std::size_t { ETS_FUNCTION16_CLASS, ETS_FUNCTIONN_CLASS, + TYPE_ERROR, + COUNT, }; @@ -246,6 +248,8 @@ public: Type *GlobalJSRuntimeBuiltinType(); Type *GlobalJSValueBuiltinType(); + Type *GlobalTypeError(); + void InitializeBuiltin(util::StringView name, Type *type); using Holder = std::array(GlobalTypeId::COUNT)>; diff --git a/ets2panda/checker/types/type.cpp b/ets2panda/checker/types/type.cpp index 3d443396d49f3fa039cd9d1107931f8b439ddb36..a0aab5954d2cb81ac0ff99f00b5833cea34d03e5 100644 --- a/ets2panda/checker/types/type.cpp +++ b/ets2panda/checker/types/type.cpp @@ -167,4 +167,15 @@ std::uint32_t Type::GetPrecedence(Type const *type) noexcept } return 0U; } + +bool IsTypeError(Type const *tp) +{ + return tp != nullptr && tp->IsTypeError(); +} + +void ThrowEmptyError() +{ + throw Error(ErrorType::TYPE, "", ""); +} + } // namespace ark::es2panda::checker diff --git a/ets2panda/checker/types/type.h b/ets2panda/checker/types/type.h index a1e21b1e2204d87c490032ae7723f1c720b1b820..6a0183a19f5a4df51ee2f1d93f9a8a5998eeb1b4 100644 --- a/ets2panda/checker/types/type.h +++ b/ets2panda/checker/types/type.h @@ -33,6 +33,7 @@ class ETSAsyncFuncReturnType; class ETSChecker; class ETSDynamicFunctionType; class ETSTypeParameter; +class ETSEnumInterface; // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define DECLARE_TYPENAMES(typeFlag, typeName) class typeName; @@ -267,6 +268,18 @@ public: [[nodiscard]] virtual Type *Clone(Checker *checker); virtual Type *Substitute(TypeRelation *relation, const Substitution *substitution); + const ETSEnumInterface *AsEnumInterface() const + { + ASSERT(IsETSEnumType() || IsETSStringEnumType()); + return reinterpret_cast(this); + } + + ETSEnumInterface *AsEnumInterface() + { + ASSERT(IsETSEnumType() || IsETSStringEnumType()); + return reinterpret_cast(this); + } + protected: // NOLINTBEGIN(misc-non-private-member-variables-in-classes) TypeFlag typeFlags_; @@ -274,6 +287,14 @@ protected: uint64_t id_; // NOLINTEND(misc-non-private-member-variables-in-classes) }; + +// NOLINTBEGIN(readability-redundant-declaration) +// To avoid including type.h from variable.h, astNode.h +bool IsTypeError(Type const *tp); +// Use this in order to avoid crashes where TypeError is not expected +[[noreturn]] void ThrowEmptyError(); +// NOLINTEND(readability-redundant-declaration) + } // namespace ark::es2panda::checker #endif /* TYPESCRIPT_TYPES_TYPE_H */ diff --git a/ets2panda/checker/types/typeError.h b/ets2panda/checker/types/typeError.h new file mode 100644 index 0000000000000000000000000000000000000000..a07736532c1831311061e8b4333d7eda069a7699 --- /dev/null +++ b/ets2panda/checker/types/typeError.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ES2PANDA_CHECKER_TYPES_ERROR_TYPE_ERROR_H +#define ES2PANDA_CHECKER_TYPES_ERROR_TYPE_ERROR_H + +#include "es2panda.h" +#include "checker/types/type.h" + +namespace ark::es2panda::checker { + +class TypeError : public Type { +public: + explicit TypeError() : Type(TypeFlag::TYPE_ERROR) {} + + bool AssignmentSource(TypeRelation *relation, [[maybe_unused]] Type *target) override + { + // Don't spread the error + relation->Result(RelationResult::TRUE); + return true; + } + + void AssignmentTarget(TypeRelation *relation, [[maybe_unused]] Type *source) override + { + // Don't spread the error + relation->Result(RelationResult::TRUE); + } + + void ToString(std::stringstream &ss, [[maybe_unused]] bool precise) const override + { + ss << "*TYPE_ERROR*"; + } +}; + +} // namespace ark::es2panda::checker + +#endif diff --git a/ets2panda/checker/types/typeFlag.h b/ets2panda/checker/types/typeFlag.h index 59a66bfaf395f3bd88cf4b75b923ca77d93bb966..413d17915a8b84388e788c8993428a1869f3a634 100644 --- a/ets2panda/checker/types/typeFlag.h +++ b/ets2panda/checker/types/typeFlag.h @@ -71,24 +71,24 @@ enum class TypeFlag : uint64_t { ETS_VOID = 1ULL << 43ULL, // ETS void type ETS_OBJECT = 1ULL << 44ULL, // ETS class or interface type ETS_ARRAY = 1ULL << 45ULL, // ETS array type - SYNTHETIC = 1ULL << 46ULL, // synthetic type created by the checker for specific checks - WILDCARD = 1ULL << 47ULL, // new A() - ETS_TYPE_PARAMETER = 1ULL << 48ULL, // ETS type parameter - ETS_TYPE_REFERENCE = 1ULL << 49ULL, // ETS type reference - GENERIC = 1ULL << 50ULL, // ETS Generic - ETS_ENUM = 1ULL << 51ULL, // ETS Enum - ETS_STRING_ENUM = 1ULL << 52ULL, // ETS string-type Enumeration - ETS_DYNAMIC_FLAG = 1ULL << 53ULL, // ETS Dynamic flag - GETTER = 1ULL << 54ULL, // ETS Getter - SETTER = 1ULL << 55ULL, // ETS Setter - ETS_EXTENSION_FUNC_HELPER = 1ULL << 56ULL, // ETS Extension Function Helper - ETS_UNION = 1ULL << 57ULL, // ETS union - ETS_TUPLE = 1ULL << 58ULL, // ETS tuple type - ETS_NULL = 1ULL << 59ULL, // ETS null - ETS_UNDEFINED = 1ULL << 60ULL, // ETS undefined - ETS_NONNULLISH = 1ULL << 61ULL, // ETS nonnullish type parameter - ETS_READONLY = 1ULL << 62ULL, // ETS readonly type parameter - ETS_REQUIRED_TYPE_PARAMETER = 1ULL << 63ULL, // ETS Required type parameter + WILDCARD = 1ULL << 46ULL, // new A() + ETS_TYPE_PARAMETER = 1ULL << 47ULL, // ETS type parameter + ETS_TYPE_REFERENCE = 1ULL << 48ULL, // ETS type reference + GENERIC = 1ULL << 49ULL, // ETS Generic + ETS_ENUM = 1ULL << 50ULL, // ETS Enum + ETS_STRING_ENUM = 1ULL << 51ULL, // ETS string-type Enumeration + ETS_DYNAMIC_FLAG = 1ULL << 52ULL, // ETS Dynamic flag + GETTER = 1ULL << 53ULL, // ETS Getter + SETTER = 1ULL << 54ULL, // ETS Setter + ETS_EXTENSION_FUNC_HELPER = 1ULL << 55ULL, // ETS Extension Function Helper + ETS_UNION = 1ULL << 56ULL, // ETS union + ETS_TUPLE = 1ULL << 57ULL, // ETS tuple type + ETS_NULL = 1ULL << 58ULL, // ETS null + ETS_UNDEFINED = 1ULL << 59ULL, // ETS undefined + ETS_NONNULLISH = 1ULL << 60ULL, // ETS nonnullish type parameter + ETS_READONLY = 1ULL << 61ULL, // ETS readonly type parameter + ETS_REQUIRED_TYPE_PARAMETER = 1ULL << 62ULL, // ETS Required type parameter + TYPE_ERROR = 1ULL << 63ULL, // type error 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 | diff --git a/ets2panda/checker/types/typeMapping.h b/ets2panda/checker/types/typeMapping.h index 653fc40c15796b534fbe661e853d0e7044b334c2..b3c116db4d0c1033e6c13de042f219e5cea84133 100644 --- a/ets2panda/checker/types/typeMapping.h +++ b/ets2panda/checker/types/typeMapping.h @@ -64,7 +64,8 @@ _(TypeFlag::ETS_ENUM, ETSEnumType) \ _(TypeFlag::ETS_STRING_ENUM, ETSStringEnumType) \ _(TypeFlag::ETS_EXTENSION_FUNC_HELPER, ETSExtensionFuncHelperType) \ - _(TypeFlag::ETS_TUPLE, ETSTupleType) + _(TypeFlag::ETS_TUPLE, ETSTupleType) \ + _(TypeFlag::TYPE_ERROR, TypeError) #define OBJECT_TYPE_MAPPING(_) \ _(ObjectType::ObjectTypeKind::FUNCTION, FunctionType) \ diff --git a/ets2panda/compiler/core/ASTVerifier.cpp b/ets2panda/compiler/core/ASTVerifier.cpp deleted file mode 100644 index ebb27993e3b243c5776a29fe35daee9aed520fe0..0000000000000000000000000000000000000000 --- a/ets2panda/compiler/core/ASTVerifier.cpp +++ /dev/null @@ -1,1443 +0,0 @@ -/* - * Copyright (c) 2023-2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ASTVerifier.h" - -#include "checker/types/typeFlag.h" -#include "ir/astNode.h" -#include "ir/base/classDefinition.h" -#include "ir/base/classElement.h" -#include "ir/statement.h" -#include "ir/base/classStaticBlock.h" -#include "ir/base/methodDefinition.h" -#include "ir/base/scriptFunction.h" -#include "ir/ets/etsClassLiteral.h" -#include "ir/ets/etsFunctionType.h" -#include "ir/ets/etsNewClassInstanceExpression.h" -#include "ir/ets/etsParameterExpression.h" -#include "ir/ets/etsTypeReference.h" -#include "ir/ets/etsTypeReferencePart.h" -#include "ir/ets/etsImportDeclaration.h" -#include "ir/ets/etsScript.h" -#include "ir/expressions/sequenceExpression.h" -#include "ir/module/importSpecifier.h" -#include "ir/module/importNamespaceSpecifier.h" -#include "ir/module/importDefaultSpecifier.h" -#include "ir/expressions/callExpression.h" -#include "ir/expressions/binaryExpression.h" -#include "ir/expressions/functionExpression.h" -#include "ir/expressions/identifier.h" -#include "ir/expressions/literals/numberLiteral.h" -#include "ir/expressions/literals/stringLiteral.h" -#include "ir/expressions/memberExpression.h" -#include "ir/statements/blockStatement.h" -#include "ir/statements/forInStatement.h" -#include "ir/statements/forOfStatement.h" -#include "ir/statements/forUpdateStatement.h" -#include "ir/statements/variableDeclaration.h" -#include "ir/statements/variableDeclarator.h" -#include "ir/statements/classDeclaration.h" -#include "ir/statements/expressionStatement.h" -#include "ir/statements/throwStatement.h" -#include "ir/statements/tryStatement.h" -#include "ir/ts/tsClassImplements.h" -#include "ir/ts/tsEnumDeclaration.h" -#include "ir/ts/tsInterfaceBody.h" -#include "ir/ts/tsTypeParameter.h" -#include "ir/ts/tsTypeParameterDeclaration.h" -#include "ir/ts/tsTypeParameterInstantiation.h" -#include "lexer/token/tokenType.h" -#include "util/ustring.h" -#include "utils/arena_containers.h" -#include "varbinder/scope.h" - -#include -#include - -namespace ark::es2panda::compiler::ast_verifier { -class CheckContext { -public: - explicit CheckContext() : checkName_ {"Invalid"} {} - - void AddCheckMessage(const std::string &cause, const ir::AstNode &node, const lexer::SourcePosition &from) - { - const auto loc = from.line; - const auto &&dump = node.DumpJSON(); - messages_.emplace_back(checkName_, cause.data(), dump.data(), loc); - } - - void SetCheckName(util::StringView checkName) - { - checkName_ = checkName; - } - - Messages GetMessages() - { - return messages_; - } - -private: - Messages messages_; - util::StringView checkName_; -}; - -static bool IsBooleanType(const ir::AstNode *ast) -{ - if (ast == nullptr) { - return false; - } - - if (!ast->IsTyped()) { - return false; - } - - auto typedAst = static_cast(ast); - - if (typedAst->TsType() == nullptr) { - return false; - } - - if (typedAst->TsType()->HasTypeFlag(checker::TypeFlag::ETS_OBJECT) && - ast->HasBoxingUnboxingFlags(ir::BoxingUnboxingFlags::UNBOXING_FLAG)) { - return typedAst->TsType()->AsETSObjectType()->HasObjectFlag(checker::ETSObjectFlags::BUILTIN_BOOLEAN); - } - - return typedAst->TsType()->HasTypeFlag(checker::TypeFlag::ETS_BOOLEAN) || - typedAst->TsType()->HasTypeFlag(checker::TypeFlag::BOOLEAN_LIKE); -} - -bool IsImportLike(const ir::AstNode *ast) -{ - return (ast->IsETSImportDeclaration() || ast->IsETSReExportDeclaration() || ast->IsImportExpression() || - ast->IsImportSpecifier() || ast->IsImportDefaultSpecifier() || ast->IsImportNamespaceSpecifier()); -} - -bool IsExportLike(const ir::AstNode *ast) -{ - return (ast->IsExportDefaultDeclaration() || ast->IsExportSpecifier() || ast->IsExportAllDeclaration() || - ast->IsExportNamedDeclaration() || ast->IsETSReExportDeclaration()); -} - -static bool IsValidTypeForBinaryOp(const ir::AstNode *ast, bool isBitwise) -{ - if (ast == nullptr) { - std::cout << __LINE__ << std::endl; - return false; - } - - if (!ast->IsTyped()) { - std::cout << __LINE__ << std::endl; - return false; - } - - auto typedAst = static_cast(ast); - - if (typedAst->TsType() == nullptr) { - // std::cout << typedAst - std::cout << __LINE__ << std::endl; - return false; - } - - if (IsBooleanType(ast)) { - return isBitwise; - } - - if (typedAst->TsType()->HasTypeFlag(checker::TypeFlag::ETS_OBJECT) && - typedAst->TsType()->AsETSObjectType()->HasObjectFlag(checker::ETSObjectFlags::BUILTIN_BIGINT)) { - return true; - } - - if (typedAst->TsType()->HasTypeFlag(checker::TypeFlag::ETS_OBJECT) && - ast->HasBoxingUnboxingFlags(ir::BoxingUnboxingFlags::UNBOXING_FLAG)) { - return typedAst->TsType()->AsETSObjectType()->HasObjectFlag(checker::ETSObjectFlags::BUILTIN_TYPE) && - !typedAst->TsType()->AsETSObjectType()->HasObjectFlag(checker::ETSObjectFlags::BUILTIN_BOOLEAN); - } - - return typedAst->TsType()->HasTypeFlag(checker::TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC) || - typedAst->TsType()->HasTypeFlag(checker::TypeFlag::NUMBER_LITERAL) || - typedAst->TsType()->HasTypeFlag(checker::TypeFlag::BIGINT) || - typedAst->TsType()->HasTypeFlag(checker::TypeFlag::BIGINT_LITERAL); -} - -static bool IsStringType(const ir::AstNode *ast) -{ - if (ast == nullptr) { - return false; - } - - if (!ast->IsTyped()) { - return false; - } - - auto typedAst = static_cast(ast); - - if (typedAst->TsType() == nullptr) { - return false; - } - - if (typedAst->TsType()->HasTypeFlag(checker::TypeFlag::ETS_OBJECT)) { - return typedAst->TsType()->AsETSObjectType()->HasObjectFlag(checker::ETSObjectFlags::STRING) || - typedAst->TsType()->AsETSObjectType()->HasObjectFlag(checker::ETSObjectFlags::BUILTIN_STRING); - } - - return typedAst->TsType()->HasTypeFlag(checker::TypeFlag::STRING_LIKE); -} - -template -static bool IsContainedIn(const T *child, const T *parent) -{ - if (child == nullptr || parent == nullptr) { - return false; - } - - std::unordered_set savedNodes; - while (child != nullptr && child != parent) { - savedNodes.emplace(child); - child = child->Parent(); - if (savedNodes.find(child) != savedNodes.end()) { - return false; - } - } - return child == parent; -} -bool IsVisibleInternalNode(const ir::AstNode *ast, const ir::AstNode *objTypeDeclNode) -{ - // NOTE(orlovskymaxim) This relies on the fact, that GetTopStatement has no bugs, that is not the case for now - if (!ast->GetTopStatement()->IsETSScript()) { - return false; - } - auto *currentTopStatement = (static_cast(ast->GetTopStatement())); - auto *currentProgram = currentTopStatement->Program(); - if (currentProgram == nullptr) { - return false; - } - util::StringView moduleNameCurrent = currentProgram->ModuleName(); - // NOTE(orlovskymaxim) This relies on the fact, that GetTopStatement has no bugs, that is not the case for now - if (!objTypeDeclNode->GetTopStatement()->IsETSScript()) { - return false; - } - auto *objectTopStatement = (static_cast(objTypeDeclNode->GetTopStatement())); - auto *objectProgram = objectTopStatement->Program(); - if (objectProgram == nullptr) { - return false; - } - util::StringView moduleNameObject = objectProgram->ModuleName(); - return currentTopStatement == objectTopStatement || moduleNameCurrent == moduleNameObject; -} - -static const checker::Type *GetClassDefinitionType(const ir::AstNode *ast) -{ - const ir::AstNode *tmpNode = ast; - while (tmpNode->Parent() != nullptr && !tmpNode->IsClassDefinition()) { - tmpNode = tmpNode->Parent(); - } - if (!tmpNode->IsClassDefinition()) { - return nullptr; - } - auto *classDefinition = tmpNode->AsClassDefinition(); - return classDefinition->TsType(); -} - -static const checker::Type *GetTSInterfaceDeclarationType(const ir::AstNode *ast) -{ - const ir::AstNode *tmpNode = ast; - while (tmpNode->Parent() != nullptr && !tmpNode->IsTSInterfaceDeclaration()) { - tmpNode = tmpNode->Parent(); - } - if (!tmpNode->IsTSInterfaceDeclaration()) { - return nullptr; - } - auto *tsInterfaceDeclaration = tmpNode->AsTSInterfaceDeclaration(); - return tsInterfaceDeclaration->TsType(); -} - -static bool ValidateMethodAccessForClass(const ir::AstNode *ast, const ir::AstNode *ownerSignDeclNode, - checker::Signature *signature, const ir::AstNode *memberObjTypeDeclNode) -{ - // Check if the method is used where it is declared - if (IsContainedIn(ast, ownerSignDeclNode)) { - return true; - } - if (signature->HasSignatureFlag(checker::SignatureFlags::PRIVATE)) { - return false; - } - if (signature->HasSignatureFlag(checker::SignatureFlags::PROTECTED)) { - // Check if the method is inherited and is used in class in which it is inherited - auto *classDefinitionType = GetClassDefinitionType(ast); - if (classDefinitionType == nullptr || !classDefinitionType->IsETSObjectType()) { - return false; - } - auto *classObjectType = classDefinitionType->AsETSObjectType(); - return classObjectType->IsDescendantOf(signature->Owner()); - } - if (signature->HasSignatureFlag(checker::SignatureFlags::INTERNAL)) { - return IsVisibleInternalNode(ast, memberObjTypeDeclNode); - } - return true; -} - -static bool ValidateMethodAccessForTSInterface(const ir::AstNode *ast, const ir::AstNode *ownerSignDeclNode, - checker::Signature *signature, const ir::AstNode *memberObjTypeDeclNode) -{ - // Check if the method is used where it is declared - if (IsContainedIn(ast, ownerSignDeclNode)) { - return true; - } - if (signature->HasSignatureFlag(checker::SignatureFlags::PRIVATE)) { - return false; - } - if (signature->HasSignatureFlag(checker::SignatureFlags::PROTECTED)) { - // Check if the method is inherited and is used in class in which it is inherited - auto *tsInterfaceDeclarationType = GetTSInterfaceDeclarationType(ast); - if (tsInterfaceDeclarationType == nullptr || !tsInterfaceDeclarationType->IsETSObjectType()) { - return false; - } - auto *tsInterfaceObjectType = tsInterfaceDeclarationType->AsETSObjectType(); - return tsInterfaceObjectType->IsDescendantOf(signature->Owner()); - } - if (signature->HasSignatureFlag(checker::SignatureFlags::INTERNAL)) { - return IsVisibleInternalNode(ast, memberObjTypeDeclNode); - } - return true; -} - -static bool ValidatePropertyAccessForClass(const ir::AstNode *ast, const ir::AstNode *propVarDeclNode, - const ir::AstNode *propVarDeclNodeParent, - const varbinder::LocalVariable *propVar, const ir::AstNode *objTypeDeclNode) -{ - // Check if the variable is used where it is declared - if (IsContainedIn(ast, propVarDeclNodeParent)) { - return true; - } - if (propVarDeclNode->IsPrivate()) { - return false; - } - if (propVarDeclNode->IsProtected()) { - auto *classDefinitionType = GetClassDefinitionType(ast); - if (classDefinitionType == nullptr || !classDefinitionType->IsETSObjectType()) { - return false; - } - auto *classObjectType = classDefinitionType->AsETSObjectType(); - return classObjectType->IsPropertyOfAscendant(propVar); - } - if (propVarDeclNode->IsInternal()) { - return IsVisibleInternalNode(ast, objTypeDeclNode); - } - return true; -} - -static bool ValidateVariableAccess(const varbinder::LocalVariable *propVar, const ir::MemberExpression *ast) -{ - const auto *propVarDecl = propVar->Declaration(); - if (propVarDecl == nullptr) { - return false; - } - const auto *propVarDeclNode = propVarDecl->Node(); - if (propVarDeclNode == nullptr) { - return false; - } - auto *objType = ast->ObjType(); - if (objType == nullptr) { - return false; - } - const auto *objTypeDeclNode = objType->GetDeclNode(); - if (objTypeDeclNode == nullptr) { - return false; - } - if (objTypeDeclNode->Parent() != nullptr && objTypeDeclNode->Parent()->IsImportNamespaceSpecifier()) { - return true; - } - const auto *propVarDeclNodeParent = propVarDeclNode->Parent(); - if (propVarDeclNodeParent == nullptr) { - return false; - } - if (propVarDeclNodeParent->IsClassDefinition() && objTypeDeclNode->IsClassDefinition()) { - return ValidatePropertyAccessForClass(ast, propVarDeclNode, propVarDeclNodeParent, propVar, objTypeDeclNode); - } - return false; -} - -static bool ValidateMethodAccess(const ir::MemberExpression *memberExpression, const ir::CallExpression *ast) -{ - auto *memberObjType = memberExpression->ObjType(); - if (memberObjType == nullptr) { - return false; - } - if (memberObjType->HasObjectFlag(checker::ETSObjectFlags::RESOLVED_SUPER) && - memberObjType->SuperType() != nullptr && - memberObjType->SuperType()->HasObjectFlag(checker::ETSObjectFlags::BUILTIN_TYPE | - checker::ETSObjectFlags::GLOBAL)) { - return true; - } - const auto *memberObjTypeDeclNode = memberObjType->GetDeclNode(); - if (memberObjTypeDeclNode == nullptr) { - return false; - } - if (memberObjTypeDeclNode->Parent() != nullptr && memberObjTypeDeclNode->Parent()->IsImportNamespaceSpecifier()) { - return true; - } - auto *signature = ast->Signature(); - if (signature == nullptr) { - return false; - } - auto *ownerSign = signature->Owner(); - if (ownerSign == nullptr) { - return false; - } - auto *ownerSignDeclNode = ownerSign->GetDeclNode(); - if (ownerSignDeclNode == nullptr) { - return false; - } - if (!ownerSignDeclNode->IsClassDefinition() && !ownerSignDeclNode->IsTSInterfaceDeclaration()) { - return false; - } - bool ret = false; - if (memberObjTypeDeclNode->IsClassDefinition()) { - ret = ValidateMethodAccessForClass(ast, ownerSignDeclNode, signature, memberObjTypeDeclNode); - } else if (memberObjTypeDeclNode->IsTSInterfaceDeclaration()) { - ret = ValidateMethodAccessForTSInterface(ast, ownerSignDeclNode, signature, memberObjTypeDeclNode); - } - return ret; -} - -class VariableNameIdentifierNameSame { -public: - explicit VariableNameIdentifierNameSame([[maybe_unused]] ArenaAllocator &allocator) {} - - [[nodiscard]] CheckResult operator()(CheckContext &ctx, const ir::AstNode *ast) - { - if (!ast->IsIdentifier()) { - return {CheckDecision::CORRECT, CheckAction::CONTINUE}; - } - const auto *id = ast->AsIdentifier(); - const auto variable = ast->AsIdentifier()->Variable(); - if (variable == nullptr || variable->Declaration() == nullptr || variable->Declaration()->Node() == nullptr) { - return {CheckDecision::CORRECT, CheckAction::CONTINUE}; - } - const auto variableNode = variable->Declaration()->Node(); - // NOTE(psaykerone): skip because, this exceptions need to be fixed in checker and lowering - if (variableNode->IsExported() || variableNode->IsExportedType() || variableNode->IsDefaultExported() || - id->Name().Utf8().find("field") == 0 || variable->Name().Utf8().find("field") == 0) { - return {CheckDecision::CORRECT, CheckAction::CONTINUE}; - } - if (id->Name() == variable->Name()) { - return {CheckDecision::CORRECT, CheckAction::CONTINUE}; - } - - // For dynamic imports imported identifier name does not match variable name - // Example: - // import { A as AA } from "dynamic_js_import_tests" - // Variable name will be AA - // But imported identifier name is A - auto parent = ast->Parent(); - while (parent != nullptr) { - if (parent->IsETSImportDeclaration() && parent->AsETSImportDeclaration()->IsPureDynamic()) { - return {CheckDecision::CORRECT, CheckAction::CONTINUE}; - } - - parent = parent->Parent(); - } - - ctx.AddCheckMessage("IDENTIFIER_NAME_DIFFERENCE", *id, id->Start()); - return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; - } -}; - -class NodeHasParent { -public: - explicit NodeHasParent([[maybe_unused]] ArenaAllocator &allocator) {} - - [[nodiscard]] CheckResult operator()(CheckContext &ctx, const ir::AstNode *ast) - { - const auto isEtsScript = - ast->IsETSScript() || (ast->IsBlockStatement() && ast->AsBlockStatement()->IsProgram()); - const auto hasParent = ast->Parent() != nullptr; - if (!isEtsScript && !hasParent) { - ctx.AddCheckMessage("NULL_PARENT", *ast, ast->Start()); - return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; - } - if (ast->IsProgram()) { - return {CheckDecision::CORRECT, CheckAction::CONTINUE}; - } - return {CheckDecision::CORRECT, CheckAction::CONTINUE}; - } -}; - -class ReferenceTypeAnnotationIsNull { -public: - explicit ReferenceTypeAnnotationIsNull([[maybe_unused]] ArenaAllocator &allocator) {} - - [[nodiscard]] CheckResult operator()(CheckContext &ctx, const ir::AstNode *ast) - { - auto result = std::make_tuple(CheckDecision::CORRECT, CheckAction::CONTINUE); - if (ast->IsIdentifier()) { - if (ast->AsIdentifier()->IsReference() && ast->AsIdentifier()->TypeAnnotation() != nullptr) { - ctx.AddCheckMessage("TYPE_ANNOTATION_NOT_NULLPTR", *ast, ast->Start()); - result = {CheckDecision::INCORRECT, CheckAction::CONTINUE}; - } - } - return result; - } -}; - -class NodeHasSourceRange { -public: - explicit NodeHasSourceRange([[maybe_unused]] ArenaAllocator &allocator) {} - - [[nodiscard]] CheckResult operator()(CheckContext &ctx, const ir::AstNode *ast) - { - const auto hasRange = - ast->Start().line != 0 || ast->Start().index != 0 || ast->End().line != 0 || ast->End().index != 0; - if (!hasRange) { - ctx.AddCheckMessage("NULL_RANGE", *ast, ast->Start()); - return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; - } - return {CheckDecision::CORRECT, CheckAction::CONTINUE}; - } -}; - -class IdentifierHasVariable { -public: - explicit IdentifierHasVariable([[maybe_unused]] ArenaAllocator &allocator) {} - - [[nodiscard]] CheckResult operator()(CheckContext &ctx, const ir::AstNode *ast) - { - if (!ast->IsIdentifier()) { - return {CheckDecision::CORRECT, CheckAction::CONTINUE}; - } - - if (ast->AsIdentifier()->Variable() != nullptr) { - return {CheckDecision::CORRECT, CheckAction::CONTINUE}; - } - - const auto *id = ast->AsIdentifier(); - if (CheckAstExceptions(id)) { - return {CheckDecision::CORRECT, CheckAction::CONTINUE}; - } - - // Another function with exceptions to reduce function size - if (CheckMoreAstExceptions(id)) { - return {CheckDecision::CORRECT, CheckAction::CONTINUE}; - } - - ctx.AddCheckMessage("NULL_VARIABLE", *id, id->Start()); - return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; - } - -private: - bool CheckMoreAstExceptions(const ir::Identifier *ast) const - { - // NOTE(kkonkuznetsov): skip async functions - auto parent = ast->Parent(); - while (parent != nullptr) { - if (parent->IsScriptFunction()) { - auto script = parent->AsScriptFunction(); - if (script->IsAsyncFunc()) { - return true; - } - - break; - } - - parent = parent->Parent(); - } - - // NOTE(kkonkuznetsov): skip reexport declarations - if (ast->Parent() != nullptr && ast->Parent()->Parent() != nullptr) { - parent = ast->Parent()->Parent(); - if (parent->IsETSReExportDeclaration()) { - return true; - } - } - - // NOTE(kkonkuznetsov): object expressions - parent = ast->Parent(); - while (parent != nullptr) { - if (parent->IsObjectExpression()) { - return true; - } - - parent = parent->Parent(); - } - - // NOTE(kkonkuznetsov): lambdas - if (ast->Name().Utf8().find("lambda$invoke$") == 0) { - return true; - } - - // NOTE(kkonkuznetsov): some identifiers have empty names - if (ast->Name().Empty()) { - return true; - } - - // NOTE(mmartin): find a better solution to handle utility type resolution - if (ast->Name().Is(Signatures::PARTIAL_TYPE_NAME) || ast->Name().Is(Signatures::REQUIRED_TYPE_NAME) || - ast->Name().Is(Signatures::READONLY_TYPE_NAME)) { - return true; - } - - return false; - } - - bool CheckAstExceptions(const ir::Identifier *ast) const - { - // NOTE(kkonkuznetsov): skip enums - if (ast->Parent()->IsMemberExpression() && - (ast->Parent()->AsMemberExpression()->Object()->TsType() == nullptr || - ast->Parent()->AsMemberExpression()->Object()->TsType()->IsETSEnumType() || - ast->Parent()->AsMemberExpression()->Object()->TsType()->IsETSStringEnumType())) { - return true; - } - - // NOTE(kkonkuznetsov): skip length property - if (ast->Parent()->IsMemberExpression() && ast->Name().Is("length")) { - return true; - } - - // NOTE(kkonkuznetsov): skip anonymous class id - if (ast->Parent()->Parent() != nullptr && ast->Parent()->Parent()->IsETSNewClassInstanceExpression()) { - return true; - } - - // NOTE(kkonkuznetsov): skip package declarations - auto parent = ast->Parent(); - while (parent != nullptr) { - if (parent->IsETSPackageDeclaration()) { - return true; - } - - parent = parent->Parent(); - } - - return false; - } -}; - -class NodeHasType { -public: - explicit NodeHasType([[maybe_unused]] ArenaAllocator &allocator) {} - - [[nodiscard]] CheckResult operator()(CheckContext &ctx, const ir::AstNode *ast) - { - // NOTE(orlovskymaxim) In TS some ETS constructs are expressions (i.e. class/interface definition) - // Because ETS uses some AST classes from TS this introduces semantical problem - // Solution for now - manually filter expressions that are statements in ETS - if (ast->IsETSPackageDeclaration()) { - return {CheckDecision::CORRECT, CheckAction::SKIP_SUBTREE}; - } - if (IsImportLike(ast)) { - return {CheckDecision::CORRECT, CheckAction::SKIP_SUBTREE}; - } - if (IsExportLike(ast)) { - return {CheckDecision::CORRECT, CheckAction::SKIP_SUBTREE}; - } - - if (ast->IsTSTypeAliasDeclaration()) { - return {CheckDecision::CORRECT, CheckAction::SKIP_SUBTREE}; - } - if (auto [decision, action] = CheckCompound(ctx, ast); action == CheckAction::SKIP_SUBTREE) { - return {decision, action}; - } - - if (ast->IsTyped() && ast->IsExpression()) { - if (ast->IsClassDefinition() && ast->AsClassDefinition()->Ident()->Name() == "ETSGLOBAL") { - return {CheckDecision::CORRECT, CheckAction::SKIP_SUBTREE}; - } - if (ast->IsIdentifier() && ast->AsIdentifier()->Name() == "") { - return {CheckDecision::CORRECT, CheckAction::SKIP_SUBTREE}; - } - const auto *typed = static_cast(ast); - if (typed->TsType() == nullptr) { - ctx.AddCheckMessage("NULL_TS_TYPE", *ast, ast->Start()); - return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; - } - } - return {CheckDecision::CORRECT, CheckAction::CONTINUE}; - } - -private: - CheckResult CheckCompound(CheckContext &ctx, const ir::AstNode *ast) - { - if (ast->IsTSInterfaceDeclaration()) { - for (const auto &member : ast->AsTSInterfaceDeclaration()->Body()->Body()) { - [[maybe_unused]] auto _ = (*this)(ctx, member); - } - return {CheckDecision::CORRECT, CheckAction::SKIP_SUBTREE}; - } - if (ast->IsTSEnumDeclaration()) { - for (const auto &member : ast->AsTSEnumDeclaration()->Members()) { - [[maybe_unused]] auto _ = (*this)(ctx, member); - } - return {CheckDecision::CORRECT, CheckAction::SKIP_SUBTREE}; - } - if (ast->IsClassDefinition()) { - for (const auto &member : ast->AsClassDefinition()->Body()) { - [[maybe_unused]] auto _ = (*this)(ctx, member); - } - return {CheckDecision::CORRECT, CheckAction::SKIP_SUBTREE}; - } - return {CheckDecision::CORRECT, CheckAction::CONTINUE}; - } -}; - -class VariableHasScope { -public: - explicit VariableHasScope(ArenaAllocator &allocator) : allocator_ {allocator} {} - - [[nodiscard]] CheckResult operator()(CheckContext &ctx, const ir::AstNode *ast) - { - if (!ast->IsIdentifier()) { - // Check invariant of Identifier only - return {CheckDecision::CORRECT, CheckAction::CONTINUE}; - } - - // NOTE(kkonkuznetsov): lambdas - if (ast->AsIdentifier()->Name().Utf8().find("lambda$invoke$") == 0) { - return {CheckDecision::CORRECT, CheckAction::CONTINUE}; - } - - // we will check invariant for only local variables of identifiers - if (const auto maybeVar = GetLocalScopeVariable(allocator_, ctx, ast); maybeVar.has_value()) { - const auto var = *maybeVar; - const auto scope = var->GetScope(); - if (scope == nullptr) { - ctx.AddCheckMessage("NULL_SCOPE_LOCAL_VAR", *ast, ast->Start()); - return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; - } - - auto result = std::make_tuple(CheckDecision::CORRECT, CheckAction::CONTINUE); - if (!ScopeEncloseVariable(ctx, var)) { - result = {CheckDecision::INCORRECT, CheckAction::CONTINUE}; - } - - return result; - } - - return {CheckDecision::CORRECT, CheckAction::CONTINUE}; - } - - static std::optional GetLocalScopeVariable(ArenaAllocator &allocator, CheckContext &ctx, - const ir::AstNode *ast) - { - if (!ast->IsIdentifier()) { - return std::nullopt; - } - - auto invariantHasVariable = IdentifierHasVariable {allocator}; - const auto variable = ast->AsIdentifier()->Variable(); - const auto [decision, action] = invariantHasVariable(ctx, ast); - - if (variable == nullptr) { - // NOTE(kkonkuznetsov): variable should not be null - // but currently some identifiers do not have variables, - // see exceptions in IdentifierHasVariable check - return std::nullopt; - } - - if (decision == CheckDecision::CORRECT && variable->IsLocalVariable()) { - const auto localVar = variable->AsLocalVariable(); - if (localVar->HasFlag(varbinder::VariableFlags::LOCAL)) { - return localVar; - } - } - - return std::nullopt; - } - - bool ScopeEncloseVariable(CheckContext &ctx, const varbinder::LocalVariable *var) - { - ASSERT(var); - - const auto scope = var->GetScope(); - if (scope == nullptr || var->Declaration() == nullptr) { - return true; - } - - const auto node = var->Declaration()->Node(); - if (node == nullptr) { - return true; - } - - const auto varStart = node->Start(); - bool isOk = true; - if (scope->Bindings().count(var->Name()) == 0) { - ctx.AddCheckMessage("SCOPE_DO_NOT_ENCLOSE_LOCAL_VAR", *node, varStart); - isOk = false; - } - - const auto scopeNode = scope->Node(); - const auto varNode = node; - bool skip = CheckAstExceptions(varNode); - - if (!IsContainedIn(varNode, scopeNode) || scopeNode == nullptr) { - if (!skip) { - ctx.AddCheckMessage("SCOPE_NODE_DONT_DOMINATE_VAR_NODE", *node, varStart); - isOk = false; - } - } - - const auto &decls = scope->Decls(); - const auto declDominate = std::count(decls.begin(), decls.end(), var->Declaration()); - if (declDominate == 0) { - if (!skip) { - ctx.AddCheckMessage("SCOPE_DECL_DONT_DOMINATE_VAR_DECL", *node, varStart); - isOk = false; - } - } - - return isOk; - } - -private: - ArenaAllocator &allocator_; - - bool CheckAstExceptions(const ir::AstNode *ast) - { - // NOTE(kkonkuznetsov): in some cases with lambdas scope node is null - if (ast->Parent() != nullptr && ast->Parent()->IsETSFunctionType()) { - return true; - } - - if (ast->IsLabelledStatement()) { - // Labels are attached to loop scopes, - // however label identifier is outside of loop. - // Example: - // - // loop: for (let i = 0; i < 10; i++) { - // } - return true; - } - - // NOTE(kkonkuznetsov): lambdas - auto parent = ast->Parent(); - while (parent != nullptr) { - if (parent->IsScriptFunction()) { - auto script = parent->AsScriptFunction(); - if (script->Id() != nullptr && script->Id()->Name().Utf8().find("lambda$invoke$") == 0) { - return true; - } - - break; - } - - parent = parent->Parent(); - } - - return false; - } -}; - -class EveryChildInParentRange { -public: - explicit EveryChildInParentRange([[maybe_unused]] ArenaAllocator &allocator) {} - - [[nodiscard]] CheckResult operator()(CheckContext &ctx, const ir::AstNode *ast) - { - auto result = std::make_tuple(CheckDecision::CORRECT, CheckAction::CONTINUE); - if (ast->Parent() == nullptr) { - return result; - } - ast->Iterate([&](const ir::AstNode *node) { - if (ast != node->Parent()) { - result = {CheckDecision::INCORRECT, CheckAction::CONTINUE}; - } - if (ast->Start().line > node->Start().line || ast->End().line < node->End().line) { - result = {CheckDecision::INCORRECT, CheckAction::CONTINUE}; - } - if (ast->Start().line == node->Start().line && ast->Start().index > node->Start().index) { - result = {CheckDecision::INCORRECT, CheckAction::CONTINUE}; - } - if (ast->End().line == node->End().line && ast->End().index < node->End().index) { - result = {CheckDecision::INCORRECT, CheckAction::CONTINUE}; - } - ctx.AddCheckMessage("INCORRECT_CHILD_RANGE", *node, node->Start()); - }); - return result; - } - -private: -}; - -class EveryChildHasValidParent { -public: - explicit EveryChildHasValidParent([[maybe_unused]] ArenaAllocator &allocator) {} - - [[nodiscard]] CheckResult operator()(CheckContext &ctx, const ir::AstNode *ast) - { - auto result = std::make_tuple(CheckDecision::CORRECT, CheckAction::CONTINUE); - if (ast->IsETSScript()) { - return result; - } - - ast->Iterate([&](const ir::AstNode *node) { - if (ir::AstNode const *parent = node->Parent(); ast != parent) { - // NOTE: Temporary suppress. - // Should be removed after special lowering for lambda-functions will be implemented: #14376 - if ((ast->IsScriptFunction() || ast->IsETSFunctionType()) && parent != nullptr && - parent->IsScriptFunction()) { - return; - } - - // NOTE: Temporary suppress. - // Should be removed after new ENUMs support will be implemented: #14443 - if (ast->IsClassDeclaration() && parent != nullptr && parent->IsETSNewClassInstanceExpression()) { - return; - } - - ctx.AddCheckMessage("INCORRECT_PARENT_REF", *node, node->Start()); - result = {CheckDecision::INCORRECT, CheckAction::CONTINUE}; - } - }); - - return result; - } - -private: -}; - -class VariableHasEnclosingScope { -public: - explicit VariableHasEnclosingScope(ArenaAllocator &allocator) : allocator_ {allocator} {} - - [[nodiscard]] CheckResult operator()(CheckContext &ctx, const ir::AstNode *ast) - { - const auto maybeVar = VariableHasScope::GetLocalScopeVariable(allocator_, ctx, ast); - if (!maybeVar) { - return {CheckDecision::CORRECT, CheckAction::CONTINUE}; - } - - const auto var = *maybeVar; - const auto scope = var->GetScope(); - if (scope == nullptr) { - // already checked - return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; - } - - const auto encloseScope = scope->EnclosingVariableScope(); - if (encloseScope == nullptr) { - ctx.AddCheckMessage("NO_ENCLOSING_VAR_SCOPE", *ast, ast->Start()); - return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; - } - - const auto node = scope->Node(); - auto result = std::make_tuple(CheckDecision::CORRECT, CheckAction::CONTINUE); - if (!IsContainedIn(ast, node)) { - if (CheckCatchClause(ast, node)) { - return {CheckDecision::CORRECT, CheckAction::CONTINUE}; - } - - if (CheckScopeNodeExceptions(node)) { - return {CheckDecision::CORRECT, CheckAction::CONTINUE}; - } - - if (CheckAstExceptions(ast)) { - return {CheckDecision::CORRECT, CheckAction::CONTINUE}; - } - - result = {CheckDecision::INCORRECT, CheckAction::CONTINUE}; - ctx.AddCheckMessage("VARIABLE_NOT_ENCLOSE_SCOPE", *ast, ast->Start()); - } - - if (!IsContainedIn(scope, encloseScope)) { - result = {CheckDecision::INCORRECT, CheckAction::CONTINUE}; - ctx.AddCheckMessage("VARIABLE_NOT_ENCLOSE_SCOPE", *ast, ast->Start()); - } - - return result; - } - -private: - ArenaAllocator &allocator_; - - bool CheckCatchClause(const ir::AstNode *ast, const ir::AstNode *node) const - { - if (node == nullptr) { - return false; - } - - // Check that ast node is contained within node parent for Catch Clause: - // Catch Clause { - // Catch Body { - // AST that we need to check - // } - // Param (Scope Node) { - // } - // } - if (node->Parent() != nullptr && node->Parent()->IsCatchClause()) { - return IsContainedIn(ast, node->Parent()); - } - - return false; - } - - bool CheckScopeNodeExceptions(const ir::AstNode *node) const - { - if (node == nullptr) { - return false; - } - - // NOTE(kkonkuznetsov): lambdas - auto parent = node->Parent(); - while (parent != nullptr) { - if (parent->IsFunctionExpression()) { - auto script = parent->AsFunctionExpression()->Function(); - if (script->Id()->Name().Utf8().find("lambda$invoke$") == 0) { - return true; - } - - break; - } - - parent = parent->Parent(); - } - - return false; - } - - bool CheckAstExceptions(const ir::AstNode *ast) const - { - // NOTE(kkonkuznetsov): skip parameter expression inside arrow function expression - auto parent = ast->Parent(); - while (parent != nullptr) { - if (parent->IsETSParameterExpression()) { - return true; - } - - parent = parent->Parent(); - } - - if (ast->Parent()->IsLabelledStatement()) { - // Labels are attached to loop scopes, - // however label identifier is outside of loop. - // Example: - // - // loop: for (let i = 0; i < 10; i++) { - // } - return true; - } - - // NOTE(kkonkuznetsov): skip lambdas - parent = ast->Parent(); - while (parent != nullptr) { - if (parent->IsFunctionExpression()) { - auto script = parent->AsFunctionExpression()->Function(); - if (script->Id()->Name().Utf8().find("lambda$invoke$") == 0) { - return true; - } - - break; - } - - parent = parent->Parent(); - } - - return false; - } -}; - -class SequenceExpressionHasLastType { -public: - explicit SequenceExpressionHasLastType([[maybe_unused]] ArenaAllocator &allocator) {} - - [[nodiscard]] CheckResult operator()(CheckContext &ctx, const ir::AstNode *ast) - { - if (!ast->IsSequenceExpression()) { - return {CheckDecision::CORRECT, CheckAction::CONTINUE}; - } - const auto *expr = ast->AsSequenceExpression(); - const auto *last = expr->Sequence().back(); - if (expr->TsType() == nullptr) { - ctx.AddCheckMessage("Sequence expression type is null", *expr, expr->Start()); - return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; - } - if (last->TsType() == nullptr) { - ctx.AddCheckMessage("Sequence expression last type is null", *last, last->Start()); - return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; - } - if (expr->TsType() != last->TsType()) { - ctx.AddCheckMessage("Sequence expression type and last expression type are not the same", *expr, - expr->Start()); - return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; - } - return {CheckDecision::CORRECT, CheckAction::CONTINUE}; - } - -private: -}; - -class ForLoopCorrectlyInitialized { -public: - explicit ForLoopCorrectlyInitialized([[maybe_unused]] ArenaAllocator &allocator) {} - - [[nodiscard]] CheckResult operator()(CheckContext &ctx, const ir::AstNode *ast) - { - if (ast->IsForInStatement()) { - return HandleForInStatement(ctx, ast); - } - - if (ast->IsForOfStatement()) { - return HandleForOfStatement(ctx, ast); - } - - if (ast->IsForUpdateStatement()) { - return HandleForUpdateStatement(ctx, ast); - } - return {CheckDecision::CORRECT, CheckAction::CONTINUE}; - } - -private: - [[nodiscard]] CheckResult HandleForInStatement(CheckContext &ctx, const ir::AstNode *ast) - { - auto const *left = ast->AsForInStatement()->Left(); - if (left == nullptr) { - ctx.AddCheckMessage("NULL FOR-IN-LEFT", *ast, ast->Start()); - return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; - } - - if (!left->IsIdentifier() && !left->IsVariableDeclaration()) { - ctx.AddCheckMessage("INCORRECT FOR-IN-LEFT", *ast, ast->Start()); - return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; - } - - return {CheckDecision::CORRECT, CheckAction::CONTINUE}; - } - - [[nodiscard]] CheckResult HandleForOfStatement(CheckContext &ctx, const ir::AstNode *ast) - { - auto const *left = ast->AsForOfStatement()->Left(); - if (left == nullptr) { - ctx.AddCheckMessage("NULL FOR-OF-LEFT", *ast, ast->Start()); - return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; - } - - if (!left->IsIdentifier() && !left->IsVariableDeclaration()) { - ctx.AddCheckMessage("INCORRECT FOR-OF-LEFT", *ast, ast->Start()); - return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; - } - - return {CheckDecision::CORRECT, CheckAction::CONTINUE}; - } - - [[nodiscard]] CheckResult HandleForUpdateStatement(CheckContext &ctx, const ir::AstNode *ast) - { - // The most important part of for-loop is the test. - // But it also can be null. Then there must be break;(return) in the body. - auto const *test = ast->AsForUpdateStatement()->Test(); - if (test == nullptr) { - auto const *body = ast->AsForUpdateStatement()->Body(); - if (body == nullptr) { - ctx.AddCheckMessage("NULL FOR-TEST AND FOR-BODY", *ast, ast->Start()); - return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; - } - bool hasExit = body->IsBreakStatement() || body->IsReturnStatement(); - body->IterateRecursively( - [&hasExit](ir::AstNode *child) { hasExit |= child->IsBreakStatement() || child->IsReturnStatement(); }); - if (!hasExit) { - // an infinite loop - ctx.AddCheckMessage("NULL FOR-TEST AND FOR-BODY doesn't exit", *ast, ast->Start()); - } - return {CheckDecision::CORRECT, CheckAction::CONTINUE}; - } - - if (!test->IsExpression()) { - ctx.AddCheckMessage("NULL FOR VAR", *ast, ast->Start()); - return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; - } - - return {CheckDecision::CORRECT, CheckAction::CONTINUE}; - } -}; - -class ModifierAccessValid { -public: - explicit ModifierAccessValid([[maybe_unused]] ArenaAllocator &allocator) {} - - [[nodiscard]] CheckResult operator()(CheckContext &ctx, const ir::AstNode *ast) - { - if (auto [decision, action] = HandleMethodExpression(ctx, ast); decision == CheckDecision::INCORRECT) { - return {decision, action}; - } - if (auto [decision, action] = HandleCallExpression(ctx, ast); decision == CheckDecision::INCORRECT) { - return {decision, action}; - } - return {CheckDecision::CORRECT, CheckAction::CONTINUE}; - } - -private: - CheckResult HandleMethodExpression(CheckContext &ctx, const ir::AstNode *ast) - { - if (!ast->IsMemberExpression()) { - return {CheckDecision::CORRECT, CheckAction::CONTINUE}; - } - const auto *propVar = ast->AsMemberExpression()->PropVar(); - if (propVar != nullptr && propVar->HasFlag(varbinder::VariableFlags::PROPERTY) && - !ValidateVariableAccess(propVar, ast->AsMemberExpression())) { - ctx.AddCheckMessage("PROPERTY_NOT_VISIBLE_HERE", *ast, ast->Start()); - return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; - } - return {CheckDecision::CORRECT, CheckAction::CONTINUE}; - } - - CheckResult HandleCallExpression(CheckContext &ctx, const ir::AstNode *ast) - { - if (!ast->IsCallExpression()) { - return {CheckDecision::CORRECT, CheckAction::CONTINUE}; - } - const auto *callExpr = ast->AsCallExpression(); - const auto *callee = callExpr->Callee(); - if (callee != nullptr && callee->IsMemberExpression()) { - const auto *calleeMember = callee->AsMemberExpression(); - const auto *propVarCallee = calleeMember->PropVar(); - if (propVarCallee != nullptr && propVarCallee->HasFlag(varbinder::VariableFlags::METHOD) && - !ValidateMethodAccess(calleeMember, ast->AsCallExpression())) { - ctx.AddCheckMessage("PROPERTY_NOT_VISIBLE_HERE", *callee, callee->Start()); - return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; - } - } - return {CheckDecision::CORRECT, CheckAction::CONTINUE}; - } -}; - -class ImportExportAccessValid { -public: - explicit ImportExportAccessValid([[maybe_unused]] ArenaAllocator &allocator) {} - - [[nodiscard]] CheckResult operator()(CheckContext &ctx, const ir::AstNode *ast) - { - std::unordered_set importedVariables {}; - if (ast->IsETSImportDeclaration()) { - const auto importDecl = ast->AsETSImportDeclaration()->Specifiers(); - const auto name = [](ir::AstNode *const specifier) { - if (specifier->IsImportNamespaceSpecifier()) { - return specifier->AsImportNamespaceSpecifier()->Local()->Name(); - } - if (specifier->IsImportSpecifier()) { - return specifier->AsImportSpecifier()->Local()->Name(); - } - return specifier->AsImportDefaultSpecifier()->Local()->Name(); - }; - for (const auto import : importDecl) { - importedVariables.emplace(name(import)); - } - } - if (ast->IsCallExpression()) { - const auto *callExpr = ast->AsCallExpression(); - const auto *callee = callExpr->Callee(); - if (callee != nullptr && callee->IsIdentifier() && - !HandleImportExportIdentifier(importedVariables, callee->AsIdentifier(), callExpr)) { - ctx.AddCheckMessage("PROPERTY_NOT_VISIBLE_HERE(NOT_EXPORTED)", *callee, callee->Start()); - return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; - } - } - if (ast->IsIdentifier() && !HandleImportExportIdentifier(importedVariables, ast->AsIdentifier(), nullptr)) { - ctx.AddCheckMessage("PROPERTY_NOT_VISIBLE_HERE(NOT_EXPORTED)", *ast, ast->Start()); - return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; - } - return {CheckDecision::CORRECT, CheckAction::CONTINUE}; - } - -private: - bool ValidateExport(const varbinder::Variable *var) - { - const auto *decl = var->Declaration(); - if (decl == nullptr) { - return false; - } - const auto *node = decl->Node(); - if (node == nullptr) { - return false; - } - return node->IsExported() || node->IsExportedType(); - } - - bool InvariantImportExportMethod(const std::unordered_set &importedVariables, - const varbinder::Variable *varCallee, const ir::AstNode *callExpr, - util::StringView name) - { - auto *signature = callExpr->AsCallExpression()->Signature(); - if (signature->Owner() == nullptr) { - // NOTE(vpukhov): Add a synthetic owner for dynamic signatures - ASSERT(callExpr->AsCallExpression()->Callee()->TsType()->HasTypeFlag(checker::TypeFlag::ETS_DYNAMIC_FLAG)); - return true; - } - - if (signature != nullptr && varCallee->Declaration() != nullptr && - varCallee->Declaration()->Node() != nullptr && - !IsContainedIn(varCallee->Declaration()->Node(), signature->Owner()->GetDeclNode()) && - varCallee->Declaration()->Node() != signature->Owner()->GetDeclNode()) { - if (importedVariables.find(name.Mutf8()) != importedVariables.end() || - importedVariables.find("") != importedVariables.end()) { - return ValidateExport(varCallee); - } - return false; - } - return true; - } - - bool InvariantImportExportVariable(const std::unordered_set &importedVariables, - const varbinder::Variable *var, const ir::Identifier *ident, - util::StringView name) - { - if (!var->HasFlag(varbinder::VariableFlags::LOCAL) && !var->HasFlag(varbinder::VariableFlags::VAR) && - var->HasFlag(varbinder::VariableFlags::INITIALIZED) && var->Declaration() != nullptr && - var->Declaration()->Node() != nullptr && !var->Declaration()->Node()->IsMethodDefinition() && - !var->Declaration()->Node()->IsClassProperty()) { - auto varParent = var->Declaration()->Node()->Parent(); - if (varParent != nullptr && !IsContainedIn(ident->Parent(), varParent) && ident->Parent() != varParent) { - if (var->GetScope() != nullptr && var->GetScope()->Parent() != nullptr && - var->GetScope()->Parent()->IsGlobalScope() && - ident->GetTopStatement() == varParent->GetTopStatement()) { - return true; - } - if (importedVariables.find(name.Mutf8()) != importedVariables.end() || - importedVariables.find("") != importedVariables.end()) { - return ValidateExport(var); - } - return false; - } - } - return true; - } - - bool HandleImportExportIdentifier(std::unordered_set &importedVariables, const ir::Identifier *ident, - const ir::AstNode *callExpr) - { - if (ident->IsReference()) { - const auto *var = ident->Variable(); - if (var != nullptr) { - if (var->HasFlag(varbinder::VariableFlags::METHOD) && callExpr != nullptr) { - return InvariantImportExportMethod(importedVariables, var, callExpr, ident->Name()); - } - return InvariantImportExportVariable(importedVariables, var, ident, ident->Name()); - } - } - return true; - } -}; - -class ArithmeticOperationValid { -public: - explicit ArithmeticOperationValid([[maybe_unused]] ArenaAllocator &allocator) {} - - [[nodiscard]] CheckResult operator()([[maybe_unused]] CheckContext &ctx, const ir::AstNode *ast) - { - if (auto [decision, action] = CheckCompound(ctx, ast); action == CheckAction::SKIP_SUBTREE) { - return {decision, action}; - } - if (!ast->IsBinaryExpression() || !ast->AsBinaryExpression()->IsArithmetic()) { - return {CheckDecision::CORRECT, CheckAction::CONTINUE}; - } - if ((ast->AsBinaryExpression()->OperatorType() == lexer::TokenType::PUNCTUATOR_PLUS || - ast->AsBinaryExpression()->OperatorType() == lexer::TokenType::PUNCTUATOR_PLUS_EQUAL) && - (IsStringType(ast->AsBinaryExpression()->Left()) || IsStringType(ast->AsBinaryExpression()->Right()))) { - return {CheckDecision::CORRECT, CheckAction::CONTINUE}; - } - auto result = std::make_tuple(CheckDecision::CORRECT, CheckAction::CONTINUE); - bool isBitwise = ast->AsBinaryExpression()->IsBitwise(); - ast->Iterate([&result, &ctx, &isBitwise](ir::AstNode *child) { - if (!IsValidTypeForBinaryOp(child, isBitwise)) { - ctx.AddCheckMessage("Not a numeric type", *child, child->Start()); - result = {CheckDecision::INCORRECT, CheckAction::CONTINUE}; - } - }); - return result; - } - -private: - CheckResult CheckCompound(CheckContext &ctx, const ir::AstNode *ast) - { - if (ast->IsTSInterfaceDeclaration()) { - for (const auto &member : ast->AsTSInterfaceDeclaration()->Body()->Body()) { - [[maybe_unused]] auto _ = (*this)(ctx, member); - } - return {CheckDecision::CORRECT, CheckAction::SKIP_SUBTREE}; - } - if (ast->IsTSEnumDeclaration()) { - for (const auto &member : ast->AsTSEnumDeclaration()->Members()) { - [[maybe_unused]] auto _ = (*this)(ctx, member); - } - return {CheckDecision::CORRECT, CheckAction::SKIP_SUBTREE}; - } - if (ast->IsClassDefinition()) { - for (const auto &member : ast->AsClassDefinition()->Body()) { - [[maybe_unused]] auto _ = (*this)(ctx, member); - } - return {CheckDecision::CORRECT, CheckAction::SKIP_SUBTREE}; - } - return {CheckDecision::CORRECT, CheckAction::CONTINUE}; - } -}; - -ASTVerifier::ASTVerifier(ArenaAllocator *allocator) -{ - AddInvariant(allocator, "NodeHasParent"); - AddInvariant(allocator, "NodeHasSourceRange"); - AddInvariant(allocator, "NodeHasType"); - AddInvariant(allocator, "IdentifierHasVariable"); - AddInvariant(allocator, "VariableHasScope"); - AddInvariant(allocator, "EveryChildHasValidParent"); - AddInvariant(allocator, "EveryChildInParentRange"); - AddInvariant(allocator, "VariableHasEnclosingScope"); - AddInvariant(allocator, "ForLoopCorrectlyInitialized"); - AddInvariant(allocator, "ModifierAccessValid"); - AddInvariant(allocator, "ImportExportAccessValid"); - AddInvariant(allocator, "ArithmeticOperationValid"); - AddInvariant(allocator, "SequenceExpressionHasLastType"); - AddInvariant(allocator, "ReferenceTypeAnnotationIsNull"); - AddInvariant(allocator, "VariableNameIdentifierNameSame"); -} - -Messages ASTVerifier::VerifyFull(const ir::AstNode *ast) -{ - auto recursiveChecks = InvariantNameSet {}; - std::copy_if(invariantsNames_.begin(), invariantsNames_.end(), - std::inserter(recursiveChecks, recursiveChecks.end()), - [](const std::string &s) { return s.find(RECURSIVE_SUFFIX) != s.npos; }); - return Verify(ast, recursiveChecks); -} - -Messages ASTVerifier::Verify(const ir::AstNode *ast, const InvariantNameSet &invariantSet) -{ - CheckContext ctx {}; - const auto containsInvariants = - std::includes(invariantsNames_.begin(), invariantsNames_.end(), invariantSet.begin(), invariantSet.end()); - if (!containsInvariants) { - auto invalidInvariants = InvariantNameSet {}; - for (const auto &invariant : invariantSet) { - if (invariantsNames_.find(invariant) == invariantsNames_.end()) { - invalidInvariants.insert(invariant); - } - } - for (const auto &invariant : invalidInvariants) { - ctx.AddCheckMessage(std::string {"Invariant was not found: "} + invariant, *ast, lexer::SourcePosition {}); - } - } - - for (const auto &name : invariantSet) { - if (const auto &found = invariantsChecks_.find(name); found != invariantsChecks_.end()) { - if (ast == nullptr) { - continue; - } - - auto invariant = found->second; - ctx.SetCheckName(name.data()); - invariant(ctx, ast); - } - } - - return ctx.GetMessages(); -} - -} // namespace ark::es2panda::compiler::ast_verifier diff --git a/ets2panda/compiler/core/ETSCompiler.cpp b/ets2panda/compiler/core/ETSCompiler.cpp index 2e0e177454e25f6292c51fb59d964b5e4b137022..6b33fde02f6e39a424969d5c1c37711937b66fd0 100644 --- a/ets2panda/compiler/core/ETSCompiler.cpp +++ b/ets2panda/compiler/core/ETSCompiler.cpp @@ -799,6 +799,9 @@ bool ETSCompiler::IsSucceedCompilationProxyMemberExpr(const ir::CallExpression * ETSGen *etsg = GetETSGen(); auto *const calleeObject = expr->callee_->AsMemberExpression()->Object(); auto const *const enumInterface = [calleeType = calleeObject->TsType()]() -> checker::ETSEnumInterface const * { + if (calleeType == nullptr) { + return nullptr; + } if (calleeType->IsETSEnumType()) { return calleeType->AsETSEnumType(); } @@ -1316,7 +1319,7 @@ void ETSCompiler::Compile([[maybe_unused]] const ir::TypeofExpression *expr) con etsg->LoadAccumulatorString(expr, "number"); return; } - if (argType->IsETSStringType()) { + if (argType->IsETSStringType() || argType->IsETSStringEnumType()) { etsg->LoadAccumulatorString(expr, "string"); return; } @@ -2048,9 +2051,11 @@ void ETSCompiler::CompileCast(const ir::TSAsExpression *expr) const case checker::TypeFlag::ETS_STRING_ENUM: [[fallthrough]]; case checker::TypeFlag::ETS_ENUM: { - auto *const signature = expr->TsType()->IsETSEnumType() - ? expr->TsType()->AsETSEnumType()->FromIntMethod().globalSignature - : expr->TsType()->AsETSStringEnumType()->FromIntMethod().globalSignature; + auto *const acuType = etsg->GetAccumulatorType(); + if (acuType->IsETSEnumType() || acuType->IsETSStringEnumType()) { + break; + } + auto *const signature = expr->TsType()->AsEnumInterface()->FromIntMethod().globalSignature; ArenaVector arguments(etsg->Allocator()->Adapter()); arguments.push_back(expr->expression_); etsg->CallExact(expr, signature, arguments); diff --git a/ets2panda/compiler/core/ETSGen.cpp b/ets2panda/compiler/core/ETSGen.cpp index c5638130e200b9246fe41d03facc883e6f4a4760..0f309dff51599d91515e9c669ba441aa3809c8eb 100644 --- a/ets2panda/compiler/core/ETSGen.cpp +++ b/ets2panda/compiler/core/ETSGen.cpp @@ -825,6 +825,9 @@ void ETSGen::BranchIfIsInstance(const ir::AstNode *const node, const VReg srcReg void ETSGen::IsInstance(const ir::AstNode *const node, const VReg srcReg, const checker::Type *target) { target = Checker()->GetApparentType(target); + if (target->IsETSEnumType() || target->IsETSStringEnumType()) { + target = target->AsEnumInterface()->GetDecl()->BoxedClass()->TsType(); + } ASSERT(target->IsETSReferenceType()); if (IsAnyReferenceSupertype(target)) { // should be IsSupertypeOf(target, source) @@ -1087,13 +1090,6 @@ void ETSGen::ApplyConversion(const ir::AstNode *node, const checker::Type *targe { auto ttctx = TargetTypeContext(this, targetType); - if (node->HasAstNodeFlags(ir::AstNodeFlags::ENUM_GET_VALUE)) { - Ra().Emit( - node, node->AsExpression()->TsType()->AsETSEnumType()->GetValueMethod().globalSignature->InternalName(), - dummyReg_, 0); - node->RemoveAstNodeFlags(ir::AstNodeFlags::ENUM_GET_VALUE); - } - if ((node->GetBoxingUnboxingFlags() & ir::BoxingUnboxingFlags::BOXING_FLAG) != 0U) { ApplyBoxingConversion(node); @@ -1175,6 +1171,7 @@ void ETSGen::ApplyCastToBoxingFlags(const ir::AstNode *node, const ir::BoxingUnb void ETSGen::EmitUnboxedCall(const ir::AstNode *node, std::string_view signatureFlag, const checker::Type *const targetType, const checker::Type *const boxedType) { + RegScope rs(this); if (node->HasAstNodeFlags(ir::AstNodeFlags::CHECKCAST)) { CheckedReferenceNarrowing(node, boxedType); } @@ -1195,14 +1192,23 @@ void ETSGen::EmitUnboxedCall(const ir::AstNode *node, std::string_view signature } } -void ETSGen::EmitUnboxingConversion(const ir::AstNode *node) +void ETSGen::EmitUnboxEnum(const ir::AstNode *node) { - const auto unboxingFlag = - static_cast(ir::BoxingUnboxingFlags::UNBOXING_FLAG & node->GetBoxingUnboxingFlags()); - RegScope rs(this); + ASSERT(node->Parent()->IsTSAsExpression()); + auto *const asExprression = node->Parent()->AsTSAsExpression(); + auto *const enumType = asExprression->TsType(); + auto *const enumInterface = enumType->AsEnumInterface(); + auto assemblerType = ToAssemblerType(enumInterface->GetDecl()->BoxedClass()->TsType()); + Sa().Emit(node, assemblerType); + auto unboxMethod = enumInterface->UnboxMethod(); + Ra().Emit(node, unboxMethod.globalSignature->InternalName(), dummyReg_, 0); + SetAccumulatorType(enumType); +} - switch (unboxingFlag) { +void ETSGen::EmitUnboxingConversion(const ir::AstNode *node) +{ + switch (ir::BoxingUnboxingFlags(ir::BoxingUnboxingFlags::UNBOXING_FLAG & node->GetBoxingUnboxingFlags())) { case ir::BoxingUnboxingFlags::UNBOX_TO_BOOLEAN: { EmitUnboxedCall(node, Signatures::BUILTIN_BOOLEAN_UNBOXED, Checker()->GlobalETSBooleanType(), Checker()->GetGlobalTypesHolder()->GlobalETSBooleanBuiltinType()); @@ -1243,6 +1249,10 @@ void ETSGen::EmitUnboxingConversion(const ir::AstNode *node) Checker()->GetGlobalTypesHolder()->GlobalDoubleBuiltinType()); break; } + case ir::BoxingUnboxingFlags::UNBOX_TO_ENUM: { + EmitUnboxEnum(node); + break; + } default: UNREACHABLE(); } @@ -1283,6 +1293,13 @@ checker::Type *ETSGen::EmitBoxedType(ir::BoxingUnboxingFlags boxingFlag, const i Ra().Emit(node, Signatures::BUILTIN_DOUBLE_VALUE_OF, dummyReg_, 0); return Checker()->GetGlobalTypesHolder()->GlobalDoubleBuiltinType(); } + case ir::BoxingUnboxingFlags::BOX_TO_ENUM: { + auto *const enumInterface = node->AsExpression()->TsType()->AsEnumInterface(); + auto boxedFromIntMethod = enumInterface->BoxedFromIntMethod(); + + Ra().Emit(node, boxedFromIntMethod.globalSignature->InternalName(), dummyReg_, 0); + return enumInterface->GetDecl()->BoxedClass()->TsType(); + } default: UNREACHABLE(); break; diff --git a/ets2panda/compiler/core/ETSGen.h b/ets2panda/compiler/core/ETSGen.h index 1b7a2ab00d7104fdcb80c7474609aaf34630c956..09143b3c1b3852ab28ed0449be25ecdafe945636 100644 --- a/ets2panda/compiler/core/ETSGen.h +++ b/ets2panda/compiler/core/ETSGen.h @@ -670,6 +670,7 @@ private: void EmitUnboxedCall(const ir::AstNode *node, std::string_view signatureFlag, const checker::Type *targetType, const checker::Type *boxedType); + void EmitUnboxEnum(const ir::AstNode *node); void LoadConstantObject(const ir::Expression *node, const checker::Type *type); void StringBuilderAppend(const ir::AstNode *node, VReg builder); void AppendString(const ir::Expression *binExpr, VReg builder); diff --git a/ets2panda/compiler/core/compilerImpl.cpp b/ets2panda/compiler/core/compilerImpl.cpp index 65ee766630109033d7286ffc04b4a1e2906618a1..aadaf76642acdf06ee4ed3cb579a69993792baf1 100644 --- a/ets2panda/compiler/core/compilerImpl.cpp +++ b/ets2panda/compiler/core/compilerImpl.cpp @@ -15,7 +15,7 @@ #include "compilerImpl.h" -#include "compiler/core/ASTVerifier.h" +#include "ast_verifier/ASTVerifier.h" #include "es2panda.h" #include "checker/ETSAnalyzer.h" #include "checker/TSAnalyzer.h" @@ -187,15 +187,16 @@ static public_lib::Context::CodeGenCb MakeCompileJob() #ifndef NDEBUG -static bool RunVerifierAndPhases(ArenaAllocator &allocator, public_lib::Context &context, +static bool RunVerifierAndPhases(CompilerImpl *compilerImpl, public_lib::Context &context, const std::vector &phases, parser::Program &program) { - auto runner = ASTVerificationRunner(allocator, context); + auto runner = ASTVerificationRunner(*context.allocator, context); auto verificationCtx = ast_verifier::VerificationContext {}; const auto runAllChecks = context.config->options->CompilerOptions().verifierAllChecks; for (auto *phase : phases) { if (!phase->Apply(&context, &program)) { + compilerImpl->SetIsAnyError(context.checker->ErrorLogger()->IsAnyError()); return false; } @@ -224,6 +225,18 @@ static bool RunVerifierAndPhases(ArenaAllocator &allocator, public_lib::Context } #endif +static bool RunPhases(CompilerImpl *compilerImpl, public_lib::Context &context, const std::vector &phases, + parser::Program &program) +{ + for (auto *phase : phases) { + if (!phase->Apply(&context, &program)) { + compilerImpl->SetIsAnyError(context.checker->ErrorLogger()->IsAnyError()); + return false; + } + } + return true; +} + using EmitCb = std::function; using PhaseListGetter = std::function(ScriptExtension)>; @@ -267,21 +280,15 @@ static pandasm::Program *CreateCompiler(const CompilationUnit &unit, const Phase parser.ParseScript(unit.input, unit.options.CompilerOptions().compilationMode == CompilationMode::GEN_STD_LIB); #ifndef NDEBUG if (unit.ext == ScriptExtension::ETS) { - if (!RunVerifierAndPhases(allocator, context, getPhases(unit.ext), program)) { + if (!RunVerifierAndPhases(compilerImpl, context, getPhases(unit.ext), program)) { return nullptr; } - } else { - for (auto *phase : getPhases(unit.ext)) { - if (!phase->Apply(&context, &program)) { - return nullptr; - } - } + } else if (!RunPhases(compilerImpl, context, getPhases(unit.ext), program)) { + return nullptr; } #else - for (auto *phase : getPhases(unit.ext)) { - if (!phase->Apply(&context, &program)) { - return nullptr; - } + if (!RunPhases(compilerImpl, context, getPhases(unit.ext), program)) { + return nullptr; } #endif diff --git a/ets2panda/compiler/core/compilerImpl.h b/ets2panda/compiler/core/compilerImpl.h index 8214ab16cb635d8032e4495a147f0ce898ea5bfb..dee397332d26bb2abd8a9b3c90a8b643cd6ee2aa 100644 --- a/ets2panda/compiler/core/compilerImpl.h +++ b/ets2panda/compiler/core/compilerImpl.h @@ -72,11 +72,22 @@ public: return &queue_; } + bool IsAnyError() + { + return isAnyError_; + } + + void SetIsAnyError(bool value) + { + isAnyError_ = value; + } + private: static void HandleContextLiterals(public_lib::Context *context); CompileQueue queue_; std::vector const *plugins_; + bool isAnyError_ = false; }; } // namespace ark::es2panda::compiler diff --git a/ets2panda/compiler/lowering/ets/enumLowering.cpp b/ets2panda/compiler/lowering/ets/enumLowering.cpp index afe92fd949a087c02e3abcde442593c53e941b74..f38e491bf5ee0fea805c196cc42cebc6686f225f 100644 --- a/ets2panda/compiler/lowering/ets/enumLowering.cpp +++ b/ets2panda/compiler/lowering/ets/enumLowering.cpp @@ -54,21 +54,30 @@ namespace { return checker->AllocNode(referencePart); } -ir::MethodDefinition *MakeMethodDef(checker::ETSChecker *const checker, ir::ClassDefinition *globalClass, +ir::MethodDefinition *MakeMethodDef(checker::ETSChecker *const checker, ir::ClassDefinition *enumClass, varbinder::ETSBinder *const varbinder, ir::Identifier *const ident, ir::ScriptFunction *const function) { auto *const functionExpr = checker->AllocNode(function); auto *const identClone = ident->Clone(checker->Allocator(), nullptr); + auto *const methodDef = checker->AllocNode( - ir::MethodDefinitionKind::METHOD, identClone, functionExpr, - ir::ModifierFlags::PUBLIC | ir::ModifierFlags::STATIC, checker->Allocator(), false); - methodDef->SetParent(globalClass); - globalClass->Body().push_back(methodDef); + ir::MethodDefinitionKind::METHOD, identClone, functionExpr, function->Modifiers(), checker->Allocator(), false); + methodDef->SetParent(enumClass); + enumClass->Body().push_back(methodDef); + + auto classCtx = varbinder::LexicalScope::Enter( + varbinder, enumClass->Scope()->AsClassScope()->StaticMethodScope()); + auto *const methodVar = std::get<1>(varbinder->NewVarDecl( methodDef->Start(), checker->Allocator(), methodDef->Id()->Name(), methodDef)); - methodVar->AddFlag(varbinder::VariableFlags::STATIC | varbinder::VariableFlags::SYNTHETIC | - varbinder::VariableFlags::METHOD); + + varbinder::VariableFlags varFlags = varbinder::VariableFlags::SYNTHETIC | varbinder::VariableFlags::METHOD; + if ((function->Modifiers() & ir::ModifierFlags::STATIC) != 0) { + varFlags |= varbinder::VariableFlags::STATIC; + } + + methodVar->AddFlag(varFlags); methodDef->Function()->Id()->SetVariable(methodVar); methodDef->Id()->SetVariable(methodVar); return methodDef; @@ -76,112 +85,86 @@ ir::MethodDefinition *MakeMethodDef(checker::ETSChecker *const checker, ir::Clas } // namespace -[[nodiscard]] ir::ScriptFunction *EnumLoweringPhase::MakeFunction(varbinder::FunctionParamScope *const paramScope, - ArenaVector &¶ms, - ArenaVector &&body, - ir::TypeNode *const returnTypeAnnotation, - const ir::TSEnumDeclaration *const enumDecl) +[[nodiscard]] ir::ScriptFunction *EnumLoweringPhase::MakeFunction(FunctionInfo &&functionInfo) { auto *const functionScope = - varbinder_->Allocator()->New(checker_->Allocator(), paramScope); - functionScope->BindParamScope(paramScope); - paramScope->BindFunctionScope(functionScope); - auto *const bodyBlock = checker_->AllocNode(checker_->Allocator(), std::move(body)); - bodyBlock->SetScope(functionScope); - - auto flags = ir::ModifierFlags::PUBLIC | ir::ModifierFlags::STATIC; - - if (enumDecl->IsDeclare()) { - flags |= ir::ModifierFlags::DECLARE; + varbinder_->Allocator()->New(Allocator(), functionInfo.paramScope); + functionScope->BindParamScope(functionInfo.paramScope); + functionInfo.paramScope->BindFunctionScope(functionScope); + ir::BlockStatement *bodyBlock = nullptr; + + if (functionInfo.enumDecl->IsDeclare()) { + functionInfo.flags |= ir::ModifierFlags::DECLARE; + } else { + bodyBlock = checker_->AllocNode(Allocator(), std::move(functionInfo.body)); + bodyBlock->SetScope(functionScope); } // clang-format off auto *const function = checker_->AllocNode( - checker_->Allocator(), ir::ScriptFunction::ScriptFunctionData { - bodyBlock, ir::FunctionSignature(nullptr, std::move(params), returnTypeAnnotation), - ir::ScriptFunctionFlags::METHOD, flags, enumDecl->IsDeclare()}); + Allocator(), ir::ScriptFunction::ScriptFunctionData { + bodyBlock, + ir::FunctionSignature(nullptr, std::move(functionInfo.params), functionInfo.returnTypeAnnotation), + ir::ScriptFunctionFlags::METHOD, functionInfo.flags, functionInfo.enumDecl->IsDeclare()}); // clang-format on function->SetScope(functionScope); - varbinder_->AsETSBinder()->AddCompilableFunction(function); - paramScope->BindNode(function); + if (!function->Declare()) { + varbinder_->AsETSBinder()->AddCompilableFunction(function); + } + functionInfo.paramScope->BindNode(function); functionScope->BindNode(function); return function; } -void EnumLoweringPhase::AppendParentNames(util::UString &qualifiedName, const ir::AstNode *const node) +util::UString EnumLoweringPhase::GetEnumClassName(checker::ETSChecker *checker, + const ir::TSEnumDeclaration *const enumDecl) { - if (node != nullptr && !node->IsProgram()) { - AppendParentNames(qualifiedName, node->Parent()); - if (node->IsTSInterfaceDeclaration()) { - qualifiedName.Append(node->AsTSInterfaceDeclaration()->Id()->Name()); - } else if (node->IsClassDefinition()) { - qualifiedName.Append(node->AsClassDefinition()->Ident()->Name()); - } else { - ASSERT(node->IsClassDeclaration() || node->IsTSInterfaceBody()); - return; - } - qualifiedName.Append('#'); - } -} - -util::UString EnumLoweringPhase::GetQualifiedName(checker::ETSChecker *checker, - const ir::TSEnumDeclaration *const enumDecl, - const util::StringView &name) -{ - util::UString qualifiedName(util::StringView("#"), checker->Allocator()); - AppendParentNames(qualifiedName, enumDecl->Parent()); - qualifiedName.Append(enumDecl->Key()->Name()); - qualifiedName.Append('#'); - qualifiedName.Append(name); - return qualifiedName; -} - -[[nodiscard]] ir::Identifier *EnumLoweringPhase::MakeQualifiedIdentifier(const ir::TSEnumDeclaration *const enumDecl, - const util::StringView &name) -{ - return checker_->AllocNode(GetQualifiedName(checker_, enumDecl, name).View(), - checker_->Allocator()); + 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 *globalClass, + ir::ClassDefinition *const enumClass, const util::StringView &name, ir::TypeNode *const typeAnnotation, ElementMaker &&elementMaker) { auto fieldCtx = varbinder::LexicalScope::Enter( - varbinder_, globalClass->Scope()->AsClassScope()->StaticFieldScope()); - ArenaVector elements(checker_->Allocator()->Adapter()); + varbinder_, enumClass->Scope()->AsClassScope()->StaticFieldScope()); + ArenaVector elements(Allocator()->Adapter()); elements.reserve(enumDecl->Members().size()); for (const auto *const member : enumDecl->Members()) { elements.push_back(elementMaker(member->AsTSEnumMember())); } - auto *const arrayExpr = checker_->AllocNode(std::move(elements), checker_->Allocator()); - auto *const arrayIdent = MakeQualifiedIdentifier(enumDecl, name); + auto *const arrayExpr = checker_->AllocNode(std::move(elements), Allocator()); + auto *const arrayIdent = checker_->AllocNode(name, Allocator()); auto *const arrayClassProp = checker_->AllocNode( arrayIdent, arrayExpr, typeAnnotation, - ir::ModifierFlags::STATIC | ir::ModifierFlags::PUBLIC | ir::ModifierFlags::CONST, checker_->Allocator(), false); - arrayClassProp->SetParent(globalClass); - globalClass->Body().push_back(arrayClassProp); + ir::ModifierFlags::STATIC | ir::ModifierFlags::PROTECTED | ir::ModifierFlags::CONST, Allocator(), false); + arrayClassProp->SetParent(enumClass); + enumClass->Body().push_back(arrayClassProp); auto [array_decl, array_var] = varbinder_->NewVarDecl(arrayIdent->Start(), arrayIdent->Name(), arrayClassProp); arrayIdent->SetVariable(array_var); - array_var->AddFlag(varbinder::VariableFlags::PUBLIC | varbinder::VariableFlags::STATIC | + array_var->AddFlag(varbinder::VariableFlags::PROTECTED | varbinder::VariableFlags::STATIC | varbinder::VariableFlags::PROPERTY); - array_decl->Node()->SetParent(globalClass); + array_var->SetScope(enumClass->Scope()->AsClassScope()->StaticFieldScope()); + array_decl->Node()->SetParent(enumClass); return arrayIdent; } -ir::Identifier *EnumLoweringPhase::CreateEnumNamesArray(const ir::TSEnumDeclaration *const enumDecl) +ir::Identifier *EnumLoweringPhase::CreateEnumNamesArray(const ir::TSEnumDeclaration *const enumDecl, + ir::ClassDefinition *const enumClass) { auto *const stringTypeAnnotation = MakeTypeReference(checker_, "String"); // NOTE String -> Builtin? auto *const arrayTypeAnnotation = checker_->AllocNode(stringTypeAnnotation); // clang-format off - return MakeArray(enumDecl, program_->GlobalClass(), "NamesArray", arrayTypeAnnotation, + return MakeArray(enumDecl, enumClass, "NamesArray", arrayTypeAnnotation, [this](const ir::TSEnumMember *const member) { auto *const enumNameStringLiteral = checker_->AllocNode(member->Key()->AsIdentifier()->Name()); @@ -190,57 +173,229 @@ ir::Identifier *EnumLoweringPhase::CreateEnumNamesArray(const ir::TSEnumDeclarat // clang-format on } -void EnumLoweringPhase::CreateEnumIntClassFromEnumDeclaration(ir::TSEnumDeclaration const *const enumDecl) +ir::ClassDefinition *EnumLoweringPhase::CreateClass(ir::TSEnumDeclaration *const enumDecl) { - auto *const namesArrayIdent = CreateEnumNamesArray(enumDecl); + auto globalCtx = varbinder::LexicalScope::Enter(varbinder_, program_->GlobalScope()); + auto *ident = Allocator()->New(GetEnumClassName(checker_, enumDecl).View(), Allocator()); + auto [decl, var] = varbinder_->NewVarDecl(ident->Start(), ident->Name()); + ident->SetVariable(var); - auto *identClone = namesArrayIdent->Clone(checker_->Allocator(), nullptr); - CreateEnumGetNameMethod(enumDecl, identClone); + auto classCtx = varbinder::LexicalScope(varbinder_); + auto *classDef = checker_->AllocNode( + Allocator(), ident, + enumDecl->IsDeclare() ? ir::ClassDefinitionModifiers::DECLARATION : ir::ClassDefinitionModifiers::NONE, + enumDecl->IsDeclare() ? ir::ModifierFlags::DECLARE : ir::ModifierFlags::NONE, Language(Language::Id::ETS)); + + classDef->SetScope(classCtx.GetScope()); + auto *classDecl = checker_->AllocNode(classDef, Allocator()); + classDef->Scope()->BindNode(classDef); + decl->BindNode(classDecl); + program_->Ast()->Statements().push_back(classDecl); + classDecl->SetParent(program_->Ast()); + enumDecl->SetBoxedClass(classDef); + + CreateOrdinalField(classDef); + CreateCCtorForEnumClass(classDef); + CreateCtorForEnumClass(classDef); + + return classDef; +} - identClone = namesArrayIdent->Clone(checker_->Allocator(), nullptr); - CreateEnumValueOfMethod(enumDecl, identClone); +void EnumLoweringPhase::CreateCCtorForEnumClass(ir::ClassDefinition *const enumClass) +{ + ArenaVector params(Allocator()->Adapter()); + auto *id = checker_->AllocNode(compiler::Signatures::CCTOR, Allocator()); - auto *const valuesArrayIdent = CreateEnumValuesArray(enumDecl); + auto *const paramScope = + varbinder_->Allocator()->New(Allocator(), program_->GlobalScope()); + auto *const functionScope = varbinder_->Allocator()->New(Allocator(), paramScope); + functionScope->BindParamScope(paramScope); + paramScope->BindFunctionScope(functionScope); - identClone = valuesArrayIdent->Clone(checker_->Allocator(), nullptr); - CreateEnumGetValueMethod(enumDecl, identClone); + ArenaVector statements(Allocator()->Adapter()); + + auto *body = checker_->AllocNode(Allocator(), std::move(statements)); + auto *func = checker_->AllocNode( + Allocator(), + ir::ScriptFunction::ScriptFunctionData {body, ir::FunctionSignature(nullptr, std::move(params), nullptr), + ir::ScriptFunctionFlags::STATIC_BLOCK | ir::ScriptFunctionFlags::HIDDEN, + ir::ModifierFlags::STATIC, false, Language(Language::Id::ETS)}); + + func->SetIdent(id); + id->SetParent(func); + body->SetScope(functionScope); + func->SetScope(functionScope); + auto *funcExpr = checker_->AllocNode(func); + + varbinder_->AsETSBinder()->AddCompilableFunction(func); + functionScope->BindNode(func); + paramScope->BindNode(func); + + auto *const identClone = id->Clone(Allocator(), nullptr); + auto *const methodDef = checker_->AllocNode( + ir::MethodDefinitionKind::METHOD, identClone, funcExpr, ir::ModifierFlags::PUBLIC | ir::ModifierFlags::STATIC, + Allocator(), false); + methodDef->SetParent(enumClass); + enumClass->Body().push_back(methodDef); + + auto classCtx = varbinder::LexicalScope::Enter( + varbinder_, enumClass->Scope()->AsClassScope()->StaticMethodScope()); + auto *const methodVar = std::get<1>(varbinder_->NewVarDecl( + methodDef->Start(), Allocator(), methodDef->Id()->Name(), methodDef)); + methodVar->AddFlag(varbinder::VariableFlags::STATIC | varbinder::VariableFlags::SYNTHETIC | + varbinder::VariableFlags::METHOD); + methodDef->Function()->Id()->SetVariable(methodVar); + methodDef->Id()->SetVariable(methodVar); +} - auto *const stringValuesArrayIdent = CreateEnumStringValuesArray(enumDecl); +ir::ClassProperty *EnumLoweringPhase::CreateOrdinalField(ir::ClassDefinition *const enumClass) +{ + auto fieldCtx = varbinder::LexicalScope::Enter( + varbinder_, enumClass->Scope()->AsClassScope()->InstanceFieldScope()); + + auto *const fieldIdent = Allocator()->New("ordinal", Allocator()); + auto *const intTypeAnnotation = Allocator()->New(ir::PrimitiveType::INT); + auto *field = checker_->AllocNode(fieldIdent, nullptr, intTypeAnnotation, + ir::ModifierFlags::PROTECTED, Allocator(), false); + + auto [decl, var] = varbinder_->NewVarDecl(lexer::SourcePosition(), fieldIdent->Name()); + var->SetScope(enumClass->Scope()->AsClassScope()->InstanceFieldScope()); + var->AddFlag(varbinder::VariableFlags::PROPERTY | varbinder::VariableFlags::PROTECTED); + fieldIdent->SetVariable(var); + decl->BindNode(field); + + enumClass->Body().push_back(field); + field->SetParent(enumClass); + return field; +} - identClone = stringValuesArrayIdent->Clone(checker_->Allocator(), nullptr); - CreateEnumToStringMethod(enumDecl, identClone); +void EnumLoweringPhase::CreateCtorForEnumClass(ir::ClassDefinition *const enumClass) +{ + auto *const paramScope = + varbinder_->Allocator()->New(Allocator(), program_->GlobalScope()); - auto *const itemsArrayIdent = CreateEnumItemsArray(enumDecl); + ArenaVector params(Allocator()->Adapter()); - identClone = itemsArrayIdent->Clone(checker_->Allocator(), nullptr); - CreateEnumValuesMethod(enumDecl, identClone); + auto *const intTypeAnnotation = checker_->AllocNode(ir::PrimitiveType::INT); + auto *const inputOrdinalParam = MakeFunctionParam(checker_, varbinder_, paramScope, "ordinal", intTypeAnnotation); + params.push_back(inputOrdinalParam); - identClone = itemsArrayIdent->Clone(checker_->Allocator(), nullptr); - CreateEnumFromIntMethod(enumDecl, identClone); + auto *id = checker_->AllocNode("constructor", Allocator()); + auto *const functionScope = varbinder_->Allocator()->New(Allocator(), paramScope); + functionScope->BindParamScope(paramScope); + paramScope->BindFunctionScope(functionScope); + ArenaVector statements(Allocator()->Adapter()); + + auto *body = checker_->AllocNode(Allocator(), std::move(statements)); + auto *func = checker_->AllocNode( + Allocator(), + ir::ScriptFunction::ScriptFunctionData {body, ir::FunctionSignature(nullptr, std::move(params), nullptr), + ir::ScriptFunctionFlags::CONSTRUCTOR, ir::ModifierFlags::CONSTRUCTOR, + false, Language(Language::Id::ETS)}); + + func->SetIdent(id); + body->SetScope(functionScope); + func->SetScope(functionScope); + auto *funcExpr = checker_->AllocNode(func); + + varbinder_->AsETSBinder()->AddCompilableFunction(func); + functionScope->BindNode(func); + paramScope->BindNode(func); + + auto *thisExpr = Allocator()->New(); + auto *fieldIdentifier = Allocator()->New("ordinal", Allocator()); + fieldIdentifier->SetReference(); + auto *leftHandSide = checker_->AllocNode( + thisExpr, fieldIdentifier, ir::MemberExpressionKind::PROPERTY_ACCESS, false, false); + auto *rightHandSide = checker_->AllocNode("ordinal", Allocator()); + rightHandSide->SetVariable(inputOrdinalParam->Ident()->Variable()); + auto *initializer = checker_->AllocNode(leftHandSide, rightHandSide, + lexer::TokenType::PUNCTUATOR_SUBSTITUTION); + auto initStatement = checker_->AllocNode(initializer); + initStatement->SetParent(body); + body->Statements().push_back(initStatement); + + auto *const identClone = id->Clone(Allocator(), nullptr); + auto *const methodDef = checker_->AllocNode( + ir::MethodDefinitionKind::CONSTRUCTOR, identClone, funcExpr, ir::ModifierFlags::PUBLIC, Allocator(), false); + methodDef->SetParent(enumClass); + enumClass->Body().push_back(methodDef); + + auto classCtx = varbinder::LexicalScope::Enter( + varbinder_, enumClass->Scope()->AsClassScope()->StaticMethodScope()); + auto *const methodVar = std::get<1>(varbinder_->NewVarDecl( + methodDef->Start(), Allocator(), methodDef->Id()->Name(), methodDef)); + methodVar->AddFlag(varbinder::VariableFlags::SYNTHETIC | varbinder::VariableFlags::METHOD); + methodDef->Function()->Id()->SetVariable(methodVar); + methodDef->Id()->SetVariable(methodVar); } -void EnumLoweringPhase::CreateEnumStringClassFromEnumDeclaration(ir::TSEnumDeclaration const *const enumDecl) +void EnumLoweringPhase::CreateEnumIntClassFromEnumDeclaration(ir::TSEnumDeclaration *const enumDecl) { - auto *const namesArrayIdent = CreateEnumNamesArray(enumDecl); + auto *const enumClass = CreateClass(enumDecl); + 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); + + auto *identClone = namesArrayIdent->Clone(Allocator(), nullptr); + CreateEnumGetNameMethod(enumDecl, enumClass, identClone); - auto *identClone = namesArrayIdent->Clone(checker_->Allocator(), nullptr); - CreateEnumGetNameMethod(enumDecl, identClone); + identClone = namesArrayIdent->Clone(Allocator(), nullptr); + CreateEnumValueOfMethod(enumDecl, enumClass, identClone); - identClone = namesArrayIdent->Clone(checker_->Allocator(), nullptr); - CreateEnumValueOfMethod(enumDecl, identClone); + identClone = valuesArrayIdent->Clone(Allocator(), nullptr); + CreateEnumGetValueMethod(enumDecl, enumClass, identClone); - auto *const stringValuesArrayIdent = CreateEnumStringValuesArray(enumDecl); + identClone = stringValuesArrayIdent->Clone(Allocator(), nullptr); + CreateEnumToStringMethod(enumDecl, enumClass, identClone); - identClone = stringValuesArrayIdent->Clone(checker_->Allocator(), nullptr); - CreateEnumToStringMethod(enumDecl, identClone); + identClone = itemsArrayIdent->Clone(Allocator(), nullptr); + CreateEnumValuesMethod(enumDecl, enumClass, identClone); - auto *const itemsArrayIdent = CreateEnumItemsArray(enumDecl); + identClone = itemsArrayIdent->Clone(Allocator(), nullptr); + CreateEnumFromIntMethod(enumDecl, enumClass, identClone, checker::ETSEnumInterface::FROM_INT_METHOD_NAME, + enumDecl->Key()->Name()); - identClone = itemsArrayIdent->Clone(checker_->Allocator(), nullptr); - CreateEnumValuesMethod(enumDecl, identClone); + identClone = itemsArrayIdent->Clone(Allocator(), nullptr); + CreateUnboxingMethod(enumDecl, enumClass, identClone); - identClone = itemsArrayIdent->Clone(checker_->Allocator(), nullptr); - CreateEnumFromIntMethod(enumDecl, identClone); + identClone = boxedItemsArrayIdent->Clone(Allocator(), nullptr); + CreateEnumFromIntMethod(enumDecl, enumClass, identClone, checker::ETSEnumInterface::BOXED_FROM_INT_METHOD_NAME, + GetEnumClassName(checker_, enumDecl).View()); +} + +void EnumLoweringPhase::CreateEnumStringClassFromEnumDeclaration(ir::TSEnumDeclaration *const enumDecl) +{ + auto *const enumClass = CreateClass(enumDecl); + auto *const namesArrayIdent = CreateEnumNamesArray(enumDecl, enumClass); + auto *const stringValuesArrayIdent = CreateEnumStringValuesArray(enumDecl, enumClass); + auto *const itemsArrayIdent = CreateEnumItemsArray(enumDecl, enumClass); + auto *const boxedItemsArrayIdent = CreateBoxedEnumItemsArray(enumDecl, enumClass); + + auto *identClone = namesArrayIdent->Clone(Allocator(), nullptr); + CreateEnumGetNameMethod(enumDecl, enumClass, identClone); + + identClone = namesArrayIdent->Clone(Allocator(), nullptr); + CreateEnumValueOfMethod(enumDecl, enumClass, identClone); + + identClone = stringValuesArrayIdent->Clone(Allocator(), nullptr); + CreateEnumToStringMethod(enumDecl, enumClass, identClone); + + identClone = itemsArrayIdent->Clone(Allocator(), nullptr); + CreateEnumValuesMethod(enumDecl, enumClass, identClone); + + identClone = itemsArrayIdent->Clone(Allocator(), nullptr); + CreateEnumFromIntMethod(enumDecl, enumClass, identClone, checker::ETSEnumInterface::FROM_INT_METHOD_NAME, + enumDecl->Key()->Name()); + + identClone = itemsArrayIdent->Clone(Allocator(), nullptr); + CreateUnboxingMethod(enumDecl, enumClass, identClone); + + identClone = boxedItemsArrayIdent->Clone(Allocator(), nullptr); + CreateEnumFromIntMethod(enumDecl, enumClass, identClone, checker::ETSEnumInterface::BOXED_FROM_INT_METHOD_NAME, + GetEnumClassName(checker_, enumDecl).View()); } bool EnumLoweringPhase::Perform(public_lib::Context *ctx, parser::Program *program) @@ -276,12 +431,13 @@ bool EnumLoweringPhase::Perform(public_lib::Context *ctx, parser::Program *progr return true; } -ir::Identifier *EnumLoweringPhase::CreateEnumValuesArray(const ir::TSEnumDeclaration *const enumDecl) +ir::Identifier *EnumLoweringPhase::CreateEnumValuesArray(const ir::TSEnumDeclaration *const enumDecl, + ir::ClassDefinition *const enumClass) { auto *const intType = checker_->AllocNode(ir::PrimitiveType::INT); auto *const arrayTypeAnnotation = checker_->AllocNode(intType); // clang-format off - return MakeArray(enumDecl, program_->GlobalClass(), "ValuesArray", arrayTypeAnnotation, + return MakeArray(enumDecl, enumClass, "ValuesArray", arrayTypeAnnotation, [this](const ir::TSEnumMember *const member) { auto *const enumValueLiteral = checker_->AllocNode( lexer::Number(member->AsTSEnumMember() @@ -294,13 +450,14 @@ ir::Identifier *EnumLoweringPhase::CreateEnumValuesArray(const ir::TSEnumDeclara // clang-format on } -ir::Identifier *EnumLoweringPhase::CreateEnumStringValuesArray(const ir::TSEnumDeclaration *const enumDecl) +ir::Identifier *EnumLoweringPhase::CreateEnumStringValuesArray(const ir::TSEnumDeclaration *const enumDecl, + ir::ClassDefinition *const enumClass) { auto *const stringTypeAnnotation = MakeTypeReference(checker_, "String"); // NOTE String -> Builtin? auto *const arrayTypeAnnotation = checker_->AllocNode(stringTypeAnnotation); // clang-format off - return MakeArray(enumDecl, program_->GlobalClass(), "StringValuesArray", arrayTypeAnnotation, + return MakeArray(enumDecl, enumClass, "StringValuesArray", arrayTypeAnnotation, [this](const ir::TSEnumMember *const member) { auto *const init = member->AsTSEnumMember()->Init(); util::StringView stringValue; @@ -310,7 +467,7 @@ ir::Identifier *EnumLoweringPhase::CreateEnumStringValuesArray(const ir::TSEnumD } else { auto str = std::to_string( init->AsNumberLiteral()->Number().GetValue()); - stringValue = util::UString(str, checker_->Allocator()).View(); + stringValue = util::UString(str, Allocator()).View(); } auto *const enumValueStringLiteral = checker_->AllocNode(stringValue); @@ -319,19 +476,20 @@ ir::Identifier *EnumLoweringPhase::CreateEnumStringValuesArray(const ir::TSEnumD // clang-format on } -ir::Identifier *EnumLoweringPhase::CreateEnumItemsArray(const ir::TSEnumDeclaration *const enumDecl) +ir::Identifier *EnumLoweringPhase::CreateEnumItemsArray(const ir::TSEnumDeclaration *const enumDecl, + ir::ClassDefinition *const enumClass) { auto *const enumTypeAnnotation = MakeTypeReference(checker_, enumDecl->Key()->Name()); auto *const arrayTypeAnnotation = checker_->AllocNode(enumTypeAnnotation); // clang-format off - return MakeArray(enumDecl, program_->GlobalClass(), "ItemsArray", arrayTypeAnnotation, + return MakeArray(enumDecl, enumClass, "ItemsArray", arrayTypeAnnotation, [this, enumDecl](const ir::TSEnumMember *const member) { auto *const enumTypeIdent = - checker_->AllocNode(enumDecl->Key()->Name(), checker_->Allocator()); + checker_->AllocNode(enumDecl->Key()->Name(), Allocator()); enumTypeIdent->SetReference(); auto *const enumMemberIdent = checker_->AllocNode( - member->AsTSEnumMember()->Key()->AsIdentifier()->Name(), checker_->Allocator()); + member->AsTSEnumMember()->Key()->AsIdentifier()->Name(), Allocator()); enumMemberIdent->SetReference(); auto *const enumMemberExpr = checker_->AllocNode( enumTypeIdent, enumMemberIdent, ir::MemberExpressionKind::PROPERTY_ACCESS, false, false); @@ -340,6 +498,40 @@ ir::Identifier *EnumLoweringPhase::CreateEnumItemsArray(const ir::TSEnumDeclarat // clang-format on } +ir::Identifier *EnumLoweringPhase::CreateBoxedEnumItemsArray(const ir::TSEnumDeclaration *const enumDecl, + ir::ClassDefinition *const enumClass) +{ + auto boxedClassName = GetEnumClassName(checker_, enumDecl).View(); + auto *const enumTypeAnnotation = MakeTypeReference(checker_, boxedClassName); + auto *const arrayTypeAnnotation = checker_->AllocNode(enumTypeAnnotation); + // 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->SetReference(); + + auto *const enumMemberIdent = checker_->AllocNode( + member->AsTSEnumMember()->Key()->AsIdentifier()->Name(), Allocator()); + enumMemberIdent->SetReference(); + auto *const enumMemberExpr = checker_->AllocNode( + enumTypeIdent, enumMemberIdent, ir::MemberExpressionKind::PROPERTY_ACCESS, false, false); + + auto intType = checker_->AllocNode(ir::PrimitiveType::INT); + 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), nullptr); + return newExpression; + }); + // clang-format on +} + namespace { ir::BinaryExpression *CreateIfTest(EnumLoweringPhase *const elp, ir::Identifier *const itemsArrayIdentifier, @@ -364,8 +556,6 @@ ir::ReturnStatement *CreateReturnEnumStatement(EnumLoweringPhase *const elp, ir: auto itemsArrayIdentClone = itemsArrayIdentifier->Clone(checker->Allocator(), nullptr); auto *const arrayAccessExpr = checker->AllocNode( itemsArrayIdentClone, paramRefIdent, ir::MemberExpressionKind::ELEMENT_ACCESS, true, false); - paramRefIdent->SetParent(arrayAccessExpr); - auto *const returnStatement = checker->AllocNode(arrayAccessExpr); return returnStatement; } @@ -408,117 +598,130 @@ ir::ReturnStatement *CreateReturnWitAsStatement(EnumLoweringPhase *const elp, ir } // namespace void EnumLoweringPhase::CreateEnumFromIntMethod(const ir::TSEnumDeclaration *const enumDecl, - ir::Identifier *const itemsArrayIdent) + ir::ClassDefinition *const enumClass, ir::Identifier *const arrayIdent, + const util::StringView &methodName, + const util::StringView &returnTypeName) { auto *const paramScope = - varbinder_->Allocator()->New(checker_->Allocator(), program_->GlobalScope()); + varbinder_->Allocator()->New(Allocator(), enumClass->Scope()); auto *const intTypeAnnotation = checker_->AllocNode(ir::PrimitiveType::INT); auto *const inputOrdinalParameter = MakeFunctionParam(checker_, varbinder_, paramScope, "ordinal", intTypeAnnotation); - auto *const inArraySizeExpr = CreateIfTest(this, itemsArrayIdent, inputOrdinalParameter); - auto *const returnEnumStmt = CreateReturnEnumStatement(this, itemsArrayIdent, inputOrdinalParameter); + auto *const inArraySizeExpr = CreateIfTest(this, arrayIdent, inputOrdinalParameter); + auto *const returnEnumStmt = CreateReturnEnumStatement(this, arrayIdent, inputOrdinalParameter); auto *const ifOrdinalExistsStmt = checker_->AllocNode(inArraySizeExpr, returnEnumStmt, nullptr); - util::UString messageString(util::StringView("No enum constant in "), checker_->Allocator()); + util::UString messageString(util::StringView("No enum constant in "), Allocator()); messageString.Append(enumDecl->Key()->Name()); messageString.Append(" with ordinal value "); auto *const throwNoEnumStmt = CreateThrowStatement(this, inputOrdinalParameter, messageString); - ArenaVector params(checker_->Allocator()->Adapter()); + ArenaVector params(Allocator()->Adapter()); params.push_back(inputOrdinalParameter); - ArenaVector body(checker_->Allocator()->Adapter()); + ArenaVector body(Allocator()->Adapter()); body.push_back(ifOrdinalExistsStmt); body.push_back(throwNoEnumStmt); - auto *const enumTypeAnnotation = MakeTypeReference(checker_, enumDecl->Key()->Name()); + auto *const returnTypeAnnotation = MakeTypeReference(checker_, returnTypeName); - auto *const function = MakeFunction(paramScope, std::move(params), std::move(body), enumTypeAnnotation, enumDecl); + auto *const function = MakeFunction({paramScope, std::move(params), std::move(body), returnTypeAnnotation, enumDecl, + ir::ModifierFlags::PUBLIC | ir::ModifierFlags::STATIC}); function->AddFlag(ir::ScriptFunctionFlags::THROWS); - auto *const ident = MakeQualifiedIdentifier(enumDecl, checker::ETSEnumType::FROM_INT_METHOD_NAME); + auto *const ident = checker_->AllocNode(methodName, Allocator()); + function->SetIdent(ident); function->Scope()->BindInternalName(ident->Name()); - MakeMethodDef(checker_, program_->GlobalClass(), varbinder_, ident, function); + MakeMethodDef(checker_, enumClass, varbinder_, ident, function); ident->SetReference(); } void EnumLoweringPhase::CreateEnumToStringMethod(const ir::TSEnumDeclaration *const enumDecl, + ir::ClassDefinition *const enumClass, ir::Identifier *const stringValuesArrayIdent) { - auto *const paramScope = varbinder_->Allocator()->New(checker_->Allocator(), - program_->GlobalClassScope()); + auto *const paramScope = + varbinder_->Allocator()->New(Allocator(), enumClass->Scope()); auto *const enumTypeAnnotation = MakeTypeReference(checker_, enumDecl->Key()->Name()); auto *const inputEnumIdent = MakeFunctionParam(checker_, varbinder_, paramScope, "ordinal", enumTypeAnnotation); auto *const returnStmt = CreateReturnWitAsStatement(this, stringValuesArrayIdent, inputEnumIdent); - ArenaVector body(checker_->Allocator()->Adapter()); + ArenaVector body(Allocator()->Adapter()); body.push_back(returnStmt); - ArenaVector params(checker_->Allocator()->Adapter()); + ArenaVector params(Allocator()->Adapter()); params.push_back(inputEnumIdent); auto *const stringTypeAnnotation = MakeTypeReference(checker_, "String"); // NOTE String -> Builtin? - auto *const function = MakeFunction(paramScope, std::move(params), std::move(body), stringTypeAnnotation, enumDecl); + auto *const function = MakeFunction({paramScope, std::move(params), std::move(body), stringTypeAnnotation, enumDecl, + ir::ModifierFlags::PUBLIC | ir::ModifierFlags::STATIC}); + + auto *const functionIdent = + checker_->AllocNode(checker::ETSEnumInterface::TO_STRING_METHOD_NAME, Allocator()); - auto *const functionIdent = MakeQualifiedIdentifier(enumDecl, checker::ETSEnumType::TO_STRING_METHOD_NAME); function->SetIdent(functionIdent); function->Scope()->BindInternalName(functionIdent->Name()); - MakeMethodDef(checker_, program_->GlobalClass(), varbinder_, functionIdent, function); + MakeMethodDef(checker_, enumClass, varbinder_, functionIdent, function); functionIdent->SetReference(); } void EnumLoweringPhase::CreateEnumGetValueMethod(const ir::TSEnumDeclaration *const enumDecl, + ir::ClassDefinition *const enumClass, ir::Identifier *const valuesArrayIdent) { - auto *const paramScope = varbinder_->Allocator()->New(checker_->Allocator(), - program_->GlobalClassScope()); + auto *const paramScope = + varbinder_->Allocator()->New(Allocator(), enumClass->Scope()); auto *const enumTypeAnnotation = MakeTypeReference(checker_, enumDecl->Key()->Name()); auto *const inputEnumIdent = MakeFunctionParam(checker_, varbinder_, paramScope, "e", enumTypeAnnotation); auto *const returnStmt = CreateReturnWitAsStatement(this, valuesArrayIdent, inputEnumIdent); - ArenaVector body(checker_->Allocator()->Adapter()); + ArenaVector body(Allocator()->Adapter()); body.push_back(returnStmt); - ArenaVector params(checker_->Allocator()->Adapter()); + ArenaVector params(Allocator()->Adapter()); params.push_back(inputEnumIdent); auto *const intTypeAnnotation = checker_->AllocNode(ir::PrimitiveType::INT); - auto *const function = MakeFunction(paramScope, std::move(params), std::move(body), intTypeAnnotation, enumDecl); - - auto *const functionIdent = MakeQualifiedIdentifier(enumDecl, checker::ETSEnumType::GET_VALUE_METHOD_NAME); + auto *const function = MakeFunction({paramScope, std::move(params), std::move(body), intTypeAnnotation, enumDecl, + ir::ModifierFlags::PUBLIC | ir::ModifierFlags::STATIC}); + auto *const functionIdent = + checker_->AllocNode(checker::ETSEnumInterface::GET_VALUE_METHOD_NAME, Allocator()); function->SetIdent(functionIdent); function->Scope()->BindInternalName(functionIdent->Name()); - MakeMethodDef(checker_, program_->GlobalClass(), varbinder_, functionIdent, function); + MakeMethodDef(checker_, enumClass, varbinder_, functionIdent, function); functionIdent->SetReference(); } void EnumLoweringPhase::CreateEnumGetNameMethod(const ir::TSEnumDeclaration *const enumDecl, + ir::ClassDefinition *const enumClass, ir::Identifier *const namesArrayIdent) { auto *const paramScope = - varbinder_->Allocator()->New(checker_->Allocator(), program_->GlobalScope()); + varbinder_->Allocator()->New(Allocator(), enumClass->Scope()); auto *const enumTypeAnnotation = MakeTypeReference(checker_, enumDecl->Key()->Name()); auto *const inputEnumIdent = MakeFunctionParam(checker_, varbinder_, paramScope, "ordinal", enumTypeAnnotation); auto *const returnStmt = CreateReturnWitAsStatement(this, namesArrayIdent, inputEnumIdent); - ArenaVector body(checker_->Allocator()->Adapter()); + ArenaVector body(Allocator()->Adapter()); body.push_back(returnStmt); - ArenaVector params(checker_->Allocator()->Adapter()); + ArenaVector params(Allocator()->Adapter()); params.push_back(inputEnumIdent); auto *const stringTypeAnnotation = MakeTypeReference(checker_, "String"); // NOTE String -> Builtin? - auto *const function = MakeFunction(paramScope, std::move(params), std::move(body), stringTypeAnnotation, enumDecl); + auto *const function = MakeFunction({paramScope, std::move(params), std::move(body), stringTypeAnnotation, enumDecl, + ir::ModifierFlags::PUBLIC | ir::ModifierFlags::STATIC}); + auto *const functionIdent = + checker_->AllocNode(checker::ETSEnumInterface::GET_NAME_METHOD_NAME, Allocator()); - auto *const functionIdent = MakeQualifiedIdentifier(enumDecl, checker::ETSEnumType::GET_NAME_METHOD_NAME); function->SetIdent(functionIdent); function->Scope()->BindInternalName(functionIdent->Name()); - MakeMethodDef(checker_, program_->GlobalClass(), varbinder_, functionIdent, function); + MakeMethodDef(checker_, enumClass, varbinder_, functionIdent, function); functionIdent->SetReference(); } @@ -599,10 +802,11 @@ ir::IfStatement *CreateIf(EnumLoweringPhase *const elp, const ir::TSEnumDeclarat } // namespace void EnumLoweringPhase::CreateEnumValueOfMethod(const ir::TSEnumDeclaration *const enumDecl, + ir::ClassDefinition *const enumClass, ir::Identifier *const namesArrayIdent) { auto *const paramScope = - varbinder_->Allocator()->New(checker_->Allocator(), program_->GlobalScope()); + varbinder_->Allocator()->New(Allocator(), enumClass->Scope()); varbinder::LexicalScope loopDeclScope(varbinder_); @@ -622,50 +826,100 @@ void EnumLoweringPhase::CreateEnumValueOfMethod(const ir::TSEnumDeclaration *con forLoop->SetScope(loopScope.GetScope()); loopScope.GetScope()->DeclScope()->BindNode(forLoop); - util::UString messageString(util::StringView("No enum constant "), checker_->Allocator()); + util::UString messageString(util::StringView("No enum constant "), Allocator()); messageString.Append(enumDecl->Key()->Name()); messageString.Append('.'); auto *const throwStmt = CreateThrowStatement(this, inputNameIdent, messageString); - ArenaVector body(checker_->Allocator()->Adapter()); + ArenaVector body(Allocator()->Adapter()); body.push_back(forLoop); body.push_back(throwStmt); - ArenaVector params(checker_->Allocator()->Adapter()); + ArenaVector params(Allocator()->Adapter()); params.push_back(inputNameIdent); auto *const enumTypeAnnotation = MakeTypeReference(checker_, enumDecl->Key()->Name()); - auto *const function = MakeFunction(paramScope, std::move(params), std::move(body), enumTypeAnnotation, enumDecl); + auto *const function = MakeFunction({paramScope, std::move(params), std::move(body), enumTypeAnnotation, enumDecl, + ir::ModifierFlags::PUBLIC | ir::ModifierFlags::STATIC}); function->AddFlag(ir::ScriptFunctionFlags::THROWS); - auto *const functionIdent = MakeQualifiedIdentifier(enumDecl, checker::ETSEnumType::VALUE_OF_METHOD_NAME); + auto *const functionIdent = + checker_->AllocNode(checker::ETSEnumInterface::VALUE_OF_METHOD_NAME, Allocator()); + function->SetIdent(functionIdent); function->Scope()->BindInternalName(functionIdent->Name()); - MakeMethodDef(checker_, program_->GlobalClass(), varbinder_, functionIdent, function); + MakeMethodDef(checker_, enumClass, varbinder_, functionIdent, function); functionIdent->SetReference(); } void EnumLoweringPhase::CreateEnumValuesMethod(const ir::TSEnumDeclaration *const enumDecl, + ir::ClassDefinition *const enumClass, ir::Identifier *const itemsArrayIdent) { auto *const paramScope = - varbinder_->Allocator()->New(checker_->Allocator(), program_->GlobalScope()); + varbinder_->Allocator()->New(Allocator(), enumClass->Scope()); auto *const returnStmt = checker_->AllocNode(itemsArrayIdent); - ArenaVector body(checker_->Allocator()->Adapter()); + ArenaVector body(Allocator()->Adapter()); body.push_back(returnStmt); - ArenaVector params(checker_->Allocator()->Adapter()); + ArenaVector params(Allocator()->Adapter()); auto *const enumArrayTypeAnnotation = checker_->AllocNode(MakeTypeReference(checker_, enumDecl->Key()->Name())); - auto *const function = - MakeFunction(paramScope, std::move(params), std::move(body), enumArrayTypeAnnotation, enumDecl); - auto *const functionIdent = MakeQualifiedIdentifier(enumDecl, checker::ETSEnumType::VALUES_METHOD_NAME); + auto *const function = MakeFunction({paramScope, std::move(params), std::move(body), enumArrayTypeAnnotation, + enumDecl, ir::ModifierFlags::PUBLIC | ir::ModifierFlags::STATIC}); + auto *const functionIdent = + checker_->AllocNode(checker::ETSEnumInterface::VALUES_METHOD_NAME, Allocator()); + function->SetIdent(functionIdent); + function->Scope()->BindInternalName(functionIdent->Name()); + + MakeMethodDef(checker_, enumClass, varbinder_, functionIdent, function); + functionIdent->SetReference(); +} + +void EnumLoweringPhase::CreateUnboxingMethod(ir::TSEnumDeclaration const *const enumDecl, + ir::ClassDefinition *const enumClass, + ir::Identifier *const itemsArrayIdent) + +{ + auto *const paramScope = + varbinder_->Allocator()->New(Allocator(), enumClass->Scope()); + + ArenaVector body(Allocator()->Adapter()); + + auto *thisExpr = Allocator()->New(); + auto *fieldIdentifier = Allocator()->New("ordinal", Allocator()); + fieldIdentifier->SetReference(); + auto *arrayIndexExpr = checker_->AllocNode( + thisExpr, fieldIdentifier, ir::MemberExpressionKind::PROPERTY_ACCESS, false, false); + + auto itemsArrayIdentClone = itemsArrayIdent->Clone(checker_->Allocator(), nullptr); + auto *const arrayAccessExpr = checker_->AllocNode( + itemsArrayIdentClone, 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 function = MakeFunction( + {paramScope, std::move(params), std::move(body), returnTypeAnnotation, enumDecl, ir::ModifierFlags::PUBLIC}); + + varbinder_->AddFunctionThisParam(function); + auto *const functionIdent = + checker_->AllocNode(checker::ETSEnumInterface::UNBOX_METHOD_NAME, Allocator()); function->SetIdent(functionIdent); function->Scope()->BindInternalName(functionIdent->Name()); - MakeMethodDef(checker_, program_->GlobalClass(), varbinder_, functionIdent, function); + MakeMethodDef(checker_, enumClass, varbinder_, functionIdent, function); functionIdent->SetReference(); } +ArenaAllocator *EnumLoweringPhase::Allocator() +{ + return checker_->Allocator(); +} + } // namespace ark::es2panda::compiler \ No newline at end of file diff --git a/ets2panda/compiler/lowering/ets/enumLowering.h b/ets2panda/compiler/lowering/ets/enumLowering.h index 42965553c4b498a15da11d34f1c7da75c310d37d..b3fc60c9dbd62608d16fa8a330e1b2536f4980c4 100644 --- a/ets2panda/compiler/lowering/ets/enumLowering.h +++ b/ets2panda/compiler/lowering/ets/enumLowering.h @@ -29,9 +29,7 @@ public: return "EnumLoweringPhase"; } bool Perform(public_lib::Context *ctx, parser::Program *program) override; - static util::UString GetQualifiedName(checker::ETSChecker *checker, const ir::TSEnumDeclaration *const enumDecl, - const util::StringView &name); - + static util::UString GetEnumClassName(checker::ETSChecker *checker, const ir::TSEnumDeclaration *const enumDecl); checker::ETSChecker *Checker() { return checker_; @@ -43,37 +41,54 @@ public: } private: - [[nodiscard]] ir::ScriptFunction *MakeFunction(varbinder::FunctionParamScope *const paramScope, - ArenaVector &¶ms, - ArenaVector &&body, - ir::TypeNode *const returnTypeAnnotation, - const ir::TSEnumDeclaration *const enumDecl); - - void CreateEnumIntClassFromEnumDeclaration(ir::TSEnumDeclaration const *const enumDecl); - void CreateEnumStringClassFromEnumDeclaration(ir::TSEnumDeclaration const *const enumDecl); + struct FunctionInfo { + varbinder::FunctionParamScope *paramScope; + ArenaVector &¶ms; + ArenaVector &&body; + ir::TypeNode *returnTypeAnnotation; + const ir::TSEnumDeclaration *enumDecl; + ir::ModifierFlags flags; + }; + + [[nodiscard]] ir::ScriptFunction *MakeFunction(FunctionInfo &&functionInfo); + ir::ClassDefinition *CreateClass(ir::TSEnumDeclaration *const enumDecl); + ir::ClassProperty *CreateOrdinalField(ir::ClassDefinition *const enumClass); + void CreateCCtorForEnumClass(ir::ClassDefinition *const enumClass); + void CreateCtorForEnumClass(ir::ClassDefinition *const enumClass); + + void CreateEnumIntClassFromEnumDeclaration(ir::TSEnumDeclaration *const enumDecl); + void CreateEnumStringClassFromEnumDeclaration(ir::TSEnumDeclaration *const enumDecl); static void AppendParentNames(util::UString &qualifiedName, const ir::AstNode *const node); - [[nodiscard]] ir::Identifier *MakeQualifiedIdentifier(const ir::TSEnumDeclaration *const enumDecl, - const util::StringView &name); - template - [[nodiscard]] ir::Identifier *MakeArray(const ir::TSEnumDeclaration *const enumDecl, - ir::ClassDefinition *globalClass, const util::StringView &name, - ir::TypeNode *const typeAnnotation, ElementMaker &&elementMaker); - - ir::Identifier *CreateEnumNamesArray(const ir::TSEnumDeclaration *const enumDecl); - - ir::Identifier *CreateEnumValuesArray(const ir::TSEnumDeclaration *const enumDecl); - ir::Identifier *CreateEnumStringValuesArray(const ir::TSEnumDeclaration *const enumDecl); - ir::Identifier *CreateEnumItemsArray(const ir::TSEnumDeclaration *const enumDecl); - void CreateEnumFromIntMethod(ir::TSEnumDeclaration const *const enumDecl, ir::Identifier *const itemsArrayIdent); - - void CreateEnumToStringMethod(ir::TSEnumDeclaration const *const enumDecl, + [[nodiscard]] ir::Identifier *MakeArray(const ir::TSEnumDeclaration *const enumDecl, ir::ClassDefinition *enumClass, + const util::StringView &name, ir::TypeNode *const typeAnnotation, + ElementMaker &&elementMaker); + + 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 CreateEnumGetValueMethod(ir::TSEnumDeclaration const *const enumDecl, ir::Identifier *const valuesArrayIdent); - void CreateEnumGetNameMethod(ir::TSEnumDeclaration const *const enumDecl, ir::Identifier *const namesArrayIdent); - void CreateEnumValueOfMethod(ir::TSEnumDeclaration const *const enumDecl, ir::Identifier *const namesArrayIdent); - void CreateEnumValuesMethod(ir::TSEnumDeclaration const *const enumDecl, ir::Identifier *const itemsArrayIdent); + void CreateEnumGetValueMethod(ir::TSEnumDeclaration const *const enumDecl, ir::ClassDefinition *const enumClass, + ir::Identifier *const valuesArrayIdent); + void CreateEnumGetNameMethod(ir::TSEnumDeclaration const *const enumDecl, ir::ClassDefinition *const enumClass, + ir::Identifier *const namesArrayIdent); + void CreateEnumValueOfMethod(ir::TSEnumDeclaration const *const enumDecl, ir::ClassDefinition *const enumClass, + ir::Identifier *const namesArrayIdent); + 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); + + ArenaAllocator *Allocator(); private: checker::ETSChecker *checker_ {nullptr}; diff --git a/ets2panda/compiler/lowering/ets/enumPostCheckLowering.cpp b/ets2panda/compiler/lowering/ets/enumPostCheckLowering.cpp new file mode 100644 index 0000000000000000000000000000000000000000..bd05eb425d7d53feb6b4c304c2a4a127c7fc5c6a --- /dev/null +++ b/ets2panda/compiler/lowering/ets/enumPostCheckLowering.cpp @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2021 - 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "enumPostCheckLowering.h" +#include "checker/types/ets/etsEnumType.h" +#include "checker/ETSchecker.h" +#include "checker/types/type.h" +#include "varbinder/ETSBinder.h" +#include "varbinder/variable.h" + +namespace ark::es2panda::compiler { + +ir::CallExpression *EnumPostCheckLoweringPhase::CreateGetValueCall(checker::ETSChecker *checker, + ir::ClassDefinition *const classDef, + ir::Expression *argument) +{ + auto *classId = checker->AllocNode(classDef->Ident()->Name(), checker->Allocator()); + auto *methodId = checker->AllocNode( + argument->TsType()->AsEnumInterface()->GetValueMethod().memberProxyType->Name(), checker->Allocator()); + methodId->SetReference(); + auto *callee = checker->AllocNode(classId, methodId, + ir::MemberExpressionKind::PROPERTY_ACCESS, false, false); + + ArenaVector callArguments(checker->Allocator()->Adapter()); + callArguments.push_back(argument); + return checker->AllocNode(callee, std::move(callArguments), nullptr, false); +} + +namespace { + +bool NeedToGenerateGetValueForBinaryExpression(lexer::TokenType op) +{ + return 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 || + op == lexer::TokenType::PUNCTUATOR_EQUAL || op == lexer::TokenType::PUNCTUATOR_NOT_EQUAL || + op == lexer::TokenType::PUNCTUATOR_BITWISE_AND || op == lexer::TokenType::PUNCTUATOR_BITWISE_OR || + op == lexer::TokenType::PUNCTUATOR_BITWISE_XOR; +} + +} // namespace + +bool EnumPostCheckLoweringPhase::Perform(public_lib::Context *ctx, parser::Program *program) +{ + if (program->Extension() != ScriptExtension::ETS) { + return true; + } + + for (auto &[_, extPrograms] : program->ExternalSources()) { + (void)_; + for (auto *extProg : extPrograms) { + Perform(ctx, extProg); + } + } + + program->Ast()->IterateRecursively([this, ctx](ir::AstNode *ast) -> void { + if (ast->IsBinaryExpression()) { + auto *binaryExpr = ast->AsBinaryExpression(); + if (!NeedToGenerateGetValueForBinaryExpression(binaryExpr->OperatorType())) { + return; + } + + auto *left = binaryExpr->Left(); + auto *right = binaryExpr->Right(); + auto *leftType = left->TsType(); + auto *rightType = right->TsType(); + + if (leftType != nullptr && (leftType->IsETSEnumType() || leftType->IsETSStringEnumType())) { + auto *enumIf = leftType->AsEnumInterface(); + auto *callExpr = + CreateGetValueCall(ctx->checker->AsETSChecker(), enumIf->GetDecl()->BoxedClass(), left); + callExpr->SetParent(binaryExpr); + binaryExpr->SetLeft(callExpr); + } + if (rightType != nullptr && (rightType->IsETSEnumType() || rightType->IsETSStringEnumType())) { + auto *enumIf = rightType->AsEnumInterface(); + auto *callExpr = + CreateGetValueCall(ctx->checker->AsETSChecker(), enumIf->GetDecl()->BoxedClass(), right); + callExpr->SetParent(binaryExpr); + binaryExpr->SetRight(callExpr); + } + if (leftType != nullptr || rightType != nullptr) { + binaryExpr->SetTsType(nullptr); // force recheck + binaryExpr->Check(ctx->checker->AsETSChecker()); + } + } + }); + return true; +} + +} // namespace ark::es2panda::compiler \ No newline at end of file diff --git a/ets2panda/compiler/lowering/ets/enumPostCheckLowering.h b/ets2panda/compiler/lowering/ets/enumPostCheckLowering.h new file mode 100644 index 0000000000000000000000000000000000000000..3f59999cbba3bd0675e49f3e3fb50aadc4e56b02 --- /dev/null +++ b/ets2panda/compiler/lowering/ets/enumPostCheckLowering.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2021 - 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ES2PANDA_COMPILER_ENUM_POST_CHECK_LOWERING_H +#define ES2PANDA_COMPILER_ENUM_POST_CHECK_LOWERING_H + +#include "compiler/lowering/phase.h" +#include "checker/types/ets/etsEnumType.h" + +namespace ark::es2panda::compiler { + +class EnumPostCheckLoweringPhase : public Phase { +public: + EnumPostCheckLoweringPhase() noexcept = default; + std::string_view Name() const override + { + return "EnumPostCheckLoweringPhase"; + } + bool Perform(public_lib::Context *ctx, parser::Program *program) override; + +protected: + ir::CallExpression *CreateGetValueCall(checker::ETSChecker *checker, ir::ClassDefinition *const classDef, + ir::Expression *argument); +}; + +} // namespace ark::es2panda::compiler + +#endif // ES2PANDA_COMPILER_ENUM_POST_CHECK_LOWERING_H diff --git a/ets2panda/compiler/lowering/ets/expressionLambdaLowering.cpp b/ets2panda/compiler/lowering/ets/expressionLambdaLowering.cpp index 72d9e98a7f746e66600de3f28093463d88e02de9..73cea7ae19e9fb6d7295fe486d1c2ea0d43d6c2c 100644 --- a/ets2panda/compiler/lowering/ets/expressionLambdaLowering.cpp +++ b/ets2panda/compiler/lowering/ets/expressionLambdaLowering.cpp @@ -15,7 +15,6 @@ #include "expressionLambdaLowering.h" #include "checker/ETSchecker.h" -#include "compiler/core/ASTVerifier.h" namespace ark::es2panda::compiler { static ir::AstNode *ConvertExpression(checker::ETSChecker *const checker, ir::ArrowFunctionExpression *const arrow) diff --git a/ets2panda/compiler/lowering/ets/interfaceObjectLiteralLowering.cpp b/ets2panda/compiler/lowering/ets/interfaceObjectLiteralLowering.cpp new file mode 100644 index 0000000000000000000000000000000000000000..08c048450f070147e8cd7004b985c2c57769b3bd --- /dev/null +++ b/ets2panda/compiler/lowering/ets/interfaceObjectLiteralLowering.cpp @@ -0,0 +1,287 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "interfaceObjectLiteralLowering.h" +#include "checker/ETSchecker.h" +#include "checker/ets/typeRelationContext.h" +#include "ir/expressions/assignmentExpression.h" +#include "util/helpers.h" + +namespace ark::es2panda::compiler { + +std::string_view InterfaceObjectLiteralLowering::Name() const +{ + return "InterfaceObjectLiteralLowering"; +} + +static inline bool IsInterfaceType(const checker::Type *type) +{ + return type != nullptr && type->IsETSObjectType() && + type->AsETSObjectType()->HasObjectFlag(checker::ETSObjectFlags::INTERFACE) && + !type->AsETSObjectType()->HasObjectFlag(checker::ETSObjectFlags::DYNAMIC); +} + +static ir::AstNode *CreateAnonClassImplCtor(checker::ETSChecker *checker) +{ + checker::ETSChecker::ClassInitializerBuilder initBuilder = + [checker]([[maybe_unused]] ArenaVector *statements, + [[maybe_unused]] ArenaVector *params) { + checker->AddParam(varbinder::VarBinder::MANDATORY_PARAM_THIS, nullptr); + }; + + return checker->CreateClassInstanceInitializer(initBuilder); +} + +static ir::ClassProperty *CreateAnonClassField(ir::MethodDefinition *ifaceMethod, checker::ETSChecker *checker) +{ + auto *const allocator = checker->Allocator(); + + // Field type annotation + auto *fieldType = ifaceMethod->Function()->Signature()->ReturnType(); + if (IsInterfaceType(fieldType)) { + auto *anonClass = fieldType->AsETSObjectType()->GetDeclNode()->AsTSInterfaceDeclaration()->GetAnonClass(); + ASSERT(anonClass != nullptr); + fieldType = anonClass->Definition()->TsType(); + } + ASSERT(fieldType != nullptr); + auto *fieldTypeNode = checker->AllocNode(fieldType); + + // Field identifier + util::UString fieldName(std::string("_"), allocator); + fieldName.Append(ifaceMethod->Id()->Name()); + auto *fieldId = checker->AllocNode(fieldName.View(), nullptr, allocator); + + // Field modifiers flags + ir::ModifierFlags fieldMF = ir::ModifierFlags::PRIVATE; + + // No overloads means no setter function with the same name, so the field is readonly + if (ifaceMethod->Overloads().empty()) { + fieldMF |= ir::ModifierFlags::READONLY; + } + + // Create synthetic class property node + auto *field = checker->AllocNode(fieldId, nullptr, fieldTypeNode->Clone(allocator, nullptr), + fieldMF, allocator, false); + field->SetRange(ifaceMethod->Range()); + + return field; +} + +static ir::MethodDefinition *CreateAnonClassFieldGetterSetter(checker::ETSChecker *checker, + ir::MethodDefinition *ifaceMethod, bool isSetter) +{ + checker::ETSChecker::MethodBuilder methodBuilder = [checker, ifaceMethod, + isSetter](ArenaVector *statements, + ArenaVector *params, + checker::Type **returnType) { + auto *const allocator = checker->Allocator(); + + // Adding mandatory 'this' parameter + checker->AddParam(varbinder::VarBinder::MANDATORY_PARAM_THIS, nullptr); + + // ifaceMethod is getter, so it should have return type + auto *retType = ifaceMethod->Function()->Signature()->ReturnType(); + if (IsInterfaceType(retType)) { + auto *anonClass = retType->AsETSObjectType()->GetDeclNode()->AsTSInterfaceDeclaration()->GetAnonClass(); + ASSERT(anonClass != nullptr); + retType = anonClass->Definition()->TsType(); + } + ASSERT(retType != nullptr); + + // Field identifier + util::UString fieldName(std::string("_"), allocator); + fieldName.Append(ifaceMethod->Id()->Name()); + auto *fieldId = checker->AllocNode(fieldName.View(), nullptr, allocator); + + if (isSetter) { + // Setter call params + ir::ETSParameterExpression *param = + checker->AddParam(ifaceMethod->Id()->Name(), checker->AllocNode(retType)); + params->push_back(param); + + // Setter body: + // this. = ; + auto *thisExpr = checker->AllocNode(); + auto *lhs = checker->AllocNode( + thisExpr, fieldId->Clone(allocator, nullptr), ir::MemberExpressionKind::PROPERTY_ACCESS, false, false); + auto *rhs = param->Ident()->Clone(allocator, nullptr); + + auto *assignment = + checker->AllocNode(lhs, rhs, lexer::TokenType::PUNCTUATOR_SUBSTITUTION); + auto *statement = checker->AllocNode(assignment); + statements->push_back(statement); + + // Setter return type + *returnType = checker->GlobalVoidType(); + } else { + // Getter call params are empty + + // Getter body: + // Just return this.; + auto *thisExpr = checker->AllocNode(); + auto *argument = checker->AllocNode( + thisExpr, fieldId->Clone(allocator, nullptr), ir::MemberExpressionKind::PROPERTY_ACCESS, false, false); + + auto *statement = checker->AllocNode(argument); + statements->push_back(statement); + + // Getter return type + *returnType = retType; + } + }; + + ir::ModifierFlags modifierFlags = ir::ModifierFlags::PUBLIC; + modifierFlags |= isSetter ? ir::ModifierFlags::SETTER : ir::ModifierFlags::GETTER; + ir::ScriptFunctionFlags funcFlags = ir::ScriptFunctionFlags::METHOD; + funcFlags |= isSetter ? ir::ScriptFunctionFlags::SETTER : ir::ScriptFunctionFlags::GETTER; + + return checker->CreateClassMethod(ifaceMethod->Id()->Name().Utf8(), funcFlags, modifierFlags, methodBuilder); +} + +static void FillClassBody(checker::ETSChecker *checker, ArenaVector *classBody, + const ArenaVector &ifaceBody, ir::ObjectExpression *objExpr) +{ + for (auto *it : ifaceBody) { + ASSERT(it->IsMethodDefinition()); + auto *ifaceMethod = it->AsMethodDefinition(); + + if (!ifaceMethod->Function()->IsGetter() && !ifaceMethod->Function()->IsSetter()) { + checker->ThrowTypeError("Interface has methods", objExpr->Start()); + } + + if (!ifaceMethod->Function()->IsGetter()) { + continue; + } + + auto *field = CreateAnonClassField(ifaceMethod, checker); + classBody->push_back(field); + + auto *getter = CreateAnonClassFieldGetterSetter(checker, ifaceMethod, false); + classBody->push_back(getter); + + if (ifaceMethod->Overloads().size() == 1 && ifaceMethod->Overloads()[0]->Function()->IsSetter()) { + auto *setter = CreateAnonClassFieldGetterSetter(checker, ifaceMethod, true); + classBody->push_back(setter); + } + } +} + +static void FillAnonClassBody(checker::ETSChecker *checker, ArenaVector *classBody, + ir::TSInterfaceDeclaration *ifaceNode, ir::ObjectExpression *objExpr) +{ + for (auto *extendedIface : ifaceNode->TsType()->AsETSObjectType()->Interfaces()) { + auto extendedIfaceBody = extendedIface->GetDeclNode()->AsTSInterfaceDeclaration()->Body()->Body(); + FillClassBody(checker, classBody, extendedIfaceBody, objExpr); + } + + FillClassBody(checker, classBody, ifaceNode->Body()->Body(), objExpr); +} + +static checker::ETSObjectType *GenerateAnonClassTypeFromInterface(checker::ETSChecker *checker, + ir::TSInterfaceDeclaration *ifaceNode, + ir::ObjectExpression *objExpr) +{ + if (ifaceNode->GetAnonClass() != nullptr) { + return ifaceNode->GetAnonClass()->Definition()->TsType()->AsETSObjectType(); + } + + auto classBodyBuilder = [checker, ifaceNode, objExpr](ArenaVector *classBody) { + if (ifaceNode->TsType() == nullptr) { + ifaceNode->Check(checker); + } + + FillAnonClassBody(checker, classBody, ifaceNode, objExpr); + classBody->push_back(CreateAnonClassImplCtor(checker)); + }; + + util::UString className(util::StringView("$anonymous_class$"), checker->Allocator()); + className.Append(ifaceNode->Id()->Name()); + auto *classDecl = checker->BuildClass(className.View(), classBodyBuilder); + auto *classDef = classDecl->Definition(); + auto *classType = classDef->TsType()->AsETSObjectType(); + + // Class type params + if (ifaceNode->TypeParams() != nullptr) { + // NOTE: to be done + checker->ThrowTypeError("Object literal cannot be of typed interface type", objExpr->Start()); + } + + // Class implements + auto *classImplements = + checker->AllocNode(checker->AllocNode(ifaceNode->TsType())); + classImplements->SetParent(classDef); + classDef->Implements().emplace_back(classImplements); + classType->RemoveObjectFlag(checker::ETSObjectFlags::RESOLVED_INTERFACES); + checker->GetInterfacesOfClass(classType); + + ifaceNode->SetAnonClass(classDecl); + return classType; +} + +static void HandleInterfaceLowering(checker::ETSChecker *checker, ir::ObjectExpression *objExpr) +{ + const auto *const targetType = objExpr->TsType(); + ASSERT(targetType->AsETSObjectType()->GetDeclNode()->IsTSInterfaceDeclaration()); + auto *ifaceNode = targetType->AsETSObjectType()->GetDeclNode()->AsTSInterfaceDeclaration(); + auto *resultType = GenerateAnonClassTypeFromInterface(checker, ifaceNode, objExpr); + + if (const auto *const parent = objExpr->Parent(); parent->IsArrayExpression()) { + for (auto *elem : parent->AsArrayExpression()->Elements()) { + if (!elem->IsObjectExpression()) { + continue; + } + // Adjusting ts types of other object literals in array + elem->AsObjectExpression()->SetTsType(resultType); + } + } + objExpr->SetTsType(resultType); +} + +bool InterfaceObjectLiteralLowering::Perform(public_lib::Context *ctx, parser::Program *program) +{ + for (auto &[_, extPrograms] : program->ExternalSources()) { + (void)_; + for (auto *extProg : extPrograms) { + Perform(ctx, extProg); + } + } + + auto *checker = ctx->checker->AsETSChecker(); + + program->Ast()->IterateRecursivelyPostorder([checker](ir::AstNode *ast) -> void { + if (ast->IsObjectExpression() && IsInterfaceType(ast->AsObjectExpression()->TsType())) { + HandleInterfaceLowering(checker, ast->AsObjectExpression()); + } + }); + + return true; +} + +bool InterfaceObjectLiteralLowering::Postcondition(public_lib::Context *ctx, const parser::Program *program) +{ + for (auto &[_, extPrograms] : program->ExternalSources()) { + (void)_; + for (auto *extProg : extPrograms) { + if (!Postcondition(ctx, extProg)) { + return false; + } + } + } + + return !program->Ast()->IsAnyChild([](const ir::AstNode *ast) -> bool { + return ast->IsObjectExpression() && IsInterfaceType(ast->AsObjectExpression()->TsType()); + }); +} +} // namespace ark::es2panda::compiler diff --git a/ets2panda/compiler/lowering/ets/interfaceObjectLiteralLowering.h b/ets2panda/compiler/lowering/ets/interfaceObjectLiteralLowering.h new file mode 100644 index 0000000000000000000000000000000000000000..b82b7af2c3036d3dc8cebc5cec715885edeffdf4 --- /dev/null +++ b/ets2panda/compiler/lowering/ets/interfaceObjectLiteralLowering.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ES2PANDA_COMPILER_LOWERING_INTERFACE_LOWERING_H +#define ES2PANDA_COMPILER_LOWERING_INTERFACE_LOWERING_H + +#include "compiler/lowering/phase.h" + +namespace ark::es2panda::compiler { + +class InterfaceObjectLiteralLowering : public Phase { +public: + std::string_view Name() const override; + bool Perform(public_lib::Context *ctx, parser::Program *program) override; + bool Postcondition(public_lib::Context *ctx, const parser::Program *program) override; +}; + +} // namespace ark::es2panda::compiler + +#endif diff --git a/ets2panda/compiler/lowering/ets/interfacePropertyDeclarations.cpp b/ets2panda/compiler/lowering/ets/interfacePropertyDeclarations.cpp index 5a8f89886df5f1afd3148d5d2dd7f6b0ca834d18..33fc10fd3a888f2483d7cd48152ea2d865190ba2 100644 --- a/ets2panda/compiler/lowering/ets/interfacePropertyDeclarations.cpp +++ b/ets2panda/compiler/lowering/ets/interfacePropertyDeclarations.cpp @@ -17,7 +17,6 @@ #include "checker/ETSchecker.h" #include "checker/types/type.h" -#include "compiler/core/ASTVerifier.h" #include "compiler/lowering/util.h" #include "ir/astNode.h" #include "ir/expression.h" diff --git a/ets2panda/compiler/lowering/ets/objectLiteralLowering.cpp b/ets2panda/compiler/lowering/ets/objectLiteralLowering.cpp index 56283418178c27edc85a4207eabd951afb772bfa..43a72da7c9067eb076d64f67e6cf51b7bcfd08b7 100644 --- a/ets2panda/compiler/lowering/ets/objectLiteralLowering.cpp +++ b/ets2panda/compiler/lowering/ets/objectLiteralLowering.cpp @@ -108,18 +108,18 @@ static void GenerateNewStatements(checker::ETSChecker *checker, ir::ObjectExpres { auto *const allocator = checker->Allocator(); - auto *const classType = objExpr->PreferredType()->AsETSObjectType(); + auto *const classType = objExpr->TsType()->AsETSObjectType(); auto addNode = [&newStmts](ir::AstNode *node) -> int { newStmts.emplace_back(node); return newStmts.size(); }; - // Generating: let : = new (); + // Generating: let : = new (); auto *genSymIdent = Gensym(allocator); - auto *preferredType = checker->AllocNode(classType); - ss << "let @@I" << addNode(genSymIdent) << ": @@T" << addNode(preferredType) << " = new @@T" - << addNode(checker->AllocNode(classType)) << "();" << std::endl; + auto *type = checker->AllocNode(classType); + ss << "let @@I" << addNode(genSymIdent) << ": @@T" << addNode(type) << " = new @@T" + << addNode(type->Clone(allocator, nullptr)) << "();" << std::endl; // Generating: .key_i = value_i ( i <= [0, object_literal.properties.size) ) for (auto *propExpr : objExpr->Properties()) { @@ -155,13 +155,13 @@ static ir::AstNode *HandleObjectLiteralLowering(public_lib::Context *ctx, ir::Ob * For given object literal of class type generates following block expression: * * ({ - * let : = new (); + * let : = new (); * .key_i = value_i ( i <= [0, object_literal.properties.size) ) * ; <-- NOTE: result of block expression * }) */ - if (objExpr->PreferredType() == nullptr) { + if (objExpr->TsType() == nullptr) { return objExpr; } @@ -179,7 +179,7 @@ static ir::AstNode *HandleObjectLiteralLowering(public_lib::Context *ctx, ir::Ob auto *loweringResult = parser->CreateFormattedExpression(ss.str(), newStmts); loweringResult->SetParent(objExpr->Parent()); - MaybeAllowConstAssign(objExpr->PreferredType(), loweringResult->AsBlockExpression()->Statements()); + MaybeAllowConstAssign(objExpr->TsType(), loweringResult->AsBlockExpression()->Statements()); auto scopeCtx = varbinder::LexicalScope::Enter(varbinder, NearestScope(objExpr)); InitScopesPhaseETS::RunExternalNode(loweringResult, varbinder); @@ -210,9 +210,8 @@ bool ObjectLiteralLowering::Perform(public_lib::Context *ctx, parser::Program *p program->Ast()->TransformChildrenRecursively( [ctx](ir::AstNode *ast) -> ir::AstNode * { // Skip processing dynamic objects - if (ast->IsObjectExpression() && - !ast->AsObjectExpression()->PreferredType()->AsETSObjectType()->HasObjectFlag( - checker::ETSObjectFlags::DYNAMIC)) { + if (ast->IsObjectExpression() && !ast->AsObjectExpression()->TsType()->AsETSObjectType()->HasObjectFlag( + checker::ETSObjectFlags::DYNAMIC)) { return HandleObjectLiteralLowering(ctx, ast->AsObjectExpression()); } return ast; @@ -236,8 +235,7 @@ bool ObjectLiteralLowering::Postcondition(public_lib::Context *ctx, const parser // In all object literal contexts (except dynamic) a substitution should take place return !program->Ast()->IsAnyChild([](const ir::AstNode *ast) -> bool { return ast->IsObjectExpression() && - !ast->AsObjectExpression()->PreferredType()->AsETSObjectType()->HasObjectFlag( - checker::ETSObjectFlags::DYNAMIC); + !ast->AsObjectExpression()->TsType()->AsETSObjectType()->HasObjectFlag(checker::ETSObjectFlags::DYNAMIC); }); } diff --git a/ets2panda/compiler/lowering/ets/promiseVoid.cpp b/ets2panda/compiler/lowering/ets/promiseVoid.cpp index 3ad58325fc1404a6af51c634c0ee82d53a370be2..30de0dbe7a9f6cc2cdb42a2614b5c5119f8ed074 100644 --- a/ets2panda/compiler/lowering/ets/promiseVoid.cpp +++ b/ets2panda/compiler/lowering/ets/promiseVoid.cpp @@ -16,7 +16,6 @@ #include "promiseVoid.h" #include "checker/ETSchecker.h" #include "checker/checker.h" -#include "compiler/core/ASTVerifier.h" #include "generated/signatures.h" #include "ir/base/scriptFunction.h" #include "ir/ets/etsTypeReference.h" diff --git a/ets2panda/compiler/lowering/ets/topLevelStmts/globalDeclTransformer.cpp b/ets2panda/compiler/lowering/ets/topLevelStmts/globalDeclTransformer.cpp index 07c923371047cb2090240c4bd9635aff3e27c3a4..a19c606ce5950b87a34e4be42e84e6ed71d8e58a 100644 --- a/ets2panda/compiler/lowering/ets/topLevelStmts/globalDeclTransformer.cpp +++ b/ets2panda/compiler/lowering/ets/topLevelStmts/globalDeclTransformer.cpp @@ -53,6 +53,11 @@ void GlobalDeclTransformer::VisitFunctionDeclaration(ir::FunctionDeclaration *fu allocator_, methodKind, funcDecl->Function()->Id()->Clone(allocator_, nullptr), funcExpr, funcDecl->Function()->Modifiers(), allocator_, false); method->SetRange(funcDecl->Range()); + + if (funcDecl->Function()->IsExported() && funcDecl->Function()->HasExportAlias()) { + method->AddAstNodeFlags(ir::AstNodeFlags::HAS_EXPORT_ALIAS); + } + result_.classProperties.emplace_back(method); } @@ -66,6 +71,11 @@ void GlobalDeclTransformer::VisitVariableDeclaration(ir::VariableDeclaration *va declarator->Init(), typeAnn, varDecl->Modifiers(), allocator_, false); field->SetRange(declarator->Range()); + + if (varDecl->IsExported() && varDecl->HasExportAlias()) { + field->AddAstNodeFlags(ir::AstNodeFlags::HAS_EXPORT_ALIAS); + } + result_.classProperties.emplace_back(field); if (auto stmt = InitTopLevelProperty(field); stmt != nullptr) { result_.initStatements.emplace_back(stmt); diff --git a/ets2panda/compiler/lowering/ets/topLevelStmts/importExportDecls.cpp b/ets2panda/compiler/lowering/ets/topLevelStmts/importExportDecls.cpp index 177b7577b891650c7be1102253bc5e8000990df0..344b652f482722e88f150e735f1e1222764ed690 100644 --- a/ets2panda/compiler/lowering/ets/topLevelStmts/importExportDecls.cpp +++ b/ets2panda/compiler/lowering/ets/topLevelStmts/importExportDecls.cpp @@ -35,35 +35,95 @@ void ImportExportDecls::HandleGlobalStmts(const ArenaVector & exportedTypes_.clear(); for (auto stmt : program->Ast()->Statements()) { stmt->Accept(this); + if (stmt->IsExportNamedDeclaration()) { + PopulateAliasMap(stmt->AsExportNamedDeclaration(), program->SourceFilePath()); + } } for (auto const &[exportName, startLoc] : exportNameMap_) { const bool isType = exportedTypes_.find(exportName) != exportedTypes_.end(); - if ((fieldMap_.count(exportName) == 0 && !isType)) { + util::StringView originalName = varbinder_->FindNameInAliasMap(program->SourceFilePath(), exportName); + + ASSERT(!originalName.Empty()); + + if (fieldMap_.find(originalName) == fieldMap_.end() && !isType) { util::ErrorHandler::ThrowSyntaxError( - program, "Cannot find name '" + exportName.Mutf8() + "' to export.", startLoc); + varbinder_->Program(), "Cannot find name '" + originalName.Mutf8() + "' to export", startLoc); } if (!isType) { - auto field = fieldMap_[exportName]; - field->AddModifier(ir::ModifierFlags::EXPORT); + HandleSelectiveExportWithAlias(originalName, exportName, startLoc); + } + } + } +} + +void ImportExportDecls::PopulateAliasMap(const ir::ExportNamedDeclaration *decl, const util::StringView &path) +{ + for (auto spec : decl->Specifiers()) { + if (!varbinder_->AddSelectiveExportAlias(path, spec->Local()->Name(), spec->Exported()->Name())) { + util::ErrorHandler::ThrowSyntaxError(varbinder_->Program(), + "The given name '" + spec->Local()->Name().Mutf8() + + "' is already used in another export", + spec->Start()); + } + } +} + +void ImportExportDecls::HandleSelectiveExportWithAlias(util::StringView originalFieldName, util::StringView exportName, + lexer::SourcePosition startLoc) +{ + ir::AstNode *field = fieldMap_.find(originalFieldName)->second; + if ((field->Modifiers() & ir::ModifierFlags::EXPORTED) != 0) { + // Note (oeotvos) Needs to be discussed, whether we would like to allow exporting the same program + // element using its original name and also an alias, like: export {test_func, test_func as foo}. + util::ErrorHandler::ThrowSyntaxError( + varbinder_->Program(), "Cannot export '" + originalFieldName.Mutf8() + "', it was already exported", + startLoc); + } + + field->AddModifier(ir::ModifierFlags::EXPORT); + + if (exportName != originalFieldName) { + if (auto declItem = fieldMap_.find(exportName); declItem != fieldMap_.end()) { + // Checking for the alias might be unnecessary, because explicit exports cannot + // have an alias yet. + if (((declItem->second->Modifiers() & ir::ModifierFlags::EXPORTED) != 0) && + !declItem->second->HasExportAlias()) { + util::ErrorHandler::ThrowSyntaxError( + varbinder_->Program(), + "The given name '" + exportName.Mutf8() + "' is already used in another export", startLoc); } } + field->AddAstNodeFlags(ir::AstNodeFlags::HAS_EXPORT_ALIAS); } } void ImportExportDecls::VisitFunctionDeclaration(ir::FunctionDeclaration *funcDecl) { - auto id = funcDecl->Function()->Id(); - fieldMap_.emplace(id->Name(), funcDecl->Function()); + fieldMap_.emplace(funcDecl->Function()->Id()->Name(), funcDecl->Function()); } void ImportExportDecls::VisitVariableDeclaration(ir::VariableDeclaration *varDecl) { for (const auto &decl : varDecl->Declarators()) { - auto id = decl->Id()->AsIdentifier(); - fieldMap_.emplace(id->Name(), varDecl); + fieldMap_.emplace(decl->Id()->AsIdentifier()->Name(), varDecl); } } +void ImportExportDecls::VisitClassDeclaration(ir::ClassDeclaration *classDecl) +{ + fieldMap_.emplace(classDecl->Definition()->Ident()->Name(), classDecl); +} + +void ImportExportDecls::VisitTSTypeAliasDeclaration(ir::TSTypeAliasDeclaration *typeAliasDecl) +{ + fieldMap_.emplace(typeAliasDecl->Id()->Name(), typeAliasDecl); +} + +void ImportExportDecls::VisitTSInterfaceDeclaration(ir::TSInterfaceDeclaration *interfaceDecl) +{ + fieldMap_.emplace(interfaceDecl->Id()->Name(), interfaceDecl); +} + void ImportExportDecls::VisitExportNamedDeclaration(ir::ExportNamedDeclaration *exportDecl) { for (auto spec : exportDecl->Specifiers()) { @@ -72,9 +132,9 @@ void ImportExportDecls::VisitExportNamedDeclaration(ir::ExportNamedDeclaration * exportedTypes_.insert(local->Name()); } if (!exportNameMap_.emplace(local->Name(), local->Start()).second) { - util::ErrorHandler::ThrowSyntaxError(varbinder_->Program(), - "Cannot redeclare exported variable '" + local->Name().Mutf8() + "'", - local->Start()); + util::ErrorHandler::ThrowSyntaxError( + varbinder_->Program(), + "The given name '" + local->Name().Mutf8() + "' is already used in another export", local->Start()); } } } @@ -162,7 +222,6 @@ void ImportExportDecls::VerifyType(ir::Statement *stmt, parser::Program *program HandleSimpleType(exportedTypes, exportedStatements, stmt, name, program, spec->Local()->Start()); if (!name.Is(nameFind.Mutf8())) { element->second->AddAstNodeFlags(ir::AstNodeFlags::HAS_EXPORT_ALIAS); - varbinder_->AddExportSelectiveAlias(program->SourceFilePath(), name, nameFind); HandleSimpleType(exportedTypes, exportedStatements, stmt, nameFind, program, spec->Local()->Start()); } } diff --git a/ets2panda/compiler/lowering/ets/topLevelStmts/importExportDecls.h b/ets2panda/compiler/lowering/ets/topLevelStmts/importExportDecls.h index 303b0df0702bb2e107ce1d3a8423a6c206d31d82..ae4ae4676c69b15835590714721db4797be9ff1e 100644 --- a/ets2panda/compiler/lowering/ets/topLevelStmts/importExportDecls.h +++ b/ets2panda/compiler/lowering/ets/topLevelStmts/importExportDecls.h @@ -65,11 +65,17 @@ public: lexer::SourcePosition pos); void VerifySingleExportDefault(const ArenaVector &programs); + void HandleSelectiveExportWithAlias(util::StringView originalFieldName, util::StringView exportName, + lexer::SourcePosition startLoc); + void PopulateAliasMap(const ir::ExportNamedDeclaration *decl, const util::StringView &path); private: void VisitFunctionDeclaration(ir::FunctionDeclaration *funcDecl) override; void VisitVariableDeclaration(ir::VariableDeclaration *varDecl) override; void VisitExportNamedDeclaration(ir::ExportNamedDeclaration *exportDecl) override; + void VisitClassDeclaration(ir::ClassDeclaration *classDecl) override; + void VisitTSTypeAliasDeclaration(ir::TSTypeAliasDeclaration *typeAliasDecl) override; + void VisitTSInterfaceDeclaration(ir::TSInterfaceDeclaration *interfaceDecl) override; private: varbinder::ETSBinder *varbinder_ {nullptr}; diff --git a/ets2panda/compiler/lowering/ets/tupleLowering.cpp b/ets2panda/compiler/lowering/ets/tupleLowering.cpp index 984f66b1d5529b9bcf79d76b65016be27a6f1282..2cae029c7378314875b354142ddddab2b3e945f6 100644 --- a/ets2panda/compiler/lowering/ets/tupleLowering.cpp +++ b/ets2panda/compiler/lowering/ets/tupleLowering.cpp @@ -17,7 +17,6 @@ #include "checker/ETSchecker.h" #include "checker/types/ets/etsTupleType.h" -#include "compiler/core/ASTVerifier.h" #include "compiler/lowering/util.h" #include "ir/expressions/assignmentExpression.h" #include "ir/expressions/identifier.h" diff --git a/ets2panda/compiler/lowering/ets/unionLowering.cpp b/ets2panda/compiler/lowering/ets/unionLowering.cpp index a95619817c900207860aa936daaacfae67ce711b..03b0ac0f37096dcb76e725d30402e93aa7bb7352 100644 --- a/ets2panda/compiler/lowering/ets/unionLowering.cpp +++ b/ets2panda/compiler/lowering/ets/unionLowering.cpp @@ -14,7 +14,6 @@ */ #include "unionLowering.h" -#include "compiler/core/ASTVerifier.h" #include "varbinder/variableFlags.h" #include "varbinder/ETSBinder.h" #include "checker/ETSchecker.h" diff --git a/ets2panda/compiler/lowering/phase.cpp b/ets2panda/compiler/lowering/phase.cpp index 99fb42aae557c4579432b0f1957483ffb742968c..fc0906a3dffec642fc5d0b0ee5440f54520b31eb 100644 --- a/ets2panda/compiler/lowering/phase.cpp +++ b/ets2panda/compiler/lowering/phase.cpp @@ -15,10 +15,9 @@ #include "phase.h" #include "checker/checker.h" -#include "compiler/core/ASTVerifier.h" #include "ets/ambientLowering.h" -#include "ets/defaultParameterLowering.h" #include "lexer/token/sourceLocation.h" +#include "compiler/lowering/resolveIdentifiers.h" #include "compiler/lowering/checkerPhase.h" #include "compiler/lowering/ets/constStringToCharLowering.h" #include "compiler/lowering/ets/defaultParameterLowering.h" @@ -35,6 +34,7 @@ #include "compiler/lowering/ets/localClassLowering.h" #include "compiler/lowering/ets/opAssignment.h" #include "compiler/lowering/ets/objectLiteralLowering.h" +#include "compiler/lowering/ets/interfaceObjectLiteralLowering.h" #include "compiler/lowering/ets/optionalLowering.h" #include "compiler/lowering/ets/partialExportClassGen.h" #include "compiler/lowering/ets/promiseVoid.h" @@ -45,6 +45,7 @@ #include "compiler/lowering/ets/unionLowering.h" #include "compiler/lowering/ets/stringConstructorLowering.h" #include "compiler/lowering/ets/enumLowering.h" +#include "compiler/lowering/ets/enumPostCheckLowering.h" #include "compiler/lowering/plugin_phase.h" #include "compiler/lowering/scopesInit/scopesInitPhase.h" #include "public/es2panda_lib.h" @@ -52,20 +53,14 @@ namespace ark::es2panda::compiler { static CheckerPhase g_checkerPhase; - -std::vector GetTrivialPhaseList() -{ - return std::vector { - &g_checkerPhase, - }; -} - +static ResolveIdentifiers g_resolveIdentifiers {}; static AmbientLowering g_ambientLowering; static BigIntLowering g_bigintLowering; static StringConstructorLowering g_stringConstructorLowering; static ConstStringToCharLowering g_constStringToCharLowering; static InterfacePropertyDeclarationsPhase g_interfacePropDeclPhase; static EnumLoweringPhase g_enumLoweringPhase; +static EnumPostCheckLoweringPhase g_enumPostCheckLoweringPhase; static SpreadConstructionPhase g_spreadConstructionPhase; static ExpressionLambdaConstructionPhase g_expressionLambdaConstructionPhase; static OpAssignmentLowering g_opAssignmentLowering; @@ -74,6 +69,7 @@ static LambdaConversionPhase g_lambdaConversionPhase; static ObjectIndexLowering g_objectIndexLowering; static ObjectIteratorLowering g_objectIteratorLowering; static ObjectLiteralLowering g_objectLiteralLowering; +static InterfaceObjectLiteralLowering g_interfaceObjectLiteralLowering; static TupleLowering g_tupleLowering; // Can be only applied after checking phase, and OP_ASSIGNMENT_LOWERING phase static UnionLowering g_unionLowering; static OptionalLowering g_optionalLowering; @@ -117,11 +113,14 @@ std::vector GetETSPhaseList() &g_expressionLambdaConstructionPhase, &g_interfacePropDeclPhase, &g_enumLoweringPhase, + &g_resolveIdentifiers, &g_checkerPhase, + &g_enumPostCheckLoweringPhase, &g_spreadConstructionPhase, &g_pluginsAfterCheck, &g_bigintLowering, &g_opAssignmentLowering, + &g_constStringToCharLowering, &g_boxingForLocals, &g_lambdaConversionPhase, &g_recordLowering, @@ -131,9 +130,9 @@ std::vector GetETSPhaseList() &g_unionLowering, &g_expandBracketsPhase, &g_localClassLowering, + &g_interfaceObjectLiteralLowering, &g_objectLiteralLowering, &g_stringConstructorLowering, - &g_constStringToCharLowering, &g_stringComparisonLowering, &g_partialExportClassGen, &g_pluginsAfterLowerings, diff --git a/ets2panda/compiler/lowering/plugin_phase.h b/ets2panda/compiler/lowering/plugin_phase.h index e8422519496110724f91574faf07172f2511a391..9616d5e212d5beea0b4085cd0291b2e6c635aabc 100644 --- a/ets2panda/compiler/lowering/plugin_phase.h +++ b/ets2panda/compiler/lowering/plugin_phase.h @@ -16,7 +16,6 @@ #ifndef ES2PANDA_COMPILER_PLUGIN_PHASE_H #define ES2PANDA_COMPILER_PLUGIN_PHASE_H -#include "compiler/core/ASTVerifier.h" #include "compiler/lowering/phase.h" #include "util/plugin.h" diff --git a/ets2panda/compiler/lowering/resolveIdentifiers.cpp b/ets2panda/compiler/lowering/resolveIdentifiers.cpp new file mode 100644 index 0000000000000000000000000000000000000000..944c828acbc383c329b187149e92de6bafc270b3 --- /dev/null +++ b/ets2panda/compiler/lowering/resolveIdentifiers.cpp @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "resolveIdentifiers.h" + +#include "varbinder/ETSBinder.h" + +namespace ark::es2panda::compiler { +bool ResolveIdentifiers::Perform(public_lib::Context *ctx, [[maybe_unused]] parser::Program *program) +{ + auto const &options = ctx->config->options->CompilerOptions(); + auto *varbinder = ctx->parserProgram->VarBinder()->AsETSBinder(); + + if (options.dumpAst) { + std::cout << varbinder->Program()->Dump() << std::endl; + } + + if (options.opDumpAstOnlySilent) { + varbinder->Program()->DumpSilent(); + return false; + } + + if (options.parseOnly) { + return false; + } + + varbinder->SetGenStdLib(options.compilationMode == CompilationMode::GEN_STD_LIB); + varbinder->IdentifierAnalysis(); + + return true; +} + +} // namespace ark::es2panda::compiler diff --git a/ets2panda/compiler/lowering/resolveIdentifiers.h b/ets2panda/compiler/lowering/resolveIdentifiers.h new file mode 100644 index 0000000000000000000000000000000000000000..d7f97078bfc115cc868b5fd62914dde3713fd5dc --- /dev/null +++ b/ets2panda/compiler/lowering/resolveIdentifiers.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ES2PANDA_COMPILER_LOWERING_RESOLVE_IDENT_H +#define ES2PANDA_COMPILER_LOWERING_RESOLVE_IDENT_H + +#include "compiler/lowering/phase.h" + +namespace ark::es2panda::compiler { +class ResolveIdentifiers : public Phase { +public: + std::string_view Name() const override + { + return "ResolveIdentifiers"; + } + + bool Perform(public_lib::Context *ctx, parser::Program *program) override; +}; +} // namespace ark::es2panda::compiler + +#endif diff --git a/ets2panda/compiler/lowering/scopesInit/scopesInitPhase.cpp b/ets2panda/compiler/lowering/scopesInit/scopesInitPhase.cpp index 2249844f1963e514019a94acd2cf416a18433c10..43ebef53b1feb83bfdb2f4ec9c60609d6461c3d1 100644 --- a/ets2panda/compiler/lowering/scopesInit/scopesInitPhase.cpp +++ b/ets2panda/compiler/lowering/scopesInit/scopesInitPhase.cpp @@ -840,6 +840,7 @@ void AddOverload(ir::MethodDefinition *overload, varbinder::Variable *variable) auto *currentNode = variable->Declaration()->Node(); currentNode->AsMethodDefinition()->AddOverload(overload); overload->Id()->SetVariable(variable); + overload->SetParent(currentNode); } void InitScopesPhaseETS::DeclareClassMethod(ir::MethodDefinition *method) diff --git a/ets2panda/declgen_ets2ts/declgenEts2Ts.cpp b/ets2panda/declgen_ets2ts/declgenEts2Ts.cpp index 193466fc3e96f7a0e5b919a82434c535142b1722..f925c6c3bf67a8ee6190922134e901a5063c01a3 100644 --- a/ets2panda/declgen_ets2ts/declgenEts2Ts.cpp +++ b/ets2panda/declgen_ets2ts/declgenEts2Ts.cpp @@ -75,7 +75,10 @@ void TSDeclGen::Generate() } else if (globalStatement->IsTSEnumDeclaration()) { GenEnumDeclaration(globalStatement->AsTSEnumDeclaration()); } else if (globalStatement->IsClassDeclaration()) { - GenClassDeclaration(globalStatement->AsClassDeclaration()); + if (globalStatement->AsClassDeclaration()->Definition()->Ident()->Name().Mutf8().find('#') == + std::string::npos) { + GenClassDeclaration(globalStatement->AsClassDeclaration()); + } } else if (globalStatement->IsTSInterfaceDeclaration()) { GenInterfaceDeclaration(globalStatement->AsTSInterfaceDeclaration()); } else if (globalStatement->IsTSTypeAliasDeclaration()) { diff --git a/ets2panda/es2panda.cpp b/ets2panda/es2panda.cpp index f217db0a8fdef248272bce9eb05827e06550b399..4d08eda39c0d5d21e05bc85374deb2601166a217 100644 --- a/ets2panda/es2panda.cpp +++ b/ets2panda/es2panda.cpp @@ -80,6 +80,11 @@ pandasm::Program *Compiler::Compile(const SourceFile &input, const util::Options } } +bool Compiler::IsAnyError() const noexcept +{ + return compiler_->IsAnyError(); +} + void Compiler::DumpAsm(const pandasm::Program *prog) { compiler::CompilerImpl::DumpAsm(prog); diff --git a/ets2panda/es2panda.h b/ets2panda/es2panda.h index fa07e32171fe21f0c17046d7e962463eefa0f471..01c1108e5b1c909e416249de58d3fce80db23d82 100644 --- a/ets2panda/es2panda.h +++ b/ets2panda/es2panda.h @@ -247,6 +247,10 @@ public: static void DumpAsm(const pandasm::Program *prog); + // This is used as a _different_ channel of error reporting than GetError(). + // If this is true, the errors in question have already been reported to the user. + bool IsAnyError() const noexcept; + const Error &GetError() const noexcept { return error_; diff --git a/ets2panda/ir/astNode.cpp b/ets2panda/ir/astNode.cpp index 84a8c67fd7fdf24ee51230cf312bc704b06486da..1d4717a9a5298fe9eaf347845f2813740ae712bf 100644 --- a/ets2panda/ir/astNode.cpp +++ b/ets2panda/ir/astNode.cpp @@ -27,9 +27,28 @@ AstNode::AstNode(AstNode const &other) variable_ = other.variable_; } flags_ = other.flags_; + astNodeFlags_ = other.astNodeFlags_; // boxing_unboxing_flags_ {}; leave default value! } +[[nodiscard]] bool AstNode::IsExported() const noexcept +{ + if (UNLIKELY(IsClassDefinition())) { + return parent_->IsExported(); + } + + return (flags_ & ModifierFlags::EXPORT) != 0; +} + +[[nodiscard]] bool AstNode::IsDefaultExported() const noexcept +{ + if (UNLIKELY(IsClassDefinition())) { + return parent_->IsDefaultExported(); + } + + return (flags_ & ModifierFlags::DEFAULT_EXPORT) != 0; +} + [[nodiscard]] bool AstNode::IsExportedType() const noexcept { if (UNLIKELY(IsClassDefinition())) { @@ -39,10 +58,10 @@ AstNode::AstNode(AstNode const &other) return (flags_ & ModifierFlags::EXPORT_TYPE) != 0; } -[[nodiscard]] bool AstNode::HasAliasExport() const noexcept +[[nodiscard]] bool AstNode::HasExportAlias() const noexcept { if (UNLIKELY(IsClassDefinition())) { - return parent_->HasAliasExport(); + return parent_->HasExportAlias(); } return (astNodeFlags_ & AstNodeFlags::HAS_EXPORT_ALIAS) != 0; diff --git a/ets2panda/ir/astNode.h b/ets2panda/ir/astNode.h index afe1186b28226ced5bb83468db75a7a387be70cd..157c0d99474b3cd516912da9b957a2a672fc3e3a 100644 --- a/ets2panda/ir/astNode.h +++ b/ets2panda/ir/astNode.h @@ -369,23 +369,9 @@ public: return (flags_ & ModifierFlags::INTERNAL) != 0; } - [[nodiscard]] bool IsExported() const noexcept - { - if (UNLIKELY(IsClassDefinition())) { - return parent_->IsExported(); - } - - return (flags_ & ModifierFlags::EXPORT) != 0; - } + [[nodiscard]] bool IsExported() const noexcept; - [[nodiscard]] bool IsDefaultExported() const noexcept - { - if (UNLIKELY(IsClassDefinition())) { - return parent_->IsDefaultExported(); - } - - return (flags_ & ModifierFlags::DEFAULT_EXPORT) != 0; - } + [[nodiscard]] bool IsDefaultExported() const noexcept; [[nodiscard]] bool IsExportedType() const noexcept; @@ -429,7 +415,7 @@ public: return flags_; } - [[nodiscard]] bool HasAliasExport() const noexcept; + [[nodiscard]] bool HasExportAlias() const noexcept; // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define DECLARE_FLAG_OPERATIONS(flag_type, member_name) \ @@ -538,46 +524,6 @@ private: void SetOriginalNode(AstNode *originalNode); }; -template -class Typed : public T { -public: - Typed() = delete; - ~Typed() override = default; - - NO_COPY_OPERATOR(Typed); - NO_MOVE_SEMANTIC(Typed); - - [[nodiscard]] checker::Type *TsType() noexcept - { - return tsType_; - } - - [[nodiscard]] const checker::Type *TsType() const noexcept - { - return tsType_; - } - - void SetTsType(checker::Type *tsType) noexcept - { - tsType_ = tsType; - } - - bool IsTyped() const override - { - return true; - } - -protected: - explicit Typed(AstNodeType const type) : T(type) {} - explicit Typed(AstNodeType const type, ModifierFlags const flags) : T(type, flags) {} - - // NOTE: when cloning node its type is not copied but removed empty so that it can be re-checked further. - Typed(Typed const &other) : T(static_cast(other)) {} - -private: - checker::Type *tsType_ {}; -}; - template class Annotated : public T { public: @@ -611,40 +557,5 @@ private: TypeNode *typeAnnotation_ {}; }; -class TypedAstNode : public Typed { -public: - TypedAstNode() = delete; - ~TypedAstNode() override = default; - - NO_COPY_OPERATOR(TypedAstNode); - NO_MOVE_SEMANTIC(TypedAstNode); - -protected: - explicit TypedAstNode(AstNodeType const type) : Typed(type) {} - explicit TypedAstNode(AstNodeType const type, ModifierFlags const flags) : Typed(type, flags) {} - - TypedAstNode(TypedAstNode const &other) : Typed(static_cast const &>(other)) {} -}; - -class AnnotatedAstNode : public Annotated { -public: - AnnotatedAstNode() = delete; - ~AnnotatedAstNode() override = default; - - NO_COPY_OPERATOR(AnnotatedAstNode); - NO_MOVE_SEMANTIC(AnnotatedAstNode); - -protected: - explicit AnnotatedAstNode(AstNodeType const type, TypeNode *const typeAnnotation) - : Annotated(type, typeAnnotation) - { - } - explicit AnnotatedAstNode(AstNodeType const type) : Annotated(type) {} - explicit AnnotatedAstNode(AstNodeType const type, ModifierFlags const flags) : Annotated(type, flags) {} - - AnnotatedAstNode(AnnotatedAstNode const &other) : Annotated(static_cast const &>(other)) - { - } -}; } // namespace ark::es2panda::ir #endif diff --git a/ets2panda/ir/astNodeFlags.h b/ets2panda/ir/astNodeFlags.h index 6ccc32303bc603fe8237b82666c9ab6ddb164dc0..9c5e805efeb14d189488eefa5871e795cadf689c 100644 --- a/ets2panda/ir/astNodeFlags.h +++ b/ets2panda/ir/astNodeFlags.h @@ -27,10 +27,9 @@ using ENUMBITOPS_OPERATORS; enum class AstNodeFlags { NO_OPTS = 0, CHECKCAST = 1U << 0U, - ENUM_GET_VALUE = 1U << 1U, - CONVERT_TO_STRING = 1U << 2U, - ALLOW_REQUIRED_INSTANTIATION = 1U << 3U, - HAS_EXPORT_ALIAS = 1U << 4U + CONVERT_TO_STRING = 1U << 1U, + ALLOW_REQUIRED_INSTANTIATION = 1U << 2U, + HAS_EXPORT_ALIAS = 1U << 3U }; enum class ModifierFlags : uint32_t { @@ -60,7 +59,6 @@ enum class ModifierFlags : uint32_t { SETTER = 1U << 22U, DEFAULT_EXPORT = 1U << 23U, EXPORT_TYPE = 1U << 24U, - EXTERNAL = 1U << 25U, SUPER_OWNER = 1U << 26U, ACCESS = PUBLIC | PROTECTED | PRIVATE | INTERNAL, ALL = STATIC | ASYNC | ACCESS | DECLARE | READONLY | ABSTRACT, @@ -112,18 +110,20 @@ enum class BoxingUnboxingFlags : uint32_t { BOX_TO_LONG = 1U << 5U, BOX_TO_FLOAT = 1U << 6U, BOX_TO_DOUBLE = 1U << 7U, - UNBOX_TO_BOOLEAN = 1U << 8U, - UNBOX_TO_BYTE = 1U << 9U, - UNBOX_TO_SHORT = 1U << 10U, - UNBOX_TO_CHAR = 1U << 11U, - UNBOX_TO_INT = 1U << 12U, - UNBOX_TO_LONG = 1U << 13U, - UNBOX_TO_FLOAT = 1U << 14U, - UNBOX_TO_DOUBLE = 1U << 15U, + BOX_TO_ENUM = 1U << 8U, + UNBOX_TO_BOOLEAN = 1U << 9U, + UNBOX_TO_BYTE = 1U << 10U, + UNBOX_TO_SHORT = 1U << 11U, + UNBOX_TO_CHAR = 1U << 12U, + UNBOX_TO_INT = 1U << 13U, + 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_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_FLOAT | UNBOX_TO_DOUBLE | UNBOX_TO_ENUM, }; } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/base/classElement.h b/ets2panda/ir/base/classElement.h index 8ef3b02dd7ac1c6651ade1bc134224ebeda278c7..cc7061343181239762ac410ca8b1edd122386909 100644 --- a/ets2panda/ir/base/classElement.h +++ b/ets2panda/ir/base/classElement.h @@ -17,6 +17,7 @@ #define ES2PANDA_PARSER_INCLUDE_AST_CLASS_ELEMENT_H #include "ir/statement.h" +#include "ir/typed.h" namespace ark::es2panda::ir { class Expression; diff --git a/ets2panda/ir/base/classProperty.cpp b/ets2panda/ir/base/classProperty.cpp index 7a07160d7b9125d8f7f12ac3ae74529346f9d1e1..a2217e79f9d9b55cfc1cc7632c308dfcfbf36d12 100644 --- a/ets2panda/ir/base/classProperty.cpp +++ b/ets2panda/ir/base/classProperty.cpp @@ -110,6 +110,10 @@ void ClassProperty::Dump(ir::SrcDumper *dumper) const key_->Dump(dumper); } + if (IsOptionalDeclaration()) { + dumper->Add("?"); + } + if (typeAnnotation_ != nullptr) { dumper->Add(": "); typeAnnotation_->Dump(dumper); @@ -121,6 +125,7 @@ void ClassProperty::Dump(ir::SrcDumper *dumper) const } dumper->Add(";"); + dumper->Endl(); } void ClassProperty::Compile(compiler::PandaGen *pg) const diff --git a/ets2panda/ir/base/scriptFunction.cpp b/ets2panda/ir/base/scriptFunction.cpp index 818f0c08d68e5a7749847279c3e89c36e8f557c9..4f3eb479d2b583dc99bb7a9980547202ec1f6a22 100644 --- a/ets2panda/ir/base/scriptFunction.cpp +++ b/ets2panda/ir/base/scriptFunction.cpp @@ -120,7 +120,9 @@ void ScriptFunction::Iterate(const NodeTraverser &cb) const void ScriptFunction::SetReturnTypeAnnotation(TypeNode *node) noexcept { irSignature_.SetReturnType(node); - node->SetParent(this); + if (node != nullptr) { + node->SetParent(this); + } } void ScriptFunction::Dump(ir::AstDumper *dumper) const diff --git a/ets2panda/ir/base/tsSignatureDeclaration.h b/ets2panda/ir/base/tsSignatureDeclaration.h index 8524c7516ec8766bcc0fc9f950c62a40de637d0b..1ff286cc192622ac3623823e80dcf7a793c50a20 100644 --- a/ets2panda/ir/base/tsSignatureDeclaration.h +++ b/ets2panda/ir/base/tsSignatureDeclaration.h @@ -18,7 +18,7 @@ #include "ir/astNode.h" #include "ir/base/scriptFunctionSignature.h" -#include "ir/statement.h" +#include "ir/typed.h" namespace ark::es2panda::checker { class TSAnalyzer; diff --git a/ets2panda/ir/ets/etsParameterExpression.cpp b/ets2panda/ir/ets/etsParameterExpression.cpp index 4b15f70473ec16f9418ca5f77d5d922e25412676..df9262725b6fcfd50baaa98f671cbbb20eedd1d6 100644 --- a/ets2panda/ir/ets/etsParameterExpression.cpp +++ b/ets2panda/ir/ets/etsParameterExpression.cpp @@ -168,11 +168,8 @@ void ETSParameterExpression::Dump(ir::SrcDumper *const dumper) const } } if (initializer_ != nullptr) { - ASSERT(initializer_->IsNumberLiteral()); - if (initializer_->AsNumberLiteral()->Str().Length() > 0) { - dumper->Add(" = "); - initializer_->Dump(dumper); - } + dumper->Add(" = "); + initializer_->Dump(dumper); } } } diff --git a/ets2panda/ir/expression.h b/ets2panda/ir/expression.h index 9e982324c4f8bdd7ae508eaff2d2b124abf76814..4ab79d03beb2fe44b1d9c6fef24bb91a833a766d 100644 --- a/ets2panda/ir/expression.h +++ b/ets2panda/ir/expression.h @@ -17,6 +17,7 @@ #define ES2PANDA_IR_EXPRESSION_H #include "ir/astNode.h" +#include "ir/typed.h" namespace ark::es2panda::ir { class Literal; diff --git a/ets2panda/ir/statement.h b/ets2panda/ir/statement.h index 398e28ea23f1c02e2ea162059416444f75c9332d..e4304eba19525718abf02ea52b2e257419650bb4 100644 --- a/ets2panda/ir/statement.h +++ b/ets2panda/ir/statement.h @@ -42,44 +42,6 @@ protected: Statement(Statement const &other) : AstNode(static_cast(other)) {} }; -class TypedStatement : public Typed { -public: - TypedStatement() = delete; - ~TypedStatement() override = default; - - NO_COPY_OPERATOR(TypedStatement); - NO_MOVE_SEMANTIC(TypedStatement); - -protected: - explicit TypedStatement(AstNodeType type) : Typed(type) {}; - explicit TypedStatement(AstNodeType type, ModifierFlags flags) : Typed(type, flags) {}; - - TypedStatement(TypedStatement const &other) : Typed(static_cast const &>(other)) {} - - inline static checker::Type *const CHECKED = reinterpret_cast(0x01); -}; - -class AnnotatedStatement : public Annotated { -public: - AnnotatedStatement() = delete; - ~AnnotatedStatement() override = default; - - NO_COPY_OPERATOR(AnnotatedStatement); - NO_MOVE_SEMANTIC(AnnotatedStatement); - -protected: - explicit AnnotatedStatement(AstNodeType type, TypeNode *typeAnnotation) : Annotated(type, typeAnnotation) - { - } - - explicit AnnotatedStatement(AstNodeType type) : Annotated(type) {} - explicit AnnotatedStatement(AstNodeType type, ModifierFlags flags) : Annotated(type, flags) {} - - AnnotatedStatement(AnnotatedStatement const &other) - : Annotated(static_cast const &>(other)) - { - } -}; } // namespace ark::es2panda::ir #endif diff --git a/ets2panda/ir/statements/blockStatement.cpp b/ets2panda/ir/statements/blockStatement.cpp index 14c6f80c70edcb743a0906a8d2134248ca0ad0f4..0f0b7d01a36a7cebccda9f70599564a8e8b42468 100644 --- a/ets2panda/ir/statements/blockStatement.cpp +++ b/ets2panda/ir/statements/blockStatement.cpp @@ -34,6 +34,20 @@ void BlockStatement::TransformChildren(const NodeTransformer &cb, std::string_vi } } +AstNode *BlockStatement::Clone(ArenaAllocator *const allocator, AstNode *const parent) +{ + ArenaVector statements(allocator->Adapter()); + + for (auto *statement : this->statements_) { + statements.push_back(statement->Clone(allocator, parent)->AsStatement()); + } + + auto retVal = util::NodeAllocator::ForceSetParent(allocator, allocator, std::move(statements)); + retVal->SetParent(parent); + + return retVal; +} + void BlockStatement::Iterate(const NodeTraverser &cb) const { // This will survive pushing element to the back of statements_ in the process diff --git a/ets2panda/ir/statements/blockStatement.h b/ets2panda/ir/statements/blockStatement.h index 04fe521c868a6ac7a88b56cbff006414eef8a3af..94627554c0c95e6c776526507f929da5b4a67854 100644 --- a/ets2panda/ir/statements/blockStatement.h +++ b/ets2panda/ir/statements/blockStatement.h @@ -72,6 +72,8 @@ public: void TransformChildren(const NodeTransformer &cb, std::string_view transformationName) override; + AstNode *Clone(ArenaAllocator *const allocator, AstNode *const parent) override; + void Iterate(const NodeTraverser &cb) const override; void Dump(ir::AstDumper *dumper) const override; void Dump(ir::SrcDumper *dumper) const override; diff --git a/ets2panda/ir/ts/tsEnumDeclaration.h b/ets2panda/ir/ts/tsEnumDeclaration.h index 791b3460956568e9eb38b72fec1e802e1d4e913a..bd8c7cb5dcf87d517c3194c7ddf774f33598a341 100644 --- a/ets2panda/ir/ts/tsEnumDeclaration.h +++ b/ets2panda/ir/ts/tsEnumDeclaration.h @@ -100,6 +100,16 @@ public: internalName_ = internalName; } + ir::ClassDefinition *BoxedClass() const + { + return boxedClass_; + } + + void SetBoxedClass(ir::ClassDefinition *const wrapperClass) + { + boxedClass_ = wrapperClass; + } + bool IsConst() const { return isConst_; @@ -152,6 +162,7 @@ private: Identifier *key_; ArenaVector members_; util::StringView internalName_; + ir::ClassDefinition *boxedClass_ {nullptr}; bool isConst_; bool isDeclare_; }; diff --git a/ets2panda/ir/ts/tsInterfaceDeclaration.h b/ets2panda/ir/ts/tsInterfaceDeclaration.h index 3238a604d1b07d3a3a87912f64d0d488c9d4cd20..8f76200f65d944422b87ab737d91e59b13317833 100644 --- a/ets2panda/ir/ts/tsInterfaceDeclaration.h +++ b/ets2panda/ir/ts/tsInterfaceDeclaration.h @@ -167,6 +167,21 @@ public: return lang_; } + ClassDeclaration *GetAnonClass() noexcept + { + return anonClass_; + } + + ClassDeclaration *GetAnonClass() const noexcept + { + return anonClass_; + } + + void SetAnonClass(ClassDeclaration *anonClass) noexcept + { + anonClass_ = anonClass; + } + void Iterate(const NodeTraverser &cb) const override; void Dump(ir::AstDumper *dumper) const override; void Dump(ir::SrcDumper *dumper) const override; @@ -192,6 +207,7 @@ private: bool isStatic_; bool isExternal_; es2panda::Language lang_; + ClassDeclaration *anonClass_ {nullptr}; }; } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/ts/tsThisType.cpp b/ets2panda/ir/ts/tsThisType.cpp index d317d7253c28c26c19cf0f24e0c827d31d2bcf43..02f90d8077ec466f8dcc7db512b3c78d5f99fa4d 100644 --- a/ets2panda/ir/ts/tsThisType.cpp +++ b/ets2panda/ir/ts/tsThisType.cpp @@ -68,4 +68,19 @@ checker::Type *TSThisType::GetType([[maybe_unused]] checker::ETSChecker *checker { return checker->Context().ContainingClass(); } + +TSThisType *TSThisType::Clone(ArenaAllocator *const allocator, AstNode *const parent) +{ + if (auto *const clone = allocator->New(); clone != nullptr) { + if (parent != nullptr) { + clone->SetParent(parent); + } + + clone->SetRange(Range()); + return clone; + } + + throw Error(ErrorType::GENERIC, "", CLONE_ALLOCATION_ERROR); +} + } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/ts/tsThisType.h b/ets2panda/ir/ts/tsThisType.h index 23b24d26dc25108e9348572814f266b8a27e8be8..5ce3170b2784b08743896b321ada17a8df701584 100644 --- a/ets2panda/ir/ts/tsThisType.h +++ b/ets2panda/ir/ts/tsThisType.h @@ -33,6 +33,7 @@ public: checker::Type *GetType([[maybe_unused]] checker::TSChecker *checker) override; checker::Type *Check([[maybe_unused]] checker::ETSChecker *checker) override; checker::Type *GetType([[maybe_unused]] checker::ETSChecker *checker) override; + TSThisType *Clone(ArenaAllocator *allocator, AstNode *parent) override; void Accept(ASTVisitorT *v) override { diff --git a/ets2panda/ir/ts/tsTypeAliasDeclaration.h b/ets2panda/ir/ts/tsTypeAliasDeclaration.h index f00e94e3f1cb138ce96c13ed8015f99e9b4d379b..ba80fb5e4e33826deafdb879402dcb875024c324 100644 --- a/ets2panda/ir/ts/tsTypeAliasDeclaration.h +++ b/ets2panda/ir/ts/tsTypeAliasDeclaration.h @@ -17,6 +17,7 @@ #define ES2PANDA_IR_TS_TYPE_ALIAS_DECLARATION_H #include "ir/statement.h" +#include "ir/typed.h" namespace ark::es2panda::varbinder { class Variable; diff --git a/ets2panda/ir/typed.h b/ets2panda/ir/typed.h new file mode 100644 index 0000000000000000000000000000000000000000..7bf9428a214731974de115cc3ee5f98477d04edd --- /dev/null +++ b/ets2panda/ir/typed.h @@ -0,0 +1,164 @@ +/** + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ES2PANDA_IR_TYPED_H +#define ES2PANDA_IR_TYPED_H + +#include "ir/astNode.h" +#include "ir/statement.h" + +namespace ark::es2panda::checker { +// NOLINTBEGIN(readability-redundant-declaration) +bool IsTypeError(Type const *tp); +[[noreturn]] void ThrowEmptyError(); +// NOLINTEND(readability-redundant-declaration) +} // namespace ark::es2panda::checker + +namespace ark::es2panda::ir { + +template +class Typed : public T { +public: + Typed() = delete; + ~Typed() override = default; + + NO_COPY_OPERATOR(Typed); + NO_MOVE_SEMANTIC(Typed); + + [[nodiscard]] checker::Type const *TsType() const + { + if (UNLIKELY(IsTypeError(tsType_))) { + checker::ThrowEmptyError(); + } + return tsType_; + } + + [[nodiscard]] checker::Type const *TsTypeOrError() const noexcept + { + return tsType_; + } + + [[nodiscard]] checker::Type *TsType() + { + if (UNLIKELY(IsTypeError(tsType_))) { + checker::ThrowEmptyError(); + } + return tsType_; + } + + [[nodiscard]] checker::Type *TsTypeOrError() noexcept + { + return tsType_; + } + + void SetTsType(checker::Type *tsType) noexcept + { + tsType_ = tsType; + } + + bool IsTyped() const override + { + return true; + } + +protected: + explicit Typed(AstNodeType const type) : T(type) {} + explicit Typed(AstNodeType const type, ModifierFlags const flags) : T(type, flags) {} + + // NOTE: when cloning node its type is not copied but removed empty so that it can be re-checked further. + Typed(Typed const &other) : T(static_cast(other)) {} + +private: + checker::Type *tsType_ {}; +}; + +class TypedAstNode : public Typed { +public: + TypedAstNode() = delete; + ~TypedAstNode() override = default; + + NO_COPY_OPERATOR(TypedAstNode); + NO_MOVE_SEMANTIC(TypedAstNode); + +protected: + explicit TypedAstNode(AstNodeType const type) : Typed(type) {} + explicit TypedAstNode(AstNodeType const type, ModifierFlags const flags) : Typed(type, flags) {} + + TypedAstNode(TypedAstNode const &other) : Typed(static_cast const &>(other)) {} +}; + +class AnnotatedAstNode : public Annotated { +public: + AnnotatedAstNode() = delete; + ~AnnotatedAstNode() override = default; + + NO_COPY_OPERATOR(AnnotatedAstNode); + NO_MOVE_SEMANTIC(AnnotatedAstNode); + +protected: + explicit AnnotatedAstNode(AstNodeType const type, TypeNode *const typeAnnotation) + : Annotated(type, typeAnnotation) + { + } + explicit AnnotatedAstNode(AstNodeType const type) : Annotated(type) {} + explicit AnnotatedAstNode(AstNodeType const type, ModifierFlags const flags) : Annotated(type, flags) {} + + AnnotatedAstNode(AnnotatedAstNode const &other) : Annotated(static_cast const &>(other)) + { + } +}; + +class TypedStatement : public Typed { +public: + TypedStatement() = delete; + ~TypedStatement() override = default; + + NO_COPY_OPERATOR(TypedStatement); + NO_MOVE_SEMANTIC(TypedStatement); + +protected: + explicit TypedStatement(AstNodeType type) : Typed(type) {}; + explicit TypedStatement(AstNodeType type, ModifierFlags flags) : Typed(type, flags) {}; + + TypedStatement(TypedStatement const &other) : Typed(static_cast const &>(other)) {} + + inline static checker::Type *const CHECKED = reinterpret_cast(0x01); +}; + +class AnnotatedStatement : public Annotated { +public: + AnnotatedStatement() = delete; + ~AnnotatedStatement() override = default; + + NO_COPY_OPERATOR(AnnotatedStatement); + NO_MOVE_SEMANTIC(AnnotatedStatement); + +protected: + explicit AnnotatedStatement(AstNodeType type, TypeNode *typeAnnotation) : Annotated(type, typeAnnotation) + { + } + + explicit AnnotatedStatement(AstNodeType type) : Annotated(type) {} + explicit AnnotatedStatement(AstNodeType type, ModifierFlags flags) : Annotated(type, flags) {} + + AnnotatedStatement(AnnotatedStatement const &other) + : Annotated(static_cast const &>(other)) + { + } +}; + +} // namespace ark::es2panda::ir + +#endif diff --git a/ets2panda/lexer/ETSLexer.cpp b/ets2panda/lexer/ETSLexer.cpp index 607ae7b55267ec60d8cb60524810ca71cad61de4..1cbb947551fbb91544f29e6638bd085ad7ce0a6f 100644 --- a/ets2panda/lexer/ETSLexer.cpp +++ b/ets2panda/lexer/ETSLexer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - 2023 Huawei Device Co., Ltd. + * Copyright (c) 2021 - 2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -94,56 +94,6 @@ void ETSLexer::CheckUtf16Compatible(char32_t cp) const } } -void ETSLexer::SkipMultiLineComment() -{ - uint32_t depth = 1U; - - // Just to reduce extra nested level(s) - auto const checkAsterisk = [this, &depth]() -> bool { - if (Iterator().Peek() == LEX_CHAR_SLASH) { - Iterator().Forward(1); - - if (--depth == 0U) { - return false; - } - } - return true; - }; - - while (true) { - switch (Iterator().Next()) { - case util::StringView::Iterator::INVALID_CP: { - ThrowError("Unterminated multi-line comment"); - break; - } - case LEX_CHAR_LF: - case LEX_CHAR_CR: - case LEX_CHAR_LS: - case LEX_CHAR_PS: { - Pos().NextTokenLine()++; - continue; - } - case LEX_CHAR_ASTERISK: { - if (!checkAsterisk()) { - return; - } - break; - } - case LEX_CHAR_SLASH: { - if (Iterator().Peek() == LEX_CHAR_ASTERISK) { - Iterator().Forward(1); - depth++; - } - break; - } - - default: { - break; - } - } - } -} - void ETSLexer::ScanAsteriskPunctuator() { GetToken().type_ = TokenType::PUNCTUATOR_MULTIPLY; diff --git a/ets2panda/lexer/ETSLexer.h b/ets2panda/lexer/ETSLexer.h index 341c800aca7873dbb459351ac763f7a333cc22fa..71f734e3490dbffc29994a371998c089aed1c384 100644 --- a/ets2panda/lexer/ETSLexer.h +++ b/ets2panda/lexer/ETSLexer.h @@ -35,7 +35,6 @@ public: void NextToken(NextTokenFlags flags = NextTokenFlags::NONE) override; void ScanHashMark() override; bool ScanCharLiteral() override; - void SkipMultiLineComment() override; void ScanAsteriskPunctuator() override; void ScanNumberLeadingZero() override diff --git a/ets2panda/linter/scripts/update-test-results.sh b/ets2panda/linter/scripts/update-test-results.sh index de5c6e3bdffae05a3240b797caffd56accfd29a8..3f42932535299afd61da790265912991c40244c9 100644 --- a/ets2panda/linter/scripts/update-test-results.sh +++ b/ets2panda/linter/scripts/update-test-results.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright (c) 2023-2024 Huawei Device Co., Ltd. diff --git a/ets2panda/linter/test_linter.sh b/ets2panda/linter/test_linter.sh index f0eab4f460563fb02e19547a6976007e5ab0ed0f..5e5ccc907b582e307c75ca8867fb44f1fcc14dca 100644 --- a/ets2panda/linter/test_linter.sh +++ b/ets2panda/linter/test_linter.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright (c) 2022-2024 Huawei Device Co., Ltd. diff --git a/ets2panda/linter/tslinter.sh b/ets2panda/linter/tslinter.sh index 0758e211fa1e29db83934579972476b9cc1df294..e0d3b80221ba7a72af759bebef9c2f6b7b8d6117 100644 --- a/ets2panda/linter/tslinter.sh +++ b/ets2panda/linter/tslinter.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright (c) 2022-2024 Huawei Device Co., Ltd. diff --git a/ets2panda/public/es2panda_lib.cpp b/ets2panda/public/es2panda_lib.cpp index f1158a2149144c49af86d10d4ee5ab2f5cc7cea4..912dcafe44700b837b858f9bf0930742b75d11f9 100644 --- a/ets2panda/public/es2panda_lib.cpp +++ b/ets2panda/public/es2panda_lib.cpp @@ -433,6 +433,7 @@ static es2panda_Context *CreateContext(es2panda_Config *config, std::string cons res->parser = new parser::ETSParser(res->parserProgram, cfg->options->CompilerOptions(), parser::ParserStatus::NO_OPTS); res->checker = new checker::ETSChecker(); + res->checker->ErrorLogger()->SetOstream(nullptr); res->analyzer = new checker::ETSAnalyzer(res->checker); res->checker->SetAnalyzer(res->analyzer); @@ -545,6 +546,13 @@ static Context *Check(Context *ctx) ASSERT(ctx->state >= ES2PANDA_STATE_PARSED && ctx->state < ES2PANDA_STATE_CHECKED); + auto handleError = [ctx](Error const &e) { + std::stringstream ss; + ss << e.TypeString() << ": " << e.Message() << "[" << e.File() << ":" << e.Line() << "," << e.Col() << "]"; + ctx->errorMessage = ss.str(); + ctx->state = ES2PANDA_STATE_ERROR; + }; + try { do { if (ctx->currentPhase >= ctx->phases.size()) { @@ -553,12 +561,13 @@ static Context *Check(Context *ctx) ctx->phases[ctx->currentPhase]->Apply(ctx, ctx->parserProgram); } while (ctx->phases[ctx->currentPhase++]->Name() != compiler::CheckerPhase::NAME); - ctx->state = ES2PANDA_STATE_CHECKED; + if (ctx->checker->ErrorLogger()->IsAnyError()) { + handleError(ctx->checker->ErrorLogger()->Log()[0]); + } else { + ctx->state = ES2PANDA_STATE_CHECKED; + } } catch (Error &e) { - std::stringstream ss; - ss << e.TypeString() << ": " << e.Message() << "[" << e.File() << ":" << e.Line() << "," << e.Col() << "]"; - ctx->errorMessage = ss.str(); - ctx->state = ES2PANDA_STATE_ERROR; + handleError(e); } return ctx; } diff --git a/ets2panda/scripts/es2panda_coverage.sh b/ets2panda/scripts/es2panda_coverage.sh index f6a42ea5900d858a7e0cc6f7c66424dd01e58bf6..fe9a6949aee9be284c80de867fdaa1ba1b5af8df 100644 --- a/ets2panda/scripts/es2panda_coverage.sh +++ b/ets2panda/scripts/es2panda_coverage.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Copyright (c) 2023-2024 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ets2panda/test/compiler/ets/dynamic-equality-expected.txt b/ets2panda/test/compiler/ets/dynamic-equality-expected.txt index 9bb50cd36c0e639a58739c298580f39099bbd075..8ca21a759d1a417896d59290bf16d4efd46b7484 100644 --- a/ets2panda/test/compiler/ets/dynamic-equality-expected.txt +++ b/ets2panda/test/compiler/ets/dynamic-equality-expected.txt @@ -1414,6 +1414,19 @@ "async": false, "expression": false, "params": [], + "returnType": { + "type": "OpaqueType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "body": { "type": "BlockStatement", "statements": [], diff --git a/ets2panda/test/compiler/ets/dynamicJsImport-expected.txt b/ets2panda/test/compiler/ets/dynamicJsImport-expected.txt index df48da9663acc5d7a22608e58998c567db5d1af1..c44c0419101e1a60acc31d6e11c11799588ac41f 100644 --- a/ets2panda/test/compiler/ets/dynamicJsImport-expected.txt +++ b/ets2panda/test/compiler/ets/dynamicJsImport-expected.txt @@ -2900,6 +2900,19 @@ "async": false, "expression": false, "params": [], + "returnType": { + "type": "OpaqueType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "body": { "type": "BlockStatement", "statements": [], diff --git a/ets2panda/test/compiler/ets/dynamicLambda-expected.txt b/ets2panda/test/compiler/ets/dynamicLambda-expected.txt index 51c5059a1f34d7c07f891d8aec5fff118cb03bae..afa9b369ae138c746926e05b21acc17e1308a281 100644 --- a/ets2panda/test/compiler/ets/dynamicLambda-expected.txt +++ b/ets2panda/test/compiler/ets/dynamicLambda-expected.txt @@ -2165,6 +2165,19 @@ "async": false, "expression": false, "params": [], + "returnType": { + "type": "OpaqueType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "body": { "type": "BlockStatement", "statements": [], diff --git a/ets2panda/test/compiler/ets/dynamicLambdaJSValue-expected.txt b/ets2panda/test/compiler/ets/dynamicLambdaJSValue-expected.txt index 37fa1da0140f74b15f483a84b99a086c99456863..e9576be966fcb99fb3855402de07b9da738f2780 100644 --- a/ets2panda/test/compiler/ets/dynamicLambdaJSValue-expected.txt +++ b/ets2panda/test/compiler/ets/dynamicLambdaJSValue-expected.txt @@ -2362,6 +2362,19 @@ "async": false, "expression": false, "params": [], + "returnType": { + "type": "OpaqueType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "body": { "type": "BlockStatement", "statements": [], diff --git a/ets2panda/test/compiler/ets/dynamicObjectLiteral-expected.txt b/ets2panda/test/compiler/ets/dynamicObjectLiteral-expected.txt index 0a23031bbad92ccb34a2e62cb12b208c3868772d..9ee3de341e14352852c452ed5c6096c41d38fed6 100644 --- a/ets2panda/test/compiler/ets/dynamicObjectLiteral-expected.txt +++ b/ets2panda/test/compiler/ets/dynamicObjectLiteral-expected.txt @@ -892,6 +892,19 @@ "async": false, "expression": false, "params": [], + "returnType": { + "type": "OpaqueType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "body": { "type": "BlockStatement", "statements": [], diff --git a/ets2panda/test/compiler/ets/dynamic_call-expected.txt b/ets2panda/test/compiler/ets/dynamic_call-expected.txt index ec3db732b2e7661834e0f17113b24eb582d39be8..696d11f1fcd6f8634fcad53272866dda671f1586 100644 --- a/ets2panda/test/compiler/ets/dynamic_call-expected.txt +++ b/ets2panda/test/compiler/ets/dynamic_call-expected.txt @@ -2401,6 +2401,19 @@ "async": false, "expression": false, "params": [], + "returnType": { + "type": "OpaqueType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "body": { "type": "BlockStatement", "statements": [], diff --git a/ets2panda/test/compiler/ets/dynamic_instanceof_error-expected.txt b/ets2panda/test/compiler/ets/dynamic_instanceof_error-expected.txt index c1d6abeccf546d13369ff730d3c404f5e054fc76..31c259d53d8be2c1c5984298f7006ca88c63555c 100644 --- a/ets2panda/test/compiler/ets/dynamic_instanceof_error-expected.txt +++ b/ets2panda/test/compiler/ets/dynamic_instanceof_error-expected.txt @@ -1 +1,926 @@ TypeError: Bad operand type, the types of the operands must be same type. [dynamic_instanceof_error.sts:24:11] +{ + "type": "Program", + "statements": [ + { + "type": "ImportDeclaration", + "source": { + "type": "StringLiteral", + "value": "dynamic_js_import_tests", + "loc": { + "start": { + "line": 20, + "column": 20 + }, + "end": { + "line": 20, + "column": 45 + } + } + }, + "specifiers": [ + { + "type": "ImportSpecifier", + "local": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 10 + }, + "end": { + "line": 20, + "column": 11 + } + } + }, + "imported": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 10 + }, + "end": { + "line": 20, + "column": 11 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 10 + }, + "end": { + "line": 20, + "column": 11 + } + } + } + ], + "loc": { + "start": { + "line": 20, + "column": 1 + }, + "end": { + "line": 20, + "column": 45 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ETSGLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "foo", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 10 + }, + "end": { + "line": 22, + "column": 13 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "foo", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 10 + }, + "end": { + "line": 22, + "column": 13 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 22, + "column": 17 + }, + "end": { + "line": 22, + "column": 21 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "a", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 7 + }, + "end": { + "line": 23, + "column": 8 + } + } + }, + "init": { + "type": "NumberLiteral", + "value": 42, + "loc": { + "start": { + "line": 23, + "column": 11 + }, + "end": { + "line": 23, + "column": 13 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 7 + }, + "end": { + "line": 23, + "column": 13 + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 23, + "column": 3 + }, + "end": { + "line": 23, + "column": 14 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "b", + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 7 + }, + "end": { + "line": 24, + "column": 8 + } + } + }, + "init": { + "type": "BinaryExpression", + "operator": "instanceof", + "left": { + "type": "Identifier", + "name": "a", + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 11 + }, + "end": { + "line": 24, + "column": 12 + } + } + }, + "right": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 24 + }, + "end": { + "line": 24, + "column": 25 + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 24 + }, + "end": { + "line": 24, + "column": 26 + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 24 + }, + "end": { + "line": 24, + "column": 26 + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 11 + }, + "end": { + "line": 24, + "column": 26 + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 7 + }, + "end": { + "line": 24, + "column": 26 + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 24, + "column": 3 + }, + "end": { + "line": 24, + "column": 26 + } + } + } + ], + "loc": { + "start": { + "line": 22, + "column": 22 + }, + "end": { + "line": 25, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 13 + }, + "end": { + "line": 25, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 13 + }, + "end": { + "line": 25, + "column": 2 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 1 + }, + "end": { + "line": 25, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "$dynmodule", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "dynamic_js_import_tests0", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "public", + "static": true, + "readonly": true, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "OpaqueType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassStaticBlock", + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": true, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "$dynmodule", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "dynamic_js_import_tests0", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "JSRuntime", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "loadModule", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "StringLiteral", + "value": "dynamic_js_import_tests", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "init", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "OpaqueType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 26, + "column": 1 + } + } +} diff --git a/ets2panda/test/compiler/ets/dynamic_instanceof_error.sts b/ets2panda/test/compiler/ets/dynamic_instanceof_error.sts index f5458761d4082d0c9c7a4c3ab0978844fdc3eca5..14847ca7149080c914d0f31177b75dd86243a524 100644 --- a/ets2panda/test/compiler/ets/dynamic_instanceof_error.sts +++ b/ets2panda/test/compiler/ets/dynamic_instanceof_error.sts @@ -19,7 +19,7 @@ flags: [dynamic-ast] import { A, } from "dynamic_js_import_tests" -function foo(): int { +function foo(): void { let a = 42; let b = a instanceof A; } 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 0c303048cfa53a9ed2b9c382724fecd80a2ec2f6..595942beb1d9a0440cd248bd07f5194cbc5b2b22 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 @@ -1390,12 +1390,56 @@ "column": 1 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ { "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -1408,52 +1452,44 @@ } } }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "Red", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "StringLiteral", - "value": "Green", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "accessibility": "protected", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 }, - { - "type": "StringLiteral", - "value": "Blue", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "end": { + "line": 1, + "column": 1 } - ], + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "", + "decorators": [], "loc": { "start": { "line": 1, @@ -1465,33 +1501,37 @@ } } }, + "kind": "method", "accessibility": "public", "static": true, - "readonly": false, - "declare": false, "optional": false, "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], "loc": { "start": { "line": 1, @@ -1525,7 +1565,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -1542,7 +1582,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -1555,9 +1595,9 @@ } } }, - "kind": "method", + "kind": "constructor", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -1566,7 +1606,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -1589,35 +1629,7 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1653,75 +1665,18 @@ } } ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, "body": { "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color#NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", "loc": { "start": { "line": 1, @@ -1733,8 +1688,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -1746,6 +1703,23 @@ } } }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -1757,8 +1731,6 @@ } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 1, @@ -1829,10 +1801,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#valueOf", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1845,19 +1817,12 @@ } } }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "#Color#valueOf", - "decorators": [], + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "Red", "loc": { "start": { "line": 1, @@ -1869,99 +1834,62 @@ } } }, - "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": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + { + "type": "StringLiteral", + "value": "Green", + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + }, + { + "type": "StringLiteral", + "value": "Blue", + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], "loc": { "start": { "line": 1, @@ -1984,58 +1912,3427 @@ } } }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ForUpdateStatement", - "init": { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "init": { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "kind": "let", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "NumberLiteral", + "value": 2, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "0", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "1", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "2", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Green", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Blue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "BoxedItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Green", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Blue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getName", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "valueOf", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ForUpdateStatement", + "init": { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "init": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "update": { + "type": "UpdateExpression", + "operator": "++", + "prefix": true, + "argument": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "==", + "left": { + "type": "Identifier", + "name": "name", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "alternate": null, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant Color.", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "name", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + "throwMarker": "throws", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getValue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getValue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "e", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "e", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "toString", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "values", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "fromInt", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "fromInt", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "alternate": null, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant in Color with ordinal value ", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + "throwMarker": "throws", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "unbox", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "unbox", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "boxedfromInt", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -2047,12 +5344,82 @@ } } }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "IfStatement", "test": { "type": "BinaryExpression", "operator": "<", "left": { "type": "Identifier", - "name": "i", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2069,7 +5436,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -2121,172 +5488,29 @@ } } }, - "update": { - "type": "UpdateExpression", - "operator": "++", - "prefix": true, + "consequent": { + "type": "ReturnStatement", "argument": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "body": { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "==", - "left": { + "type": "MemberExpression", + "object": { "type": "Identifier", - "name": "name", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { "line": 1, "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color#NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "consequent": { - "type": "ReturnStatement", - "argument": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -2298,6 +5522,8 @@ } } }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -2309,7 +5535,6 @@ } } }, - "alternate": null, "loc": { "start": { "line": 1, @@ -2321,6 +5546,7 @@ } } }, + "alternate": null, "loc": { "start": { "line": 1, @@ -2383,7 +5609,7 @@ "operator": "+", "left": { "type": "StringLiteral", - "value": "No enum constant Color.", + "value": "No enum constant in Color with ordinal value ", "loc": { "start": { "line": 1, @@ -2397,7 +5623,7 @@ }, "right": { "type": "Identifier", - "name": "name", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2491,12 +5717,56 @@ "column": 1 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "#Shape", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ { "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#ValuesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2509,26 +5779,68 @@ } } }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "accessibility": "protected", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 }, - { - "type": "NumberLiteral", - "value": 1, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], "loc": { "start": { "line": 1, @@ -2540,9 +5852,13 @@ } } }, - { - "type": "NumberLiteral", - "value": 2, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], "loc": { "start": { "line": 1, @@ -2553,29 +5869,7 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -2598,7 +5892,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2615,7 +5909,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#getValue", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -2628,9 +5922,9 @@ } } }, - "kind": "method", + "kind": "constructor", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -2639,7 +5933,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#getValue", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -2660,37 +5954,9 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "e", + "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -2719,54 +5985,25 @@ "line": 1, "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color#ValuesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "e", - "decorators": [], + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", "loc": { "start": { "line": 1, @@ -2778,8 +6015,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -2791,6 +6030,23 @@ } } }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -2802,8 +6058,6 @@ } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 1, @@ -2877,7 +6131,7 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#StringValuesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -2895,7 +6149,7 @@ "elements": [ { "type": "StringLiteral", - "value": "0", + "value": "Circle", "loc": { "start": { "line": 1, @@ -2909,7 +6163,7 @@ }, { "type": "StringLiteral", - "value": "1", + "value": "Square", "loc": { "start": { "line": 1, @@ -2923,7 +6177,7 @@ }, { "type": "StringLiteral", - "value": "2", + "value": "Triangle", "loc": { "start": { "line": 1, @@ -2947,7 +6201,7 @@ } } }, - "accessibility": "public", + "accessibility": "protected", "static": true, "readonly": false, "declare": false, @@ -3021,10 +6275,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#toString", + "name": "StringValuesArray", "decorators": [], "loc": { "start": { @@ -3037,19 +6291,12 @@ } } }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "#Color#toString", - "decorators": [], + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "CIRCLE", "loc": { "start": { "line": 1, @@ -3061,209 +6308,73 @@ } } }, - "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": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + { + "type": "StringLiteral", + "value": "SQUARE", "loc": { "start": { "line": 1, "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color#StringValuesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "TRIANGLE", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], + }, "loc": { "start": { "line": 1, @@ -3297,7 +6408,7 @@ } } }, - "overloads": [], + "definite": false, "decorators": [], "loc": { "start": { @@ -3314,7 +6425,7 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#ItemsArray", + "name": "ItemsArray", "decorators": [], "loc": { "start": { @@ -3334,7 +6445,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "Color", + "name": "Shape", "decorators": [], "loc": { "start": { @@ -3349,7 +6460,7 @@ }, "property": { "type": "Identifier", - "name": "Red", + "name": "Circle", "decorators": [], "loc": { "start": { @@ -3379,7 +6490,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "Color", + "name": "Shape", "decorators": [], "loc": { "start": { @@ -3394,7 +6505,7 @@ }, "property": { "type": "Identifier", - "name": "Green", + "name": "Square", "decorators": [], "loc": { "start": { @@ -3424,7 +6535,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "Color", + "name": "Shape", "decorators": [], "loc": { "start": { @@ -3439,7 +6550,7 @@ }, "property": { "type": "Identifier", - "name": "Blue", + "name": "Triangle", "decorators": [], "loc": { "start": { @@ -3477,7 +6588,7 @@ } } }, - "accessibility": "public", + "accessibility": "protected", "static": true, "readonly": false, "declare": false, @@ -3491,7 +6602,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Color", + "name": "Shape", "decorators": [], "loc": { "start": { @@ -3551,187 +6662,10 @@ } }, { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "#Color#values", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "#Color#values", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "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": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "#Color#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#fromInt", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -3744,41 +6678,19 @@ } } }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "#Color#fromInt", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSPrimitiveType", + "type": "ArrayExpression", + "elements": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Shape", + "decorators": [], "loc": { "start": { "line": 1, @@ -3790,7 +6702,6 @@ } } }, - "decorators": [], "loc": { "start": { "line": 1, @@ -3812,16 +6723,112 @@ "column": 1 } } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Shape", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Circle", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Shape", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -3844,28 +6851,14 @@ } } }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ + "arguments": [ { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "<", - "left": { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { "type": "Identifier", - "name": "ordinal", + "name": "Shape", "decorators": [], "loc": { "start": { @@ -3878,40 +6871,10 @@ } } }, - "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "length", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, + "property": { + "type": "Identifier", + "name": "Square", + "decorators": [], "loc": { "start": { "line": 1, @@ -3923,6 +6886,8 @@ } } }, + "computed": false, + "optional": false, "loc": { "start": { "line": 1, @@ -3933,54 +6898,53 @@ "column": 1 } } - }, - "consequent": { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Shape", + "decorators": [], "loc": { "start": { "line": 1, @@ -3992,7 +6956,6 @@ } } }, - "alternate": null, "loc": { "start": { "line": 1, @@ -4004,40 +6967,26 @@ } } }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ { - "type": "ThrowStatement", - "argument": { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Exception", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Shape", + "decorators": [], "loc": { "start": { "line": 1, @@ -4049,51 +6998,36 @@ } } }, - "arguments": [ - { - "type": "BinaryExpression", - "operator": "+", - "left": { - "type": "StringLiteral", - "value": "No enum constant in Color with ordinal value ", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "right": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "property": { + "type": "Identifier", + "name": "Triangle", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -4111,110 +7045,12 @@ "column": 1 }, "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - "throwMarker": "throws", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#Shape#NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "Circle", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "StringLiteral", - "value": "Square", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 + "line": 1, + "column": 1 + } + } } - } - }, - { - "type": "StringLiteral", - "value": "Triangle", + ], "loc": { "start": { "line": 1, @@ -4238,7 +7074,7 @@ } } }, - "accessibility": "public", + "accessibility": "protected", "static": true, "readonly": false, "declare": false, @@ -4252,7 +7088,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "#Shape", "decorators": [], "loc": { "start": { @@ -4315,7 +7151,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Shape#getName", + "name": "getName", "decorators": [], "loc": { "start": { @@ -4339,7 +7175,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Shape#getName", + "name": "getName", "decorators": [], "loc": { "start": { @@ -4476,7 +7312,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Shape#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -4605,7 +7441,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Shape#valueOf", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -4629,7 +7465,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Shape#valueOf", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -4842,7 +7678,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Shape#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -4948,7 +7784,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Shape#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -5194,7 +8030,298 @@ } } } - ], + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + "throwMarker": "throws", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "toString", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -5228,8 +8355,7 @@ "column": 1 } } - } - "throwMarker": "throws", + }, "loc": { "start": { "line": 1, @@ -5266,10 +8392,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Shape#StringValuesArray", + "name": "values", "decorators": [], "loc": { "start": { @@ -5282,12 +8408,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "CIRCLE", + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "values", + "decorators": [], "loc": { "start": { "line": 1, @@ -5299,23 +8432,53 @@ } } }, - { - "type": "StringLiteral", - "value": "SQUARE", - "loc": { - "start": { - "line": 1, - "column": 1 + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Shape", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - } - }, - { - "type": "StringLiteral", - "value": "TRIANGLE", + }, "loc": { "start": { "line": 1, @@ -5326,46 +8489,39 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -5399,7 +8555,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -5416,7 +8572,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Shape#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -5440,7 +8596,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Shape#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -5463,35 +8619,7 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Shape", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -5533,7 +8661,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "Shape", "decorators": [], "loc": { "start": { @@ -5572,12 +8700,13 @@ "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { "type": "Identifier", - "name": "#Shape#StringValuesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -5590,11 +8719,69 @@ } } }, - "property": { - "type": "TSAsExpression", - "expression": { + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { "type": "Identifier", - "name": "ordinal", + "name": "ItemsArray", "decorators": [], "loc": { "start": { @@ -5607,8 +8794,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -5620,6 +8809,8 @@ } } }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -5631,8 +8822,6 @@ } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 1, @@ -5644,258 +8833,131 @@ } } }, + "alternate": null, "loc": { "start": { "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#Shape#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Shape", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Circle", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Shape", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Square", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Shape", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Triangle", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Shape", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant in Shape with ordinal value ", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -5906,7 +8968,8 @@ "column": 1 } } - }, + } + "throwMarker": "throws", "loc": { "start": { "line": 1, @@ -5929,7 +8992,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -5946,7 +9009,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Shape#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -5961,7 +9024,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -5970,7 +9033,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Shape#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -5988,26 +9051,13 @@ "expression": false, "params": [], "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Shape", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Shape", + "decorators": [], "loc": { "start": { "line": 1, @@ -6047,9 +9097,67 @@ { "type": "ReturnStatement", "argument": { - "type": "Identifier", - "name": "#Shape#ItemsArray", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -6123,7 +9231,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Shape#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -6147,7 +9255,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Shape#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -6212,7 +9320,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Shape", + "name": "#Shape", "decorators": [], "loc": { "start": { @@ -6274,7 +9382,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Shape#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -6332,7 +9440,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Shape#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { diff --git a/ets2panda/test/compiler/ets/enum_as_type_alias-expected.txt b/ets2panda/test/compiler/ets/enum_as_type_alias-expected.txt index 16787cdb3ab67d2d14f24822c34f2db8a3c69ee7..bf6adeae07d8a608871b882abc697a64e585f0e7 100644 --- a/ets2panda/test/compiler/ets/enum_as_type_alias-expected.txt +++ b/ets2panda/test/compiler/ets/enum_as_type_alias-expected.txt @@ -709,12 +709,56 @@ "column": 2 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ { "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -727,52 +771,44 @@ } } }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "Red", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "StringLiteral", - "value": "Green", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "accessibility": "protected", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 }, - { - "type": "StringLiteral", - "value": "Blue", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "end": { + "line": 1, + "column": 1 } - ], + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "", + "decorators": [], "loc": { "start": { "line": 1, @@ -784,33 +820,37 @@ } } }, + "kind": "method", "accessibility": "public", "static": true, - "readonly": false, - "declare": false, "optional": false, "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], "loc": { "start": { "line": 1, @@ -844,7 +884,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -861,7 +901,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -874,9 +914,9 @@ } } }, - "kind": "method", + "kind": "constructor", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -885,7 +925,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -908,12 +948,68 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { "type": "Identifier", - "name": "Color", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -926,6 +1022,23 @@ } } }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -948,7 +1061,6 @@ } } }, - "decorators": [], "loc": { "start": { "line": 1, @@ -959,49 +1071,91 @@ "column": 1 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "Red", + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } - }, + } + }, + { + "type": "StringLiteral", + "value": "Green", "loc": { "start": { "line": 1, @@ -1013,94 +1167,59 @@ } } }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color#NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + { + "type": "StringLiteral", + "value": "Blue", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], + }, "loc": { "start": { "line": 1, @@ -1134,7 +1253,7 @@ } } }, - "overloads": [], + "definite": false, "decorators": [], "loc": { "start": { @@ -1148,10 +1267,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#valueOf", + "name": "ValuesArray", "decorators": [], "loc": { "start": { @@ -1164,18 +1283,1300 @@ } } }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { + "type": "ArrayExpression", + "elements": [ + { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "NumberLiteral", + "value": 2, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "0", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "1", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "2", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Green", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Blue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "BoxedItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Green", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Blue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getName", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "valueOf", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { "type": "Identifier", - "name": "#Color#valueOf", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -1388,7 +2789,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1494,7 +2895,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1812,10 +3213,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#ValuesArray", + "name": "getValue", "decorators": [], "loc": { "start": { @@ -1828,12 +3229,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumberLiteral", - "value": 0, + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getValue", + "decorators": [], "loc": { "start": { "line": 1, @@ -1845,9 +3253,82 @@ } } }, - { - "type": "NumberLiteral", - "value": 1, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "e", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1859,9 +3340,94 @@ } } }, - { - "type": "NumberLiteral", - "value": 2, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "e", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], "loc": { "start": { "line": 1, @@ -1872,29 +3438,7 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1917,7 +3461,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -1934,7 +3478,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -1958,7 +3502,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -1979,7 +3523,7 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "e", + "name": "ordinal", "typeAnnotation": { "type": "ETSTypeReference", "part": { @@ -2046,7 +3590,35 @@ } ], "returnType": { - "type": "ETSPrimitiveType", + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -2067,7 +3639,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#ValuesArray", + "name": "StringValuesArray", "decorators": [], "loc": { "start": { @@ -2084,7 +3656,7 @@ "type": "TSAsExpression", "expression": { "type": "Identifier", - "name": "e", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2193,10 +3765,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#StringValuesArray", + "name": "values", "decorators": [], "loc": { "start": { @@ -2209,12 +3781,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "0", + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "values", + "decorators": [], "loc": { "start": { "line": 1, @@ -2226,23 +3805,53 @@ } } }, - { - "type": "StringLiteral", - "value": "1", - "loc": { - "start": { - "line": 1, - "column": 1 + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - } - }, - { - "type": "StringLiteral", - "value": "2", + }, "loc": { "start": { "line": 1, @@ -2253,46 +3862,39 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -2326,7 +3928,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2343,7 +3945,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -2367,7 +3969,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -2390,35 +3992,7 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -2460,7 +4034,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "Color", "decorators": [], "loc": { "start": { @@ -2499,12 +4073,13 @@ "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { "type": "Identifier", - "name": "#Color#StringValuesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2517,11 +4092,69 @@ } } }, - "property": { - "type": "TSAsExpression", - "expression": { + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { "type": "Identifier", - "name": "ordinal", + "name": "ItemsArray", "decorators": [], "loc": { "start": { @@ -2534,8 +4167,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -2547,6 +4182,8 @@ } } }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -2558,8 +4195,6 @@ } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 1, @@ -2571,6 +4206,7 @@ } } }, + "alternate": null, "loc": { "start": { "line": 1, @@ -2579,250 +4215,122 @@ "end": { "line": 1, "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#Color#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Red", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Green", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Blue", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 + } } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant in Color with ordinal value ", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -2833,7 +4341,8 @@ "column": 1 } } - }, + } + "throwMarker": "throws", "loc": { "start": { "line": 1, @@ -2856,7 +4365,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2873,7 +4382,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -2888,7 +4397,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -2897,7 +4406,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -2915,26 +4424,13 @@ "expression": false, "params": [], "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], "loc": { "start": { "line": 1, @@ -2974,9 +4470,67 @@ { "type": "ReturnStatement", "argument": { - "type": "Identifier", - "name": "#Color#ItemsArray", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -3050,7 +4604,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -3074,7 +4628,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -3139,7 +4693,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Color", + "name": "#Color", "decorators": [], "loc": { "start": { @@ -3201,7 +4755,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -3259,7 +4813,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { diff --git a/ets2panda/test/compiler/ets/enums_01-expected.txt b/ets2panda/test/compiler/ets/enums_01-expected.txt index da57f84e1a031340ec3737841728f9f4265354dc..942382ff8128e811a3ecb8845b3c0302851b3b82 100644 --- a/ets2panda/test/compiler/ets/enums_01-expected.txt +++ b/ets2panda/test/compiler/ets/enums_01-expected.txt @@ -2366,12 +2366,56 @@ "column": 2 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "#E1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ { "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#E1#NamesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2384,66 +2428,44 @@ } } }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "e1_item1", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "StringLiteral", - "value": "e1_item2", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "StringLiteral", - "value": "e1_item3", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "accessibility": "protected", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 }, - { - "type": "StringLiteral", - "value": "e1_item4", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "end": { + "line": 1, + "column": 1 } - ], + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "", + "decorators": [], "loc": { "start": { "line": 1, @@ -2455,33 +2477,37 @@ } } }, + "kind": "method", "accessibility": "public", "static": true, - "readonly": false, - "declare": false, "optional": false, "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], "loc": { "start": { "line": 1, @@ -2515,7 +2541,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2532,7 +2558,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#E1#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -2545,9 +2571,9 @@ } } }, - "kind": "method", + "kind": "constructor", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -2556,7 +2582,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#E1#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -2579,35 +2605,7 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "E1", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -2643,75 +2641,18 @@ } } ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, "body": { "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#E1#NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", "loc": { "start": { "line": 1, @@ -2723,8 +2664,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -2736,6 +2679,23 @@ } } }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -2747,8 +2707,6 @@ } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 1, @@ -2819,10 +2777,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#E1#valueOf", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -2835,19 +2793,12 @@ } } }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "#E1#valueOf", - "decorators": [], + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "e1_item1", "loc": { "start": { "line": 1, @@ -2859,99 +2810,76 @@ } } }, - "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": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + { + "type": "StringLiteral", + "value": "e1_item2", + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "E1", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + }, + { + "type": "StringLiteral", + "value": "e1_item3", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "e1_item4", + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], "loc": { "start": { "line": 1, @@ -2974,40 +2902,1713 @@ } } }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ForUpdateStatement", - "init": { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "init": { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "NumberLiteral", + "value": 7, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "NumberLiteral", + "value": 8, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "0", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "7", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "8", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "1", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "E1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "e1_item1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "E1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "e1_item2", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "E1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "e1_item3", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "E1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "e1_item4", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "E1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "BoxedItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#E1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "E1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "e1_item1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#E1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "E1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "e1_item2", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#E1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "E1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "e1_item3", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#E1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "E1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "e1_item4", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#E1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getName", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "E1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "valueOf", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "E1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ForUpdateStatement", + "init": { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "init": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { "line": 1, "column": 1 } @@ -3059,7 +4660,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#E1#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -3165,7 +4766,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#E1#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -3483,10 +5084,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#E1#ValuesArray", + "name": "getValue", "decorators": [], "loc": { "start": { @@ -3499,12 +5100,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumberLiteral", - "value": 0, + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getValue", + "decorators": [], "loc": { "start": { "line": 1, @@ -3516,23 +5124,82 @@ } } }, - { - "type": "NumberLiteral", - "value": 7, - "loc": { - "start": { - "line": 1, - "column": 1 + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "e", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "E1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, - { - "type": "NumberLiteral", - "value": 8, + ], + "returnType": { + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -3544,9 +5211,94 @@ } } }, - { - "type": "NumberLiteral", - "value": 1, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "e", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], "loc": { "start": { "line": 1, @@ -3557,29 +5309,7 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -3602,7 +5332,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -3619,7 +5349,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#E1#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -3643,7 +5373,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#E1#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -3664,7 +5394,7 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "e", + "name": "ordinal", "typeAnnotation": { "type": "ETSTypeReference", "part": { @@ -3731,7 +5461,35 @@ } ], "returnType": { - "type": "ETSPrimitiveType", + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -3752,7 +5510,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#E1#ValuesArray", + "name": "StringValuesArray", "decorators": [], "loc": { "start": { @@ -3769,7 +5527,7 @@ "type": "TSAsExpression", "expression": { "type": "Identifier", - "name": "e", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -3878,10 +5636,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#E1#StringValuesArray", + "name": "values", "decorators": [], "loc": { "start": { @@ -3894,26 +5652,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "0", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "StringLiteral", - "value": "7", + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "values", + "decorators": [], "loc": { "start": { "line": 1, @@ -3925,23 +5676,53 @@ } } }, - { - "type": "StringLiteral", - "value": "8", - "loc": { - "start": { - "line": 1, - "column": 1 + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "E1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - } - }, - { - "type": "StringLiteral", - "value": "1", + }, "loc": { "start": { "line": 1, @@ -3952,46 +5733,39 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -4025,7 +5799,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -4042,7 +5816,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#E1#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -4066,7 +5840,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#E1#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -4089,35 +5863,7 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "E1", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -4159,7 +5905,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "E1", "decorators": [], "loc": { "start": { @@ -4198,12 +5944,13 @@ "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { "type": "Identifier", - "name": "#E1#StringValuesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -4215,12 +5962,70 @@ "column": 1 } } - }, - "property": { - "type": "TSAsExpression", - "expression": { + }, + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { "type": "Identifier", - "name": "ordinal", + "name": "ItemsArray", "decorators": [], "loc": { "start": { @@ -4233,8 +6038,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -4246,6 +6053,8 @@ } } }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -4257,8 +6066,6 @@ } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 1, @@ -4270,6 +6077,7 @@ } } }, + "alternate": null, "loc": { "start": { "line": 1, @@ -4278,295 +6086,122 @@ "end": { "line": 1, "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#E1#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "E1", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "e1_item1", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "E1", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "e1_item2", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "E1", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "e1_item3", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "E1", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "e1_item4", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 + } } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "E1", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant in E1 with ordinal value ", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -4577,7 +6212,8 @@ "column": 1 } } - }, + } + "throwMarker": "throws", "loc": { "start": { "line": 1, @@ -4600,7 +6236,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -4617,7 +6253,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#E1#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -4632,7 +6268,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -4641,7 +6277,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#E1#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -4659,26 +6295,13 @@ "expression": false, "params": [], "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "E1", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "E1", + "decorators": [], "loc": { "start": { "line": 1, @@ -4718,9 +6341,67 @@ { "type": "ReturnStatement", "argument": { - "type": "Identifier", - "name": "#E1#ItemsArray", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -4794,7 +6475,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#E1#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -4818,7 +6499,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#E1#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -4883,7 +6564,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "E1", + "name": "#E1", "decorators": [], "loc": { "start": { @@ -4945,7 +6626,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#E1#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -5003,7 +6684,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#E1#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { diff --git a/ets2panda/test/compiler/ets/from-soft-keyword-3-expected.txt b/ets2panda/test/compiler/ets/from-soft-keyword-3-expected.txt index 6f519fe4274a2d65059ffb5a53be2a5be44f3c05..c259f246de3eac8ebda43e0bfd40c7d6b2fa9c3f 100644 --- a/ets2panda/test/compiler/ets/from-soft-keyword-3-expected.txt +++ b/ets2panda/test/compiler/ets/from-soft-keyword-3-expected.txt @@ -508,12 +508,56 @@ "column": 2 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "#from", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ { "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#from#NamesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -526,52 +570,44 @@ } } }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "from", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "StringLiteral", - "value": "from1", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "accessibility": "protected", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 }, - { - "type": "StringLiteral", - "value": "from2", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "end": { + "line": 1, + "column": 1 } - ], + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "", + "decorators": [], "loc": { "start": { "line": 1, @@ -583,33 +619,37 @@ } } }, + "kind": "method", "accessibility": "public", "static": true, - "readonly": false, - "declare": false, "optional": false, "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], "loc": { "start": { "line": 1, @@ -643,7 +683,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -660,7 +700,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#from#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -673,9 +713,9 @@ } } }, - "kind": "method", + "kind": "constructor", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -684,7 +724,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#from#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -707,12 +747,68 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { "type": "Identifier", - "name": "from", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -725,6 +821,23 @@ } } }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -747,7 +860,6 @@ } } }, - "decorators": [], "loc": { "start": { "line": 1, @@ -758,49 +870,91 @@ "column": 1 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "from", + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } - }, + } + }, + { + "type": "StringLiteral", + "value": "from1", "loc": { "start": { "line": 1, @@ -812,94 +966,59 @@ } } }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#from#NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + { + "type": "StringLiteral", + "value": "from2", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], + }, "loc": { "start": { "line": 1, @@ -933,7 +1052,7 @@ } } }, - "overloads": [], + "definite": false, "decorators": [], "loc": { "start": { @@ -947,10 +1066,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#from#valueOf", + "name": "ValuesArray", "decorators": [], "loc": { "start": { @@ -963,18 +1082,1300 @@ } } }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { + "type": "ArrayExpression", + "elements": [ + { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "NumberLiteral", + "value": 2, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "0", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "1", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "2", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "from", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "from", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "from", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "from1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "from", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "from2", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "from", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "BoxedItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#from", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "from", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "from", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#from", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "from", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "from1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#from", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "from", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "from2", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#from", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getName", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "from", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "valueOf", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { "type": "Identifier", - "name": "#from#valueOf", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -1187,7 +2588,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#from#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1293,7 +2694,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#from#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1611,10 +3012,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#from#ValuesArray", + "name": "getValue", "decorators": [], "loc": { "start": { @@ -1627,12 +3028,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumberLiteral", - "value": 0, + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getValue", + "decorators": [], "loc": { "start": { "line": 1, @@ -1644,9 +3052,82 @@ } } }, - { - "type": "NumberLiteral", - "value": 1, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "e", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "from", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1658,9 +3139,94 @@ } } }, - { - "type": "NumberLiteral", - "value": 2, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "e", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], "loc": { "start": { "line": 1, @@ -1671,29 +3237,7 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1716,7 +3260,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -1733,7 +3277,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#from#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -1757,7 +3301,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#from#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -1778,7 +3322,7 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "e", + "name": "ordinal", "typeAnnotation": { "type": "ETSTypeReference", "part": { @@ -1845,7 +3389,35 @@ } ], "returnType": { - "type": "ETSPrimitiveType", + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -1866,7 +3438,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#from#ValuesArray", + "name": "StringValuesArray", "decorators": [], "loc": { "start": { @@ -1883,7 +3455,7 @@ "type": "TSAsExpression", "expression": { "type": "Identifier", - "name": "e", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -1992,10 +3564,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#from#StringValuesArray", + "name": "values", "decorators": [], "loc": { "start": { @@ -2008,12 +3580,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "0", + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "values", + "decorators": [], "loc": { "start": { "line": 1, @@ -2025,23 +3604,53 @@ } } }, - { - "type": "StringLiteral", - "value": "1", - "loc": { - "start": { - "line": 1, - "column": 1 + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "from", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - } - }, - { - "type": "StringLiteral", - "value": "2", + }, "loc": { "start": { "line": 1, @@ -2052,46 +3661,39 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -2125,7 +3727,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2142,7 +3744,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#from#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -2166,7 +3768,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#from#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -2189,35 +3791,7 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "from", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -2259,7 +3833,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "from", "decorators": [], "loc": { "start": { @@ -2298,12 +3872,13 @@ "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { "type": "Identifier", - "name": "#from#StringValuesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2316,11 +3891,69 @@ } } }, - "property": { - "type": "TSAsExpression", - "expression": { + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { "type": "Identifier", - "name": "ordinal", + "name": "ItemsArray", "decorators": [], "loc": { "start": { @@ -2333,8 +3966,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -2346,6 +3981,8 @@ } } }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -2357,8 +3994,6 @@ } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 1, @@ -2370,6 +4005,7 @@ } } }, + "alternate": null, "loc": { "start": { "line": 1, @@ -2378,250 +4014,122 @@ "end": { "line": 1, "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#from#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "from", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "from", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "from", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "from1", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "from", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "from2", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 + } } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "from", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant in from with ordinal value ", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -2632,7 +4140,8 @@ "column": 1 } } - }, + } + "throwMarker": "throws", "loc": { "start": { "line": 1, @@ -2655,7 +4164,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2672,7 +4181,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#from#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -2687,7 +4196,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -2696,7 +4205,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#from#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -2714,26 +4223,13 @@ "expression": false, "params": [], "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "from", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "from", + "decorators": [], "loc": { "start": { "line": 1, @@ -2773,9 +4269,67 @@ { "type": "ReturnStatement", "argument": { - "type": "Identifier", - "name": "#from#ItemsArray", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -2849,7 +4403,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#from#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -2873,7 +4427,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#from#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -2938,7 +4492,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "from", + "name": "#from", "decorators": [], "loc": { "start": { @@ -3000,7 +4554,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#from#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -3058,7 +4612,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#from#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { diff --git a/ets2panda/test/compiler/ets/generic_arrayaslist-expected.txt b/ets2panda/test/compiler/ets/generic_arrayaslist-expected.txt index f5d342c34ee5f690f299404a1589f3a527322176..4ca9a1c366b5569fffffdbffe582e6a753b7ff8f 100644 --- a/ets2panda/test/compiler/ets/generic_arrayaslist-expected.txt +++ b/ets2panda/test/compiler/ets/generic_arrayaslist-expected.txt @@ -10870,231 +10870,108 @@ "test": { "type": "CallExpression", "callee": { - "type": "MemberExpression", - "object": { - "type": "TSAsExpression", - "expression": { + "type": "Identifier", + "name": "__runtimeEquals", + "decorators": [], + "loc": { + "start": { + "line": 132, + "column": 17 + }, + "end": { + "line": 132, + "column": 32 + } + } + }, + "arguments": [ + { + "type": "MemberExpression", + "object": { "type": "MemberExpression", "object": { - "type": "MemberExpression", - "object": { - "type": "ThisExpression", - "loc": { - "start": { - "line": 132, - "column": 18 - }, - "end": { - "line": 132, - "column": 22 - } - } - }, - "property": { - "type": "Identifier", - "name": "data", - "decorators": [], - "loc": { - "start": { - "line": 132, - "column": 23 - }, - "end": { - "line": 132, - "column": 27 - } - } - }, - "computed": false, - "optional": false, + "type": "ThisExpression", "loc": { "start": { "line": 132, - "column": 18 + "column": 33 }, "end": { "line": 132, - "column": 27 + "column": 37 } } }, "property": { "type": "Identifier", - "name": "i", + "name": "data", "decorators": [], "loc": { "start": { "line": 132, - "column": 28 + "column": 38 }, "end": { "line": 132, - "column": 29 + "column": 42 } } }, - "computed": true, + "computed": false, "optional": false, "loc": { "start": { "line": 132, - "column": 18 + "column": 33 }, "end": { "line": 132, - "column": 30 + "column": 42 } } }, - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Object", - "decorators": [], - "loc": { - "start": { - "line": 132, - "column": 34 - }, - "end": { - "line": 132, - "column": 40 - } - } - }, - "loc": { - "start": { - "line": 132, - "column": 34 - }, - "end": { - "line": 132, - "column": 41 - } - } - }, + "property": { + "type": "Identifier", + "name": "i", + "decorators": [], "loc": { "start": { "line": 132, - "column": 34 + "column": 43 }, "end": { "line": 132, - "column": 41 + "column": 44 } } }, + "computed": true, + "optional": false, "loc": { "start": { "line": 132, - "column": 17 + "column": 33 }, "end": { "line": 132, - "column": 41 + "column": 45 } } }, - "property": { + { "type": "Identifier", - "name": "equals", + "name": "e", "decorators": [], "loc": { "start": { "line": 132, - "column": 42 + "column": 47 }, "end": { "line": 132, "column": 48 } } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 132, - "column": 17 - }, - "end": { - "line": 132, - "column": 48 - } - } - }, - "arguments": [ - { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "e", - "decorators": [], - "loc": { - "start": { - "line": 132, - "column": 49 - }, - "end": { - "line": 132, - "column": 50 - } - } - }, - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Object", - "decorators": [], - "loc": { - "start": { - "line": 132, - "column": 54 - }, - "end": { - "line": 132, - "column": 60 - } - } - }, - "loc": { - "start": { - "line": 132, - "column": 54 - }, - "end": { - "line": 132, - "column": 61 - } - } - }, - "loc": { - "start": { - "line": 132, - "column": 54 - }, - "end": { - "line": 132, - "column": 61 - } - } - }, - "loc": { - "start": { - "line": 132, - "column": 49 - }, - "end": { - "line": 132, - "column": 50 - } - } } ], "optional": false, @@ -11105,7 +10982,7 @@ }, "end": { "line": 132, - "column": 61 + "column": 49 } } }, @@ -11143,7 +11020,7 @@ "loc": { "start": { "line": 132, - "column": 63 + "column": 51 }, "end": { "line": 134, diff --git a/ets2panda/test/compiler/ets/generic_arrayaslist.sts b/ets2panda/test/compiler/ets/generic_arrayaslist.sts index 4a08b5c2c4ca54c4b1f42fc5eba9438e16ab3230..33e480c871d95d03e533e4f2236471f699abb4c5 100644 --- a/ets2panda/test/compiler/ets/generic_arrayaslist.sts +++ b/ets2panda/test/compiler/ets/generic_arrayaslist.sts @@ -129,7 +129,7 @@ class ArrayAsListt implements Listt { assert false: "Not implemented: internal issue with calling equals"; for (let i = 0; i < this.curSize; ++i) { - if ((this.data[i] as Object).equals(e as Object)) { + if (__runtimeEquals(this.data[i], e)) { return true; } } diff --git a/ets2panda/test/compiler/ets/generics_instantiation_3-expected.txt b/ets2panda/test/compiler/ets/generics_instantiation_3-expected.txt index 757b511447bd11725f24df836c17194d92bcb295..94e90ddeb9bb4aeaedd8adc2e69128e35ec612e8 100644 --- a/ets2panda/test/compiler/ets/generics_instantiation_3-expected.txt +++ b/ets2panda/test/compiler/ets/generics_instantiation_3-expected.txt @@ -240,43 +240,14 @@ { "type": "ExpressionStatement", "expression": { - "type": "CallExpression", - "callee": { + "type": "BinaryExpression", + "operator": "==", + "left": { "type": "MemberExpression", "object": { "type": "MemberExpression", "object": { - "type": "MemberExpression", - "object": { - "type": "ThisExpression", - "loc": { - "start": { - "line": 18, - "column": 9 - }, - "end": { - "line": 18, - "column": 13 - } - } - }, - "property": { - "type": "Identifier", - "name": "data", - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 14 - }, - "end": { - "line": 18, - "column": 18 - } - } - }, - "computed": false, - "optional": false, + "type": "ThisExpression", "loc": { "start": { "line": 18, @@ -284,25 +255,26 @@ }, "end": { "line": 18, - "column": 18 + "column": 13 } } }, "property": { - "type": "NumberLiteral", - "value": 2, + "type": "Identifier", + "name": "data", + "decorators": [], "loc": { "start": { "line": 18, - "column": 19 + "column": 14 }, "end": { "line": 18, - "column": 20 + "column": 18 } } }, - "computed": true, + "computed": false, "optional": false, "loc": { "start": { @@ -311,26 +283,25 @@ }, "end": { "line": 18, - "column": 21 + "column": 18 } } }, "property": { - "type": "Identifier", - "name": "equals", - "decorators": [], + "type": "NumberLiteral", + "value": 2, "loc": { "start": { "line": 18, - "column": 22 + "column": 19 }, "end": { "line": 18, - "column": 28 + "column": 20 } } }, - "computed": false, + "computed": true, "optional": false, "loc": { "start": { @@ -339,28 +310,25 @@ }, "end": { "line": 18, - "column": 28 + "column": 21 } } }, - "arguments": [ - { - "type": "Identifier", - "name": "e", - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 29 - }, - "end": { - "line": 18, - "column": 30 - } + "right": { + "type": "Identifier", + "name": "e", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 25 + }, + "end": { + "line": 18, + "column": 26 } } - ], - "optional": false, + }, "loc": { "start": { "line": 18, @@ -368,7 +336,7 @@ }, "end": { "line": 18, - "column": 31 + "column": 26 } } }, @@ -379,7 +347,7 @@ }, "end": { "line": 18, - "column": 32 + "column": 27 } } } diff --git a/ets2panda/test/compiler/ets/generics_instantiation_3.sts b/ets2panda/test/compiler/ets/generics_instantiation_3.sts index 6a6fe0e309614d38a9ee0d6062f82a72009986be..eefe579d4755ffa8f485589ad913092c30e43b87 100644 --- a/ets2panda/test/compiler/ets/generics_instantiation_3.sts +++ b/ets2panda/test/compiler/ets/generics_instantiation_3.sts @@ -15,7 +15,7 @@ class A { public foo(e: T): void { - this.data[2].equals(e); + this.data[2] == e; } private data: T[]; 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 f914fa8a4d661f27198c59f4ae8b08dc005b6b94..8a49b05ce7c9449a25ce15515d7feb37fd3958a7 100644 --- a/ets2panda/test/compiler/ets/import_tests/enum_export-expected.txt +++ b/ets2panda/test/compiler/ets/import_tests/enum_export-expected.txt @@ -387,12 +387,56 @@ "column": 1 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ { "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -405,52 +449,44 @@ } } }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "Red", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "StringLiteral", - "value": "Blue", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "accessibility": "protected", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 }, - { - "type": "StringLiteral", - "value": "Green", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "end": { + "line": 1, + "column": 1 } - ], + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "", + "decorators": [], "loc": { "start": { "line": 1, @@ -462,33 +498,37 @@ } } }, + "kind": "method", "accessibility": "public", "static": true, - "readonly": false, - "declare": false, "optional": false, "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], "loc": { "start": { "line": 1, @@ -522,7 +562,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -539,7 +579,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -552,9 +592,9 @@ } } }, - "kind": "method", + "kind": "constructor", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -563,7 +603,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -586,12 +626,68 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { "type": "Identifier", - "name": "Color", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -604,6 +700,23 @@ } } }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -626,7 +739,6 @@ } } }, - "decorators": [], "loc": { "start": { "line": 1, @@ -637,49 +749,91 @@ "column": 1 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "Red", + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } - }, + } + }, + { + "type": "StringLiteral", + "value": "Blue", "loc": { "start": { "line": 1, @@ -691,94 +845,59 @@ } } }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color#NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + { + "type": "StringLiteral", + "value": "Green", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], + }, "loc": { "start": { "line": 1, @@ -812,7 +931,7 @@ } } }, - "overloads": [], + "definite": false, "decorators": [], "loc": { "start": { @@ -826,10 +945,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#valueOf", + "name": "ValuesArray", "decorators": [], "loc": { "start": { @@ -842,18 +961,2693 @@ } } }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { + "type": "ArrayExpression", + "elements": [ + { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "NumberLiteral", + "value": 42, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "NumberLiteral", + "value": 43, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "0", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "42", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "43", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Blue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Green", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "BoxedItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Blue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Green", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getName", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "valueOf", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ForUpdateStatement", + "init": { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "init": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "update": { + "type": "UpdateExpression", + "operator": "++", + "prefix": true, + "argument": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "==", + "left": { + "type": "Identifier", + "name": "name", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "alternate": null, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant Color.", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "name", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + "throwMarker": "throws", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getValue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getValue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "e", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "e", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "toString", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "values", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "fromInt", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { "type": "Identifier", - "name": "#Color#valueOf", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -874,37 +3668,9 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "name", + "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -985,71 +3751,13 @@ "type": "BlockStatement", "statements": [ { - "type": "ForUpdateStatement", - "init": { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "init": { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "IfStatement", "test": { "type": "BinaryExpression", "operator": "<", "left": { "type": "Identifier", - "name": "i", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -1066,7 +3774,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "ItemsArray", "decorators": [], "loc": { "start": { @@ -1118,90 +3826,14 @@ } } }, - "update": { - "type": "UpdateExpression", - "operator": "++", - "prefix": true, + "consequent": { + "type": "ReturnStatement", "argument": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "body": { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "==", - "left": { - "type": "Identifier", - "name": "name", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color#NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": true, - "optional": false, + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], "loc": { "start": { "line": 1, @@ -1213,77 +3845,10 @@ } } }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "consequent": { - "type": "ReturnStatement", - "argument": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -1295,6 +3860,8 @@ } } }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -1306,7 +3873,6 @@ } } }, - "alternate": null, "loc": { "start": { "line": 1, @@ -1318,6 +3884,7 @@ } } }, + "alternate": null, "loc": { "start": { "line": 1, @@ -1380,7 +3947,7 @@ "operator": "+", "left": { "type": "StringLiteral", - "value": "No enum constant Color.", + "value": "No enum constant in Color with ordinal value ", "loc": { "start": { "line": 1, @@ -1394,7 +3961,7 @@ }, "right": { "type": "Identifier", - "name": "name", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -1490,10 +4057,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#ValuesArray", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -1506,12 +4073,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumberLiteral", - "value": 0, + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "unbox", + "decorators": [], "loc": { "start": { "line": 1, @@ -1523,9 +4097,40 @@ } } }, - { - "type": "NumberLiteral", - "value": 42, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -1537,9 +4142,96 @@ } } }, - { - "type": "NumberLiteral", - "value": 43, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], "loc": { "start": { "line": 1, @@ -1550,29 +4242,7 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1595,7 +4265,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -1612,7 +4282,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#getValue", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -1636,7 +4306,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#getValue", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -1657,37 +4327,9 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "e", + "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1724,7 +4366,35 @@ } ], "returnType": { - "type": "ETSPrimitiveType", + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -1740,12 +4410,13 @@ "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { "type": "Identifier", - "name": "#Color#ValuesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -1758,11 +4429,11 @@ } } }, - "property": { - "type": "TSAsExpression", - "expression": { + "right": { + "type": "MemberExpression", + "object": { "type": "Identifier", - "name": "e", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -1775,8 +4446,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], "loc": { "start": { "line": 1, @@ -1788,6 +4461,8 @@ } } }, + "computed": false, + "optional": false, "loc": { "start": { "line": 1, @@ -1799,8 +4474,177 @@ } } }, - "computed": true, - "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "BoxedItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "alternate": null, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant in Color with ordinal value ", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], "loc": { "start": { "line": 1, @@ -1834,7 +4678,8 @@ "column": 1 } } - }, + } + "throwMarker": "throws", "loc": { "start": { "line": 1, @@ -1869,12 +4714,56 @@ "column": 1 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "#Commands", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ { "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#StringValuesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -1887,52 +4776,44 @@ } } }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "0", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "StringLiteral", - "value": "42", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "accessibility": "protected", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 }, - { - "type": "StringLiteral", - "value": "43", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "end": { + "line": 1, + "column": 1 } - ], + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "", + "decorators": [], "loc": { "start": { "line": 1, @@ -1944,33 +4825,37 @@ } } }, + "kind": "method", "accessibility": "public", "static": true, - "readonly": false, - "declare": false, "optional": false, "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], "loc": { "start": { "line": 1, @@ -2004,7 +4889,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2021,7 +4906,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#toString", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -2034,9 +4919,9 @@ } } }, - "kind": "method", + "kind": "constructor", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -2045,7 +4930,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#toString", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -2054,91 +4939,32 @@ }, "end": { "line": 1, - "column": 1 - } - } - }, - "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": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "String", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "decorators": [], "loc": { "start": { @@ -2161,46 +4987,20 @@ "column": 1 } } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } } - }, + ], "body": { "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color#StringValuesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", "loc": { "start": { "line": 1, @@ -2212,8 +5012,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -2225,6 +5027,23 @@ } } }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -2236,8 +5055,6 @@ } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 1, @@ -2311,7 +5128,7 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#ItemsArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -2328,39 +5145,8 @@ "type": "ArrayExpression", "elements": [ { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Red", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, + "type": "StringLiteral", + "value": "Open", "loc": { "start": { "line": 1, @@ -2373,25 +5159,46 @@ } }, { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "type": "StringLiteral", + "value": "Close", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } - }, - "property": { + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { "type": "Identifier", - "name": "Blue", + "name": "String", "decorators": [], "loc": { "start": { @@ -2404,8 +5211,6 @@ } } }, - "computed": false, - "optional": false, "loc": { "start": { "line": 1, @@ -2417,40 +5222,78 @@ } } }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "loc": { + "start": { + "line": 1, + "column": 1 }, - "property": { - "type": "Identifier", - "name": "Green", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "fopen", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } - }, - "computed": false, - "optional": false, + } + }, + { + "type": "StringLiteral", + "value": "fclose", "loc": { "start": { "line": 1, @@ -2474,7 +5317,7 @@ } } }, - "accessibility": "public", + "accessibility": "protected", "static": true, "readonly": false, "declare": false, @@ -2488,7 +5331,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Color", + "name": "String", "decorators": [], "loc": { "start": { @@ -2548,10 +5391,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#values", + "name": "ItemsArray", "decorators": [], "loc": { "start": { @@ -2564,19 +5407,43 @@ } } }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "#Color#values", - "decorators": [], + "type": "ArrayExpression", + "elements": [ + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Commands", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Open", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, "loc": { "start": { "line": 1, @@ -2588,42 +5455,27 @@ } } }, - "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": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Commands", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "property": { + "type": "Identifier", + "name": "Close", + "decorators": [], "loc": { "start": { "line": 1, @@ -2635,6 +5487,8 @@ } } }, + "computed": false, + "optional": false, "loc": { "start": { "line": 1, @@ -2645,39 +5499,46 @@ "column": 1 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "#Color#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Commands", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], + }, "loc": { "start": { "line": 1, @@ -2711,7 +5572,7 @@ } } }, - "overloads": [], + "definite": false, "decorators": [], "loc": { "start": { @@ -2725,10 +5586,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#fromInt", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -2741,84 +5602,30 @@ } } }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "#Color#fromInt", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSPrimitiveType", + "type": "ArrayExpression", + "elements": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Commands", + "decorators": [], "loc": { "start": { "line": 1, "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], "loc": { "start": { "line": 1, @@ -2841,28 +5648,14 @@ } } }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ + "arguments": [ { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "<", - "left": { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { "type": "Identifier", - "name": "ordinal", + "name": "Commands", "decorators": [], "loc": { "start": { @@ -2875,40 +5668,10 @@ } } }, - "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "length", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, + "property": { + "type": "Identifier", + "name": "Open", + "decorators": [], "loc": { "start": { "line": 1, @@ -2920,6 +5683,8 @@ } } }, + "computed": false, + "optional": false, "loc": { "start": { "line": 1, @@ -2931,53 +5696,8 @@ } } }, - "consequent": { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "typeAnnotation": { + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -2989,7 +5709,6 @@ } } }, - "alternate": null, "loc": { "start": { "line": 1, @@ -3000,97 +5719,112 @@ "column": 1 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, - { - "type": "ThrowStatement", - "argument": { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Exception", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Commands", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 }, - "arguments": [ - { - "type": "BinaryExpression", - "operator": "+", - "left": { - "type": "StringLiteral", - "value": "No enum constant in Color with ordinal value ", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "right": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Commands", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], + }, + "property": { + "type": "Identifier", + "name": "Close", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -3125,90 +5859,6 @@ } } } - "throwMarker": "throws", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#Commands#NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "Open", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "StringLiteral", - "value": "Close", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } ], "loc": { "start": { @@ -3221,7 +5871,7 @@ } } }, - "accessibility": "public", + "accessibility": "protected", "static": true, "readonly": false, "declare": false, @@ -3235,7 +5885,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "#Commands", "decorators": [], "loc": { "start": { @@ -3298,7 +5948,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Commands#getName", + "name": "getName", "decorators": [], "loc": { "start": { @@ -3322,7 +5972,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Commands#getName", + "name": "getName", "decorators": [], "loc": { "start": { @@ -3459,7 +6109,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Commands#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -3588,7 +6238,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Commands#valueOf", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -3612,7 +6262,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Commands#valueOf", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -3825,7 +6475,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Commands#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -3931,7 +6581,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Commands#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -4021,17 +6671,140 @@ } } }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "alternate": null, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant Commands.", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "right": { + "type": "Identifier", + "name": "name", + "decorators": [], "loc": { "start": { "line": 1, @@ -4053,6 +6826,146 @@ "column": 1 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + "throwMarker": "throws", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "toString", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, "loc": { "start": { @@ -4065,7 +6978,6 @@ } } }, - "alternate": null, "loc": { "start": { "line": 1, @@ -4077,6 +6989,38 @@ } } }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], "loc": { "start": { "line": 1, @@ -4088,40 +7032,39 @@ } } }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], "loc": { "start": { "line": 1, @@ -4133,39 +7076,25 @@ } } }, - "arguments": [ - { - "type": "BinaryExpression", - "operator": "+", - "left": { - "type": "StringLiteral", - "value": "No enum constant Commands.", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "right": { - "type": "Identifier", - "name": "name", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -4176,8 +7105,20 @@ "column": 1 } } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - ], + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -4211,8 +7152,7 @@ "column": 1 } } - } - "throwMarker": "throws", + }, "loc": { "start": { "line": 1, @@ -4249,10 +7189,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Commands#StringValuesArray", + "name": "values", "decorators": [], "loc": { "start": { @@ -4265,12 +7205,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "fopen", + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "values", + "decorators": [], "loc": { "start": { "line": 1, @@ -4282,9 +7229,53 @@ } } }, - { - "type": "StringLiteral", - "value": "fclose", + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Commands", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -4295,46 +7286,39 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -4368,7 +7352,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -4385,7 +7369,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Commands#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -4406,61 +7390,33 @@ "value": { "type": "FunctionExpression", "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "#Commands#toString", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "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": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "fromInt", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -4502,7 +7458,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "Commands", "decorators": [], "loc": { "start": { @@ -4541,12 +7497,13 @@ "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { "type": "Identifier", - "name": "#Commands#StringValuesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -4559,11 +7516,11 @@ } } }, - "property": { - "type": "TSAsExpression", - "expression": { + "right": { + "type": "MemberExpression", + "object": { "type": "Identifier", - "name": "ordinal", + "name": "ItemsArray", "decorators": [], "loc": { "start": { @@ -4576,8 +7533,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], "loc": { "start": { "line": 1, @@ -4589,6 +7548,66 @@ } } }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -4600,8 +7619,6 @@ } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 1, @@ -4613,6 +7630,7 @@ } } }, + "alternate": null, "loc": { "start": { "line": 1, @@ -4621,205 +7639,122 @@ "end": { "line": 1, "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#Commands#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Commands", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Open", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Commands", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Close", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 + } } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Commands", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant in Commands with ordinal value ", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -4830,7 +7765,8 @@ "column": 1 } } - }, + } + "throwMarker": "throws", "loc": { "start": { "line": 1, @@ -4853,7 +7789,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -4870,7 +7806,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Commands#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -4885,7 +7821,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -4894,7 +7830,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Commands#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -4912,26 +7848,13 @@ "expression": false, "params": [], "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Commands", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Commands", + "decorators": [], "loc": { "start": { "line": 1, @@ -4971,9 +7894,67 @@ { "type": "ReturnStatement", "argument": { - "type": "Identifier", - "name": "#Commands#ItemsArray", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -5047,7 +8028,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Commands#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -5071,7 +8052,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Commands#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -5136,7 +8117,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Commands", + "name": "#Commands", "decorators": [], "loc": { "start": { @@ -5198,7 +8179,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Commands#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -5256,7 +8237,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Commands#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { diff --git a/ets2panda/test/compiler/ets/import_tests/re-export_with_alias/export-expected.txt b/ets2panda/test/compiler/ets/import_tests/re-export_with_alias/export-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..ba5b85b1200dc08c2cff300ad918b7a2d92ba50f --- /dev/null +++ b/ets2panda/test/compiler/ets/import_tests/re-export_with_alias/export-expected.txt @@ -0,0 +1,850 @@ +{ + "type": "Program", + "statements": [ + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "TestClass", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 14 + }, + "end": { + "line": 22, + "column": 23 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "test_method", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 5 + }, + "end": { + "line": 23, + "column": 16 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "test_method", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 5 + }, + "end": { + "line": 23, + "column": 16 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 23, + "column": 20 + }, + "end": { + "line": 23, + "column": 24 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "console", + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 9 + }, + "end": { + "line": 24, + "column": 16 + } + } + }, + "property": { + "type": "Identifier", + "name": "print", + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 17 + }, + "end": { + "line": 24, + "column": 22 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 24, + "column": 9 + }, + "end": { + "line": 24, + "column": 22 + } + } + }, + "arguments": [ + { + "type": "StringLiteral", + "value": "test_method +", + "loc": { + "start": { + "line": 24, + "column": 23 + }, + "end": { + "line": 24, + "column": 38 + } + } + } + ], + "optional": false, + "loc": { + "start": { + "line": 24, + "column": 9 + }, + "end": { + "line": 24, + "column": 39 + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 9 + }, + "end": { + "line": 24, + "column": 40 + } + } + } + ], + "loc": { + "start": { + "line": 23, + "column": 25 + }, + "end": { + "line": 25, + "column": 6 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 16 + }, + "end": { + "line": 25, + "column": 6 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 16 + }, + "end": { + "line": 25, + "column": 6 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 5 + }, + "end": { + "line": 25, + "column": 6 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "constructor", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 2 + }, + "end": { + "line": 26, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 22, + "column": 24 + }, + "end": { + "line": 26, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 8 + }, + "end": { + "line": 26, + "column": 2 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ETSGLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "main", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "test_var", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 12 + }, + "end": { + "line": 16, + "column": 20 + } + } + }, + "right": { + "type": "StringLiteral", + "value": "Hello_world", + "loc": { + "start": { + "line": 16, + "column": 31 + }, + "end": { + "line": 16, + "column": 44 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 12 + }, + "end": { + "line": 16, + "column": 44 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 12 + }, + "end": { + "line": 16, + "column": 44 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "test_var", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 12 + }, + "end": { + "line": 16, + "column": 20 + } + } + }, + "accessibility": "public", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 22 + }, + "end": { + "line": 16, + "column": 28 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 22 + }, + "end": { + "line": 16, + "column": 30 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 22 + }, + "end": { + "line": 16, + "column": 30 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 12 + }, + "end": { + "line": 16, + "column": 44 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "test_func", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 17 + }, + "end": { + "line": 18, + "column": 26 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "test_func", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 17 + }, + "end": { + "line": 18, + "column": 26 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 18, + "column": 30 + }, + "end": { + "line": 18, + "column": 37 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "BooleanLiteral", + "value": true, + "loc": { + "start": { + "line": 19, + "column": 12 + }, + "end": { + "line": 19, + "column": 16 + } + } + }, + "loc": { + "start": { + "line": 19, + "column": 5 + }, + "end": { + "line": 19, + "column": 17 + } + } + } + ], + "loc": { + "start": { + "line": 18, + "column": 38 + }, + "end": { + "line": 20, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 26 + }, + "end": { + "line": 20, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 26 + }, + "end": { + "line": 20, + "column": 2 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 8 + }, + "end": { + "line": 20, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 27, + "column": 1 + } + } +} diff --git a/ets2panda/test/parser/ets/recursive_import/case_3_3-sources-in-circle-fail-no-ets-module-compile/main__foo1.sts b/ets2panda/test/compiler/ets/import_tests/re-export_with_alias/export.sts similarity index 75% rename from ets2panda/test/parser/ets/recursive_import/case_3_3-sources-in-circle-fail-no-ets-module-compile/main__foo1.sts rename to ets2panda/test/compiler/ets/import_tests/re-export_with_alias/export.sts index 45f20acd8f12d6cb77a2d6b94e3a9adc37a5cc6c..c96a7fff868ed7112ffb189d86f1962bd91edb15 100644 --- a/ets2panda/test/parser/ets/recursive_import/case_3_3-sources-in-circle-fail-no-ets-module-compile/main__foo1.sts +++ b/ets2panda/test/compiler/ets/import_tests/re-export_with_alias/export.sts @@ -13,14 +13,14 @@ * limitations under the License. */ -import {foo_in_3} from "./foo3__module" +export let test_var: String = "Hello_world"; -export class A { - a: int; +export function test_func(): boolean { + return true; } - -function main() : void { - let a = new A(); - foo_in_3(); +export class TestClass { + test_method(): void { + console.print("test_method\n"); + } } diff --git a/ets2panda/test/compiler/ets/import_tests/re-export_with_alias/import_aliased_re-export-expected.txt b/ets2panda/test/compiler/ets/import_tests/re-export_with_alias/import_aliased_re-export-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..42f22b34bd6d575613617632aa887a1f85d39f7d --- /dev/null +++ b/ets2panda/test/compiler/ets/import_tests/re-export_with_alias/import_aliased_re-export-expected.txt @@ -0,0 +1,822 @@ +{ + "type": "Program", + "statements": [ + { + "type": "ImportDeclaration", + "source": { + "type": "StringLiteral", + "value": "./re-export_with_alias", + "loc": { + "start": { + "line": 16, + "column": 27 + }, + "end": { + "line": 16, + "column": 51 + } + } + }, + "specifiers": [ + { + "type": "ImportSpecifier", + "local": { + "type": "Identifier", + "name": "aliased_var", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 9 + }, + "end": { + "line": 16, + "column": 20 + } + } + }, + "imported": { + "type": "Identifier", + "name": "aliased_var", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 9 + }, + "end": { + "line": 16, + "column": 20 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 9 + }, + "end": { + "line": 16, + "column": 20 + } + } + } + ], + "loc": { + "start": { + "line": 16, + "column": 1 + }, + "end": { + "line": 16, + "column": 52 + } + } + }, + { + "type": "ImportDeclaration", + "source": { + "type": "StringLiteral", + "value": "./re-export_with_alias", + "loc": { + "start": { + "line": 17, + "column": 42 + }, + "end": { + "line": 17, + "column": 66 + } + } + }, + "specifiers": [ + { + "type": "ImportSpecifier", + "local": { + "type": "Identifier", + "name": "aliased_func", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 9 + }, + "end": { + "line": 17, + "column": 21 + } + } + }, + "imported": { + "type": "Identifier", + "name": "aliased_func", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 9 + }, + "end": { + "line": 17, + "column": 21 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 9 + }, + "end": { + "line": 17, + "column": 21 + } + } + }, + { + "type": "ImportSpecifier", + "local": { + "type": "Identifier", + "name": "AliasedClass", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 23 + }, + "end": { + "line": 17, + "column": 35 + } + } + }, + "imported": { + "type": "Identifier", + "name": "AliasedClass", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 23 + }, + "end": { + "line": 17, + "column": 35 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 23 + }, + "end": { + "line": 17, + "column": 35 + } + } + } + ], + "loc": { + "start": { + "line": 17, + "column": 1 + }, + "end": { + "line": 17, + "column": 67 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ETSGLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "main", + "decorators": [], + "loc": { + "start": { + "line": 19, + "column": 10 + }, + "end": { + "line": 19, + "column": 14 + } + } + }, + "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": 19, + "column": 10 + }, + "end": { + "line": 19, + "column": 14 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 19, + "column": 18 + }, + "end": { + "line": 19, + "column": 22 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "console", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 5 + }, + "end": { + "line": 20, + "column": 12 + } + } + }, + "property": { + "type": "Identifier", + "name": "print", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 13 + }, + "end": { + "line": 20, + "column": 18 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 20, + "column": 5 + }, + "end": { + "line": 20, + "column": 18 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "Identifier", + "name": "aliased_var", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 19 + }, + "end": { + "line": 20, + "column": 30 + } + } + }, + "right": { + "type": "StringLiteral", + "value": " +", + "loc": { + "start": { + "line": 20, + "column": 33 + }, + "end": { + "line": 20, + "column": 37 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 19 + }, + "end": { + "line": 20, + "column": 37 + } + } + } + ], + "optional": false, + "loc": { + "start": { + "line": 20, + "column": 5 + }, + "end": { + "line": 20, + "column": 38 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 5 + }, + "end": { + "line": 20, + "column": 39 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "aliased_func", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "column": 17 + } + } + }, + "arguments": [], + "optional": false, + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "column": 19 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "column": 20 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "tmp_var", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "AliasedClass", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 18 + }, + "end": { + "line": 23, + "column": 30 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 18 + }, + "end": { + "line": 23, + "column": 32 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 18 + }, + "end": { + "line": 23, + "column": 32 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 9 + }, + "end": { + "line": 23, + "column": 16 + } + } + }, + "init": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "AliasedClass", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 37 + }, + "end": { + "line": 23, + "column": 49 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 37 + }, + "end": { + "line": 23, + "column": 50 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 37 + }, + "end": { + "line": 23, + "column": 50 + } + } + }, + "arguments": [], + "loc": { + "start": { + "line": 23, + "column": 33 + }, + "end": { + "line": 23, + "column": 52 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 9 + }, + "end": { + "line": 23, + "column": 52 + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 23, + "column": 5 + }, + "end": { + "line": 23, + "column": 52 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "tmp_var", + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 5 + }, + "end": { + "line": 24, + "column": 12 + } + } + }, + "property": { + "type": "Identifier", + "name": "test_method", + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 13 + }, + "end": { + "line": 24, + "column": 24 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 24, + "column": 5 + }, + "end": { + "line": 24, + "column": 24 + } + } + }, + "arguments": [], + "optional": false, + "loc": { + "start": { + "line": 24, + "column": 5 + }, + "end": { + "line": 24, + "column": 26 + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 5 + }, + "end": { + "line": 24, + "column": 27 + } + } + } + ], + "loc": { + "start": { + "line": 19, + "column": 23 + }, + "end": { + "line": 25, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 19, + "column": 14 + }, + "end": { + "line": 25, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 19, + "column": 14 + }, + "end": { + "line": 25, + "column": 2 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 19, + "column": 1 + }, + "end": { + "line": 25, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 26, + "column": 1 + } + } +} diff --git a/ets2panda/test/parser/ets/import_tests/modules/module.sts b/ets2panda/test/compiler/ets/import_tests/re-export_with_alias/import_aliased_re-export.sts similarity index 68% rename from ets2panda/test/parser/ets/import_tests/modules/module.sts rename to ets2panda/test/compiler/ets/import_tests/re-export_with_alias/import_aliased_re-export.sts index 42805de146aa8f4d1dfcc3293aa4f194722e1921..64474c21a54f14187783551a6b950925bc26bb41 100644 --- a/ets2panda/test/parser/ets/import_tests/modules/module.sts +++ b/ets2panda/test/compiler/ets/import_tests/re-export_with_alias/import_aliased_re-export.sts @@ -13,14 +13,13 @@ * limitations under the License. */ -export const dbl: double = 1.23456789; +import {aliased_var} from "./re-export_with_alias"; +import {aliased_func, AliasedClass} from "./re-export_with_alias"; -export class Enclosing { - public static fieldA: String; +function main(): void { + console.print(aliased_var + "\n"); + aliased_func(); - public class Nested { - public static fieldB: int; - public static fieldC: int; - public fieldD: int; - } + let tmp_var: AliasedClass = new AliasedClass(); + tmp_var.test_method(); } diff --git a/ets2panda/test/compiler/ets/import_tests/re-export_with_alias/re-export_with_alias-expected.txt b/ets2panda/test/compiler/ets/import_tests/re-export_with_alias/re-export_with_alias-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..ead73637e2907d676084dd69da67b8b537e29905 --- /dev/null +++ b/ets2panda/test/compiler/ets/import_tests/re-export_with_alias/re-export_with_alias-expected.txt @@ -0,0 +1,366 @@ +{ + "type": "Program", + "statements": [ + { + "type": "ETSReExportDeclaration", + "ets_import_declarations": { + "type": "ImportDeclaration", + "source": { + "type": "StringLiteral", + "value": "./export", + "loc": { + "start": { + "line": 16, + "column": 39 + }, + "end": { + "line": 16, + "column": 49 + } + } + }, + "specifiers": [ + { + "type": "ImportSpecifier", + "local": { + "type": "Identifier", + "name": "aliased_var", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 21 + }, + "end": { + "line": 16, + "column": 32 + } + } + }, + "imported": { + "type": "Identifier", + "name": "test_var", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 9 + }, + "end": { + "line": 16, + "column": 17 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 9 + }, + "end": { + "line": 16, + "column": 32 + } + } + } + ], + "loc": { + "start": { + "line": 16, + "column": 8 + }, + "end": { + "line": 16, + "column": 50 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSReExportDeclaration", + "ets_import_declarations": { + "type": "ImportDeclaration", + "source": { + "type": "StringLiteral", + "value": "./export", + "loc": { + "start": { + "line": 17, + "column": 68 + }, + "end": { + "line": 17, + "column": 78 + } + } + }, + "specifiers": [ + { + "type": "ImportSpecifier", + "local": { + "type": "Identifier", + "name": "aliased_func", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 22 + }, + "end": { + "line": 17, + "column": 34 + } + } + }, + "imported": { + "type": "Identifier", + "name": "test_func", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 9 + }, + "end": { + "line": 17, + "column": 18 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 9 + }, + "end": { + "line": 17, + "column": 34 + } + } + }, + { + "type": "ImportSpecifier", + "local": { + "type": "Identifier", + "name": "AliasedClass", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 49 + }, + "end": { + "line": 17, + "column": 61 + } + } + }, + "imported": { + "type": "Identifier", + "name": "TestClass", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 36 + }, + "end": { + "line": 17, + "column": 45 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 36 + }, + "end": { + "line": 17, + "column": 61 + } + } + } + ], + "loc": { + "start": { + "line": 17, + "column": 8 + }, + "end": { + "line": 17, + "column": 79 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ETSGLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 18, + "column": 1 + } + } +} diff --git a/ets2panda/test/compiler/ets/import_tests/re-export_with_alias/re-export_with_alias.sts b/ets2panda/test/compiler/ets/import_tests/re-export_with_alias/re-export_with_alias.sts new file mode 100644 index 0000000000000000000000000000000000000000..af54db5b08303cd2327925a8b0c6d2cfe283a484 --- /dev/null +++ b/ets2panda/test/compiler/ets/import_tests/re-export_with_alias/re-export_with_alias.sts @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export {test_var as aliased_var} from "./export"; +export {test_func as aliased_func, TestClass as AliasedClass} from "./export"; diff --git a/ets2panda/test/parser/ets/recursive_import/case_3_3-sources-in-circle-fail-no-ets-module-compile/foo2__module-expected.txt b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/import_function_wrong_name-expected.txt similarity index 40% rename from ets2panda/test/parser/ets/recursive_import/case_3_3-sources-in-circle-fail-no-ets-module-compile/foo2__module-expected.txt rename to ets2panda/test/compiler/ets/import_tests/selective_export_tests/import_function_wrong_name-expected.txt index bcd5f0a97effd881b5c82e3db2abf02605adc555..9f556b3d3368bf36278fff0e4884fb4eb7af10ef 100644 --- a/ets2panda/test/parser/ets/recursive_import/case_3_3-sources-in-circle-fail-no-ets-module-compile/foo2__module-expected.txt +++ b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/import_function_wrong_name-expected.txt @@ -5,15 +5,15 @@ "type": "ImportDeclaration", "source": { "type": "StringLiteral", - "value": "./main__foo1", + "value": "./selective_export_function", "loc": { "start": { "line": 16, - "column": 17 + "column": 25 }, "end": { "line": 16, - "column": 31 + "column": 54 } } }, @@ -22,7 +22,7 @@ "type": "ImportSpecifier", "local": { "type": "Identifier", - "name": "A", + "name": "test_func", "decorators": [], "loc": { "start": { @@ -31,13 +31,13 @@ }, "end": { "line": 16, - "column": 10 + "column": 18 } } }, "imported": { "type": "Identifier", - "name": "A", + "name": "test_func", "decorators": [], "loc": { "start": { @@ -46,7 +46,7 @@ }, "end": { "line": 16, - "column": 10 + "column": 18 } } }, @@ -57,7 +57,7 @@ }, "end": { "line": 16, - "column": 10 + "column": 18 } } } @@ -69,7 +69,7 @@ }, "end": { "line": 16, - "column": 31 + "column": 54 } } }, @@ -98,16 +98,16 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "foo_in_2", + "name": "_$init$_", "decorators": [], "loc": { "start": { - "line": 18, - "column": 17 + "line": 1, + "column": 1 }, "end": { - "line": 18, - "column": 25 + "line": 1, + "column": 1 } } }, @@ -122,16 +122,16 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "foo_in_2", + "name": "_$init$_", "decorators": [], "loc": { "start": { - "line": 18, - "column": 17 + "line": 1, + "column": 1 }, "end": { - "line": 18, - "column": 25 + "line": 1, + "column": 1 } } }, @@ -139,168 +139,39 @@ "async": false, "expression": false, "params": [], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 18, - "column": 29 - }, - "end": { - "line": 18, - "column": 32 - } - } - }, "body": { "type": "BlockStatement", - "statements": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "console", - "decorators": [], - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 12 - } - } - }, - "property": { - "type": "Identifier", - "name": "log", - "decorators": [], - "loc": { - "start": { - "line": 19, - "column": 13 - }, - "end": { - "line": 19, - "column": 16 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 16 - } - } - }, - "arguments": [ - { - "type": "StringLiteral", - "value": "in foo_in_2", - "loc": { - "start": { - "line": 19, - "column": 17 - }, - "end": { - "line": 19, - "column": 30 - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 31 - } - } - }, - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 32 - } - } - }, - { - "type": "ReturnStatement", - "argument": { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 20, - "column": 12 - }, - "end": { - "line": 20, - "column": 13 - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 5 - }, - "end": { - "line": 20, - "column": 14 - } - } - } - ], + "statements": [], "loc": { "start": { - "line": 18, - "column": 33 + "line": 1, + "column": 1 }, "end": { - "line": 21, - "column": 2 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 18, - "column": 25 + "line": 1, + "column": 1 }, "end": { - "line": 21, - "column": 2 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 18, - "column": 25 + "line": 1, + "column": 1 }, "end": { - "line": 21, - "column": 2 + "line": 1, + "column": 1 } } }, @@ -308,12 +179,12 @@ "decorators": [], "loc": { "start": { - "line": 18, - "column": 8 + "line": 1, + "column": 1 }, "end": { - "line": 21, - "column": 2 + "line": 1, + "column": 1 } } } @@ -347,8 +218,9 @@ "column": 1 }, "end": { - "line": 22, + "line": 17, "column": 1 } } } +SyntaxError: Cannot find imported element 'test_func' [import_function_wrong_name.sts:16:9] diff --git a/ets2panda/test/compiler/ets/import_tests/selective_export_tests/import_function_wrong_name.sts b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/import_function_wrong_name.sts new file mode 100644 index 0000000000000000000000000000000000000000..437a704787488e0cafab99f647ae4d69ed3ca96f --- /dev/null +++ b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/import_function_wrong_name.sts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import {test_func} from "./selective_export_function" diff --git a/ets2panda/test/compiler/ets/import_tests/selective_export_tests/import_interface-expected.txt b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/import_interface-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..1033b9a35ce71bb28839af769040e5451ea24575 --- /dev/null +++ b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/import_interface-expected.txt @@ -0,0 +1,652 @@ +{ + "type": "Program", + "statements": [ + { + "type": "ImportDeclaration", + "source": { + "type": "StringLiteral", + "value": "./selective_export_interface", + "loc": { + "start": { + "line": 16, + "column": 45 + }, + "end": { + "line": 16, + "column": 75 + } + } + }, + "specifiers": [ + { + "type": "ImportSpecifier", + "local": { + "type": "Identifier", + "name": "TestInterface", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 9 + }, + "end": { + "line": 16, + "column": 22 + } + } + }, + "imported": { + "type": "Identifier", + "name": "TestInterface", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 9 + }, + "end": { + "line": 16, + "column": 22 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 9 + }, + "end": { + "line": 16, + "column": 22 + } + } + }, + { + "type": "ImportSpecifier", + "local": { + "type": "Identifier", + "name": "AliasInterface", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 24 + }, + "end": { + "line": 16, + "column": 38 + } + } + }, + "imported": { + "type": "Identifier", + "name": "AliasInterface", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 24 + }, + "end": { + "line": 16, + "column": 38 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 24 + }, + "end": { + "line": 16, + "column": 38 + } + } + } + ], + "loc": { + "start": { + "line": 16, + "column": 1 + }, + "end": { + "line": 16, + "column": 76 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "TestClass", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 7 + }, + "end": { + "line": 18, + "column": 16 + } + } + }, + "superClass": null, + "implements": [ + { + "type": "TSClassImplements", + "expression": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "TestInterface", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 28 + }, + "end": { + "line": 18, + "column": 41 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 28 + }, + "end": { + "line": 18, + "column": 43 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 28 + }, + "end": { + "line": 18, + "column": 43 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 28 + }, + "end": { + "line": 18, + "column": 43 + } + } + } + ], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "constructor", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 44 + }, + "end": { + "line": 18, + "column": 44 + } + } + } + ], + "loc": { + "start": { + "line": 18, + "column": 42 + }, + "end": { + "line": 18, + "column": 44 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 1 + }, + "end": { + "line": 18, + "column": 44 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "TestClassToo", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 7 + }, + "end": { + "line": 20, + "column": 19 + } + } + }, + "superClass": null, + "implements": [ + { + "type": "TSClassImplements", + "expression": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "AliasInterface", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 31 + }, + "end": { + "line": 20, + "column": 45 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 31 + }, + "end": { + "line": 20, + "column": 47 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 31 + }, + "end": { + "line": 20, + "column": 47 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 31 + }, + "end": { + "line": 20, + "column": 47 + } + } + } + ], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "constructor", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 48 + }, + "end": { + "line": 20, + "column": 48 + } + } + } + ], + "loc": { + "start": { + "line": 20, + "column": 46 + }, + "end": { + "line": 20, + "column": 48 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1 + }, + "end": { + "line": 20, + "column": 48 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ETSGLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 21, + "column": 1 + } + } +} diff --git a/ets2panda/test/parser/ets/recursive_import/case_0/main__foo1_as__module.sts b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/import_interface.sts similarity index 78% rename from ets2panda/test/parser/ets/recursive_import/case_0/main__foo1_as__module.sts rename to ets2panda/test/compiler/ets/import_tests/selective_export_tests/import_interface.sts index 0ac6ceee06d0719b2e01dae6dc288eebb8bd6e22..44fe86357297fa74eac77a25c8e65e8f2716ff6f 100644 --- a/ets2panda/test/parser/ets/recursive_import/case_0/main__foo1_as__module.sts +++ b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/import_interface.sts @@ -13,14 +13,8 @@ * limitations under the License. */ -import {foo} from "./foo2__module" +import {TestInterface, AliasInterface} from "./selective_export_interface"; -export class A { - a: int; -} +class TestClass implements TestInterface {} - -function main() : void { - let a = new A(); - foo(a); -} +class TestClassToo implements AliasInterface {} diff --git a/ets2panda/test/parser/ets/recursive_import/case_2_3-sources-in-circle/foo2__module-expected.txt b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/import_interface_wrong_name-expected.txt similarity index 40% rename from ets2panda/test/parser/ets/recursive_import/case_2_3-sources-in-circle/foo2__module-expected.txt rename to ets2panda/test/compiler/ets/import_tests/selective_export_tests/import_interface_wrong_name-expected.txt index 2302fb5558b12fa3c6b106458ea046bf5535a083..48a09851e29c5ae92a320656734af1f9c9c56d4e 100644 --- a/ets2panda/test/parser/ets/recursive_import/case_2_3-sources-in-circle/foo2__module-expected.txt +++ b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/import_interface_wrong_name-expected.txt @@ -5,15 +5,15 @@ "type": "ImportDeclaration", "source": { "type": "StringLiteral", - "value": "./main__foo1_as__module", + "value": "./selective_export_interface", "loc": { "start": { "line": 16, - "column": 17 + "column": 32 }, "end": { "line": 16, - "column": 42 + "column": 62 } } }, @@ -22,7 +22,7 @@ "type": "ImportSpecifier", "local": { "type": "Identifier", - "name": "A", + "name": "InterfaceToAlias", "decorators": [], "loc": { "start": { @@ -31,13 +31,13 @@ }, "end": { "line": 16, - "column": 10 + "column": 25 } } }, "imported": { "type": "Identifier", - "name": "A", + "name": "InterfaceToAlias", "decorators": [], "loc": { "start": { @@ -46,7 +46,7 @@ }, "end": { "line": 16, - "column": 10 + "column": 25 } } }, @@ -57,7 +57,7 @@ }, "end": { "line": 16, - "column": 10 + "column": 25 } } } @@ -69,7 +69,7 @@ }, "end": { "line": 16, - "column": 42 + "column": 63 } } }, @@ -98,16 +98,16 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "foo_in_2", + "name": "_$init$_", "decorators": [], "loc": { "start": { - "line": 18, - "column": 17 + "line": 1, + "column": 1 }, "end": { - "line": 18, - "column": 25 + "line": 1, + "column": 1 } } }, @@ -122,16 +122,16 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "foo_in_2", + "name": "_$init$_", "decorators": [], "loc": { "start": { - "line": 18, - "column": 17 + "line": 1, + "column": 1 }, "end": { - "line": 18, - "column": 25 + "line": 1, + "column": 1 } } }, @@ -139,168 +139,39 @@ "async": false, "expression": false, "params": [], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 18, - "column": 29 - }, - "end": { - "line": 18, - "column": 32 - } - } - }, "body": { "type": "BlockStatement", - "statements": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "console", - "decorators": [], - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 12 - } - } - }, - "property": { - "type": "Identifier", - "name": "log", - "decorators": [], - "loc": { - "start": { - "line": 19, - "column": 13 - }, - "end": { - "line": 19, - "column": 16 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 16 - } - } - }, - "arguments": [ - { - "type": "StringLiteral", - "value": "in foo_in_2", - "loc": { - "start": { - "line": 19, - "column": 17 - }, - "end": { - "line": 19, - "column": 30 - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 31 - } - } - }, - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 32 - } - } - }, - { - "type": "ReturnStatement", - "argument": { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 20, - "column": 12 - }, - "end": { - "line": 20, - "column": 13 - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 5 - }, - "end": { - "line": 20, - "column": 14 - } - } - } - ], + "statements": [], "loc": { "start": { - "line": 18, - "column": 33 + "line": 1, + "column": 1 }, "end": { - "line": 21, - "column": 2 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 18, - "column": 25 + "line": 1, + "column": 1 }, "end": { - "line": 21, - "column": 2 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 18, - "column": 25 + "line": 1, + "column": 1 }, "end": { - "line": 21, - "column": 2 + "line": 1, + "column": 1 } } }, @@ -308,12 +179,12 @@ "decorators": [], "loc": { "start": { - "line": 18, - "column": 8 + "line": 1, + "column": 1 }, "end": { - "line": 21, - "column": 2 + "line": 1, + "column": 1 } } } @@ -347,8 +218,9 @@ "column": 1 }, "end": { - "line": 22, + "line": 17, "column": 1 } } } +SyntaxError: Cannot find imported element 'InterfaceToAlias' [import_interface_wrong_name.sts:16:9] diff --git a/ets2panda/test/compiler/ets/import_tests/selective_export_tests/import_interface_wrong_name.sts b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/import_interface_wrong_name.sts new file mode 100644 index 0000000000000000000000000000000000000000..74ec5fdf90181adb64c07f02df1105927242883f --- /dev/null +++ b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/import_interface_wrong_name.sts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import {InterfaceToAlias} from "./selective_export_interface"; diff --git a/ets2panda/test/compiler/ets/import_tests/selective_export_tests/import_selective_exported-expected.txt b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/import_selective_exported-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..eb89d99fb4311b781743e7000305b1326f3440e3 --- /dev/null +++ b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/import_selective_exported-expected.txt @@ -0,0 +1,1140 @@ +{ + "type": "Program", + "statements": [ + { + "type": "ImportDeclaration", + "source": { + "type": "StringLiteral", + "value": "./selective_export", + "loc": { + "start": { + "line": 16, + "column": 22 + }, + "end": { + "line": 16, + "column": 42 + } + } + }, + "specifiers": [ + { + "type": "ImportNamespaceSpecifier", + "local": { + "type": "Identifier", + "name": "all", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 13 + }, + "end": { + "line": 16, + "column": 16 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 8 + }, + "end": { + "line": 16, + "column": 16 + } + } + } + ], + "loc": { + "start": { + "line": 16, + "column": 1 + }, + "end": { + "line": 16, + "column": 42 + } + } + }, + { + "type": "ImportDeclaration", + "source": { + "type": "StringLiteral", + "value": "./selective_export", + "loc": { + "start": { + "line": 17, + "column": 20 + }, + "end": { + "line": 17, + "column": 40 + } + } + }, + "specifiers": [ + { + "type": "ImportSpecifier", + "local": { + "type": "Identifier", + "name": "func", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 9 + }, + "end": { + "line": 17, + "column": 13 + } + } + }, + "imported": { + "type": "Identifier", + "name": "func", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 9 + }, + "end": { + "line": 17, + "column": 13 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 9 + }, + "end": { + "line": 17, + "column": 13 + } + } + } + ], + "loc": { + "start": { + "line": 17, + "column": 1 + }, + "end": { + "line": 17, + "column": 41 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ETSGLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "main", + "decorators": [], + "loc": { + "start": { + "line": 19, + "column": 10 + }, + "end": { + "line": 19, + "column": 14 + } + } + }, + "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": 19, + "column": 10 + }, + "end": { + "line": 19, + "column": 14 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 19, + "column": 18 + }, + "end": { + "line": 19, + "column": 22 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "func", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 5 + }, + "end": { + "line": 20, + "column": 9 + } + } + }, + "arguments": [], + "optional": false, + "loc": { + "start": { + "line": 20, + "column": 5 + }, + "end": { + "line": 20, + "column": 11 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 5 + }, + "end": { + "line": 20, + "column": 12 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "console", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "column": 12 + } + } + }, + "property": { + "type": "Identifier", + "name": "print", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 13 + }, + "end": { + "line": 21, + "column": 18 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "column": 18 + } + } + }, + "arguments": [ + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "all", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 19 + }, + "end": { + "line": 21, + "column": 22 + } + } + }, + "property": { + "type": "Identifier", + "name": "msg", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 23 + }, + "end": { + "line": 21, + "column": 26 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 21, + "column": 19 + }, + "end": { + "line": 21, + "column": 26 + } + } + } + ], + "optional": false, + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "column": 28 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "test_var", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "TSQualifiedName", + "left": { + "type": "Identifier", + "name": "all", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 19 + }, + "end": { + "line": 23, + "column": 22 + } + } + }, + "right": { + "type": "Identifier", + "name": "tc", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 23 + }, + "end": { + "line": 23, + "column": 25 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 19 + }, + "end": { + "line": 23, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 19 + }, + "end": { + "line": 23, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 19 + }, + "end": { + "line": 23, + "column": 27 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 9 + }, + "end": { + "line": 23, + "column": 17 + } + } + }, + "init": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "TSQualifiedName", + "left": { + "type": "Identifier", + "name": "all", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 32 + }, + "end": { + "line": 23, + "column": 35 + } + } + }, + "right": { + "type": "Identifier", + "name": "tc", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 36 + }, + "end": { + "line": 23, + "column": 38 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 32 + }, + "end": { + "line": 23, + "column": 39 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 32 + }, + "end": { + "line": 23, + "column": 39 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 32 + }, + "end": { + "line": 23, + "column": 39 + } + } + }, + "arguments": [], + "loc": { + "start": { + "line": 23, + "column": 28 + }, + "end": { + "line": 23, + "column": 41 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 9 + }, + "end": { + "line": 23, + "column": 41 + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 23, + "column": 5 + }, + "end": { + "line": 23, + "column": 41 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "console", + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 5 + }, + "end": { + "line": 24, + "column": 12 + } + } + }, + "property": { + "type": "Identifier", + "name": "print", + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 13 + }, + "end": { + "line": 24, + "column": 18 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 24, + "column": 5 + }, + "end": { + "line": 24, + "column": 18 + } + } + }, + "arguments": [ + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "test_var", + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 19 + }, + "end": { + "line": 24, + "column": 27 + } + } + }, + "property": { + "type": "Identifier", + "name": "test_member", + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 28 + }, + "end": { + "line": 24, + "column": 39 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 24, + "column": 19 + }, + "end": { + "line": 24, + "column": 39 + } + } + } + ], + "optional": false, + "loc": { + "start": { + "line": 24, + "column": 5 + }, + "end": { + "line": 24, + "column": 40 + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 5 + }, + "end": { + "line": 24, + "column": 41 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "test_var", + "decorators": [], + "loc": { + "start": { + "line": 25, + "column": 5 + }, + "end": { + "line": 25, + "column": 13 + } + } + }, + "property": { + "type": "Identifier", + "name": "test_method", + "decorators": [], + "loc": { + "start": { + "line": 25, + "column": 14 + }, + "end": { + "line": 25, + "column": 25 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 25, + "column": 5 + }, + "end": { + "line": 25, + "column": 25 + } + } + }, + "arguments": [], + "optional": false, + "loc": { + "start": { + "line": 25, + "column": 5 + }, + "end": { + "line": 25, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 25, + "column": 5 + }, + "end": { + "line": 25, + "column": 28 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "alias_var", + "decorators": [], + "loc": { + "start": { + "line": 27, + "column": 9 + }, + "end": { + "line": 27, + "column": 18 + } + } + }, + "init": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "TSQualifiedName", + "left": { + "type": "Identifier", + "name": "all", + "decorators": [], + "loc": { + "start": { + "line": 27, + "column": 25 + }, + "end": { + "line": 27, + "column": 28 + } + } + }, + "right": { + "type": "Identifier", + "name": "aliased", + "decorators": [], + "loc": { + "start": { + "line": 27, + "column": 29 + }, + "end": { + "line": 27, + "column": 36 + } + } + }, + "loc": { + "start": { + "line": 27, + "column": 25 + }, + "end": { + "line": 27, + "column": 37 + } + } + }, + "loc": { + "start": { + "line": 27, + "column": 25 + }, + "end": { + "line": 27, + "column": 37 + } + } + }, + "loc": { + "start": { + "line": 27, + "column": 25 + }, + "end": { + "line": 27, + "column": 37 + } + } + }, + "arguments": [], + "loc": { + "start": { + "line": 27, + "column": 21 + }, + "end": { + "line": 27, + "column": 39 + } + } + }, + "loc": { + "start": { + "line": 27, + "column": 9 + }, + "end": { + "line": 27, + "column": 39 + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 27, + "column": 5 + }, + "end": { + "line": 27, + "column": 39 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "alias_var", + "decorators": [], + "loc": { + "start": { + "line": 28, + "column": 5 + }, + "end": { + "line": 28, + "column": 14 + } + } + }, + "property": { + "type": "Identifier", + "name": "alias_class_method", + "decorators": [], + "loc": { + "start": { + "line": 28, + "column": 15 + }, + "end": { + "line": 28, + "column": 33 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 28, + "column": 5 + }, + "end": { + "line": 28, + "column": 33 + } + } + }, + "arguments": [], + "optional": false, + "loc": { + "start": { + "line": 28, + "column": 5 + }, + "end": { + "line": 28, + "column": 35 + } + } + }, + "loc": { + "start": { + "line": 28, + "column": 5 + }, + "end": { + "line": 28, + "column": 36 + } + } + } + ], + "loc": { + "start": { + "line": 19, + "column": 23 + }, + "end": { + "line": 29, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 19, + "column": 14 + }, + "end": { + "line": 29, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 19, + "column": 14 + }, + "end": { + "line": 29, + "column": 2 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 19, + "column": 1 + }, + "end": { + "line": 29, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 30, + "column": 1 + } + } +} diff --git a/ets2panda/test/compiler/ets/import_tests/selective_export_tests/import_selective_exported.sts b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/import_selective_exported.sts new file mode 100644 index 0000000000000000000000000000000000000000..ce33368cbbd4fd85246c8b9a872da976ff64f363 --- /dev/null +++ b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/import_selective_exported.sts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as all from "./selective_export" +import {func} from "./selective_export"; + +function main(): void { + func(); + console.print(all.msg); + + let test_var: all.tc = new all.tc(); + console.print(test_var.test_member); + test_var.test_method(); + + let alias_var = new all.aliased(); + alias_var.alias_class_method(); +} diff --git a/ets2panda/test/parser/ets/recursive_import/case_2_3-sources-in-circle/main__foo1_as__module-expected.txt b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/namespace_import_wrong_access_name-expected.txt similarity index 60% rename from ets2panda/test/parser/ets/recursive_import/case_2_3-sources-in-circle/main__foo1_as__module-expected.txt rename to ets2panda/test/compiler/ets/import_tests/selective_export_tests/namespace_import_wrong_access_name-expected.txt index 5ad82849108db47f33c5019b29a393d7f9c49177..7cceed01e338236fa8fb0a6e53c03b729a8bc464 100644 --- a/ets2panda/test/parser/ets/recursive_import/case_2_3-sources-in-circle/main__foo1_as__module-expected.txt +++ b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/namespace_import_wrong_access_name-expected.txt @@ -5,59 +5,44 @@ "type": "ImportDeclaration", "source": { "type": "StringLiteral", - "value": "./foo3__module", + "value": "./selective_export", "loc": { "start": { "line": 16, - "column": 24 + "column": 22 }, "end": { "line": 16, - "column": 40 + "column": 42 } } }, "specifiers": [ { - "type": "ImportSpecifier", + "type": "ImportNamespaceSpecifier", "local": { "type": "Identifier", - "name": "foo_in_3", + "name": "all", "decorators": [], "loc": { "start": { "line": 16, - "column": 9 + "column": 13 }, "end": { "line": 16, - "column": 17 - } - } - }, - "imported": { - "type": "Identifier", - "name": "foo_in_3", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 9 - }, - "end": { - "line": 16, - "column": 17 + "column": 16 } } }, "loc": { "start": { "line": 16, - "column": 9 + "column": 8 }, "end": { "line": 16, - "column": 17 + "column": 16 } } } @@ -69,7 +54,7 @@ }, "end": { "line": 16, - "column": 40 + "column": 42 } } }, @@ -78,76 +63,27 @@ "definition": { "id": { "type": "Identifier", - "name": "A", + "name": "ETSGLOBAL", "decorators": [], "loc": { "start": { - "line": 18, - "column": 14 + "line": 1, + "column": 1 }, "end": { - "line": 18, - "column": 15 + "line": 1, + "column": 1 } } }, "superClass": null, "implements": [], "body": [ - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "a", - "decorators": [], - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 6 - } - } - }, - "accessibility": "public", - "static": false, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 19, - "column": 8 - }, - "end": { - "line": 19, - "column": 11 - } - } - }, - "definite": false, - "decorators": [], - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 11 - } - } - }, { "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "constructor", + "name": "main", "decorators": [], "loc": { "start": { @@ -160,8 +96,9 @@ } } }, - "kind": "constructor", - "static": false, + "kind": "method", + "accessibility": "public", + "static": true, "optional": false, "computed": false, "value": { @@ -170,7 +107,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "constructor", + "name": "main", "decorators": [], "loc": { "start": { @@ -227,73 +164,29 @@ "decorators": [], "loc": { "start": { - "line": 20, - "column": 2 + "line": 1, + "column": 1 }, "end": { - "line": 20, - "column": 2 + "line": 1, + "column": 1 } } - } - ], - "loc": { - "start": { - "line": 18, - "column": 16 }, - "end": { - "line": 20, - "column": 2 - } - } - }, - "loc": { - "start": { - "line": 18, - "column": 8 - }, - "end": { - "line": 20, - "column": 2 - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "ETSGLOBAL", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "superClass": null, - "implements": [], - "body": [ { "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "main", + "name": "_$init$_", "decorators": [], "loc": { "start": { - "line": 23, - "column": 10 + "line": 1, + "column": 1 }, "end": { - "line": 23, - "column": 14 + "line": 1, + "column": 1 } } }, @@ -308,16 +201,16 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "main", + "name": "_$init$_", "decorators": [], "loc": { "start": { - "line": 23, - "column": 10 + "line": 1, + "column": 1 }, "end": { - "line": 23, - "column": 14 + "line": 1, + "column": 1 } } }, @@ -325,195 +218,165 @@ "async": false, "expression": false, "params": [], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 23, - "column": 19 - }, - "end": { - "line": 23, - "column": 23 - } - } - }, "body": { "type": "BlockStatement", "statements": [ { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "a", - "decorators": [], - "loc": { - "start": { - "line": 24, - "column": 9 - }, - "end": { - "line": 24, - "column": 10 - } + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "test_var", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 18, + "column": 13 } - }, - "init": { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { + } + }, + "right": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "TSQualifiedName", + "left": { "type": "Identifier", - "name": "A", + "name": "all", "decorators": [], "loc": { "start": { - "line": 24, - "column": 17 + "line": 18, + "column": 20 }, "end": { - "line": 24, - "column": 18 + "line": 18, + "column": 23 + } + } + }, + "right": { + "type": "Identifier", + "name": "TestClass", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 24 + }, + "end": { + "line": 18, + "column": 33 } } }, "loc": { "start": { - "line": 24, - "column": 17 + "line": 18, + "column": 20 }, "end": { - "line": 24, - "column": 19 + "line": 18, + "column": 34 } } }, "loc": { "start": { - "line": 24, - "column": 17 + "line": 18, + "column": 20 }, "end": { - "line": 24, - "column": 19 + "line": 18, + "column": 34 } } }, - "arguments": [], "loc": { "start": { - "line": 24, - "column": 13 + "line": 18, + "column": 20 }, "end": { - "line": 24, - "column": 21 + "line": 18, + "column": 34 } } }, + "arguments": [], "loc": { "start": { - "line": 24, - "column": 9 + "line": 18, + "column": 16 }, "end": { - "line": 24, - "column": 21 + "line": 18, + "column": 36 } } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 24, - "column": 5 }, - "end": { - "line": 24, - "column": 21 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "foo_in_3", - "decorators": [], - "loc": { - "start": { - "line": 25, - "column": 5 - }, - "end": { - "line": 25, - "column": 13 - } - } - }, - "arguments": [], - "optional": false, "loc": { "start": { - "line": 25, + "line": 18, "column": 5 }, "end": { - "line": 25, - "column": 15 + "line": 18, + "column": 36 } } }, "loc": { "start": { - "line": 25, + "line": 18, "column": 5 }, "end": { - "line": 25, - "column": 16 + "line": 18, + "column": 36 } } } ], "loc": { "start": { - "line": 23, - "column": 24 + "line": 1, + "column": 1 }, "end": { - "line": 26, - "column": 2 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 23, - "column": 14 + "line": 1, + "column": 1 }, "end": { - "line": 26, - "column": 2 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 23, - "column": 14 + "line": 1, + "column": 1 }, "end": { - "line": 26, - "column": 2 + "line": 1, + "column": 1 } } }, @@ -521,12 +384,131 @@ "decorators": [], "loc": { "start": { - "line": 23, + "line": 1, + "column": 1 + }, + "end": { + "line": 1, "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "test_var", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 18, + "column": 13 + } + } + }, + "value": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "TSQualifiedName", + "left": { + "type": "Identifier", + "name": "all", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 20 + }, + "end": { + "line": 18, + "column": 23 + } + } + }, + "right": { + "type": "Identifier", + "name": "TestClass", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 24 + }, + "end": { + "line": 18, + "column": 33 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 20 + }, + "end": { + "line": 18, + "column": 34 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 20 + }, + "end": { + "line": 18, + "column": 34 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 20 + }, + "end": { + "line": 18, + "column": 34 + } + } + }, + "arguments": [], + "loc": { + "start": { + "line": 18, + "column": 16 + }, + "end": { + "line": 18, + "column": 36 + } + } + }, + "accessibility": "public", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 5 }, "end": { - "line": 26, - "column": 2 + "line": 18, + "column": 36 } } } @@ -560,8 +542,9 @@ "column": 1 }, "end": { - "line": 27, + "line": 19, "column": 1 } } } +TypeError: Cannot find imported element 'TestClass' exported with alias [namespace_import_wrong_access_name.sts:18:24] diff --git a/ets2panda/test/parser/ets/import_tests/import_nested_class_1.sts b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/namespace_import_wrong_access_name.sts similarity index 88% rename from ets2panda/test/parser/ets/import_tests/import_nested_class_1.sts rename to ets2panda/test/compiler/ets/import_tests/selective_export_tests/namespace_import_wrong_access_name.sts index 091234e0aab6a53086cac6286c639cec42e2f2e8..de48420948d04387d0c7df5bca75d98ad40e1f52 100644 --- a/ets2panda/test/parser/ets/import_tests/import_nested_class_1.sts +++ b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/namespace_import_wrong_access_name.sts @@ -13,6 +13,6 @@ * limitations under the License. */ -import Enclosing.Nested from "import_tests/modules/module"; +import * as all from "./selective_export" -let x = new Nested(); +let test_var = new all.TestClass(); diff --git a/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export-expected.txt b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..203d3feaac6505699d43a1113c55fb0620d6c48c --- /dev/null +++ b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export-expected.txt @@ -0,0 +1,1157 @@ +{ + "type": "Program", + "statements": [ + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "TestClass", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 7 + }, + "end": { + "line": 20, + "column": 16 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "test_member", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "column": 16 + } + } + }, + "value": { + "type": "StringLiteral", + "value": "test_member", + "loc": { + "start": { + "line": 21, + "column": 19 + }, + "end": { + "line": 21, + "column": 32 + } + } + }, + "accessibility": "public", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "column": 32 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "test_method", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 5 + }, + "end": { + "line": 23, + "column": 16 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "test_method", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 5 + }, + "end": { + "line": 23, + "column": 16 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 23, + "column": 20 + }, + "end": { + "line": 23, + "column": 24 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 23, + "column": 25 + }, + "end": { + "line": 23, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 16 + }, + "end": { + "line": 23, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 16 + }, + "end": { + "line": 23, + "column": 27 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 5 + }, + "end": { + "line": 23, + "column": 27 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "constructor", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 2 + }, + "end": { + "line": 24, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 20, + "column": 17 + }, + "end": { + "line": 24, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1 + }, + "end": { + "line": 24, + "column": 2 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "AliasClass", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 7 + }, + "end": { + "line": 26, + "column": 17 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "alias_class_method", + "decorators": [], + "loc": { + "start": { + "line": 27, + "column": 5 + }, + "end": { + "line": 27, + "column": 23 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "alias_class_method", + "decorators": [], + "loc": { + "start": { + "line": 27, + "column": 5 + }, + "end": { + "line": 27, + "column": 23 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 27, + "column": 27 + }, + "end": { + "line": 27, + "column": 31 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "console", + "decorators": [], + "loc": { + "start": { + "line": 28, + "column": 9 + }, + "end": { + "line": 28, + "column": 16 + } + } + }, + "property": { + "type": "Identifier", + "name": "print", + "decorators": [], + "loc": { + "start": { + "line": 28, + "column": 17 + }, + "end": { + "line": 28, + "column": 22 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 28, + "column": 9 + }, + "end": { + "line": 28, + "column": 22 + } + } + }, + "arguments": [ + { + "type": "StringLiteral", + "value": "alias_class_method", + "loc": { + "start": { + "line": 28, + "column": 23 + }, + "end": { + "line": 28, + "column": 43 + } + } + } + ], + "optional": false, + "loc": { + "start": { + "line": 28, + "column": 9 + }, + "end": { + "line": 28, + "column": 44 + } + } + }, + "loc": { + "start": { + "line": 28, + "column": 9 + }, + "end": { + "line": 28, + "column": 45 + } + } + } + ], + "loc": { + "start": { + "line": 27, + "column": 32 + }, + "end": { + "line": 29, + "column": 6 + } + } + }, + "loc": { + "start": { + "line": 27, + "column": 23 + }, + "end": { + "line": 29, + "column": 6 + } + } + }, + "loc": { + "start": { + "line": 27, + "column": 23 + }, + "end": { + "line": 29, + "column": 6 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 27, + "column": 5 + }, + "end": { + "line": 29, + "column": 6 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "constructor", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 30, + "column": 2 + }, + "end": { + "line": 30, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 26, + "column": 18 + }, + "end": { + "line": 30, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 1 + }, + "end": { + "line": 30, + "column": 2 + } + } + }, + { + "type": "TSTypeAliasDeclaration", + "id": { + "type": "Identifier", + "name": "aliased", + "decorators": [], + "loc": { + "start": { + "line": 32, + "column": 6 + }, + "end": { + "line": 32, + "column": 13 + } + } + }, + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "AliasClass", + "decorators": [], + "loc": { + "start": { + "line": 32, + "column": 16 + }, + "end": { + "line": 32, + "column": 26 + } + } + }, + "loc": { + "start": { + "line": 32, + "column": 16 + }, + "end": { + "line": 32, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 32, + "column": 16 + }, + "end": { + "line": 32, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 32, + "column": 1 + }, + "end": { + "line": 32, + "column": 27 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ETSGLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "main", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "msg", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 18, + "column": 8 + } + } + }, + "right": { + "type": "StringLiteral", + "value": "hello", + "loc": { + "start": { + "line": 18, + "column": 11 + }, + "end": { + "line": 18, + "column": 18 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 18, + "column": 18 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 18, + "column": 18 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "test_func", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 10 + }, + "end": { + "line": 16, + "column": 19 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "test_func", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 10 + }, + "end": { + "line": 16, + "column": 19 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 16, + "column": 23 + }, + "end": { + "line": 16, + "column": 27 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 16, + "column": 28 + }, + "end": { + "line": 16, + "column": 30 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 19 + }, + "end": { + "line": 16, + "column": 30 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 19 + }, + "end": { + "line": 16, + "column": 30 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 1 + }, + "end": { + "line": 16, + "column": 30 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "msg", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 18, + "column": 8 + } + } + }, + "value": { + "type": "StringLiteral", + "value": "hello", + "loc": { + "start": { + "line": 18, + "column": 11 + }, + "end": { + "line": 18, + "column": 18 + } + } + }, + "accessibility": "public", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 18, + "column": 18 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 39, + "column": 1 + } + } +} diff --git a/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export.sts b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export.sts new file mode 100644 index 0000000000000000000000000000000000000000..0e0fe091a65b1a18cba6879f1fc356c0933d993e --- /dev/null +++ b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export.sts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function test_func(): void {} + +let msg = "hello"; + +class TestClass { + test_member = "test_member"; + + test_method(): void {} +} + +class AliasClass { + alias_class_method(): void { + console.print("alias_class_method"); + } +} + +type aliased = AliasClass; + +export { + test_func as func, msg, + TestClass as tc, + aliased +} diff --git a/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_1-expected.txt b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_1-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..71bfb7b363d701d3acc448aa577c9947d630ecfa --- /dev/null +++ b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_1-expected.txt @@ -0,0 +1 @@ +SyntaxError: Cannot export 'foo', it was already exported [selective_export_clashing_exports_1.sts:19:10] diff --git a/ets2panda/test/parser/ets/import_tests/import_separate_module.sts b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_1.sts similarity index 89% rename from ets2panda/test/parser/ets/import_tests/import_separate_module.sts rename to ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_1.sts index bb33fd4b76fe81d4c923f1f9101385071f75a0e1..a6e150c959792ec0a47056f2962d1ec9292d1551 100644 --- a/ets2panda/test/parser/ets/import_tests/import_separate_module.sts +++ b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_1.sts @@ -13,6 +13,8 @@ * limitations under the License. */ -import * as all from "import_tests/modules/module"; +export function foo(): void {} -let x = all.dbl; +export { + foo as bar +} diff --git a/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_2-expected.txt b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_2-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..8fc6fee19ebb29e82d73518ae8ce18700edb83d8 --- /dev/null +++ b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_2-expected.txt @@ -0,0 +1 @@ +SyntaxError: Cannot export 'foo', it was already exported [selective_export_clashing_exports_2.sts:19:10] diff --git a/ets2panda/test/parser/ets/import_tests/import_class_members_1.sts b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_2.sts similarity index 88% rename from ets2panda/test/parser/ets/import_tests/import_class_members_1.sts rename to ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_2.sts index fbb005d3c17e84b0a4ebfd47e4e63a42008ef734..3fb34fc5e7d98c811af27616a0e40a9af3382777 100644 --- a/ets2panda/test/parser/ets/import_tests/import_class_members_1.sts +++ b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_2.sts @@ -13,6 +13,8 @@ * limitations under the License. */ -import Enclosing.fieldA from "import_tests/modules/module"; +export default function foo(): void {} -let x = fieldA; +export { + foo as bar +} diff --git a/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_3-expected.txt b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_3-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..5063f18fc062b878b4735c827f6598a4d6fb93df --- /dev/null +++ b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_3-expected.txt @@ -0,0 +1 @@ +SyntaxError: The given name 'foo' is already used in another export [selective_export_clashing_exports_3.sts:21:10] diff --git a/ets2panda/test/parser/ets/import_tests/import_nested_class_2.sts b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_3.sts similarity index 88% rename from ets2panda/test/parser/ets/import_tests/import_nested_class_2.sts rename to ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_3.sts index fcc005aee9d64dc680b2ec2eff9b8678f80e8390..d0d9d293534155b0b008cc6ab0c505024afc36cc 100644 --- a/ets2panda/test/parser/ets/import_tests/import_nested_class_2.sts +++ b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_3.sts @@ -13,6 +13,10 @@ * limitations under the License. */ -import Enclosing.* from "import_tests/modules/module"; +export function foo(): void {} -let x = new Nested(); +let msg = "hello"; + +export { + msg as foo +} diff --git a/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_4-expected.txt b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_4-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..1bf388931064ad2b8b95872d865c8c63705ceb03 --- /dev/null +++ b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_4-expected.txt @@ -0,0 +1 @@ +SyntaxError: The given name 'foo' is already used in another export [selective_export_clashing_exports_4.sts:21:10] diff --git a/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_4.sts b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_4.sts new file mode 100644 index 0000000000000000000000000000000000000000..7b8b5f7b450a0b48d9f406cbf96a337bb519887f --- /dev/null +++ b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_clashing_exports_4.sts @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default function foo(): void {} + +let msg = "hello"; + +export { + msg as foo +} diff --git a/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_function-expected.txt b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_function-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..16124914e4858f7a9a7f07e609d54e803c40ae00 --- /dev/null +++ b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_function-expected.txt @@ -0,0 +1,260 @@ +{ + "type": "Program", + "statements": [ + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ETSGLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "test_func", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 10 + }, + "end": { + "line": 16, + "column": 19 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "test_func", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 10 + }, + "end": { + "line": 16, + "column": 19 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 16, + "column": 23 + }, + "end": { + "line": 16, + "column": 27 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 16, + "column": 28 + }, + "end": { + "line": 16, + "column": 30 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 19 + }, + "end": { + "line": 16, + "column": 30 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 19 + }, + "end": { + "line": 16, + "column": 30 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 1 + }, + "end": { + "line": 16, + "column": 30 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 21, + "column": 1 + } + } +} diff --git a/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_function.sts b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_function.sts new file mode 100644 index 0000000000000000000000000000000000000000..b2843f7bb2271ef8c349cfe2d671351f36bd8e56 --- /dev/null +++ b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_function.sts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function test_func(): void {} + +export { + test_func as func +} diff --git a/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_interface-expected.txt b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_interface-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..d42e05e3b2c5082509f4f88b582cef5212594ffb --- /dev/null +++ b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_interface-expected.txt @@ -0,0 +1,239 @@ +{ + "type": "Program", + "statements": [ + { + "type": "TSInterfaceDeclaration", + "body": { + "type": "TSInterfaceBody", + "body": [], + "loc": { + "start": { + "line": 16, + "column": 25 + }, + "end": { + "line": 16, + "column": 27 + } + } + }, + "id": { + "type": "Identifier", + "name": "TestInterface", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 11 + }, + "end": { + "line": 16, + "column": 24 + } + } + }, + "extends": [], + "loc": { + "start": { + "line": 16, + "column": 1 + }, + "end": { + "line": 17, + "column": 10 + } + } + }, + { + "type": "TSInterfaceDeclaration", + "body": { + "type": "TSInterfaceBody", + "body": [], + "loc": { + "start": { + "line": 17, + "column": 28 + }, + "end": { + "line": 17, + "column": 30 + } + } + }, + "id": { + "type": "Identifier", + "name": "InterfaceToAlias", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 11 + }, + "end": { + "line": 17, + "column": 27 + } + } + }, + "extends": [], + "loc": { + "start": { + "line": 17, + "column": 1 + }, + "end": { + "line": 19, + "column": 7 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ETSGLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 23, + "column": 1 + } + } +} diff --git a/ets2panda/test/parser/ets/recursive_import/case_1_fail_not_called_w_module/foo2__module.sts b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_interface.sts similarity index 83% rename from ets2panda/test/parser/ets/recursive_import/case_1_fail_not_called_w_module/foo2__module.sts rename to ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_interface.sts index 0885357093d4b3c486b86b8015011baa7aa48838..1ffcec9e6f4fb7ec1bef7aecda84784333373c45 100644 --- a/ets2panda/test/parser/ets/recursive_import/case_1_fail_not_called_w_module/foo2__module.sts +++ b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_interface.sts @@ -13,9 +13,10 @@ * limitations under the License. */ -import {A} from "./main__foo1" +interface TestInterface {} +interface InterfaceToAlias {} -export function foo(a: A): int { - console.log("in foo"); - return 0; +export { + TestInterface, + InterfaceToAlias as AliasInterface } diff --git a/ets2panda/test/compiler/ets/inferTypeOfArrayNegative1-expected.txt b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_with_alias-expected.txt similarity index 75% rename from ets2panda/test/compiler/ets/inferTypeOfArrayNegative1-expected.txt rename to ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_with_alias-expected.txt index 6417db5f5d7d8e8a812e5a24a2209c1918afa51a..cc8fc2edbbc6f3d7490a6671673c1e8772c935b6 100644 --- a/ets2panda/test/compiler/ets/inferTypeOfArrayNegative1-expected.txt +++ b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_with_alias-expected.txt @@ -171,95 +171,52 @@ "operator": "=", "left": { "type": "Identifier", - "name": "a", + "name": "msg", "decorators": [], "loc": { "start": { - "line": 16, + "line": 18, "column": 5 }, "end": { - "line": 16, - "column": 6 + "line": 18, + "column": 8 } } }, "right": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "a", - "loc": { - "start": { - "line": 16, - "column": 10 - }, - "end": { - "line": 16, - "column": 13 - } - } - }, - { - "type": "NumberLiteral", - "value": 1, - "loc": { - "start": { - "line": 16, - "column": 15 - }, - "end": { - "line": 16, - "column": 16 - } - } - }, - { - "type": "NumberLiteral", - "value": 3.14, - "loc": { - "start": { - "line": 16, - "column": 18 - }, - "end": { - "line": 16, - "column": 22 - } - } - } - ], + "type": "StringLiteral", + "value": "hello", "loc": { "start": { - "line": 16, - "column": 9 + "line": 18, + "column": 11 }, "end": { - "line": 16, - "column": 23 + "line": 18, + "column": 18 } } }, "loc": { "start": { - "line": 16, + "line": 18, "column": 5 }, "end": { - "line": 16, - "column": 23 + "line": 18, + "column": 18 } } }, "loc": { "start": { - "line": 16, + "line": 18, "column": 5 }, "end": { - "line": 16, - "column": 23 + "line": 18, + "column": 18 } } } @@ -311,28 +268,35 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "a", + "name": "foo", "decorators": [], "loc": { "start": { "line": 16, - "column": 5 + "column": 10 }, "end": { "line": 16, - "column": 6 + "column": 13 } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "a", + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "foo", + "decorators": [], "loc": { "start": { "line": 16, @@ -344,43 +308,100 @@ } } }, - { - "type": "NumberLiteral", - "value": 1, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSPrimitiveType", "loc": { "start": { "line": 16, - "column": 15 + "column": 17 }, "end": { "line": 16, - "column": 16 + "column": 21 } } }, - { - "type": "NumberLiteral", - "value": 3.14, + "body": { + "type": "BlockStatement", + "statements": [], "loc": { "start": { "line": 16, - "column": 18 + "column": 22 }, "end": { "line": 16, - "column": 22 + "column": 24 } } + }, + "loc": { + "start": { + "line": 16, + "column": 13 + }, + "end": { + "line": 16, + "column": 24 + } } - ], + }, "loc": { "start": { "line": 16, - "column": 9 + "column": 13 }, "end": { "line": 16, - "column": 23 + "column": 24 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 1 + }, + "end": { + "line": 16, + "column": 24 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "msg", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 18, + "column": 8 + } + } + }, + "value": { + "type": "StringLiteral", + "value": "hello", + "loc": { + "start": { + "line": 18, + "column": 11 + }, + "end": { + "line": 18, + "column": 18 } } }, @@ -394,12 +415,12 @@ "decorators": [], "loc": { "start": { - "line": 16, + "line": 18, "column": 5 }, "end": { - "line": 16, - "column": 23 + "line": 18, + "column": 18 } } } @@ -433,9 +454,8 @@ "column": 1 }, "end": { - "line": 17, + "line": 23, "column": 1 } } } -TypeError: Union type is not implemented yet! [inferTypeOfArrayNegative1.sts:16:5] diff --git a/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_with_alias.sts b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_with_alias.sts new file mode 100644 index 0000000000000000000000000000000000000000..11af1b7dc4486c1b58087fdf7a3565668a490ee8 --- /dev/null +++ b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_export_with_alias.sts @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function foo(): void {} + +let msg = "hello"; + +export { + msg as foo +} diff --git a/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_import_with_alias_1-expected.txt b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_import_with_alias_1-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..0df208ec173ee4e00379015052eab19acc1d9d9d --- /dev/null +++ b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_import_with_alias_1-expected.txt @@ -0,0 +1,417 @@ +{ + "type": "Program", + "statements": [ + { + "type": "ImportDeclaration", + "source": { + "type": "StringLiteral", + "value": "./selective_export_interface", + "loc": { + "start": { + "line": 16, + "column": 51 + }, + "end": { + "line": 16, + "column": 81 + } + } + }, + "specifiers": [ + { + "type": "ImportSpecifier", + "local": { + "type": "Identifier", + "name": "NotAliasInterface", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 27 + }, + "end": { + "line": 16, + "column": 44 + } + } + }, + "imported": { + "type": "Identifier", + "name": "AliasInterface", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 9 + }, + "end": { + "line": 16, + "column": 23 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 9 + }, + "end": { + "line": 16, + "column": 44 + } + } + } + ], + "loc": { + "start": { + "line": 16, + "column": 1 + }, + "end": { + "line": 16, + "column": 81 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "TestClass", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 7 + }, + "end": { + "line": 18, + "column": 16 + } + } + }, + "superClass": null, + "implements": [ + { + "type": "TSClassImplements", + "expression": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "NotAliasInterface", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 28 + }, + "end": { + "line": 18, + "column": 45 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 28 + }, + "end": { + "line": 18, + "column": 47 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 28 + }, + "end": { + "line": 18, + "column": 47 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 28 + }, + "end": { + "line": 18, + "column": 47 + } + } + } + ], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "constructor", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 48 + }, + "end": { + "line": 18, + "column": 48 + } + } + } + ], + "loc": { + "start": { + "line": 18, + "column": 46 + }, + "end": { + "line": 18, + "column": 48 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 1 + }, + "end": { + "line": 18, + "column": 48 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ETSGLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 19, + "column": 1 + } + } +} diff --git a/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_import_with_alias_1.sts b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_import_with_alias_1.sts new file mode 100644 index 0000000000000000000000000000000000000000..34ef91370e88503af7a0ba8ceac13649f2b357a3 --- /dev/null +++ b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_import_with_alias_1.sts @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import {AliasInterface as NotAliasInterface} from "./selective_export_interface" + +class TestClass implements NotAliasInterface {} diff --git a/ets2panda/test/parser/ets/recursive_import/case_5_main-is-not-part-of-circle/main__foo1-expected.txt b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_import_with_alias_2-expected.txt similarity index 67% rename from ets2panda/test/parser/ets/recursive_import/case_5_main-is-not-part-of-circle/main__foo1-expected.txt rename to ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_import_with_alias_2-expected.txt index 8910b1506dbd8a48d1b49f766be54573b428a761..c1f9019854b9bd34f833b70d8fd78fe57cc4c1f6 100644 --- a/ets2panda/test/parser/ets/recursive_import/case_5_main-is-not-part-of-circle/main__foo1-expected.txt +++ b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_import_with_alias_2-expected.txt @@ -5,15 +5,15 @@ "type": "ImportDeclaration", "source": { "type": "StringLiteral", - "value": "./foo2__module", + "value": "./selective_export_interface", "loc": { "start": { "line": 16, - "column": 24 + "column": 47 }, "end": { "line": 16, - "column": 40 + "column": 77 } } }, @@ -22,22 +22,22 @@ "type": "ImportSpecifier", "local": { "type": "Identifier", - "name": "foo_in_2", + "name": "InterfaceAlias", "decorators": [], "loc": { "start": { "line": 16, - "column": 9 + "column": 26 }, "end": { "line": 16, - "column": 17 + "column": 40 } } }, "imported": { "type": "Identifier", - "name": "foo_in_2", + "name": "TestInterface", "decorators": [], "loc": { "start": { @@ -46,7 +46,7 @@ }, "end": { "line": 16, - "column": 17 + "column": 22 } } }, @@ -57,7 +57,7 @@ }, "end": { "line": 16, - "column": 17 + "column": 40 } } } @@ -69,7 +69,7 @@ }, "end": { "line": 16, - "column": 40 + "column": 77 } } }, @@ -78,27 +78,82 @@ "definition": { "id": { "type": "Identifier", - "name": "ETSGLOBAL", + "name": "TestClass", "decorators": [], "loc": { "start": { - "line": 1, - "column": 1 + "line": 18, + "column": 7 }, "end": { - "line": 1, - "column": 1 + "line": 18, + "column": 16 } } }, "superClass": null, - "implements": [], + "implements": [ + { + "type": "TSClassImplements", + "expression": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "InterfaceAlias", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 28 + }, + "end": { + "line": 18, + "column": 42 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 28 + }, + "end": { + "line": 18, + "column": 44 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 28 + }, + "end": { + "line": 18, + "column": 44 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 28 + }, + "end": { + "line": 18, + "column": 44 + } + } + } + ], "body": [ { "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "_$init$_", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -111,9 +166,8 @@ } } }, - "kind": "method", - "accessibility": "public", - "static": true, + "kind": "constructor", + "static": false, "optional": false, "computed": false, "value": { @@ -122,7 +176,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "_$init$_", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -179,29 +233,73 @@ "decorators": [], "loc": { "start": { - "line": 1, - "column": 1 + "line": 18, + "column": 45 }, "end": { - "line": 1, - "column": 1 + "line": 18, + "column": 45 } } + } + ], + "loc": { + "start": { + "line": 18, + "column": 43 }, + "end": { + "line": 18, + "column": 45 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 1 + }, + "end": { + "line": 18, + "column": 45 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ETSGLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ { "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "main", + "name": "_$init$_", "decorators": [], "loc": { "start": { - "line": 18, - "column": 10 + "line": 1, + "column": 1 }, "end": { - "line": 18, - "column": 14 + "line": 1, + "column": 1 } } }, @@ -216,16 +314,16 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "main", + "name": "_$init$_", "decorators": [], "loc": { "start": { - "line": 18, - "column": 10 + "line": 1, + "column": 1 }, "end": { - "line": 18, - "column": 14 + "line": 1, + "column": 1 } } }, @@ -233,96 +331,39 @@ "async": false, "expression": false, "params": [], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 18, - "column": 19 - }, - "end": { - "line": 18, - "column": 23 - } - } - }, "body": { "type": "BlockStatement", - "statements": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "foo_in_2", - "decorators": [], - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 13 - } - } - }, - "arguments": [], - "optional": false, - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 15 - } - } - }, - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 16 - } - } - } - ], + "statements": [], "loc": { "start": { - "line": 18, - "column": 24 + "line": 1, + "column": 1 }, "end": { - "line": 20, - "column": 2 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 18, - "column": 14 + "line": 1, + "column": 1 }, "end": { - "line": 20, - "column": 2 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 18, - "column": 14 + "line": 1, + "column": 1 }, "end": { - "line": 20, - "column": 2 + "line": 1, + "column": 1 } } }, @@ -330,12 +371,12 @@ "decorators": [], "loc": { "start": { - "line": 18, + "line": 1, "column": 1 }, "end": { - "line": 20, - "column": 2 + "line": 1, + "column": 1 } } } @@ -369,7 +410,7 @@ "column": 1 }, "end": { - "line": 21, + "line": 19, "column": 1 } } diff --git a/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_import_with_alias_2.sts b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_import_with_alias_2.sts new file mode 100644 index 0000000000000000000000000000000000000000..5ccc9bb6f6ea5d182335dc99baa3cf9963ddb13b --- /dev/null +++ b/ets2panda/test/compiler/ets/import_tests/selective_export_tests/selective_import_with_alias_2.sts @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import {TestInterface as InterfaceAlias} from "./selective_export_interface" + +class TestClass implements InterfaceAlias {} diff --git a/ets2panda/test/compiler/ets/instanceof_dyndecl_dynvalue-expected.txt b/ets2panda/test/compiler/ets/instanceof_dyndecl_dynvalue-expected.txt index e1bec4ead9e3a0d4b3f33baa2985c45cd7482548..96e895ca22b02de23f8cfbfd6806ff52ee393314 100644 --- a/ets2panda/test/compiler/ets/instanceof_dyndecl_dynvalue-expected.txt +++ b/ets2panda/test/compiler/ets/instanceof_dyndecl_dynvalue-expected.txt @@ -1 +1,979 @@ TypeError: Right-hand side of instanceof expression must represent a type. [instanceof_dyndecl_dynvalue.sts:24:12] +{ + "type": "Program", + "statements": [ + { + "type": "ImportDeclaration", + "source": { + "type": "StringLiteral", + "value": "dynamic_js_import_tests", + "loc": { + "start": { + "line": 20, + "column": 19 + }, + "end": { + "line": 20, + "column": 44 + } + } + }, + "specifiers": [ + { + "type": "ImportSpecifier", + "local": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 10 + }, + "end": { + "line": 20, + "column": 11 + } + } + }, + "imported": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 10 + }, + "end": { + "line": 20, + "column": 11 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 10 + }, + "end": { + "line": 20, + "column": 11 + } + } + } + ], + "loc": { + "start": { + "line": 20, + "column": 1 + }, + "end": { + "line": 20, + "column": 44 + } + } + }, + { + "type": "ImportDeclaration", + "source": { + "type": "StringLiteral", + "value": "dynamic_import_tests/modules/instanceof", + "loc": { + "start": { + "line": 21, + "column": 27 + }, + "end": { + "line": 21, + "column": 68 + } + } + }, + "specifiers": [ + { + "type": "ImportSpecifier", + "local": { + "type": "Identifier", + "name": "ADeclared", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 10 + }, + "end": { + "line": 21, + "column": 19 + } + } + }, + "imported": { + "type": "Identifier", + "name": "ADeclared", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 10 + }, + "end": { + "line": 21, + "column": 19 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 10 + }, + "end": { + "line": 21, + "column": 19 + } + } + } + ], + "loc": { + "start": { + "line": 21, + "column": 1 + }, + "end": { + "line": 21, + "column": 68 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ETSGLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "fn", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 10 + }, + "end": { + "line": 23, + "column": 12 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "fn", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 10 + }, + "end": { + "line": 23, + "column": 12 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "o", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "ADeclared", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 16 + }, + "end": { + "line": 23, + "column": 25 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 16 + }, + "end": { + "line": 23, + "column": 26 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 16 + }, + "end": { + "line": 23, + "column": 26 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 13 + }, + "end": { + "line": 23, + "column": 26 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 13 + }, + "end": { + "line": 23, + "column": 26 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 23, + "column": 28 + }, + "end": { + "line": 23, + "column": 35 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "BinaryExpression", + "operator": "instanceof", + "left": { + "type": "Identifier", + "name": "o", + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 12 + }, + "end": { + "line": 24, + "column": 13 + } + } + }, + "right": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 25 + }, + "end": { + "line": 24, + "column": 26 + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 25 + }, + "end": { + "line": 24, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 25 + }, + "end": { + "line": 24, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 12 + }, + "end": { + "line": 24, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 5 + }, + "end": { + "line": 24, + "column": 27 + } + } + } + ], + "loc": { + "start": { + "line": 23, + "column": 36 + }, + "end": { + "line": 25, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 12 + }, + "end": { + "line": 25, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 12 + }, + "end": { + "line": 25, + "column": 2 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 1 + }, + "end": { + "line": 25, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "$dynmodule", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "dynamic_js_import_tests0", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "public", + "static": true, + "readonly": true, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "OpaqueType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassStaticBlock", + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": true, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "$dynmodule", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "dynamic_js_import_tests0", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "JSRuntime", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "loadModule", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "StringLiteral", + "value": "dynamic_js_import_tests", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "init", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "OpaqueType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 27, + "column": 1 + } + } +} diff --git a/ets2panda/test/compiler/ets/instanceof_dyndecl_jsvalue-expected.txt b/ets2panda/test/compiler/ets/instanceof_dyndecl_jsvalue-expected.txt index a86ba39bac425e57023d625bce8f85445629d942..02d80c075b74115f1cd90c5a54722fb95fe4a339 100644 --- a/ets2panda/test/compiler/ets/instanceof_dyndecl_jsvalue-expected.txt +++ b/ets2panda/test/compiler/ets/instanceof_dyndecl_jsvalue-expected.txt @@ -1 +1,487 @@ TypeError: Right-hand side of instanceof expression must represent a type. [instanceof_dyndecl_jsvalue.sts:23:12] +{ + "type": "Program", + "statements": [ + { + "type": "ImportDeclaration", + "source": { + "type": "StringLiteral", + "value": "dynamic_import_tests/modules/instanceof", + "loc": { + "start": { + "line": 20, + "column": 27 + }, + "end": { + "line": 20, + "column": 68 + } + } + }, + "specifiers": [ + { + "type": "ImportSpecifier", + "local": { + "type": "Identifier", + "name": "ADeclared", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 10 + }, + "end": { + "line": 20, + "column": 19 + } + } + }, + "imported": { + "type": "Identifier", + "name": "ADeclared", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 10 + }, + "end": { + "line": 20, + "column": 19 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 10 + }, + "end": { + "line": 20, + "column": 19 + } + } + } + ], + "loc": { + "start": { + "line": 20, + "column": 1 + }, + "end": { + "line": 20, + "column": 68 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ETSGLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "fn_dyn_decl", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 10 + }, + "end": { + "line": 22, + "column": 21 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "fn_dyn_decl", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 10 + }, + "end": { + "line": 22, + "column": 21 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "o", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "ADeclared", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 25 + }, + "end": { + "line": 22, + "column": 34 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 25 + }, + "end": { + "line": 22, + "column": 35 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 25 + }, + "end": { + "line": 22, + "column": 35 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 22 + }, + "end": { + "line": 22, + "column": 35 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 22 + }, + "end": { + "line": 22, + "column": 35 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 22, + "column": 37 + }, + "end": { + "line": 22, + "column": 44 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "BinaryExpression", + "operator": "instanceof", + "left": { + "type": "Identifier", + "name": "o", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 12 + }, + "end": { + "line": 23, + "column": 13 + } + } + }, + "right": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "JSValue", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 25 + }, + "end": { + "line": 23, + "column": 32 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 25 + }, + "end": { + "line": 23, + "column": 33 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 25 + }, + "end": { + "line": 23, + "column": 33 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 12 + }, + "end": { + "line": 23, + "column": 33 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 5 + }, + "end": { + "line": 23, + "column": 33 + } + } + } + ], + "loc": { + "start": { + "line": 22, + "column": 45 + }, + "end": { + "line": 24, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 21 + }, + "end": { + "line": 24, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 21 + }, + "end": { + "line": 24, + "column": 2 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 1 + }, + "end": { + "line": 24, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 25, + "column": 1 + } + } +} diff --git a/ets2panda/test/compiler/ets/instanceof_dynvalue_dynvalue-expected.txt b/ets2panda/test/compiler/ets/instanceof_dynvalue_dynvalue-expected.txt index 7525918b64bae31b02a581c901c314b3a4b2e5f9..7711e970399d3a8ee59fbdfd6c97fefb54a2b6f8 100644 --- a/ets2panda/test/compiler/ets/instanceof_dynvalue_dynvalue-expected.txt +++ b/ets2panda/test/compiler/ets/instanceof_dynvalue_dynvalue-expected.txt @@ -1 +1,950 @@ TypeError: Right-hand side of instanceof expression must represent a type. [instanceof_dynvalue_dynvalue.sts:23:12] +{ + "type": "Program", + "statements": [ + { + "type": "ImportDeclaration", + "source": { + "type": "StringLiteral", + "value": "dynamic_js_import_tests", + "loc": { + "start": { + "line": 20, + "column": 22 + }, + "end": { + "line": 20, + "column": 47 + } + } + }, + "specifiers": [ + { + "type": "ImportSpecifier", + "local": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 10 + }, + "end": { + "line": 20, + "column": 11 + } + } + }, + "imported": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 10 + }, + "end": { + "line": 20, + "column": 11 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 10 + }, + "end": { + "line": 20, + "column": 11 + } + } + }, + { + "type": "ImportSpecifier", + "local": { + "type": "Identifier", + "name": "B", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 13 + }, + "end": { + "line": 20, + "column": 14 + } + } + }, + "imported": { + "type": "Identifier", + "name": "B", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 13 + }, + "end": { + "line": 20, + "column": 14 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 13 + }, + "end": { + "line": 20, + "column": 14 + } + } + } + ], + "loc": { + "start": { + "line": 20, + "column": 1 + }, + "end": { + "line": 20, + "column": 47 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ETSGLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "fn", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 10 + }, + "end": { + "line": 22, + "column": 12 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "fn", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 10 + }, + "end": { + "line": 22, + "column": 12 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "o", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "B", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 16 + }, + "end": { + "line": 22, + "column": 17 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 16 + }, + "end": { + "line": 22, + "column": 18 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 16 + }, + "end": { + "line": 22, + "column": 18 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 13 + }, + "end": { + "line": 22, + "column": 18 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 13 + }, + "end": { + "line": 22, + "column": 18 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 22, + "column": 20 + }, + "end": { + "line": 22, + "column": 27 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "BinaryExpression", + "operator": "instanceof", + "left": { + "type": "Identifier", + "name": "o", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 12 + }, + "end": { + "line": 23, + "column": 13 + } + } + }, + "right": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 25 + }, + "end": { + "line": 23, + "column": 26 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 25 + }, + "end": { + "line": 23, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 25 + }, + "end": { + "line": 23, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 12 + }, + "end": { + "line": 23, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 5 + }, + "end": { + "line": 23, + "column": 27 + } + } + } + ], + "loc": { + "start": { + "line": 22, + "column": 28 + }, + "end": { + "line": 24, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 12 + }, + "end": { + "line": 24, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 12 + }, + "end": { + "line": 24, + "column": 2 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 1 + }, + "end": { + "line": 24, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "$dynmodule", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "dynamic_js_import_tests0", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "public", + "static": true, + "readonly": true, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "OpaqueType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassStaticBlock", + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": true, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "$dynmodule", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "dynamic_js_import_tests0", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "JSRuntime", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "loadModule", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "StringLiteral", + "value": "dynamic_js_import_tests", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "init", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "OpaqueType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 25, + "column": 1 + } + } +} diff --git a/ets2panda/test/compiler/ets/instanceof_dynvalue_jsvalue-expected.txt b/ets2panda/test/compiler/ets/instanceof_dynvalue_jsvalue-expected.txt index 08bf19216fedf132d269695a11dba3a7090e079f..b08eeb4634ec42794a82f96ebb8236a3693ac7df 100644 --- a/ets2panda/test/compiler/ets/instanceof_dynvalue_jsvalue-expected.txt +++ b/ets2panda/test/compiler/ets/instanceof_dynvalue_jsvalue-expected.txt @@ -1 +1,907 @@ TypeError: Right-hand side of instanceof expression must represent a type. [instanceof_dynvalue_jsvalue.sts:23:12] +{ + "type": "Program", + "statements": [ + { + "type": "ImportDeclaration", + "source": { + "type": "StringLiteral", + "value": "dynamic_js_import_tests", + "loc": { + "start": { + "line": 20, + "column": 19 + }, + "end": { + "line": 20, + "column": 44 + } + } + }, + "specifiers": [ + { + "type": "ImportSpecifier", + "local": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 10 + }, + "end": { + "line": 20, + "column": 11 + } + } + }, + "imported": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 10 + }, + "end": { + "line": 20, + "column": 11 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 10 + }, + "end": { + "line": 20, + "column": 11 + } + } + } + ], + "loc": { + "start": { + "line": 20, + "column": 1 + }, + "end": { + "line": 20, + "column": 44 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ETSGLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "fn", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 10 + }, + "end": { + "line": 22, + "column": 12 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "fn", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 10 + }, + "end": { + "line": 22, + "column": 12 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "o", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 16 + }, + "end": { + "line": 22, + "column": 17 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 16 + }, + "end": { + "line": 22, + "column": 18 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 16 + }, + "end": { + "line": 22, + "column": 18 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 13 + }, + "end": { + "line": 22, + "column": 18 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 13 + }, + "end": { + "line": 22, + "column": 18 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 22, + "column": 20 + }, + "end": { + "line": 22, + "column": 27 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "BinaryExpression", + "operator": "instanceof", + "left": { + "type": "Identifier", + "name": "o", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 12 + }, + "end": { + "line": 23, + "column": 13 + } + } + }, + "right": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "JSValue", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 25 + }, + "end": { + "line": 23, + "column": 32 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 25 + }, + "end": { + "line": 23, + "column": 33 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 25 + }, + "end": { + "line": 23, + "column": 33 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 12 + }, + "end": { + "line": 23, + "column": 33 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 5 + }, + "end": { + "line": 23, + "column": 33 + } + } + } + ], + "loc": { + "start": { + "line": 22, + "column": 28 + }, + "end": { + "line": 24, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 12 + }, + "end": { + "line": 24, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 12 + }, + "end": { + "line": 24, + "column": 2 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 1 + }, + "end": { + "line": 24, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "$dynmodule", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "dynamic_js_import_tests0", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "public", + "static": true, + "readonly": true, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "OpaqueType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassStaticBlock", + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": true, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "$dynmodule", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "dynamic_js_import_tests0", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "JSRuntime", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "loadModule", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "StringLiteral", + "value": "dynamic_js_import_tests", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "init", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "OpaqueType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 25, + "column": 1 + } + } +} diff --git a/ets2panda/test/compiler/ets/instanceof_etsobject_dynvalue-expected.txt b/ets2panda/test/compiler/ets/instanceof_etsobject_dynvalue-expected.txt index ba9a9bf054d77f5872b8c89ed365102954f0e2bd..119a75c24f916c8bfc79af50ff99a88c3efe1009 100644 --- a/ets2panda/test/compiler/ets/instanceof_etsobject_dynvalue-expected.txt +++ b/ets2panda/test/compiler/ets/instanceof_etsobject_dynvalue-expected.txt @@ -1 +1,1044 @@ TypeError: Right-hand side of instanceof expression must represent a type. [instanceof_etsobject_dynvalue.sts:25:12] +{ + "type": "Program", + "statements": [ + { + "type": "ImportDeclaration", + "source": { + "type": "StringLiteral", + "value": "dynamic_js_import_tests", + "loc": { + "start": { + "line": 20, + "column": 19 + }, + "end": { + "line": 20, + "column": 44 + } + } + }, + "specifiers": [ + { + "type": "ImportSpecifier", + "local": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 10 + }, + "end": { + "line": 20, + "column": 11 + } + } + }, + "imported": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 10 + }, + "end": { + "line": 20, + "column": 11 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 10 + }, + "end": { + "line": 20, + "column": 11 + } + } + } + ], + "loc": { + "start": { + "line": 20, + "column": 1 + }, + "end": { + "line": 20, + "column": 44 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ETSGLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "fn", + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 10 + }, + "end": { + "line": 24, + "column": 12 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "fn", + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 10 + }, + "end": { + "line": 24, + "column": 12 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "o", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "B", + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 16 + }, + "end": { + "line": 24, + "column": 17 + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 16 + }, + "end": { + "line": 24, + "column": 18 + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 16 + }, + "end": { + "line": 24, + "column": 18 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 13 + }, + "end": { + "line": 24, + "column": 18 + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 13 + }, + "end": { + "line": 24, + "column": 18 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 24, + "column": 20 + }, + "end": { + "line": 24, + "column": 27 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "BinaryExpression", + "operator": "instanceof", + "left": { + "type": "Identifier", + "name": "o", + "decorators": [], + "loc": { + "start": { + "line": 25, + "column": 12 + }, + "end": { + "line": 25, + "column": 13 + } + } + }, + "right": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 25, + "column": 25 + }, + "end": { + "line": 25, + "column": 26 + } + } + }, + "loc": { + "start": { + "line": 25, + "column": 25 + }, + "end": { + "line": 25, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 25, + "column": 25 + }, + "end": { + "line": 25, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 25, + "column": 12 + }, + "end": { + "line": 25, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 25, + "column": 5 + }, + "end": { + "line": 25, + "column": 27 + } + } + } + ], + "loc": { + "start": { + "line": 24, + "column": 28 + }, + "end": { + "line": 26, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 12 + }, + "end": { + "line": 26, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 12 + }, + "end": { + "line": 26, + "column": 2 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 1 + }, + "end": { + "line": 26, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "B", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 7 + }, + "end": { + "line": 22, + "column": 8 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "constructor", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 11 + }, + "end": { + "line": 22, + "column": 11 + } + } + } + ], + "loc": { + "start": { + "line": 22, + "column": 9 + }, + "end": { + "line": 22, + "column": 11 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 1 + }, + "end": { + "line": 22, + "column": 11 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "$dynmodule", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "dynamic_js_import_tests0", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "public", + "static": true, + "readonly": true, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "OpaqueType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassStaticBlock", + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": true, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "$dynmodule", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "dynamic_js_import_tests0", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "JSRuntime", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "loadModule", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "StringLiteral", + "value": "dynamic_js_import_tests", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "init", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "OpaqueType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 27, + "column": 1 + } + } +} diff --git a/ets2panda/test/compiler/ets/instanceof_etsobject_jsvalue-expected.txt b/ets2panda/test/compiler/ets/instanceof_etsobject_jsvalue-expected.txt index 8cc14d5a93e7d1e52a34756a90d576aa3c88c4bb..4337145fbda206156b07c3a6cb9e3cf9cfa3c4f2 100644 --- a/ets2panda/test/compiler/ets/instanceof_etsobject_jsvalue-expected.txt +++ b/ets2panda/test/compiler/ets/instanceof_etsobject_jsvalue-expected.txt @@ -1 +1,552 @@ TypeError: Right-hand side of instanceof expression must represent a type. [instanceof_etsobject_jsvalue.sts:23:12] +{ + "type": "Program", + "statements": [ + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ETSGLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "fn", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 10 + }, + "end": { + "line": 22, + "column": 12 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "fn", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 10 + }, + "end": { + "line": 22, + "column": 12 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "o", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 16 + }, + "end": { + "line": 22, + "column": 17 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 16 + }, + "end": { + "line": 22, + "column": 18 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 16 + }, + "end": { + "line": 22, + "column": 18 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 13 + }, + "end": { + "line": 22, + "column": 18 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 13 + }, + "end": { + "line": 22, + "column": 18 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 22, + "column": 20 + }, + "end": { + "line": 22, + "column": 27 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "BinaryExpression", + "operator": "instanceof", + "left": { + "type": "Identifier", + "name": "o", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 12 + }, + "end": { + "line": 23, + "column": 13 + } + } + }, + "right": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "JSValue", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 25 + }, + "end": { + "line": 23, + "column": 32 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 25 + }, + "end": { + "line": 23, + "column": 33 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 25 + }, + "end": { + "line": 23, + "column": 33 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 12 + }, + "end": { + "line": 23, + "column": 33 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 5 + }, + "end": { + "line": 23, + "column": 33 + } + } + } + ], + "loc": { + "start": { + "line": 22, + "column": 28 + }, + "end": { + "line": 24, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 12 + }, + "end": { + "line": 24, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 12 + }, + "end": { + "line": 24, + "column": 2 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 1 + }, + "end": { + "line": 24, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 7 + }, + "end": { + "line": 20, + "column": 8 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "constructor", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 11 + }, + "end": { + "line": 20, + "column": 11 + } + } + } + ], + "loc": { + "start": { + "line": 20, + "column": 9 + }, + "end": { + "line": 20, + "column": 11 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1 + }, + "end": { + "line": 20, + "column": 11 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 25, + "column": 1 + } + } +} diff --git a/ets2panda/test/compiler/ets/instanceof_jsvalue_dynvalue-expected.txt b/ets2panda/test/compiler/ets/instanceof_jsvalue_dynvalue-expected.txt index 1ee94072bca45fb09f8e4c9196199df26b8f3c93..230f4447506b4b1df02ba0c21ce9185e0f021a8c 100644 --- a/ets2panda/test/compiler/ets/instanceof_jsvalue_dynvalue-expected.txt +++ b/ets2panda/test/compiler/ets/instanceof_jsvalue_dynvalue-expected.txt @@ -1 +1,907 @@ TypeError: Right-hand side of instanceof expression must represent a type. [instanceof_jsvalue_dynvalue.sts:23:12] +{ + "type": "Program", + "statements": [ + { + "type": "ImportDeclaration", + "source": { + "type": "StringLiteral", + "value": "dynamic_js_import_tests", + "loc": { + "start": { + "line": 20, + "column": 19 + }, + "end": { + "line": 20, + "column": 44 + } + } + }, + "specifiers": [ + { + "type": "ImportSpecifier", + "local": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 10 + }, + "end": { + "line": 20, + "column": 11 + } + } + }, + "imported": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 10 + }, + "end": { + "line": 20, + "column": 11 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 10 + }, + "end": { + "line": 20, + "column": 11 + } + } + } + ], + "loc": { + "start": { + "line": 20, + "column": 1 + }, + "end": { + "line": 20, + "column": 44 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ETSGLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "fn", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 10 + }, + "end": { + "line": 22, + "column": 12 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "fn", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 10 + }, + "end": { + "line": 22, + "column": 12 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "o", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "JSValue", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 16 + }, + "end": { + "line": 22, + "column": 23 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 16 + }, + "end": { + "line": 22, + "column": 24 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 16 + }, + "end": { + "line": 22, + "column": 24 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 13 + }, + "end": { + "line": 22, + "column": 24 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 13 + }, + "end": { + "line": 22, + "column": 24 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 22, + "column": 26 + }, + "end": { + "line": 22, + "column": 33 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "BinaryExpression", + "operator": "instanceof", + "left": { + "type": "Identifier", + "name": "o", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 12 + }, + "end": { + "line": 23, + "column": 13 + } + } + }, + "right": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 25 + }, + "end": { + "line": 23, + "column": 26 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 25 + }, + "end": { + "line": 23, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 25 + }, + "end": { + "line": 23, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 12 + }, + "end": { + "line": 23, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 5 + }, + "end": { + "line": 23, + "column": 27 + } + } + } + ], + "loc": { + "start": { + "line": 22, + "column": 34 + }, + "end": { + "line": 24, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 12 + }, + "end": { + "line": 24, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 12 + }, + "end": { + "line": 24, + "column": 2 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 1 + }, + "end": { + "line": 24, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "$dynmodule", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "dynamic_js_import_tests0", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "public", + "static": true, + "readonly": true, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "OpaqueType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassStaticBlock", + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": true, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "$dynmodule", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "dynamic_js_import_tests0", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "JSRuntime", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "loadModule", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "StringLiteral", + "value": "dynamic_js_import_tests", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "init", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "OpaqueType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 25, + "column": 1 + } + } +} diff --git a/ets2panda/test/compiler/ets/instanceof_jsvalue_jsvalue-expected.txt b/ets2panda/test/compiler/ets/instanceof_jsvalue_jsvalue-expected.txt index bb8a10306930bb7596764878f8711089729ab74c..ec220f018c1c47b8f32ab6ecf3382222cd46d0a3 100644 --- a/ets2panda/test/compiler/ets/instanceof_jsvalue_jsvalue-expected.txt +++ b/ets2panda/test/compiler/ets/instanceof_jsvalue_jsvalue-expected.txt @@ -1 +1,415 @@ TypeError: Right-hand side of instanceof expression must represent a type. [instanceof_jsvalue_jsvalue.sts:21:12] +{ + "type": "Program", + "statements": [ + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ETSGLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "fn", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 10 + }, + "end": { + "line": 20, + "column": 12 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "fn", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 10 + }, + "end": { + "line": 20, + "column": 12 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "o", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "JSValue", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 16 + }, + "end": { + "line": 20, + "column": 23 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 16 + }, + "end": { + "line": 20, + "column": 24 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 16 + }, + "end": { + "line": 20, + "column": 24 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 13 + }, + "end": { + "line": 20, + "column": 24 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 13 + }, + "end": { + "line": 20, + "column": 24 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 20, + "column": 26 + }, + "end": { + "line": 20, + "column": 33 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "BinaryExpression", + "operator": "instanceof", + "left": { + "type": "Identifier", + "name": "o", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 12 + }, + "end": { + "line": 21, + "column": 13 + } + } + }, + "right": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "JSValue", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 25 + }, + "end": { + "line": 21, + "column": 32 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 25 + }, + "end": { + "line": 21, + "column": 33 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 25 + }, + "end": { + "line": 21, + "column": 33 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 12 + }, + "end": { + "line": 21, + "column": 33 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "column": 33 + } + } + } + ], + "loc": { + "start": { + "line": 20, + "column": 34 + }, + "end": { + "line": 22, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 12 + }, + "end": { + "line": 22, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 12 + }, + "end": { + "line": 22, + "column": 2 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1 + }, + "end": { + "line": 22, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 23, + "column": 1 + } + } +} diff --git a/ets2panda/test/compiler/ets/instanceof_object_dynvalue-expected.txt b/ets2panda/test/compiler/ets/instanceof_object_dynvalue-expected.txt index 5db20a3a7f30bcb1085416ec5a792b8104451c6d..3338a5ec67aff7bee784cd293faa6e4269b5dd84 100644 --- a/ets2panda/test/compiler/ets/instanceof_object_dynvalue-expected.txt +++ b/ets2panda/test/compiler/ets/instanceof_object_dynvalue-expected.txt @@ -1 +1,907 @@ TypeError: Right-hand side of instanceof expression must represent a type. [instanceof_object_dynvalue.sts:23:12] +{ + "type": "Program", + "statements": [ + { + "type": "ImportDeclaration", + "source": { + "type": "StringLiteral", + "value": "dynamic_js_import_tests", + "loc": { + "start": { + "line": 20, + "column": 19 + }, + "end": { + "line": 20, + "column": 44 + } + } + }, + "specifiers": [ + { + "type": "ImportSpecifier", + "local": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 10 + }, + "end": { + "line": 20, + "column": 11 + } + } + }, + "imported": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 10 + }, + "end": { + "line": 20, + "column": 11 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 10 + }, + "end": { + "line": 20, + "column": 11 + } + } + } + ], + "loc": { + "start": { + "line": 20, + "column": 1 + }, + "end": { + "line": 20, + "column": 44 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ETSGLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "fn", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 10 + }, + "end": { + "line": 22, + "column": 12 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "fn", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 10 + }, + "end": { + "line": 22, + "column": 12 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "o", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Object", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 16 + }, + "end": { + "line": 22, + "column": 22 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 16 + }, + "end": { + "line": 22, + "column": 23 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 16 + }, + "end": { + "line": 22, + "column": 23 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 13 + }, + "end": { + "line": 22, + "column": 23 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 13 + }, + "end": { + "line": 22, + "column": 23 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 22, + "column": 25 + }, + "end": { + "line": 22, + "column": 32 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "BinaryExpression", + "operator": "instanceof", + "left": { + "type": "Identifier", + "name": "o", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 12 + }, + "end": { + "line": 23, + "column": 13 + } + } + }, + "right": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 25 + }, + "end": { + "line": 23, + "column": 26 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 25 + }, + "end": { + "line": 23, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 25 + }, + "end": { + "line": 23, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 12 + }, + "end": { + "line": 23, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 5 + }, + "end": { + "line": 23, + "column": 27 + } + } + } + ], + "loc": { + "start": { + "line": 22, + "column": 33 + }, + "end": { + "line": 24, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 12 + }, + "end": { + "line": 24, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 12 + }, + "end": { + "line": 24, + "column": 2 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 1 + }, + "end": { + "line": 24, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "$dynmodule", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "dynamic_js_import_tests0", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "public", + "static": true, + "readonly": true, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "OpaqueType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassStaticBlock", + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": true, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "$dynmodule", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "dynamic_js_import_tests0", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "JSRuntime", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "loadModule", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "StringLiteral", + "value": "dynamic_js_import_tests", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "init", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "OpaqueType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 25, + "column": 1 + } + } +} diff --git a/ets2panda/test/compiler/ets/instanceof_object_jsvalue-expected.txt b/ets2panda/test/compiler/ets/instanceof_object_jsvalue-expected.txt index 49523fae910e529cf7000511dbb44c6a38bbf5ae..27e0b351390c8caa21000fc69482b0f34deff1eb 100644 --- a/ets2panda/test/compiler/ets/instanceof_object_jsvalue-expected.txt +++ b/ets2panda/test/compiler/ets/instanceof_object_jsvalue-expected.txt @@ -1 +1,415 @@ TypeError: Right-hand side of instanceof expression must represent a type. [instanceof_object_jsvalue.sts:21:12] +{ + "type": "Program", + "statements": [ + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ETSGLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "fn", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 10 + }, + "end": { + "line": 20, + "column": 12 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "fn", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 10 + }, + "end": { + "line": 20, + "column": 12 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "o", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Object", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 16 + }, + "end": { + "line": 20, + "column": 22 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 16 + }, + "end": { + "line": 20, + "column": 23 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 16 + }, + "end": { + "line": 20, + "column": 23 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 13 + }, + "end": { + "line": 20, + "column": 23 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 13 + }, + "end": { + "line": 20, + "column": 23 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 20, + "column": 25 + }, + "end": { + "line": 20, + "column": 32 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "BinaryExpression", + "operator": "instanceof", + "left": { + "type": "Identifier", + "name": "o", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 12 + }, + "end": { + "line": 21, + "column": 13 + } + } + }, + "right": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "JSValue", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 25 + }, + "end": { + "line": 21, + "column": 32 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 25 + }, + "end": { + "line": 21, + "column": 33 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 25 + }, + "end": { + "line": 21, + "column": 33 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 12 + }, + "end": { + "line": 21, + "column": 33 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "column": 33 + } + } + } + ], + "loc": { + "start": { + "line": 20, + "column": 33 + }, + "end": { + "line": 22, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 12 + }, + "end": { + "line": 22, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 12 + }, + "end": { + "line": 22, + "column": 2 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1 + }, + "end": { + "line": 22, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 23, + "column": 1 + } + } +} diff --git a/ets2panda/test/compiler/ets/instanceof_object_long-expected.txt b/ets2panda/test/compiler/ets/instanceof_object_long-expected.txt index 78700a0fe1b0f35e98035f512a5673dbc8a7930c..6ff7d27ad6ce05e870b51d128674b066b434bdef 100644 --- a/ets2panda/test/compiler/ets/instanceof_object_long-expected.txt +++ b/ets2panda/test/compiler/ets/instanceof_object_long-expected.txt @@ -1 +1,387 @@ TypeError: Bad operand type, the types of the operands must be same type. [instanceof_object_long.sts:21:12] +{ + "type": "Program", + "statements": [ + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ETSGLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "fn", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 10 + }, + "end": { + "line": 20, + "column": 12 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "fn", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 10 + }, + "end": { + "line": 20, + "column": 12 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "o", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Object", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 16 + }, + "end": { + "line": 20, + "column": 22 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 16 + }, + "end": { + "line": 20, + "column": 23 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 16 + }, + "end": { + "line": 20, + "column": 23 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 13 + }, + "end": { + "line": 20, + "column": 23 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 13 + }, + "end": { + "line": 20, + "column": 23 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 20, + "column": 25 + }, + "end": { + "line": 20, + "column": 32 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "BinaryExpression", + "operator": "instanceof", + "left": { + "type": "Identifier", + "name": "o", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 12 + }, + "end": { + "line": 21, + "column": 13 + } + } + }, + "right": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 21, + "column": 25 + }, + "end": { + "line": 21, + "column": 29 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 12 + }, + "end": { + "line": 21, + "column": 29 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "column": 30 + } + } + } + ], + "loc": { + "start": { + "line": 20, + "column": 33 + }, + "end": { + "line": 22, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 12 + }, + "end": { + "line": 22, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 12 + }, + "end": { + "line": 22, + "column": 2 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1 + }, + "end": { + "line": 22, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 23, + "column": 1 + } + } +} diff --git a/ets2panda/test/compiler/ets/instanceof_x_dyndecl-expected.txt b/ets2panda/test/compiler/ets/instanceof_x_dyndecl-expected.txt index 8e2be440f7e0634339dc17bf042d2561a1ec2da0..ed001e339cd7baa7f2cda7a93602a4f54053f5b6 100644 --- a/ets2panda/test/compiler/ets/instanceof_x_dyndecl-expected.txt +++ b/ets2panda/test/compiler/ets/instanceof_x_dyndecl-expected.txt @@ -2103,6 +2103,19 @@ "async": false, "expression": false, "params": [], + "returnType": { + "type": "OpaqueType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "body": { "type": "BlockStatement", "statements": [], diff --git a/ets2panda/test/compiler/ets/instanceof_x_etstype-expected.txt b/ets2panda/test/compiler/ets/instanceof_x_etstype-expected.txt index ddff810f78444d4dc8238e8a5817ac86e09ececa..baa635269e75e4259f8852db3c28e91f92e818ae 100644 --- a/ets2panda/test/compiler/ets/instanceof_x_etstype-expected.txt +++ b/ets2panda/test/compiler/ets/instanceof_x_etstype-expected.txt @@ -2197,6 +2197,19 @@ "async": false, "expression": false, "params": [], + "returnType": { + "type": "OpaqueType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "body": { "type": "BlockStatement", "statements": [], diff --git a/ets2panda/test/compiler/ets/instanceof_x_object-expected.txt b/ets2panda/test/compiler/ets/instanceof_x_object-expected.txt index 2b42c302e50fb567cfac8abb39ca8fb7ddcf5ae6..fbaa260a6ff9e5e6314d1708f9c59f1e68d6b41f 100644 --- a/ets2panda/test/compiler/ets/instanceof_x_object-expected.txt +++ b/ets2panda/test/compiler/ets/instanceof_x_object-expected.txt @@ -2060,6 +2060,19 @@ "async": false, "expression": false, "params": [], + "returnType": { + "type": "OpaqueType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "body": { "type": "BlockStatement", "statements": [], diff --git a/ets2panda/test/compiler/ets/lambda_infer_type/lambda_cast_infer_type_void-expected.txt b/ets2panda/test/compiler/ets/lambda_infer_type/lambda_cast_infer_type_void-expected.txt index 0c0b9647866639f77fec8e981ece37580c4a5bfd..6dd986eaa17d50ce9402603ed4bd8b2353985d5b 100644 --- a/ets2panda/test/compiler/ets/lambda_infer_type/lambda_cast_infer_type_void-expected.txt +++ b/ets2panda/test/compiler/ets/lambda_infer_type/lambda_cast_infer_type_void-expected.txt @@ -235,43 +235,15 @@ "type": "ETSFunctionType", "params": [], "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "void", - "decorators": [], - "loc": { - "start": { - "line": 17, - "column": 30 - }, - "end": { - "line": 17, - "column": 34 - } - } - }, - "loc": { - "start": { - "line": 17, - "column": 30 - }, - "end": { - "line": 18, - "column": 8 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 17, "column": 30 }, "end": { - "line": 18, - "column": 8 + "line": 17, + "column": 34 } } }, @@ -281,8 +253,8 @@ "column": 25 }, "end": { - "line": 18, - "column": 8 + "line": 17, + "column": 34 } } }, @@ -333,35 +305,7 @@ "type": "ETSFunctionType", "params": [], "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "void", - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 26 - }, - "end": { - "line": 18, - "column": 30 - } - } - }, - "loc": { - "start": { - "line": 18, - "column": 26 - }, - "end": { - "line": 18, - "column": 32 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 18, @@ -369,7 +313,7 @@ }, "end": { "line": 18, - "column": 32 + "column": 30 } } }, @@ -380,7 +324,7 @@ }, "end": { "line": 18, - "column": 32 + "column": 30 } } }, diff --git a/ets2panda/test/compiler/ets/lambda_infer_type/lambda_param_type_cannot_be_determined-expected.txt b/ets2panda/test/compiler/ets/lambda_infer_type/lambda_param_type_cannot_be_determined-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..098abf77f0d1dd5d4a41bfb3dbe844c0dbca1162 --- /dev/null +++ b/ets2panda/test/compiler/ets/lambda_infer_type/lambda_param_type_cannot_be_determined-expected.txt @@ -0,0 +1,630 @@ +{ + "type": "Program", + "statements": [ + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ETSGLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "foo", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 10 + }, + "end": { + "line": 16, + "column": 13 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "foo", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 10 + }, + "end": { + "line": 16, + "column": 13 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "f", + "typeAnnotation": { + "type": "ETSFunctionType", + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "i", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "T", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 24 + }, + "end": { + "line": 16, + "column": 25 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 24 + }, + "end": { + "line": 16, + "column": 26 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 24 + }, + "end": { + "line": 16, + "column": 26 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 21 + }, + "end": { + "line": 16, + "column": 26 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 21 + }, + "end": { + "line": 16, + "column": 26 + } + } + } + ], + "returnType": { + "type": "ETSUndefinedType", + "loc": { + "start": { + "line": 16, + "column": 30 + }, + "end": { + "line": 16, + "column": 39 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 20 + }, + "end": { + "line": 16, + "column": 39 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 17 + }, + "end": { + "line": 16, + "column": 39 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 17 + }, + "end": { + "line": 16, + "column": 39 + } + } + } + ], + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "params": [ + { + "type": "TSTypeParameter", + "name": { + "type": "Identifier", + "name": "T", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 14 + }, + "end": { + "line": 16, + "column": 15 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 14 + }, + "end": { + "line": 16, + "column": 16 + } + } + } + ], + "loc": { + "start": { + "line": 16, + "column": 13 + }, + "end": { + "line": 16, + "column": 16 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 16, + "column": 41 + }, + "end": { + "line": 16, + "column": 43 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 13 + }, + "end": { + "line": 16, + "column": 43 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 13 + }, + "end": { + "line": 16, + "column": 43 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 1 + }, + "end": { + "line": 16, + "column": 43 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "main", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 10 + }, + "end": { + "line": 18, + "column": 14 + } + } + }, + "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": 18, + "column": 10 + }, + "end": { + "line": 18, + "column": 14 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "foo", + "decorators": [], + "loc": { + "start": { + "line": 19, + "column": 5 + }, + "end": { + "line": 19, + "column": 8 + } + } + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "function": { + "type": "ScriptFunction", + "id": null, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "value", + "decorators": [], + "loc": { + "start": { + "line": 19, + "column": 10 + }, + "end": { + "line": 19, + "column": 15 + } + } + }, + "loc": { + "start": { + "line": 19, + "column": 10 + }, + "end": { + "line": 19, + "column": 15 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 19, + "column": 20 + }, + "end": { + "line": 19, + "column": 22 + } + } + }, + "loc": { + "start": { + "line": 19, + "column": 9 + }, + "end": { + "line": 19, + "column": 22 + } + } + }, + "loc": { + "start": { + "line": 19, + "column": 9 + }, + "end": { + "line": 19, + "column": 22 + } + } + } + ], + "optional": false, + "loc": { + "start": { + "line": 19, + "column": 5 + }, + "end": { + "line": 19, + "column": 23 + } + } + }, + "loc": { + "start": { + "line": 19, + "column": 5 + }, + "end": { + "line": 19, + "column": 23 + } + } + } + ], + "loc": { + "start": { + "line": 18, + "column": 17 + }, + "end": { + "line": 20, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 14 + }, + "end": { + "line": 20, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 14 + }, + "end": { + "line": 20, + "column": 2 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 1 + }, + "end": { + "line": 20, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 21, + "column": 1 + } + } +} +TypeError: The type of parameter 'value' cannot be determined [lambda_param_type_cannot_be_determined.sts:19:10] diff --git a/ets2panda/test/compiler/ets/lambda_infer_type/lambda_param_type_cannot_be_determined.sts b/ets2panda/test/compiler/ets/lambda_infer_type/lambda_param_type_cannot_be_determined.sts new file mode 100644 index 0000000000000000000000000000000000000000..cde0c73e14e7dfa50d18b1d51424fb167f234fc7 --- /dev/null +++ b/ets2panda/test/compiler/ets/lambda_infer_type/lambda_param_type_cannot_be_determined.sts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function foo(f: (i: T) => undefined) {} + +function main() { + foo((value) => {}) +} diff --git a/ets2panda/test/compiler/ets/nullable_type_in_stringconcat_func-expected.txt b/ets2panda/test/compiler/ets/nullable_type_in_stringconcat_func-expected.txt index bba047a07204b9ccf23d32951d7668dcb56fae80..4e95db51d818f7d8da37246128910d2f9b8782b0 100644 --- a/ets2panda/test/compiler/ets/nullable_type_in_stringconcat_func-expected.txt +++ b/ets2panda/test/compiler/ets/nullable_type_in_stringconcat_func-expected.txt @@ -1229,3 +1229,4 @@ } } TypeError: Bad operand type: multiple types left in the normalized union type (String|null). Unions are not allowed in binary expressions except equality. [nullable_type_in_stringconcat_func.sts:17:12] +TypeError: Bad operand type: multiple types left in the normalized union type (String|null). Unions are not allowed in binary expressions except equality. [nullable_type_in_stringconcat_func.sts:21:12] diff --git a/ets2panda/test/compiler/ets/objectLiteralInterface-expected.txt b/ets2panda/test/compiler/ets/objectLiteralInterface-expected.txt index fdcf31062c8f8d6bbef6b3f31e403044f496605a..435c8034dc07952d7f0d675c5b1def74ca2e696d 100644 --- a/ets2panda/test/compiler/ets/objectLiteralInterface-expected.txt +++ b/ets2panda/test/compiler/ets/objectLiteralInterface-expected.txt @@ -422,4 +422,3 @@ } } } -TypeError: target type for class composite C is not instantiable [objectLiteralInterface.sts:18:12] diff --git a/ets2panda/test/compiler/ets/objectLiteralInterface2-expected.txt b/ets2panda/test/compiler/ets/objectLiteralInterface2-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..18399f5d1d86f3c24f5c938af740f37c4a4eef27 --- /dev/null +++ b/ets2panda/test/compiler/ets/objectLiteralInterface2-expected.txt @@ -0,0 +1,1537 @@ +{ + "type": "Program", + "statements": [ + { + "type": "TSInterfaceDeclaration", + "body": { + "type": "TSInterfaceBody", + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "s", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "s", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "T1", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 8 + }, + "end": { + "line": 17, + "column": 10 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 8 + }, + "end": { + "line": 17, + "column": 11 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 8 + }, + "end": { + "line": 17, + "column": 11 + } + } + }, + "declare": true, + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 17, + "column": 11 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 17, + "column": 11 + } + } + }, + "overloads": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "s", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "s", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "s", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "T1", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 8 + }, + "end": { + "line": 17, + "column": 10 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 8 + }, + "end": { + "line": 17, + "column": 11 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 8 + }, + "end": { + "line": 17, + "column": 11 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 17, + "column": 6 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 17, + "column": 6 + } + } + } + ], + "declare": true, + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 17, + "column": 11 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 17, + "column": 11 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 17, + "column": 11 + } + } + } + ], + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 17, + "column": 11 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "s", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "s", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "s", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "T1", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 8 + }, + "end": { + "line": 17, + "column": 10 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 8 + }, + "end": { + "line": 17, + "column": 11 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 8 + }, + "end": { + "line": 17, + "column": 11 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 17, + "column": 6 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 17, + "column": 6 + } + } + } + ], + "declare": true, + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 17, + "column": 11 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 17, + "column": 11 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 17, + "column": 11 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "n", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "n", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "T2", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 8 + }, + "end": { + "line": 18, + "column": 10 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 8 + }, + "end": { + "line": 19, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 8 + }, + "end": { + "line": 19, + "column": 2 + } + } + }, + "declare": true, + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 19, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 19, + "column": 2 + } + } + }, + "overloads": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "n", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "n", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "n", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "T2", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 8 + }, + "end": { + "line": 18, + "column": 10 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 8 + }, + "end": { + "line": 19, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 8 + }, + "end": { + "line": 19, + "column": 2 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 18, + "column": 6 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 18, + "column": 6 + } + } + } + ], + "declare": true, + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 19, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 19, + "column": 2 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 19, + "column": 2 + } + } + } + ], + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 19, + "column": 2 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "n", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "n", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "n", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "T2", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 8 + }, + "end": { + "line": 18, + "column": 10 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 8 + }, + "end": { + "line": 19, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 8 + }, + "end": { + "line": 19, + "column": 2 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 18, + "column": 6 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 18, + "column": 6 + } + } + } + ], + "declare": true, + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 19, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 19, + "column": 2 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 19, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 16, + "column": 22 + }, + "end": { + "line": 19, + "column": 2 + } + } + }, + "id": { + "type": "Identifier", + "name": "I", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 11 + }, + "end": { + "line": 16, + "column": 12 + } + } + }, + "extends": [], + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "params": [ + { + "type": "TSTypeParameter", + "name": { + "type": "Identifier", + "name": "T1", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 14 + }, + "end": { + "line": 16, + "column": 16 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 14 + }, + "end": { + "line": 16, + "column": 17 + } + } + }, + { + "type": "TSTypeParameter", + "name": { + "type": "Identifier", + "name": "T2", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 18 + }, + "end": { + "line": 16, + "column": 20 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 18 + }, + "end": { + "line": 16, + "column": 21 + } + } + } + ], + "loc": { + "start": { + "line": 16, + "column": 13 + }, + "end": { + "line": 16, + "column": 21 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 1 + }, + "end": { + "line": 21, + "column": 4 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ETSGLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "main", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "c", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "column": 6 + } + } + }, + "right": { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "method": false, + "shorthand": false, + "computed": false, + "key": { + "type": "Identifier", + "name": "s", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 30 + }, + "end": { + "line": 21, + "column": 31 + } + } + }, + "value": { + "type": "StringLiteral", + "value": "default", + "loc": { + "start": { + "line": 21, + "column": 33 + }, + "end": { + "line": 21, + "column": 42 + } + } + }, + "kind": "init", + "loc": { + "start": { + "line": 21, + "column": 30 + }, + "end": { + "line": 21, + "column": 42 + } + } + }, + { + "type": "Property", + "method": false, + "shorthand": false, + "computed": false, + "key": { + "type": "Identifier", + "name": "n", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 44 + }, + "end": { + "line": 21, + "column": 45 + } + } + }, + "value": { + "type": "NumberLiteral", + "value": 10, + "loc": { + "start": { + "line": 21, + "column": 47 + }, + "end": { + "line": 21, + "column": 49 + } + } + }, + "kind": "init", + "loc": { + "start": { + "line": 21, + "column": 44 + }, + "end": { + "line": 21, + "column": 49 + } + } + } + ], + "loc": { + "start": { + "line": 21, + "column": 28 + }, + "end": { + "line": 21, + "column": 50 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "column": 50 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "column": 50 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "c", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "column": 6 + } + } + }, + "accessibility": "public", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "I", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 8 + }, + "end": { + "line": 21, + "column": 9 + } + } + }, + "typeParams": { + "type": "TSTypeParameterInstantiation", + "params": [ + { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "string", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 10 + }, + "end": { + "line": 21, + "column": 16 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 10 + }, + "end": { + "line": 21, + "column": 17 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 10 + }, + "end": { + "line": 21, + "column": 17 + } + } + }, + { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "number", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 18 + }, + "end": { + "line": 21, + "column": 24 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 18 + }, + "end": { + "line": 21, + "column": 25 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 18 + }, + "end": { + "line": 21, + "column": 25 + } + } + } + ], + "loc": { + "start": { + "line": 21, + "column": 9 + }, + "end": { + "line": 21, + "column": 25 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 8 + }, + "end": { + "line": 21, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 8 + }, + "end": { + "line": 21, + "column": 27 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "column": 50 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 22, + "column": 1 + } + } +} +TypeError: Object literal cannot be of typed interface type [objectLiteralInterface2.sts:21:28] diff --git a/ets2panda/test/compiler/ets/objectLiteralInterface2.sts b/ets2panda/test/compiler/ets/objectLiteralInterface2.sts new file mode 100644 index 0000000000000000000000000000000000000000..bdc768bd43287e78f9c3ab2f6d6cffe5fd6d678f --- /dev/null +++ b/ets2panda/test/compiler/ets/objectLiteralInterface2.sts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +interface I { + s: T1, + n: T2 +} + +let c: I = { s: "default", n: 10}; diff --git a/ets2panda/test/compiler/ets/objectLiteralInterface3-expected.txt b/ets2panda/test/compiler/ets/objectLiteralInterface3-expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..94fbaea4ce2dbe96369cac4d83c28e828b73a149 --- /dev/null +++ b/ets2panda/test/compiler/ets/objectLiteralInterface3-expected.txt @@ -0,0 +1,979 @@ +{ + "type": "Program", + "statements": [ + { + "type": "TSInterfaceDeclaration", + "body": { + "type": "TSInterfaceBody", + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "name", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "name", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "string", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 11 + }, + "end": { + "line": 17, + "column": 17 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 11 + }, + "end": { + "line": 18, + "column": 8 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 11 + }, + "end": { + "line": 18, + "column": 8 + } + } + }, + "declare": true, + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 18, + "column": 8 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 18, + "column": 8 + } + } + }, + "overloads": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "name", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "name", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 17, + "column": 11 + }, + "end": { + "line": 17, + "column": 17 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 11 + }, + "end": { + "line": 18, + "column": 8 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 11 + }, + "end": { + "line": 18, + "column": 8 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 17, + "column": 9 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 17, + "column": 9 + } + } + } + ], + "declare": true, + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 18, + "column": 8 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 18, + "column": 8 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 18, + "column": 8 + } + } + } + ], + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 18, + "column": 8 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "name", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "name", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 17, + "column": 11 + }, + "end": { + "line": 17, + "column": 17 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 11 + }, + "end": { + "line": 18, + "column": 8 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 11 + }, + "end": { + "line": 18, + "column": 8 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 17, + "column": 9 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 17, + "column": 9 + } + } + } + ], + "declare": true, + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 18, + "column": 8 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 18, + "column": 8 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 18, + "column": 8 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "foo", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 18, + "column": 8 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "foo", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 18, + "column": 8 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "declare": true, + "loc": { + "start": { + "line": 18, + "column": 8 + }, + "end": { + "line": 19, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 8 + }, + "end": { + "line": 19, + "column": 2 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 19, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 16, + "column": 13 + }, + "end": { + "line": 19, + "column": 2 + } + } + }, + "id": { + "type": "Identifier", + "name": "I", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 11 + }, + "end": { + "line": 16, + "column": 12 + } + } + }, + "extends": [], + "loc": { + "start": { + "line": 16, + "column": 1 + }, + "end": { + "line": 21, + "column": 4 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ETSGLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "main", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "c", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "column": 6 + } + } + }, + "right": { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "method": false, + "shorthand": false, + "computed": false, + "key": { + "type": "Identifier", + "name": "name", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 14 + }, + "end": { + "line": 21, + "column": 18 + } + } + }, + "value": { + "type": "StringLiteral", + "value": "Alice", + "loc": { + "start": { + "line": 21, + "column": 20 + }, + "end": { + "line": 21, + "column": 27 + } + } + }, + "kind": "init", + "loc": { + "start": { + "line": 21, + "column": 14 + }, + "end": { + "line": 21, + "column": 27 + } + } + } + ], + "loc": { + "start": { + "line": 21, + "column": 12 + }, + "end": { + "line": 21, + "column": 29 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "column": 29 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "column": 29 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "c", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "column": 6 + } + } + }, + "accessibility": "public", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "I", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 8 + }, + "end": { + "line": 21, + "column": 9 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 8 + }, + "end": { + "line": 21, + "column": 11 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 8 + }, + "end": { + "line": 21, + "column": 11 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "column": 29 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 22, + "column": 1 + } + } +} +TypeError: Interface has methods [objectLiteralInterface3.sts:21:12] diff --git a/ets2panda/test/compiler/ets/objectLiteralInterface3.sts b/ets2panda/test/compiler/ets/objectLiteralInterface3.sts new file mode 100644 index 0000000000000000000000000000000000000000..4b997efec8d4a6a76f8a439a6ee7ece3ad7b192a --- /dev/null +++ b/ets2panda/test/compiler/ets/objectLiteralInterface3.sts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +interface I { + name: string + foo() +} + +let c: I = { name: "Alice" }; diff --git a/ets2panda/test/compiler/ets/optionalLambdaParameter-expected.txt b/ets2panda/test/compiler/ets/optionalLambdaParameter-expected.txt index 24be78cae4b038b2e51b904cd49746f9301bb966..ac2baf4b89df986a9b5ef48c5e2f38bb687d6886 100644 --- a/ets2panda/test/compiler/ets/optionalLambdaParameter-expected.txt +++ b/ets2panda/test/compiler/ets/optionalLambdaParameter-expected.txt @@ -167,16 +167,13 @@ "type": "Identifier", "name": "exec", "typeAnnotation": { - "type": "ETSFunctionType", - "params": [], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "void", - "decorators": [], + "type": "ETSUnionType", + "types": [ + { + "type": "ETSFunctionType", + "params": [], + "returnType": { + "type": "ETSPrimitiveType", "loc": { "start": { "line": 16, @@ -191,25 +188,28 @@ "loc": { "start": { "line": 16, - "column": 27 + "column": 21 }, "end": { "line": 16, - "column": 32 + "column": 31 } } }, - "loc": { - "start": { - "line": 16, - "column": 27 - }, - "end": { - "line": 16, - "column": 32 + { + "type": "ETSUndefinedType", + "loc": { + "start": { + "line": 16, + "column": 18 + }, + "end": { + "line": 16, + "column": 19 + } } } - }, + ], "loc": { "start": { "line": 16, @@ -217,7 +217,7 @@ }, "end": { "line": 16, - "column": 32 + "column": 31 } } }, @@ -229,7 +229,7 @@ }, "end": { "line": 16, - "column": 32 + "column": 31 } } }, @@ -240,41 +240,13 @@ }, "end": { "line": 16, - "column": 32 + "column": 31 } } } ], "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "void", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 34 - }, - "end": { - "line": 16, - "column": 38 - } - } - }, - "loc": { - "start": { - "line": 16, - "column": 34 - }, - "end": { - "line": 16, - "column": 40 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 16, @@ -282,7 +254,7 @@ }, "end": { "line": 16, - "column": 40 + "column": 38 } } }, @@ -292,24 +264,181 @@ { "type": "ExpressionStatement", "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "exec", - "decorators": [], - "loc": { - "start": { - "line": 17, - "column": 5 + "type": "BlockExpression", + "statements": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "gensym$_1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "init": { + "type": "Identifier", + "name": "exec", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 17, + "column": 9 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 17, + "column": 13 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "ConditionalExpression", + "test": { + "type": "BinaryExpression", + "operator": "==", + "left": { + "type": "Identifier", + "name": "gensym$_1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "right": { + "type": "NullLiteral", + "value": null, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "consequent": { + "type": "UndefinedLiteral", + "value": undefined, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "alternate": { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "gensym$_1", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 17, + "column": 13 + } + } + }, + "arguments": [], + "optional": false, + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 17, + "column": 13 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } }, - "end": { - "line": 17, - "column": 9 + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } } } - }, - "arguments": [], - "optional": true, + ], "loc": { "start": { "line": 17, @@ -413,43 +542,15 @@ "expression": false, "params": [], "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "void", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 34 - }, - "end": { - "line": 16, - "column": 38 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { - "line": 1, - "column": 1 + "line": 16, + "column": 34 }, "end": { - "line": 1, - "column": 1 + "line": 16, + "column": 38 } } }, @@ -528,11 +629,11 @@ }, "loc": { "start": { - "line": 606, + "line": 611, "column": 1 }, "end": { - "line": 606, + "line": 611, "column": 1 } } diff --git a/ets2panda/test/compiler/ets/override17-expected.txt b/ets2panda/test/compiler/ets/override17-expected.txt index 45a68f597a114620990b525d51b22f9a8fdd13ee..6c3d820bde16ccef1b5d6d755a5158e96f481196 100644 --- a/ets2panda/test/compiler/ets/override17-expected.txt +++ b/ets2panda/test/compiler/ets/override17-expected.txt @@ -735,4 +735,3 @@ } } } -TypeError: Hiding method is not return-type-substitutable for other method. [override17.sts:23:12] diff --git a/ets2panda/test/compiler/ets/override3-expected.txt b/ets2panda/test/compiler/ets/override3-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..4d6e52f50a6494fb5ef793c561cdc6ead0572290 --- /dev/null +++ b/ets2panda/test/compiler/ets/override3-expected.txt @@ -0,0 +1,292 @@ +{ + "type": "Program", + "statements": [ + { + "type": "TSInterfaceDeclaration", + "body": { + "type": "TSInterfaceBody", + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "toString", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 3 + }, + "end": { + "line": 17, + "column": 11 + } + } + }, + "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": 17, + "column": 3 + }, + "end": { + "line": 17, + "column": 11 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 17, + "column": 15 + }, + "end": { + "line": 17, + "column": 18 + } + } + }, + "declare": true, + "loc": { + "start": { + "line": 17, + "column": 11 + }, + "end": { + "line": 17, + "column": 18 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 11 + }, + "end": { + "line": 17, + "column": 18 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 3 + }, + "end": { + "line": 17, + "column": 19 + } + } + } + ], + "loc": { + "start": { + "line": 16, + "column": 13 + }, + "end": { + "line": 18, + "column": 2 + } + } + }, + "id": { + "type": "Identifier", + "name": "I", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 11 + }, + "end": { + "line": 16, + "column": 12 + } + } + }, + "extends": [], + "loc": { + "start": { + "line": 16, + "column": 1 + }, + "end": { + "line": 19, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ETSGLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 19, + "column": 1 + } + } +} +TypeError: toString(): int in I cannot override toString(): String in Object because overriding return type is not compatible with the other return type. [override3.sts:17:11] diff --git a/ets2panda/test/compiler/ets/override4-expected.txt b/ets2panda/test/compiler/ets/override4-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..cc4592d96b2b28553eec7d1ad2025ccc4bb31c55 --- /dev/null +++ b/ets2panda/test/compiler/ets/override4-expected.txt @@ -0,0 +1,837 @@ +{ + "type": "Program", + "statements": [ + { + "type": "TSInterfaceDeclaration", + "body": { + "type": "TSInterfaceBody", + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "fn", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 3 + }, + "end": { + "line": 17, + "column": 5 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "fn", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 3 + }, + "end": { + "line": 17, + "column": 5 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 17, + "column": 9 + }, + "end": { + "line": 17, + "column": 12 + } + } + }, + "declare": true, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 17, + "column": 22 + }, + "end": { + "line": 17, + "column": 23 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 15 + }, + "end": { + "line": 17, + "column": 24 + } + } + } + ], + "loc": { + "start": { + "line": 17, + "column": 13 + }, + "end": { + "line": 17, + "column": 26 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 17, + "column": 26 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 17, + "column": 26 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 3 + }, + "end": { + "line": 17, + "column": 26 + } + } + } + ], + "loc": { + "start": { + "line": 16, + "column": 13 + }, + "end": { + "line": 18, + "column": 2 + } + } + }, + "id": { + "type": "Identifier", + "name": "I", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 11 + }, + "end": { + "line": 16, + "column": 12 + } + } + }, + "extends": [], + "loc": { + "start": { + "line": 16, + "column": 1 + }, + "end": { + "line": 20, + "column": 6 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 7 + }, + "end": { + "line": 20, + "column": 8 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "fn", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 3 + }, + "end": { + "line": 21, + "column": 5 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "fn", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 3 + }, + "end": { + "line": 21, + "column": 5 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 21, + "column": 9 + }, + "end": { + "line": 21, + "column": 12 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "NumberLiteral", + "value": 42, + "loc": { + "start": { + "line": 21, + "column": 22 + }, + "end": { + "line": 21, + "column": 24 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 15 + }, + "end": { + "line": 21, + "column": 25 + } + } + } + ], + "loc": { + "start": { + "line": 21, + "column": 13 + }, + "end": { + "line": 21, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "column": 27 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 3 + }, + "end": { + "line": 21, + "column": 27 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "constructor", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 2 + }, + "end": { + "line": 22, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 20, + "column": 9 + }, + "end": { + "line": 22, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1 + }, + "end": { + "line": 22, + "column": 2 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "B", + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 7 + }, + "end": { + "line": 24, + "column": 8 + } + } + }, + "superClass": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 17 + }, + "end": { + "line": 24, + "column": 18 + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 17 + }, + "end": { + "line": 24, + "column": 29 + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 17 + }, + "end": { + "line": 24, + "column": 29 + } + } + }, + "implements": [ + { + "type": "TSClassImplements", + "expression": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "I", + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 30 + }, + "end": { + "line": 24, + "column": 31 + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 30 + }, + "end": { + "line": 24, + "column": 33 + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 30 + }, + "end": { + "line": 24, + "column": 33 + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 30 + }, + "end": { + "line": 24, + "column": 33 + } + } + } + ], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "constructor", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 35 + }, + "end": { + "line": 24, + "column": 35 + } + } + } + ], + "loc": { + "start": { + "line": 24, + "column": 32 + }, + "end": { + "line": 24, + "column": 35 + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 1 + }, + "end": { + "line": 24, + "column": 35 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ETSGLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 25, + "column": 1 + } + } +} diff --git a/ets2panda/test/compiler/ets/override5-expected.txt b/ets2panda/test/compiler/ets/override5-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..510f8e145e0bb53715b9ecef1a3e7039696a0367 --- /dev/null +++ b/ets2panda/test/compiler/ets/override5-expected.txt @@ -0,0 +1,737 @@ +{ + "type": "Program", + "statements": [ + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 7 + }, + "end": { + "line": 16, + "column": 8 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "fn", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 11 + }, + "end": { + "line": 17, + "column": 13 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "fn", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 11 + }, + "end": { + "line": 17, + "column": 13 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 17, + "column": 17 + }, + "end": { + "line": 17, + "column": 20 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 17, + "column": 30 + }, + "end": { + "line": 17, + "column": 31 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 23 + }, + "end": { + "line": 17, + "column": 32 + } + } + } + ], + "loc": { + "start": { + "line": 17, + "column": 21 + }, + "end": { + "line": 17, + "column": 34 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 13 + }, + "end": { + "line": 17, + "column": 34 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 13 + }, + "end": { + "line": 17, + "column": 34 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 3 + }, + "end": { + "line": 17, + "column": 34 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "constructor", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 2 + }, + "end": { + "line": 18, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 16, + "column": 9 + }, + "end": { + "line": 18, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 1 + }, + "end": { + "line": 18, + "column": 2 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "B", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 7 + }, + "end": { + "line": 20, + "column": 8 + } + } + }, + "superClass": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 17 + }, + "end": { + "line": 20, + "column": 18 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 17 + }, + "end": { + "line": 20, + "column": 20 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 17 + }, + "end": { + "line": 20, + "column": 20 + } + } + }, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "fn", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 21 + }, + "end": { + "line": 21, + "column": 23 + } + } + }, + "kind": "method", + "accessibility": "internal", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "fn", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 21 + }, + "end": { + "line": 21, + "column": 23 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 21, + "column": 27 + }, + "end": { + "line": 21, + "column": 30 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "NumberLiteral", + "value": 2, + "loc": { + "start": { + "line": 21, + "column": 40 + }, + "end": { + "line": 21, + "column": 41 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 33 + }, + "end": { + "line": 21, + "column": 42 + } + } + } + ], + "loc": { + "start": { + "line": 21, + "column": 31 + }, + "end": { + "line": 21, + "column": 44 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 23 + }, + "end": { + "line": 21, + "column": 44 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 23 + }, + "end": { + "line": 21, + "column": 44 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 3 + }, + "end": { + "line": 21, + "column": 44 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "constructor", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 2 + }, + "end": { + "line": 22, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 20, + "column": 19 + }, + "end": { + "line": 22, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1 + }, + "end": { + "line": 22, + "column": 2 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ETSGLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 23, + "column": 1 + } + } +} diff --git a/ets2panda/test/compiler/ets/promiseVoid.sts b/ets2panda/test/compiler/ets/promiseVoid.sts deleted file mode 100644 index d9e7b6812cb7c20ced680d91a3b25af1cc06af09..0000000000000000000000000000000000000000 --- a/ets2panda/test/compiler/ets/promiseVoid.sts +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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. - */ - -class A { - async testAsyncVoidMethodImplicit() {} - async testAsyncVoidMethodExplicit(): Promise { return } - async testAsyncVoidMethodExplicitObject(): Promise { return Void } - async testAsyncVoidMethodReturns() { - let flag = false - if (flag) { - return - } else { - if (flag) { return } - } - } -} - -async function testAsyncVoidImplicit() {} -async function testAsyncVoidExplicit(): Promise { return } -async function testAsyncVoidExplicitObject(): Promise { return Void } -async function testAsyncVoidEarlyReturn(): Promise { - let flag: boolean = true - if (flag) { - return - } - console.println("something") -} -async function testAsyncVoidMultipleReturns() { - let flag: boolean = true - if (flag) { - return - } - console.println("something x1") - if (!flag) { - return // we return here - } - console.println("something x2") - return console.println("something x3") -} - -// NOTE(orlovskiymaxim): add support for lambdas -// let testAsyncVoidLambdaImplicit = async () => {} -// let testAsyncVoidLambdaExplicit = async (): Promise => { return } -// let testAsyncVoidLambdaExplicitObject = async (): Promise => { return } diff --git a/ets2panda/test/compiler/ets/referenceEqualityNotCastable_n-expected.txt b/ets2panda/test/compiler/ets/referenceEqualityNotCastable_n-expected.txt index a8ead25813310e6942382e3971068a51f88c461f..40632050f73d402805717e77c748c051fdc0818e 100644 --- a/ets2panda/test/compiler/ets/referenceEqualityNotCastable_n-expected.txt +++ b/ets2panda/test/compiler/ets/referenceEqualityNotCastable_n-expected.txt @@ -901,4 +901,4 @@ } } } -TypeError: The operands of strict equality are not compatible with each other [referenceEqualityNotCastable_n.sts:22:11] +TypeError: Operator '===' cannot be applied to types 'A' and 'B'. [referenceEqualityNotCastable_n.sts:22:11] diff --git a/ets2panda/test/compiler/ets/tuple_types_9_neg-expected.txt b/ets2panda/test/compiler/ets/tuple_types_9_neg-expected.txt index 3f9549516efd4a039b491b76863ac67e06d360f3..3c6a9c1c692fcf633e75fd47c18fc4c39bbddb14 100644 --- a/ets2panda/test/compiler/ets/tuple_types_9_neg-expected.txt +++ b/ets2panda/test/compiler/ets/tuple_types_9_neg-expected.txt @@ -709,4 +709,4 @@ } } } -TypeError: Type '[double, String, ...Int[]]' cannot be assigned to type '[double, String, Int]' [tuple_types_9_neg.sts:19:36] +TypeError: Type '[Double, String, ...Int[]]' cannot be assigned to type '[Double, String, Int]' [tuple_types_9_neg.sts:19:36] diff --git a/ets2panda/test/parser/ets/InferTypeParamFromParam2-expected.txt b/ets2panda/test/parser/ets/InferTypeParamFromParam2-expected.txt index de2e089fb05996da7563dd2c45a8996c682c977d..611eeee0416e86b8a21f588b60a9a9b5e98d1eb1 100644 --- a/ets2panda/test/parser/ets/InferTypeParamFromParam2-expected.txt +++ b/ets2panda/test/parser/ets/InferTypeParamFromParam2-expected.txt @@ -2133,4 +2133,4 @@ } } } -TypeError: Type 'B' is not compatible with type 'AInterface' at index 1 [InferTypeParamFromParam2.sts:27:39] +TypeError: No matching call signature for staticFunction(B) [InferTypeParamFromParam2.sts:27:12] diff --git a/ets2panda/test/parser/ets/comment_block-expected.txt b/ets2panda/test/parser/ets/comment_block-expected.txt index 89446062c95d59b86c9c1cd91595cf208db080e4..34161da49dc21c4d072054fe661094090db3d94c 100644 --- a/ets2panda/test/parser/ets/comment_block-expected.txt +++ b/ets2panda/test/parser/ets/comment_block-expected.txt @@ -146,7 +146,7 @@ "column": 1 }, "end": { - "line": 34, + "line": 33, "column": 6 } } diff --git a/ets2panda/test/parser/ets/comment_block.sts b/ets2panda/test/parser/ets/comment_block.sts index 875515bd1971e5b0c287c0742e5cf66f87f478da..68dfeaa95b1bf4834b178d0e37a5e7ff0a64db74 100644 --- a/ets2panda/test/parser/ets/comment_block.sts +++ b/ets2panda/test/parser/ets/comment_block.sts @@ -21,8 +21,7 @@ /* /* - nested block - */ + block */ /* diff --git a/ets2panda/test/parser/ets/declare_enum-expected.txt b/ets2panda/test/parser/ets/declare_enum-expected.txt index 1f8595eba9f39797193dec2f130683b3ebd909e4..2365edb2081fbb5ee6bac785d02d2f0a3bcb259c 100644 --- a/ets2panda/test/parser/ets/declare_enum-expected.txt +++ b/ets2panda/test/parser/ets/declare_enum-expected.txt @@ -230,12 +230,56 @@ "column": 1 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "#Enum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ { "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Enum#NamesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -248,38 +292,44 @@ } } }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "AAA", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "accessibility": "protected", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 }, - { - "type": "StringLiteral", - "value": "BBB", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "end": { + "line": 1, + "column": 1 } - ], + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "", + "decorators": [], "loc": { "start": { "line": 1, @@ -291,33 +341,37 @@ } } }, + "kind": "method", "accessibility": "public", "static": true, - "readonly": false, - "declare": false, "optional": false, "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], "loc": { "start": { "line": 1, @@ -351,7 +405,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -368,7 +422,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Enum#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -381,9 +435,9 @@ } } }, - "kind": "method", + "kind": "constructor", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -392,7 +446,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Enum#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -415,35 +469,7 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Enum", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -479,76 +505,18 @@ } } ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "declare": true, "body": { "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Enum#NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", "loc": { "start": { "line": 1, @@ -560,8 +528,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -573,6 +543,23 @@ } } }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -584,8 +571,6 @@ } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 1, @@ -656,10 +641,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Enum#valueOf", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -672,19 +657,12 @@ } } }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "#Enum#valueOf", - "decorators": [], + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "AAA", "loc": { "start": { "line": 1, @@ -696,99 +674,48 @@ } } }, - "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": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + { + "type": "StringLiteral", + "value": "BBB", + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Enum", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], "loc": { "start": { "line": 1, @@ -811,163 +738,504 @@ } } }, - "declare": true, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ForUpdateStatement", - "init": { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "init": { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "test": { - "type": "BinaryExpression", - "operator": "<", - "left": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Enum#NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "length", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "0", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "1", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "update": { - "type": "UpdateExpression", - "operator": "++", - "prefix": true, - "argument": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "AAA", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "BBB", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "BoxedItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Enum", + "decorators": [], "loc": { "start": { "line": 1, @@ -979,71 +1247,37 @@ } } }, - "body": { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "==", - "left": { - "type": "Identifier", - "name": "name", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Enum#NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Enum", + "decorators": [], "loc": { "start": { "line": 1, @@ -1055,77 +1289,10 @@ } } }, - "consequent": { - "type": "ReturnStatement", - "argument": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Enum", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "property": { + "type": "Identifier", + "name": "AAA", + "decorators": [], "loc": { "start": { "line": 1, @@ -1137,7 +1304,8 @@ } } }, - "alternate": null, + "computed": false, + "optional": false, "loc": { "start": { "line": 1, @@ -1149,107 +1317,8 @@ } } }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ThrowStatement", - "argument": { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Exception", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "arguments": [ - { - "type": "BinaryExpression", - "operator": "+", - "left": { - "type": "StringLiteral", - "value": "No enum constant Enum.", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "right": { - "type": "Identifier", - "name": "name", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], + "typeAnnotation": { + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1283,80 +1352,123 @@ "column": 1 } } - } - "throwMarker": "throws", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#Enum#ValuesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 1, - "column": 1 + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Enum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "BBB", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } } - } - }, - { - "type": "NumberLiteral", - "value": 1, + ], "loc": { "start": { "line": 1, @@ -1380,7 +1492,7 @@ } } }, - "accessibility": "public", + "accessibility": "protected", "static": true, "readonly": false, "declare": false, @@ -1389,7 +1501,35 @@ "typeAnnotation": { "type": "TSArrayType", "elementType": { - "type": "ETSPrimitiveType", + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Enum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -1429,7 +1569,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Enum#getValue", + "name": "getName", "decorators": [], "loc": { "start": { @@ -1453,7 +1593,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Enum#getValue", + "name": "getName", "decorators": [], "loc": { "start": { @@ -1474,7 +1614,7 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "e", + "name": "ordinal", "typeAnnotation": { "type": "ETSTypeReference", "part": { @@ -1541,7 +1681,35 @@ } ], "returnType": { - "type": "ETSPrimitiveType", + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -1554,33 +1722,98 @@ } }, "declare": true, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Enum#ValuesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "valueOf", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "name", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { "type": "Identifier", - "name": "e", + "name": "String", "decorators": [], "loc": { "start": { @@ -1593,19 +1826,6 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, "loc": { "start": { "line": 1, @@ -1617,8 +1837,6 @@ } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 1, @@ -1630,6 +1848,38 @@ } } }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Enum", + "decorators": [], "loc": { "start": { "line": 1, @@ -1640,8 +1890,18 @@ "column": 1 } } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - ], + }, "loc": { "start": { "line": 1, @@ -1653,6 +1913,8 @@ } } }, + "declare": true + "throwMarker": "throws", "loc": { "start": { "line": 1, @@ -1689,10 +1951,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Enum#StringValuesArray", + "name": "getValue", "decorators": [], "loc": { "start": { @@ -1705,12 +1967,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "0", + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getValue", + "decorators": [], "loc": { "start": { "line": 1, @@ -1722,48 +1991,68 @@ } } }, - { - "type": "StringLiteral", - "value": "1", - "loc": { - "start": { - "line": 1, - "column": 1 + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "e", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], "loc": { "start": { "line": 1, @@ -1774,7 +2063,10 @@ "column": 1 } } - }, + } + ], + "returnType": { + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1786,6 +2078,7 @@ } } }, + "declare": true, "loc": { "start": { "line": 1, @@ -1808,7 +2101,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -1825,7 +2118,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Enum#toString", + "name": "toString", "decorators": [], "loc": { "start": { @@ -1849,7 +2142,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Enum#toString", + "name": "toString", "decorators": [], "loc": { "start": { @@ -1978,71 +2271,96 @@ } }, "declare": true, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Enum#StringValuesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": true, - "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "values", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Enum", + "decorators": [], "loc": { "start": { "line": 1, @@ -2064,8 +2382,18 @@ "column": 1 } } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - ], + }, "loc": { "start": { "line": 1, @@ -2077,6 +2405,7 @@ } } }, + "declare": true, "loc": { "start": { "line": 1, @@ -2113,10 +2442,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Enum#ItemsArray", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -2129,43 +2458,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Enum", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "AAA", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "fromInt", + "decorators": [], "loc": { "start": { "line": 1, @@ -2177,27 +2482,40 @@ } } }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Enum", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - } - }, - "property": { - "type": "Identifier", - "name": "BBB", - "decorators": [], + }, "loc": { "start": { "line": 1, @@ -2208,48 +2526,27 @@ "column": 1 } } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Enum", - "decorators": [], + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -2272,6 +2569,8 @@ } } }, + "declare": true + "throwMarker": "throws", "loc": { "start": { "line": 1, @@ -2294,7 +2593,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2311,7 +2610,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Enum#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -2326,7 +2625,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -2335,7 +2634,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Enum#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -2353,26 +2652,13 @@ "expression": false, "params": [], "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Enum", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Enum", + "decorators": [], "loc": { "start": { "line": 1, @@ -2407,49 +2693,6 @@ } }, "declare": true, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "#Enum#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, "loc": { "start": { "line": 1, @@ -2489,7 +2732,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Enum#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -2513,7 +2756,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Enum#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -2578,7 +2821,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Enum", + "name": "#Enum", "decorators": [], "loc": { "start": { @@ -2613,280 +2856,7 @@ } } }, - "declare": true, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "<", - "left": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Enum#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "length", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "consequent": { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Enum#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "alternate": null, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ThrowStatement", - "argument": { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Exception", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "arguments": [ - { - "type": "BinaryExpression", - "operator": "+", - "left": { - "type": "StringLiteral", - "value": "No enum constant in Enum with ordinal value ", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "right": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } + "declare": true "throwMarker": "throws", "loc": { "start": { diff --git a/ets2panda/test/parser/ets/differentTypeCompare-expected.txt b/ets2panda/test/parser/ets/differentTypeCompare-expected.txt index d0244231c9276c17f6e4e8f92d4fedbb2cae811e..5a60a9ad37c82932eb5e4ca46a8fc63f1e76686a 100644 --- a/ets2panda/test/parser/ets/differentTypeCompare-expected.txt +++ b/ets2panda/test/parser/ets/differentTypeCompare-expected.txt @@ -212,7 +212,7 @@ }, "end": { "line": 16, - "column": 34 + "column": 31 } } }, @@ -222,7 +222,7 @@ "loc": { "start": { "line": 16, - "column": 35 + "column": 32 }, "end": { "line": 17, @@ -666,4 +666,4 @@ } } } -TypeError: Bad operand type, the types of the operands must be numeric or boolean type. [differentTypeCompare.sts:23:9] +TypeError: Bad operand type, the types of the operands must be numeric, same enumeration, or boolean type. [differentTypeCompare.sts:23:9] diff --git a/ets2panda/test/parser/ets/differentTypeCompare.sts b/ets2panda/test/parser/ets/differentTypeCompare.sts index 05201d7c99d411dee164c09b38c7f44b16a0e750..4f4d459ebbbd1873c7dee33bbd5222a42adbf515 100644 --- a/ets2panda/test/parser/ets/differentTypeCompare.sts +++ b/ets2panda/test/parser/ets/differentTypeCompare.sts @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -function foo(a: boolean): boolean { +function foo(a: boolean): void { } function main(): void { diff --git a/ets2panda/test/parser/ets/enum-expected.txt b/ets2panda/test/parser/ets/enum-expected.txt index 1b1fac78cf462835e5d8839f888016662ece9e27..c70ab2b9c678e611317d9719deae7604cc31c2a8 100644 --- a/ets2panda/test/parser/ets/enum-expected.txt +++ b/ets2panda/test/parser/ets/enum-expected.txt @@ -2723,12 +2723,56 @@ "column": 2 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ { "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2741,52 +2785,44 @@ } } }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "Red", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "StringLiteral", - "value": "Green", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "accessibility": "protected", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 }, - { - "type": "StringLiteral", - "value": "Blue", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "end": { + "line": 1, + "column": 1 } - ], + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "", + "decorators": [], "loc": { "start": { "line": 1, @@ -2798,33 +2834,37 @@ } } }, + "kind": "method", "accessibility": "public", "static": true, - "readonly": false, - "declare": false, "optional": false, "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], "loc": { "start": { "line": 1, @@ -2858,7 +2898,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2875,7 +2915,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -2888,9 +2928,9 @@ } } }, - "kind": "method", + "kind": "constructor", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -2899,7 +2939,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -2922,35 +2962,7 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -2986,75 +2998,18 @@ } } ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, "body": { "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color#NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", "loc": { "start": { "line": 1, @@ -3066,8 +3021,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -3079,6 +3036,23 @@ } } }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -3090,8 +3064,6 @@ } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 1, @@ -3162,10 +3134,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#valueOf", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -3178,19 +3150,12 @@ } } }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "#Color#valueOf", - "decorators": [], + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "Red", "loc": { "start": { "line": 1, @@ -3202,99 +3167,62 @@ } } }, - "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": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + { + "type": "StringLiteral", + "value": "Green", + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + }, + { + "type": "StringLiteral", + "value": "Blue", + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], "loc": { "start": { "line": 1, @@ -3317,58 +3245,1531 @@ } } }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ForUpdateStatement", - "init": { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "init": { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "kind": "let", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "NumberLiteral", + "value": 2, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "0", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "1", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "2", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Green", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Blue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "BoxedItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Green", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Blue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getName", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "valueOf", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ForUpdateStatement", + "init": { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "init": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "kind": "let", "loc": { "start": { "line": 1, @@ -3402,7 +4803,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -3508,7 +4909,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -3826,10 +5227,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#ValuesArray", + "name": "getValue", "decorators": [], "loc": { "start": { @@ -3842,12 +5243,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumberLiteral", - "value": 0, + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getValue", + "decorators": [], "loc": { "start": { "line": 1, @@ -3859,23 +5267,181 @@ } } }, - { - "type": "NumberLiteral", - "value": 1, - "loc": { - "start": { - "line": 1, - "column": 1 + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "e", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, - { - "type": "NumberLiteral", - "value": 2, + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "e", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], "loc": { "start": { "line": 1, @@ -3886,29 +5452,7 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -3931,7 +5475,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -3948,7 +5492,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -3972,7 +5516,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -3993,7 +5537,7 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "e", + "name": "ordinal", "typeAnnotation": { "type": "ETSTypeReference", "part": { @@ -4060,7 +5604,35 @@ } ], "returnType": { - "type": "ETSPrimitiveType", + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -4081,7 +5653,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#ValuesArray", + "name": "StringValuesArray", "decorators": [], "loc": { "start": { @@ -4098,7 +5670,7 @@ "type": "TSAsExpression", "expression": { "type": "Identifier", - "name": "e", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -4207,10 +5779,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#StringValuesArray", + "name": "values", "decorators": [], "loc": { "start": { @@ -4223,12 +5795,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "0", + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "values", + "decorators": [], "loc": { "start": { "line": 1, @@ -4240,23 +5819,53 @@ } } }, - { - "type": "StringLiteral", - "value": "1", - "loc": { - "start": { - "line": 1, - "column": 1 + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - } - }, - { - "type": "StringLiteral", - "value": "2", + }, "loc": { "start": { "line": 1, @@ -4267,46 +5876,39 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -4340,7 +5942,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -4357,7 +5959,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -4381,7 +5983,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -4404,35 +6006,7 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -4474,7 +6048,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "Color", "decorators": [], "loc": { "start": { @@ -4513,12 +6087,13 @@ "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { "type": "Identifier", - "name": "#Color#StringValuesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -4531,11 +6106,69 @@ } } }, - "property": { - "type": "TSAsExpression", - "expression": { + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { "type": "Identifier", - "name": "ordinal", + "name": "ItemsArray", "decorators": [], "loc": { "start": { @@ -4548,8 +6181,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -4561,6 +6196,8 @@ } } }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -4572,8 +6209,6 @@ } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 1, @@ -4585,258 +6220,131 @@ } } }, + "alternate": null, "loc": { "start": { "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#Color#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Red", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Green", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Blue", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant in Color with ordinal value ", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -4847,7 +6355,8 @@ "column": 1 } } - }, + } + "throwMarker": "throws", "loc": { "start": { "line": 1, @@ -4870,7 +6379,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -4887,7 +6396,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -4902,7 +6411,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -4911,7 +6420,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -4929,26 +6438,13 @@ "expression": false, "params": [], "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], "loc": { "start": { "line": 1, @@ -4988,9 +6484,67 @@ { "type": "ReturnStatement", "argument": { - "type": "Identifier", - "name": "#Color#ItemsArray", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -5064,7 +6618,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -5088,7 +6642,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -5153,7 +6707,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Color", + "name": "#Color", "decorators": [], "loc": { "start": { @@ -5215,7 +6769,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -5273,7 +6827,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { diff --git a/ets2panda/test/parser/ets/enum10-expected.txt b/ets2panda/test/parser/ets/enum10-expected.txt index 30c514b1bc20d43ff56a8d03328195ba26031575..93c0f3016fc340697b5ba362dfb50fdf6f7c93fb 100644 --- a/ets2panda/test/parser/ets/enum10-expected.txt +++ b/ets2panda/test/parser/ets/enum10-expected.txt @@ -641,12 +641,750 @@ "column": 2 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "Red", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "0", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, { "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "ItemsArray", "decorators": [], "loc": { "start": { @@ -663,8 +1401,271 @@ "type": "ArrayExpression", "elements": [ { - "type": "StringLiteral", - "value": "Red", + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "BoxedItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], "loc": { "start": { "line": 1, @@ -688,7 +1689,7 @@ } } }, - "accessibility": "public", + "accessibility": "protected", "static": true, "readonly": false, "declare": false, @@ -702,7 +1703,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "#Color", "decorators": [], "loc": { "start": { @@ -765,7 +1766,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#getName", + "name": "getName", "decorators": [], "loc": { "start": { @@ -789,7 +1790,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#getName", + "name": "getName", "decorators": [], "loc": { "start": { @@ -926,7 +1927,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1055,7 +2056,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#valueOf", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -1079,7 +2080,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#valueOf", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -1292,7 +2293,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1398,7 +2399,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1644,7 +2645,270 @@ } } } - ], + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + "throwMarker": "throws", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getValue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getValue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "e", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "e", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -1678,99 +2942,7 @@ "column": 1 } } - } - "throwMarker": "throws", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#Color#ValuesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1793,7 +2965,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -1810,7 +2982,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -1834,7 +3006,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -1855,7 +3027,7 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "e", + "name": "ordinal", "typeAnnotation": { "type": "ETSTypeReference", "part": { @@ -1922,7 +3094,35 @@ } ], "returnType": { - "type": "ETSPrimitiveType", + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -1943,7 +3143,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#ValuesArray", + "name": "StringValuesArray", "decorators": [], "loc": { "start": { @@ -1960,7 +3160,7 @@ "type": "TSAsExpression", "expression": { "type": "Identifier", - "name": "e", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2069,10 +3269,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#StringValuesArray", + "name": "values", "decorators": [], "loc": { "start": { @@ -2085,12 +3285,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "0", + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "values", + "decorators": [], "loc": { "start": { "line": 1, @@ -2101,46 +3308,97 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, "column": 1 }, - "end": { - "line": 1, - "column": 1 + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -2174,7 +3432,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2191,7 +3449,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -2215,7 +3473,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -2238,35 +3496,7 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -2308,7 +3538,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "Color", "decorators": [], "loc": { "start": { @@ -2347,12 +3577,13 @@ "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { "type": "Identifier", - "name": "#Color#StringValuesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2365,9 +3596,82 @@ } } }, - "property": { - "type": "TSAsExpression", - "expression": { + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { "type": "Identifier", "name": "ordinal", "decorators": [], @@ -2382,8 +3686,120 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "alternate": null, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant in Color with ordinal value ", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -2394,20 +3810,8 @@ "column": 1 } } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } } - }, - "computed": true, - "optional": false, + ], "loc": { "start": { "line": 1, @@ -2441,157 +3845,8 @@ "column": 1 } } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#Color#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Red", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "throwMarker": "throws", "loc": { "start": { "line": 1, @@ -2614,7 +3869,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2631,7 +3886,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -2646,7 +3901,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -2655,7 +3910,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -2673,26 +3928,13 @@ "expression": false, "params": [], "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], "loc": { "start": { "line": 1, @@ -2732,9 +3974,67 @@ { "type": "ReturnStatement", "argument": { - "type": "Identifier", - "name": "#Color#ItemsArray", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -2808,7 +4108,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -2832,7 +4132,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -2897,7 +4197,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Color", + "name": "#Color", "decorators": [], "loc": { "start": { @@ -2959,7 +4259,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -3017,7 +4317,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { diff --git a/ets2panda/test/parser/ets/enum11-expected.txt b/ets2panda/test/parser/ets/enum11-expected.txt index ff9bec04068006d9e29a713302b9ea215bdf272e..a310ad1c0f13a27f3c6ea376d0a82fe44a7fbc8e 100644 --- a/ets2panda/test/parser/ets/enum11-expected.txt +++ b/ets2panda/test/parser/ets/enum11-expected.txt @@ -792,12 +792,750 @@ "column": 2 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "Red", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "0", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, { "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "ItemsArray", "decorators": [], "loc": { "start": { @@ -814,8 +1552,271 @@ "type": "ArrayExpression", "elements": [ { - "type": "StringLiteral", - "value": "Red", + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "BoxedItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], "loc": { "start": { "line": 1, @@ -839,7 +1840,7 @@ } } }, - "accessibility": "public", + "accessibility": "protected", "static": true, "readonly": false, "declare": false, @@ -853,7 +1854,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "#Color", "decorators": [], "loc": { "start": { @@ -916,7 +1917,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#getName", + "name": "getName", "decorators": [], "loc": { "start": { @@ -940,7 +1941,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#getName", + "name": "getName", "decorators": [], "loc": { "start": { @@ -1077,7 +2078,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1206,7 +2207,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#valueOf", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -1230,7 +2231,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#valueOf", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -1443,7 +2444,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1549,7 +2550,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1795,7 +2796,270 @@ } } } - ], + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + "throwMarker": "throws", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getValue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getValue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "e", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "e", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -1829,99 +3093,7 @@ "column": 1 } } - } - "throwMarker": "throws", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#Color#ValuesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1944,7 +3116,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -1961,7 +3133,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -1985,7 +3157,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -2006,7 +3178,7 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "e", + "name": "ordinal", "typeAnnotation": { "type": "ETSTypeReference", "part": { @@ -2073,7 +3245,35 @@ } ], "returnType": { - "type": "ETSPrimitiveType", + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -2094,7 +3294,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#ValuesArray", + "name": "StringValuesArray", "decorators": [], "loc": { "start": { @@ -2111,7 +3311,7 @@ "type": "TSAsExpression", "expression": { "type": "Identifier", - "name": "e", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2220,10 +3420,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#StringValuesArray", + "name": "values", "decorators": [], "loc": { "start": { @@ -2236,12 +3436,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "0", + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "values", + "decorators": [], "loc": { "start": { "line": 1, @@ -2252,46 +3459,97 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, "column": 1 }, - "end": { - "line": 1, - "column": 1 + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -2325,7 +3583,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2342,7 +3600,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -2366,7 +3624,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -2389,35 +3647,7 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -2459,7 +3689,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "Color", "decorators": [], "loc": { "start": { @@ -2498,12 +3728,13 @@ "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { "type": "Identifier", - "name": "#Color#StringValuesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2516,9 +3747,82 @@ } } }, - "property": { - "type": "TSAsExpression", - "expression": { + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { "type": "Identifier", "name": "ordinal", "decorators": [], @@ -2533,8 +3837,120 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "alternate": null, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant in Color with ordinal value ", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -2545,20 +3961,8 @@ "column": 1 } } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } } - }, - "computed": true, - "optional": false, + ], "loc": { "start": { "line": 1, @@ -2592,157 +3996,8 @@ "column": 1 } } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#Color#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Red", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "throwMarker": "throws", "loc": { "start": { "line": 1, @@ -2765,7 +4020,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2782,7 +4037,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -2797,7 +4052,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -2806,7 +4061,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -2824,26 +4079,13 @@ "expression": false, "params": [], "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], "loc": { "start": { "line": 1, @@ -2883,9 +4125,67 @@ { "type": "ReturnStatement", "argument": { - "type": "Identifier", - "name": "#Color#ItemsArray", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -2959,7 +4259,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -2983,7 +4283,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -3048,7 +4348,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Color", + "name": "#Color", "decorators": [], "loc": { "start": { @@ -3110,7 +4410,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -3168,7 +4468,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { diff --git a/ets2panda/test/parser/ets/enum12-expected.txt b/ets2panda/test/parser/ets/enum12-expected.txt index 5210fee14dfe73530643e5f5db6272ea979406a9..d87655103340a838fd74afe346549c1376c97a46 100644 --- a/ets2panda/test/parser/ets/enum12-expected.txt +++ b/ets2panda/test/parser/ets/enum12-expected.txt @@ -825,12 +825,750 @@ "column": 2 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "Red", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "0", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, { "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "ItemsArray", "decorators": [], "loc": { "start": { @@ -847,8 +1585,271 @@ "type": "ArrayExpression", "elements": [ { - "type": "StringLiteral", - "value": "Red", + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "BoxedItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], "loc": { "start": { "line": 1, @@ -872,7 +1873,7 @@ } } }, - "accessibility": "public", + "accessibility": "protected", "static": true, "readonly": false, "declare": false, @@ -886,7 +1887,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "#Color", "decorators": [], "loc": { "start": { @@ -949,7 +1950,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#getName", + "name": "getName", "decorators": [], "loc": { "start": { @@ -973,7 +1974,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#getName", + "name": "getName", "decorators": [], "loc": { "start": { @@ -1110,7 +2111,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1239,7 +2240,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#valueOf", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -1263,7 +2264,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#valueOf", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -1476,7 +2477,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1582,7 +2583,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1828,7 +2829,270 @@ } } } - ], + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + "throwMarker": "throws", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getValue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getValue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "e", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "e", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -1862,99 +3126,7 @@ "column": 1 } } - } - "throwMarker": "throws", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#Color#ValuesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1977,7 +3149,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -1994,7 +3166,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -2018,7 +3190,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -2039,7 +3211,7 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "e", + "name": "ordinal", "typeAnnotation": { "type": "ETSTypeReference", "part": { @@ -2106,7 +3278,35 @@ } ], "returnType": { - "type": "ETSPrimitiveType", + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -2127,7 +3327,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#ValuesArray", + "name": "StringValuesArray", "decorators": [], "loc": { "start": { @@ -2144,7 +3344,7 @@ "type": "TSAsExpression", "expression": { "type": "Identifier", - "name": "e", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2253,10 +3453,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#StringValuesArray", + "name": "values", "decorators": [], "loc": { "start": { @@ -2269,12 +3469,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "0", + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "values", + "decorators": [], "loc": { "start": { "line": 1, @@ -2285,46 +3492,97 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, "column": 1 }, - "end": { - "line": 1, - "column": 1 + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -2358,7 +3616,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2375,7 +3633,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -2399,7 +3657,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -2422,35 +3680,7 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -2492,7 +3722,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "Color", "decorators": [], "loc": { "start": { @@ -2531,12 +3761,13 @@ "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { "type": "Identifier", - "name": "#Color#StringValuesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2549,9 +3780,82 @@ } } }, - "property": { - "type": "TSAsExpression", - "expression": { + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { "type": "Identifier", "name": "ordinal", "decorators": [], @@ -2566,8 +3870,120 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "alternate": null, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant in Color with ordinal value ", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -2578,20 +3994,8 @@ "column": 1 } } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } } - }, - "computed": true, - "optional": false, + ], "loc": { "start": { "line": 1, @@ -2625,157 +4029,8 @@ "column": 1 } } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#Color#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Red", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "throwMarker": "throws", "loc": { "start": { "line": 1, @@ -2798,7 +4053,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2815,7 +4070,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -2830,7 +4085,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -2839,7 +4094,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -2857,26 +4112,13 @@ "expression": false, "params": [], "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], "loc": { "start": { "line": 1, @@ -2916,9 +4158,67 @@ { "type": "ReturnStatement", "argument": { - "type": "Identifier", - "name": "#Color#ItemsArray", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -2992,7 +4292,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -3016,7 +4316,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -3081,7 +4381,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Color", + "name": "#Color", "decorators": [], "loc": { "start": { @@ -3143,7 +4443,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -3201,7 +4501,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { diff --git a/ets2panda/test/parser/ets/enum13-expected.txt b/ets2panda/test/parser/ets/enum13-expected.txt index d7de8e181265766813c50044291ab4888440d697..8fc87cf1ac1f3223ad7c19ea0c9947fd17d49f34 100644 --- a/ets2panda/test/parser/ets/enum13-expected.txt +++ b/ets2panda/test/parser/ets/enum13-expected.txt @@ -884,12 +884,750 @@ "column": 2 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "Red", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "0", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, { "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "ItemsArray", "decorators": [], "loc": { "start": { @@ -906,8 +1644,271 @@ "type": "ArrayExpression", "elements": [ { - "type": "StringLiteral", - "value": "Red", + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "BoxedItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], "loc": { "start": { "line": 1, @@ -931,7 +1932,7 @@ } } }, - "accessibility": "public", + "accessibility": "protected", "static": true, "readonly": false, "declare": false, @@ -945,7 +1946,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "#Color", "decorators": [], "loc": { "start": { @@ -1008,7 +2009,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#getName", + "name": "getName", "decorators": [], "loc": { "start": { @@ -1032,7 +2033,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#getName", + "name": "getName", "decorators": [], "loc": { "start": { @@ -1169,7 +2170,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1298,7 +2299,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#valueOf", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -1322,7 +2323,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#valueOf", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -1535,7 +2536,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1641,7 +2642,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1887,7 +2888,270 @@ } } } - ], + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + "throwMarker": "throws", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getValue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getValue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "e", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "e", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -1921,99 +3185,7 @@ "column": 1 } } - } - "throwMarker": "throws", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#Color#ValuesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -2036,7 +3208,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2053,7 +3225,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -2077,7 +3249,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -2098,7 +3270,7 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "e", + "name": "ordinal", "typeAnnotation": { "type": "ETSTypeReference", "part": { @@ -2165,7 +3337,35 @@ } ], "returnType": { - "type": "ETSPrimitiveType", + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -2186,7 +3386,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#ValuesArray", + "name": "StringValuesArray", "decorators": [], "loc": { "start": { @@ -2203,7 +3403,7 @@ "type": "TSAsExpression", "expression": { "type": "Identifier", - "name": "e", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2312,10 +3512,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#StringValuesArray", + "name": "values", "decorators": [], "loc": { "start": { @@ -2328,12 +3528,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "0", + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "values", + "decorators": [], "loc": { "start": { "line": 1, @@ -2344,46 +3551,97 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, "column": 1 }, - "end": { - "line": 1, - "column": 1 + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -2417,7 +3675,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2434,7 +3692,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -2458,7 +3716,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -2481,35 +3739,7 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -2551,7 +3781,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "Color", "decorators": [], "loc": { "start": { @@ -2590,12 +3820,13 @@ "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { "type": "Identifier", - "name": "#Color#StringValuesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2608,9 +3839,82 @@ } } }, - "property": { - "type": "TSAsExpression", - "expression": { + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { "type": "Identifier", "name": "ordinal", "decorators": [], @@ -2625,8 +3929,120 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "alternate": null, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant in Color with ordinal value ", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -2637,20 +4053,8 @@ "column": 1 } } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } } - }, - "computed": true, - "optional": false, + ], "loc": { "start": { "line": 1, @@ -2684,157 +4088,8 @@ "column": 1 } } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#Color#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Red", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "throwMarker": "throws", "loc": { "start": { "line": 1, @@ -2857,7 +4112,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2874,7 +4129,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -2889,7 +4144,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -2898,7 +4153,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -2916,26 +4171,13 @@ "expression": false, "params": [], "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], "loc": { "start": { "line": 1, @@ -2975,9 +4217,67 @@ { "type": "ReturnStatement", "argument": { - "type": "Identifier", - "name": "#Color#ItemsArray", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -3051,7 +4351,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -3075,7 +4375,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -3140,7 +4440,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Color", + "name": "#Color", "decorators": [], "loc": { "start": { @@ -3202,7 +4502,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -3260,7 +4560,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { diff --git a/ets2panda/test/parser/ets/enum14-expected.txt b/ets2panda/test/parser/ets/enum14-expected.txt index c98bde6c51942e1d49907d4a94d0a3889e0ceda5..7de10b339ba6b4c54c59c46cbbabc5e58f3390e2 100644 --- a/ets2panda/test/parser/ets/enum14-expected.txt +++ b/ets2panda/test/parser/ets/enum14-expected.txt @@ -721,12 +721,56 @@ "column": 2 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ { "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -739,52 +783,44 @@ } } }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "Red", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "StringLiteral", - "value": "Green", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "accessibility": "protected", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 }, - { - "type": "StringLiteral", - "value": "Blue", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "end": { + "line": 1, + "column": 1 } - ], + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "", + "decorators": [], "loc": { "start": { "line": 1, @@ -796,33 +832,37 @@ } } }, + "kind": "method", "accessibility": "public", "static": true, - "readonly": false, - "declare": false, "optional": false, "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], "loc": { "start": { "line": 1, @@ -856,7 +896,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -873,7 +913,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -886,9 +926,9 @@ } } }, - "kind": "method", + "kind": "constructor", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -897,7 +937,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -920,12 +960,68 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { "type": "Identifier", - "name": "Color", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -938,6 +1034,23 @@ } } }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -960,7 +1073,6 @@ } } }, - "decorators": [], "loc": { "start": { "line": 1, @@ -971,49 +1083,91 @@ "column": 1 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "Red", + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } - }, + } + }, + { + "type": "StringLiteral", + "value": "Green", "loc": { "start": { "line": 1, @@ -1025,94 +1179,59 @@ } } }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color#NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + { + "type": "StringLiteral", + "value": "Blue", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], + }, "loc": { "start": { "line": 1, @@ -1146,7 +1265,7 @@ } } }, - "overloads": [], + "definite": false, "decorators": [], "loc": { "start": { @@ -1160,10 +1279,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#valueOf", + "name": "ValuesArray", "decorators": [], "loc": { "start": { @@ -1176,18 +1295,1300 @@ } } }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { + "type": "ArrayExpression", + "elements": [ + { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "NumberLiteral", + "value": 2, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "0", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "1", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "2", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Green", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Blue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "BoxedItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Green", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Blue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getName", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "valueOf", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { "type": "Identifier", - "name": "#Color#valueOf", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -1400,7 +2801,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1506,7 +2907,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1824,10 +3225,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#ValuesArray", + "name": "getValue", "decorators": [], "loc": { "start": { @@ -1840,12 +3241,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumberLiteral", - "value": 0, + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getValue", + "decorators": [], "loc": { "start": { "line": 1, @@ -1857,9 +3265,82 @@ } } }, - { - "type": "NumberLiteral", - "value": 1, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "e", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1871,9 +3352,94 @@ } } }, - { - "type": "NumberLiteral", - "value": 2, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "e", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], "loc": { "start": { "line": 1, @@ -1884,29 +3450,7 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1929,7 +3473,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -1946,7 +3490,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -1970,7 +3514,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -1991,7 +3535,7 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "e", + "name": "ordinal", "typeAnnotation": { "type": "ETSTypeReference", "part": { @@ -2058,7 +3602,35 @@ } ], "returnType": { - "type": "ETSPrimitiveType", + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -2079,7 +3651,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#ValuesArray", + "name": "StringValuesArray", "decorators": [], "loc": { "start": { @@ -2096,7 +3668,7 @@ "type": "TSAsExpression", "expression": { "type": "Identifier", - "name": "e", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2205,10 +3777,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#StringValuesArray", + "name": "values", "decorators": [], "loc": { "start": { @@ -2221,12 +3793,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "0", + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "values", + "decorators": [], "loc": { "start": { "line": 1, @@ -2238,23 +3817,53 @@ } } }, - { - "type": "StringLiteral", - "value": "1", - "loc": { - "start": { - "line": 1, - "column": 1 + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - } - }, - { - "type": "StringLiteral", - "value": "2", + }, "loc": { "start": { "line": 1, @@ -2265,46 +3874,39 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -2338,7 +3940,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2355,7 +3957,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -2379,7 +3981,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -2402,35 +4004,7 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -2472,7 +4046,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "Color", "decorators": [], "loc": { "start": { @@ -2511,12 +4085,13 @@ "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { "type": "Identifier", - "name": "#Color#StringValuesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2529,11 +4104,69 @@ } } }, - "property": { - "type": "TSAsExpression", - "expression": { + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { "type": "Identifier", - "name": "ordinal", + "name": "ItemsArray", "decorators": [], "loc": { "start": { @@ -2546,8 +4179,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -2559,6 +4194,8 @@ } } }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -2570,8 +4207,6 @@ } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 1, @@ -2583,6 +4218,7 @@ } } }, + "alternate": null, "loc": { "start": { "line": 1, @@ -2591,250 +4227,122 @@ "end": { "line": 1, "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#Color#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Red", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Green", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Blue", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 + } } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant in Color with ordinal value ", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -2845,7 +4353,8 @@ "column": 1 } } - }, + } + "throwMarker": "throws", "loc": { "start": { "line": 1, @@ -2868,7 +4377,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2885,7 +4394,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -2900,7 +4409,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -2909,7 +4418,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -2927,26 +4436,13 @@ "expression": false, "params": [], "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], "loc": { "start": { "line": 1, @@ -2986,9 +4482,67 @@ { "type": "ReturnStatement", "argument": { - "type": "Identifier", - "name": "#Color#ItemsArray", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -3062,7 +4616,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -3086,7 +4640,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -3151,7 +4705,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Color", + "name": "#Color", "decorators": [], "loc": { "start": { @@ -3213,7 +4767,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -3271,7 +4825,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { diff --git a/ets2panda/test/parser/ets/enum19-expected.txt b/ets2panda/test/parser/ets/enum19-expected.txt index 278789677e06e54ac85ba59249b83006d9f1c3b9..c9b00b58c491a22062ef742cfe3754c8a474b2d0 100644 --- a/ets2panda/test/parser/ets/enum19-expected.txt +++ b/ets2panda/test/parser/ets/enum19-expected.txt @@ -272,12 +272,56 @@ "column": 1 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "#InvalidInitTypeEnum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ { "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#InvalidInitTypeEnum#NamesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -290,52 +334,44 @@ } } }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "Red", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "StringLiteral", - "value": "Green", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "accessibility": "protected", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 }, - { - "type": "StringLiteral", - "value": "Blue", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "end": { + "line": 1, + "column": 1 } - ], + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "", + "decorators": [], "loc": { "start": { "line": 1, @@ -347,33 +383,37 @@ } } }, + "kind": "method", "accessibility": "public", "static": true, - "readonly": false, - "declare": false, "optional": false, "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], "loc": { "start": { "line": 1, @@ -407,7 +447,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -424,7 +464,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#InvalidInitTypeEnum#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -437,9 +477,9 @@ } } }, - "kind": "method", + "kind": "constructor", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -448,7 +488,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#InvalidInitTypeEnum#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -471,12 +511,68 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { "type": "Identifier", - "name": "InvalidInitTypeEnum", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -489,6 +585,23 @@ } } }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -511,7 +624,6 @@ } } }, - "decorators": [], "loc": { "start": { "line": 1, @@ -522,49 +634,91 @@ "column": 1 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "Red", + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } - }, + } + }, + { + "type": "StringLiteral", + "value": "Green", "loc": { "start": { "line": 1, @@ -576,94 +730,59 @@ } } }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#InvalidInitTypeEnum#NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + { + "type": "StringLiteral", + "value": "Blue", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], + }, "loc": { "start": { "line": 1, @@ -697,7 +816,7 @@ } } }, - "overloads": [], + "definite": false, "decorators": [], "loc": { "start": { @@ -711,10 +830,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#InvalidInitTypeEnum#valueOf", + "name": "ValuesArray", "decorators": [], "loc": { "start": { @@ -727,18 +846,1300 @@ } } }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { + "type": "ArrayExpression", + "elements": [ + { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "NumberLiteral", + "value": -1, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "NumberLiteral", + "value": -1, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "0", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "-1", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "-1", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "InvalidInitTypeEnum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "InvalidInitTypeEnum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Green", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "InvalidInitTypeEnum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Blue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "InvalidInitTypeEnum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "BoxedItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#InvalidInitTypeEnum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "InvalidInitTypeEnum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#InvalidInitTypeEnum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "InvalidInitTypeEnum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Green", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#InvalidInitTypeEnum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "InvalidInitTypeEnum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Blue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#InvalidInitTypeEnum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getName", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "InvalidInitTypeEnum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "valueOf", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { "type": "Identifier", - "name": "#InvalidInitTypeEnum#valueOf", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -951,7 +2352,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#InvalidInitTypeEnum#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1057,7 +2458,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#InvalidInitTypeEnum#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1375,10 +2776,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#InvalidInitTypeEnum#ValuesArray", + "name": "getValue", "decorators": [], "loc": { "start": { @@ -1391,12 +2792,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumberLiteral", - "value": 0, + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getValue", + "decorators": [], "loc": { "start": { "line": 1, @@ -1408,9 +2816,82 @@ } } }, - { - "type": "NumberLiteral", - "value": -1, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "e", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "InvalidInitTypeEnum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1422,9 +2903,94 @@ } } }, - { - "type": "NumberLiteral", - "value": -1, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "e", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], "loc": { "start": { "line": 1, @@ -1435,29 +3001,7 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1480,7 +3024,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -1497,7 +3041,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#InvalidInitTypeEnum#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -1521,7 +3065,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#InvalidInitTypeEnum#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -1542,7 +3086,7 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "e", + "name": "ordinal", "typeAnnotation": { "type": "ETSTypeReference", "part": { @@ -1609,7 +3153,35 @@ } ], "returnType": { - "type": "ETSPrimitiveType", + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -1630,7 +3202,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#InvalidInitTypeEnum#ValuesArray", + "name": "StringValuesArray", "decorators": [], "loc": { "start": { @@ -1647,7 +3219,7 @@ "type": "TSAsExpression", "expression": { "type": "Identifier", - "name": "e", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -1756,10 +3328,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#InvalidInitTypeEnum#StringValuesArray", + "name": "values", "decorators": [], "loc": { "start": { @@ -1772,12 +3344,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "0", + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "values", + "decorators": [], "loc": { "start": { "line": 1, @@ -1789,23 +3368,53 @@ } } }, - { - "type": "StringLiteral", - "value": "-1", - "loc": { - "start": { - "line": 1, - "column": 1 + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "InvalidInitTypeEnum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - } - }, - { - "type": "StringLiteral", - "value": "-1", + }, "loc": { "start": { "line": 1, @@ -1816,46 +3425,39 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -1889,7 +3491,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -1906,7 +3508,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#InvalidInitTypeEnum#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -1930,7 +3532,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#InvalidInitTypeEnum#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -1953,35 +3555,7 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "InvalidInitTypeEnum", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -2023,7 +3597,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "InvalidInitTypeEnum", "decorators": [], "loc": { "start": { @@ -2062,12 +3636,13 @@ "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { "type": "Identifier", - "name": "#InvalidInitTypeEnum#StringValuesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2080,11 +3655,69 @@ } } }, - "property": { - "type": "TSAsExpression", - "expression": { + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { "type": "Identifier", - "name": "ordinal", + "name": "ItemsArray", "decorators": [], "loc": { "start": { @@ -2097,8 +3730,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -2110,6 +3745,8 @@ } } }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -2121,8 +3758,6 @@ } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 1, @@ -2134,6 +3769,7 @@ } } }, + "alternate": null, "loc": { "start": { "line": 1, @@ -2142,250 +3778,122 @@ "end": { "line": 1, "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#InvalidInitTypeEnum#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "InvalidInitTypeEnum", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Red", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "InvalidInitTypeEnum", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Green", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "InvalidInitTypeEnum", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Blue", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 + } } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "InvalidInitTypeEnum", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant in InvalidInitTypeEnum with ordinal value ", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -2396,7 +3904,8 @@ "column": 1 } } - }, + } + "throwMarker": "throws", "loc": { "start": { "line": 1, @@ -2419,7 +3928,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2436,7 +3945,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#InvalidInitTypeEnum#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -2451,7 +3960,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -2460,7 +3969,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#InvalidInitTypeEnum#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -2478,26 +3987,13 @@ "expression": false, "params": [], "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "InvalidInitTypeEnum", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "InvalidInitTypeEnum", + "decorators": [], "loc": { "start": { "line": 1, @@ -2537,9 +4033,67 @@ { "type": "ReturnStatement", "argument": { - "type": "Identifier", - "name": "#InvalidInitTypeEnum#ItemsArray", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -2613,7 +4167,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#InvalidInitTypeEnum#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -2637,7 +4191,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#InvalidInitTypeEnum#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -2702,7 +4256,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "InvalidInitTypeEnum", + "name": "#InvalidInitTypeEnum", "decorators": [], "loc": { "start": { @@ -2764,7 +4318,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#InvalidInitTypeEnum#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -2822,7 +4376,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#InvalidInitTypeEnum#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { diff --git a/ets2panda/test/parser/ets/enum20-expected.txt b/ets2panda/test/parser/ets/enum20-expected.txt index 4456459682914f0c9c75301446038f95124d669a..dc00c68826bb068b2fb3e7bb1f0027a658952ac2 100644 --- a/ets2panda/test/parser/ets/enum20-expected.txt +++ b/ets2panda/test/parser/ets/enum20-expected.txt @@ -958,12 +958,56 @@ "column": 2 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ { "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -976,66 +1020,44 @@ } } }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "Red", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "StringLiteral", - "value": "Green", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "StringLiteral", - "value": "Blue", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "accessibility": "protected", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 }, - { - "type": "StringLiteral", - "value": "White", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "end": { + "line": 1, + "column": 1 } - ], + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "", + "decorators": [], "loc": { "start": { "line": 1, @@ -1047,33 +1069,37 @@ } } }, + "kind": "method", "accessibility": "public", "static": true, - "readonly": false, - "declare": false, "optional": false, "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], "loc": { "start": { "line": 1, @@ -1107,7 +1133,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -1124,7 +1150,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -1137,9 +1163,9 @@ } } }, - "kind": "method", + "kind": "constructor", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -1148,7 +1174,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -1171,35 +1197,7 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1235,75 +1233,18 @@ } } ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, "body": { "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color#NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", "loc": { "start": { "line": 1, @@ -1315,8 +1256,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -1328,6 +1271,23 @@ } } }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -1339,8 +1299,6 @@ } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 1, @@ -1411,10 +1369,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#valueOf", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1427,19 +1385,12 @@ } } }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "#Color#valueOf", - "decorators": [], + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "Red", "loc": { "start": { "line": 1, @@ -1451,99 +1402,76 @@ } } }, - "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": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + { + "type": "StringLiteral", + "value": "Green", + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + }, + { + "type": "StringLiteral", + "value": "Blue", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "White", + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], "loc": { "start": { "line": 1, @@ -1566,40 +1494,1713 @@ } } }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ForUpdateStatement", - "init": { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "init": { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "NumberLiteral", + "value": -100, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "NumberLiteral", + "value": -99, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "0", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "-100", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "-99", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "0", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Green", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Blue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "White", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "BoxedItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Green", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Blue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "White", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getName", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "valueOf", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ForUpdateStatement", + "init": { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "init": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { "line": 1, "column": 1 } @@ -1651,7 +3252,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1757,7 +3358,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -2075,10 +3676,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#ValuesArray", + "name": "getValue", "decorators": [], "loc": { "start": { @@ -2091,12 +3692,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumberLiteral", - "value": 0, + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getValue", + "decorators": [], "loc": { "start": { "line": 1, @@ -2108,23 +3716,82 @@ } } }, - { - "type": "NumberLiteral", - "value": -100, - "loc": { - "start": { - "line": 1, - "column": 1 + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "e", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, - { - "type": "NumberLiteral", - "value": -99, + ], + "returnType": { + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -2136,9 +3803,94 @@ } } }, - { - "type": "NumberLiteral", - "value": 0, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "e", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], "loc": { "start": { "line": 1, @@ -2149,29 +3901,7 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -2194,7 +3924,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2211,7 +3941,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -2235,7 +3965,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -2256,7 +3986,7 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "e", + "name": "ordinal", "typeAnnotation": { "type": "ETSTypeReference", "part": { @@ -2323,7 +4053,35 @@ } ], "returnType": { - "type": "ETSPrimitiveType", + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -2344,7 +4102,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#ValuesArray", + "name": "StringValuesArray", "decorators": [], "loc": { "start": { @@ -2361,7 +4119,7 @@ "type": "TSAsExpression", "expression": { "type": "Identifier", - "name": "e", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2470,10 +4228,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#StringValuesArray", + "name": "values", "decorators": [], "loc": { "start": { @@ -2486,26 +4244,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "0", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "StringLiteral", - "value": "-100", + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "values", + "decorators": [], "loc": { "start": { "line": 1, @@ -2517,23 +4268,53 @@ } } }, - { - "type": "StringLiteral", - "value": "-99", - "loc": { - "start": { - "line": 1, - "column": 1 + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - } - }, - { - "type": "StringLiteral", - "value": "0", + }, "loc": { "start": { "line": 1, @@ -2544,46 +4325,39 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -2617,7 +4391,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2634,7 +4408,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -2658,7 +4432,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -2681,35 +4455,7 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -2751,7 +4497,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "Color", "decorators": [], "loc": { "start": { @@ -2790,12 +4536,13 @@ "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { "type": "Identifier", - "name": "#Color#StringValuesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2807,12 +4554,70 @@ "column": 1 } } - }, - "property": { - "type": "TSAsExpression", - "expression": { + }, + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { "type": "Identifier", - "name": "ordinal", + "name": "ItemsArray", "decorators": [], "loc": { "start": { @@ -2825,8 +4630,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -2838,6 +4645,8 @@ } } }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -2849,8 +4658,6 @@ } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 1, @@ -2862,6 +4669,7 @@ } } }, + "alternate": null, "loc": { "start": { "line": 1, @@ -2870,295 +4678,122 @@ "end": { "line": 1, "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#Color#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Red", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Green", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Blue", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "White", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 + } } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant in Color with ordinal value ", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -3169,7 +4804,8 @@ "column": 1 } } - }, + } + "throwMarker": "throws", "loc": { "start": { "line": 1, @@ -3192,7 +4828,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -3209,7 +4845,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -3224,7 +4860,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -3233,7 +4869,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -3251,26 +4887,13 @@ "expression": false, "params": [], "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], "loc": { "start": { "line": 1, @@ -3310,9 +4933,67 @@ { "type": "ReturnStatement", "argument": { - "type": "Identifier", - "name": "#Color#ItemsArray", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -3386,7 +5067,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -3410,7 +5091,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -3475,7 +5156,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Color", + "name": "#Color", "decorators": [], "loc": { "start": { @@ -3537,7 +5218,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -3595,7 +5276,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { diff --git a/ets2panda/test/parser/ets/enum21-expected.txt b/ets2panda/test/parser/ets/enum21-expected.txt index 28b2f3053d617b1d91749cf60cae116ae0255a75..3f3fdb8ff0196a32d6c82837f17e2d65c813bcfd 100644 --- a/ets2panda/test/parser/ets/enum21-expected.txt +++ b/ets2panda/test/parser/ets/enum21-expected.txt @@ -230,12 +230,56 @@ "column": 1 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "#ArkColor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ { "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#ArkColor#NamesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -248,38 +292,44 @@ } } }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "Gray", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "accessibility": "protected", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 }, - { - "type": "StringLiteral", - "value": "Grey", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "end": { + "line": 1, + "column": 1 } - ], + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "", + "decorators": [], "loc": { "start": { "line": 1, @@ -291,33 +341,37 @@ } } }, + "kind": "method", "accessibility": "public", "static": true, - "readonly": false, - "declare": false, "optional": false, "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], "loc": { "start": { "line": 1, @@ -351,7 +405,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -368,7 +422,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#ArkColor#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -381,9 +435,9 @@ } } }, - "kind": "method", + "kind": "constructor", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -392,7 +446,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#ArkColor#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -415,35 +469,7 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "ArkColor", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -479,75 +505,18 @@ } } ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, "body": { "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#ArkColor#NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", "loc": { "start": { "line": 1, @@ -559,9 +528,11 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { "start": { "line": 1, "column": 1 @@ -572,6 +543,23 @@ } } }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -583,8 +571,6 @@ } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 1, @@ -655,10 +641,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#ArkColor#valueOf", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -671,19 +657,12 @@ } } }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "#ArkColor#valueOf", - "decorators": [], + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "Gray", "loc": { "start": { "line": 1, @@ -695,99 +674,48 @@ } } }, - "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": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + { + "type": "StringLiteral", + "value": "Grey", + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "ArkColor", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], "loc": { "start": { "line": 1, @@ -810,93 +738,1261 @@ } } }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ForUpdateStatement", - "init": { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "init": { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "test": { - "type": "BinaryExpression", - "operator": "<", - "left": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#ArkColor#NamesArray", - "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "#ff808080", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "#ff808080", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ArkColor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Gray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ArkColor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Grey", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "ArkColor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "BoxedItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#ArkColor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ArkColor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Gray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#ArkColor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ArkColor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Grey", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#ArkColor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getName", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "ArkColor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "valueOf", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "ArkColor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ForUpdateStatement", + "init": { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "init": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], "loc": { "start": { "line": 1, @@ -1001,7 +2097,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#ArkColor#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1091,17 +2187,140 @@ } } }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "alternate": null, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant ArkColor.", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "right": { + "type": "Identifier", + "name": "name", + "decorators": [], "loc": { "start": { "line": 1, @@ -1123,6 +2342,146 @@ "column": 1 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + "throwMarker": "throws", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "toString", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "ArkColor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, "loc": { "start": { @@ -1135,7 +2494,6 @@ } } }, - "alternate": null, "loc": { "start": { "line": 1, @@ -1147,6 +2505,38 @@ } } }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], "loc": { "start": { "line": 1, @@ -1158,40 +2548,39 @@ } } }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], "loc": { "start": { "line": 1, @@ -1203,39 +2592,25 @@ } } }, - "arguments": [ - { - "type": "BinaryExpression", - "operator": "+", - "left": { - "type": "StringLiteral", - "value": "No enum constant ArkColor.", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "right": { - "type": "Identifier", - "name": "name", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1246,8 +2621,20 @@ "column": 1 } } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - ], + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -1281,8 +2668,7 @@ "column": 1 } } - } - "throwMarker": "throws", + }, "loc": { "start": { "line": 1, @@ -1319,10 +2705,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#ArkColor#StringValuesArray", + "name": "values", "decorators": [], "loc": { "start": { @@ -1335,12 +2721,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "#ff808080", + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "values", + "decorators": [], "loc": { "start": { "line": 1, @@ -1352,9 +2745,53 @@ } } }, - { - "type": "StringLiteral", - "value": "#ff808080", + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "ArkColor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -1365,46 +2802,39 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -1438,7 +2868,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -1455,7 +2885,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#ArkColor#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -1476,61 +2906,33 @@ "value": { "type": "FunctionExpression", "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "#ArkColor#toString", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "ArkColor", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "fromInt", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1572,7 +2974,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "ArkColor", "decorators": [], "loc": { "start": { @@ -1611,12 +3013,13 @@ "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { "type": "Identifier", - "name": "#ArkColor#StringValuesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -1629,11 +3032,11 @@ } } }, - "property": { - "type": "TSAsExpression", - "expression": { + "right": { + "type": "MemberExpression", + "object": { "type": "Identifier", - "name": "ordinal", + "name": "ItemsArray", "decorators": [], "loc": { "start": { @@ -1646,8 +3049,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], "loc": { "start": { "line": 1, @@ -1659,6 +3064,66 @@ } } }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -1670,8 +3135,6 @@ } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 1, @@ -1683,6 +3146,7 @@ } } }, + "alternate": null, "loc": { "start": { "line": 1, @@ -1691,205 +3155,122 @@ "end": { "line": 1, "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#ArkColor#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "ArkColor", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Gray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "ArkColor", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Grey", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 + } } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "ArkColor", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant in ArkColor with ordinal value ", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -1900,7 +3281,8 @@ "column": 1 } } - }, + } + "throwMarker": "throws", "loc": { "start": { "line": 1, @@ -1923,7 +3305,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -1940,7 +3322,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#ArkColor#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -1955,7 +3337,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -1964,7 +3346,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#ArkColor#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -1982,26 +3364,13 @@ "expression": false, "params": [], "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "ArkColor", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "ArkColor", + "decorators": [], "loc": { "start": { "line": 1, @@ -2041,9 +3410,67 @@ { "type": "ReturnStatement", "argument": { - "type": "Identifier", - "name": "#ArkColor#ItemsArray", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -2117,7 +3544,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#ArkColor#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -2141,7 +3568,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#ArkColor#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -2206,7 +3633,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "ArkColor", + "name": "#ArkColor", "decorators": [], "loc": { "start": { @@ -2268,7 +3695,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#ArkColor#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -2326,7 +3753,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#ArkColor#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { diff --git a/ets2panda/test/parser/ets/enum4-expected.txt b/ets2panda/test/parser/ets/enum4-expected.txt index af8bd39f5ecaf2ed180123e00643b6cff4cb5455..76edaa102dd51502471d31de6644f51ae3c1e60f 100644 --- a/ets2panda/test/parser/ets/enum4-expected.txt +++ b/ets2panda/test/parser/ets/enum4-expected.txt @@ -188,12 +188,750 @@ "column": 1 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "#TrailingCommaEnum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "Red", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "0", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, { "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#TrailingCommaEnum#NamesArray", + "name": "ItemsArray", "decorators": [], "loc": { "start": { @@ -210,8 +948,271 @@ "type": "ArrayExpression", "elements": [ { - "type": "StringLiteral", - "value": "Red", + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "TrailingCommaEnum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "TrailingCommaEnum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "BoxedItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#TrailingCommaEnum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "TrailingCommaEnum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], "loc": { "start": { "line": 1, @@ -235,7 +1236,7 @@ } } }, - "accessibility": "public", + "accessibility": "protected", "static": true, "readonly": false, "declare": false, @@ -249,7 +1250,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "#TrailingCommaEnum", "decorators": [], "loc": { "start": { @@ -312,7 +1313,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#TrailingCommaEnum#getName", + "name": "getName", "decorators": [], "loc": { "start": { @@ -336,7 +1337,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#TrailingCommaEnum#getName", + "name": "getName", "decorators": [], "loc": { "start": { @@ -473,7 +1474,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#TrailingCommaEnum#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -602,7 +1603,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#TrailingCommaEnum#valueOf", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -626,7 +1627,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#TrailingCommaEnum#valueOf", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -839,7 +1840,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#TrailingCommaEnum#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -945,7 +1946,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#TrailingCommaEnum#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1191,7 +2192,270 @@ } } } - ], + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + "throwMarker": "throws", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getValue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getValue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "e", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "TrailingCommaEnum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "e", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -1225,99 +2489,7 @@ "column": 1 } } - } - "throwMarker": "throws", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#TrailingCommaEnum#ValuesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1340,7 +2512,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -1357,7 +2529,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#TrailingCommaEnum#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -1381,7 +2553,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#TrailingCommaEnum#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -1402,7 +2574,7 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "e", + "name": "ordinal", "typeAnnotation": { "type": "ETSTypeReference", "part": { @@ -1469,7 +2641,35 @@ } ], "returnType": { - "type": "ETSPrimitiveType", + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -1490,7 +2690,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#TrailingCommaEnum#ValuesArray", + "name": "StringValuesArray", "decorators": [], "loc": { "start": { @@ -1507,7 +2707,7 @@ "type": "TSAsExpression", "expression": { "type": "Identifier", - "name": "e", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -1616,10 +2816,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#TrailingCommaEnum#StringValuesArray", + "name": "values", "decorators": [], "loc": { "start": { @@ -1632,12 +2832,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "0", + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "values", + "decorators": [], "loc": { "start": { "line": 1, @@ -1648,46 +2855,97 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "TrailingCommaEnum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, "column": 1 }, - "end": { - "line": 1, - "column": 1 + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -1721,7 +2979,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -1738,7 +2996,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#TrailingCommaEnum#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -1762,7 +3020,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#TrailingCommaEnum#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -1785,35 +3043,7 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "TrailingCommaEnum", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1855,7 +3085,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "TrailingCommaEnum", "decorators": [], "loc": { "start": { @@ -1894,12 +3124,13 @@ "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { "type": "Identifier", - "name": "#TrailingCommaEnum#StringValuesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -1912,9 +3143,82 @@ } } }, - "property": { - "type": "TSAsExpression", - "expression": { + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { "type": "Identifier", "name": "ordinal", "decorators": [], @@ -1929,8 +3233,120 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "alternate": null, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant in TrailingCommaEnum with ordinal value ", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -1941,20 +3357,8 @@ "column": 1 } } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } } - }, - "computed": true, - "optional": false, + ], "loc": { "start": { "line": 1, @@ -1988,157 +3392,8 @@ "column": 1 } } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#TrailingCommaEnum#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "TrailingCommaEnum", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Red", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "TrailingCommaEnum", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "throwMarker": "throws", "loc": { "start": { "line": 1, @@ -2161,7 +3416,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2178,7 +3433,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#TrailingCommaEnum#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -2193,7 +3448,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -2202,7 +3457,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#TrailingCommaEnum#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -2220,26 +3475,13 @@ "expression": false, "params": [], "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "TrailingCommaEnum", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "TrailingCommaEnum", + "decorators": [], "loc": { "start": { "line": 1, @@ -2279,9 +3521,67 @@ { "type": "ReturnStatement", "argument": { - "type": "Identifier", - "name": "#TrailingCommaEnum#ItemsArray", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -2355,7 +3655,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#TrailingCommaEnum#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -2379,7 +3679,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#TrailingCommaEnum#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -2444,7 +3744,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "TrailingCommaEnum", + "name": "#TrailingCommaEnum", "decorators": [], "loc": { "start": { @@ -2506,7 +3806,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#TrailingCommaEnum#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -2564,7 +3864,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#TrailingCommaEnum#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { diff --git a/ets2panda/test/parser/ets/enum6-expected.txt b/ets2panda/test/parser/ets/enum6-expected.txt index e8cdaffc9445d6dfae267c75af0d14b20e1af0fa..f73a7c0548d5d41b764fee3d195166d626ddfa6d 100644 --- a/ets2panda/test/parser/ets/enum6-expected.txt +++ b/ets2panda/test/parser/ets/enum6-expected.txt @@ -684,12 +684,56 @@ "column": 2 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ { "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -702,52 +746,44 @@ } } }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "Red", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "StringLiteral", - "value": "Green", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "accessibility": "protected", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 }, - { - "type": "StringLiteral", - "value": "Blue", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "end": { + "line": 1, + "column": 1 } - ], + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "", + "decorators": [], "loc": { "start": { "line": 1, @@ -759,33 +795,37 @@ } } }, + "kind": "method", "accessibility": "public", "static": true, - "readonly": false, - "declare": false, "optional": false, "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], "loc": { "start": { "line": 1, @@ -819,7 +859,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -836,7 +876,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -849,9 +889,9 @@ } } }, - "kind": "method", + "kind": "constructor", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -860,7 +900,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -883,12 +923,68 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { "type": "Identifier", - "name": "Color", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -901,6 +997,23 @@ } } }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -923,147 +1036,6 @@ } } }, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color#NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, "loc": { "start": { "line": 1, @@ -1123,10 +1095,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#valueOf", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1139,19 +1111,12 @@ } } }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "#Color#valueOf", - "decorators": [], + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "Red", "loc": { "start": { "line": 1, @@ -1163,101 +1128,1537 @@ } } }, - "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": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + { + "type": "StringLiteral", + "value": "Green", + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { + }, + { + "type": "StringLiteral", + "value": "Blue", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "NumberLiteral", + "value": 2, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "0", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "1", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "2", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Green", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Blue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "BoxedItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Green", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Blue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getName", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "valueOf", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { "line": 1, "column": 1 }, @@ -1363,7 +2764,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1469,7 +2870,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1787,10 +3188,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#ValuesArray", + "name": "getValue", "decorators": [], "loc": { "start": { @@ -1803,12 +3204,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumberLiteral", - "value": 0, + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getValue", + "decorators": [], "loc": { "start": { "line": 1, @@ -1820,9 +3228,82 @@ } } }, - { - "type": "NumberLiteral", - "value": 1, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "e", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1834,9 +3315,94 @@ } } }, - { - "type": "NumberLiteral", - "value": 2, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "e", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], "loc": { "start": { "line": 1, @@ -1847,29 +3413,7 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1892,7 +3436,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -1909,7 +3453,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -1933,7 +3477,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -1954,7 +3498,7 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "e", + "name": "ordinal", "typeAnnotation": { "type": "ETSTypeReference", "part": { @@ -2021,7 +3565,35 @@ } ], "returnType": { - "type": "ETSPrimitiveType", + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -2042,7 +3614,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#ValuesArray", + "name": "StringValuesArray", "decorators": [], "loc": { "start": { @@ -2059,7 +3631,7 @@ "type": "TSAsExpression", "expression": { "type": "Identifier", - "name": "e", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2168,10 +3740,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#StringValuesArray", + "name": "values", "decorators": [], "loc": { "start": { @@ -2184,12 +3756,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "0", + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "values", + "decorators": [], "loc": { "start": { "line": 1, @@ -2201,23 +3780,53 @@ } } }, - { - "type": "StringLiteral", - "value": "1", - "loc": { - "start": { - "line": 1, - "column": 1 + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - } - }, - { - "type": "StringLiteral", - "value": "2", + }, "loc": { "start": { "line": 1, @@ -2228,46 +3837,39 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -2301,7 +3903,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2318,7 +3920,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -2342,7 +3944,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -2365,35 +3967,7 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -2435,7 +4009,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "Color", "decorators": [], "loc": { "start": { @@ -2474,12 +4048,13 @@ "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { "type": "Identifier", - "name": "#Color#StringValuesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2492,11 +4067,69 @@ } } }, - "property": { - "type": "TSAsExpression", - "expression": { + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { "type": "Identifier", - "name": "ordinal", + "name": "ItemsArray", "decorators": [], "loc": { "start": { @@ -2509,8 +4142,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -2522,6 +4157,8 @@ } } }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -2533,8 +4170,6 @@ } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 1, @@ -2546,6 +4181,7 @@ } } }, + "alternate": null, "loc": { "start": { "line": 1, @@ -2554,250 +4190,122 @@ "end": { "line": 1, "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#Color#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Red", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Green", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Blue", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 + } } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant in Color with ordinal value ", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -2808,7 +4316,8 @@ "column": 1 } } - }, + } + "throwMarker": "throws", "loc": { "start": { "line": 1, @@ -2831,7 +4340,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2848,7 +4357,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -2863,7 +4372,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -2872,7 +4381,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -2890,26 +4399,13 @@ "expression": false, "params": [], "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], "loc": { "start": { "line": 1, @@ -2949,9 +4445,67 @@ { "type": "ReturnStatement", "argument": { - "type": "Identifier", - "name": "#Color#ItemsArray", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -3025,7 +4579,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -3049,7 +4603,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -3114,7 +4668,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Color", + "name": "#Color", "decorators": [], "loc": { "start": { @@ -3176,7 +4730,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -3234,7 +4788,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { diff --git a/ets2panda/test/parser/ets/enum7-expected.txt b/ets2panda/test/parser/ets/enum7-expected.txt index ed1b85e24f74a487ce1c5227aade7c6400bc712f..2dbce51fc442a4936f5a064b445fa85da6188db1 100644 --- a/ets2panda/test/parser/ets/enum7-expected.txt +++ b/ets2panda/test/parser/ets/enum7-expected.txt @@ -487,12 +487,56 @@ "column": 2 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ { "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -505,24 +549,44 @@ } } }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "Red", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "accessibility": "protected", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } - ], + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "", + "decorators": [], "loc": { "start": { "line": 1, @@ -534,33 +598,37 @@ } } }, + "kind": "method", "accessibility": "public", "static": true, - "readonly": false, - "declare": false, "optional": false, "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], "loc": { "start": { "line": 1, @@ -594,7 +662,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -611,7 +679,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -624,9 +692,9 @@ } } }, - "kind": "method", + "kind": "constructor", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -635,7 +703,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -658,35 +726,7 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -722,75 +762,18 @@ } } ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, "body": { "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color#NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", "loc": { "start": { "line": 1, @@ -802,8 +785,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -815,6 +800,8 @@ } } }, + "computed": false, + "optional": false, "loc": { "start": { "line": 1, @@ -826,13 +813,26 @@ } } }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, "end": { "line": 1, "column": 1 @@ -898,10 +898,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#valueOf", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -914,19 +914,12 @@ } } }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "#Color#valueOf", - "decorators": [], + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "Red", "loc": { "start": { "line": 1, @@ -937,69 +930,35 @@ "column": 1 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "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": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], "loc": { "start": { "line": 1, @@ -1010,38 +969,76 @@ "column": 1 } } - } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + }, + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "NumberLiteral", + "value": 0, "loc": { "start": { "line": 1, @@ -1052,35 +1049,1426 @@ "column": 1 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ForUpdateStatement", - "init": { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "init": { - "type": "NumberLiteral", - "value": 0, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "0", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "BoxedItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getName", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "valueOf", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ForUpdateStatement", + "init": { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "init": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "update": { + "type": "UpdateExpression", + "operator": "++", + "prefix": true, + "argument": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "==", + "left": { + "type": "Identifier", + "name": "name", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "alternate": null, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant Color.", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "name", + "decorators": [], "loc": { "start": { "line": 1, @@ -1103,8 +2491,858 @@ } } } - ], - "kind": "let", + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + "throwMarker": "throws", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getValue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getValue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "e", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "e", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "toString", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "values", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "fromInt", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "fromInt", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1116,12 +3354,82 @@ } } }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "IfStatement", "test": { "type": "BinaryExpression", "operator": "<", "left": { "type": "Identifier", - "name": "i", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -1138,7 +3446,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "ItemsArray", "decorators": [], "loc": { "start": { @@ -1157,205 +3465,62 @@ "decorators": [], "loc": { "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "update": { - "type": "UpdateExpression", - "operator": "++", - "prefix": true, - "argument": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "body": { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "==", - "left": { - "type": "Identifier", - "name": "name", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color#NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "consequent": { - "type": "ReturnStatement", - "argument": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -1367,6 +3532,8 @@ } } }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -1378,7 +3545,6 @@ } } }, - "alternate": null, "loc": { "start": { "line": 1, @@ -1390,6 +3556,7 @@ } } }, + "alternate": null, "loc": { "start": { "line": 1, @@ -1452,7 +3619,7 @@ "operator": "+", "left": { "type": "StringLiteral", - "value": "No enum constant Color.", + "value": "No enum constant in Color with ordinal value ", "loc": { "start": { "line": 1, @@ -1466,7 +3633,7 @@ }, "right": { "type": "Identifier", - "name": "name", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -1478,7 +3645,216 @@ "column": 1 } } - }, + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + "throwMarker": "throws", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "unbox", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "unbox", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -1489,8 +3865,22 @@ "column": 1 } } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - ], + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -1524,99 +3914,7 @@ "column": 1 } } - } - "throwMarker": "throws", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#Color#ValuesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1639,7 +3937,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -1656,7 +3954,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#getValue", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -1680,7 +3978,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#getValue", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -1701,14 +3999,186 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "e", + "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "BoxedItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { "type": "Identifier", - "name": "Color", + "name": "BoxedItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -1721,6 +4191,8 @@ } } }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -1743,7 +4215,7 @@ } } }, - "decorators": [], + "alternate": null, "loc": { "start": { "line": 1, @@ -1755,72 +4227,29 @@ } } }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ { - "type": "ReturnStatement", + "type": "ThrowStatement", "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color#ValuesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "e", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + }, "loc": { "start": { "line": 1, @@ -1843,8 +4272,51 @@ } } }, - "computed": true, - "optional": false, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant in Color with ordinal value ", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], "loc": { "start": { "line": 1, @@ -1878,18 +4350,112 @@ "column": 1 } } + } + "throwMarker": "throws", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "#Color2", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "accessibility": "protected", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1901,7 +4467,7 @@ } } }, - "overloads": [], + "definite": false, "decorators": [], "loc": { "start": { @@ -1915,10 +4481,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#StringValuesArray", + "name": "", "decorators": [], "loc": { "start": { @@ -1931,12 +4497,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "0", + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], "loc": { "start": { "line": 1, @@ -1947,46 +4520,14 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], "loc": { "start": { "line": 1, @@ -2020,7 +4561,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2037,7 +4578,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#toString", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -2050,9 +4591,9 @@ } } }, - "kind": "method", + "kind": "constructor", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -2061,7 +4602,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#toString", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -2084,35 +4625,7 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -2148,75 +4661,18 @@ } } ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, "body": { "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color#StringValuesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", "loc": { "start": { "line": 1, @@ -2228,8 +4684,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -2241,6 +4699,23 @@ } } }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -2252,8 +4727,6 @@ } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 1, @@ -2327,7 +4800,7 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#ItemsArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -2344,39 +4817,8 @@ "type": "ArrayExpression", "elements": [ { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Red", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, + "type": "StringLiteral", + "value": "Red", "loc": { "start": { "line": 1, @@ -2400,7 +4842,7 @@ } } }, - "accessibility": "public", + "accessibility": "protected", "static": true, "readonly": false, "declare": false, @@ -2414,7 +4856,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Color", + "name": "String", "decorators": [], "loc": { "start": { @@ -2474,10 +4916,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#values", + "name": "ValuesArray", "decorators": [], "loc": { "start": { @@ -2490,120 +4932,12 @@ } } }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "#Color#values", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "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": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "#Color#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], + "type": "ArrayExpression", + "elements": [ + { + "type": "NumberLiteral", + "value": 0, "loc": { "start": { "line": 1, @@ -2614,7 +4948,29 @@ "column": 1 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -2637,7 +4993,7 @@ } } }, - "overloads": [], + "definite": false, "decorators": [], "loc": { "start": { @@ -2651,10 +5007,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#fromInt", + "name": "StringValuesArray", "decorators": [], "loc": { "start": { @@ -2667,19 +5023,12 @@ } } }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "#Color#fromInt", - "decorators": [], + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "0", "loc": { "start": { "line": 1, @@ -2690,72 +5039,35 @@ "column": 1 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], "loc": { "start": { "line": 1, @@ -2769,277 +5081,104 @@ }, "loc": { "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "<", - "left": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "length", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "consequent": { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "alternate": null, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ThrowStatement", - "argument": { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Exception", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "arguments": [ - { - "type": "BinaryExpression", - "operator": "+", - "left": { - "type": "StringLiteral", - "value": "No enum constant in Color with ordinal value ", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "right": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color2", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, "loc": { "start": { "line": 1, @@ -3051,7 +5190,56 @@ } } } - "throwMarker": "throws", + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color2", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -3074,7 +5262,7 @@ } } }, - "overloads": [], + "definite": false, "decorators": [], "loc": { "start": { @@ -3091,7 +5279,7 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color2#NamesArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -3108,8 +5296,121 @@ "type": "ArrayExpression", "elements": [ { - "type": "StringLiteral", - "value": "Red", + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color2", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color2", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], "loc": { "start": { "line": 1, @@ -3133,7 +5434,7 @@ } } }, - "accessibility": "public", + "accessibility": "protected", "static": true, "readonly": false, "declare": false, @@ -3147,7 +5448,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "#Color2", "decorators": [], "loc": { "start": { @@ -3210,7 +5511,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color2#getName", + "name": "getName", "decorators": [], "loc": { "start": { @@ -3234,7 +5535,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color2#getName", + "name": "getName", "decorators": [], "loc": { "start": { @@ -3371,7 +5672,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color2#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -3500,7 +5801,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color2#valueOf", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -3524,7 +5825,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color2#valueOf", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -3737,7 +6038,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color2#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -3843,7 +6144,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color2#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -4089,7 +6390,270 @@ } } } - ], + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + "throwMarker": "throws", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getValue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getValue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "e", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color2", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "e", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -4123,99 +6687,7 @@ "column": 1 } } - } - "throwMarker": "throws", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#Color2#ValuesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -4238,7 +6710,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -4255,7 +6727,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color2#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -4279,7 +6751,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color2#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -4300,7 +6772,7 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "e", + "name": "ordinal", "typeAnnotation": { "type": "ETSTypeReference", "part": { @@ -4367,7 +6839,35 @@ } ], "returnType": { - "type": "ETSPrimitiveType", + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -4388,7 +6888,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color2#ValuesArray", + "name": "StringValuesArray", "decorators": [], "loc": { "start": { @@ -4405,7 +6905,7 @@ "type": "TSAsExpression", "expression": { "type": "Identifier", - "name": "e", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -4514,10 +7014,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color2#StringValuesArray", + "name": "values", "decorators": [], "loc": { "start": { @@ -4530,12 +7030,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "0", + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "values", + "decorators": [], "loc": { "start": { "line": 1, @@ -4546,46 +7053,97 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color2", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, "column": 1 }, - "end": { - "line": 1, - "column": 1 + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -4619,7 +7177,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -4636,7 +7194,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color2#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -4660,7 +7218,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color2#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -4683,35 +7241,7 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color2", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -4753,7 +7283,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "Color2", "decorators": [], "loc": { "start": { @@ -4792,12 +7322,13 @@ "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { "type": "Identifier", - "name": "#Color2#StringValuesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -4810,9 +7341,82 @@ } } }, - "property": { - "type": "TSAsExpression", - "expression": { + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { "type": "Identifier", "name": "ordinal", "decorators": [], @@ -4827,8 +7431,120 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "alternate": null, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant in Color2 with ordinal value ", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -4839,20 +7555,8 @@ "column": 1 } } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } } - }, - "computed": true, - "optional": false, + ], "loc": { "start": { "line": 1, @@ -4886,157 +7590,8 @@ "column": 1 } } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#Color2#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color2", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Red", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color2", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "throwMarker": "throws", "loc": { "start": { "line": 1, @@ -5059,7 +7614,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -5076,7 +7631,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color2#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -5091,7 +7646,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -5100,7 +7655,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color2#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -5118,26 +7673,13 @@ "expression": false, "params": [], "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color2", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color2", + "decorators": [], "loc": { "start": { "line": 1, @@ -5177,9 +7719,67 @@ { "type": "ReturnStatement", "argument": { - "type": "Identifier", - "name": "#Color2#ItemsArray", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -5253,7 +7853,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color2#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -5277,7 +7877,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color2#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -5342,7 +7942,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Color2", + "name": "#Color2", "decorators": [], "loc": { "start": { @@ -5404,7 +8004,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color2#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -5462,7 +8062,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color2#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { diff --git a/ets2panda/test/parser/ets/enum8-expected.txt b/ets2panda/test/parser/ets/enum8-expected.txt index fc5676e326bf11dc966c8b03ae3e9d7b9abd00f3..73ebeb02de0c0e3c2ac80ed4ba869a4a91d456ba 100644 --- a/ets2panda/test/parser/ets/enum8-expected.txt +++ b/ets2panda/test/parser/ets/enum8-expected.txt @@ -499,12 +499,56 @@ "column": 2 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ { "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -517,24 +561,44 @@ } } }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "Red", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "accessibility": "protected", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } - ], + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "", + "decorators": [], "loc": { "start": { "line": 1, @@ -546,33 +610,37 @@ } } }, + "kind": "method", "accessibility": "public", "static": true, - "readonly": false, - "declare": false, "optional": false, "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], "loc": { "start": { "line": 1, @@ -606,7 +674,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -623,7 +691,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -636,9 +704,9 @@ } } }, - "kind": "method", + "kind": "constructor", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -647,7 +715,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -670,35 +738,7 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -734,75 +774,18 @@ } } ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, "body": { "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color#NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", "loc": { "start": { "line": 1, @@ -814,8 +797,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -827,6 +812,8 @@ } } }, + "computed": false, + "optional": false, "loc": { "start": { "line": 1, @@ -838,13 +825,26 @@ } } }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, "end": { "line": 1, "column": 1 @@ -910,10 +910,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#valueOf", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -926,19 +926,12 @@ } } }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "#Color#valueOf", - "decorators": [], + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "Red", "loc": { "start": { "line": 1, @@ -949,69 +942,35 @@ "column": 1 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "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": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], "loc": { "start": { "line": 1, @@ -1022,38 +981,76 @@ "column": 1 } } - } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + }, + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "NumberLiteral", + "value": 0, "loc": { "start": { "line": 1, @@ -1064,35 +1061,1426 @@ "column": 1 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ForUpdateStatement", - "init": { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "init": { - "type": "NumberLiteral", - "value": 0, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "0", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "BoxedItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getName", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "valueOf", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ForUpdateStatement", + "init": { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "init": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "update": { + "type": "UpdateExpression", + "operator": "++", + "prefix": true, + "argument": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "==", + "left": { + "type": "Identifier", + "name": "name", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "alternate": null, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant Color.", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "name", + "decorators": [], "loc": { "start": { "line": 1, @@ -1115,8 +2503,858 @@ } } } - ], - "kind": "let", + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + "throwMarker": "throws", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getValue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getValue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "e", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "e", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "toString", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "values", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "fromInt", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "fromInt", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1128,12 +3366,82 @@ } } }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "IfStatement", "test": { "type": "BinaryExpression", "operator": "<", "left": { "type": "Identifier", - "name": "i", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -1150,7 +3458,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "ItemsArray", "decorators": [], "loc": { "start": { @@ -1169,205 +3477,62 @@ "decorators": [], "loc": { "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "update": { - "type": "UpdateExpression", - "operator": "++", - "prefix": true, - "argument": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "body": { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "==", - "left": { - "type": "Identifier", - "name": "name", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color#NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "consequent": { - "type": "ReturnStatement", - "argument": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -1379,6 +3544,8 @@ } } }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -1390,7 +3557,6 @@ } } }, - "alternate": null, "loc": { "start": { "line": 1, @@ -1402,6 +3568,7 @@ } } }, + "alternate": null, "loc": { "start": { "line": 1, @@ -1464,7 +3631,7 @@ "operator": "+", "left": { "type": "StringLiteral", - "value": "No enum constant Color.", + "value": "No enum constant in Color with ordinal value ", "loc": { "start": { "line": 1, @@ -1478,7 +3645,7 @@ }, "right": { "type": "Identifier", - "name": "name", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -1490,7 +3657,216 @@ "column": 1 } } - }, + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + "throwMarker": "throws", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "unbox", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "unbox", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -1501,8 +3877,22 @@ "column": 1 } } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - ], + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -1536,99 +3926,7 @@ "column": 1 } } - } - "throwMarker": "throws", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#Color#ValuesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1651,7 +3949,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -1668,7 +3966,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#getValue", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -1692,7 +3990,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#getValue", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -1713,14 +4011,186 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "e", + "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "BoxedItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { "type": "Identifier", - "name": "Color", + "name": "BoxedItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -1733,6 +4203,8 @@ } } }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -1755,7 +4227,7 @@ } } }, - "decorators": [], + "alternate": null, "loc": { "start": { "line": 1, @@ -1767,72 +4239,29 @@ } } }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ { - "type": "ReturnStatement", + "type": "ThrowStatement", "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color#ValuesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "e", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + }, "loc": { "start": { "line": 1, @@ -1855,8 +4284,51 @@ } } }, - "computed": true, - "optional": false, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant in Color with ordinal value ", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], "loc": { "start": { "line": 1, @@ -1890,18 +4362,112 @@ "column": 1 } } + } + "throwMarker": "throws", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "#Color2", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "accessibility": "protected", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1913,7 +4479,7 @@ } } }, - "overloads": [], + "definite": false, "decorators": [], "loc": { "start": { @@ -1927,10 +4493,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#StringValuesArray", + "name": "", "decorators": [], "loc": { "start": { @@ -1943,12 +4509,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "0", + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], "loc": { "start": { "line": 1, @@ -1959,46 +4532,14 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], "loc": { "start": { "line": 1, @@ -2032,7 +4573,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2049,7 +4590,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#toString", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -2062,9 +4603,9 @@ } } }, - "kind": "method", + "kind": "constructor", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -2073,7 +4614,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#toString", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -2096,35 +4637,7 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -2160,75 +4673,18 @@ } } ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, "body": { "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color#StringValuesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", "loc": { "start": { "line": 1, @@ -2240,8 +4696,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -2253,6 +4711,23 @@ } } }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -2264,8 +4739,6 @@ } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 1, @@ -2339,7 +4812,7 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#ItemsArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -2356,39 +4829,8 @@ "type": "ArrayExpression", "elements": [ { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Red", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, + "type": "StringLiteral", + "value": "Red", "loc": { "start": { "line": 1, @@ -2412,7 +4854,7 @@ } } }, - "accessibility": "public", + "accessibility": "protected", "static": true, "readonly": false, "declare": false, @@ -2426,7 +4868,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Color", + "name": "String", "decorators": [], "loc": { "start": { @@ -2486,10 +4928,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#values", + "name": "ValuesArray", "decorators": [], "loc": { "start": { @@ -2502,120 +4944,12 @@ } } }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "#Color#values", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "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": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "#Color#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], + "type": "ArrayExpression", + "elements": [ + { + "type": "NumberLiteral", + "value": 0, "loc": { "start": { "line": 1, @@ -2626,7 +4960,29 @@ "column": 1 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -2649,7 +5005,7 @@ } } }, - "overloads": [], + "definite": false, "decorators": [], "loc": { "start": { @@ -2663,10 +5019,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#fromInt", + "name": "StringValuesArray", "decorators": [], "loc": { "start": { @@ -2679,19 +5035,12 @@ } } }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "#Color#fromInt", - "decorators": [], + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "0", "loc": { "start": { "line": 1, @@ -2702,72 +5051,35 @@ "column": 1 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], "loc": { "start": { "line": 1, @@ -2781,277 +5093,104 @@ }, "loc": { "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "<", - "left": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "length", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "consequent": { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "alternate": null, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ThrowStatement", - "argument": { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Exception", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "arguments": [ - { - "type": "BinaryExpression", - "operator": "+", - "left": { - "type": "StringLiteral", - "value": "No enum constant in Color with ordinal value ", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "right": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color2", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, "loc": { "start": { "line": 1, @@ -3063,7 +5202,56 @@ } } } - "throwMarker": "throws", + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color2", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -3086,7 +5274,7 @@ } } }, - "overloads": [], + "definite": false, "decorators": [], "loc": { "start": { @@ -3103,7 +5291,7 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color2#NamesArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -3120,8 +5308,121 @@ "type": "ArrayExpression", "elements": [ { - "type": "StringLiteral", - "value": "Red", + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color2", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color2", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], "loc": { "start": { "line": 1, @@ -3145,7 +5446,7 @@ } } }, - "accessibility": "public", + "accessibility": "protected", "static": true, "readonly": false, "declare": false, @@ -3159,7 +5460,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "#Color2", "decorators": [], "loc": { "start": { @@ -3222,7 +5523,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color2#getName", + "name": "getName", "decorators": [], "loc": { "start": { @@ -3246,7 +5547,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color2#getName", + "name": "getName", "decorators": [], "loc": { "start": { @@ -3383,7 +5684,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color2#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -3512,7 +5813,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color2#valueOf", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -3536,7 +5837,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color2#valueOf", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -3749,7 +6050,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color2#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -3855,7 +6156,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color2#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -4101,7 +6402,270 @@ } } } - ], + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + "throwMarker": "throws", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getValue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getValue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "e", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color2", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "e", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -4135,99 +6699,7 @@ "column": 1 } } - } - "throwMarker": "throws", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#Color2#ValuesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -4250,7 +6722,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -4267,7 +6739,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color2#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -4291,7 +6763,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color2#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -4312,7 +6784,7 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "e", + "name": "ordinal", "typeAnnotation": { "type": "ETSTypeReference", "part": { @@ -4379,7 +6851,35 @@ } ], "returnType": { - "type": "ETSPrimitiveType", + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -4400,7 +6900,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color2#ValuesArray", + "name": "StringValuesArray", "decorators": [], "loc": { "start": { @@ -4417,7 +6917,7 @@ "type": "TSAsExpression", "expression": { "type": "Identifier", - "name": "e", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -4526,10 +7026,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color2#StringValuesArray", + "name": "values", "decorators": [], "loc": { "start": { @@ -4542,12 +7042,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "0", + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "values", + "decorators": [], "loc": { "start": { "line": 1, @@ -4558,46 +7065,97 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color2", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, "column": 1 }, - "end": { - "line": 1, - "column": 1 + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -4631,7 +7189,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -4648,7 +7206,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color2#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -4672,7 +7230,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color2#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -4695,35 +7253,7 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color2", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -4765,7 +7295,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "Color2", "decorators": [], "loc": { "start": { @@ -4804,12 +7334,13 @@ "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { "type": "Identifier", - "name": "#Color2#StringValuesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -4822,9 +7353,82 @@ } } }, - "property": { - "type": "TSAsExpression", - "expression": { + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { "type": "Identifier", "name": "ordinal", "decorators": [], @@ -4839,8 +7443,120 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "alternate": null, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant in Color2 with ordinal value ", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -4851,20 +7567,8 @@ "column": 1 } } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } } - }, - "computed": true, - "optional": false, + ], "loc": { "start": { "line": 1, @@ -4898,157 +7602,8 @@ "column": 1 } } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#Color2#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color2", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Red", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color2", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "throwMarker": "throws", "loc": { "start": { "line": 1, @@ -5071,7 +7626,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -5088,7 +7643,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color2#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -5103,7 +7658,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -5112,7 +7667,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color2#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -5130,26 +7685,13 @@ "expression": false, "params": [], "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color2", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color2", + "decorators": [], "loc": { "start": { "line": 1, @@ -5189,9 +7731,67 @@ { "type": "ReturnStatement", "argument": { - "type": "Identifier", - "name": "#Color2#ItemsArray", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -5265,7 +7865,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color2#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -5289,7 +7889,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color2#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -5354,7 +7954,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Color2", + "name": "#Color2", "decorators": [], "loc": { "start": { @@ -5416,7 +8016,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color2#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -5474,7 +8074,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color2#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { diff --git a/ets2panda/test/parser/ets/enum9-expected.txt b/ets2panda/test/parser/ets/enum9-expected.txt index add8890f731c5474d5602caa69605137be93af0a..d3e7fbeb6a36566d6bab2263c9d6bad5e2431e32 100644 --- a/ets2panda/test/parser/ets/enum9-expected.txt +++ b/ets2panda/test/parser/ets/enum9-expected.txt @@ -456,12 +456,750 @@ "column": 2 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "Red", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "0", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, { "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "ItemsArray", "decorators": [], "loc": { "start": { @@ -478,8 +1216,271 @@ "type": "ArrayExpression", "elements": [ { - "type": "StringLiteral", - "value": "Red", + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "BoxedItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], "loc": { "start": { "line": 1, @@ -503,7 +1504,7 @@ } } }, - "accessibility": "public", + "accessibility": "protected", "static": true, "readonly": false, "declare": false, @@ -517,7 +1518,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "#Color", "decorators": [], "loc": { "start": { @@ -580,7 +1581,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#getName", + "name": "getName", "decorators": [], "loc": { "start": { @@ -604,7 +1605,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#getName", + "name": "getName", "decorators": [], "loc": { "start": { @@ -741,7 +1742,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -870,7 +1871,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#valueOf", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -894,7 +1895,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#valueOf", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -1107,7 +2108,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1213,7 +2214,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1459,7 +2460,270 @@ } } } - ], + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + "throwMarker": "throws", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getValue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getValue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "e", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "e", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -1493,99 +2757,7 @@ "column": 1 } } - } - "throwMarker": "throws", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#Color#ValuesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1608,7 +2780,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -1625,7 +2797,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -1649,7 +2821,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -1670,7 +2842,7 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "e", + "name": "ordinal", "typeAnnotation": { "type": "ETSTypeReference", "part": { @@ -1737,7 +2909,35 @@ } ], "returnType": { - "type": "ETSPrimitiveType", + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -1758,7 +2958,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#ValuesArray", + "name": "StringValuesArray", "decorators": [], "loc": { "start": { @@ -1775,7 +2975,7 @@ "type": "TSAsExpression", "expression": { "type": "Identifier", - "name": "e", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -1884,10 +3084,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#StringValuesArray", + "name": "values", "decorators": [], "loc": { "start": { @@ -1900,12 +3100,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "0", + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "values", + "decorators": [], "loc": { "start": { "line": 1, @@ -1916,46 +3123,97 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, "column": 1 }, - "end": { - "line": 1, - "column": 1 + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -1989,7 +3247,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2006,7 +3264,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -2030,7 +3288,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -2053,35 +3311,7 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -2123,7 +3353,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "Color", "decorators": [], "loc": { "start": { @@ -2162,12 +3392,13 @@ "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { "type": "Identifier", - "name": "#Color#StringValuesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2180,9 +3411,82 @@ } } }, - "property": { - "type": "TSAsExpression", - "expression": { + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { "type": "Identifier", "name": "ordinal", "decorators": [], @@ -2197,8 +3501,120 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "alternate": null, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant in Color with ordinal value ", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -2209,20 +3625,8 @@ "column": 1 } } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } } - }, - "computed": true, - "optional": false, + ], "loc": { "start": { "line": 1, @@ -2256,157 +3660,8 @@ "column": 1 } } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#Color#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Red", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "throwMarker": "throws", "loc": { "start": { "line": 1, @@ -2429,7 +3684,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2446,7 +3701,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -2461,7 +3716,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -2470,7 +3725,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -2488,26 +3743,13 @@ "expression": false, "params": [], "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], "loc": { "start": { "line": 1, @@ -2547,9 +3789,67 @@ { "type": "ReturnStatement", "argument": { - "type": "Identifier", - "name": "#Color#ItemsArray", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -2623,7 +3923,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -2647,7 +3947,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -2712,7 +4012,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Color", + "name": "#Color", "decorators": [], "loc": { "start": { @@ -2774,7 +4074,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -2832,7 +4132,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { diff --git a/ets2panda/test/parser/ets/extension_function_tests/extension_function_not_for_class_type-expected.txt b/ets2panda/test/parser/ets/extension_function_tests/extension_function_not_for_class_type-expected.txt index 8e563aa1384bbcc978b674320d1a11378d05c7c3..b84f0b5279a73ccd2c3c7162c679d8455aff3383 100644 --- a/ets2panda/test/parser/ets/extension_function_tests/extension_function_not_for_class_type-expected.txt +++ b/ets2panda/test/parser/ets/extension_function_tests/extension_function_not_for_class_type-expected.txt @@ -393,12 +393,750 @@ "column": 2 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "#Fruit", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "size", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "NumberLiteral", + "value": 4, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "4", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, { "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Fruit#NamesArray", + "name": "ItemsArray", "decorators": [], "loc": { "start": { @@ -415,8 +1153,271 @@ "type": "ArrayExpression", "elements": [ { - "type": "StringLiteral", - "value": "size", + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Fruit", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "size", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Fruit", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "BoxedItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Fruit", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Fruit", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "size", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], "loc": { "start": { "line": 1, @@ -440,7 +1441,7 @@ } } }, - "accessibility": "public", + "accessibility": "protected", "static": true, "readonly": false, "declare": false, @@ -454,7 +1455,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "#Fruit", "decorators": [], "loc": { "start": { @@ -517,7 +1518,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Fruit#getName", + "name": "getName", "decorators": [], "loc": { "start": { @@ -541,7 +1542,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Fruit#getName", + "name": "getName", "decorators": [], "loc": { "start": { @@ -678,7 +1679,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Fruit#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -807,7 +1808,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Fruit#valueOf", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -831,7 +1832,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Fruit#valueOf", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -1044,7 +2045,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Fruit#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1150,7 +2151,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Fruit#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1396,7 +2397,270 @@ } } } - ], + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + "throwMarker": "throws", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getValue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getValue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "e", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Fruit", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "e", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -1430,99 +2694,7 @@ "column": 1 } } - } - "throwMarker": "throws", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#Fruit#ValuesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumberLiteral", - "value": 4, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1545,7 +2717,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -1562,7 +2734,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Fruit#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -1586,7 +2758,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Fruit#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -1607,7 +2779,7 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "e", + "name": "ordinal", "typeAnnotation": { "type": "ETSTypeReference", "part": { @@ -1674,7 +2846,35 @@ } ], "returnType": { - "type": "ETSPrimitiveType", + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -1695,7 +2895,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Fruit#ValuesArray", + "name": "StringValuesArray", "decorators": [], "loc": { "start": { @@ -1712,7 +2912,7 @@ "type": "TSAsExpression", "expression": { "type": "Identifier", - "name": "e", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -1821,10 +3021,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Fruit#StringValuesArray", + "name": "values", "decorators": [], "loc": { "start": { @@ -1837,12 +3037,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "4", + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "values", + "decorators": [], "loc": { "start": { "line": 1, @@ -1853,46 +3060,97 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Fruit", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, "column": 1 }, - "end": { - "line": 1, - "column": 1 + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -1926,7 +3184,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -1943,7 +3201,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Fruit#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -1967,7 +3225,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Fruit#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -1990,35 +3248,7 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Fruit", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -2060,7 +3290,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "Fruit", "decorators": [], "loc": { "start": { @@ -2099,12 +3329,13 @@ "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { "type": "Identifier", - "name": "#Fruit#StringValuesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2117,9 +3348,82 @@ } } }, - "property": { - "type": "TSAsExpression", - "expression": { + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { "type": "Identifier", "name": "ordinal", "decorators": [], @@ -2134,8 +3438,120 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "alternate": null, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant in Fruit with ordinal value ", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -2146,20 +3562,8 @@ "column": 1 } } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } } - }, - "computed": true, - "optional": false, + ], "loc": { "start": { "line": 1, @@ -2193,157 +3597,8 @@ "column": 1 } } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#Fruit#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Fruit", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "size", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Fruit", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "throwMarker": "throws", "loc": { "start": { "line": 1, @@ -2366,7 +3621,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2383,7 +3638,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Fruit#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -2398,7 +3653,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -2407,7 +3662,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Fruit#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -2425,26 +3680,13 @@ "expression": false, "params": [], "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Fruit", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Fruit", + "decorators": [], "loc": { "start": { "line": 1, @@ -2484,9 +3726,67 @@ { "type": "ReturnStatement", "argument": { - "type": "Identifier", - "name": "#Fruit#ItemsArray", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -2560,7 +3860,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Fruit#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -2584,7 +3884,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Fruit#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -2649,7 +3949,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Fruit", + "name": "#Fruit", "decorators": [], "loc": { "start": { @@ -2711,7 +4011,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Fruit#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -2769,7 +4069,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Fruit#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { diff --git a/ets2panda/test/compiler/ets/promiseVoid-expected.txt b/ets2panda/test/parser/ets/import_tests/enum/export-expected.txt similarity index 42% rename from ets2panda/test/compiler/ets/promiseVoid-expected.txt rename to ets2panda/test/parser/ets/import_tests/enum/export-expected.txt index 73c1460b96d11626db944bdd60b7e13344271665..fa2fdd7b1a548fe92adf575297f85f3394315049 100644 --- a/ets2panda/test/compiler/ets/promiseVoid-expected.txt +++ b/ets2panda/test/parser/ets/import_tests/enum/export-expected.txt @@ -1,47 +1,282 @@ { "type": "Program", "statements": [ + { + "type": "ETSPackageDeclaration", + "name": { + "type": "Identifier", + "name": "xml", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 9 + }, + "end": { + "line": 16, + "column": 12 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 1 + }, + "end": { + "line": 18, + "column": 7 + } + } + }, + { + "type": "TSEnumDeclaration", + "id": { + "type": "Identifier", + "name": "EventType", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 13 + }, + "end": { + "line": 18, + "column": 22 + } + } + }, + "members": [ + { + "type": "TSEnumMember", + "id": { + "type": "Identifier", + "name": "START_DOCUMENT", + "decorators": [], + "loc": { + "start": { + "line": 19, + "column": 5 + }, + "end": { + "line": 19, + "column": 19 + } + } + }, + "initializer": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 19, + "column": 21 + }, + "end": { + "line": 19, + "column": 22 + } + } + }, + "loc": { + "start": { + "line": 19, + "column": 5 + }, + "end": { + "line": 19, + "column": 22 + } + } + }, + { + "type": "TSEnumMember", + "id": { + "type": "Identifier", + "name": "END_DOCUMENT", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 5 + }, + "end": { + "line": 20, + "column": 17 + } + } + }, + "initializer": { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 20, + "column": 20 + }, + "end": { + "line": 20, + "column": 21 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 5 + }, + "end": { + "line": 20, + "column": 21 + } + } + } + ], + "const": false, + "loc": { + "start": { + "line": 18, + "column": 8 + }, + "end": { + "line": 21, + "column": 2 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ETSGLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, { "type": "ClassDeclaration", "definition": { "id": { "type": "Identifier", - "name": "A", + "name": "#EventType", "decorators": [], "loc": { "start": { - "line": 16, - "column": 7 + "line": 1, + "column": 1 }, "end": { - "line": 16, - "column": 8 + "line": 1, + "column": 1 } } }, "superClass": null, "implements": [], "body": [ + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, { "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "testAsyncVoidMethodImplicit", + "name": "", "decorators": [], "loc": { "start": { - "line": 17, - "column": 11 + "line": 1, + "column": 1 }, "end": { - "line": 17, - "column": 38 + "line": 1, + "column": 1 } } }, "kind": "method", "accessibility": "public", - "static": false, + "static": true, "optional": false, "computed": false, "value": { @@ -50,386 +285,1216 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "testAsyncVoidMethodImplicit", + "name": "", "decorators": [], "loc": { "start": { - "line": 17, - "column": 11 + "line": 1, + "column": 1 }, "end": { - "line": 17, - "column": 38 + "line": 1, + "column": 1 } } }, "generator": false, - "async": true, + "async": false, "expression": false, "params": [], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Promise", - "decorators": [], - "loc": { - "start": { - "line": 17, - "column": 38 - }, - "end": { - "line": 17, - "column": 38 - } - } - }, - "typeParams": { - "type": "TSTypeParameterInstantiation", - "params": [ - { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "void", - "decorators": [], - "loc": { - "start": { - "line": 17, - "column": 38 - }, - "end": { - "line": 17, - "column": 38 - } - } - }, - "loc": { - "start": { - "line": 17, - "column": 38 - }, - "end": { - "line": 17, - "column": 38 - } - } - }, - "loc": { - "start": { - "line": 17, - "column": 38 - }, - "end": { - "line": 17, - "column": 38 - } - } - } - ], - "loc": { - "start": { - "line": 17, - "column": 38 - }, - "end": { - "line": 17, - "column": 38 - } - } - }, - "loc": { - "start": { - "line": 17, - "column": 38 - }, - "end": { - "line": 17, - "column": 38 - } - } - }, - "loc": { - "start": { - "line": 17, - "column": 38 - }, - "end": { - "line": 17, - "column": 38 - } - } - }, "body": { "type": "BlockStatement", "statements": [], "loc": { "start": { - "line": 17, - "column": 41 + "line": 1, + "column": 1 }, "end": { - "line": 17, - "column": 43 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 17, - "column": 38 + "line": 1, + "column": 1 }, "end": { - "line": 17, - "column": 43 + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "START_DOCUMENT", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "END_DOCUMENT", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "0", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "1", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "EventType", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "START_DOCUMENT", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "EventType", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "END_DOCUMENT", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "EventType", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 17, - "column": 38 + "line": 1, + "column": 1 }, "end": { - "line": 17, - "column": 43 + "line": 1, + "column": 1 } } }, - "overloads": [], + "definite": false, "decorators": [], "loc": { "start": { - "line": 17, - "column": 5 + "line": 1, + "column": 1 }, "end": { - "line": 17, - "column": 43 + "line": 1, + "column": 1 } } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "testAsyncVoidMethodExplicit", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { - "line": 18, - "column": 11 + "line": 1, + "column": 1 }, "end": { - "line": 18, - "column": 38 + "line": 1, + "column": 1 } } }, - "kind": "method", - "accessibility": "public", - "static": false, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "testAsyncVoidMethodExplicit", - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 11 - }, - "end": { - "line": 18, - "column": 38 - } - } - }, - "generator": false, - "async": true, - "expression": false, - "params": [], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Promise", - "decorators": [], + "type": "ArrayExpression", + "elements": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#EventType", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { - "line": 18, - "column": 42 + "line": 1, + "column": 1 }, "end": { - "line": 18, - "column": 49 + "line": 1, + "column": 1 } } }, - "typeParams": { - "type": "TSTypeParameterInstantiation", - "params": [ - { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "void", - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 50 - }, - "end": { - "line": 18, - "column": 54 - } - } + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "EventType", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 18, - "column": 50 - }, - "end": { - "line": 18, - "column": 55 - } + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "property": { + "type": "Identifier", + "name": "START_DOCUMENT", + "decorators": [], "loc": { "start": { - "line": 18, - "column": 50 + "line": 1, + "column": 1 }, "end": { - "line": 18, - "column": 55 + "line": 1, + "column": 1 } } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - ], + }, "loc": { "start": { - "line": 18, - "column": 49 + "line": 1, + "column": 1 }, "end": { - "line": 18, - "column": 55 + "line": 1, + "column": 1 } } - }, - "loc": { - "start": { - "line": 18, - "column": 42 - }, - "end": { - "line": 18, - "column": 57 - } } - }, + ], "loc": { "start": { - "line": 18, - "column": 42 + "line": 1, + "column": 1 }, "end": { - "line": 18, - "column": 57 + "line": 1, + "column": 1 } } }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { "type": "Identifier", - "name": "Void", + "name": "#EventType", "decorators": [], "loc": { "start": { - "line": 18, - "column": 64 + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "EventType", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "END_DOCUMENT", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 }, "end": { - "line": 18, - "column": 64 + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 18, - "column": 58 + "line": 1, + "column": 1 }, "end": { - "line": 18, - "column": 64 + "line": 1, + "column": 1 } } } ], "loc": { "start": { - "line": 18, - "column": 56 + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#EventType", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 }, "end": { - "line": 18, - "column": 66 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 18, - "column": 38 + "line": 1, + "column": 1 }, "end": { - "line": 18, - "column": 66 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 18, - "column": 38 + "line": 1, + "column": 1 }, "end": { - "line": 18, - "column": 66 + "line": 1, + "column": 1 } } }, - "overloads": [], + "definite": false, "decorators": [], "loc": { "start": { - "line": 18, - "column": 5 + "line": 1, + "column": 1 }, "end": { - "line": 18, - "column": 66 + "line": 1, + "column": 1 } } }, @@ -437,22 +1502,22 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "testAsyncVoidMethodExplicitObject", + "name": "getName", "decorators": [], "loc": { "start": { - "line": 19, - "column": 11 + "line": 1, + "column": 1 }, "end": { - "line": 19, - "column": 44 + "line": 1, + "column": 1 } } }, "kind": "method", "accessibility": "public", - "static": false, + "static": true, "optional": false, "computed": false, "value": { @@ -461,117 +1526,131 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "testAsyncVoidMethodExplicitObject", + "name": "getName", "decorators": [], "loc": { "start": { - "line": 19, - "column": 11 + "line": 1, + "column": 1 }, "end": { - "line": 19, - "column": 44 + "line": 1, + "column": 1 } } }, "generator": false, - "async": true, + "async": false, "expression": false, - "params": [], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", + "params": [ + { + "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "Promise", - "decorators": [], - "loc": { - "start": { - "line": 19, - "column": 48 - }, - "end": { - "line": 19, - "column": 55 - } - } - }, - "typeParams": { - "type": "TSTypeParameterInstantiation", - "params": [ - { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "void", - "decorators": [], - "loc": { - "start": { - "line": 19, - "column": 56 - }, - "end": { - "line": 19, - "column": 60 - } - } - }, + "name": "ordinal", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "EventType", + "decorators": [], "loc": { "start": { - "line": 19, - "column": 56 + "line": 1, + "column": 1 }, "end": { - "line": 19, - "column": 61 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 19, - "column": 56 + "line": 1, + "column": 1 }, "end": { - "line": 19, - "column": 61 + "line": 1, + "column": 1 } } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } - ], + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], "loc": { "start": { - "line": 19, - "column": 55 + "line": 1, + "column": 1 }, "end": { - "line": 19, - "column": 61 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 19, - "column": 48 + "line": 1, + "column": 1 }, "end": { - "line": 19, - "column": 63 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 19, - "column": 48 + "line": 1, + "column": 1 }, "end": { - "line": 19, - "column": 63 + "line": 1, + "column": 1 } } }, @@ -581,62 +1660,118 @@ { "type": "ReturnStatement", "argument": { - "type": "Identifier", - "name": "Void", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { - "line": 19, - "column": 71 + "line": 1, + "column": 1 }, "end": { - "line": 19, - "column": 75 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 19, - "column": 64 + "line": 1, + "column": 1 }, "end": { - "line": 19, - "column": 75 + "line": 1, + "column": 1 } } } ], "loc": { "start": { - "line": 19, - "column": 62 + "line": 1, + "column": 1 }, "end": { - "line": 19, - "column": 77 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 19, - "column": 44 + "line": 1, + "column": 1 }, "end": { - "line": 19, - "column": 77 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 19, - "column": 44 + "line": 1, + "column": 1 }, "end": { - "line": 19, - "column": 77 + "line": 1, + "column": 1 } } }, @@ -644,12 +1779,12 @@ "decorators": [], "loc": { "start": { - "line": 19, - "column": 5 + "line": 1, + "column": 1 }, "end": { - "line": 19, - "column": 77 + "line": 1, + "column": 1 } } }, @@ -657,22 +1792,22 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "testAsyncVoidMethodReturns", + "name": "valueOf", "decorators": [], "loc": { "start": { - "line": 20, - "column": 11 + "line": 1, + "column": 1 }, "end": { - "line": 20, - "column": 37 + "line": 1, + "column": 1 } } }, "kind": "method", "accessibility": "public", - "static": false, + "static": true, "optional": false, "computed": false, "value": { @@ -681,433 +1816,595 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "testAsyncVoidMethodReturns", + "name": "valueOf", "decorators": [], "loc": { "start": { - "line": 20, - "column": 11 + "line": 1, + "column": 1 }, "end": { - "line": 20, - "column": 37 + "line": 1, + "column": 1 } } }, "generator": false, - "async": true, + "async": false, "expression": false, - "params": [], + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "name", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], "returnType": { "type": "ETSTypeReference", "part": { "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Promise", + "name": "EventType", "decorators": [], "loc": { "start": { - "line": 20, - "column": 37 + "line": 1, + "column": 1 }, "end": { - "line": 20, - "column": 37 + "line": 1, + "column": 1 } } }, - "typeParams": { - "type": "TSTypeParameterInstantiation", - "params": [ - { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ForUpdateStatement", + "init": { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "init": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "update": { + "type": "UpdateExpression", + "operator": "++", + "prefix": true, + "argument": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "==", + "left": { + "type": "Identifier", + "name": "name", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { "type": "Identifier", - "name": "void", + "name": "i", "decorators": [], "loc": { "start": { - "line": 20, - "column": 37 + "line": 1, + "column": 1 }, "end": { - "line": 20, - "column": 37 + "line": 1, + "column": 1 } } }, + "computed": true, + "optional": false, "loc": { "start": { - "line": 20, - "column": 37 + "line": 1, + "column": 1 }, "end": { - "line": 20, - "column": 37 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 20, - "column": 37 + "line": 1, + "column": 1 }, "end": { - "line": 20, - "column": 37 + "line": 1, + "column": 1 } } - } - ], - "loc": { - "start": { - "line": 20, - "column": 37 }, - "end": { - "line": 20, - "column": 37 - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 37 - }, - "end": { - "line": 20, - "column": 37 - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 37 - }, - "end": { - "line": 20, - "column": 37 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "flag", - "decorators": [], - "loc": { - "start": { - "line": 21, - "column": 13 + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "EventType", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 21, - "column": 17 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - } - }, - "init": { - "type": "BooleanLiteral", - "value": false, + }, "loc": { "start": { - "line": 21, - "column": 20 + "line": 1, + "column": 1 }, "end": { - "line": 21, - "column": 25 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 21, - "column": 13 + "line": 1, + "column": 1 }, "end": { - "line": 21, - "column": 25 + "line": 1, + "column": 1 } } + }, + "alternate": null, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - ], - "kind": "let", + }, "loc": { "start": { - "line": 21, - "column": 9 + "line": 1, + "column": 1 }, "end": { - "line": 21, - "column": 25 + "line": 1, + "column": 1 } } }, { - "type": "IfStatement", - "test": { - "type": "Identifier", - "name": "flag", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 13 - }, - "end": { - "line": 22, - "column": 17 - } - } - }, - "consequent": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { "type": "Identifier", - "name": "Void", + "name": "Exception", "decorators": [], "loc": { "start": { - "line": 23, - "column": 19 + "line": 1, + "column": 1 }, "end": { - "line": 23, - "column": 19 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 23, - "column": 13 + "line": 1, + "column": 1 }, "end": { - "line": 23, - "column": 19 + "line": 1, + "column": 1 } } - } - ], - "loc": { - "start": { - "line": 22, - "column": 19 }, - "end": { - "line": 24, - "column": 10 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - } - }, - "alternate": { - "type": "BlockStatement", - "statements": [ + }, + "arguments": [ { - "type": "IfStatement", - "test": { - "type": "Identifier", - "name": "flag", - "decorators": [], + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant EventType.", "loc": { "start": { - "line": 25, - "column": 17 + "line": 1, + "column": 1 }, "end": { - "line": 25, - "column": 21 + "line": 1, + "column": 1 } } }, - "consequent": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "Void", - "decorators": [], - "loc": { - "start": { - "line": 25, - "column": 31 - }, - "end": { - "line": 25, - "column": 31 - } - } - }, - "loc": { - "start": { - "line": 25, - "column": 25 - }, - "end": { - "line": 25, - "column": 31 - } - } - } - ], + "right": { + "type": "Identifier", + "name": "name", + "decorators": [], "loc": { "start": { - "line": 25, - "column": 23 + "line": 1, + "column": 1 }, "end": { - "line": 25, - "column": 33 + "line": 1, + "column": 1 } } }, - "alternate": null, "loc": { "start": { - "line": 25, - "column": 13 + "line": 1, + "column": 1 }, "end": { - "line": 25, - "column": 33 + "line": 1, + "column": 1 } } } ], "loc": { "start": { - "line": 24, - "column": 16 + "line": 1, + "column": 1 }, "end": { - "line": 26, - "column": 10 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 22, - "column": 9 + "line": 1, + "column": 1 }, "end": { - "line": 26, - "column": 10 + "line": 1, + "column": 1 } } } ], - "loc": { - "start": { - "line": 20, - "column": 40 - }, - "end": { - "line": 27, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 37 - }, - "end": { - "line": 27, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 37 - }, - "end": { - "line": 27, - "column": 6 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 5 - }, - "end": { - "line": 27, - "column": 6 - } - } - }, - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "constructor", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "kind": "constructor", - "static": false, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "constructor", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "body": { - "type": "BlockStatement", - "statements": [], "loc": { "start": { "line": 1, @@ -1118,7 +2415,8 @@ "column": 1 } } - }, + } + "throwMarker": "throws", "loc": { "start": { "line": 1, @@ -1144,65 +2442,21 @@ "overloads": [], "decorators": [], "loc": { - "start": { - "line": 28, - "column": 2 - }, - "end": { - "line": 28, - "column": 2 - } - } - } - ], - "loc": { - "start": { - "line": 16, - "column": 9 - }, - "end": { - "line": 28, - "column": 2 - } - } - }, - "loc": { - "start": { - "line": 16, - "column": 1 - }, - "end": { - "line": 28, - "column": 2 - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "ETSGLOBAL", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - } - }, - "superClass": null, - "implements": [], - "body": [ + }, { "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "_$init$_", + "name": "getValue", "decorators": [], "loc": { "start": { @@ -1226,7 +2480,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "_$init$_", + "name": "getValue", "decorators": [], "loc": { "start": { @@ -1242,10 +2496,178 @@ "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": "EventType", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "body": { "type": "BlockStatement", - "statements": [], + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "e", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], "loc": { "start": { "line": 1, @@ -1296,16 +2718,16 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "testAsyncVoidImplicit", + "name": "toString", "decorators": [], "loc": { "start": { - "line": 30, - "column": 16 + "line": 1, + "column": 1 }, "end": { - "line": 30, - "column": 37 + "line": 1, + "column": 1 } } }, @@ -1320,153 +2742,252 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "testAsyncVoidImplicit", + "name": "toString", "decorators": [], "loc": { "start": { - "line": 30, - "column": 16 + "line": 1, + "column": 1 }, "end": { - "line": 30, - "column": 37 + "line": 1, + "column": 1 } } }, "generator": false, - "async": true, + "async": false, "expression": false, - "params": [], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", + "params": [ + { + "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "Promise", - "decorators": [], - "loc": { - "start": { - "line": 30, - "column": 37 - }, - "end": { - "line": 30, - "column": 37 - } - } - }, - "typeParams": { - "type": "TSTypeParameterInstantiation", - "params": [ - { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "void", - "decorators": [], - "loc": { - "start": { - "line": 30, - "column": 37 - }, - "end": { - "line": 30, - "column": 37 - } - } - }, + "name": "ordinal", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "EventType", + "decorators": [], "loc": { "start": { - "line": 30, - "column": 37 + "line": 1, + "column": 1 }, "end": { - "line": 30, - "column": 37 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 30, - "column": 37 + "line": 1, + "column": 1 }, "end": { - "line": 30, - "column": 37 + "line": 1, + "column": 1 } } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } - ], + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], "loc": { "start": { - "line": 30, - "column": 37 + "line": 1, + "column": 1 }, "end": { - "line": 30, - "column": 37 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 30, - "column": 37 + "line": 1, + "column": 1 }, "end": { - "line": 30, - "column": 37 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 30, - "column": 37 + "line": 1, + "column": 1 }, "end": { - "line": 30, - "column": 37 + "line": 1, + "column": 1 } } }, "body": { "type": "BlockStatement", - "statements": [], + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], "loc": { "start": { - "line": 30, - "column": 40 + "line": 1, + "column": 1 }, "end": { - "line": 30, - "column": 42 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 30, - "column": 37 + "line": 1, + "column": 1 }, "end": { - "line": 30, - "column": 42 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 30, - "column": 37 + "line": 1, + "column": 1 }, "end": { - "line": 30, - "column": 42 + "line": 1, + "column": 1 } } }, @@ -1474,12 +2995,12 @@ "decorators": [], "loc": { "start": { - "line": 30, + "line": 1, "column": 1 }, "end": { - "line": 30, - "column": 42 + "line": 1, + "column": 1 } } }, @@ -1487,16 +3008,16 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "testAsyncVoidExplicit", + "name": "values", "decorators": [], "loc": { "start": { - "line": 31, - "column": 16 + "line": 1, + "column": 1 }, "end": { - "line": 31, - "column": 37 + "line": 1, + "column": 1 } } }, @@ -1511,117 +3032,74 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "testAsyncVoidExplicit", + "name": "values", "decorators": [], "loc": { "start": { - "line": 31, - "column": 16 + "line": 1, + "column": 1 }, "end": { - "line": 31, - "column": 37 + "line": 1, + "column": 1 } } }, "generator": false, - "async": true, + "async": false, "expression": false, "params": [], "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Promise", - "decorators": [], - "loc": { - "start": { - "line": 31, - "column": 41 - }, - "end": { - "line": 31, - "column": 48 - } - } - }, - "typeParams": { - "type": "TSTypeParameterInstantiation", - "params": [ - { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "void", - "decorators": [], - "loc": { - "start": { - "line": 31, - "column": 49 - }, - "end": { - "line": 31, - "column": 53 - } - } - }, - "loc": { - "start": { - "line": 31, - "column": 49 - }, - "end": { - "line": 31, - "column": 54 - } - } + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "EventType", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 31, - "column": 49 - }, - "end": { - "line": 31, - "column": 54 - } + "end": { + "line": 1, + "column": 1 } } - ], + }, "loc": { "start": { - "line": 31, - "column": 48 + "line": 1, + "column": 1 }, "end": { - "line": 31, - "column": 54 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 31, - "column": 41 + "line": 1, + "column": 1 }, "end": { - "line": 31, - "column": 56 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 31, - "column": 41 + "line": 1, + "column": 1 }, "end": { - "line": 31, - "column": 56 + "line": 1, + "column": 1 } } }, @@ -1632,61 +3110,61 @@ "type": "ReturnStatement", "argument": { "type": "Identifier", - "name": "Void", + "name": "ItemsArray", "decorators": [], "loc": { "start": { - "line": 31, - "column": 63 + "line": 1, + "column": 1 }, "end": { - "line": 31, - "column": 63 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 31, - "column": 57 + "line": 1, + "column": 1 }, "end": { - "line": 31, - "column": 63 + "line": 1, + "column": 1 } } } ], "loc": { "start": { - "line": 31, - "column": 55 + "line": 1, + "column": 1 }, "end": { - "line": 31, - "column": 65 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 31, - "column": 37 + "line": 1, + "column": 1 }, "end": { - "line": 31, - "column": 65 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 31, - "column": 37 + "line": 1, + "column": 1 }, "end": { - "line": 31, - "column": 65 + "line": 1, + "column": 1 } } }, @@ -1694,12 +3172,12 @@ "decorators": [], "loc": { "start": { - "line": 31, + "line": 1, "column": 1 }, "end": { - "line": 31, - "column": 65 + "line": 1, + "column": 1 } } }, @@ -1707,16 +3185,16 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "testAsyncVoidExplicitObject", + "name": "fromInt", "decorators": [], "loc": { "start": { - "line": 32, - "column": 16 + "line": 1, + "column": 1 }, "end": { - "line": 32, - "column": 43 + "line": 1, + "column": 1 } } }, @@ -1731,182 +3209,399 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "testAsyncVoidExplicitObject", + "name": "fromInt", "decorators": [], "loc": { "start": { - "line": 32, - "column": 16 + "line": 1, + "column": 1 }, "end": { - "line": 32, - "column": 43 + "line": 1, + "column": 1 } } }, "generator": false, - "async": true, + "async": false, "expression": false, - "params": [], + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], "returnType": { "type": "ETSTypeReference", "part": { "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Promise", + "name": "EventType", "decorators": [], "loc": { "start": { - "line": 32, - "column": 47 + "line": 1, + "column": 1 }, "end": { - "line": 32, - "column": 54 + "line": 1, + "column": 1 } } }, - "typeParams": { - "type": "TSTypeParameterInstantiation", - "params": [ - { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "void", - "decorators": [], - "loc": { - "start": { - "line": 32, - "column": 55 - }, - "end": { - "line": 32, - "column": 59 - } + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], "loc": { "start": { - "line": 32, - "column": 55 + "line": 1, + "column": 1 }, "end": { - "line": 32, - "column": 60 + "line": 1, + "column": 1 } } }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { - "line": 32, - "column": 55 + "line": 1, + "column": 1 }, "end": { - "line": 32, - "column": 60 + "line": 1, + "column": 1 } } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - ], + }, + "alternate": null, "loc": { "start": { - "line": 32, - "column": 54 + "line": 1, + "column": 1 }, "end": { - "line": 32, - "column": 60 + "line": 1, + "column": 1 } } }, - "loc": { - "start": { - "line": 32, - "column": 47 - }, - "end": { - "line": 32, - "column": 62 - } - } - }, - "loc": { - "start": { - "line": 32, - "column": 47 - }, - "end": { - "line": 32, - "column": 62 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ { - "type": "ReturnStatement", + "type": "ThrowStatement", "argument": { - "type": "Identifier", - "name": "Void", - "decorators": [], + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant in EventType with ordinal value ", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], "loc": { "start": { - "line": 32, - "column": 70 + "line": 1, + "column": 1 }, "end": { - "line": 32, - "column": 74 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 32, - "column": 63 + "line": 1, + "column": 1 }, "end": { - "line": 32, - "column": 74 + "line": 1, + "column": 1 } } } ], "loc": { "start": { - "line": 32, - "column": 61 + "line": 1, + "column": 1 }, "end": { - "line": 32, - "column": 76 + "line": 1, + "column": 1 } } - }, + } + "throwMarker": "throws", "loc": { "start": { - "line": 32, - "column": 43 + "line": 1, + "column": 1 }, "end": { - "line": 32, - "column": 76 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 32, - "column": 43 + "line": 1, + "column": 1 }, "end": { - "line": 32, - "column": 76 + "line": 1, + "column": 1 } } }, @@ -1914,12 +3609,12 @@ "decorators": [], "loc": { "start": { - "line": 32, + "line": 1, "column": 1 }, "end": { - "line": 32, - "column": 76 + "line": 1, + "column": 1 } } }, @@ -1927,22 +3622,22 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "testAsyncVoidEarlyReturn", + "name": "unbox", "decorators": [], "loc": { "start": { - "line": 33, - "column": 16 + "line": 1, + "column": 1 }, "end": { - "line": 33, - "column": 40 + "line": 1, + "column": 1 } } }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -1951,21 +3646,21 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "testAsyncVoidEarlyReturn", + "name": "unbox", "decorators": [], "loc": { "start": { - "line": 33, - "column": 16 + "line": 1, + "column": 1 }, "end": { - "line": 33, - "column": 40 + "line": 1, + "column": 1 } } }, "generator": false, - "async": true, + "async": false, "expression": false, "params": [], "returnType": { @@ -1974,94 +3669,38 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Promise", + "name": "EventType", "decorators": [], "loc": { "start": { - "line": 33, - "column": 44 - }, - "end": { - "line": 33, - "column": 51 - } - } - }, - "typeParams": { - "type": "TSTypeParameterInstantiation", - "params": [ - { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "void", - "decorators": [], - "loc": { - "start": { - "line": 33, - "column": 52 - }, - "end": { - "line": 33, - "column": 56 - } - } - }, - "loc": { - "start": { - "line": 33, - "column": 52 - }, - "end": { - "line": 33, - "column": 57 - } - } - }, - "loc": { - "start": { - "line": 33, - "column": 52 - }, - "end": { - "line": 33, - "column": 57 - } - } - } - ], - "loc": { - "start": { - "line": 33, - "column": 51 + "line": 1, + "column": 1 }, "end": { - "line": 33, - "column": 57 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 33, - "column": 44 + "line": 1, + "column": 1 }, "end": { - "line": 33, - "column": 59 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 33, - "column": 44 + "line": 1, + "column": 1 }, "end": { - "line": 33, - "column": 59 + "line": 1, + "column": 1 } } }, @@ -2069,181 +3708,51 @@ "type": "BlockStatement", "statements": [ { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "flag", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 34, - "column": 15 - }, - "end": { - "line": 34, - "column": 22 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 34, - "column": 9 - }, - "end": { - "line": 34, - "column": 13 - } - } - }, - "init": { - "type": "BooleanLiteral", - "value": true, - "loc": { - "start": { - "line": 34, - "column": 25 - }, - "end": { - "line": 34, - "column": 29 - } - } - }, + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], "loc": { "start": { - "line": 34, - "column": 9 + "line": 1, + "column": 1 }, "end": { - "line": 34, - "column": 29 - } - } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 34, - "column": 5 - }, - "end": { - "line": 34, - "column": 29 - } - } - }, - { - "type": "IfStatement", - "test": { - "type": "Identifier", - "name": "flag", - "decorators": [], - "loc": { - "start": { - "line": 35, - "column": 9 - }, - "end": { - "line": 35, - "column": 13 - } - } - }, - "consequent": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "Void", - "decorators": [], - "loc": { - "start": { - "line": 36, - "column": 15 - }, - "end": { - "line": 36, - "column": 15 - } - } - }, - "loc": { - "start": { - "line": 36, - "column": 9 - }, - "end": { - "line": 36, - "column": 15 - } + "line": 1, + "column": 1 } } - ], - "loc": { - "start": { - "line": 35, - "column": 15 - }, - "end": { - "line": 37, - "column": 6 - } - } - }, - "alternate": null, - "loc": { - "start": { - "line": 35, - "column": 5 }, - "end": { - "line": 37, - "column": 6 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { + "property": { "type": "MemberExpression", "object": { - "type": "Identifier", - "name": "console", - "decorators": [], + "type": "ThisExpression", "loc": { "start": { - "line": 38, - "column": 5 + "line": 1, + "column": 1 }, "end": { - "line": 38, - "column": 12 + "line": 1, + "column": 1 } } }, "property": { "type": "Identifier", - "name": "println", + "name": "ordinal", "decorators": [], "loc": { "start": { - "line": 38, - "column": 13 + "line": 1, + "column": 1 }, "end": { - "line": 38, - "column": 20 + "line": 1, + "column": 1 } } }, @@ -2251,85 +3760,70 @@ "optional": false, "loc": { "start": { - "line": 38, - "column": 5 + "line": 1, + "column": 1 }, "end": { - "line": 38, - "column": 20 + "line": 1, + "column": 1 } } }, - "arguments": [ - { - "type": "StringLiteral", - "value": "something", - "loc": { - "start": { - "line": 38, - "column": 21 - }, - "end": { - "line": 38, - "column": 32 - } - } - } - ], + "computed": true, "optional": false, "loc": { "start": { - "line": 38, - "column": 5 + "line": 1, + "column": 1 }, "end": { - "line": 38, - "column": 33 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 38, - "column": 5 + "line": 1, + "column": 1 }, "end": { - "line": 38, - "column": 33 + "line": 1, + "column": 1 } } } ], "loc": { "start": { - "line": 33, - "column": 58 + "line": 1, + "column": 1 }, "end": { - "line": 39, - "column": 2 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 33, - "column": 40 + "line": 1, + "column": 1 }, "end": { - "line": 39, - "column": 2 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 33, - "column": 40 + "line": 1, + "column": 1 }, "end": { - "line": 39, - "column": 2 + "line": 1, + "column": 1 } } }, @@ -2337,12 +3831,12 @@ "decorators": [], "loc": { "start": { - "line": 33, + "line": 1, "column": 1 }, "end": { - "line": 39, - "column": 2 + "line": 1, + "column": 1 } } }, @@ -2350,16 +3844,16 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "testAsyncVoidMultipleReturns", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { - "line": 40, - "column": 16 + "line": 1, + "column": 1 }, "end": { - "line": 40, - "column": 44 + "line": 1, + "column": 1 } } }, @@ -2374,117 +3868,103 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "testAsyncVoidMultipleReturns", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { - "line": 40, - "column": 16 + "line": 1, + "column": 1 }, "end": { - "line": 40, - "column": 44 + "line": 1, + "column": 1 } } }, "generator": false, - "async": true, + "async": false, "expression": false, - "params": [], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", + "params": [ + { + "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "Promise", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "decorators": [], "loc": { "start": { - "line": 40, - "column": 44 + "line": 1, + "column": 1 }, - "end": { - "line": 40, - "column": 44 - } - } - }, - "typeParams": { - "type": "TSTypeParameterInstantiation", - "params": [ - { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "void", - "decorators": [], - "loc": { - "start": { - "line": 40, - "column": 44 - }, - "end": { - "line": 40, - "column": 44 - } - } - }, - "loc": { - "start": { - "line": 40, - "column": 44 - }, - "end": { - "line": 40, - "column": 44 - } - } - }, - "loc": { - "start": { - "line": 40, - "column": 44 - }, - "end": { - "line": 40, - "column": 44 - } - } + "end": { + "line": 1, + "column": 1 } - ], + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#EventType", + "decorators": [], "loc": { "start": { - "line": 40, - "column": 44 + "line": 1, + "column": 1 }, "end": { - "line": 40, - "column": 44 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 40, - "column": 44 + "line": 1, + "column": 1 }, "end": { - "line": 40, - "column": 44 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 40, - "column": 44 + "line": 1, + "column": 1 }, "end": { - "line": 40, - "column": 44 + "line": 1, + "column": 1 } } }, @@ -2492,181 +3972,54 @@ "type": "BlockStatement", "statements": [ { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "flag", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 41, - "column": 15 - }, - "end": { - "line": 41, - "column": 22 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 41, - "column": 9 - }, - "end": { - "line": 41, - "column": 13 - } - } - }, - "init": { - "type": "BooleanLiteral", - "value": true, - "loc": { - "start": { - "line": 41, - "column": 25 - }, - "end": { - "line": 41, - "column": 29 - } - } - }, + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { - "line": 41, - "column": 9 + "line": 1, + "column": 1 }, "end": { - "line": 41, - "column": 29 - } - } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 41, - "column": 5 - }, - "end": { - "line": 41, - "column": 29 - } - } - }, - { - "type": "IfStatement", - "test": { - "type": "Identifier", - "name": "flag", - "decorators": [], - "loc": { - "start": { - "line": 42, - "column": 9 - }, - "end": { - "line": 42, - "column": 13 - } - } - }, - "consequent": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "Void", - "decorators": [], - "loc": { - "start": { - "line": 43, - "column": 15 - }, - "end": { - "line": 43, - "column": 15 - } - } - }, - "loc": { - "start": { - "line": 43, - "column": 9 - }, - "end": { - "line": 43, - "column": 15 - } + "line": 1, + "column": 1 } } - ], - "loc": { - "start": { - "line": 42, - "column": 15 - }, - "end": { - "line": 44, - "column": 6 - } - } - }, - "alternate": null, - "loc": { - "start": { - "line": 42, - "column": 5 }, - "end": { - "line": 44, - "column": 6 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { + "right": { "type": "MemberExpression", "object": { "type": "Identifier", - "name": "console", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { - "line": 45, - "column": 5 + "line": 1, + "column": 1 }, "end": { - "line": 45, - "column": 12 + "line": 1, + "column": 1 } } }, "property": { "type": "Identifier", - "name": "println", + "name": "length", "decorators": [], "loc": { "start": { - "line": 45, - "column": 13 + "line": 1, + "column": 1 }, "end": { - "line": 45, - "column": 20 + "line": 1, + "column": 1 } } }, @@ -2674,348 +4027,240 @@ "optional": false, "loc": { "start": { - "line": 45, - "column": 5 - }, - "end": { - "line": 45, - "column": 20 - } - } - }, - "arguments": [ - { - "type": "StringLiteral", - "value": "something x1", - "loc": { - "start": { - "line": 45, - "column": 21 - }, - "end": { - "line": 45, - "column": 35 - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 45, - "column": 5 - }, - "end": { - "line": 45, - "column": 36 - } - } - }, - "loc": { - "start": { - "line": 45, - "column": 5 - }, - "end": { - "line": 45, - "column": 36 - } - } - }, - { - "type": "IfStatement", - "test": { - "type": "UnaryExpression", - "operator": "!", - "prefix": true, - "argument": { - "type": "Identifier", - "name": "flag", - "decorators": [], - "loc": { - "start": { - "line": 46, - "column": 10 + "line": 1, + "column": 1 }, "end": { - "line": 46, - "column": 14 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 46, - "column": 9 + "line": 1, + "column": 1 }, "end": { - "line": 46, - "column": 14 + "line": 1, + "column": 1 } } }, "consequent": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "Void", - "decorators": [], - "loc": { - "start": { - "line": 47, - "column": 15 - }, - "end": { - "line": 47, - "column": 15 - } - } - }, - "loc": { - "start": { - "line": 47, - "column": 9 - }, - "end": { - "line": 47, - "column": 15 - } - } - } - ], - "loc": { - "start": { - "line": 46, - "column": 16 - }, - "end": { - "line": 48, - "column": 6 - } - } - }, - "alternate": null, - "loc": { - "start": { - "line": 46, - "column": 5 - }, - "end": { - "line": 48, - "column": 6 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { + "type": "ReturnStatement", + "argument": { "type": "MemberExpression", "object": { "type": "Identifier", - "name": "console", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { - "line": 49, - "column": 5 + "line": 1, + "column": 1 }, "end": { - "line": 49, - "column": 12 + "line": 1, + "column": 1 } } }, "property": { "type": "Identifier", - "name": "println", + "name": "ordinal", "decorators": [], "loc": { "start": { - "line": 49, - "column": 13 + "line": 1, + "column": 1 }, "end": { - "line": 49, - "column": 20 + "line": 1, + "column": 1 } } }, - "computed": false, + "computed": true, "optional": false, "loc": { "start": { - "line": 49, - "column": 5 + "line": 1, + "column": 1 }, "end": { - "line": 49, - "column": 20 + "line": 1, + "column": 1 } } }, - "arguments": [ - { - "type": "StringLiteral", - "value": "something x2", - "loc": { - "start": { - "line": 49, - "column": 21 - }, - "end": { - "line": 49, - "column": 35 - } - } - } - ], - "optional": false, "loc": { "start": { - "line": 49, - "column": 5 + "line": 1, + "column": 1 }, "end": { - "line": 49, - "column": 36 + "line": 1, + "column": 1 } } }, + "alternate": null, "loc": { "start": { - "line": 49, - "column": 5 + "line": 1, + "column": 1 }, "end": { - "line": 49, - "column": 36 + "line": 1, + "column": 1 } } }, { - "type": "ReturnStatement", + "type": "ThrowStatement", "argument": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "console", - "decorators": [], - "loc": { - "start": { - "line": 50, - "column": 12 - }, - "end": { - "line": 50, - "column": 19 + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - } - }, - "property": { - "type": "Identifier", - "name": "println", - "decorators": [], + }, "loc": { "start": { - "line": 50, - "column": 20 + "line": 1, + "column": 1 }, "end": { - "line": 50, - "column": 27 + "line": 1, + "column": 1 } } }, - "computed": false, - "optional": false, "loc": { "start": { - "line": 50, - "column": 12 + "line": 1, + "column": 1 }, "end": { - "line": 50, - "column": 27 + "line": 1, + "column": 1 } } }, "arguments": [ { - "type": "StringLiteral", - "value": "something x3", + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant in EventType with ordinal value ", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { - "line": 50, - "column": 28 + "line": 1, + "column": 1 }, "end": { - "line": 50, - "column": 42 + "line": 1, + "column": 1 } } } ], - "optional": false, "loc": { "start": { - "line": 50, - "column": 12 + "line": 1, + "column": 1 }, "end": { - "line": 50, - "column": 43 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 50, - "column": 5 + "line": 1, + "column": 1 }, "end": { - "line": 50, - "column": 43 + "line": 1, + "column": 1 } } } ], "loc": { "start": { - "line": 40, - "column": 47 + "line": 1, + "column": 1 }, "end": { - "line": 51, - "column": 2 + "line": 1, + "column": 1 } } - }, + } + "throwMarker": "throws", "loc": { "start": { - "line": 40, - "column": 44 + "line": 1, + "column": 1 }, "end": { - "line": 51, - "column": 2 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 40, - "column": 44 + "line": 1, + "column": 1 }, "end": { - "line": 51, - "column": 2 + "line": 1, + "column": 1 } } }, @@ -3023,12 +4268,12 @@ "decorators": [], "loc": { "start": { - "line": 40, + "line": 1, "column": 1 }, "end": { - "line": 51, - "column": 2 + "line": 1, + "column": 1 } } } @@ -3062,7 +4307,7 @@ "column": 1 }, "end": { - "line": 57, + "line": 22, "column": 1 } } diff --git a/ets2panda/test/parser/ets/import_tests/enum/export.sts b/ets2panda/test/parser/ets/import_tests/enum/export.sts new file mode 100644 index 0000000000000000000000000000000000000000..678522a9ad334ac4e3bda2adefa6ea21edd0a544 --- /dev/null +++ b/ets2panda/test/parser/ets/import_tests/enum/export.sts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package xml + +export enum EventType { + START_DOCUMENT =0, + END_DOCUMENT = 1, +}; diff --git a/ets2panda/test/parser/ets/recursive_import/case_5_main-is-not-part-of-circle/foo2__module-expected.txt b/ets2panda/test/parser/ets/import_tests/enum/import-expected.txt similarity index 57% rename from ets2panda/test/parser/ets/recursive_import/case_5_main-is-not-part-of-circle/foo2__module-expected.txt rename to ets2panda/test/parser/ets/import_tests/enum/import-expected.txt index 1fcd9da6ef94a6943ce864ff97d00b5cd757684c..9ae9b0527d17fec6530ec598b73931d609a6be8e 100644 --- a/ets2panda/test/parser/ets/recursive_import/case_5_main-is-not-part-of-circle/foo2__module-expected.txt +++ b/ets2panda/test/parser/ets/import_tests/enum/import-expected.txt @@ -5,59 +5,44 @@ "type": "ImportDeclaration", "source": { "type": "StringLiteral", - "value": "./foo3__module", + "value": "./export", "loc": { "start": { "line": 16, - "column": 24 + "column": 20 }, "end": { "line": 16, - "column": 40 + "column": 30 } } }, "specifiers": [ { - "type": "ImportSpecifier", + "type": "ImportNamespaceSpecifier", "local": { "type": "Identifier", - "name": "foo_in_3", + "name": "x", "decorators": [], "loc": { "start": { "line": 16, - "column": 9 + "column": 13 }, "end": { "line": 16, - "column": 17 - } - } - }, - "imported": { - "type": "Identifier", - "name": "foo_in_3", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 9 - }, - "end": { - "line": 16, - "column": 17 + "column": 14 } } }, "loc": { "start": { "line": 16, - "column": 9 + "column": 8 }, "end": { "line": 16, - "column": 17 + "column": 14 } } } @@ -69,7 +54,7 @@ }, "end": { "line": 16, - "column": 40 + "column": 30 } } }, @@ -78,16 +63,16 @@ "definition": { "id": { "type": "Identifier", - "name": "A", + "name": "ETSGLOBAL", "decorators": [], "loc": { "start": { - "line": 18, - "column": 14 + "line": 1, + "column": 1 }, "end": { - "line": 18, - "column": 15 + "line": 1, + "column": 1 } } }, @@ -98,7 +83,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "constructor", + "name": "main", "decorators": [], "loc": { "start": { @@ -111,8 +96,9 @@ } } }, - "kind": "constructor", - "static": false, + "kind": "method", + "accessibility": "public", + "static": true, "optional": false, "computed": false, "value": { @@ -121,7 +107,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "constructor", + "name": "main", "decorators": [], "loc": { "start": { @@ -178,73 +164,29 @@ "decorators": [], "loc": { "start": { - "line": 18, - "column": 18 + "line": 1, + "column": 1 }, "end": { - "line": 18, - "column": 18 + "line": 1, + "column": 1 } } - } - ], - "loc": { - "start": { - "line": 18, - "column": 16 }, - "end": { - "line": 18, - "column": 18 - } - } - }, - "loc": { - "start": { - "line": 18, - "column": 8 - }, - "end": { - "line": 18, - "column": 18 - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "ETSGLOBAL", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "superClass": null, - "implements": [], - "body": [ { "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "foo_in_2", + "name": "_$init$_", "decorators": [], "loc": { "start": { - "line": 20, - "column": 17 + "line": 1, + "column": 1 }, "end": { - "line": 20, - "column": 25 + "line": 1, + "column": 1 } } }, @@ -259,16 +201,16 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "foo_in_2", + "name": "_$init$_", "decorators": [], "loc": { "start": { - "line": 20, - "column": 17 + "line": 1, + "column": 1 }, "end": { - "line": 20, - "column": 25 + "line": 1, + "column": 1 } } }, @@ -276,55 +218,88 @@ "async": false, "expression": false, "params": [], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 20, - "column": 29 - }, - "end": { - "line": 20, - "column": 32 - } - } - }, "body": { "type": "BlockStatement", "statements": [ { "type": "ExpressionStatement", "expression": { - "type": "CallExpression", - "callee": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "event", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 18, + "column": 10 + } + } + }, + "right": { "type": "MemberExpression", "object": { - "type": "Identifier", - "name": "console", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "x", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 26 + }, + "end": { + "line": 18, + "column": 27 + } + } + }, + "property": { + "type": "Identifier", + "name": "EventType", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 28 + }, + "end": { + "line": 18, + "column": 37 + } + } + }, + "computed": false, + "optional": false, "loc": { "start": { - "line": 21, - "column": 5 + "line": 18, + "column": 26 }, "end": { - "line": 21, - "column": 12 + "line": 18, + "column": 37 } } }, "property": { "type": "Identifier", - "name": "log", + "name": "END_DOCUMENT", "decorators": [], "loc": { "start": { - "line": 21, - "column": 13 + "line": 18, + "column": 38 }, "end": { - "line": 21, - "column": 16 + "line": 18, + "column": 50 } } }, @@ -332,168 +307,186 @@ "optional": false, "loc": { "start": { - "line": 21, - "column": 5 + "line": 18, + "column": 26 }, "end": { - "line": 21, - "column": 16 + "line": 18, + "column": 50 } } }, - "arguments": [ - { - "type": "StringLiteral", - "value": "in foo_in_2", - "loc": { - "start": { - "line": 21, - "column": 17 - }, - "end": { - "line": 21, - "column": 30 - } - } - } - ], - "optional": false, "loc": { "start": { - "line": 21, + "line": 18, "column": 5 }, "end": { - "line": 21, - "column": 31 + "line": 18, + "column": 50 } } }, "loc": { "start": { - "line": 21, + "line": 18, "column": 5 }, "end": { - "line": 21, - "column": 32 + "line": 18, + "column": 50 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "foo_in_3", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 5 - }, - "end": { - "line": 22, - "column": 13 - } - } - }, - "arguments": [], - "optional": false, - "loc": { - "start": { - "line": 22, - "column": 5 - }, - "end": { - "line": 22, - "column": 15 - } - } + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "event", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 18, + "column": 10 + } + } + }, + "accessibility": "public", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "TSQualifiedName", + "left": { + "type": "Identifier", + "name": "x", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 12 }, - "loc": { - "start": { - "line": 22, - "column": 5 - }, - "end": { - "line": 22, - "column": 16 - } + "end": { + "line": 18, + "column": 13 } - }, - { - "type": "ReturnStatement", - "argument": { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 23, - "column": 12 - }, - "end": { - "line": 23, - "column": 13 - } - } + } + }, + "right": { + "type": "Identifier", + "name": "EventType", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 14 }, - "loc": { - "start": { - "line": 23, - "column": 5 - }, - "end": { - "line": 23, - "column": 14 - } + "end": { + "line": 18, + "column": 23 } } - ], + }, "loc": { "start": { - "line": 20, - "column": 33 + "line": 18, + "column": 12 }, "end": { - "line": 24, - "column": 2 + "line": 18, + "column": 25 } } }, "loc": { "start": { - "line": 20, - "column": 25 + "line": 18, + "column": 12 }, "end": { - "line": 24, - "column": 2 + "line": 18, + "column": 25 } } }, "loc": { "start": { - "line": 20, - "column": 25 + "line": 18, + "column": 12 }, "end": { - "line": 24, - "column": 2 + "line": 18, + "column": 25 } } }, - "overloads": [], + "definite": false, "decorators": [], "loc": { "start": { - "line": 20, - "column": 8 + "line": 18, + "column": 5 }, "end": { - "line": 24, - "column": 2 + "line": 18, + "column": 50 } } } @@ -527,7 +520,7 @@ "column": 1 }, "end": { - "line": 25, + "line": 19, "column": 1 } } diff --git a/ets2panda/test/parser/ets/import_tests/enum/import.sts b/ets2panda/test/parser/ets/import_tests/enum/import.sts new file mode 100644 index 0000000000000000000000000000000000000000..32287a37405aacb817e665c40a72df193cc13c56 --- /dev/null +++ b/ets2panda/test/parser/ets/import_tests/enum/import.sts @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as x from "./export" + +let event: x.EventType = x.EventType.END_DOCUMENT; diff --git a/ets2panda/test/parser/ets/import_tests/import_class_members_2.sts b/ets2panda/test/parser/ets/import_tests/import_class_members_2.sts deleted file mode 100644 index 90cb6aa0ec667d800f63ceefbec970f6b219d3d6..0000000000000000000000000000000000000000 --- a/ets2panda/test/parser/ets/import_tests/import_class_members_2.sts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import Enclosing.* from "import_tests/modules/module"; -import Enclosing.Nested.* from "import_tests/modules/module"; - -let a = fieldA; -let b = fieldB; -let c = fieldC; diff --git a/ets2panda/test/parser/ets/import_tests/import_name_conflict_1.sts b/ets2panda/test/parser/ets/import_tests/import_name_conflict_1.sts index 2ce98bc63712ec247c7ac2c25ff3884c9f61e191..387dddd5cc1c99234db48eaf3f1bdb2c0cd4dace 100644 --- a/ets2panda/test/parser/ets/import_tests/import_name_conflict_1.sts +++ b/ets2panda/test/parser/ets/import_tests/import_name_conflict_1.sts @@ -13,7 +13,7 @@ * limitations under the License. */ -import dbl as floatingPointNumber from "import_tests/packages"; -import flt as floatingPointNumber from "import_tests/packages"; +import { dbl as floatingPointNumber} from "import_tests/packages"; +import { flt as floatingPointNumber} from "import_tests/packages"; // Throw error because floatingPointNumber is for multiple value. diff --git a/ets2panda/test/parser/ets/import_tests/import_name_conflict_3.sts b/ets2panda/test/parser/ets/import_tests/import_name_conflict_3.sts deleted file mode 100644 index 8abc027da3abb83fb2559b53639ed7e48f852935..0000000000000000000000000000000000000000 --- a/ets2panda/test/parser/ets/import_tests/import_name_conflict_3.sts +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import * from "import_tests/packages"; -import * from "import_tests/modules/module"; - -// Throw error: "dbl" is defined by "package/package_module_1.sts" and "modules/module.sts". -let x = dbl; diff --git a/ets2panda/test/parser/ets/import_tests/import_nested_class_3.sts b/ets2panda/test/parser/ets/import_tests/import_nested_class_3.sts deleted file mode 100644 index 33a630567c110f697d4c3a57ede9d060a3dea883..0000000000000000000000000000000000000000 --- a/ets2panda/test/parser/ets/import_tests/import_nested_class_3.sts +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import Enclosing.Nested as NESTED from "import_tests/modules/module"; - -let x = new NESTED(); diff --git a/ets2panda/test/parser/ets/import_tests/import_several_8.sts b/ets2panda/test/parser/ets/import_tests/import_several_8.sts deleted file mode 100644 index 4948676a83bb1237256d42e603cbc05bfb1a32e2..0000000000000000000000000000000000000000 --- a/ets2panda/test/parser/ets/import_tests/import_several_8.sts +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import dbl, flt, foo as Foo, * as Test, * from "import_tests/packages"; - -let a = Foo(dbl /* double based signature */ ); -let b = Foo(flt /* float based signature */); -let c = Test.foo(dbl /* double based signature */); -let d = Test.foo(flt /* float based signature */); -let e = Test.foo(Test.dbl /* double based signature */); -let f = Test.foo(Test.flt /* float based signature */); diff --git a/ets2panda/test/parser/ets/import_tests/type/import_type_1-expected.txt b/ets2panda/test/parser/ets/import_tests/type/import_type_1-expected.txt index 82700e59aa9294e80f85ba6ec2db242b6a26b434..29d73a26afc48fcaf8454f4966efa354c281a52f 100644 --- a/ets2panda/test/parser/ets/import_tests/type/import_type_1-expected.txt +++ b/ets2panda/test/parser/ets/import_tests/type/import_type_1-expected.txt @@ -300,4 +300,4 @@ } } } -SyntaxError: Cannot find imported element 'A' exported with alias [import_type_1.sts:16:9] +SyntaxError: Cannot find imported element 'A' [import_type_1.sts:16:9] diff --git a/ets2panda/test/parser/ets/import_tests/type/type_3-expected.txt b/ets2panda/test/parser/ets/import_tests/type/type_3-expected.txt index 7c42abd6031aec5cf05b70cb65b48cea42e845a2..a652c64308b33a89a33fb64d76142e320ace8444 100644 --- a/ets2panda/test/parser/ets/import_tests/type/type_3-expected.txt +++ b/ets2panda/test/parser/ets/import_tests/type/type_3-expected.txt @@ -1 +1 @@ -SyntaxError: Cannot redeclare exported variable 'foo' [type_3.sts:20:27] +SyntaxError: The given name 'foo' is already used in another export [type_3.sts:20:27] diff --git a/ets2panda/test/parser/ets/method_modifier_check_17-expected.txt b/ets2panda/test/parser/ets/method_modifier_check_17-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..bc376817ada9dcb4da89fc20b404d72285118974 --- /dev/null +++ b/ets2panda/test/parser/ets/method_modifier_check_17-expected.txt @@ -0,0 +1,1440 @@ +{ + "type": "Program", + "statements": [ + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 16 + }, + "end": { + "line": 16, + "column": 17 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "instance_method", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 2 + }, + "end": { + "line": 17, + "column": 17 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "instance_method", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 2 + }, + "end": { + "line": 17, + "column": 17 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "v", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Int", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 21 + }, + "end": { + "line": 17, + "column": 24 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 21 + }, + "end": { + "line": 17, + "column": 25 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 21 + }, + "end": { + "line": 17, + "column": 25 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 19 + }, + "end": { + "line": 17, + "column": 25 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 19 + }, + "end": { + "line": 17, + "column": 25 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 17, + "column": 27 + }, + "end": { + "line": 17, + "column": 31 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 17, + "column": 32 + }, + "end": { + "line": 17, + "column": 34 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 18 + }, + "end": { + "line": 17, + "column": 34 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 18 + }, + "end": { + "line": 17, + "column": 34 + } + } + }, + "overloads": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "instance_method", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 11 + }, + "end": { + "line": 18, + "column": 26 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "instance_method", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 11 + }, + "end": { + "line": 18, + "column": 26 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 18, + "column": 31 + }, + "end": { + "line": 18, + "column": 35 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 27 + }, + "end": { + "line": 18, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 27 + }, + "end": { + "line": 18, + "column": 27 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 2 + }, + "end": { + "line": 18, + "column": 27 + } + } + } + ], + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 2 + }, + "end": { + "line": 17, + "column": 34 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "constructor", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 19, + "column": 2 + }, + "end": { + "line": 19, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 16, + "column": 18 + }, + "end": { + "line": 19, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 10 + }, + "end": { + "line": 19, + "column": 2 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "Base", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 7 + }, + "end": { + "line": 20, + "column": 11 + } + } + }, + "superClass": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 20 + }, + "end": { + "line": 20, + "column": 21 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 20 + }, + "end": { + "line": 20, + "column": 23 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 20 + }, + "end": { + "line": 20, + "column": 23 + } + } + }, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "instance_method", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 2 + }, + "end": { + "line": 21, + "column": 17 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "instance_method", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 2 + }, + "end": { + "line": 21, + "column": 17 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "console", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 4 + }, + "end": { + "line": 22, + "column": 11 + } + } + }, + "property": { + "type": "Identifier", + "name": "log", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 12 + }, + "end": { + "line": 22, + "column": 15 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 22, + "column": 4 + }, + "end": { + "line": 22, + "column": 15 + } + } + }, + "arguments": [ + { + "type": "TemplateLiteral", + "expressions": [], + "quasis": [ + { + "type": "TemplateElement", + "value": { + "raw": "Base: instance_method() ...", + "cooked": "Base: instance_method() ..." + }, + "loc": { + "start": { + "line": 22, + "column": 17 + }, + "end": { + "line": 22, + "column": 44 + } + } + } + ], + "loc": { + "start": { + "line": 22, + "column": 16 + }, + "end": { + "line": 22, + "column": 45 + } + } + } + ], + "optional": false, + "loc": { + "start": { + "line": 22, + "column": 4 + }, + "end": { + "line": 22, + "column": 46 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 4 + }, + "end": { + "line": 22, + "column": 46 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "object": { + "type": "Super", + "loc": { + "start": { + "line": 23, + "column": 4 + }, + "end": { + "line": 23, + "column": 9 + } + } + }, + "property": { + "type": "Identifier", + "name": "instance_method", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 10 + }, + "end": { + "line": 23, + "column": 25 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 23, + "column": 4 + }, + "end": { + "line": 23, + "column": 25 + } + } + }, + "arguments": [ + { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 23, + "column": 26 + }, + "end": { + "line": 23, + "column": 27 + } + } + } + ], + "optional": false, + "loc": { + "start": { + "line": 23, + "column": 4 + }, + "end": { + "line": 23, + "column": 28 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 4 + }, + "end": { + "line": 23, + "column": 28 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "object": { + "type": "Super", + "loc": { + "start": { + "line": 24, + "column": 3 + }, + "end": { + "line": 24, + "column": 8 + } + } + }, + "property": { + "type": "Identifier", + "name": "instance_method", + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 9 + }, + "end": { + "line": 24, + "column": 24 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 24, + "column": 3 + }, + "end": { + "line": 24, + "column": 24 + } + } + }, + "arguments": [], + "optional": false, + "loc": { + "start": { + "line": 24, + "column": 3 + }, + "end": { + "line": 24, + "column": 26 + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 3 + }, + "end": { + "line": 24, + "column": 26 + } + } + } + ], + "loc": { + "start": { + "line": 21, + "column": 21 + }, + "end": { + "line": 25, + "column": 3 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 18 + }, + "end": { + "line": 25, + "column": 3 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 18 + }, + "end": { + "line": 25, + "column": 3 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 2 + }, + "end": { + "line": 25, + "column": 3 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "constructor", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 2 + }, + "end": { + "line": 26, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 20, + "column": 22 + }, + "end": { + "line": 26, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1 + }, + "end": { + "line": 26, + "column": 2 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ETSGLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "Identifier", + "name": "a", + "decorators": [], + "loc": { + "start": { + "line": 28, + "column": 5 + }, + "end": { + "line": 28, + "column": 6 + } + } + }, + "right": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Base", + "decorators": [], + "loc": { + "start": { + "line": 28, + "column": 16 + }, + "end": { + "line": 28, + "column": 20 + } + } + }, + "loc": { + "start": { + "line": 28, + "column": 16 + }, + "end": { + "line": 29, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 28, + "column": 16 + }, + "end": { + "line": 29, + "column": 2 + } + } + }, + "arguments": [], + "loc": { + "start": { + "line": 28, + "column": 12 + }, + "end": { + "line": 29, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 28, + "column": 5 + }, + "end": { + "line": 29, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 28, + "column": 5 + }, + "end": { + "line": 29, + "column": 2 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "a", + "decorators": [], + "loc": { + "start": { + "line": 29, + "column": 1 + }, + "end": { + "line": 29, + "column": 2 + } + } + }, + "property": { + "type": "Identifier", + "name": "instance_method", + "decorators": [], + "loc": { + "start": { + "line": 29, + "column": 3 + }, + "end": { + "line": 29, + "column": 18 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 29, + "column": 1 + }, + "end": { + "line": 29, + "column": 18 + } + } + }, + "arguments": [], + "optional": false, + "loc": { + "start": { + "line": 29, + "column": 1 + }, + "end": { + "line": 29, + "column": 21 + } + } + }, + "loc": { + "start": { + "line": 29, + "column": 1 + }, + "end": { + "line": 29, + "column": 21 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "a", + "decorators": [], + "loc": { + "start": { + "line": 28, + "column": 5 + }, + "end": { + "line": 28, + "column": 6 + } + } + }, + "accessibility": "public", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 28, + "column": 8 + }, + "end": { + "line": 28, + "column": 9 + } + } + }, + "loc": { + "start": { + "line": 28, + "column": 8 + }, + "end": { + "line": 28, + "column": 11 + } + } + }, + "loc": { + "start": { + "line": 28, + "column": 8 + }, + "end": { + "line": 28, + "column": 11 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 28, + "column": 5 + }, + "end": { + "line": 29, + "column": 2 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "main", + "decorators": [], + "loc": { + "start": { + "line": 31, + "column": 10 + }, + "end": { + "line": 31, + "column": 14 + } + } + }, + "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": 31, + "column": 10 + }, + "end": { + "line": 31, + "column": 14 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 31, + "column": 17 + }, + "end": { + "line": 31, + "column": 19 + } + } + }, + "loc": { + "start": { + "line": 31, + "column": 14 + }, + "end": { + "line": 31, + "column": 19 + } + } + }, + "loc": { + "start": { + "line": 31, + "column": 14 + }, + "end": { + "line": 31, + "column": 19 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 31, + "column": 1 + }, + "end": { + "line": 31, + "column": 19 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 32, + "column": 1 + } + } +} +TypeError: Cannot call abstract method! [method_modifier_check_17.sts:24:3] diff --git a/ets2panda/test/parser/ets/method_modifier_check_17.sts b/ets2panda/test/parser/ets/method_modifier_check_17.sts new file mode 100644 index 0000000000000000000000000000000000000000..d5e793a7f1b45c849d193d4d7af6b1c988b91649 --- /dev/null +++ b/ets2panda/test/parser/ets/method_modifier_check_17.sts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +abstract class A { + instance_method (v:Int): void {} + abstract instance_method (): void +} +class Base extends A { + instance_method () { + console.log(`Base: instance_method() ...`) + super.instance_method(1) + super.instance_method() // Should be CTE as instance_method() is abstract + } +} + +let a: A = new Base +a.instance_method () + +function main() {} diff --git a/ets2panda/test/parser/ets/optional-chaining-array-expected.txt b/ets2panda/test/parser/ets/optional-chaining-array-expected.txt index 9a02f3f966372bb2ef972f822f39abffa97c6cb2..2ce8e4469ee8510b2bc29f8a482a2238ae56b172 100644 --- a/ets2panda/test/parser/ets/optional-chaining-array-expected.txt +++ b/ets2panda/test/parser/ets/optional-chaining-array-expected.txt @@ -22,6 +22,100 @@ "superClass": null, "implements": [], "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "main", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, { "type": "MethodDefinition", "key": { @@ -91,51 +185,118 @@ } }, "right": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumberLiteral", - "value": 1, - "loc": { - "start": { - "line": 16, - "column": 26 - }, - "end": { - "line": 16, - "column": 27 + "type": "TSAsExpression", + "expression": { + "type": "ArrayExpression", + "elements": [ + { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 16, + "column": 26 + }, + "end": { + "line": 16, + "column": 27 + } + } + }, + { + "type": "NumberLiteral", + "value": 4, + "loc": { + "start": { + "line": 16, + "column": 29 + }, + "end": { + "line": 16, + "column": 30 + } + } + }, + { + "type": "NumberLiteral", + "value": 5, + "loc": { + "start": { + "line": 16, + "column": 32 + }, + "end": { + "line": 16, + "column": 33 + } } } - }, - { - "type": "NumberLiteral", - "value": 4, - "loc": { - "start": { - "line": 16, - "column": 29 + ], + "loc": { + "start": { + "line": 16, + "column": 25 + }, + "end": { + "line": 16, + "column": 34 + } + } + }, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Int", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 38 + }, + "end": { + "line": 16, + "column": 41 + } + } }, - "end": { - "line": 16, - "column": 30 + "loc": { + "start": { + "line": 16, + "column": 38 + }, + "end": { + "line": 16, + "column": 42 + } } - } - }, - { - "type": "NumberLiteral", - "value": 5, + }, "loc": { "start": { "line": 16, - "column": 32 + "column": 38 }, "end": { "line": 16, - "column": 33 + "column": 42 } } + }, + "loc": { + "start": { + "line": 16, + "column": 43 + }, + "end": { + "line": 16, + "column": 44 + } } - ], + }, "loc": { "start": { "line": 16, @@ -193,38 +354,195 @@ "type": "LogicalExpression", "operator": "??", "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "arr", - "decorators": [], - "loc": { - "start": { - "line": 17, - "column": 12 - }, - "end": { - "line": 17, - "column": 15 + "type": "BlockExpression", + "statements": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "gensym$_1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "init": { + "type": "Identifier", + "name": "arr", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 12 + }, + "end": { + "line": 17, + "column": 15 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 17, + "column": 12 + }, + "end": { + "line": 17, + "column": 33 + } } - } - }, - "property": { - "type": "NumberLiteral", - "value": 1, - "loc": { - "start": { - "line": 17, - "column": 18 + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "ConditionalExpression", + "test": { + "type": "BinaryExpression", + "operator": "==", + "left": { + "type": "Identifier", + "name": "gensym$_1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "right": { + "type": "NullLiteral", + "value": null, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "consequent": { + "type": "UndefinedLiteral", + "value": undefined, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "alternate": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "gensym$_1", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 12 + }, + "end": { + "line": 17, + "column": 20 + } + } + }, + "property": { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 17, + "column": 18 + }, + "end": { + "line": 17, + "column": 19 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 17, + "column": 12 + }, + "end": { + "line": 17, + "column": 20 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } }, - "end": { - "line": 17, - "column": 19 + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } } } - }, - "computed": true, - "optional": true, + ], "loc": { "start": { "line": 17, @@ -232,7 +550,7 @@ }, "end": { "line": 17, - "column": 20 + "column": 33 } } }, @@ -307,38 +625,195 @@ "type": "LogicalExpression", "operator": "??", "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "arr2", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 13 - }, - "end": { - "line": 20, - "column": 17 + "type": "BlockExpression", + "statements": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "gensym$_2", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "init": { + "type": "Identifier", + "name": "arr2", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 13 + }, + "end": { + "line": 20, + "column": 17 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 20, + "column": 13 + }, + "end": { + "line": 20, + "column": 38 + } } - } - }, - "property": { - "type": "NumberLiteral", - "value": 100, - "loc": { - "start": { - "line": 20, - "column": 20 + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "ConditionalExpression", + "test": { + "type": "BinaryExpression", + "operator": "==", + "left": { + "type": "Identifier", + "name": "gensym$_2", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "right": { + "type": "NullLiteral", + "value": null, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "consequent": { + "type": "UndefinedLiteral", + "value": undefined, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "alternate": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "gensym$_2", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 13 + }, + "end": { + "line": 20, + "column": 24 + } + } + }, + "property": { + "type": "NumberLiteral", + "value": 100, + "loc": { + "start": { + "line": 20, + "column": 20 + }, + "end": { + "line": 20, + "column": 23 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 20, + "column": 13 + }, + "end": { + "line": 20, + "column": 24 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } }, - "end": { - "line": 20, - "column": 23 + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } } } - }, - "computed": true, - "optional": true, + ], "loc": { "start": { "line": 20, @@ -346,7 +821,7 @@ }, "end": { "line": 20, - "column": 24 + "column": 38 } } }, @@ -468,15 +943,40 @@ "optional": false, "computed": false, "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Int", - "decorators": [], + "type": "ETSUnionType", + "types": [ + { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Int", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 10 + }, + "end": { + "line": 16, + "column": 13 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 10 + }, + "end": { + "line": 16, + "column": 14 + } + } + }, "loc": { "start": { "line": 16, @@ -484,32 +984,35 @@ }, "end": { "line": 16, - "column": 13 + "column": 14 } } }, "loc": { "start": { "line": 16, - "column": 10 + "column": 16 }, "end": { "line": 16, - "column": 14 + "column": 17 } } }, - "loc": { - "start": { - "line": 16, - "column": 10 - }, - "end": { - "line": 16, - "column": 14 + { + "type": "ETSNullType", + "loc": { + "start": { + "line": 16, + "column": 18 + }, + "end": { + "line": 16, + "column": 22 + } } } - }, + ], "loc": { "start": { "line": 16, @@ -517,7 +1020,7 @@ }, "end": { "line": 16, - "column": 17 + "column": 22 } } }, @@ -555,38 +1058,195 @@ "type": "LogicalExpression", "operator": "??", "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "arr", - "decorators": [], - "loc": { - "start": { - "line": 17, - "column": 12 - }, - "end": { - "line": 17, - "column": 15 + "type": "BlockExpression", + "statements": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "gensym$_3", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "init": { + "type": "Identifier", + "name": "arr", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 12 + }, + "end": { + "line": 17, + "column": 15 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 17, + "column": 12 + }, + "end": { + "line": 17, + "column": 33 + } } - } - }, - "property": { - "type": "NumberLiteral", - "value": 1, - "loc": { - "start": { - "line": 17, - "column": 18 + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "ConditionalExpression", + "test": { + "type": "BinaryExpression", + "operator": "==", + "left": { + "type": "Identifier", + "name": "gensym$_3", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "right": { + "type": "NullLiteral", + "value": null, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "consequent": { + "type": "UndefinedLiteral", + "value": undefined, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "alternate": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "gensym$_3", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 12 + }, + "end": { + "line": 17, + "column": 20 + } + } + }, + "property": { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 17, + "column": 18 + }, + "end": { + "line": 17, + "column": 19 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 17, + "column": 12 + }, + "end": { + "line": 17, + "column": 20 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } }, - "end": { - "line": 17, - "column": 19 + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } } } - }, - "computed": true, - "optional": true, + ], "loc": { "start": { "line": 17, @@ -594,7 +1254,7 @@ }, "end": { "line": 17, - "column": 20 + "column": 33 } } }, @@ -666,15 +1326,40 @@ "optional": false, "computed": false, "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], + "type": "ETSUnionType", + "types": [ + { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 19, + "column": 11 + }, + "end": { + "line": 19, + "column": 17 + } + } + }, + "loc": { + "start": { + "line": 19, + "column": 11 + }, + "end": { + "line": 19, + "column": 18 + } + } + }, "loc": { "start": { "line": 19, @@ -682,32 +1367,35 @@ }, "end": { "line": 19, - "column": 17 + "column": 18 } } }, "loc": { "start": { "line": 19, - "column": 11 + "column": 20 }, "end": { "line": 19, - "column": 18 + "column": 21 } } }, - "loc": { - "start": { - "line": 19, - "column": 11 - }, - "end": { - "line": 19, - "column": 18 + { + "type": "ETSNullType", + "loc": { + "start": { + "line": 19, + "column": 22 + }, + "end": { + "line": 19, + "column": 26 + } } } - }, + ], "loc": { "start": { "line": 19, @@ -715,7 +1403,7 @@ }, "end": { "line": 19, - "column": 21 + "column": 26 } } }, @@ -753,38 +1441,195 @@ "type": "LogicalExpression", "operator": "??", "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "arr2", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 13 - }, - "end": { - "line": 20, - "column": 17 + "type": "BlockExpression", + "statements": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "gensym$_4", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "init": { + "type": "Identifier", + "name": "arr2", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 13 + }, + "end": { + "line": 20, + "column": 17 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 20, + "column": 13 + }, + "end": { + "line": 20, + "column": 38 + } } - } - }, - "property": { - "type": "NumberLiteral", - "value": 100, - "loc": { - "start": { - "line": 20, - "column": 20 + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "ConditionalExpression", + "test": { + "type": "BinaryExpression", + "operator": "==", + "left": { + "type": "Identifier", + "name": "gensym$_4", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "right": { + "type": "NullLiteral", + "value": null, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "consequent": { + "type": "UndefinedLiteral", + "value": undefined, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "alternate": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "gensym$_4", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 13 + }, + "end": { + "line": 20, + "column": 24 + } + } + }, + "property": { + "type": "NumberLiteral", + "value": 100, + "loc": { + "start": { + "line": 20, + "column": 20 + }, + "end": { + "line": 20, + "column": 23 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 20, + "column": 13 + }, + "end": { + "line": 20, + "column": 24 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } }, - "end": { - "line": 20, - "column": 23 + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } } } - }, - "computed": true, - "optional": true, + ], "loc": { "start": { "line": 20, @@ -792,7 +1637,7 @@ }, "end": { "line": 20, - "column": 24 + "column": 38 } } }, diff --git a/ets2panda/test/parser/ets/optional-chaining-array.sts b/ets2panda/test/parser/ets/optional-chaining-array.sts index 4dd690c0ed4bf9716128993d24ee127d352d90a5..4283f0a1e6c271a383a07a5876e7753c2e2cd88a 100644 --- a/ets2panda/test/parser/ets/optional-chaining-array.sts +++ b/ets2panda/test/parser/ets/optional-chaining-array.sts @@ -13,7 +13,7 @@ * limitations under the License. */ -let arr: Int[] | null = [1, 4, 5]; +let arr: Int[] | null = [1, 4, 5] as Int[]; let test = arr?.[1] ?? "unknown"; let arr2: String[] | null; diff --git a/ets2panda/test/parser/ets/optional_chaining_invalid_property-expected.txt b/ets2panda/test/parser/ets/optional_chaining_invalid_property-expected.txt index 815657ca435fd14ec9f2d737a2d47ec72474a88d..9cc8f63ceeba9778f81dd69495d718c3af097a25 100644 --- a/ets2panda/test/parser/ets/optional_chaining_invalid_property-expected.txt +++ b/ets2panda/test/parser/ets/optional_chaining_invalid_property-expected.txt @@ -313,6 +313,100 @@ "superClass": null, "implements": [], "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "main", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, { "type": "MethodDefinition", "key": { @@ -485,43 +579,200 @@ } }, "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "dog", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 16 - }, - "end": { - "line": 26, - "column": 19 + "type": "BlockExpression", + "statements": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "gensym$_1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "init": { + "type": "Identifier", + "name": "dog", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 16 + }, + "end": { + "line": 26, + "column": 19 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 26, + "column": 5 + }, + "end": { + "line": 26, + "column": 29 + } } - } - }, - "property": { - "type": "Identifier", - "name": "hasSting", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 21 + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "ConditionalExpression", + "test": { + "type": "BinaryExpression", + "operator": "==", + "left": { + "type": "Identifier", + "name": "gensym$_1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "right": { + "type": "NullLiteral", + "value": null, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "consequent": { + "type": "UndefinedLiteral", + "value": undefined, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "alternate": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "gensym$_1", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 16 + }, + "end": { + "line": 26, + "column": 29 + } + } + }, + "property": { + "type": "Identifier", + "name": "hasSting", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 21 + }, + "end": { + "line": 26, + "column": 29 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 26, + "column": 16 + }, + "end": { + "line": 26, + "column": 29 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } }, - "end": { - "line": 26, - "column": 29 + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } } } - }, - "computed": false, - "optional": true, + ], "loc": { "start": { "line": 26, - "column": 16 + "column": 5 }, "end": { "line": 26, @@ -693,43 +944,200 @@ } }, "value": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "dog", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 16 - }, - "end": { - "line": 26, - "column": 19 + "type": "BlockExpression", + "statements": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "gensym$_2", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "init": { + "type": "Identifier", + "name": "dog", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 16 + }, + "end": { + "line": 26, + "column": 19 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 26, + "column": 5 + }, + "end": { + "line": 26, + "column": 29 + } } - } - }, - "property": { - "type": "Identifier", - "name": "hasSting", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 21 + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "ConditionalExpression", + "test": { + "type": "BinaryExpression", + "operator": "==", + "left": { + "type": "Identifier", + "name": "gensym$_2", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "right": { + "type": "NullLiteral", + "value": null, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "consequent": { + "type": "UndefinedLiteral", + "value": undefined, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "alternate": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "gensym$_2", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 16 + }, + "end": { + "line": 26, + "column": 29 + } + } + }, + "property": { + "type": "Identifier", + "name": "hasSting", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 21 + }, + "end": { + "line": 26, + "column": 29 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 26, + "column": 16 + }, + "end": { + "line": 26, + "column": 29 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } }, - "end": { - "line": 26, - "column": 29 + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } } } - }, - "computed": false, - "optional": true, + ], "loc": { "start": { "line": 26, - "column": 16 + "column": 5 }, "end": { "line": 26, diff --git a/ets2panda/test/parser/ets/optional_chaining_nested_property-expected.txt b/ets2panda/test/parser/ets/optional_chaining_nested_property-expected.txt index 120efe8f89d47fbfbf157fee6ccded238588f2eb..2bd767406ef813745369efee549fe3c7bb5847a5 100644 --- a/ets2panda/test/parser/ets/optional_chaining_nested_property-expected.txt +++ b/ets2panda/test/parser/ets/optional_chaining_nested_property-expected.txt @@ -390,6 +390,100 @@ "superClass": null, "implements": [], "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "main", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, { "type": "MethodDefinition", "key": { @@ -562,73 +656,387 @@ } }, "right": { - "type": "MemberExpression", - "object": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "car", - "decorators": [], + "type": "BlockExpression", + "statements": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "gensym$_2", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "init": { + "type": "BlockExpression", + "statements": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "gensym$_1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "init": { + "type": "Identifier", + "name": "car", + "decorators": [], + "loc": { + "start": { + "line": 27, + "column": 21 + }, + "end": { + "line": 27, + "column": 24 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 27, + "column": 21 + }, + "end": { + "line": 27, + "column": 41 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "ConditionalExpression", + "test": { + "type": "BinaryExpression", + "operator": "==", + "left": { + "type": "Identifier", + "name": "gensym$_1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "right": { + "type": "NullLiteral", + "value": null, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "consequent": { + "type": "UndefinedLiteral", + "value": undefined, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "alternate": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "gensym$_1", + "decorators": [], + "loc": { + "start": { + "line": 27, + "column": 21 + }, + "end": { + "line": 27, + "column": 33 + } + } + }, + "property": { + "type": "Identifier", + "name": "company", + "decorators": [], + "loc": { + "start": { + "line": 27, + "column": 26 + }, + "end": { + "line": 27, + "column": 33 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 27, + "column": 21 + }, + "end": { + "line": 27, + "column": 33 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + } + ], + "loc": { + "start": { + "line": 27, + "column": 21 + }, + "end": { + "line": 27, + "column": 41 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + } + ], + "kind": "let", "loc": { "start": { "line": 27, - "column": 21 + "column": 5 }, "end": { "line": 27, - "column": 24 + "column": 41 } } }, - "property": { - "type": "Identifier", - "name": "company", - "decorators": [], + { + "type": "ExpressionStatement", + "expression": { + "type": "ConditionalExpression", + "test": { + "type": "BinaryExpression", + "operator": "==", + "left": { + "type": "Identifier", + "name": "gensym$_2", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "right": { + "type": "NullLiteral", + "value": null, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "consequent": { + "type": "UndefinedLiteral", + "value": undefined, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "alternate": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "gensym$_2", + "decorators": [], + "loc": { + "start": { + "line": 27, + "column": 21 + }, + "end": { + "line": 27, + "column": 41 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 27, + "column": 35 + }, + "end": { + "line": 27, + "column": 41 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 27, + "column": 21 + }, + "end": { + "line": 27, + "column": 41 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, "loc": { "start": { - "line": 27, - "column": 26 + "line": 1, + "column": 3 }, "end": { - "line": 27, - "column": 33 + "line": 1, + "column": 3 } } - }, - "computed": false, - "optional": true, - "loc": { - "start": { - "line": 27, - "column": 21 - }, - "end": { - "line": 27, - "column": 33 - } - } - }, - "property": { - "type": "Identifier", - "name": "length", - "decorators": [], - "loc": { - "start": { - "line": 27, - "column": 35 - }, - "end": { - "line": 27, - "column": 41 - } } - }, - "computed": false, - "optional": true, + ], "loc": { "start": { "line": 27, - "column": 21 + "column": 5 }, "end": { "line": 27, @@ -800,73 +1208,387 @@ } }, "value": { - "type": "MemberExpression", - "object": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "car", - "decorators": [], + "type": "BlockExpression", + "statements": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "gensym$_4", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "init": { + "type": "BlockExpression", + "statements": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "gensym$_3", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "init": { + "type": "Identifier", + "name": "car", + "decorators": [], + "loc": { + "start": { + "line": 27, + "column": 21 + }, + "end": { + "line": 27, + "column": 24 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 27, + "column": 21 + }, + "end": { + "line": 27, + "column": 41 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "ConditionalExpression", + "test": { + "type": "BinaryExpression", + "operator": "==", + "left": { + "type": "Identifier", + "name": "gensym$_3", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "right": { + "type": "NullLiteral", + "value": null, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "consequent": { + "type": "UndefinedLiteral", + "value": undefined, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "alternate": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "gensym$_3", + "decorators": [], + "loc": { + "start": { + "line": 27, + "column": 21 + }, + "end": { + "line": 27, + "column": 33 + } + } + }, + "property": { + "type": "Identifier", + "name": "company", + "decorators": [], + "loc": { + "start": { + "line": 27, + "column": 26 + }, + "end": { + "line": 27, + "column": 33 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 27, + "column": 21 + }, + "end": { + "line": 27, + "column": 33 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + } + ], + "loc": { + "start": { + "line": 27, + "column": 21 + }, + "end": { + "line": 27, + "column": 41 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + } + ], + "kind": "let", "loc": { "start": { "line": 27, - "column": 21 + "column": 5 }, "end": { "line": 27, - "column": 24 + "column": 41 } } }, - "property": { - "type": "Identifier", - "name": "company", - "decorators": [], + { + "type": "ExpressionStatement", + "expression": { + "type": "ConditionalExpression", + "test": { + "type": "BinaryExpression", + "operator": "==", + "left": { + "type": "Identifier", + "name": "gensym$_4", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "right": { + "type": "NullLiteral", + "value": null, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "consequent": { + "type": "UndefinedLiteral", + "value": undefined, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "alternate": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "gensym$_4", + "decorators": [], + "loc": { + "start": { + "line": 27, + "column": 21 + }, + "end": { + "line": 27, + "column": 41 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 27, + "column": 35 + }, + "end": { + "line": 27, + "column": 41 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 27, + "column": 21 + }, + "end": { + "line": 27, + "column": 41 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, "loc": { "start": { - "line": 27, - "column": 26 + "line": 1, + "column": 3 }, "end": { - "line": 27, - "column": 33 + "line": 1, + "column": 3 } } - }, - "computed": false, - "optional": true, - "loc": { - "start": { - "line": 27, - "column": 21 - }, - "end": { - "line": 27, - "column": 33 - } } - }, - "property": { - "type": "Identifier", - "name": "length", - "decorators": [], - "loc": { - "start": { - "line": 27, - "column": 35 - }, - "end": { - "line": 27, - "column": 41 - } - } - }, - "computed": false, - "optional": true, + ], "loc": { "start": { "line": 27, - "column": 21 + "column": 5 }, "end": { "line": 27, diff --git a/ets2panda/test/parser/ets/optional_chaining_object_property-expected.txt b/ets2panda/test/parser/ets/optional_chaining_object_property-expected.txt index c97274831d075f813bb2affcc45700db686fe31f..8a7d890e947dc9b2df4fcaeb13c23d087c030fd0 100644 --- a/ets2panda/test/parser/ets/optional_chaining_object_property-expected.txt +++ b/ets2panda/test/parser/ets/optional_chaining_object_property-expected.txt @@ -313,6 +313,100 @@ "superClass": null, "implements": [], "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "main", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, { "type": "MethodDefinition", "key": { @@ -488,39 +582,196 @@ "type": "LogicalExpression", "operator": "??", "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "dog", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 12 - }, - "end": { - "line": 26, - "column": 15 + "type": "BlockExpression", + "statements": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "gensym$_1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "init": { + "type": "Identifier", + "name": "dog", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 12 + }, + "end": { + "line": 26, + "column": 15 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 26, + "column": 12 + }, + "end": { + "line": 26, + "column": 32 + } } - } - }, - "property": { - "type": "Identifier", - "name": "name", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 17 + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "ConditionalExpression", + "test": { + "type": "BinaryExpression", + "operator": "==", + "left": { + "type": "Identifier", + "name": "gensym$_1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "right": { + "type": "NullLiteral", + "value": null, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "consequent": { + "type": "UndefinedLiteral", + "value": undefined, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "alternate": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "gensym$_1", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 12 + }, + "end": { + "line": 26, + "column": 21 + } + } + }, + "property": { + "type": "Identifier", + "name": "name", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 17 + }, + "end": { + "line": 26, + "column": 21 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 26, + "column": 12 + }, + "end": { + "line": 26, + "column": 21 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } }, - "end": { - "line": 26, - "column": 21 + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } } } - }, - "computed": false, - "optional": true, + ], "loc": { "start": { "line": 26, @@ -528,7 +779,7 @@ }, "end": { "line": 26, - "column": 21 + "column": 32 } } }, @@ -603,39 +854,196 @@ "type": "LogicalExpression", "operator": "??", "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "dog", - "decorators": [], - "loc": { - "start": { - "line": 27, - "column": 21 - }, - "end": { - "line": 27, - "column": 24 + "type": "BlockExpression", + "statements": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "gensym$_2", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "init": { + "type": "Identifier", + "name": "dog", + "decorators": [], + "loc": { + "start": { + "line": 27, + "column": 21 + }, + "end": { + "line": 27, + "column": 24 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 27, + "column": 21 + }, + "end": { + "line": 27, + "column": 35 + } } - } - }, - "property": { - "type": "Identifier", - "name": "legs", - "decorators": [], - "loc": { - "start": { - "line": 27, - "column": 26 + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "ConditionalExpression", + "test": { + "type": "BinaryExpression", + "operator": "==", + "left": { + "type": "Identifier", + "name": "gensym$_2", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "right": { + "type": "NullLiteral", + "value": null, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "consequent": { + "type": "UndefinedLiteral", + "value": undefined, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "alternate": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "gensym$_2", + "decorators": [], + "loc": { + "start": { + "line": 27, + "column": 21 + }, + "end": { + "line": 27, + "column": 30 + } + } + }, + "property": { + "type": "Identifier", + "name": "legs", + "decorators": [], + "loc": { + "start": { + "line": 27, + "column": 26 + }, + "end": { + "line": 27, + "column": 30 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 27, + "column": 21 + }, + "end": { + "line": 27, + "column": 30 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } }, - "end": { - "line": 27, - "column": 30 + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } } } - }, - "computed": false, - "optional": true, + ], "loc": { "start": { "line": 27, @@ -643,7 +1051,7 @@ }, "end": { "line": 27, - "column": 30 + "column": 35 } } }, @@ -839,39 +1247,196 @@ "type": "LogicalExpression", "operator": "??", "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "dog", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 12 - }, - "end": { - "line": 26, - "column": 15 + "type": "BlockExpression", + "statements": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "gensym$_3", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "init": { + "type": "Identifier", + "name": "dog", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 12 + }, + "end": { + "line": 26, + "column": 15 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 26, + "column": 12 + }, + "end": { + "line": 26, + "column": 32 + } } - } - }, - "property": { - "type": "Identifier", - "name": "name", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 17 + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "ConditionalExpression", + "test": { + "type": "BinaryExpression", + "operator": "==", + "left": { + "type": "Identifier", + "name": "gensym$_3", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "right": { + "type": "NullLiteral", + "value": null, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "consequent": { + "type": "UndefinedLiteral", + "value": undefined, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } + }, + "alternate": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "gensym$_3", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 12 + }, + "end": { + "line": 26, + "column": 21 + } + } + }, + "property": { + "type": "Identifier", + "name": "name", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 17 + }, + "end": { + "line": 26, + "column": 21 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 26, + "column": 12 + }, + "end": { + "line": 26, + "column": 21 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } + } }, - "end": { - "line": 26, - "column": 21 + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 3 + } } } - }, - "computed": false, - "optional": true, + ], "loc": { "start": { "line": 26, @@ -879,7 +1444,7 @@ }, "end": { "line": 26, - "column": 21 + "column": 32 } } }, diff --git a/ets2panda/test/parser/ets/recursive_import/case_0/foo2__module-expected.txt b/ets2panda/test/parser/ets/recursive_import/case_0/foo2__module-expected.txt deleted file mode 100644 index 0066ab9929f7c70f6c8425b35194c65e8c68fc66..0000000000000000000000000000000000000000 --- a/ets2panda/test/parser/ets/recursive_import/case_0/foo2__module-expected.txt +++ /dev/null @@ -1,424 +0,0 @@ -{ - "type": "Program", - "statements": [ - { - "type": "ImportDeclaration", - "source": { - "type": "StringLiteral", - "value": "./main__foo1_as__module", - "loc": { - "start": { - "line": 16, - "column": 17 - }, - "end": { - "line": 16, - "column": 42 - } - } - }, - "specifiers": [ - { - "type": "ImportSpecifier", - "local": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 9 - }, - "end": { - "line": 16, - "column": 10 - } - } - }, - "imported": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 9 - }, - "end": { - "line": 16, - "column": 10 - } - } - }, - "loc": { - "start": { - "line": 16, - "column": 9 - }, - "end": { - "line": 16, - "column": 10 - } - } - } - ], - "loc": { - "start": { - "line": 16, - "column": 1 - }, - "end": { - "line": 16, - "column": 42 - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "ETSGLOBAL", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "foo", - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 17 - }, - "end": { - "line": 18, - "column": 20 - } - } - }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "foo", - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 17 - }, - "end": { - "line": 18, - "column": 20 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "a", - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 24 - }, - "end": { - "line": 18, - "column": 25 - } - } - }, - "loc": { - "start": { - "line": 18, - "column": 24 - }, - "end": { - "line": 18, - "column": 26 - } - } - }, - "loc": { - "start": { - "line": 18, - "column": 24 - }, - "end": { - "line": 18, - "column": 26 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 21 - }, - "end": { - "line": 18, - "column": 26 - } - } - }, - "loc": { - "start": { - "line": 18, - "column": 21 - }, - "end": { - "line": 18, - "column": 26 - } - } - } - ], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 18, - "column": 28 - }, - "end": { - "line": 18, - "column": 31 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "console", - "decorators": [], - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 12 - } - } - }, - "property": { - "type": "Identifier", - "name": "log", - "decorators": [], - "loc": { - "start": { - "line": 19, - "column": 13 - }, - "end": { - "line": 19, - "column": 16 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 16 - } - } - }, - "arguments": [ - { - "type": "StringLiteral", - "value": "in foo", - "loc": { - "start": { - "line": 19, - "column": 17 - }, - "end": { - "line": 19, - "column": 25 - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 26 - } - } - }, - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 27 - } - } - }, - { - "type": "ReturnStatement", - "argument": { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 20, - "column": 12 - }, - "end": { - "line": 20, - "column": 13 - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 5 - }, - "end": { - "line": 20, - "column": 14 - } - } - } - ], - "loc": { - "start": { - "line": 18, - "column": 32 - }, - "end": { - "line": 21, - "column": 2 - } - } - }, - "loc": { - "start": { - "line": 18, - "column": 20 - }, - "end": { - "line": 21, - "column": 2 - } - } - }, - "loc": { - "start": { - "line": 18, - "column": 20 - }, - "end": { - "line": 21, - "column": 2 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 8 - }, - "end": { - "line": 21, - "column": 2 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 22, - "column": 1 - } - } -} diff --git a/ets2panda/test/parser/ets/recursive_import/case_0/foo2__module.sts b/ets2panda/test/parser/ets/recursive_import/case_0/foo2__module.sts deleted file mode 100644 index 0ab31c2b366c9dde2383fe782eca202f9c559835..0000000000000000000000000000000000000000 --- a/ets2panda/test/parser/ets/recursive_import/case_0/foo2__module.sts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import {A} from "./main__foo1_as__module" - -export function foo(a: A): int { - console.log("in foo"); - return 0; -} diff --git a/ets2panda/test/parser/ets/recursive_import/case_1_fail_not_called_w_module/foo2__module-expected.txt b/ets2panda/test/parser/ets/recursive_import/case_1_fail_not_called_w_module/foo2__module-expected.txt deleted file mode 100644 index b505646cc5d1fd0063344f2ca9b33a38654aa324..0000000000000000000000000000000000000000 --- a/ets2panda/test/parser/ets/recursive_import/case_1_fail_not_called_w_module/foo2__module-expected.txt +++ /dev/null @@ -1,424 +0,0 @@ -{ - "type": "Program", - "statements": [ - { - "type": "ImportDeclaration", - "source": { - "type": "StringLiteral", - "value": "./main__foo1", - "loc": { - "start": { - "line": 16, - "column": 17 - }, - "end": { - "line": 16, - "column": 31 - } - } - }, - "specifiers": [ - { - "type": "ImportSpecifier", - "local": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 9 - }, - "end": { - "line": 16, - "column": 10 - } - } - }, - "imported": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 9 - }, - "end": { - "line": 16, - "column": 10 - } - } - }, - "loc": { - "start": { - "line": 16, - "column": 9 - }, - "end": { - "line": 16, - "column": 10 - } - } - } - ], - "loc": { - "start": { - "line": 16, - "column": 1 - }, - "end": { - "line": 16, - "column": 31 - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "ETSGLOBAL", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "foo", - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 17 - }, - "end": { - "line": 18, - "column": 20 - } - } - }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "foo", - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 17 - }, - "end": { - "line": 18, - "column": 20 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "a", - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 24 - }, - "end": { - "line": 18, - "column": 25 - } - } - }, - "loc": { - "start": { - "line": 18, - "column": 24 - }, - "end": { - "line": 18, - "column": 26 - } - } - }, - "loc": { - "start": { - "line": 18, - "column": 24 - }, - "end": { - "line": 18, - "column": 26 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 21 - }, - "end": { - "line": 18, - "column": 26 - } - } - }, - "loc": { - "start": { - "line": 18, - "column": 21 - }, - "end": { - "line": 18, - "column": 26 - } - } - } - ], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 18, - "column": 28 - }, - "end": { - "line": 18, - "column": 31 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "console", - "decorators": [], - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 12 - } - } - }, - "property": { - "type": "Identifier", - "name": "log", - "decorators": [], - "loc": { - "start": { - "line": 19, - "column": 13 - }, - "end": { - "line": 19, - "column": 16 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 16 - } - } - }, - "arguments": [ - { - "type": "StringLiteral", - "value": "in foo", - "loc": { - "start": { - "line": 19, - "column": 17 - }, - "end": { - "line": 19, - "column": 25 - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 26 - } - } - }, - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 27 - } - } - }, - { - "type": "ReturnStatement", - "argument": { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 20, - "column": 12 - }, - "end": { - "line": 20, - "column": 13 - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 5 - }, - "end": { - "line": 20, - "column": 14 - } - } - } - ], - "loc": { - "start": { - "line": 18, - "column": 32 - }, - "end": { - "line": 21, - "column": 2 - } - } - }, - "loc": { - "start": { - "line": 18, - "column": 20 - }, - "end": { - "line": 21, - "column": 2 - } - } - }, - "loc": { - "start": { - "line": 18, - "column": 20 - }, - "end": { - "line": 21, - "column": 2 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 8 - }, - "end": { - "line": 21, - "column": 2 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 22, - "column": 1 - } - } -} diff --git a/ets2panda/test/parser/ets/recursive_import/case_1_fail_not_called_w_module/main__foo1-expected.txt b/ets2panda/test/parser/ets/recursive_import/case_1_fail_not_called_w_module/main__foo1-expected.txt deleted file mode 100644 index 3c204fa1e96450b3125bde11021bf114cceed9d4..0000000000000000000000000000000000000000 --- a/ets2panda/test/parser/ets/recursive_import/case_1_fail_not_called_w_module/main__foo1-expected.txt +++ /dev/null @@ -1 +0,0 @@ -SyntaxError: Please compile `main__foo1.sts` with `--ets-module` option. It is being imported by another file. [foo2__module.sts:16:17] diff --git a/ets2panda/test/parser/ets/recursive_import/case_2_3-sources-in-circle/foo2__module.sts b/ets2panda/test/parser/ets/recursive_import/case_2_3-sources-in-circle/foo2__module.sts deleted file mode 100644 index cb9236d125862eb505374fb2b9f69cd2fd6a382f..0000000000000000000000000000000000000000 --- a/ets2panda/test/parser/ets/recursive_import/case_2_3-sources-in-circle/foo2__module.sts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import {A} from "./main__foo1_as__module" - -export function foo_in_2(): int { - console.log("in foo_in_2"); - return 0; -} diff --git a/ets2panda/test/parser/ets/recursive_import/case_2_3-sources-in-circle/foo3__module-expected.txt b/ets2panda/test/parser/ets/recursive_import/case_2_3-sources-in-circle/foo3__module-expected.txt deleted file mode 100644 index b0338509f06711db3977b09dfc7ecaf52a257f85..0000000000000000000000000000000000000000 --- a/ets2panda/test/parser/ets/recursive_import/case_2_3-sources-in-circle/foo3__module-expected.txt +++ /dev/null @@ -1,397 +0,0 @@ -{ - "type": "Program", - "statements": [ - { - "type": "ImportDeclaration", - "source": { - "type": "StringLiteral", - "value": "./foo2__module", - "loc": { - "start": { - "line": 16, - "column": 24 - }, - "end": { - "line": 16, - "column": 40 - } - } - }, - "specifiers": [ - { - "type": "ImportSpecifier", - "local": { - "type": "Identifier", - "name": "foo_in_2", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 9 - }, - "end": { - "line": 16, - "column": 17 - } - } - }, - "imported": { - "type": "Identifier", - "name": "foo_in_2", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 9 - }, - "end": { - "line": 16, - "column": 17 - } - } - }, - "loc": { - "start": { - "line": 16, - "column": 9 - }, - "end": { - "line": 16, - "column": 17 - } - } - } - ], - "loc": { - "start": { - "line": 16, - "column": 1 - }, - "end": { - "line": 16, - "column": 40 - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "ETSGLOBAL", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "foo_in_3", - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 17 - }, - "end": { - "line": 18, - "column": 25 - } - } - }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "foo_in_3", - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 17 - }, - "end": { - "line": 18, - "column": 25 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 18, - "column": 29 - }, - "end": { - "line": 18, - "column": 32 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "console", - "decorators": [], - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 12 - } - } - }, - "property": { - "type": "Identifier", - "name": "log", - "decorators": [], - "loc": { - "start": { - "line": 19, - "column": 13 - }, - "end": { - "line": 19, - "column": 16 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 16 - } - } - }, - "arguments": [ - { - "type": "StringLiteral", - "value": "in foo_in_3", - "loc": { - "start": { - "line": 19, - "column": 17 - }, - "end": { - "line": 19, - "column": 30 - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 31 - } - } - }, - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 32 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "foo_in_2", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 5 - }, - "end": { - "line": 20, - "column": 13 - } - } - }, - "arguments": [], - "optional": false, - "loc": { - "start": { - "line": 20, - "column": 5 - }, - "end": { - "line": 20, - "column": 15 - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 5 - }, - "end": { - "line": 20, - "column": 16 - } - } - }, - { - "type": "ReturnStatement", - "argument": { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 21, - "column": 12 - }, - "end": { - "line": 21, - "column": 13 - } - } - }, - "loc": { - "start": { - "line": 21, - "column": 5 - }, - "end": { - "line": 21, - "column": 14 - } - } - } - ], - "loc": { - "start": { - "line": 18, - "column": 33 - }, - "end": { - "line": 22, - "column": 2 - } - } - }, - "loc": { - "start": { - "line": 18, - "column": 25 - }, - "end": { - "line": 22, - "column": 2 - } - } - }, - "loc": { - "start": { - "line": 18, - "column": 25 - }, - "end": { - "line": 22, - "column": 2 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 8 - }, - "end": { - "line": 22, - "column": 2 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 23, - "column": 1 - } - } -} diff --git a/ets2panda/test/parser/ets/recursive_import/case_2_3-sources-in-circle/foo3__module.sts b/ets2panda/test/parser/ets/recursive_import/case_2_3-sources-in-circle/foo3__module.sts deleted file mode 100644 index e3f5710b25aede52f3e5a93305fc720cc83e4653..0000000000000000000000000000000000000000 --- a/ets2panda/test/parser/ets/recursive_import/case_2_3-sources-in-circle/foo3__module.sts +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import {foo_in_2} from "./foo2__module" - -export function foo_in_3(): int { - console.log("in foo_in_3"); - foo_in_2(); - return 0; -} diff --git a/ets2panda/test/parser/ets/recursive_import/case_3_3-sources-in-circle-fail-no-ets-module-compile/foo2__module.sts b/ets2panda/test/parser/ets/recursive_import/case_3_3-sources-in-circle-fail-no-ets-module-compile/foo2__module.sts deleted file mode 100644 index 99a8034055dd8080fd0ad4c75ed5138d67457a8e..0000000000000000000000000000000000000000 --- a/ets2panda/test/parser/ets/recursive_import/case_3_3-sources-in-circle-fail-no-ets-module-compile/foo2__module.sts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import {A} from "./main__foo1" - -export function foo_in_2(): int { - console.log("in foo_in_2"); - return 0; -} diff --git a/ets2panda/test/parser/ets/recursive_import/case_3_3-sources-in-circle-fail-no-ets-module-compile/foo3__module-expected.txt b/ets2panda/test/parser/ets/recursive_import/case_3_3-sources-in-circle-fail-no-ets-module-compile/foo3__module-expected.txt deleted file mode 100644 index b0338509f06711db3977b09dfc7ecaf52a257f85..0000000000000000000000000000000000000000 --- a/ets2panda/test/parser/ets/recursive_import/case_3_3-sources-in-circle-fail-no-ets-module-compile/foo3__module-expected.txt +++ /dev/null @@ -1,397 +0,0 @@ -{ - "type": "Program", - "statements": [ - { - "type": "ImportDeclaration", - "source": { - "type": "StringLiteral", - "value": "./foo2__module", - "loc": { - "start": { - "line": 16, - "column": 24 - }, - "end": { - "line": 16, - "column": 40 - } - } - }, - "specifiers": [ - { - "type": "ImportSpecifier", - "local": { - "type": "Identifier", - "name": "foo_in_2", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 9 - }, - "end": { - "line": 16, - "column": 17 - } - } - }, - "imported": { - "type": "Identifier", - "name": "foo_in_2", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 9 - }, - "end": { - "line": 16, - "column": 17 - } - } - }, - "loc": { - "start": { - "line": 16, - "column": 9 - }, - "end": { - "line": 16, - "column": 17 - } - } - } - ], - "loc": { - "start": { - "line": 16, - "column": 1 - }, - "end": { - "line": 16, - "column": 40 - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "ETSGLOBAL", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "foo_in_3", - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 17 - }, - "end": { - "line": 18, - "column": 25 - } - } - }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "foo_in_3", - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 17 - }, - "end": { - "line": 18, - "column": 25 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 18, - "column": 29 - }, - "end": { - "line": 18, - "column": 32 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "console", - "decorators": [], - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 12 - } - } - }, - "property": { - "type": "Identifier", - "name": "log", - "decorators": [], - "loc": { - "start": { - "line": 19, - "column": 13 - }, - "end": { - "line": 19, - "column": 16 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 16 - } - } - }, - "arguments": [ - { - "type": "StringLiteral", - "value": "in foo_in_3", - "loc": { - "start": { - "line": 19, - "column": 17 - }, - "end": { - "line": 19, - "column": 30 - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 31 - } - } - }, - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 32 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "foo_in_2", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 5 - }, - "end": { - "line": 20, - "column": 13 - } - } - }, - "arguments": [], - "optional": false, - "loc": { - "start": { - "line": 20, - "column": 5 - }, - "end": { - "line": 20, - "column": 15 - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 5 - }, - "end": { - "line": 20, - "column": 16 - } - } - }, - { - "type": "ReturnStatement", - "argument": { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 21, - "column": 12 - }, - "end": { - "line": 21, - "column": 13 - } - } - }, - "loc": { - "start": { - "line": 21, - "column": 5 - }, - "end": { - "line": 21, - "column": 14 - } - } - } - ], - "loc": { - "start": { - "line": 18, - "column": 33 - }, - "end": { - "line": 22, - "column": 2 - } - } - }, - "loc": { - "start": { - "line": 18, - "column": 25 - }, - "end": { - "line": 22, - "column": 2 - } - } - }, - "loc": { - "start": { - "line": 18, - "column": 25 - }, - "end": { - "line": 22, - "column": 2 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 8 - }, - "end": { - "line": 22, - "column": 2 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 23, - "column": 1 - } - } -} diff --git a/ets2panda/test/parser/ets/recursive_import/case_3_3-sources-in-circle-fail-no-ets-module-compile/foo3__module.sts b/ets2panda/test/parser/ets/recursive_import/case_3_3-sources-in-circle-fail-no-ets-module-compile/foo3__module.sts deleted file mode 100644 index e3f5710b25aede52f3e5a93305fc720cc83e4653..0000000000000000000000000000000000000000 --- a/ets2panda/test/parser/ets/recursive_import/case_3_3-sources-in-circle-fail-no-ets-module-compile/foo3__module.sts +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import {foo_in_2} from "./foo2__module" - -export function foo_in_3(): int { - console.log("in foo_in_3"); - foo_in_2(); - return 0; -} diff --git a/ets2panda/test/parser/ets/recursive_import/case_3_3-sources-in-circle-fail-no-ets-module-compile/main__foo1-expected.txt b/ets2panda/test/parser/ets/recursive_import/case_3_3-sources-in-circle-fail-no-ets-module-compile/main__foo1-expected.txt deleted file mode 100644 index 3c204fa1e96450b3125bde11021bf114cceed9d4..0000000000000000000000000000000000000000 --- a/ets2panda/test/parser/ets/recursive_import/case_3_3-sources-in-circle-fail-no-ets-module-compile/main__foo1-expected.txt +++ /dev/null @@ -1 +0,0 @@ -SyntaxError: Please compile `main__foo1.sts` with `--ets-module` option. It is being imported by another file. [foo2__module.sts:16:17] diff --git a/ets2panda/test/parser/ets/recursive_import/case_4_3-sources-in-circle_no-ets-module-compile_2/foo2-expected.txt b/ets2panda/test/parser/ets/recursive_import/case_4_3-sources-in-circle_no-ets-module-compile_2/foo2-expected.txt deleted file mode 100644 index 09075d002d5daa890ee2fd9fe9d87eba2e39d4bb..0000000000000000000000000000000000000000 --- a/ets2panda/test/parser/ets/recursive_import/case_4_3-sources-in-circle_no-ets-module-compile_2/foo2-expected.txt +++ /dev/null @@ -1 +0,0 @@ -SyntaxError: Please compile `foo2.sts` with `--ets-module` option. It is being imported by another file. [foo3__module.sts:16:24] diff --git a/ets2panda/test/parser/ets/recursive_import/case_4_3-sources-in-circle_no-ets-module-compile_2/foo2.sts b/ets2panda/test/parser/ets/recursive_import/case_4_3-sources-in-circle_no-ets-module-compile_2/foo2.sts deleted file mode 100644 index cb9236d125862eb505374fb2b9f69cd2fd6a382f..0000000000000000000000000000000000000000 --- a/ets2panda/test/parser/ets/recursive_import/case_4_3-sources-in-circle_no-ets-module-compile_2/foo2.sts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import {A} from "./main__foo1_as__module" - -export function foo_in_2(): int { - console.log("in foo_in_2"); - return 0; -} diff --git a/ets2panda/test/parser/ets/recursive_import/case_4_3-sources-in-circle_no-ets-module-compile_2/foo3__module-expected.txt b/ets2panda/test/parser/ets/recursive_import/case_4_3-sources-in-circle_no-ets-module-compile_2/foo3__module-expected.txt deleted file mode 100644 index 2400c82d6fa5a02335d8ef0368b09b30e69f1f66..0000000000000000000000000000000000000000 --- a/ets2panda/test/parser/ets/recursive_import/case_4_3-sources-in-circle_no-ets-module-compile_2/foo3__module-expected.txt +++ /dev/null @@ -1,397 +0,0 @@ -{ - "type": "Program", - "statements": [ - { - "type": "ImportDeclaration", - "source": { - "type": "StringLiteral", - "value": "./foo2", - "loc": { - "start": { - "line": 16, - "column": 24 - }, - "end": { - "line": 16, - "column": 32 - } - } - }, - "specifiers": [ - { - "type": "ImportSpecifier", - "local": { - "type": "Identifier", - "name": "foo_in_2", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 9 - }, - "end": { - "line": 16, - "column": 17 - } - } - }, - "imported": { - "type": "Identifier", - "name": "foo_in_2", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 9 - }, - "end": { - "line": 16, - "column": 17 - } - } - }, - "loc": { - "start": { - "line": 16, - "column": 9 - }, - "end": { - "line": 16, - "column": 17 - } - } - } - ], - "loc": { - "start": { - "line": 16, - "column": 1 - }, - "end": { - "line": 16, - "column": 32 - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "ETSGLOBAL", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "foo_in_3", - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 17 - }, - "end": { - "line": 18, - "column": 25 - } - } - }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "foo_in_3", - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 17 - }, - "end": { - "line": 18, - "column": 25 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 18, - "column": 29 - }, - "end": { - "line": 18, - "column": 32 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "console", - "decorators": [], - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 12 - } - } - }, - "property": { - "type": "Identifier", - "name": "log", - "decorators": [], - "loc": { - "start": { - "line": 19, - "column": 13 - }, - "end": { - "line": 19, - "column": 16 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 16 - } - } - }, - "arguments": [ - { - "type": "StringLiteral", - "value": "in foo_in_3", - "loc": { - "start": { - "line": 19, - "column": 17 - }, - "end": { - "line": 19, - "column": 30 - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 31 - } - } - }, - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 32 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "foo_in_2", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 5 - }, - "end": { - "line": 20, - "column": 13 - } - } - }, - "arguments": [], - "optional": false, - "loc": { - "start": { - "line": 20, - "column": 5 - }, - "end": { - "line": 20, - "column": 15 - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 5 - }, - "end": { - "line": 20, - "column": 16 - } - } - }, - { - "type": "ReturnStatement", - "argument": { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 21, - "column": 12 - }, - "end": { - "line": 21, - "column": 13 - } - } - }, - "loc": { - "start": { - "line": 21, - "column": 5 - }, - "end": { - "line": 21, - "column": 14 - } - } - } - ], - "loc": { - "start": { - "line": 18, - "column": 33 - }, - "end": { - "line": 22, - "column": 2 - } - } - }, - "loc": { - "start": { - "line": 18, - "column": 25 - }, - "end": { - "line": 22, - "column": 2 - } - } - }, - "loc": { - "start": { - "line": 18, - "column": 25 - }, - "end": { - "line": 22, - "column": 2 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 8 - }, - "end": { - "line": 22, - "column": 2 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 23, - "column": 1 - } - } -} diff --git a/ets2panda/test/parser/ets/recursive_import/case_4_3-sources-in-circle_no-ets-module-compile_2/foo3__module.sts b/ets2panda/test/parser/ets/recursive_import/case_4_3-sources-in-circle_no-ets-module-compile_2/foo3__module.sts deleted file mode 100644 index cb13fab47c8120f47aa306383063a1876be761f7..0000000000000000000000000000000000000000 --- a/ets2panda/test/parser/ets/recursive_import/case_4_3-sources-in-circle_no-ets-module-compile_2/foo3__module.sts +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import {foo_in_2} from "./foo2" - -export function foo_in_3(): int { - console.log("in foo_in_3"); - foo_in_2(); - return 0; -} diff --git a/ets2panda/test/parser/ets/recursive_import/case_4_3-sources-in-circle_no-ets-module-compile_2/main__foo1_as__module.sts b/ets2panda/test/parser/ets/recursive_import/case_4_3-sources-in-circle_no-ets-module-compile_2/main__foo1_as__module.sts deleted file mode 100644 index 45f20acd8f12d6cb77a2d6b94e3a9adc37a5cc6c..0000000000000000000000000000000000000000 --- a/ets2panda/test/parser/ets/recursive_import/case_4_3-sources-in-circle_no-ets-module-compile_2/main__foo1_as__module.sts +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import {foo_in_3} from "./foo3__module" - -export class A { - a: int; -} - - -function main() : void { - let a = new A(); - foo_in_3(); -} diff --git a/ets2panda/test/parser/ets/recursive_import/case_5_main-is-not-part-of-circle/foo2__module.sts b/ets2panda/test/parser/ets/recursive_import/case_5_main-is-not-part-of-circle/foo2__module.sts deleted file mode 100644 index d9d2023fdf83c9011b1bbaaae93c9aba4e5013ed..0000000000000000000000000000000000000000 --- a/ets2panda/test/parser/ets/recursive_import/case_5_main-is-not-part-of-circle/foo2__module.sts +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import {foo_in_3} from "./foo3__module" - -export class A {} - -export function foo_in_2(): int { - console.log("in foo_in_2"); - foo_in_3(); - return 0; -} diff --git a/ets2panda/test/parser/ets/recursive_import/case_5_main-is-not-part-of-circle/foo3__module-expected.txt b/ets2panda/test/parser/ets/recursive_import/case_5_main-is-not-part-of-circle/foo3__module-expected.txt deleted file mode 100644 index 97d461121eabb07ff9427897220583b61e88e847..0000000000000000000000000000000000000000 --- a/ets2panda/test/parser/ets/recursive_import/case_5_main-is-not-part-of-circle/foo3__module-expected.txt +++ /dev/null @@ -1,453 +0,0 @@ -{ - "type": "Program", - "statements": [ - { - "type": "ImportDeclaration", - "source": { - "type": "StringLiteral", - "value": "./foo2__module", - "loc": { - "start": { - "line": 15, - "column": 17 - }, - "end": { - "line": 15, - "column": 33 - } - } - }, - "specifiers": [ - { - "type": "ImportSpecifier", - "local": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 15, - "column": 9 - }, - "end": { - "line": 15, - "column": 10 - } - } - }, - "imported": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 15, - "column": 9 - }, - "end": { - "line": 15, - "column": 10 - } - } - }, - "loc": { - "start": { - "line": 15, - "column": 9 - }, - "end": { - "line": 15, - "column": 10 - } - } - } - ], - "loc": { - "start": { - "line": 15, - "column": 1 - }, - "end": { - "line": 15, - "column": 33 - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "ETSGLOBAL", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "foo_in_3", - "decorators": [], - "loc": { - "start": { - "line": 17, - "column": 17 - }, - "end": { - "line": 17, - "column": 25 - } - } - }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "foo_in_3", - "decorators": [], - "loc": { - "start": { - "line": 17, - "column": 17 - }, - "end": { - "line": 17, - "column": 25 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 17, - "column": 29 - }, - "end": { - "line": 17, - "column": 32 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "a", - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 9 - }, - "end": { - "line": 18, - "column": 10 - } - } - }, - "init": { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 17 - }, - "end": { - "line": 18, - "column": 18 - } - } - }, - "loc": { - "start": { - "line": 18, - "column": 17 - }, - "end": { - "line": 18, - "column": 19 - } - } - }, - "loc": { - "start": { - "line": 18, - "column": 17 - }, - "end": { - "line": 18, - "column": 19 - } - } - }, - "arguments": [], - "loc": { - "start": { - "line": 18, - "column": 13 - }, - "end": { - "line": 18, - "column": 21 - } - } - }, - "loc": { - "start": { - "line": 18, - "column": 9 - }, - "end": { - "line": 18, - "column": 21 - } - } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 18, - "column": 5 - }, - "end": { - "line": 18, - "column": 21 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "console", - "decorators": [], - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 12 - } - } - }, - "property": { - "type": "Identifier", - "name": "log", - "decorators": [], - "loc": { - "start": { - "line": 19, - "column": 13 - }, - "end": { - "line": 19, - "column": 16 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 16 - } - } - }, - "arguments": [ - { - "type": "StringLiteral", - "value": "in foo_in_3", - "loc": { - "start": { - "line": 19, - "column": 17 - }, - "end": { - "line": 19, - "column": 30 - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 31 - } - } - }, - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 31 - } - } - }, - { - "type": "ReturnStatement", - "argument": { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 20, - "column": 12 - }, - "end": { - "line": 20, - "column": 13 - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 5 - }, - "end": { - "line": 20, - "column": 14 - } - } - } - ], - "loc": { - "start": { - "line": 17, - "column": 33 - }, - "end": { - "line": 21, - "column": 2 - } - } - }, - "loc": { - "start": { - "line": 17, - "column": 25 - }, - "end": { - "line": 21, - "column": 2 - } - } - }, - "loc": { - "start": { - "line": 17, - "column": 25 - }, - "end": { - "line": 21, - "column": 2 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 17, - "column": 8 - }, - "end": { - "line": 21, - "column": 2 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 22, - "column": 1 - } - } -} diff --git a/ets2panda/test/parser/ets/recursive_import/case_5_main-is-not-part-of-circle/foo3__module.sts b/ets2panda/test/parser/ets/recursive_import/case_5_main-is-not-part-of-circle/foo3__module.sts deleted file mode 100644 index 615dd74a9bf7997e62d5c1632b9480fde44761e4..0000000000000000000000000000000000000000 --- a/ets2panda/test/parser/ets/recursive_import/case_5_main-is-not-part-of-circle/foo3__module.sts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import {A} from "./foo2__module" - -export function foo_in_3(): int { - let a = new A(); - console.log("in foo_in_3") - return 0; -} diff --git a/ets2panda/test/parser/ets/selective_export/selective_export_bad-expected.txt b/ets2panda/test/parser/ets/selective_export/selective_export_bad-expected.txt index 7541e6c377e5d16de19e8c70724d66b70a10cb92..77a50908d8da93d2513d2c39ec0b5a168301eca9 100644 --- a/ets2panda/test/parser/ets/selective_export/selective_export_bad-expected.txt +++ b/ets2panda/test/parser/ets/selective_export/selective_export_bad-expected.txt @@ -1 +1 @@ -SyntaxError: Cannot find name 'foo' to export. [selective_export_bad.sts:16:10] +SyntaxError: Cannot find name 'foo' to export [selective_export_bad.sts:16:10] diff --git a/ets2panda/test/parser/ets/switch_enum-expected.txt b/ets2panda/test/parser/ets/switch_enum-expected.txt index f559f2e9cb3c24c69dbad4f07cf9514f85f40c99..53e42d4e5eb8b47450940a4d7cb6669d6a2444cf 100644 --- a/ets2panda/test/parser/ets/switch_enum-expected.txt +++ b/ets2panda/test/parser/ets/switch_enum-expected.txt @@ -618,12 +618,56 @@ "column": 2 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ { "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -636,52 +680,44 @@ } } }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "Red", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "StringLiteral", - "value": "Green", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "accessibility": "protected", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 }, - { - "type": "StringLiteral", - "value": "Blue", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "end": { + "line": 1, + "column": 1 } - ], + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "", + "decorators": [], "loc": { "start": { "line": 1, @@ -693,33 +729,37 @@ } } }, + "kind": "method", "accessibility": "public", "static": true, - "readonly": false, - "declare": false, "optional": false, "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], "loc": { "start": { "line": 1, @@ -753,7 +793,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -770,7 +810,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -783,9 +823,9 @@ } } }, - "kind": "method", + "kind": "constructor", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -794,7 +834,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -817,12 +857,68 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { "type": "Identifier", - "name": "Color", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -835,6 +931,23 @@ } } }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -857,7 +970,6 @@ } } }, - "decorators": [], "loc": { "start": { "line": 1, @@ -868,49 +980,91 @@ "column": 1 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "Red", + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } - }, + } + }, + { + "type": "StringLiteral", + "value": "Green", "loc": { "start": { "line": 1, @@ -922,94 +1076,59 @@ } } }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color#NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + { + "type": "StringLiteral", + "value": "Blue", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], + }, "loc": { "start": { "line": 1, @@ -1043,7 +1162,7 @@ } } }, - "overloads": [], + "definite": false, "decorators": [], "loc": { "start": { @@ -1057,10 +1176,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#valueOf", + "name": "ValuesArray", "decorators": [], "loc": { "start": { @@ -1073,18 +1192,1300 @@ } } }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { + "type": "ArrayExpression", + "elements": [ + { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "NumberLiteral", + "value": 2, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "0", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "1", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "2", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Green", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Blue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "BoxedItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Green", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Blue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getName", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "valueOf", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { "type": "Identifier", - "name": "#Color#valueOf", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -1297,7 +2698,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1403,7 +2804,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1721,10 +3122,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#ValuesArray", + "name": "getValue", "decorators": [], "loc": { "start": { @@ -1737,12 +3138,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumberLiteral", - "value": 0, + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getValue", + "decorators": [], "loc": { "start": { "line": 1, @@ -1754,9 +3162,82 @@ } } }, - { - "type": "NumberLiteral", - "value": 1, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "e", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1768,9 +3249,94 @@ } } }, - { - "type": "NumberLiteral", - "value": 2, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "e", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], "loc": { "start": { "line": 1, @@ -1781,29 +3347,7 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1826,7 +3370,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -1843,7 +3387,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -1867,7 +3411,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -1888,7 +3432,7 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "e", + "name": "ordinal", "typeAnnotation": { "type": "ETSTypeReference", "part": { @@ -1955,7 +3499,35 @@ } ], "returnType": { - "type": "ETSPrimitiveType", + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -1976,7 +3548,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#ValuesArray", + "name": "StringValuesArray", "decorators": [], "loc": { "start": { @@ -1993,7 +3565,7 @@ "type": "TSAsExpression", "expression": { "type": "Identifier", - "name": "e", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2102,10 +3674,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#StringValuesArray", + "name": "values", "decorators": [], "loc": { "start": { @@ -2118,12 +3690,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "0", + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "values", + "decorators": [], "loc": { "start": { "line": 1, @@ -2135,23 +3714,53 @@ } } }, - { - "type": "StringLiteral", - "value": "1", - "loc": { - "start": { - "line": 1, - "column": 1 + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - } - }, - { - "type": "StringLiteral", - "value": "2", + }, "loc": { "start": { "line": 1, @@ -2162,46 +3771,39 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -2235,7 +3837,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2252,7 +3854,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -2276,7 +3878,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -2299,35 +3901,7 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -2369,7 +3943,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "Color", "decorators": [], "loc": { "start": { @@ -2408,12 +3982,13 @@ "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { "type": "Identifier", - "name": "#Color#StringValuesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2426,11 +4001,69 @@ } } }, - "property": { - "type": "TSAsExpression", - "expression": { + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { "type": "Identifier", - "name": "ordinal", + "name": "ItemsArray", "decorators": [], "loc": { "start": { @@ -2443,8 +4076,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -2456,6 +4091,8 @@ } } }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -2467,8 +4104,6 @@ } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 1, @@ -2480,6 +4115,7 @@ } } }, + "alternate": null, "loc": { "start": { "line": 1, @@ -2488,250 +4124,122 @@ "end": { "line": 1, "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#Color#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Red", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Green", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Blue", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 + } } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant in Color with ordinal value ", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -2742,7 +4250,8 @@ "column": 1 } } - }, + } + "throwMarker": "throws", "loc": { "start": { "line": 1, @@ -2765,7 +4274,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2782,7 +4291,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -2797,7 +4306,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -2806,7 +4315,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -2824,26 +4333,13 @@ "expression": false, "params": [], "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], "loc": { "start": { "line": 1, @@ -2883,9 +4379,67 @@ { "type": "ReturnStatement", "argument": { - "type": "Identifier", - "name": "#Color#ItemsArray", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -2959,7 +4513,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -2983,7 +4537,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -3048,7 +4602,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Color", + "name": "#Color", "decorators": [], "loc": { "start": { @@ -3110,7 +4664,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -3168,7 +4722,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { diff --git a/ets2panda/test/parser/ets/switch_enum2-expected.txt b/ets2panda/test/parser/ets/switch_enum2-expected.txt index c6f4b32c6a31cc2d723a6d8dc151cf9465a3c9a0..1f0c3a64b714f40795cd6792d43332e84516ad08 100644 --- a/ets2panda/test/parser/ets/switch_enum2-expected.txt +++ b/ets2panda/test/parser/ets/switch_enum2-expected.txt @@ -513,12 +513,56 @@ "column": 2 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ { "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -531,52 +575,44 @@ } } }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "Red", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "StringLiteral", - "value": "Green", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "accessibility": "protected", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 }, - { - "type": "StringLiteral", - "value": "Blue", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "end": { + "line": 1, + "column": 1 } - ], + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "", + "decorators": [], "loc": { "start": { "line": 1, @@ -588,33 +624,37 @@ } } }, + "kind": "method", "accessibility": "public", "static": true, - "readonly": false, - "declare": false, "optional": false, "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], "loc": { "start": { "line": 1, @@ -648,7 +688,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -665,7 +705,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -678,9 +718,9 @@ } } }, - "kind": "method", + "kind": "constructor", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -689,7 +729,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -712,12 +752,68 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { "type": "Identifier", - "name": "Color", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -730,6 +826,23 @@ } } }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -752,7 +865,6 @@ } } }, - "decorators": [], "loc": { "start": { "line": 1, @@ -763,49 +875,91 @@ "column": 1 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "Red", + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } - }, + } + }, + { + "type": "StringLiteral", + "value": "Green", "loc": { "start": { "line": 1, @@ -817,94 +971,59 @@ } } }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Color#NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + { + "type": "StringLiteral", + "value": "Blue", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], + }, "loc": { "start": { "line": 1, @@ -938,7 +1057,7 @@ } } }, - "overloads": [], + "definite": false, "decorators": [], "loc": { "start": { @@ -952,10 +1071,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Color#valueOf", + "name": "ValuesArray", "decorators": [], "loc": { "start": { @@ -968,18 +1087,1300 @@ } } }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { + "type": "ArrayExpression", + "elements": [ + { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "NumberLiteral", + "value": 2, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "0", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "1", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "2", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Green", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Blue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "BoxedItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Red", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Green", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "Blue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getName", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "valueOf", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { "type": "Identifier", - "name": "#Color#valueOf", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -1192,7 +2593,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1298,7 +2699,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1616,10 +3017,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#ValuesArray", + "name": "getValue", "decorators": [], "loc": { "start": { @@ -1632,12 +3033,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumberLiteral", - "value": 0, + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getValue", + "decorators": [], "loc": { "start": { "line": 1, @@ -1649,9 +3057,82 @@ } } }, - { - "type": "NumberLiteral", - "value": 1, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "e", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1663,9 +3144,94 @@ } } }, - { - "type": "NumberLiteral", - "value": 2, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "e", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], "loc": { "start": { "line": 1, @@ -1676,29 +3242,7 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1721,7 +3265,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -1738,7 +3282,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -1762,7 +3306,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -1783,7 +3327,7 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "e", + "name": "ordinal", "typeAnnotation": { "type": "ETSTypeReference", "part": { @@ -1850,7 +3394,35 @@ } ], "returnType": { - "type": "ETSPrimitiveType", + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -1871,7 +3443,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#ValuesArray", + "name": "StringValuesArray", "decorators": [], "loc": { "start": { @@ -1888,7 +3460,7 @@ "type": "TSAsExpression", "expression": { "type": "Identifier", - "name": "e", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -1997,10 +3569,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#StringValuesArray", + "name": "values", "decorators": [], "loc": { "start": { @@ -2013,12 +3585,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "0", + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "values", + "decorators": [], "loc": { "start": { "line": 1, @@ -2030,23 +3609,53 @@ } } }, - { - "type": "StringLiteral", - "value": "1", - "loc": { - "start": { - "line": 1, - "column": 1 + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - } - }, - { - "type": "StringLiteral", - "value": "2", + }, "loc": { "start": { "line": 1, @@ -2057,46 +3666,39 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -2130,7 +3732,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2147,7 +3749,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -2171,7 +3773,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -2194,35 +3796,7 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -2264,7 +3838,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "Color", "decorators": [], "loc": { "start": { @@ -2303,12 +3877,13 @@ "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { "type": "Identifier", - "name": "#Color#StringValuesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2321,11 +3896,69 @@ } } }, - "property": { - "type": "TSAsExpression", - "expression": { + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { "type": "Identifier", - "name": "ordinal", + "name": "ItemsArray", "decorators": [], "loc": { "start": { @@ -2338,8 +3971,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -2351,6 +3986,8 @@ } } }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -2362,8 +3999,6 @@ } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 1, @@ -2375,6 +4010,7 @@ } } }, + "alternate": null, "loc": { "start": { "line": 1, @@ -2383,250 +4019,122 @@ "end": { "line": 1, "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#Color#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Red", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Green", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "Blue", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 + } } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant in Color with ordinal value ", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -2637,7 +4145,8 @@ "column": 1 } } - }, + } + "throwMarker": "throws", "loc": { "start": { "line": 1, @@ -2660,7 +4169,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2677,7 +4186,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -2692,7 +4201,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -2701,7 +4210,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -2719,26 +4228,13 @@ "expression": false, "params": [], "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Color", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Color", + "decorators": [], "loc": { "start": { "line": 1, @@ -2778,9 +4274,67 @@ { "type": "ReturnStatement", "argument": { - "type": "Identifier", - "name": "#Color#ItemsArray", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -2854,7 +4408,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Color#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -2878,7 +4432,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Color#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -2943,7 +4497,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Color", + "name": "#Color", "decorators": [], "loc": { "start": { @@ -3005,7 +4559,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -3063,7 +4617,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Color#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { diff --git a/ets2panda/test/parser/ets/switch_enum_3-expected.txt b/ets2panda/test/parser/ets/switch_enum_3-expected.txt index 9b66fae6212ded658457b6f380d36d15448d1fb6..289c8ac64013466347cc9e6a6443d1e6959e7bf1 100644 --- a/ets2panda/test/parser/ets/switch_enum_3-expected.txt +++ b/ets2panda/test/parser/ets/switch_enum_3-expected.txt @@ -749,12 +749,56 @@ "column": 2 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "#A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ { "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#A#NamesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -767,52 +811,44 @@ } } }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "B", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "StringLiteral", - "value": "C", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "accessibility": "protected", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 }, - { - "type": "StringLiteral", - "value": "D", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "end": { + "line": 1, + "column": 1 } - ], + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "", + "decorators": [], "loc": { "start": { "line": 1, @@ -824,33 +860,37 @@ } } }, + "kind": "method", "accessibility": "public", "static": true, - "readonly": false, - "declare": false, "optional": false, "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], "loc": { "start": { "line": 1, @@ -884,7 +924,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -901,7 +941,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#A#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -914,9 +954,9 @@ } } }, - "kind": "method", + "kind": "constructor", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -925,7 +965,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#A#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -948,12 +988,68 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { "type": "Identifier", - "name": "A", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -966,6 +1062,23 @@ } } }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -988,7 +1101,6 @@ } } }, - "decorators": [], "loc": { "start": { "line": 1, @@ -999,49 +1111,91 @@ "column": 1 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "B", + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } - }, + } + }, + { + "type": "StringLiteral", + "value": "C", "loc": { "start": { "line": 1, @@ -1053,94 +1207,59 @@ } } }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#A#NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + { + "type": "StringLiteral", + "value": "D", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], + }, "loc": { "start": { "line": 1, @@ -1174,7 +1293,7 @@ } } }, - "overloads": [], + "definite": false, "decorators": [], "loc": { "start": { @@ -1188,10 +1307,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#A#valueOf", + "name": "ValuesArray", "decorators": [], "loc": { "start": { @@ -1204,18 +1323,1300 @@ } } }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { + "type": "ArrayExpression", + "elements": [ + { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "NumberLiteral", + "value": 2, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "0", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "1", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "2", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "B", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "C", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "D", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "BoxedItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "B", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "C", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "D", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getName", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "valueOf", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { "type": "Identifier", - "name": "#A#valueOf", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -1428,7 +2829,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#A#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1534,7 +2935,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#A#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1852,10 +3253,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#A#ValuesArray", + "name": "getValue", "decorators": [], "loc": { "start": { @@ -1868,12 +3269,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumberLiteral", - "value": 0, + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getValue", + "decorators": [], "loc": { "start": { "line": 1, @@ -1885,9 +3293,82 @@ } } }, - { - "type": "NumberLiteral", - "value": 1, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "e", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1899,9 +3380,94 @@ } } }, - { - "type": "NumberLiteral", - "value": 2, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "e", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], "loc": { "start": { "line": 1, @@ -1912,29 +3478,7 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1957,7 +3501,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -1974,7 +3518,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#A#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -1998,7 +3542,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#A#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -2019,7 +3563,7 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "e", + "name": "ordinal", "typeAnnotation": { "type": "ETSTypeReference", "part": { @@ -2086,7 +3630,35 @@ } ], "returnType": { - "type": "ETSPrimitiveType", + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -2107,7 +3679,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#A#ValuesArray", + "name": "StringValuesArray", "decorators": [], "loc": { "start": { @@ -2124,7 +3696,7 @@ "type": "TSAsExpression", "expression": { "type": "Identifier", - "name": "e", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2233,10 +3805,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#A#StringValuesArray", + "name": "values", "decorators": [], "loc": { "start": { @@ -2249,12 +3821,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "0", + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "values", + "decorators": [], "loc": { "start": { "line": 1, @@ -2266,23 +3845,53 @@ } } }, - { - "type": "StringLiteral", - "value": "1", - "loc": { - "start": { - "line": 1, - "column": 1 + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - } - }, - { - "type": "StringLiteral", - "value": "2", + }, "loc": { "start": { "line": 1, @@ -2293,46 +3902,39 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -2366,7 +3968,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2383,7 +3985,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#A#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -2407,7 +4009,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#A#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -2430,35 +4032,7 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -2500,7 +4074,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "A", "decorators": [], "loc": { "start": { @@ -2539,12 +4113,13 @@ "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { "type": "Identifier", - "name": "#A#StringValuesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2557,11 +4132,69 @@ } } }, - "property": { - "type": "TSAsExpression", - "expression": { + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { "type": "Identifier", - "name": "ordinal", + "name": "ItemsArray", "decorators": [], "loc": { "start": { @@ -2574,8 +4207,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -2587,6 +4222,8 @@ } } }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -2598,8 +4235,6 @@ } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 1, @@ -2611,6 +4246,7 @@ } } }, + "alternate": null, "loc": { "start": { "line": 1, @@ -2619,250 +4255,122 @@ "end": { "line": 1, "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#A#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "B", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "C", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "D", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 + } } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant in A with ordinal value ", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -2873,7 +4381,8 @@ "column": 1 } } - }, + } + "throwMarker": "throws", "loc": { "start": { "line": 1, @@ -2896,7 +4405,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2913,7 +4422,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#A#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -2928,7 +4437,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -2937,7 +4446,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#A#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -2955,26 +4464,13 @@ "expression": false, "params": [], "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], "loc": { "start": { "line": 1, @@ -3014,9 +4510,67 @@ { "type": "ReturnStatement", "argument": { - "type": "Identifier", - "name": "#A#ItemsArray", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -3090,7 +4644,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#A#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -3114,7 +4668,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#A#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -3179,7 +4733,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "A", + "name": "#A", "decorators": [], "loc": { "start": { @@ -3241,7 +4795,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#A#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -3299,7 +4853,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#A#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { diff --git a/ets2panda/test/parser/ets/switch_enum_case_duplicate-expected.txt b/ets2panda/test/parser/ets/switch_enum_case_duplicate-expected.txt index 6894132279d6399119963adb4b0a2dd98155cf89..91c9da17dbdc600447eb730307e8496df8f481ec 100644 --- a/ets2panda/test/parser/ets/switch_enum_case_duplicate-expected.txt +++ b/ets2panda/test/parser/ets/switch_enum_case_duplicate-expected.txt @@ -749,12 +749,56 @@ "column": 2 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "#B", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ { "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#B#NamesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -767,52 +811,44 @@ } } }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "C", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "StringLiteral", - "value": "D", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "accessibility": "protected", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 }, - { - "type": "StringLiteral", - "value": "E", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "end": { + "line": 1, + "column": 1 } - ], + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "", + "decorators": [], "loc": { "start": { "line": 1, @@ -824,33 +860,37 @@ } } }, + "kind": "method", "accessibility": "public", "static": true, - "readonly": false, - "declare": false, "optional": false, "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], "loc": { "start": { "line": 1, @@ -884,7 +924,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -901,7 +941,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#B#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -914,9 +954,9 @@ } } }, - "kind": "method", + "kind": "constructor", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -925,7 +965,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#B#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -948,12 +988,68 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { "type": "Identifier", - "name": "B", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -966,6 +1062,23 @@ } } }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -988,7 +1101,6 @@ } } }, - "decorators": [], "loc": { "start": { "line": 1, @@ -999,49 +1111,91 @@ "column": 1 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "C", + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } - }, + } + }, + { + "type": "StringLiteral", + "value": "D", "loc": { "start": { "line": 1, @@ -1053,94 +1207,59 @@ } } }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#B#NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + { + "type": "StringLiteral", + "value": "E", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], + }, "loc": { "start": { "line": 1, @@ -1174,7 +1293,7 @@ } } }, - "overloads": [], + "definite": false, "decorators": [], "loc": { "start": { @@ -1188,10 +1307,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#B#valueOf", + "name": "ValuesArray", "decorators": [], "loc": { "start": { @@ -1204,18 +1323,1300 @@ } } }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { + "type": "ArrayExpression", + "elements": [ + { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "NumberLiteral", + "value": 2, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "0", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "1", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "2", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "B", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "C", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "B", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "D", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "B", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "E", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "B", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "BoxedItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#B", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "B", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "C", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#B", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "B", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "D", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#B", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "B", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "E", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#B", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getName", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "B", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "valueOf", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { "type": "Identifier", - "name": "#B#valueOf", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -1428,7 +2829,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#B#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1534,7 +2935,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#B#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1852,10 +3253,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#B#ValuesArray", + "name": "getValue", "decorators": [], "loc": { "start": { @@ -1868,12 +3269,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumberLiteral", - "value": 0, + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getValue", + "decorators": [], "loc": { "start": { "line": 1, @@ -1885,9 +3293,82 @@ } } }, - { - "type": "NumberLiteral", - "value": 1, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "e", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "B", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1899,9 +3380,94 @@ } } }, - { - "type": "NumberLiteral", - "value": 2, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "e", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], "loc": { "start": { "line": 1, @@ -1912,29 +3478,7 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1957,7 +3501,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -1974,7 +3518,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#B#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -1998,7 +3542,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#B#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -2019,7 +3563,7 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "e", + "name": "ordinal", "typeAnnotation": { "type": "ETSTypeReference", "part": { @@ -2086,7 +3630,35 @@ } ], "returnType": { - "type": "ETSPrimitiveType", + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -2107,7 +3679,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#B#ValuesArray", + "name": "StringValuesArray", "decorators": [], "loc": { "start": { @@ -2124,7 +3696,7 @@ "type": "TSAsExpression", "expression": { "type": "Identifier", - "name": "e", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2233,10 +3805,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#B#StringValuesArray", + "name": "values", "decorators": [], "loc": { "start": { @@ -2249,12 +3821,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "0", + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "values", + "decorators": [], "loc": { "start": { "line": 1, @@ -2266,23 +3845,53 @@ } } }, - { - "type": "StringLiteral", - "value": "1", - "loc": { - "start": { - "line": 1, - "column": 1 + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "B", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - } - }, - { - "type": "StringLiteral", - "value": "2", + }, "loc": { "start": { "line": 1, @@ -2293,46 +3902,39 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -2366,7 +3968,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2383,7 +3985,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#B#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -2407,7 +4009,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#B#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -2430,35 +4032,7 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "B", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -2500,7 +4074,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "B", "decorators": [], "loc": { "start": { @@ -2539,12 +4113,13 @@ "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { "type": "Identifier", - "name": "#B#StringValuesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2557,11 +4132,69 @@ } } }, - "property": { - "type": "TSAsExpression", - "expression": { + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { "type": "Identifier", - "name": "ordinal", + "name": "ItemsArray", "decorators": [], "loc": { "start": { @@ -2574,8 +4207,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -2587,6 +4222,8 @@ } } }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -2598,8 +4235,6 @@ } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 1, @@ -2611,6 +4246,7 @@ } } }, + "alternate": null, "loc": { "start": { "line": 1, @@ -2619,250 +4255,122 @@ "end": { "line": 1, "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#B#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "B", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "C", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "B", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "D", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "B", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "E", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 + } } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "B", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant in B with ordinal value ", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -2873,7 +4381,8 @@ "column": 1 } } - }, + } + "throwMarker": "throws", "loc": { "start": { "line": 1, @@ -2896,7 +4405,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2913,7 +4422,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#B#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -2928,7 +4437,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -2937,7 +4446,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#B#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -2955,26 +4464,13 @@ "expression": false, "params": [], "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "B", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "B", + "decorators": [], "loc": { "start": { "line": 1, @@ -3014,9 +4510,67 @@ { "type": "ReturnStatement", "argument": { - "type": "Identifier", - "name": "#B#ItemsArray", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -3090,7 +4644,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#B#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -3114,7 +4668,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#B#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -3179,7 +4733,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "B", + "name": "#B", "decorators": [], "loc": { "start": { @@ -3241,7 +4795,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#B#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -3299,7 +4853,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#B#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { 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 10ab356f163582aca7c42abf29e287db0bd9d811..e3ce7b418ff730bbef0a62d8c6007a69e9f86504 100644 --- a/ets2panda/test/parser/ets/switch_enum_string_case-expected.txt +++ b/ets2panda/test/parser/ets/switch_enum_string_case-expected.txt @@ -764,12 +764,56 @@ "column": 2 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "#Enum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ { "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Enum#NamesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -782,52 +826,44 @@ } } }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "e1", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "StringLiteral", - "value": "e2", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "accessibility": "protected", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 }, - { - "type": "StringLiteral", - "value": "e3", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "end": { + "line": 1, + "column": 1 } - ], + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "", + "decorators": [], "loc": { "start": { "line": 1, @@ -839,33 +875,37 @@ } } }, + "kind": "method", "accessibility": "public", "static": true, - "readonly": false, - "declare": false, "optional": false, "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], "loc": { "start": { "line": 1, @@ -899,7 +939,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -916,7 +956,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Enum#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -929,9 +969,9 @@ } } }, - "kind": "method", + "kind": "constructor", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -940,7 +980,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Enum#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -963,12 +1003,68 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { "type": "Identifier", - "name": "Enum", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -981,6 +1077,23 @@ } } }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -1003,7 +1116,6 @@ } } }, - "decorators": [], "loc": { "start": { "line": 1, @@ -1014,49 +1126,91 @@ "column": 1 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "e1", + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } - }, + } + }, + { + "type": "StringLiteral", + "value": "e2", "loc": { "start": { "line": 1, @@ -1068,94 +1222,59 @@ } } }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Enum#NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + { + "type": "StringLiteral", + "value": "e3", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], + }, "loc": { "start": { "line": 1, @@ -1189,7 +1308,7 @@ } } }, - "overloads": [], + "definite": false, "decorators": [], "loc": { "start": { @@ -1203,10 +1322,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Enum#valueOf", + "name": "StringValuesArray", "decorators": [], "loc": { "start": { @@ -1219,18 +1338,1181 @@ } } }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "A", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "B", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "C", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "e1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "e2", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "e3", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "BoxedItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Enum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "e1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Enum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "e2", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Enum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "e3", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Enum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getName", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "valueOf", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { "type": "Identifier", - "name": "#Enum#valueOf", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -1443,7 +2725,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Enum#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1549,7 +2831,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Enum#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1639,17 +2921,140 @@ } } }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "alternate": null, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant Enum.", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "right": { + "type": "Identifier", + "name": "name", + "decorators": [], "loc": { "start": { "line": 1, @@ -1671,6 +3076,146 @@ "column": 1 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + "throwMarker": "throws", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "toString", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, "loc": { "start": { @@ -1683,7 +3228,6 @@ } } }, - "alternate": null, "loc": { "start": { "line": 1, @@ -1695,6 +3239,38 @@ } } }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], "loc": { "start": { "line": 1, @@ -1706,29 +3282,69 @@ } } }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1751,51 +3367,8 @@ } } }, - "arguments": [ - { - "type": "BinaryExpression", - "operator": "+", - "left": { - "type": "StringLiteral", - "value": "No enum constant Enum.", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "right": { - "type": "Identifier", - "name": "name", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -1829,8 +3402,7 @@ "column": 1 } } - } - "throwMarker": "throws", + }, "loc": { "start": { "line": 1, @@ -1867,10 +3439,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Enum#StringValuesArray", + "name": "values", "decorators": [], "loc": { "start": { @@ -1883,12 +3455,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "A", + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "values", + "decorators": [], "loc": { "start": { "line": 1, @@ -1900,23 +3479,53 @@ } } }, - { - "type": "StringLiteral", - "value": "B", - "loc": { - "start": { - "line": 1, - "column": 1 + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - } - }, - { - "type": "StringLiteral", - "value": "C", + }, "loc": { "start": { "line": 1, @@ -1927,46 +3536,39 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -2000,7 +3602,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2017,7 +3619,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Enum#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -2041,7 +3643,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Enum#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -2064,35 +3666,7 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Enum", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -2134,7 +3708,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "Enum", "decorators": [], "loc": { "start": { @@ -2173,12 +3747,13 @@ "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { "type": "Identifier", - "name": "#Enum#StringValuesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2191,11 +3766,69 @@ } } }, - "property": { - "type": "TSAsExpression", - "expression": { + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { "type": "Identifier", - "name": "ordinal", + "name": "ItemsArray", "decorators": [], "loc": { "start": { @@ -2208,8 +3841,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -2221,6 +3856,8 @@ } } }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -2232,8 +3869,6 @@ } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 1, @@ -2245,6 +3880,7 @@ } } }, + "alternate": null, "loc": { "start": { "line": 1, @@ -2253,250 +3889,122 @@ "end": { "line": 1, "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#Enum#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Enum", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "e1", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Enum", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "e2", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Enum", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "e3", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 + } } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Enum", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant in Enum with ordinal value ", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -2507,7 +4015,8 @@ "column": 1 } } - }, + } + "throwMarker": "throws", "loc": { "start": { "line": 1, @@ -2530,7 +4039,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2547,7 +4056,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Enum#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -2562,7 +4071,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -2571,7 +4080,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Enum#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -2589,26 +4098,13 @@ "expression": false, "params": [], "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Enum", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Enum", + "decorators": [], "loc": { "start": { "line": 1, @@ -2648,9 +4144,67 @@ { "type": "ReturnStatement", "argument": { - "type": "Identifier", - "name": "#Enum#ItemsArray", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -2724,7 +4278,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Enum#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -2748,7 +4302,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Enum#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -2813,7 +4367,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Enum", + "name": "#Enum", "decorators": [], "loc": { "start": { @@ -2875,7 +4429,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Enum#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -2933,7 +4487,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Enum#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { diff --git a/ets2panda/test/parser/ets/switch_enum_string_case_duplicate-expected.txt b/ets2panda/test/parser/ets/switch_enum_string_case_duplicate-expected.txt index 7cf35b95e8340efd86830329d6e249487943df8a..a04956b89d5a29ffb7d923e91307dda3abf21647 100644 --- a/ets2panda/test/parser/ets/switch_enum_string_case_duplicate-expected.txt +++ b/ets2panda/test/parser/ets/switch_enum_string_case_duplicate-expected.txt @@ -708,12 +708,56 @@ "column": 2 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "#Enum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ { "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Enum#NamesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -726,52 +770,44 @@ } } }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "e1", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "StringLiteral", - "value": "e2", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "accessibility": "protected", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 }, - { - "type": "StringLiteral", - "value": "e3", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "end": { + "line": 1, + "column": 1 } - ], + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "", + "decorators": [], "loc": { "start": { "line": 1, @@ -783,33 +819,37 @@ } } }, + "kind": "method", "accessibility": "public", "static": true, - "readonly": false, - "declare": false, "optional": false, "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], "loc": { "start": { "line": 1, @@ -843,7 +883,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -860,7 +900,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Enum#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -873,9 +913,9 @@ } } }, - "kind": "method", + "kind": "constructor", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -884,7 +924,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Enum#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -907,12 +947,68 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { "type": "Identifier", - "name": "Enum", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -925,6 +1021,23 @@ } } }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -947,7 +1060,6 @@ } } }, - "decorators": [], "loc": { "start": { "line": 1, @@ -958,49 +1070,91 @@ "column": 1 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "e1", + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } - }, + } + }, + { + "type": "StringLiteral", + "value": "e2", "loc": { "start": { "line": 1, @@ -1012,94 +1166,59 @@ } } }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#Enum#NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + { + "type": "StringLiteral", + "value": "e3", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], + }, "loc": { "start": { "line": 1, @@ -1133,7 +1252,7 @@ } } }, - "overloads": [], + "definite": false, "decorators": [], "loc": { "start": { @@ -1147,10 +1266,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#Enum#valueOf", + "name": "StringValuesArray", "decorators": [], "loc": { "start": { @@ -1163,18 +1282,1181 @@ } } }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "A", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "B", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "C", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "e1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "e2", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "e3", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "BoxedItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Enum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "e1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Enum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "e2", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Enum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "e3", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#Enum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getName", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "valueOf", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { "type": "Identifier", - "name": "#Enum#valueOf", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -1387,7 +2669,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Enum#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1493,7 +2775,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Enum#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1583,17 +2865,140 @@ } } }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "alternate": null, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant Enum.", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "right": { + "type": "Identifier", + "name": "name", + "decorators": [], "loc": { "start": { "line": 1, @@ -1615,6 +3020,146 @@ "column": 1 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + "throwMarker": "throws", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "toString", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, "loc": { "start": { @@ -1627,7 +3172,6 @@ } } }, - "alternate": null, "loc": { "start": { "line": 1, @@ -1639,6 +3183,38 @@ } } }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], "loc": { "start": { "line": 1, @@ -1650,29 +3226,69 @@ } } }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -1695,51 +3311,8 @@ } } }, - "arguments": [ - { - "type": "BinaryExpression", - "operator": "+", - "left": { - "type": "StringLiteral", - "value": "No enum constant Enum.", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "right": { - "type": "Identifier", - "name": "name", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -1773,8 +3346,7 @@ "column": 1 } } - } - "throwMarker": "throws", + }, "loc": { "start": { "line": 1, @@ -1811,10 +3383,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Enum#StringValuesArray", + "name": "values", "decorators": [], "loc": { "start": { @@ -1827,12 +3399,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "A", + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "values", + "decorators": [], "loc": { "start": { "line": 1, @@ -1844,23 +3423,53 @@ } } }, - { - "type": "StringLiteral", - "value": "B", - "loc": { - "start": { - "line": 1, - "column": 1 + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Enum", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - } - }, - { - "type": "StringLiteral", - "value": "C", + }, "loc": { "start": { "line": 1, @@ -1871,46 +3480,39 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -1944,7 +3546,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -1961,7 +3563,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Enum#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -1985,7 +3587,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Enum#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -2008,35 +3610,7 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Enum", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -2078,7 +3652,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "Enum", "decorators": [], "loc": { "start": { @@ -2117,12 +3691,13 @@ "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { "type": "Identifier", - "name": "#Enum#StringValuesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2135,11 +3710,69 @@ } } }, - "property": { - "type": "TSAsExpression", - "expression": { + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { "type": "Identifier", - "name": "ordinal", + "name": "ItemsArray", "decorators": [], "loc": { "start": { @@ -2152,8 +3785,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -2165,6 +3800,8 @@ } } }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -2176,8 +3813,6 @@ } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 1, @@ -2189,6 +3824,7 @@ } } }, + "alternate": null, "loc": { "start": { "line": 1, @@ -2197,250 +3833,122 @@ "end": { "line": 1, "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#Enum#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Enum", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "e1", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Enum", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "e2", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Enum", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "e3", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 + } } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Enum", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant in Enum with ordinal value ", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -2451,7 +3959,8 @@ "column": 1 } } - }, + } + "throwMarker": "throws", "loc": { "start": { "line": 1, @@ -2474,7 +3983,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2491,7 +4000,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Enum#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -2506,7 +4015,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -2515,7 +4024,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Enum#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -2533,26 +4042,13 @@ "expression": false, "params": [], "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Enum", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Enum", + "decorators": [], "loc": { "start": { "line": 1, @@ -2592,9 +4088,67 @@ { "type": "ReturnStatement", "argument": { - "type": "Identifier", - "name": "#Enum#ItemsArray", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -2668,7 +4222,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#Enum#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -2692,7 +4246,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#Enum#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -2757,7 +4311,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "Enum", + "name": "#Enum", "decorators": [], "loc": { "start": { @@ -2819,7 +4373,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Enum#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -2877,7 +4431,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#Enum#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { diff --git a/ets2panda/test/parser/ets/switch_readonly_member_different_enum-expected.txt b/ets2panda/test/parser/ets/switch_readonly_member_different_enum-expected.txt index 44a4e7c0d6f9ddc46e4bf87c61268099402314f0..7e4ff26d28c230ec31e3beae8091a7885d878463 100644 --- a/ets2panda/test/parser/ets/switch_readonly_member_different_enum-expected.txt +++ b/ets2panda/test/parser/ets/switch_readonly_member_different_enum-expected.txt @@ -1257,12 +1257,56 @@ "column": 2 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "#A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ { "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#A#NamesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -1275,52 +1319,44 @@ } } }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "B", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "StringLiteral", - "value": "C", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "accessibility": "protected", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 }, - { - "type": "StringLiteral", - "value": "D", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "end": { + "line": 1, + "column": 1 } - ], + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "", + "decorators": [], "loc": { "start": { "line": 1, @@ -1332,33 +1368,37 @@ } } }, + "kind": "method", "accessibility": "public", "static": true, - "readonly": false, - "declare": false, "optional": false, "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], "loc": { "start": { "line": 1, @@ -1392,7 +1432,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -1409,7 +1449,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#A#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -1422,9 +1462,9 @@ } } }, - "kind": "method", + "kind": "constructor", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -1433,7 +1473,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#A#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -1456,12 +1496,68 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { "type": "Identifier", - "name": "A", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -1474,6 +1570,23 @@ } } }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -1496,147 +1609,6 @@ } } }, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#A#NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, "loc": { "start": { "line": 1, @@ -1696,10 +1668,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#A#valueOf", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1712,19 +1684,12 @@ } } }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "#A#valueOf", - "decorators": [], + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "B", "loc": { "start": { "line": 1, @@ -1736,100 +1701,3560 @@ } } }, - "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": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + { + "type": "StringLiteral", + "value": "C", + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { + }, + { + "type": "StringLiteral", + "value": "D", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "NumberLiteral", + "value": 2, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "0", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "1", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "2", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "B", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "C", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "D", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "BoxedItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "B", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "C", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "D", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getName", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "valueOf", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ForUpdateStatement", + "init": { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "init": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "update": { + "type": "UpdateExpression", + "operator": "++", + "prefix": true, + "argument": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "==", + "left": { + "type": "Identifier", + "name": "name", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "alternate": null, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant A.", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "name", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + "throwMarker": "throws", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getValue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getValue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "e", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "e", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "toString", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "values", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "fromInt", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "fromInt", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "alternate": null, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant in A with ordinal value ", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + "throwMarker": "throws", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "unbox", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "unbox", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "boxedfromInt", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { "start": { "line": 1, "column": 1 @@ -1855,71 +5280,13 @@ "type": "BlockStatement", "statements": [ { - "type": "ForUpdateStatement", - "init": { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "init": { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "IfStatement", "test": { "type": "BinaryExpression", "operator": "<", "left": { "type": "Identifier", - "name": "i", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -1936,7 +5303,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#A#NamesArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -1952,126 +5319,7 @@ "property": { "type": "Identifier", "name": "length", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "update": { - "type": "UpdateExpression", - "operator": "++", - "prefix": true, - "argument": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "body": { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "==", - "left": { - "type": "Identifier", - "name": "name", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#A#NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": true, - "optional": false, + "decorators": [], "loc": { "start": { "line": 1, @@ -2083,6 +5331,8 @@ } } }, + "computed": false, + "optional": false, "loc": { "start": { "line": 1, @@ -2094,66 +5344,40 @@ } } }, - "consequent": { - "type": "ReturnStatement", - "argument": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "BoxedItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -2165,6 +5389,8 @@ } } }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -2176,7 +5402,6 @@ } } }, - "alternate": null, "loc": { "start": { "line": 1, @@ -2188,6 +5413,7 @@ } } }, + "alternate": null, "loc": { "start": { "line": 1, @@ -2250,7 +5476,7 @@ "operator": "+", "left": { "type": "StringLiteral", - "value": "No enum constant A.", + "value": "No enum constant in A with ordinal value ", "loc": { "start": { "line": 1, @@ -2264,7 +5490,7 @@ }, "right": { "type": "Identifier", - "name": "name", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2358,12 +5584,56 @@ "column": 1 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "#E", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ { "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#A#ValuesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2376,52 +5646,44 @@ } } }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "NumberLiteral", - "value": 1, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "accessibility": "protected", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 }, - { - "type": "NumberLiteral", - "value": 2, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "end": { + "line": 1, + "column": 1 } - ], + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "", + "decorators": [], "loc": { "start": { "line": 1, @@ -2433,16 +5695,48 @@ } } }, + "kind": "method", "accessibility": "public", "static": true, - "readonly": false, - "declare": false, "optional": false, "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSPrimitiveType", + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -2465,7 +5759,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2482,7 +5776,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#A#getValue", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -2495,9 +5789,9 @@ } } }, - "kind": "method", + "kind": "constructor", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -2506,7 +5800,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#A#getValue", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -2527,37 +5821,9 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "e", + "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -2593,47 +5859,18 @@ } } ], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, "body": { "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#A#ValuesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "e", - "decorators": [], + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", "loc": { "start": { "line": 1, @@ -2645,8 +5882,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -2658,6 +5897,23 @@ } } }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -2669,8 +5925,6 @@ } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 1, @@ -2744,7 +5998,7 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#A#StringValuesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -2762,7 +6016,154 @@ "elements": [ { "type": "StringLiteral", - "value": "0", + "value": "F", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "G", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "H", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "NumberLiteral", + "value": 0, "loc": { "start": { "line": 1, @@ -2775,8 +6176,8 @@ } }, { - "type": "StringLiteral", - "value": "1", + "type": "NumberLiteral", + "value": 1, "loc": { "start": { "line": 1, @@ -2789,8 +6190,8 @@ } }, { - "type": "StringLiteral", - "value": "2", + "type": "NumberLiteral", + "value": 2, "loc": { "start": { "line": 1, @@ -2814,7 +6215,7 @@ } } }, - "accessibility": "public", + "accessibility": "protected", "static": true, "readonly": false, "declare": false, @@ -2823,35 +6224,7 @@ "typeAnnotation": { "type": "TSArrayType", "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -2888,10 +6261,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#A#toString", + "name": "StringValuesArray", "decorators": [], "loc": { "start": { @@ -2903,234 +6276,91 @@ "column": 1 } } - }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "#A#toString", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#A#StringValuesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "0", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "1", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "2", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], + }, "loc": { "start": { "line": 1, @@ -3164,7 +6394,7 @@ } } }, - "overloads": [], + "definite": false, "decorators": [], "loc": { "start": { @@ -3181,7 +6411,7 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#A#ItemsArray", + "name": "ItemsArray", "decorators": [], "loc": { "start": { @@ -3201,7 +6431,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "A", + "name": "E", "decorators": [], "loc": { "start": { @@ -3216,7 +6446,7 @@ }, "property": { "type": "Identifier", - "name": "B", + "name": "F", "decorators": [], "loc": { "start": { @@ -3246,7 +6476,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "A", + "name": "E", "decorators": [], "loc": { "start": { @@ -3261,7 +6491,7 @@ }, "property": { "type": "Identifier", - "name": "C", + "name": "G", "decorators": [], "loc": { "start": { @@ -3291,7 +6521,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "A", + "name": "E", "decorators": [], "loc": { "start": { @@ -3306,7 +6536,7 @@ }, "property": { "type": "Identifier", - "name": "D", + "name": "H", "decorators": [], "loc": { "start": { @@ -3341,159 +6571,25 @@ "end": { "line": 1, "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "definite": false, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "#A#values", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "#A#values", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "E", + "decorators": [], "loc": { "start": { "line": 1, @@ -3516,49 +6612,6 @@ } } }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "#A#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, "loc": { "start": { "line": 1, @@ -3581,7 +6634,7 @@ } } }, - "overloads": [], + "definite": false, "decorators": [], "loc": { "start": { @@ -3595,10 +6648,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#A#fromInt", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -3611,41 +6664,19 @@ } } }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "#A#fromInt", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSPrimitiveType", + "type": "ArrayExpression", + "elements": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#E", + "decorators": [], "loc": { "start": { "line": 1, @@ -3657,38 +6688,6 @@ } } }, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "A", - "decorators": [], "loc": { "start": { "line": 1, @@ -3711,28 +6710,14 @@ } } }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ + "arguments": [ { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "<", - "left": { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { "type": "Identifier", - "name": "ordinal", + "name": "E", "decorators": [], "loc": { "start": { @@ -3745,40 +6730,10 @@ } } }, - "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#A#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "length", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, + "property": { + "type": "Identifier", + "name": "F", + "decorators": [], "loc": { "start": { "line": 1, @@ -3790,6 +6745,8 @@ } } }, + "computed": false, + "optional": false, "loc": { "start": { "line": 1, @@ -3801,53 +6758,52 @@ } } }, - "consequent": { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#A#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#E", + "decorators": [], "loc": { "start": { "line": 1, @@ -3859,7 +6815,6 @@ } } }, - "alternate": null, "loc": { "start": { "line": 1, @@ -3871,40 +6826,26 @@ } } }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ { - "type": "ThrowStatement", - "argument": { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Exception", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "E", + "decorators": [], "loc": { "start": { "line": 1, @@ -3916,51 +6857,36 @@ } } }, - "arguments": [ - { - "type": "BinaryExpression", - "operator": "+", - "left": { - "type": "StringLiteral", - "value": "No enum constant in A with ordinal value ", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "right": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "property": { + "type": "Identifier", + "name": "G", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -3994,94 +6920,123 @@ "column": 1 } } - } - "throwMarker": "throws", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#E#NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ { - "type": "StringLiteral", - "value": "F", - "loc": { - "start": { - "line": 1, - "column": 1 + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#E", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - } - }, - { - "type": "StringLiteral", - "value": "G", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "E", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "H", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } } - } - }, - { - "type": "StringLiteral", - "value": "H", + ], "loc": { "start": { "line": 1, @@ -4105,7 +7060,7 @@ } } }, - "accessibility": "public", + "accessibility": "protected", "static": true, "readonly": false, "declare": false, @@ -4119,7 +7074,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "#E", "decorators": [], "loc": { "start": { @@ -4182,7 +7137,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#E#getName", + "name": "getName", "decorators": [], "loc": { "start": { @@ -4206,7 +7161,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#E#getName", + "name": "getName", "decorators": [], "loc": { "start": { @@ -4343,7 +7298,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#E#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -4472,7 +7427,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#E#valueOf", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -4496,7 +7451,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#E#valueOf", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -4709,7 +7664,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#E#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -4815,7 +7770,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#E#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -5133,10 +8088,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#E#ValuesArray", + "name": "getValue", "decorators": [], "loc": { "start": { @@ -5149,12 +8104,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumberLiteral", - "value": 0, + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getValue", + "decorators": [], "loc": { "start": { "line": 1, @@ -5166,9 +8128,82 @@ } } }, - { - "type": "NumberLiteral", - "value": 1, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "e", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "E", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -5178,11 +8213,96 @@ "line": 1, "column": 1 } - } - }, - { - "type": "NumberLiteral", - "value": 2, + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "e", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], "loc": { "start": { "line": 1, @@ -5193,29 +8313,7 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -5238,7 +8336,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -5255,7 +8353,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#E#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -5279,7 +8377,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#E#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -5300,7 +8398,7 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "e", + "name": "ordinal", "typeAnnotation": { "type": "ETSTypeReference", "part": { @@ -5367,7 +8465,35 @@ } ], "returnType": { - "type": "ETSPrimitiveType", + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -5388,7 +8514,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#E#ValuesArray", + "name": "StringValuesArray", "decorators": [], "loc": { "start": { @@ -5405,7 +8531,7 @@ "type": "TSAsExpression", "expression": { "type": "Identifier", - "name": "e", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -5514,10 +8640,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#E#StringValuesArray", + "name": "values", "decorators": [], "loc": { "start": { @@ -5530,12 +8656,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "0", + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "values", + "decorators": [], "loc": { "start": { "line": 1, @@ -5547,23 +8680,53 @@ } } }, - { - "type": "StringLiteral", - "value": "1", - "loc": { - "start": { - "line": 1, - "column": 1 + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "E", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - } - }, - { - "type": "StringLiteral", - "value": "2", + }, "loc": { "start": { "line": 1, @@ -5574,46 +8737,39 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -5647,7 +8803,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -5664,7 +8820,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#E#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -5688,7 +8844,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#E#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -5711,35 +8867,7 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "E", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -5781,7 +8909,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "E", "decorators": [], "loc": { "start": { @@ -5820,12 +8948,13 @@ "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { "type": "Identifier", - "name": "#E#StringValuesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -5838,11 +8967,69 @@ } } }, - "property": { - "type": "TSAsExpression", - "expression": { + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { "type": "Identifier", - "name": "ordinal", + "name": "ItemsArray", "decorators": [], "loc": { "start": { @@ -5855,8 +9042,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -5868,6 +9057,8 @@ } } }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -5879,8 +9070,6 @@ } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 1, @@ -5892,6 +9081,7 @@ } } }, + "alternate": null, "loc": { "start": { "line": 1, @@ -5902,248 +9092,120 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#E#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "E", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "F", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "E", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "G", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "E", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "H", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "E", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant in E with ordinal value ", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -6154,7 +9216,8 @@ "column": 1 } } - }, + } + "throwMarker": "throws", "loc": { "start": { "line": 1, @@ -6177,7 +9240,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -6194,7 +9257,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#E#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -6209,7 +9272,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -6218,7 +9281,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#E#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -6236,26 +9299,13 @@ "expression": false, "params": [], "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "E", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "E", + "decorators": [], "loc": { "start": { "line": 1, @@ -6295,9 +9345,67 @@ { "type": "ReturnStatement", "argument": { - "type": "Identifier", - "name": "#E#ItemsArray", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -6371,7 +9479,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#E#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -6395,7 +9503,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#E#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -6460,7 +9568,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "E", + "name": "#E", "decorators": [], "loc": { "start": { @@ -6522,7 +9630,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#E#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -6580,7 +9688,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#E#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { diff --git a/ets2panda/test/parser/ets/switch_readonly_member_different_enum_2-expected.txt b/ets2panda/test/parser/ets/switch_readonly_member_different_enum_2-expected.txt index 7a5a3fef70db89ef899343652bbeb540aa21827a..4bb48cc0aeaf9eefd21116fba0824a3a30ba12f9 100644 --- a/ets2panda/test/parser/ets/switch_readonly_member_different_enum_2-expected.txt +++ b/ets2panda/test/parser/ets/switch_readonly_member_different_enum_2-expected.txt @@ -1257,12 +1257,56 @@ "column": 2 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "#A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ { "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#A#NamesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -1275,52 +1319,44 @@ } } }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "B", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "StringLiteral", - "value": "C", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "accessibility": "protected", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 }, - { - "type": "StringLiteral", - "value": "D", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "end": { + "line": 1, + "column": 1 } - ], + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "", + "decorators": [], "loc": { "start": { "line": 1, @@ -1332,33 +1368,37 @@ } } }, + "kind": "method", "accessibility": "public", "static": true, - "readonly": false, - "declare": false, "optional": false, "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], "loc": { "start": { "line": 1, @@ -1392,7 +1432,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -1409,7 +1449,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#A#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -1422,9 +1462,9 @@ } } }, - "kind": "method", + "kind": "constructor", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -1433,7 +1473,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#A#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -1456,12 +1496,68 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { "type": "Identifier", - "name": "A", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -1474,6 +1570,23 @@ } } }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -1496,147 +1609,6 @@ } } }, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#A#NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, "loc": { "start": { "line": 1, @@ -1696,10 +1668,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#A#valueOf", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1712,19 +1684,12 @@ } } }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "#A#valueOf", - "decorators": [], + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "B", "loc": { "start": { "line": 1, @@ -1736,100 +1701,3560 @@ } } }, - "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": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + { + "type": "StringLiteral", + "value": "C", + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { + }, + { + "type": "StringLiteral", + "value": "D", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "NumberLiteral", + "value": 2, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "0", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "1", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "2", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "B", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "C", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "D", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "BoxedItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "B", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "C", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "D", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getName", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "valueOf", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ForUpdateStatement", + "init": { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "init": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "update": { + "type": "UpdateExpression", + "operator": "++", + "prefix": true, + "argument": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "==", + "left": { + "type": "Identifier", + "name": "name", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "alternate": null, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant A.", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "name", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + "throwMarker": "throws", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getValue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getValue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "e", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "e", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "toString", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "values", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "fromInt", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "fromInt", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "alternate": null, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant in A with ordinal value ", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + "throwMarker": "throws", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "unbox", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "unbox", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "boxedfromInt", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { "start": { "line": 1, "column": 1 @@ -1855,71 +5280,13 @@ "type": "BlockStatement", "statements": [ { - "type": "ForUpdateStatement", - "init": { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "init": { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "IfStatement", "test": { "type": "BinaryExpression", "operator": "<", "left": { "type": "Identifier", - "name": "i", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -1936,7 +5303,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#A#NamesArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -1952,126 +5319,7 @@ "property": { "type": "Identifier", "name": "length", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "update": { - "type": "UpdateExpression", - "operator": "++", - "prefix": true, - "argument": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "body": { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "==", - "left": { - "type": "Identifier", - "name": "name", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#A#NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": true, - "optional": false, + "decorators": [], "loc": { "start": { "line": 1, @@ -2083,6 +5331,8 @@ } } }, + "computed": false, + "optional": false, "loc": { "start": { "line": 1, @@ -2094,66 +5344,40 @@ } } }, - "consequent": { - "type": "ReturnStatement", - "argument": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "BoxedItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -2165,6 +5389,8 @@ } } }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -2176,7 +5402,6 @@ } } }, - "alternate": null, "loc": { "start": { "line": 1, @@ -2188,6 +5413,7 @@ } } }, + "alternate": null, "loc": { "start": { "line": 1, @@ -2250,7 +5476,7 @@ "operator": "+", "left": { "type": "StringLiteral", - "value": "No enum constant A.", + "value": "No enum constant in A with ordinal value ", "loc": { "start": { "line": 1, @@ -2264,7 +5490,7 @@ }, "right": { "type": "Identifier", - "name": "name", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2358,12 +5584,56 @@ "column": 1 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "#E", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ { "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#A#ValuesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2376,52 +5646,44 @@ } } }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "NumberLiteral", - "value": 1, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "accessibility": "protected", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 }, - { - "type": "NumberLiteral", - "value": 2, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "end": { + "line": 1, + "column": 1 } - ], + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "", + "decorators": [], "loc": { "start": { "line": 1, @@ -2433,16 +5695,48 @@ } } }, + "kind": "method", "accessibility": "public", "static": true, - "readonly": false, - "declare": false, "optional": false, "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSPrimitiveType", + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -2465,7 +5759,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2482,7 +5776,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#A#getValue", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -2495,9 +5789,9 @@ } } }, - "kind": "method", + "kind": "constructor", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -2506,7 +5800,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#A#getValue", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -2527,37 +5821,9 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "e", + "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -2593,47 +5859,18 @@ } } ], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, "body": { "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#A#ValuesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "e", - "decorators": [], + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", "loc": { "start": { "line": 1, @@ -2645,8 +5882,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -2658,6 +5897,23 @@ } } }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -2669,8 +5925,6 @@ } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 1, @@ -2744,7 +5998,7 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#A#StringValuesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -2762,7 +6016,154 @@ "elements": [ { "type": "StringLiteral", - "value": "0", + "value": "F", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "G", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "H", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "NumberLiteral", + "value": 0, "loc": { "start": { "line": 1, @@ -2775,8 +6176,8 @@ } }, { - "type": "StringLiteral", - "value": "1", + "type": "NumberLiteral", + "value": 1, "loc": { "start": { "line": 1, @@ -2789,8 +6190,8 @@ } }, { - "type": "StringLiteral", - "value": "2", + "type": "NumberLiteral", + "value": 2, "loc": { "start": { "line": 1, @@ -2814,7 +6215,7 @@ } } }, - "accessibility": "public", + "accessibility": "protected", "static": true, "readonly": false, "declare": false, @@ -2823,35 +6224,7 @@ "typeAnnotation": { "type": "TSArrayType", "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -2888,10 +6261,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#A#toString", + "name": "StringValuesArray", "decorators": [], "loc": { "start": { @@ -2903,234 +6276,91 @@ "column": 1 } } - }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "#A#toString", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#A#StringValuesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "0", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "1", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "2", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], + }, "loc": { "start": { "line": 1, @@ -3164,7 +6394,7 @@ } } }, - "overloads": [], + "definite": false, "decorators": [], "loc": { "start": { @@ -3181,7 +6411,7 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#A#ItemsArray", + "name": "ItemsArray", "decorators": [], "loc": { "start": { @@ -3201,7 +6431,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "A", + "name": "E", "decorators": [], "loc": { "start": { @@ -3216,7 +6446,7 @@ }, "property": { "type": "Identifier", - "name": "B", + "name": "F", "decorators": [], "loc": { "start": { @@ -3246,7 +6476,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "A", + "name": "E", "decorators": [], "loc": { "start": { @@ -3261,7 +6491,7 @@ }, "property": { "type": "Identifier", - "name": "C", + "name": "G", "decorators": [], "loc": { "start": { @@ -3291,7 +6521,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "A", + "name": "E", "decorators": [], "loc": { "start": { @@ -3306,7 +6536,7 @@ }, "property": { "type": "Identifier", - "name": "D", + "name": "H", "decorators": [], "loc": { "start": { @@ -3341,159 +6571,25 @@ "end": { "line": 1, "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "definite": false, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "#A#values", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "#A#values", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "E", + "decorators": [], "loc": { "start": { "line": 1, @@ -3516,49 +6612,6 @@ } } }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "#A#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, "loc": { "start": { "line": 1, @@ -3581,7 +6634,7 @@ } } }, - "overloads": [], + "definite": false, "decorators": [], "loc": { "start": { @@ -3595,10 +6648,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#A#fromInt", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -3611,41 +6664,19 @@ } } }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "#A#fromInt", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSPrimitiveType", + "type": "ArrayExpression", + "elements": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#E", + "decorators": [], "loc": { "start": { "line": 1, @@ -3657,38 +6688,6 @@ } } }, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "A", - "decorators": [], "loc": { "start": { "line": 1, @@ -3711,28 +6710,14 @@ } } }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ + "arguments": [ { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "<", - "left": { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { "type": "Identifier", - "name": "ordinal", + "name": "E", "decorators": [], "loc": { "start": { @@ -3745,40 +6730,10 @@ } } }, - "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#A#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "length", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, + "property": { + "type": "Identifier", + "name": "F", + "decorators": [], "loc": { "start": { "line": 1, @@ -3790,6 +6745,8 @@ } } }, + "computed": false, + "optional": false, "loc": { "start": { "line": 1, @@ -3801,53 +6758,52 @@ } } }, - "consequent": { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#A#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#E", + "decorators": [], "loc": { "start": { "line": 1, @@ -3859,7 +6815,6 @@ } } }, - "alternate": null, "loc": { "start": { "line": 1, @@ -3871,40 +6826,26 @@ } } }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ { - "type": "ThrowStatement", - "argument": { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Exception", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "E", + "decorators": [], "loc": { "start": { "line": 1, @@ -3916,51 +6857,36 @@ } } }, - "arguments": [ - { - "type": "BinaryExpression", - "operator": "+", - "left": { - "type": "StringLiteral", - "value": "No enum constant in A with ordinal value ", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "right": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "property": { + "type": "Identifier", + "name": "G", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -3994,94 +6920,123 @@ "column": 1 } } - } - "throwMarker": "throws", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#E#NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ { - "type": "StringLiteral", - "value": "F", - "loc": { - "start": { - "line": 1, - "column": 1 + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#E", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - } - }, - { - "type": "StringLiteral", - "value": "G", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "E", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "H", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } } - } - }, - { - "type": "StringLiteral", - "value": "H", + ], "loc": { "start": { "line": 1, @@ -4105,7 +7060,7 @@ } } }, - "accessibility": "public", + "accessibility": "protected", "static": true, "readonly": false, "declare": false, @@ -4119,7 +7074,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "#E", "decorators": [], "loc": { "start": { @@ -4182,7 +7137,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#E#getName", + "name": "getName", "decorators": [], "loc": { "start": { @@ -4206,7 +7161,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#E#getName", + "name": "getName", "decorators": [], "loc": { "start": { @@ -4343,7 +7298,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#E#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -4472,7 +7427,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#E#valueOf", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -4496,7 +7451,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#E#valueOf", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -4709,7 +7664,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#E#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -4815,7 +7770,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#E#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -5133,10 +8088,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#E#ValuesArray", + "name": "getValue", "decorators": [], "loc": { "start": { @@ -5149,12 +8104,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumberLiteral", - "value": 0, + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getValue", + "decorators": [], "loc": { "start": { "line": 1, @@ -5166,9 +8128,82 @@ } } }, - { - "type": "NumberLiteral", - "value": 1, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "e", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "E", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -5178,11 +8213,96 @@ "line": 1, "column": 1 } - } - }, - { - "type": "NumberLiteral", - "value": 2, + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "e", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], "loc": { "start": { "line": 1, @@ -5193,29 +8313,7 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -5238,7 +8336,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -5255,7 +8353,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#E#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -5279,7 +8377,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#E#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -5300,7 +8398,7 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "e", + "name": "ordinal", "typeAnnotation": { "type": "ETSTypeReference", "part": { @@ -5367,7 +8465,35 @@ } ], "returnType": { - "type": "ETSPrimitiveType", + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -5388,7 +8514,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#E#ValuesArray", + "name": "StringValuesArray", "decorators": [], "loc": { "start": { @@ -5405,7 +8531,7 @@ "type": "TSAsExpression", "expression": { "type": "Identifier", - "name": "e", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -5514,10 +8640,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#E#StringValuesArray", + "name": "values", "decorators": [], "loc": { "start": { @@ -5530,12 +8656,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "0", + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "values", + "decorators": [], "loc": { "start": { "line": 1, @@ -5547,23 +8680,53 @@ } } }, - { - "type": "StringLiteral", - "value": "1", - "loc": { - "start": { - "line": 1, - "column": 1 + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "E", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - } - }, - { - "type": "StringLiteral", - "value": "2", + }, "loc": { "start": { "line": 1, @@ -5574,46 +8737,39 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -5647,7 +8803,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -5664,7 +8820,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#E#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -5688,7 +8844,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#E#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -5711,35 +8867,7 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "E", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -5781,7 +8909,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "E", "decorators": [], "loc": { "start": { @@ -5820,12 +8948,13 @@ "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { "type": "Identifier", - "name": "#E#StringValuesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -5838,11 +8967,69 @@ } } }, - "property": { - "type": "TSAsExpression", - "expression": { + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { "type": "Identifier", - "name": "ordinal", + "name": "ItemsArray", "decorators": [], "loc": { "start": { @@ -5855,8 +9042,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -5868,6 +9057,8 @@ } } }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -5879,8 +9070,6 @@ } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 1, @@ -5892,6 +9081,7 @@ } } }, + "alternate": null, "loc": { "start": { "line": 1, @@ -5902,248 +9092,120 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#E#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "E", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "F", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "E", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "G", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "E", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "H", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "E", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant in E with ordinal value ", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -6154,7 +9216,8 @@ "column": 1 } } - }, + } + "throwMarker": "throws", "loc": { "start": { "line": 1, @@ -6177,7 +9240,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -6194,7 +9257,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#E#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -6209,7 +9272,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -6218,7 +9281,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#E#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -6236,26 +9299,13 @@ "expression": false, "params": [], "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "E", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "E", + "decorators": [], "loc": { "start": { "line": 1, @@ -6295,9 +9345,67 @@ { "type": "ReturnStatement", "argument": { - "type": "Identifier", - "name": "#E#ItemsArray", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -6371,7 +9479,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#E#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -6395,7 +9503,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#E#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -6460,7 +9568,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "E", + "name": "#E", "decorators": [], "loc": { "start": { @@ -6522,7 +9630,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#E#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -6580,7 +9688,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#E#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { diff --git a/ets2panda/test/parser/ets/switch_readonly_member_enum-expected.txt b/ets2panda/test/parser/ets/switch_readonly_member_enum-expected.txt index 2ce74fb7d731fa017012dc4fdbf3ca26c6060596..88a355367a1d2c6ac56e66eea063c395aa4fc1bf 100644 --- a/ets2panda/test/parser/ets/switch_readonly_member_enum-expected.txt +++ b/ets2panda/test/parser/ets/switch_readonly_member_enum-expected.txt @@ -1257,12 +1257,56 @@ "column": 2 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "#A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ { "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#A#NamesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -1275,52 +1319,44 @@ } } }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "B", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "StringLiteral", - "value": "C", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "accessibility": "protected", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 }, - { - "type": "StringLiteral", - "value": "D", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "end": { + "line": 1, + "column": 1 } - ], + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "", + "decorators": [], "loc": { "start": { "line": 1, @@ -1332,33 +1368,37 @@ } } }, + "kind": "method", "accessibility": "public", "static": true, - "readonly": false, - "declare": false, "optional": false, "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], "loc": { "start": { "line": 1, @@ -1392,7 +1432,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -1409,7 +1449,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#A#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -1422,9 +1462,9 @@ } } }, - "kind": "method", + "kind": "constructor", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -1433,7 +1473,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#A#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -1456,12 +1496,68 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { "type": "Identifier", - "name": "A", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -1474,6 +1570,23 @@ } } }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -1496,147 +1609,6 @@ } } }, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#A#NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, "loc": { "start": { "line": 1, @@ -1696,10 +1668,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#A#valueOf", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1712,19 +1684,12 @@ } } }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "#A#valueOf", - "decorators": [], + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "B", "loc": { "start": { "line": 1, @@ -1736,100 +1701,3560 @@ } } }, - "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": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + { + "type": "StringLiteral", + "value": "C", + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { + }, + { + "type": "StringLiteral", + "value": "D", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "NumberLiteral", + "value": 2, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "0", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "1", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "2", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "B", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "C", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "D", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "BoxedItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "B", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "C", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "D", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getName", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "valueOf", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ForUpdateStatement", + "init": { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "init": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "update": { + "type": "UpdateExpression", + "operator": "++", + "prefix": true, + "argument": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "==", + "left": { + "type": "Identifier", + "name": "name", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "alternate": null, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant A.", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "name", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + "throwMarker": "throws", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getValue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getValue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "e", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "e", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "toString", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "values", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "fromInt", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "fromInt", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "alternate": null, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant in A with ordinal value ", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + "throwMarker": "throws", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "unbox", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "unbox", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "boxedfromInt", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { "start": { "line": 1, "column": 1 @@ -1855,71 +5280,13 @@ "type": "BlockStatement", "statements": [ { - "type": "ForUpdateStatement", - "init": { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "init": { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "IfStatement", "test": { "type": "BinaryExpression", "operator": "<", "left": { "type": "Identifier", - "name": "i", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -1936,7 +5303,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#A#NamesArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -1952,126 +5319,7 @@ "property": { "type": "Identifier", "name": "length", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "update": { - "type": "UpdateExpression", - "operator": "++", - "prefix": true, - "argument": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "body": { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "==", - "left": { - "type": "Identifier", - "name": "name", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#A#NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": true, - "optional": false, + "decorators": [], "loc": { "start": { "line": 1, @@ -2083,6 +5331,8 @@ } } }, + "computed": false, + "optional": false, "loc": { "start": { "line": 1, @@ -2094,66 +5344,40 @@ } } }, - "consequent": { - "type": "ReturnStatement", - "argument": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "BoxedItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -2165,6 +5389,8 @@ } } }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -2176,7 +5402,6 @@ } } }, - "alternate": null, "loc": { "start": { "line": 1, @@ -2188,6 +5413,7 @@ } } }, + "alternate": null, "loc": { "start": { "line": 1, @@ -2250,7 +5476,7 @@ "operator": "+", "left": { "type": "StringLiteral", - "value": "No enum constant A.", + "value": "No enum constant in A with ordinal value ", "loc": { "start": { "line": 1, @@ -2264,7 +5490,7 @@ }, "right": { "type": "Identifier", - "name": "name", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2358,12 +5584,56 @@ "column": 1 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "#E", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ { "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#A#ValuesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2376,52 +5646,44 @@ } } }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "NumberLiteral", - "value": 1, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "accessibility": "protected", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 }, - { - "type": "NumberLiteral", - "value": 2, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "end": { + "line": 1, + "column": 1 } - ], + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "", + "decorators": [], "loc": { "start": { "line": 1, @@ -2433,16 +5695,48 @@ } } }, + "kind": "method", "accessibility": "public", "static": true, - "readonly": false, - "declare": false, "optional": false, "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSPrimitiveType", + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -2465,7 +5759,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2482,7 +5776,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#A#getValue", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -2495,9 +5789,9 @@ } } }, - "kind": "method", + "kind": "constructor", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -2506,7 +5800,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#A#getValue", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -2527,37 +5821,9 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "e", + "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -2593,47 +5859,18 @@ } } ], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, "body": { "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#A#ValuesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "e", - "decorators": [], + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", "loc": { "start": { "line": 1, @@ -2645,8 +5882,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -2658,6 +5897,23 @@ } } }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -2669,8 +5925,6 @@ } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 1, @@ -2744,7 +5998,7 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#A#StringValuesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -2762,7 +6016,154 @@ "elements": [ { "type": "StringLiteral", - "value": "0", + "value": "F", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "G", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "H", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "NumberLiteral", + "value": 0, "loc": { "start": { "line": 1, @@ -2775,8 +6176,8 @@ } }, { - "type": "StringLiteral", - "value": "1", + "type": "NumberLiteral", + "value": 1, "loc": { "start": { "line": 1, @@ -2789,8 +6190,8 @@ } }, { - "type": "StringLiteral", - "value": "2", + "type": "NumberLiteral", + "value": 2, "loc": { "start": { "line": 1, @@ -2814,7 +6215,7 @@ } } }, - "accessibility": "public", + "accessibility": "protected", "static": true, "readonly": false, "declare": false, @@ -2823,35 +6224,7 @@ "typeAnnotation": { "type": "TSArrayType", "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -2888,10 +6261,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#A#toString", + "name": "StringValuesArray", "decorators": [], "loc": { "start": { @@ -2903,234 +6276,91 @@ "column": 1 } } - }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "#A#toString", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#A#StringValuesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "0", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "1", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "2", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], + }, "loc": { "start": { "line": 1, @@ -3164,7 +6394,7 @@ } } }, - "overloads": [], + "definite": false, "decorators": [], "loc": { "start": { @@ -3181,7 +6411,7 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#A#ItemsArray", + "name": "ItemsArray", "decorators": [], "loc": { "start": { @@ -3201,7 +6431,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "A", + "name": "E", "decorators": [], "loc": { "start": { @@ -3216,7 +6446,7 @@ }, "property": { "type": "Identifier", - "name": "B", + "name": "F", "decorators": [], "loc": { "start": { @@ -3246,7 +6476,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "A", + "name": "E", "decorators": [], "loc": { "start": { @@ -3261,7 +6491,7 @@ }, "property": { "type": "Identifier", - "name": "C", + "name": "G", "decorators": [], "loc": { "start": { @@ -3291,7 +6521,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "A", + "name": "E", "decorators": [], "loc": { "start": { @@ -3306,7 +6536,7 @@ }, "property": { "type": "Identifier", - "name": "D", + "name": "H", "decorators": [], "loc": { "start": { @@ -3341,159 +6571,25 @@ "end": { "line": 1, "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "definite": false, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "#A#values", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "#A#values", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "E", + "decorators": [], "loc": { "start": { "line": 1, @@ -3516,49 +6612,6 @@ } } }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "#A#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, "loc": { "start": { "line": 1, @@ -3581,7 +6634,7 @@ } } }, - "overloads": [], + "definite": false, "decorators": [], "loc": { "start": { @@ -3595,10 +6648,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#A#fromInt", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -3611,41 +6664,19 @@ } } }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "#A#fromInt", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSPrimitiveType", + "type": "ArrayExpression", + "elements": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#E", + "decorators": [], "loc": { "start": { "line": 1, @@ -3657,38 +6688,6 @@ } } }, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "A", - "decorators": [], "loc": { "start": { "line": 1, @@ -3711,28 +6710,14 @@ } } }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ + "arguments": [ { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "<", - "left": { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { "type": "Identifier", - "name": "ordinal", + "name": "E", "decorators": [], "loc": { "start": { @@ -3745,40 +6730,10 @@ } } }, - "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#A#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "length", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, + "property": { + "type": "Identifier", + "name": "F", + "decorators": [], "loc": { "start": { "line": 1, @@ -3790,6 +6745,8 @@ } } }, + "computed": false, + "optional": false, "loc": { "start": { "line": 1, @@ -3801,53 +6758,52 @@ } } }, - "consequent": { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#A#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#E", + "decorators": [], "loc": { "start": { "line": 1, @@ -3859,7 +6815,6 @@ } } }, - "alternate": null, "loc": { "start": { "line": 1, @@ -3871,40 +6826,26 @@ } } }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ { - "type": "ThrowStatement", - "argument": { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Exception", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "E", + "decorators": [], "loc": { "start": { "line": 1, @@ -3916,51 +6857,36 @@ } } }, - "arguments": [ - { - "type": "BinaryExpression", - "operator": "+", - "left": { - "type": "StringLiteral", - "value": "No enum constant in A with ordinal value ", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "right": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "property": { + "type": "Identifier", + "name": "G", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -3994,94 +6920,123 @@ "column": 1 } } - } - "throwMarker": "throws", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#E#NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ { - "type": "StringLiteral", - "value": "F", - "loc": { - "start": { - "line": 1, - "column": 1 + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#E", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - } - }, - { - "type": "StringLiteral", - "value": "G", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "E", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "H", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } } - } - }, - { - "type": "StringLiteral", - "value": "H", + ], "loc": { "start": { "line": 1, @@ -4105,7 +7060,7 @@ } } }, - "accessibility": "public", + "accessibility": "protected", "static": true, "readonly": false, "declare": false, @@ -4119,7 +7074,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "#E", "decorators": [], "loc": { "start": { @@ -4182,7 +7137,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#E#getName", + "name": "getName", "decorators": [], "loc": { "start": { @@ -4206,7 +7161,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#E#getName", + "name": "getName", "decorators": [], "loc": { "start": { @@ -4343,7 +7298,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#E#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -4472,7 +7427,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#E#valueOf", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -4496,7 +7451,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#E#valueOf", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -4709,7 +7664,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#E#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -4815,7 +7770,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#E#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -5133,10 +8088,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#E#ValuesArray", + "name": "getValue", "decorators": [], "loc": { "start": { @@ -5149,12 +8104,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumberLiteral", - "value": 0, + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getValue", + "decorators": [], "loc": { "start": { "line": 1, @@ -5166,9 +8128,82 @@ } } }, - { - "type": "NumberLiteral", - "value": 1, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "e", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "E", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -5178,11 +8213,96 @@ "line": 1, "column": 1 } - } - }, - { - "type": "NumberLiteral", - "value": 2, + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "e", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], "loc": { "start": { "line": 1, @@ -5193,29 +8313,7 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -5238,7 +8336,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -5255,7 +8353,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#E#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -5279,7 +8377,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#E#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -5300,7 +8398,7 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "e", + "name": "ordinal", "typeAnnotation": { "type": "ETSTypeReference", "part": { @@ -5367,7 +8465,35 @@ } ], "returnType": { - "type": "ETSPrimitiveType", + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -5388,7 +8514,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#E#ValuesArray", + "name": "StringValuesArray", "decorators": [], "loc": { "start": { @@ -5405,7 +8531,7 @@ "type": "TSAsExpression", "expression": { "type": "Identifier", - "name": "e", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -5514,10 +8640,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#E#StringValuesArray", + "name": "values", "decorators": [], "loc": { "start": { @@ -5530,12 +8656,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "0", + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "values", + "decorators": [], "loc": { "start": { "line": 1, @@ -5547,23 +8680,53 @@ } } }, - { - "type": "StringLiteral", - "value": "1", - "loc": { - "start": { - "line": 1, - "column": 1 + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "E", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - } - }, - { - "type": "StringLiteral", - "value": "2", + }, "loc": { "start": { "line": 1, @@ -5574,46 +8737,39 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -5647,7 +8803,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -5664,7 +8820,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#E#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -5688,7 +8844,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#E#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -5711,35 +8867,7 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "E", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -5781,7 +8909,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "E", "decorators": [], "loc": { "start": { @@ -5820,12 +8948,13 @@ "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { "type": "Identifier", - "name": "#E#StringValuesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -5838,11 +8967,69 @@ } } }, - "property": { - "type": "TSAsExpression", - "expression": { + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { "type": "Identifier", - "name": "ordinal", + "name": "ItemsArray", "decorators": [], "loc": { "start": { @@ -5855,8 +9042,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -5868,6 +9057,8 @@ } } }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -5879,8 +9070,6 @@ } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 1, @@ -5892,6 +9081,7 @@ } } }, + "alternate": null, "loc": { "start": { "line": 1, @@ -5902,248 +9092,120 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#E#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "E", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "F", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "E", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "G", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "E", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "H", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "E", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant in E with ordinal value ", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -6154,7 +9216,8 @@ "column": 1 } } - }, + } + "throwMarker": "throws", "loc": { "start": { "line": 1, @@ -6177,7 +9240,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -6194,7 +9257,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#E#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -6209,7 +9272,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -6218,7 +9281,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#E#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -6236,26 +9299,13 @@ "expression": false, "params": [], "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "E", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "E", + "decorators": [], "loc": { "start": { "line": 1, @@ -6295,9 +9345,67 @@ { "type": "ReturnStatement", "argument": { - "type": "Identifier", - "name": "#E#ItemsArray", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -6371,7 +9479,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#E#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -6395,7 +9503,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#E#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -6460,7 +9568,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "E", + "name": "#E", "decorators": [], "loc": { "start": { @@ -6522,7 +9630,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#E#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -6580,7 +9688,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#E#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { diff --git a/ets2panda/test/parser/ets/switch_readonly_member_enum_duplicate-expected.txt b/ets2panda/test/parser/ets/switch_readonly_member_enum_duplicate-expected.txt index b13363f85cd9ff894bb1f4b171d9b38ffb55b838..8e038b713bf1733c4d9e95ae6595841c884a659d 100644 --- a/ets2panda/test/parser/ets/switch_readonly_member_enum_duplicate-expected.txt +++ b/ets2panda/test/parser/ets/switch_readonly_member_enum_duplicate-expected.txt @@ -1257,12 +1257,56 @@ "column": 2 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "#A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ { "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#A#NamesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -1275,52 +1319,44 @@ } } }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "B", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "StringLiteral", - "value": "C", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "accessibility": "protected", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 }, - { - "type": "StringLiteral", - "value": "D", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "end": { + "line": 1, + "column": 1 } - ], + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "", + "decorators": [], "loc": { "start": { "line": 1, @@ -1332,33 +1368,37 @@ } } }, + "kind": "method", "accessibility": "public", "static": true, - "readonly": false, - "declare": false, "optional": false, "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], "loc": { "start": { "line": 1, @@ -1392,7 +1432,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -1409,7 +1449,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#A#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -1422,9 +1462,9 @@ } } }, - "kind": "method", + "kind": "constructor", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -1433,7 +1473,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#A#getName", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -1456,12 +1496,68 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { "type": "Identifier", - "name": "A", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -1474,6 +1570,23 @@ } } }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -1496,147 +1609,6 @@ } } }, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#A#NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, "loc": { "start": { "line": 1, @@ -1696,10 +1668,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#A#valueOf", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -1712,19 +1684,12 @@ } } }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "#A#valueOf", - "decorators": [], + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "B", "loc": { "start": { "line": 1, @@ -1736,100 +1701,3560 @@ } } }, - "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": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + { + "type": "StringLiteral", + "value": "C", + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { + }, + { + "type": "StringLiteral", + "value": "D", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "NumberLiteral", + "value": 2, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "0", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "1", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "2", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "B", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "C", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "D", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "BoxedItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "B", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "C", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "D", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getName", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "valueOf", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ForUpdateStatement", + "init": { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "init": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "update": { + "type": "UpdateExpression", + "operator": "++", + "prefix": true, + "argument": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "==", + "left": { + "type": "Identifier", + "name": "name", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "NamesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "i", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "alternate": null, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant A.", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "name", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + "throwMarker": "throws", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "getValue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getValue", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "e", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "e", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "toString", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "StringValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "values", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "fromInt", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "fromInt", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "alternate": null, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant in A with ordinal value ", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + "throwMarker": "throws", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "unbox", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "unbox", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "boxedfromInt", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "ordinal", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#A", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { "start": { "line": 1, "column": 1 @@ -1855,71 +5280,13 @@ "type": "BlockStatement", "statements": [ { - "type": "ForUpdateStatement", - "init": { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "init": { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "IfStatement", "test": { "type": "BinaryExpression", "operator": "<", "left": { "type": "Identifier", - "name": "i", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -1936,7 +5303,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#A#NamesArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -1952,126 +5319,7 @@ "property": { "type": "Identifier", "name": "length", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "update": { - "type": "UpdateExpression", - "operator": "++", - "prefix": true, - "argument": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "body": { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "==", - "left": { - "type": "Identifier", - "name": "name", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#A#NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": true, - "optional": false, + "decorators": [], "loc": { "start": { "line": 1, @@ -2083,6 +5331,8 @@ } } }, + "computed": false, + "optional": false, "loc": { "start": { "line": 1, @@ -2094,66 +5344,40 @@ } } }, - "consequent": { - "type": "ReturnStatement", - "argument": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "BoxedItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } - }, + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -2165,6 +5389,8 @@ } } }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -2176,7 +5402,6 @@ } } }, - "alternate": null, "loc": { "start": { "line": 1, @@ -2188,6 +5413,7 @@ } } }, + "alternate": null, "loc": { "start": { "line": 1, @@ -2250,7 +5476,7 @@ "operator": "+", "left": { "type": "StringLiteral", - "value": "No enum constant A.", + "value": "No enum constant in A with ordinal value ", "loc": { "start": { "line": 1, @@ -2264,7 +5490,7 @@ }, "right": { "type": "Identifier", - "name": "name", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2358,12 +5584,56 @@ "column": 1 } } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "#E", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ { "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#A#ValuesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -2376,52 +5646,44 @@ } } }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "NumberLiteral", - "value": 1, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "accessibility": "protected", + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 }, - { - "type": "NumberLiteral", - "value": 2, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "end": { + "line": 1, + "column": 1 } - ], + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "", + "decorators": [], "loc": { "start": { "line": 1, @@ -2433,16 +5695,48 @@ } } }, + "kind": "method", "accessibility": "public", "static": true, - "readonly": false, - "declare": false, "optional": false, "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSPrimitiveType", + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -2465,7 +5759,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -2482,7 +5776,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#A#getValue", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -2495,9 +5789,9 @@ } } }, - "kind": "method", + "kind": "constructor", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -2506,7 +5800,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#A#getValue", + "name": "constructor", "decorators": [], "loc": { "start": { @@ -2527,37 +5821,9 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "e", + "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -2593,47 +5859,18 @@ } } ], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, "body": { "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#A#ValuesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "e", - "decorators": [], + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", "loc": { "start": { "line": 1, @@ -2645,8 +5882,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -2658,6 +5897,23 @@ } } }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -2669,8 +5925,6 @@ } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 1, @@ -2744,7 +5998,7 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#A#StringValuesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -2762,7 +6016,154 @@ "elements": [ { "type": "StringLiteral", - "value": "0", + "value": "F", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "G", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "H", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "NumberLiteral", + "value": 0, "loc": { "start": { "line": 1, @@ -2775,8 +6176,8 @@ } }, { - "type": "StringLiteral", - "value": "1", + "type": "NumberLiteral", + "value": 1, "loc": { "start": { "line": 1, @@ -2789,8 +6190,8 @@ } }, { - "type": "StringLiteral", - "value": "2", + "type": "NumberLiteral", + "value": 2, "loc": { "start": { "line": 1, @@ -2814,7 +6215,7 @@ } } }, - "accessibility": "public", + "accessibility": "protected", "static": true, "readonly": false, "declare": false, @@ -2823,35 +6224,7 @@ "typeAnnotation": { "type": "TSArrayType", "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -2888,10 +6261,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#A#toString", + "name": "StringValuesArray", "decorators": [], "loc": { "start": { @@ -2903,234 +6276,91 @@ "column": 1 } } - }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "#A#toString", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#A#StringValuesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "TSAsExpression", - "expression": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + }, + "value": { + "type": "ArrayExpression", + "elements": [ + { + "type": "StringLiteral", + "value": "0", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "1", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "StringLiteral", + "value": "2", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], + }, "loc": { "start": { "line": 1, @@ -3164,7 +6394,7 @@ } } }, - "overloads": [], + "definite": false, "decorators": [], "loc": { "start": { @@ -3181,7 +6411,7 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#A#ItemsArray", + "name": "ItemsArray", "decorators": [], "loc": { "start": { @@ -3201,7 +6431,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "A", + "name": "E", "decorators": [], "loc": { "start": { @@ -3216,7 +6446,7 @@ }, "property": { "type": "Identifier", - "name": "B", + "name": "F", "decorators": [], "loc": { "start": { @@ -3246,7 +6476,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "A", + "name": "E", "decorators": [], "loc": { "start": { @@ -3261,7 +6491,7 @@ }, "property": { "type": "Identifier", - "name": "C", + "name": "G", "decorators": [], "loc": { "start": { @@ -3291,7 +6521,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "A", + "name": "E", "decorators": [], "loc": { "start": { @@ -3306,7 +6536,7 @@ }, "property": { "type": "Identifier", - "name": "D", + "name": "H", "decorators": [], "loc": { "start": { @@ -3341,159 +6571,25 @@ "end": { "line": 1, "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "definite": false, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "#A#values", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "#A#values", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + } + } + }, + "accessibility": "protected", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "E", + "decorators": [], "loc": { "start": { "line": 1, @@ -3516,49 +6612,6 @@ } } }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "#A#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, "loc": { "start": { "line": 1, @@ -3581,7 +6634,7 @@ } } }, - "overloads": [], + "definite": false, "decorators": [], "loc": { "start": { @@ -3595,10 +6648,10 @@ } }, { - "type": "MethodDefinition", + "type": "ClassProperty", "key": { "type": "Identifier", - "name": "#A#fromInt", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -3611,41 +6664,19 @@ } } }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "#A#fromInt", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "ordinal", - "typeAnnotation": { - "type": "ETSPrimitiveType", + "type": "ArrayExpression", + "elements": [ + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#E", + "decorators": [], "loc": { "start": { "line": 1, @@ -3657,38 +6688,6 @@ } } }, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "A", - "decorators": [], "loc": { "start": { "line": 1, @@ -3711,28 +6710,14 @@ } } }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ + "arguments": [ { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "<", - "left": { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { "type": "Identifier", - "name": "ordinal", + "name": "E", "decorators": [], "loc": { "start": { @@ -3745,40 +6730,10 @@ } } }, - "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#A#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "length", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, + "property": { + "type": "Identifier", + "name": "F", + "decorators": [], "loc": { "start": { "line": 1, @@ -3790,6 +6745,8 @@ } } }, + "computed": false, + "optional": false, "loc": { "start": { "line": 1, @@ -3801,53 +6758,52 @@ } } }, - "consequent": { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "#A#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#E", + "decorators": [], "loc": { "start": { "line": 1, @@ -3859,7 +6815,6 @@ } } }, - "alternate": null, "loc": { "start": { "line": 1, @@ -3871,40 +6826,26 @@ } } }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ { - "type": "ThrowStatement", - "argument": { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Exception", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "E", + "decorators": [], "loc": { "start": { "line": 1, @@ -3916,51 +6857,36 @@ } } }, - "arguments": [ - { - "type": "BinaryExpression", - "operator": "+", - "left": { - "type": "StringLiteral", - "value": "No enum constant in A with ordinal value ", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "right": { - "type": "Identifier", - "name": "ordinal", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } + "property": { + "type": "Identifier", + "name": "G", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 1, + "column": 1 } } - ], + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -3994,94 +6920,123 @@ "column": 1 } } - } - "throwMarker": "throws", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#E#NamesArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ { - "type": "StringLiteral", - "value": "F", - "loc": { - "start": { - "line": 1, - "column": 1 + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "#E", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - } - }, - { - "type": "StringLiteral", - "value": "G", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 + }, + "arguments": [ + { + "type": "TSAsExpression", + "expression": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "E", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "H", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } } - } - }, - { - "type": "StringLiteral", - "value": "H", + ], "loc": { "start": { "line": 1, @@ -4105,7 +7060,7 @@ } } }, - "accessibility": "public", + "accessibility": "protected", "static": true, "readonly": false, "declare": false, @@ -4119,7 +7074,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "#E", "decorators": [], "loc": { "start": { @@ -4182,7 +7137,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#E#getName", + "name": "getName", "decorators": [], "loc": { "start": { @@ -4206,7 +7161,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#E#getName", + "name": "getName", "decorators": [], "loc": { "start": { @@ -4343,7 +7298,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#E#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -4472,7 +7427,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#E#valueOf", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -4496,7 +7451,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#E#valueOf", + "name": "valueOf", "decorators": [], "loc": { "start": { @@ -4709,7 +7664,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#E#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -4815,7 +7770,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#E#NamesArray", + "name": "NamesArray", "decorators": [], "loc": { "start": { @@ -5133,10 +8088,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#E#ValuesArray", + "name": "getValue", "decorators": [], "loc": { "start": { @@ -5149,12 +8104,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "NumberLiteral", - "value": 0, + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "getValue", + "decorators": [], "loc": { "start": { "line": 1, @@ -5166,9 +8128,82 @@ } } }, - { - "type": "NumberLiteral", - "value": 1, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "e", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "E", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -5178,11 +8213,96 @@ "line": 1, "column": 1 } - } - }, - { - "type": "NumberLiteral", - "value": 2, + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ValuesArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "TSAsExpression", + "expression": { + "type": "Identifier", + "name": "e", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], "loc": { "start": { "line": 1, @@ -5193,29 +8313,7 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -5238,7 +8336,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -5255,7 +8353,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#E#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -5279,7 +8377,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#E#getValue", + "name": "toString", "decorators": [], "loc": { "start": { @@ -5300,7 +8398,7 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "e", + "name": "ordinal", "typeAnnotation": { "type": "ETSTypeReference", "part": { @@ -5367,7 +8465,35 @@ } ], "returnType": { - "type": "ETSPrimitiveType", + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "String", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, "loc": { "start": { "line": 1, @@ -5388,7 +8514,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#E#ValuesArray", + "name": "StringValuesArray", "decorators": [], "loc": { "start": { @@ -5405,7 +8531,7 @@ "type": "TSAsExpression", "expression": { "type": "Identifier", - "name": "e", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -5514,10 +8640,10 @@ } }, { - "type": "ClassProperty", + "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#E#StringValuesArray", + "name": "values", "decorators": [], "loc": { "start": { @@ -5530,12 +8656,19 @@ } } }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "StringLiteral", - "value": "0", + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "values", + "decorators": [], "loc": { "start": { "line": 1, @@ -5547,23 +8680,53 @@ } } }, - { - "type": "StringLiteral", - "value": "1", - "loc": { - "start": { - "line": 1, - "column": 1 + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "TSArrayType", + "elementType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "E", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } - } - }, - { - "type": "StringLiteral", - "value": "2", + }, "loc": { "start": { "line": 1, @@ -5574,46 +8737,39 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -5647,7 +8803,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -5664,7 +8820,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#E#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -5688,7 +8844,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#E#toString", + "name": "fromInt", "decorators": [], "loc": { "start": { @@ -5711,35 +8867,7 @@ "type": "Identifier", "name": "ordinal", "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "E", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSPrimitiveType", "loc": { "start": { "line": 1, @@ -5781,7 +8909,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "String", + "name": "E", "decorators": [], "loc": { "start": { @@ -5820,12 +8948,13 @@ "type": "BlockStatement", "statements": [ { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { + "type": "IfStatement", + "test": { + "type": "BinaryExpression", + "operator": "<", + "left": { "type": "Identifier", - "name": "#E#StringValuesArray", + "name": "ordinal", "decorators": [], "loc": { "start": { @@ -5838,11 +8967,69 @@ } } }, - "property": { - "type": "TSAsExpression", - "expression": { + "right": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "length", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "consequent": { + "type": "ReturnStatement", + "argument": { + "type": "MemberExpression", + "object": { "type": "Identifier", - "name": "ordinal", + "name": "ItemsArray", "decorators": [], "loc": { "start": { @@ -5855,8 +9042,10 @@ } } }, - "typeAnnotation": { - "type": "ETSPrimitiveType", + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], "loc": { "start": { "line": 1, @@ -5868,6 +9057,8 @@ } } }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -5879,8 +9070,6 @@ } } }, - "computed": true, - "optional": false, "loc": { "start": { "line": 1, @@ -5892,6 +9081,7 @@ } } }, + "alternate": null, "loc": { "start": { "line": 1, @@ -5902,248 +9092,120 @@ "column": 1 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "#E#ItemsArray", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "value": { - "type": "ArrayExpression", - "elements": [ - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "E", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "F", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "E", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "G", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "E", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { - "type": "Identifier", - "name": "H", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "E", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 + { + "type": "ThrowStatement", + "argument": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Exception", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "StringLiteral", + "value": "No enum constant in E with ordinal value ", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } }, - "end": { - "line": 1, - "column": 1 + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } } } - }, + ], "loc": { "start": { "line": 1, @@ -6154,7 +9216,8 @@ "column": 1 } } - }, + } + "throwMarker": "throws", "loc": { "start": { "line": 1, @@ -6177,7 +9240,7 @@ } } }, - "definite": false, + "overloads": [], "decorators": [], "loc": { "start": { @@ -6194,7 +9257,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#E#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -6209,7 +9272,7 @@ }, "kind": "method", "accessibility": "public", - "static": true, + "static": false, "optional": false, "computed": false, "value": { @@ -6218,7 +9281,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#E#values", + "name": "unbox", "decorators": [], "loc": { "start": { @@ -6236,26 +9299,13 @@ "expression": false, "params": [], "returnType": { - "type": "TSArrayType", - "elementType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "E", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "E", + "decorators": [], "loc": { "start": { "line": 1, @@ -6295,9 +9345,67 @@ { "type": "ReturnStatement", "argument": { - "type": "Identifier", - "name": "#E#ItemsArray", - "decorators": [], + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "ItemsArray", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "ordinal", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": true, + "optional": false, "loc": { "start": { "line": 1, @@ -6371,7 +9479,7 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "#E#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -6395,7 +9503,7 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "#E#fromInt", + "name": "boxedfromInt", "decorators": [], "loc": { "start": { @@ -6460,7 +9568,7 @@ "type": "ETSTypeReferencePart", "name": { "type": "Identifier", - "name": "E", + "name": "#E", "decorators": [], "loc": { "start": { @@ -6522,7 +9630,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#E#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { @@ -6580,7 +9688,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "#E#ItemsArray", + "name": "BoxedItemsArray", "decorators": [], "loc": { "start": { diff --git a/ets2panda/test/parser/ets/test-type-alias-call7-expected.txt b/ets2panda/test/parser/ets/test-type-alias-call7-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..11ad0677de0cc89ec154c142e6bd03270cd83a41 --- /dev/null +++ b/ets2panda/test/parser/ets/test-type-alias-call7-expected.txt @@ -0,0 +1,250 @@ +{ + "type": "Program", + "statements": [ + { + "type": "TSTypeAliasDeclaration", + "id": { + "type": "Identifier", + "name": "Callback", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 6 + }, + "end": { + "line": 16, + "column": 14 + } + } + }, + "typeAnnotation": { + "type": "ETSFunctionType", + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "n", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 16, + "column": 21 + }, + "end": { + "line": 16, + "column": 24 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 18 + }, + "end": { + "line": 16, + "column": 24 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 18 + }, + "end": { + "line": 16, + "column": 24 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 16, + "column": 29 + }, + "end": { + "line": 16, + "column": 32 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 17 + }, + "end": { + "line": 16, + "column": 32 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 1 + }, + "end": { + "line": 17, + "column": 7 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ETSGLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "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 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 18, + "column": 1 + } + } +} diff --git a/ets2panda/test/parser/ets/recursive_import/case_4_3-sources-in-circle_no-ets-module-compile_2/main__foo1_as__module-expected.txt b/ets2panda/test/parser/ets/test-type-alias-call8-expected.txt similarity index 61% rename from ets2panda/test/parser/ets/recursive_import/case_4_3-sources-in-circle_no-ets-module-compile_2/main__foo1_as__module-expected.txt rename to ets2panda/test/parser/ets/test-type-alias-call8-expected.txt index 5ad82849108db47f33c5019b29a393d7f9c49177..14d93e5b60e29ec74fc2559c5e7dba0eb60930f5 100644 --- a/ets2panda/test/parser/ets/recursive_import/case_4_3-sources-in-circle_no-ets-module-compile_2/main__foo1_as__module-expected.txt +++ b/ets2panda/test/parser/ets/test-type-alias-call8-expected.txt @@ -5,15 +5,15 @@ "type": "ImportDeclaration", "source": { "type": "StringLiteral", - "value": "./foo3__module", + "value": "./test-type-alias-call7", "loc": { "start": { - "line": 16, - "column": 24 + "line": 17, + "column": 31 }, "end": { - "line": 16, - "column": 40 + "line": 17, + "column": 56 } } }, @@ -22,54 +22,54 @@ "type": "ImportSpecifier", "local": { "type": "Identifier", - "name": "foo_in_3", + "name": "Callback", "decorators": [], "loc": { "start": { - "line": 16, - "column": 9 + "line": 17, + "column": 15 }, "end": { - "line": 16, - "column": 17 + "line": 17, + "column": 23 } } }, "imported": { "type": "Identifier", - "name": "foo_in_3", + "name": "Callback", "decorators": [], "loc": { "start": { - "line": 16, - "column": 9 + "line": 17, + "column": 15 }, "end": { - "line": 16, - "column": 17 + "line": 17, + "column": 23 } } }, "loc": { "start": { - "line": 16, - "column": 9 + "line": 17, + "column": 15 }, "end": { - "line": 16, - "column": 17 + "line": 17, + "column": 23 } } } ], "loc": { "start": { - "line": 16, + "line": 17, "column": 1 }, "end": { - "line": 16, - "column": 40 + "line": 17, + "column": 57 } } }, @@ -83,11 +83,11 @@ "loc": { "start": { "line": 18, - "column": 14 + "column": 7 }, "end": { "line": 18, - "column": 15 + "column": 8 } } }, @@ -98,16 +98,16 @@ "type": "ClassProperty", "key": { "type": "Identifier", - "name": "a", + "name": "callback", "decorators": [], "loc": { "start": { "line": 19, - "column": 5 + "column": 12 }, "end": { "line": 19, - "column": 6 + "column": 20 } } }, @@ -118,14 +118,42 @@ "optional": false, "computed": false, "typeAnnotation": { - "type": "ETSPrimitiveType", + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Callback", + "decorators": [], + "loc": { + "start": { + "line": 19, + "column": 22 + }, + "end": { + "line": 19, + "column": 30 + } + } + }, + "loc": { + "start": { + "line": 19, + "column": 22 + }, + "end": { + "line": 20, + "column": 11 + } + } + }, "loc": { "start": { "line": 19, - "column": 8 + "column": 22 }, "end": { - "line": 19, + "line": 20, "column": 11 } } @@ -135,14 +163,195 @@ "loc": { "start": { "line": 19, - "column": 5 + "column": 12 }, "end": { - "line": 19, + "line": 20, "column": 11 } } }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "increment", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 12 + }, + "end": { + "line": 20, + "column": 21 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "increment", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 12 + }, + "end": { + "line": 20, + "column": 21 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "object": { + "type": "ThisExpression", + "loc": { + "start": { + "line": 21, + "column": 9 + }, + "end": { + "line": 21, + "column": 13 + } + } + }, + "property": { + "type": "Identifier", + "name": "callback", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 14 + }, + "end": { + "line": 21, + "column": 22 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 21, + "column": 9 + }, + "end": { + "line": 21, + "column": 22 + } + } + }, + "arguments": [ + { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 21, + "column": 23 + }, + "end": { + "line": 21, + "column": 24 + } + } + } + ], + "optional": false, + "loc": { + "start": { + "line": 21, + "column": 9 + }, + "end": { + "line": 21, + "column": 25 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 9 + }, + "end": { + "line": 21, + "column": 25 + } + } + } + ], + "loc": { + "start": { + "line": 20, + "column": 23 + }, + "end": { + "line": 22, + "column": 6 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 21 + }, + "end": { + "line": 22, + "column": 6 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 21 + }, + "end": { + "line": 22, + "column": 6 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 5 + }, + "end": { + "line": 22, + "column": 6 + } + } + }, { "type": "MethodDefinition", "key": { @@ -227,11 +436,11 @@ "decorators": [], "loc": { "start": { - "line": 20, + "line": 23, "column": 2 }, "end": { - "line": 20, + "line": 23, "column": 2 } } @@ -240,10 +449,10 @@ "loc": { "start": { "line": 18, - "column": 16 + "column": 9 }, "end": { - "line": 20, + "line": 23, "column": 2 } } @@ -251,10 +460,10 @@ "loc": { "start": { "line": 18, - "column": 8 + "column": 1 }, "end": { - "line": 20, + "line": 23, "column": 2 } } @@ -284,16 +493,16 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "main", + "name": "_$init$_", "decorators": [], "loc": { "start": { - "line": 23, - "column": 10 + "line": 1, + "column": 1 }, "end": { - "line": 23, - "column": 14 + "line": 1, + "column": 1 } } }, @@ -308,16 +517,16 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "main", + "name": "_$init$_", "decorators": [], "loc": { "start": { - "line": 23, - "column": 10 + "line": 1, + "column": 1 }, "end": { - "line": 23, - "column": 14 + "line": 1, + "column": 1 } } }, @@ -325,195 +534,39 @@ "async": false, "expression": false, "params": [], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 23, - "column": 19 - }, - "end": { - "line": 23, - "column": 23 - } - } - }, "body": { "type": "BlockStatement", - "statements": [ - { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "a", - "decorators": [], - "loc": { - "start": { - "line": 24, - "column": 9 - }, - "end": { - "line": 24, - "column": 10 - } - } - }, - "init": { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 24, - "column": 17 - }, - "end": { - "line": 24, - "column": 18 - } - } - }, - "loc": { - "start": { - "line": 24, - "column": 17 - }, - "end": { - "line": 24, - "column": 19 - } - } - }, - "loc": { - "start": { - "line": 24, - "column": 17 - }, - "end": { - "line": 24, - "column": 19 - } - } - }, - "arguments": [], - "loc": { - "start": { - "line": 24, - "column": 13 - }, - "end": { - "line": 24, - "column": 21 - } - } - }, - "loc": { - "start": { - "line": 24, - "column": 9 - }, - "end": { - "line": 24, - "column": 21 - } - } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 24, - "column": 5 - }, - "end": { - "line": 24, - "column": 21 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "foo_in_3", - "decorators": [], - "loc": { - "start": { - "line": 25, - "column": 5 - }, - "end": { - "line": 25, - "column": 13 - } - } - }, - "arguments": [], - "optional": false, - "loc": { - "start": { - "line": 25, - "column": 5 - }, - "end": { - "line": 25, - "column": 15 - } - } - }, - "loc": { - "start": { - "line": 25, - "column": 5 - }, - "end": { - "line": 25, - "column": 16 - } - } - } - ], + "statements": [], "loc": { "start": { - "line": 23, - "column": 24 + "line": 1, + "column": 1 }, "end": { - "line": 26, - "column": 2 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 23, - "column": 14 + "line": 1, + "column": 1 }, "end": { - "line": 26, - "column": 2 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 23, - "column": 14 + "line": 1, + "column": 1 }, "end": { - "line": 26, - "column": 2 + "line": 1, + "column": 1 } } }, @@ -521,12 +574,12 @@ "decorators": [], "loc": { "start": { - "line": 23, + "line": 1, "column": 1 }, "end": { - "line": 26, - "column": 2 + "line": 1, + "column": 1 } } } @@ -560,7 +613,7 @@ "column": 1 }, "end": { - "line": 27, + "line": 24, "column": 1 } } diff --git a/ets2panda/test/parser/ets/test-type-alias-call8.sts b/ets2panda/test/parser/ets/test-type-alias-call8.sts index 279e013f01a8886aa8f746ab02dc96e631f2ec5b..8b7cd710e93a1d1f8f534d67ee8b6b891f6bb900 100644 --- a/ets2panda/test/parser/ets/test-type-alias-call8.sts +++ b/ets2panda/test/parser/ets/test-type-alias-call8.sts @@ -13,7 +13,8 @@ * limitations under the License. */ -import type { Callback } from './test-type-alias-call3.sts'; + +import type { Callback } from './test-type-alias-call7'; class A { public callback: Callback public increment(){ diff --git a/ets2panda/test/parser/ets/recursive_import/case_0/main__foo1_as__module-expected.txt b/ets2panda/test/parser/ets/wrong-union-array-assignment-expected.txt similarity index 63% rename from ets2panda/test/parser/ets/recursive_import/case_0/main__foo1_as__module-expected.txt rename to ets2panda/test/parser/ets/wrong-union-array-assignment-expected.txt index 72b4c78e71162d6134fe1f6a4758c0ca682dbfee..d18803401b900770cf79ba05de25e4e4b0fa5102 100644 --- a/ets2panda/test/parser/ets/recursive_import/case_0/main__foo1_as__module-expected.txt +++ b/ets2panda/test/parser/ets/wrong-union-array-assignment-expected.txt @@ -1,148 +1,27 @@ { "type": "Program", "statements": [ - { - "type": "ImportDeclaration", - "source": { - "type": "StringLiteral", - "value": "./foo2__module", - "loc": { - "start": { - "line": 16, - "column": 19 - }, - "end": { - "line": 16, - "column": 35 - } - } - }, - "specifiers": [ - { - "type": "ImportSpecifier", - "local": { - "type": "Identifier", - "name": "foo", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 9 - }, - "end": { - "line": 16, - "column": 12 - } - } - }, - "imported": { - "type": "Identifier", - "name": "foo", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 9 - }, - "end": { - "line": 16, - "column": 12 - } - } - }, - "loc": { - "start": { - "line": 16, - "column": 9 - }, - "end": { - "line": 16, - "column": 12 - } - } - } - ], - "loc": { - "start": { - "line": 16, - "column": 1 - }, - "end": { - "line": 16, - "column": 35 - } - } - }, { "type": "ClassDeclaration", "definition": { "id": { "type": "Identifier", - "name": "A", + "name": "Bad", "decorators": [], "loc": { "start": { - "line": 18, - "column": 14 + "line": 16, + "column": 7 }, "end": { - "line": 18, - "column": 15 + "line": 16, + "column": 10 } } }, "superClass": null, "implements": [], "body": [ - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "a", - "decorators": [], - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 6 - } - } - }, - "accessibility": "public", - "static": false, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 19, - "column": 8 - }, - "end": { - "line": 19, - "column": 11 - } - } - }, - "definite": false, - "decorators": [], - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 11 - } - } - }, { "type": "MethodDefinition", "key": { @@ -227,11 +106,11 @@ "decorators": [], "loc": { "start": { - "line": 20, + "line": 19, "column": 2 }, "end": { - "line": 20, + "line": 19, "column": 2 } } @@ -239,22 +118,22 @@ ], "loc": { "start": { - "line": 18, - "column": 16 + "line": 17, + "column": 1 }, "end": { - "line": 20, + "line": 19, "column": 2 } } }, "loc": { "start": { - "line": 18, - "column": 8 + "line": 16, + "column": 1 }, "end": { - "line": 20, + "line": 19, "column": 2 } } @@ -284,16 +163,16 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "main", + "name": "_$init$_", "decorators": [], "loc": { "start": { - "line": 23, - "column": 10 + "line": 1, + "column": 1 }, "end": { - "line": 23, - "column": 14 + "line": 1, + "column": 1 } } }, @@ -308,16 +187,16 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "main", + "name": "_$init$_", "decorators": [], "loc": { "start": { - "line": 23, - "column": 10 + "line": 1, + "column": 1 }, "end": { - "line": 23, - "column": 14 + "line": 1, + "column": 1 } } }, @@ -325,19 +204,100 @@ "async": false, "expression": false, "params": [], - "returnType": { - "type": "ETSPrimitiveType", + "body": { + "type": "BlockStatement", + "statements": [], "loc": { "start": { - "line": 23, - "column": 19 + "line": 1, + "column": 1 }, "end": { - "line": 23, - "column": 23 + "line": 1, + "column": 1 } } }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "main", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 10 + }, + "end": { + "line": 21, + "column": 14 + } + } + }, + "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": 21, + "column": 10 + }, + "end": { + "line": 21, + "column": 14 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], "body": { "type": "BlockStatement", "statements": [ @@ -348,82 +308,84 @@ "type": "VariableDeclarator", "id": { "type": "Identifier", - "name": "a", + "name": "array", "decorators": [], "loc": { "start": { - "line": 24, + "line": 23, "column": 9 }, "end": { - "line": 24, - "column": 10 + "line": 23, + "column": 14 } } }, "init": { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 24, - "column": 17 - }, - "end": { - "line": 24, - "column": 18 - } - } - }, + "type": "ArrayExpression", + "elements": [ + { + "type": "NumberLiteral", + "value": 1, "loc": { "start": { - "line": 24, - "column": 17 + "line": 23, + "column": 18 }, "end": { - "line": 24, + "line": 23, "column": 19 } } }, - "loc": { - "start": { - "line": 24, - "column": 17 - }, - "end": { - "line": 24, - "column": 19 + { + "type": "NumberLiteral", + "value": 2.3, + "loc": { + "start": { + "line": 23, + "column": 21 + }, + "end": { + "line": 23, + "column": 24 + } + } + }, + { + "type": "StringLiteral", + "value": "string", + "loc": { + "start": { + "line": 23, + "column": 26 + }, + "end": { + "line": 23, + "column": 34 + } } } - }, - "arguments": [], + ], "loc": { "start": { - "line": 24, - "column": 13 + "line": 23, + "column": 17 }, "end": { - "line": 24, - "column": 21 + "line": 23, + "column": 35 } } }, "loc": { "start": { - "line": 24, + "line": 23, "column": 9 }, "end": { - "line": 24, - "column": 21 + "line": 23, + "column": 35 } } } @@ -431,104 +393,142 @@ "kind": "let", "loc": { "start": { - "line": 24, + "line": 23, "column": 5 }, "end": { - "line": 24, - "column": 21 + "line": 23, + "column": 36 } } }, { "type": "ExpressionStatement", "expression": { - "type": "CallExpression", - "callee": { + "type": "AssignmentExpression", + "operator": "=", + "left": { "type": "Identifier", - "name": "foo", + "name": "array", "decorators": [], "loc": { "start": { - "line": 25, + "line": 24, "column": 5 }, "end": { - "line": 25, - "column": 8 + "line": 24, + "column": 10 } } }, - "arguments": [ - { - "type": "Identifier", - "name": "a", - "decorators": [], + "right": { + "type": "ETSNewClassInstanceExpression", + "typeReference": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Bad", + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 17 + }, + "end": { + "line": 24, + "column": 20 + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 17 + }, + "end": { + "line": 24, + "column": 21 + } + } + }, "loc": { "start": { - "line": 25, - "column": 9 + "line": 24, + "column": 17 }, "end": { - "line": 25, - "column": 10 + "line": 24, + "column": 21 } } + }, + "arguments": [], + "loc": { + "start": { + "line": 24, + "column": 13 + }, + "end": { + "line": 24, + "column": 23 + } } - ], - "optional": false, + }, "loc": { "start": { - "line": 25, + "line": 24, "column": 5 }, "end": { - "line": 25, - "column": 11 + "line": 24, + "column": 23 } } }, "loc": { "start": { - "line": 25, + "line": 24, "column": 5 }, "end": { - "line": 25, - "column": 12 + "line": 24, + "column": 23 } } } ], "loc": { "start": { - "line": 23, - "column": 24 + "line": 22, + "column": 1 }, "end": { - "line": 26, + "line": 25, "column": 2 } } }, "loc": { "start": { - "line": 23, + "line": 21, "column": 14 }, "end": { - "line": 26, + "line": 25, "column": 2 } } }, "loc": { "start": { - "line": 23, + "line": 21, "column": 14 }, "end": { - "line": 26, + "line": 25, "column": 2 } } @@ -537,11 +537,11 @@ "decorators": [], "loc": { "start": { - "line": 23, + "line": 21, "column": 1 }, "end": { - "line": 26, + "line": 25, "column": 2 } } @@ -576,8 +576,9 @@ "column": 1 }, "end": { - "line": 27, + "line": 26, "column": 1 } } } +TypeError: Type 'Bad' cannot be assigned to type '(Int|Double|String)[]' [wrong-union-array-assignment.sts:24:13] diff --git a/ets2panda/test/parser/ets/wrong-union-array-assignment.sts b/ets2panda/test/parser/ets/wrong-union-array-assignment.sts new file mode 100644 index 0000000000000000000000000000000000000000..b1f586f33afd3648e3296221b39b60d867cc05b5 --- /dev/null +++ b/ets2panda/test/parser/ets/wrong-union-array-assignment.sts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +class Bad +{ + +} + +function main() +{ + let array = [1, 2.3, "string"]; + array = new Bad(); +} diff --git a/ets2panda/test/runtime/ets/17926.sts b/ets2panda/test/runtime/ets/17926.sts new file mode 100644 index 0000000000000000000000000000000000000000..4e55c289cbf682153ff1ff2043e237dcc2c0139b --- /dev/null +++ b/ets2panda/test/runtime/ets/17926.sts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function foo(...args: Object[]): void { + let fnc : () => void = args[0] as () => void + fnc() +} + +let global = 0 + +let l1 = () : void => { global += 1 } +foo(l1) +assert(global == 1) +foo(() : void => { global += 2 }) +assert(global == 3) + +function main() { +} diff --git a/ets2panda/test/runtime/ets/CastPrimitive.sts b/ets2panda/test/runtime/ets/CastPrimitive.sts index fd7a6a56313e88952236929fede178de011ea3b4..4a20f359e75e1a4d5fe1f33f2683ea0a296dc3e4 100644 --- a/ets2panda/test/runtime/ets/CastPrimitive.sts +++ b/ets2panda/test/runtime/ets/CastPrimitive.sts @@ -81,5 +81,16 @@ function main(): void { i = false; assert i as boolean == false; + assert 4294967296.0 as byte == -1; + assert 4294967296.0 as char == c'\uFFFF'; + assert 4294967296.0 as short == -1; + assert 4294967296.0 as int == Int.MAX_VALUE; + assert 4294967296.0 as long == 4294967296; + assert -4294967296.0 as byte == 0; + assert -4294967296.0 as char == c'\u0000'; + assert -4294967296.0 as short == 0; + assert -4294967296.0 as int == Int.MIN_VALUE; + assert -4294967296.0 as long == -4294967296; + return; } diff --git a/ets2panda/test/runtime/ets/UnionArray.sts b/ets2panda/test/runtime/ets/UnionArray.sts new file mode 100644 index 0000000000000000000000000000000000000000..66aaa42b54413ff81d327482c2fb850a98e4a184 --- /dev/null +++ b/ets2panda/test/runtime/ets/UnionArray.sts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +class Item { + public value: int; + + constructor(v: int) + { + this.value = v; + } +} + +function main() { + let objectArray = []; + let boolArray = [true, false, true]; + let intArray = [1, 2, 99, 100]; + let doubleArray = [1, -2, 1.2, 9.9]; + let stringArray = ["one", "two", "three"]; + let classArray = [new Item(1), new Item(2), new Item(3)]; + let unionArray = [true, 9.99, new Item(9), "success"]; + + assert(objectArray instanceof Object[]); + assert(boolArray instanceof Boolean[]); + assert(intArray instanceof number[]); + assert(doubleArray instanceof number[]); + assert(stringArray instanceof string[]); + assert(classArray instanceof Item[]); + assert(unionArray instanceof (Boolean|Double|Item|String)[]); +} diff --git a/ets2panda/test/runtime/ets/array-object.sts b/ets2panda/test/runtime/ets/array-object.sts index 916e01520fbd353706b532b1f11124a500540818..c7caaf99e0cc4b613b3268f5704399f05348536f 100644 --- a/ets2panda/test/runtime/ets/array-object.sts +++ b/ets2panda/test/runtime/ets/array-object.sts @@ -37,7 +37,6 @@ function main(): void { assert(arr1 == object_array); assert(arr1 == object); assert(arr1 != arr2); - assert(object.equals(arr1 as Object) == true); // Cannot cast type 'int[]' to 'Object[]' // let object_array2: Object[] = arr2 as Object[]; diff --git a/ets2panda/test/parser/ets/import_tests/import_class_members_3.sts b/ets2panda/test/runtime/ets/default_generic_function_1.sts similarity index 84% rename from ets2panda/test/parser/ets/import_tests/import_class_members_3.sts rename to ets2panda/test/runtime/ets/default_generic_function_1.sts index 67e20ba3efcfc1f46df26786e406928d98b5bd0c..d508bdf1978cb0e84f860fc565a6592cc28e2f60 100644 --- a/ets2panda/test/parser/ets/import_tests/import_class_members_3.sts +++ b/ets2panda/test/runtime/ets/default_generic_function_1.sts @@ -13,7 +13,10 @@ * limitations under the License. */ -import Enclosing.* from "import_tests/modules/module"; +class SomeType {} +function foo(): void {} -let x = fieldA; -let y = new Nested(); +function main(): void { + foo() + foo() +} \ No newline at end of file diff --git a/ets2panda/test/runtime/ets/default_generic_method_1.sts b/ets2panda/test/runtime/ets/default_generic_method_1.sts new file mode 100644 index 0000000000000000000000000000000000000000..4d8a4c7f6ae0255a7bab2f68e64a627b03a4fb29 --- /dev/null +++ b/ets2panda/test/runtime/ets/default_generic_method_1.sts @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +class BiConsumer { + accept(t: T, u: U) { + t; + u; + } +} + +class SomeObject {} +class SomeType {} +class OtherType {} + +class Base { + foo_default(): BiConsumer { + return new BiConsumer() + } + foo_array(): BiConsumer { + return new BiConsumer() + } + foo_array_implicit(): BiConsumer { + return new BiConsumer() + } + foo_union(): BiConsumer { + return new BiConsumer() + } + foo_object>(): BiConsumer { + return new BiConsumer() + } +} + +function main(): int { + new Base().foo_default().accept(new SomeType(), new SomeType()) + new Base().foo_array().accept(new SomeType(), [new SomeType()]) + new Base().foo_array_implicit().accept(new SomeType(), [new SomeType()]) + new Base().foo_union().accept(new SomeType(), new SomeType()) + new Base().foo_union().accept(new SomeType(), new OtherType()) + new Base().foo_object().accept(new SomeType(), new SomeObject) + return 0 +} diff --git a/ets2panda/test/runtime/ets/default_generic_method_2.sts b/ets2panda/test/runtime/ets/default_generic_method_2.sts new file mode 100644 index 0000000000000000000000000000000000000000..13d3a8899ebaa3eeb59ef1c379183bf8b2b83ba7 --- /dev/null +++ b/ets2panda/test/runtime/ets/default_generic_method_2.sts @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +class BiConsumer { + accept(t: T, u: U) { + t; + u; + } +} + +class SomeObject {} +class SomeType {} +class OtherType {} + +class Base { + foo_default(): BiConsumer { + return new BiConsumer() + } + foo_implicit(x: F): BiConsumer { + return new BiConsumer() + } + foo_array(): BiConsumer { + return new BiConsumer() + } + foo_array_implicit(x : X): BiConsumer { + return new BiConsumer() + } + foo_union(): BiConsumer { + return new BiConsumer() + } + foo_object>(): BiConsumer { + return new BiConsumer() + } +} + +function main(): int { + new Base().foo_default().accept(new SomeType(), new SomeType()) + new Base().foo_implicit(new OtherType()).accept(new SomeType(), new OtherType()) + new Base().foo_array().accept(new SomeType(), [new SomeType()]) + new Base().foo_array_implicit(new OtherType()).accept(new SomeType(), [new OtherType()]) + new Base().foo_union().accept(new SomeType(), new SomeType()) + new Base().foo_union().accept(new SomeType(), new OtherType()) + new Base().foo_object().accept(new SomeType(), new SomeObject) + return 0 +} diff --git a/ets2panda/test/runtime/ets/enum-relational-operator.sts b/ets2panda/test/runtime/ets/enum-relational-operator.sts new file mode 100644 index 0000000000000000000000000000000000000000..9ec99e03c38e19ddb2a627faf7d90f3302ef6230 --- /dev/null +++ b/ets2panda/test/runtime/ets/enum-relational-operator.sts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +enum Color {Red = 0, Green = 1, Blue = 0} +enum Color2 {First = "red", Second = "green", Third = "red"} + +if (Color.Red < Color.Blue) + assert(false) +if (Color.Red > Color.Blue) + assert(false) +if (Color.Red == Color.Blue) + assert(true) + +if (Color2.First < Color2.Third) + assert(false) +if (Color2.First > Color2.Third) + assert(false) +if (Color2.First == Color2.Third) + assert(true) + diff --git a/ets2panda/test/compiler/ets/inferTypeOfArrayNegative1.sts b/ets2panda/test/runtime/ets/enum-supertype.sts similarity index 56% rename from ets2panda/test/compiler/ets/inferTypeOfArrayNegative1.sts rename to ets2panda/test/runtime/ets/enum-supertype.sts index 09fd4707baaff9a4fce7544c8a21f9e09f1f7f79..d595d84f13d1766d912b7fbe549b0dbbf876ea95 100644 --- a/ets2panda/test/compiler/ets/inferTypeOfArrayNegative1.sts +++ b/ets2panda/test/runtime/ets/enum-supertype.sts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -13,4 +13,11 @@ * limitations under the License. */ -let a = ["a", 1, 3.14] +enum Commands { Open = "fopen", Close = "fclose" } +let c: Commands = Commands.Close +let o: Object = c // Autoboxing of enum type to its reference version +// Such reference version type has no name, but can be detected by instanceof +if (o instanceof Commands) { + let d = o as Commands // And explicitly converted back by 'as' conversion + assert(d == Commands.Close) +} \ No newline at end of file diff --git a/ets2panda/test/parser/ets/import_tests/import_invalid_package.sts b/ets2panda/test/runtime/ets/enum-typeof.sts similarity index 69% rename from ets2panda/test/parser/ets/import_tests/import_invalid_package.sts rename to ets2panda/test/runtime/ets/enum-typeof.sts index f7ffed595e053b64c937c91fd548725288d2b7aa..332dff0ff20aa33b4507c728d2ad5d0349b96427 100644 --- a/ets2panda/test/parser/ets/import_tests/import_invalid_package.sts +++ b/ets2panda/test/runtime/ets/enum-typeof.sts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -13,6 +13,10 @@ * limitations under the License. */ -import * as all from "import_tests/packages/different-header"; +enum Color {Red, Green, Blue} +enum Fruit {Apple="Apple", Pearl="Pearl", Peach="Peach"} -// Throw error because package modules have different package header. +let c: Color = Color.Green +assert (typeof c == "number") +let f: Fruit = Fruit.Pearl +assert(typeof f == "string") diff --git a/ets2panda/test/parser/ets/recursive_import/case_5_main-is-not-part-of-circle/main__foo1.sts b/ets2panda/test/runtime/ets/generic_constraint_implicit.sts similarity index 89% rename from ets2panda/test/parser/ets/recursive_import/case_5_main-is-not-part-of-circle/main__foo1.sts rename to ets2panda/test/runtime/ets/generic_constraint_implicit.sts index 9fef5aeb84ec75c3338e8e629cff26fa30f24675..9ff72fc678894371640d81b5bb8d24bb4aef9eb5 100644 --- a/ets2panda/test/parser/ets/recursive_import/case_5_main-is-not-part-of-circle/main__foo1.sts +++ b/ets2panda/test/runtime/ets/generic_constraint_implicit.sts @@ -13,8 +13,10 @@ * limitations under the License. */ -import {foo_in_2} from "./foo2__module" +function bar>(x:T) :T{ + return x; +} function main() : void { - foo_in_2(); -} + bar("456") +} \ No newline at end of file diff --git a/ets2panda/test/parser/ets/recursive_import/case_2_3-sources-in-circle/main__foo1_as__module.sts b/ets2panda/test/runtime/ets/inherited_getter_setter_implementation_1.sts similarity index 79% rename from ets2panda/test/parser/ets/recursive_import/case_2_3-sources-in-circle/main__foo1_as__module.sts rename to ets2panda/test/runtime/ets/inherited_getter_setter_implementation_1.sts index 45f20acd8f12d6cb77a2d6b94e3a9adc37a5cc6c..28636bc4dbdfc1701231d01435e72f3b1d865cce 100644 --- a/ets2panda/test/parser/ets/recursive_import/case_2_3-sources-in-circle/main__foo1_as__module.sts +++ b/ets2panda/test/runtime/ets/inherited_getter_setter_implementation_1.sts @@ -13,14 +13,19 @@ * limitations under the License. */ -import {foo_in_3} from "./foo3__module" +interface I { + a: int +} -export class A { +class A implements I { a: int; } +class B extends A {} -function main() : void { - let a = new A(); - foo_in_3(); -} +function main() { + let b = new B(); + b.a = 1; + let c: int = b.a; + assert c == 1; +} \ No newline at end of file diff --git a/ets2panda/test/runtime/ets/inherited_getter_setter_implementation_2.sts b/ets2panda/test/runtime/ets/inherited_getter_setter_implementation_2.sts new file mode 100644 index 0000000000000000000000000000000000000000..8102ad95a3b2d3d23de9878345e8cb0439eb2976 --- /dev/null +++ b/ets2panda/test/runtime/ets/inherited_getter_setter_implementation_2.sts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +interface I { + readonly a: boolean +} + +class A implements I { + a: boolean + b : boolean + constructor() { + this.a = false + this.b = false + } + + foo() { + this.b = true + } +} + +class B extends A { + constructor() { + super() + this.a = true + } +} + +function main() { + let b = new B() + assert(b.a) +} \ No newline at end of file diff --git a/ets2panda/test/runtime/ets/nullishTypeCodesamples.sts b/ets2panda/test/runtime/ets/nullishTypeCodesamples.sts index 4d78ff9fdb4034d08743ff5bf60a2e3173f1744a..2b42d7b9add3f47d98759cfe1cf512ee154967f4 100644 --- a/ets2panda/test/runtime/ets/nullishTypeCodesamples.sts +++ b/ets2panda/test/runtime/ets/nullishTypeCodesamples.sts @@ -19,7 +19,7 @@ class A { this.indices = new number[2][2]; } - public override equals(other: Object | null | undefined): boolean { + public equals(other: Object | null | undefined): boolean { for (let i = 0; i < this.indices!.length; ++i) { let num: number[] = this.indices![i]; num[0]; diff --git a/ets2panda/test/runtime/ets/objectLiteralInterfaceType.sts b/ets2panda/test/runtime/ets/objectLiteralInterfaceType.sts new file mode 100644 index 0000000000000000000000000000000000000000..4ed8f361003b32931599e5ff36ad5b8e589a4003 --- /dev/null +++ b/ets2panda/test/runtime/ets/objectLiteralInterfaceType.sts @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +interface Base { + f: int +} + +interface InnerValue { + v: int +} + +interface I extends Base { + x: Int + s: String + iv: InnerValue +} + +function returnI(): I { + return {x: 99, f: 44, s: "sR", iv: {v: 77}} // return statement +} + +function test(i: int, f: int, x: int, s: String, ivv: int) {} // should not prevent calling the next func + +function test(i: I = {f: -1, x: -2, s: "default", iv: {v: -3}}, + f: int = -1, + x: int = -2, + s: String = "default", + ivv: int = -3) { + assert i.f == f : "\"f\" is not equal \"" + i.f + "\" != \"" + f + "\"" + assert i.x == x : "\"x\" is not equal \"" + i.x + "\" != \"" + x + "\"" + assert i.s == s : "\"s\" is not equal \"" + i.s + "\" != \"" + s + "\"" + assert i.iv.v == ivv : "\"innervalue.v\" is not equal \"" + i.iv.v + "\" != \"" + ivv + "\"" +} + +function main(): int { + let i: I = { // variable definition + f : 1, + "x": 2, + s: "s1", + iv: { v: 3} + }; + test(i, 1, 2, "s1", 3) + + let i2 = { // as construction + f: 4, + x: 5, + s: "s2", + iv: { v: 6} + } as I; + test(i2, 4, 5, "s2", 6) + + i = {f: 7, x: 8, s: "s3", iv : { v: 9}} // assignment + test(i, 7, 8, "s3", 9) + + test({ // function argument + f: 10, + x: 11, + s: "s3", + iv: { + v: 12 + }}, 10, 11, "s3", 12) + + test(returnI(), 44, 99, "sR", 77) + + let ia: I[] = [{f: 20, x: 21, s: "first", iv: {v: 22}}, {f: 30, x: 31, s: "second", iv: {v: 32}}] // array elements + test(ia[1], 30, 31, "second", 32) + + test() // optional parameter + + return 0 +} diff --git a/ets2panda/test/parser/ets/recursive_import/case_1_fail_not_called_w_module/main__foo1.sts b/ets2panda/test/runtime/ets/union_type_and_trailing_lambda.sts similarity index 73% rename from ets2panda/test/parser/ets/recursive_import/case_1_fail_not_called_w_module/main__foo1.sts rename to ets2panda/test/runtime/ets/union_type_and_trailing_lambda.sts index 0ac6ceee06d0719b2e01dae6dc288eebb8bd6e22..2519ec0c2ad3643a9ee1b5241d3a84f0dc8008d1 100644 --- a/ets2panda/test/parser/ets/recursive_import/case_1_fail_not_called_w_module/main__foo1.sts +++ b/ets2panda/test/runtime/ets/union_type_and_trailing_lambda.sts @@ -13,14 +13,20 @@ * limitations under the License. */ -import {foo} from "./foo2__module" +class A{} -export class A { - a: int; +function no_param(fn: A | () => void) { + if (fn instanceof A){ + assert false:"false" + } else { + fn() + } } +let a: int = 5 -function main() : void { - let a = new A(); - foo(a); -} +function main(): void{ + no_param() { + assert a==5 + } +} \ No newline at end of file diff --git a/ets2panda/test/test-lists/parser/parser-ets-ignored.txt b/ets2panda/test/test-lists/parser/parser-ets-ignored.txt index 9bcf64b0b106e6aae159585b10d2df7db7df1318..650474bb0ac04f19187b623860e4573ac6819661 100644 --- a/ets2panda/test/test-lists/parser/parser-ets-ignored.txt +++ b/ets2panda/test/test-lists/parser/parser-ets-ignored.txt @@ -1,6 +1,3 @@ -parser/ets/test-type-alias-call7.sts -parser/ets/test-type-alias-call8.sts - # Disabled temporarily #I8EM2T implementation struct directly expanded to class parser/ets/struct_init.sts parser/ets/struct_static_initializer.sts @@ -32,24 +29,11 @@ compiler/ets/lambdaWithLocalClassAccess.sts # Skipped until #16329 is done. It is not properly checked and does not cause a CTE when using namespace import with alias. parser/ets/re_export/import_5.sts -# Some tests within recursive import folder should run with `--ets-module` flag. These files has "__module" in their -# name. Tests below are ignored because they should result in the ats provided in their -expected.txt. Currently they -# result in an error message due to not compiling with `--ets-module` flag. -parser/ets/recursive_import/case_0/foo2__module.sts -parser/ets/recursive_import/case_0/main__foo1_as__module.sts -parser/ets/recursive_import/case_1_fail_not_called_w_module/foo2__module.sts -parser/ets/recursive_import/case_2_3-sources-in-circle/foo2__module.sts -parser/ets/recursive_import/case_2_3-sources-in-circle/foo3__module.sts -parser/ets/recursive_import/case_2_3-sources-in-circle/main__foo1_as__module.sts -parser/ets/recursive_import/case_3_3-sources-in-circle-fail-no-ets-module-compile/foo2__module.sts -parser/ets/recursive_import/case_3_3-sources-in-circle-fail-no-ets-module-compile/foo3__module.sts -parser/ets/recursive_import/case_4_3-sources-in-circle_no-ets-module-compile_2/foo3__module.sts -parser/ets/recursive_import/case_4_3-sources-in-circle_no-ets-module-compile_2/main__foo1_as__module.sts -parser/ets/recursive_import/case_5_main-is-not-part-of-circle/foo2__module.sts -parser/ets/recursive_import/case_5_main-is-not-part-of-circle/foo3__module.sts - # No conversion from enum to Object compiler/ets/lambda_infer_type/lambda_infer_type_retrun_enum.sts # Issue: #17983 parser/ets/TypeInferFunc.sts + +# Duplicated check for global initializers +compiler/ets/inferTypeOfArrayNegative2.sts diff --git a/ets2panda/test/test-lists/parser/parser-js-ignored.txt b/ets2panda/test/test-lists/parser/parser-js-ignored.txt index c86f617be2c902e0e090108ddcc82744202df45b..747a9125d9f1b001cf56573baba954caf20492dd 100644 --- a/ets2panda/test/test-lists/parser/parser-js-ignored.txt +++ b/ets2panda/test/test-lists/parser/parser-js-ignored.txt @@ -4,28 +4,11 @@ parser/ets/interfaces.sts parser/ets/test_interface.sts # End of panda#15005 -parser/ets/import_tests/modules/module.sts -parser/ets/import_tests/import_class_members_1.sts -parser/ets/import_tests/import_class_members_2.sts -parser/ets/import_tests/import_class_members_3.sts -parser/ets/import_tests/import_invalid_package.sts -parser/ets/import_tests/import_name_conflict_1.sts -parser/ets/import_tests/import_name_conflict_3.sts -parser/ets/import_tests/import_nested_class_1.sts -parser/ets/import_tests/import_nested_class_2.sts -parser/ets/import_tests/import_nested_class_3.sts -parser/ets/import_tests/import_separate_module.sts -parser/ets/import_tests/import_several_8.sts # panda#17052 parser/ets/import_tests/import_recursive.sts parser/ets/import_tests/packages/recursive/subpackage/subpackage_module_1.sts parser/ets/import_tests/packages/recursive/subpackage_module_1.sts -# panda#11580 ([ETS front-end] Overriding issues) -compiler/ets/override3.sts -compiler/ets/override4.sts -compiler/ets/override5.sts - # Requires smart casts parser/ets/null-coalesc-negative.sts @@ -35,9 +18,6 @@ parser/ets/trailing_lambda_tests/trailing_lambda_define_lambda_in_body_capture_v # Bad test shadows Object with type parameter name #14913 compiler/ets/override13.sts -# 15095 -compiler/ets/override17.sts - # Throwing function types compiler/ets/throwingFunctionType2.sts compiler/ets/throwingFunctionAsParameter2.sts @@ -46,22 +26,9 @@ compiler/ets/throwingFunctionAsParameter2.sts parser/ets/n_overrideWithNullable.sts parser/ets/nullableType.sts -# 15577 inference for union-typed targets -compiler/ets/optionalLambdaParameter.sts -compiler/ets/tuple_types_9_neg.sts - -# 15771 broken ast varbinder scopes in etsglobal -parser/ets/optional-chaining-array.sts -parser/ets/optional_chaining_invalid_property.sts -parser/ets/optional_chaining_nested_property.sts -parser/ets/optional_chaining_object_property.sts - # 15642 compiler/ets/etsObjectToString4.sts compiler/ets/generic_variance_1.sts -# Related to void revert -compiler/ets/lambda_infer_type/lambda_cast_infer_type_void.sts - -# panda#15575 -compiler/ets/promiseVoid.sts +# Duplicated import name +parser/ets/import_tests/import_name_conflict_1.sts diff --git a/ets2panda/test/tsconfig/test.sh b/ets2panda/test/tsconfig/test.sh index 053ef29a3d89e87a575d945750165f0d61b0f886..1d093896c478bc0ed09eb28b458a2e1a0704d634 100755 --- a/ets2panda/test/tsconfig/test.sh +++ b/ets2panda/test/tsconfig/test.sh @@ -51,7 +51,7 @@ find . -type f -name '*abc' | sort --version-sort > "$ACTUAL" popd &> /dev/null set +e -/usr/bin/diff "$EXPECTED" "$ACTUAL" +diff "$EXPECTED" "$ACTUAL" RES=$? set -e if [ "$RES" -ne 0 ]; then @@ -62,7 +62,7 @@ if [ "$RES" -ne 0 ]; then echo "How to reproduce:" echo "(cd $(pwd) && $CMD)" echo "(cd $(realpath $TSCONFIG_DIR) && find . -type f -name '*abc' | sort > $(pwd)/actual.txt)" - echo "/usr/bin/diff $(realpath $EXPECTED) $(pwd)/actual.txt" + echo "diff $(realpath $EXPECTED) $(pwd)/actual.txt" fi rm "$ACTUAL" rm -r "$BUILD" diff --git a/ets2panda/test/unit/public/CMakeLists.txt b/ets2panda/test/unit/public/CMakeLists.txt index ca44d308379fe585deb69d5d8b0ee29fbb262780..1e71e0d7c6ef7142a43827fad85f393569ce1f83 100644 --- a/ets2panda/test/unit/public/CMakeLists.txt +++ b/ets2panda/test/unit/public/CMakeLists.txt @@ -59,6 +59,10 @@ ets2panda_add_gtest(ast_verifier_variable_has_scope_test CPP_SOURCES ast_verifier_variable_has_scope_test.cpp ) +ets2panda_add_gtest(ast_verifier_every_child_has_valid_parent_test + CPP_SOURCES ast_verifier_every_child_has_valid_parent_test.cpp +) + panda_add_library(e2p_test_plugin SHARED e2p_test_plugin.c) panda_target_include_directories(e2p_test_plugin PRIVATE "${ES2PANDA_PATH}") panda_target_link_libraries(e2p_test_plugin es2panda-public) diff --git a/ets2panda/test/unit/public/ast_verifier_every_child_has_valid_parent_test.cpp b/ets2panda/test/unit/public/ast_verifier_every_child_has_valid_parent_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..32ab7152902839253666fd3ab14a8c41ccab3bcf --- /dev/null +++ b/ets2panda/test/unit/public/ast_verifier_every_child_has_valid_parent_test.cpp @@ -0,0 +1,74 @@ +/** + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ast_verifier_test.h" +#include "checker/ETSchecker.h" +#include "ir/expressions/identifier.h" +#include "ir/astNode.h" +#include "parser/ETSparser.h" + +#include + +using ark::es2panda::compiler::ast_verifier::ASTVerifier; +using ark::es2panda::compiler::ast_verifier::InvariantNameSet; +using ark::es2panda::ir::AstNode; + +TEST_F(ASTVerifierTest, ReturnTypeInLambda) +{ + ASTVerifier verifier {Allocator()}; + char const *text = R"( + function main(): void { + let x: () => void = ()=> {} + } + )"; + + es2panda_Context *ctx = impl_->CreateContextFromString(cfg_, text, "dummy.sts"); + impl_->ProceedToState(ctx, ES2PANDA_STATE_CHECKED); + ASSERT_EQ(impl_->ContextState(ctx), ES2PANDA_STATE_CHECKED); + + auto *ast = reinterpret_cast(impl_->ProgramAst(impl_->ContextProgram(ctx))); + + InvariantNameSet checks; + checks.insert("EveryChildHasValidParentForAll"); + const auto &messages = verifier.Verify(ast, checks); + ASSERT_EQ(messages.size(), 0); + + impl_->DestroyContext(ctx); +} + +TEST_F(ASTVerifierTest, TSThisType) +{ + ASTVerifier verifier {Allocator()}; + char const *text = R"( + class A { + foo(a?: Number): this { return this; } + } + + function main () {} + )"; + + es2panda_Context *ctx = impl_->CreateContextFromString(cfg_, text, "dummy.sts"); + impl_->ProceedToState(ctx, ES2PANDA_STATE_CHECKED); + ASSERT_EQ(impl_->ContextState(ctx), ES2PANDA_STATE_CHECKED); + + auto *ast = reinterpret_cast(impl_->ProgramAst(impl_->ContextProgram(ctx))); + + InvariantNameSet checks; + checks.insert("EveryChildHasValidParentForAll"); + const auto &messages = verifier.Verify(ast, checks); + ASSERT_EQ(messages.size(), 0); + + impl_->DestroyContext(ctx); +} diff --git a/ets2panda/test/unit/public/ast_verifier_identifier_has_variable_test.cpp b/ets2panda/test/unit/public/ast_verifier_identifier_has_variable_test.cpp index 90b23a72c985f646684c63b34686017d3d4b1b63..7426355b3e4cbf6b7713bca246eeb7a6e0973863 100644 --- a/ets2panda/test/unit/public/ast_verifier_identifier_has_variable_test.cpp +++ b/ets2panda/test/unit/public/ast_verifier_identifier_has_variable_test.cpp @@ -134,3 +134,85 @@ TEST_F(ASTVerifierTest, TSQualifiedName) impl_->DestroyContext(ctx); } + +TEST_F(ASTVerifierTest, ParametersInArrowFunctionExpression) +{ + ASTVerifier verifier {Allocator()}; + + char const *text = R"( + let b = 1; + let f = (p: double) => b + p; + function main () { + assert f(42) == 43 + } + )"; + + es2panda_Context *ctx = impl_->CreateContextFromString(cfg_, text, "dummy.sts"); + impl_->ProceedToState(ctx, ES2PANDA_STATE_CHECKED); + ASSERT_EQ(impl_->ContextState(ctx), ES2PANDA_STATE_CHECKED); + + auto *ast = reinterpret_cast(impl_->ProgramAst(impl_->ContextProgram(ctx))); + + InvariantNameSet checks; + checks.insert("IdentifierHasVariableForAll"); + const auto &messages = verifier.Verify(ast, checks); + ASSERT_EQ(messages.size(), 0); + + impl_->DestroyContext(ctx); +} + +TEST_F(ASTVerifierTest, Lambdas) +{ + ASTVerifier verifier {Allocator()}; + + char const *text = R"( + type asyncLambda = () => Promise; + + async function asyncFunc(): Promise { + return true; + } + + function callAsyncLambda(): void { + let is_call_async_lambda: boolean = false; + + let async_lambda: asyncLambda = async (): Promise => { + await asyncFunc(); + is_call_async_lambda = true; + }; + } + + type I2v = (i: int) => void; + type T1 = (lambda: (arg: int) => int, arg: int) => int; + type T2 = (c: int) => int; + + const F1: I2v = (counter: int) => { + let funcWithLambda: T1 = (lambda: (arg: int) => int, arg: int) => { + return lambda(arg); + }; + + let it: T2 = (c: int): int => { + return c; + }; + + while (counter > 0) counter = funcWithLambda(it, counter); + }; + + function main() { + F1(44); + return 0; + } + )"; + + es2panda_Context *ctx = impl_->CreateContextFromString(cfg_, text, "dummy.sts"); + impl_->ProceedToState(ctx, ES2PANDA_STATE_CHECKED); + ASSERT_EQ(impl_->ContextState(ctx), ES2PANDA_STATE_CHECKED); + + auto *ast = reinterpret_cast(impl_->ProgramAst(impl_->ContextProgram(ctx))); + + InvariantNameSet checks; + checks.insert("IdentifierHasVariableForAll"); + const auto &messages = verifier.Verify(ast, checks); + ASSERT_EQ(messages.size(), 0); + + impl_->DestroyContext(ctx); +} \ No newline at end of file diff --git a/ets2panda/test/unit/public/ast_verifier_test.h b/ets2panda/test/unit/public/ast_verifier_test.h index 8fe3fb3e63f792e377122806f50da2130381ca8f..c7e08c897a699874b53baf815c8d952a79cf93c2 100644 --- a/ets2panda/test/unit/public/ast_verifier_test.h +++ b/ets2panda/test/unit/public/ast_verifier_test.h @@ -16,7 +16,7 @@ #ifndef TEST_UNIT_PUBLIC_AST_VERIFIER_TEST_H #define TEST_UNIT_PUBLIC_AST_VERIFIER_TEST_H -#include "compiler/core/ASTVerifier.h" +#include "ast_verifier/ASTVerifier.h" #include "test/utils/panda_executable_path_getter.h" #include diff --git a/ets2panda/test/unit/public/ast_verifier_variable_has_enclosing_scope_test.cpp b/ets2panda/test/unit/public/ast_verifier_variable_has_enclosing_scope_test.cpp index 057bf81dcaa06a7e71201f6e2419363d621960a0..a2d14463937cff9aac3bd7de5d7e6abe4701cbd0 100644 --- a/ets2panda/test/unit/public/ast_verifier_variable_has_enclosing_scope_test.cpp +++ b/ets2panda/test/unit/public/ast_verifier_variable_has_enclosing_scope_test.cpp @@ -52,3 +52,58 @@ TEST_F(ASTVerifierTest, CatchClause) impl_->DestroyContext(ctx); } + +TEST_F(ASTVerifierTest, LambdasHaveCorrectScope) +{ + ASTVerifier verifier {Allocator()}; + + char const *text = R"( + type BenchmarkFunc = () => void; + + function main() { + const arr: number[] = [1, 2, 3, 4]; + const ITERATE_FUNC: BenchmarkFunc = () => { + const length = arr.length; + }; + } + )"; + + es2panda_Context *ctx = impl_->CreateContextFromString(cfg_, text, "dummy.sts"); + impl_->ProceedToState(ctx, ES2PANDA_STATE_CHECKED); + ASSERT_EQ(impl_->ContextState(ctx), ES2PANDA_STATE_CHECKED); + + auto *ast = reinterpret_cast(impl_->ProgramAst(impl_->ContextProgram(ctx))); + + InvariantNameSet checks; + checks.insert("VariableHasEnclosingScopeForAll"); + const auto &messages = verifier.Verify(ast, checks); + ASSERT_EQ(messages.size(), 0); + + impl_->DestroyContext(ctx); +} + +TEST_F(ASTVerifierTest, ParametersInArrowFunctionExpression) +{ + ASTVerifier verifier {Allocator()}; + + char const *text = R"( + let b = 1; + let f = (p: double) => b + p; + function main () { + assert f(42) == 43 + } + )"; + + es2panda_Context *ctx = impl_->CreateContextFromString(cfg_, text, "dummy.sts"); + impl_->ProceedToState(ctx, ES2PANDA_STATE_CHECKED); + ASSERT_EQ(impl_->ContextState(ctx), ES2PANDA_STATE_CHECKED); + + auto *ast = reinterpret_cast(impl_->ProgramAst(impl_->ContextProgram(ctx))); + + InvariantNameSet checks; + checks.insert("VariableHasEnclosingScopeForAll"); + const auto &messages = verifier.Verify(ast, checks); + ASSERT_EQ(messages.size(), 0); + + impl_->DestroyContext(ctx); +} diff --git a/ets2panda/test/unit/public/ast_verifier_variable_has_scope_test.cpp b/ets2panda/test/unit/public/ast_verifier_variable_has_scope_test.cpp index 50ef463f3068d41d419ae88f8e53163d3ce4e555..c709db958d045c7cc7b3b8ea7dedb31af1ce4485 100644 --- a/ets2panda/test/unit/public/ast_verifier_variable_has_scope_test.cpp +++ b/ets2panda/test/unit/public/ast_verifier_variable_has_scope_test.cpp @@ -91,3 +91,32 @@ TEST_F(ASTVerifierTest, TestUnions) impl_->DestroyContext(ctx); } + +TEST_F(ASTVerifierTest, LambdasHaveCorrectScope) +{ + ASTVerifier verifier {Allocator()}; + + char const *text = R"( + type BenchmarkFunc = () => void; + + function main() { + const arr: number[] = [1, 2, 3, 4]; + const ITERATE_FUNC: BenchmarkFunc = () => { + const length = arr.length; + }; + } + )"; + + es2panda_Context *ctx = impl_->CreateContextFromString(cfg_, text, "dummy.sts"); + impl_->ProceedToState(ctx, ES2PANDA_STATE_CHECKED); + ASSERT_EQ(impl_->ContextState(ctx), ES2PANDA_STATE_CHECKED); + + auto *ast = reinterpret_cast(impl_->ProgramAst(impl_->ContextProgram(ctx))); + + InvariantNameSet checks; + checks.insert("VariableHasScopeForAll"); + const auto &messages = verifier.Verify(ast, checks); + ASSERT_EQ(messages.size(), 0); + + impl_->DestroyContext(ctx); +} diff --git a/ets2panda/util/errorLogger.cpp b/ets2panda/util/errorLogger.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4ca6bf289d3af6880a20b184a86eb4e4a8a0ac43 --- /dev/null +++ b/ets2panda/util/errorLogger.cpp @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "errorLogger.h" +#include "util/options.h" + +namespace ark::es2panda::util { + +void ErrorLogger::WriteLog(Error &&error) +{ + if (ostream_ != nullptr) { + *ostream_ << error.TypeString() << ": " << error.Message() << " [" << util::BaseName(error.File()) << ":" + << error.Line() << ":" << error.Col() << "]" << std::endl; + } + log_.push_back(std::move(error)); +} + +} // namespace ark::es2panda::util diff --git a/ets2panda/util/errorLogger.h b/ets2panda/util/errorLogger.h new file mode 100644 index 0000000000000000000000000000000000000000..6c6b28ca9e625bcf43d02c0c461f3ef465597e06 --- /dev/null +++ b/ets2panda/util/errorLogger.h @@ -0,0 +1,51 @@ +/** + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ES2PANDA_UTIL_ERROR_LOGGER_H +#define ES2PANDA_UTIL_ERROR_LOGGER_H + +#include "es2panda.h" + +namespace ark::es2panda::util { + +class ErrorLogger { +public: + explicit ErrorLogger() : ostream_(&std::cout) {} + + std::vector const &Log() const + { + return log_; + } + + bool IsAnyError() + { + return !log_.empty(); + } + + void WriteLog(Error &&error); + + void SetOstream(std::ostream *ostream) + { + ostream_ = ostream; + } + +private: + std::vector log_; + std::ostream *ostream_; +}; + +} // namespace ark::es2panda::util + +#endif diff --git a/ets2panda/varbinder/ETSBinder.cpp b/ets2panda/varbinder/ETSBinder.cpp index 3bd34ff6088a79686462be90e26e4f138f667b9f..432d64460a1fd075fd82b65e6517690132e66c96 100644 --- a/ets2panda/varbinder/ETSBinder.cpp +++ b/ets2panda/varbinder/ETSBinder.cpp @@ -55,6 +55,7 @@ #include "ir/module/importDeclaration.h" #include "ir/module/importSpecifier.h" #include "ir/expressions/literals/stringLiteral.h" +#include "mem/arena_allocator.h" #include "util/helpers.h" #include "util/ustring.h" #include "checker/types/type.h" @@ -458,21 +459,24 @@ static const util::StringView &GetPackageName(varbinder::Variable *var) return scope->Node()->AsETSScript()->Program()->ModuleName(); } -void AddOverloadFlag(bool isStdLib, varbinder::Variable *var, varbinder::Variable *variable) +void AddOverloadFlag(ArenaAllocator *allocator, bool isStdLib, varbinder::Variable *importedVar, + varbinder::Variable *variable) { auto *const currentNode = variable->Declaration()->Node()->AsMethodDefinition(); - auto *const method = var->Declaration()->Node()->AsMethodDefinition(); + auto *const method = importedVar->Declaration()->Node()->AsMethodDefinition(); // Necessary because stdlib and escompat handled as same package, it can be removed after fixing package handling - if (isStdLib && (GetPackageName(var) != GetPackageName(variable))) { + if (isStdLib && (GetPackageName(importedVar) != GetPackageName(variable))) { return; } if (!method->Overloads().empty() && !method->HasOverload(currentNode)) { method->AddOverload(currentNode); - currentNode->Function()->Id()->SetVariable(var); + currentNode->Function()->Id()->SetVariable(importedVar); currentNode->Function()->AddFlag(ir::ScriptFunctionFlags::OVERLOAD); currentNode->Function()->AddFlag(ir::ScriptFunctionFlags::EXTERNAL_OVERLOAD); + util::UString newInternalName(currentNode->Function()->Scope()->Name(), allocator); + currentNode->Function()->Scope()->BindInternalName(newInternalName.View()); return; } @@ -481,6 +485,8 @@ void AddOverloadFlag(bool isStdLib, varbinder::Variable *var, varbinder::Variabl method->Function()->Id()->SetVariable(variable); method->Function()->AddFlag(ir::ScriptFunctionFlags::OVERLOAD); method->Function()->AddFlag(ir::ScriptFunctionFlags::EXTERNAL_OVERLOAD); + util::UString newInternalName(method->Function()->Scope()->Name(), allocator); + method->Function()->Scope()->BindInternalName(newInternalName.View()); } } @@ -504,7 +510,7 @@ void ETSBinder::ImportAllForeignBindings(ir::AstNode *const specifier, if (variable != nullptr && var != variable && variable->Declaration()->IsFunctionDecl() && var->Declaration()->IsFunctionDecl()) { bool isStdLib = util::Helpers::IsStdLib(Program()); - AddOverloadFlag(isStdLib, var, variable); + AddOverloadFlag(Allocator(), isStdLib, var, variable); continue; } if (variable != nullptr && var != variable) { @@ -569,71 +575,33 @@ bool ETSBinder::AddImportNamespaceSpecifiersToTopBindings(ir::AstNode *const spe return true; } -void ETSBinder::AddExportSelectiveAlias(const util::StringView &path, const util::StringView &key, - const util::StringView &value) -{ - auto it = selectiveExportsWithAlias_.find(path); - if (it == selectiveExportsWithAlias_.end()) { - AliasesByExportedNames aliasesByExportedNames(Allocator()->Adapter()); - aliasesByExportedNames.insert({key, value}); - selectiveExportsWithAlias_.insert({path, aliasesByExportedNames}); - return; - } - it->second.insert({key, value}); -} - -util::StringView ETSBinder::GetExportSelectiveAliasValue(util::StringView const &path, - util::StringView const &key) const -{ - if (auto alias = selectiveExportsWithAlias_.find(path); selectiveExportsWithAlias_.end() != alias) { - auto ret = alias->second.find(key); - if (alias->second.end() != ret) { - return ret->second; - } - } - return key; -} - Variable *ETSBinder::FindImportSpecifiersVariable(const util::StringView &imported, const varbinder::Scope::VariableMap &globalBindings, const ArenaVector &recordRes) { - auto const checkVar = [this, &imported](const util::StringView &searchImported, - varbinder::Variable *foundVariable) { - if (imported.Is(searchImported.Mutf8()) && foundVariable->Declaration()->Node()->HasAliasExport()) { - ThrowError(foundVariable->Declaration()->Node()->Start(), - "Cannot find imported element '" + imported.Mutf8() + "' exported with alias"); - } - - return foundVariable; - }; - - util::StringView searchImported = GetExportSelectiveAliasValue(recordRes.front()->SourceFilePath(), imported); - auto foundVar = globalBindings.find(searchImported); + auto foundVar = globalBindings.find(imported); if (foundVar == globalBindings.end()) { const auto &staticMethodBindings = recordRes.front()->GlobalClassScope()->StaticMethodScope()->Bindings(); - foundVar = staticMethodBindings.find(searchImported); + foundVar = staticMethodBindings.find(imported); if (foundVar != staticMethodBindings.end()) { - return checkVar(searchImported, foundVar->second); + return foundVar->second; } bool found = false; for (auto res : recordRes) { - searchImported = GetExportSelectiveAliasValue(res->SourceFilePath(), imported); const auto &staticFieldBindings = res->GlobalClassScope()->StaticFieldScope()->Bindings(); - foundVar = staticFieldBindings.find(searchImported); + foundVar = staticFieldBindings.find(imported); if (foundVar != staticFieldBindings.end()) { found = true; foundVar->second->AsLocalVariable()->AddFlag(VariableFlags::INITIALIZED); break; } } - if (!found) { return nullptr; } } - return checkVar(searchImported, foundVar->second); + return foundVar->second; } ir::ETSImportDeclaration *ETSBinder::FindImportDeclInReExports(const ir::ETSImportDeclaration *const import, @@ -734,7 +702,12 @@ bool ETSBinder::AddImportSpecifiersToTopBindings(ir::AstNode *const specifier, } } - auto *const var = FindImportSpecifiersVariable(imported, globalBindings, recordRes); + util::StringView nameToSearchFor = FindNameInAliasMap(import->ResolvedSource()->Str(), imported); + if (nameToSearchFor.Empty()) { + nameToSearchFor = imported; + } + + auto *const var = FindImportSpecifiersVariable(nameToSearchFor, globalBindings, recordRes); importSpecifier->Imported()->SetVariable(var); importSpecifier->Local()->SetVariable(var); @@ -747,23 +720,39 @@ bool ETSBinder::AddImportSpecifiersToTopBindings(ir::AstNode *const specifier, return true; } - ThrowError(importPath->Start(), "Cannot find imported element " + imported.Mutf8()); + ThrowError(importPath->Start(), "Cannot find imported element '" + imported.Mutf8() + "'"); } ValidateImportVariable(var, import, imported, importPath); + if (CheckForRedeclarationError(localName, var, importPath)) { + return true; + } + + // The first part of the condition will be true, if something was given an alias when exported, but we try + // to import it using its original name. + if (nameToSearchFor == imported && var->Declaration()->Node()->HasExportAlias()) { + ThrowError(specifier->Start(), "Cannot find imported element '" + imported.Mutf8() + "'"); + } + + InsertForeignBinding(specifier, import, localName, var); + return true; +} + +bool ETSBinder::CheckForRedeclarationError(const util::StringView &localName, Variable *const var, + const ir::StringLiteral *const importPath) +{ auto variable = Program()->GlobalClassScope()->FindLocal(localName, ResolveBindingOptions::ALL); if (variable != nullptr && var != variable) { if (variable->Declaration()->IsFunctionDecl() && var->Declaration()->IsFunctionDecl()) { bool isStdLib = util::Helpers::IsStdLib(Program()); - AddOverloadFlag(isStdLib, var, variable); + AddOverloadFlag(Allocator(), isStdLib, var, variable); return true; } ThrowError(importPath->Start(), RedeclarationErrorMessageAssembler(var, variable, localName)); } - InsertForeignBinding(specifier, import, localName, var); - return true; + return false; } varbinder::Variable *ETSBinder::FindStaticBinding(const ArenaVector &recordRes, @@ -958,7 +947,8 @@ void ETSBinder::BuildFunctionName(const ir::ScriptFunction *func) const std::stringstream ss; ASSERT(func->IsArrow() || !funcScope->Name().Empty()); - ss << funcScope->Name() << compiler::Signatures::METHOD_SEPARATOR; + ss << (func->IsExternalOverload() ? funcScope->InternalName() : funcScope->Name()) + << compiler::Signatures::METHOD_SEPARATOR; const auto *signature = func->Signature(); @@ -1080,7 +1070,7 @@ bool ETSBinder::ImportGlobalPropertiesForNotDefaultedExports(varbinder::Variable bool isStdLib = util::Helpers::IsStdLib(Program()); if (variable != nullptr && var != variable) { if (variable->Declaration()->IsFunctionDecl() && var->Declaration()->IsFunctionDecl()) { - AddOverloadFlag(isStdLib, var, variable); + AddOverloadFlag(Allocator(), isStdLib, var, variable); return true; } @@ -1092,7 +1082,7 @@ bool ETSBinder::ImportGlobalPropertiesForNotDefaultedExports(varbinder::Variable return true; } if (insRes.first->second->Declaration()->IsFunctionDecl() && var->Declaration()->IsFunctionDecl()) { - AddOverloadFlag(isStdLib, var, insRes.first->second); + AddOverloadFlag(Allocator(), isStdLib, var, insRes.first->second); return true; } diff --git a/ets2panda/varbinder/ETSBinder.h b/ets2panda/varbinder/ETSBinder.h index 82627e4e21d2fe57c63c5d760baa2753985ff5ea..06481ca46c7f9cb00c0f5b4653e79036c48b2ef6 100644 --- a/ets2panda/varbinder/ETSBinder.h +++ b/ets2panda/varbinder/ETSBinder.h @@ -20,11 +20,12 @@ #include "varbinder/recordTable.h" #include "ir/ets/etsImportDeclaration.h" #include "ir/ets/etsReExportDeclaration.h" +#include "ir/expressions/identifier.h" +#include "ir/module/importSpecifier.h" #include "parser/program/program.h" #include "util/importPathManager.h" namespace ark::es2panda::varbinder { - using AliasesByExportedNames = ArenaMap; using ModulesToExportedNamesWithAliases = ArenaMap; @@ -48,7 +49,7 @@ public: reExportImports_(Allocator()->Adapter()), dynamicImportVars_(Allocator()->Adapter()), importSpecifiers_(Allocator()->Adapter()), - selectiveExportsWithAlias_(Allocator()->Adapter()) + selectiveExportAliasMultimap_(Allocator()->Adapter()) { InitImplicitThisParam(); } @@ -223,9 +224,57 @@ public: void ResolveReferencesForScopeWithContext(ir::AstNode *node, Scope *scope); - void AddExportSelectiveAlias(const util::StringView &path, const util::StringView &key, - const util::StringView &value); - util::StringView GetExportSelectiveAliasValue(util::StringView const &path, util::StringView const &key) const; + bool CheckForRedeclarationError(const util::StringView &localName, Variable *const var, + const ir::StringLiteral *const importPath); + + bool AddSelectiveExportAlias(util::StringView const &path, util::StringView const &key, + util::StringView const &value) + { + if (auto foundMap = selectiveExportAliasMultimap_.find(path); foundMap != selectiveExportAliasMultimap_.end()) { + return foundMap->second.insert({key, value}).second; + } + + ArenaMap map(Allocator()->Adapter()); + bool insertResult = map.insert({key, value}).second; + selectiveExportAliasMultimap_.insert({path, map}); + return insertResult; + } + + [[nodiscard]] const ModulesToExportedNamesWithAliases &GetSelectiveExportAliasMultimap() const noexcept + { + return selectiveExportAliasMultimap_; + } + + util::StringView FindNameInAliasMap(const util::StringView &pathAsKey, const util::StringView &aliasName) + { + if (auto relatedMap = selectiveExportAliasMultimap_.find(pathAsKey); + relatedMap != selectiveExportAliasMultimap_.end()) { + if (auto item = relatedMap->second.find(aliasName); item != relatedMap->second.end()) { + return item->second; + } + } + + return ""; + } + + util::StringView FindLocalNameForImport(const ir::ImportSpecifier *const importSpecifier, + util::StringView &imported, const ir::StringLiteral *const importPath) + { + if (importSpecifier->Local() != nullptr) { + auto checkImportPathAndName = [&importPath, &imported](const auto &savedSpecifier) { + return importPath->Str() != savedSpecifier.first && imported == savedSpecifier.second; + }; + if (!std::any_of(importSpecifiers_.begin(), importSpecifiers_.end(), checkImportPathAndName)) { + TopScope()->EraseBinding(imported); + } + + importSpecifiers_.emplace_back(importPath->Str(), imported); + + return importSpecifier->Local()->Name(); + } + + return imported; + } private: void BuildClassDefinitionImpl(ir::ClassDefinition *classDef); @@ -250,7 +299,7 @@ private: ir::Identifier *thisParam_ {}; ArenaVector> importSpecifiers_; ir::AstNode *defaultExport_ {}; - ModulesToExportedNamesWithAliases selectiveExportsWithAlias_; + ModulesToExportedNamesWithAliases selectiveExportAliasMultimap_; friend class RecordTableContext; }; diff --git a/ets2panda/varbinder/variable.cpp b/ets2panda/varbinder/variable.cpp index d845860a7433fa182c5609f06b8a008900156c56..6768c7b88aae56e067f1441206db748a60ff059e 100644 --- a/ets2panda/varbinder/variable.cpp +++ b/ets2panda/varbinder/variable.cpp @@ -15,11 +15,13 @@ #include "variable.h" +#include "checker/types/type.h" #include "varbinder/scope.h" #include namespace ark::es2panda::varbinder { + LocalVariable::LocalVariable(Decl *decl, VariableFlags flags) : Variable(decl, flags) { if (decl->IsConstDecl() || decl->IsReadonlyDecl()) { diff --git a/ets2panda/varbinder/variable.h b/ets2panda/varbinder/variable.h index ce9600fb3d0c1bbf13eae2fd30ec946d18dcb597..ff89914371a17304350b347a2ead0b6a56d49af1 100644 --- a/ets2panda/varbinder/variable.h +++ b/ets2panda/varbinder/variable.h @@ -27,6 +27,10 @@ namespace ark::es2panda::checker { class Type; enum class PropertyType; +// NOLINTBEGIN(readability-redundant-declaration) +bool IsTypeError(Type const *tp); +[[noreturn]] void ThrowEmptyError(); +// NOLINTEND(readability-redundant-declaration) } // namespace ark::es2panda::checker namespace ark::es2panda::varbinder { @@ -81,7 +85,15 @@ public: return flags_; } - [[nodiscard]] checker::Type *TsType() const noexcept + [[nodiscard]] checker::Type *TsType() const + { + if (UNLIKELY(IsTypeError(tsType_))) { + checker::ThrowEmptyError(); + } + return tsType_; + } + + [[nodiscard]] checker::Type *TsTypeOrError() const noexcept { return tsType_; }