From a6ce65e7cb319266f3ea6d0336231ba195cf26ba Mon Sep 17 00:00:00 2001 From: Peter Siket Date: Tue, 10 Oct 2023 08:58:47 +0200 Subject: [PATCH] Implement local classes. Issue: #I8TF63 Internal issue: #13836 Change-Id: I6d2fef8b90c45622ecb91b951526db1505e350b0 Signed-off-by: Peter Siket --- ets2panda/BUILD.gn | 1 + ets2panda/CMakeLists.txt | 1 + ets2panda/checker/ETSAnalyzer.cpp | 24 +- ets2panda/checker/ETSAnalyzer.h | 2 + ets2panda/checker/ETSchecker.cpp | 16 +- ets2panda/checker/ETSchecker.h | 24 +- ets2panda/checker/checkerContext.h | 1 + ets2panda/checker/ets/function.cpp | 7 +- ets2panda/checker/ets/helpers.cpp | 114 +- ets2panda/checker/ets/object.cpp | 16 +- ets2panda/checker/ets/typeCreation.cpp | 14 +- ets2panda/compiler/base/lreference.cpp | 18 +- ets2panda/compiler/core/ETSCompiler.cpp | 11 +- ets2panda/compiler/core/ETSGen.cpp | 61 +- ets2panda/compiler/core/ETSGen.h | 11 +- .../lowering/ets/localClassLowering.cpp | 279 + .../lowering/ets/localClassLowering.h | 50 + ets2panda/compiler/lowering/phase.cpp | 3 + ets2panda/ir/base/classDefinition.cpp | 3 + ets2panda/ir/base/classDefinition.h | 71 +- .../ir/ets/etsNewClassInstanceExpression.h | 5 + ets2panda/parser/ETSparser.cpp | 29 +- ets2panda/parser/statementParser.cpp | 12 + .../ets/identifierReference1-expected.txt | 1967 +--- .../ets/identifierReference15-expected.txt | 893 +- .../ets/identifierReference16-expected.txt | 1397 +-- .../ets/identifierReference6-expected.txt | 576 +- .../ets/identifierReference7-expected.txt | 830 +- .../ets/invalidInheritance2-expected.txt | 751 +- .../ets/invalidPrivateAccess5-expected.txt | 1010 +- .../ets/invalidPrivateAccess6-expected.txt | 1539 +-- .../test/compiler/ets/override13-expected.txt | 2 +- ...staticInitializerInInnerClass-expected.txt | 687 +- .../test/parser/ets/StringFasta-expected.txt | 9691 +---------------- ...terface_enum_only_top_level_4-expected.txt | 470 +- .../ets/class_property_access-expected.txt | 786 +- .../parser/ets/declare_iface-expected.txt | 128 +- .../import_recursive-expected.txt | 211 +- .../subpackage_module_1-expected.txt | 320 +- .../subpackage_module_1-expected.txt | 292 +- .../test/parser/ets/interfaces-expected.txt | 128 +- ...class-access-modifier-private-expected.txt | 1 + .../local-class-access-modifier-private.ets | 22 + ...ass-access-modifier-protected-expected.txt | 1 + .../local-class-access-modifier-protected.ets | 21 + ...-class-access-modifier-public-expected.txt | 1 + .../local-class-access-modifier-public.ets | 21 + .../test/parser/ets/local-class-expected.txt | 425 + ...mber-access-modifier-private1-expected.txt | 1 + ...-class-member-access-modifier-private1.ets | 22 + ...mber-access-modifier-private2-expected.txt | 1 + ...-class-member-access-modifier-private2.ets | 22 + ...er-access-modifier-protected1-expected.txt | 1 + ...lass-member-access-modifier-protected1.ets | 22 + ...er-access-modifier-protected2-expected.txt | 1 + ...lass-member-access-modifier-protected2.ets | 22 + ...ember-access-modifier-public1-expected.txt | 1 + ...l-class-member-access-modifier-public1.ets | 22 + ...ember-access-modifier-public2-expected.txt | 1 + ...l-class-member-access-modifier-public2.ets | 22 + ets2panda/test/parser/ets/local-class.ets | 20 + ...rface-access-modifier-private-expected.txt | 1 + ...ocal-interface-access-modifier-private.ets | 21 + ...ace-access-modifier-protected-expected.txt | 1 + ...al-interface-access-modifier-protected.ets | 21 + ...erface-access-modifier-public-expected.txt | 1 + ...local-interface-access-modifier-public.ets | 21 + .../parser/ets/local-interface-expected.txt | 331 + ...mber-access-modifier-private1-expected.txt | 1 + ...erface-member-access-modifier-private1.ets | 22 + ...mber-access-modifier-private2-expected.txt | 1 + ...erface-member-access-modifier-private2.ets | 22 + ...er-access-modifier-protected1-expected.txt | 1 + ...face-member-access-modifier-protected1.ets | 22 + ...er-access-modifier-protected2-expected.txt | 1 + ...face-member-access-modifier-protected2.ets | 22 + ...ember-access-modifier-public1-expected.txt | 1 + ...terface-member-access-modifier-public1.ets | 22 + ...ember-access-modifier-public2-expected.txt | 1 + ...terface-member-access-modifier-public2.ets | 22 + ets2panda/test/parser/ets/local-interface.ets | 20 + .../ets/localClassIsPermitted-expected.txt | 501 +- .../test/parser/ets/named_types-expected.txt | 1087 +- .../ets/null-coalesc-negative-expected.txt | 166 +- .../parser/ets/test_interface-expected.txt | 128 +- ...mbda_in_body_capture_variable-expected.txt | 595 + .../ets/local-class-capture-boxing.ets | 218 + .../ets/local-class-capture-not-boxing.ets | 151 + .../ets/local-class-capture-parameter.ets | 39 + .../ets/local-class-in-local-class.ets | 54 + .../runtime/ets/local-class-mixed-capture.ets | 46 + .../local-class-modify-captured-parameter.ets | 41 + .../ets/local-class-standard-example1.ets | 49 + .../ets/local-class-standard-example2.ets | 82 + .../ets-runtime/ets-runtime-ignored.txt | 4 + ets2panda/varbinder/ETSBinder.cpp | 2 +- ets2panda/varbinder/recordTable.cpp | 20 +- ets2panda/varbinder/recordTable.h | 3 +- ets2panda/varbinder/scope.cpp | 80 +- ets2panda/varbinder/scope.h | 3 + 100 files changed, 5452 insertions(+), 21473 deletions(-) create mode 100644 ets2panda/compiler/lowering/ets/localClassLowering.cpp create mode 100644 ets2panda/compiler/lowering/ets/localClassLowering.h create mode 100644 ets2panda/test/parser/ets/local-class-access-modifier-private-expected.txt create mode 100644 ets2panda/test/parser/ets/local-class-access-modifier-private.ets create mode 100644 ets2panda/test/parser/ets/local-class-access-modifier-protected-expected.txt create mode 100644 ets2panda/test/parser/ets/local-class-access-modifier-protected.ets create mode 100644 ets2panda/test/parser/ets/local-class-access-modifier-public-expected.txt create mode 100644 ets2panda/test/parser/ets/local-class-access-modifier-public.ets create mode 100644 ets2panda/test/parser/ets/local-class-expected.txt create mode 100644 ets2panda/test/parser/ets/local-class-member-access-modifier-private1-expected.txt create mode 100644 ets2panda/test/parser/ets/local-class-member-access-modifier-private1.ets create mode 100644 ets2panda/test/parser/ets/local-class-member-access-modifier-private2-expected.txt create mode 100644 ets2panda/test/parser/ets/local-class-member-access-modifier-private2.ets create mode 100644 ets2panda/test/parser/ets/local-class-member-access-modifier-protected1-expected.txt create mode 100644 ets2panda/test/parser/ets/local-class-member-access-modifier-protected1.ets create mode 100644 ets2panda/test/parser/ets/local-class-member-access-modifier-protected2-expected.txt create mode 100644 ets2panda/test/parser/ets/local-class-member-access-modifier-protected2.ets create mode 100644 ets2panda/test/parser/ets/local-class-member-access-modifier-public1-expected.txt create mode 100644 ets2panda/test/parser/ets/local-class-member-access-modifier-public1.ets create mode 100644 ets2panda/test/parser/ets/local-class-member-access-modifier-public2-expected.txt create mode 100644 ets2panda/test/parser/ets/local-class-member-access-modifier-public2.ets create mode 100644 ets2panda/test/parser/ets/local-class.ets create mode 100644 ets2panda/test/parser/ets/local-interface-access-modifier-private-expected.txt create mode 100644 ets2panda/test/parser/ets/local-interface-access-modifier-private.ets create mode 100644 ets2panda/test/parser/ets/local-interface-access-modifier-protected-expected.txt create mode 100644 ets2panda/test/parser/ets/local-interface-access-modifier-protected.ets create mode 100644 ets2panda/test/parser/ets/local-interface-access-modifier-public-expected.txt create mode 100644 ets2panda/test/parser/ets/local-interface-access-modifier-public.ets create mode 100644 ets2panda/test/parser/ets/local-interface-expected.txt create mode 100644 ets2panda/test/parser/ets/local-interface-member-access-modifier-private1-expected.txt create mode 100644 ets2panda/test/parser/ets/local-interface-member-access-modifier-private1.ets create mode 100644 ets2panda/test/parser/ets/local-interface-member-access-modifier-private2-expected.txt create mode 100644 ets2panda/test/parser/ets/local-interface-member-access-modifier-private2.ets create mode 100644 ets2panda/test/parser/ets/local-interface-member-access-modifier-protected1-expected.txt create mode 100644 ets2panda/test/parser/ets/local-interface-member-access-modifier-protected1.ets create mode 100644 ets2panda/test/parser/ets/local-interface-member-access-modifier-protected2-expected.txt create mode 100644 ets2panda/test/parser/ets/local-interface-member-access-modifier-protected2.ets create mode 100644 ets2panda/test/parser/ets/local-interface-member-access-modifier-public1-expected.txt create mode 100644 ets2panda/test/parser/ets/local-interface-member-access-modifier-public1.ets create mode 100644 ets2panda/test/parser/ets/local-interface-member-access-modifier-public2-expected.txt create mode 100644 ets2panda/test/parser/ets/local-interface-member-access-modifier-public2.ets create mode 100644 ets2panda/test/parser/ets/local-interface.ets create mode 100644 ets2panda/test/runtime/ets/local-class-capture-boxing.ets create mode 100644 ets2panda/test/runtime/ets/local-class-capture-not-boxing.ets create mode 100644 ets2panda/test/runtime/ets/local-class-capture-parameter.ets create mode 100644 ets2panda/test/runtime/ets/local-class-in-local-class.ets create mode 100644 ets2panda/test/runtime/ets/local-class-mixed-capture.ets create mode 100644 ets2panda/test/runtime/ets/local-class-modify-captured-parameter.ets create mode 100644 ets2panda/test/runtime/ets/local-class-standard-example1.ets create mode 100644 ets2panda/test/runtime/ets/local-class-standard-example2.ets diff --git a/ets2panda/BUILD.gn b/ets2panda/BUILD.gn index f80821e40e..75c8be3212 100644 --- a/ets2panda/BUILD.gn +++ b/ets2panda/BUILD.gn @@ -164,6 +164,7 @@ libes2panda_sources = [ "compiler/lowering/ets/generateDeclarations.cpp", "compiler/lowering/ets/interfacePropertyDeclarations.cpp", "compiler/lowering/ets/lambdaLowering.cpp", + "compiler/lowering/ets/localClassLowering.cpp", "compiler/lowering/ets/objectIndexAccess.cpp", "compiler/lowering/ets/objectIterator.cpp", "compiler/lowering/ets/opAssignment.cpp", diff --git a/ets2panda/CMakeLists.txt b/ets2panda/CMakeLists.txt index 386212ba63..668fbc3046 100644 --- a/ets2panda/CMakeLists.txt +++ b/ets2panda/CMakeLists.txt @@ -151,6 +151,7 @@ set(ES2PANDA_LIB_SRC compiler/lowering/plugin_phase.cpp compiler/lowering/util.cpp compiler/lowering/ets/lambdaLowering.cpp + compiler/lowering/ets/localClassLowering.cpp compiler/lowering/ets/generateDeclarations.cpp compiler/lowering/ets/objectIndexAccess.cpp compiler/lowering/ets/objectIterator.cpp diff --git a/ets2panda/checker/ETSAnalyzer.cpp b/ets2panda/checker/ETSAnalyzer.cpp index 7917598b0e..ac0de8bc56 100644 --- a/ets2panda/checker/ETSAnalyzer.cpp +++ b/ets2panda/checker/ETSAnalyzer.cpp @@ -555,13 +555,18 @@ checker::Type *ETSAnalyzer::Check(ir::ETSNewArrayInstanceExpression *expr) const return expr->TsType(); } -checker::Type *ETSAnalyzer::Check(ir::ETSNewClassInstanceExpression *expr) const +void ETSAnalyzer::CheckLocalClassInstantiation(ir::ETSNewClassInstanceExpression *expr, ETSObjectType *calleeObj) const { ETSChecker *checker = GetETSChecker(); - auto *calleeType = GetCalleeType(checker, expr); - auto *calleeObj = calleeType->AsETSObjectType(); - expr->SetTsType(calleeObj); + ASSERT(calleeObj->GetDeclNode()->IsClassDefinition()); + if (calleeObj->GetDeclNode()->AsClassDefinition()->IsLocal()) { + checker->AddToLocalClassInstantiationList(expr); + } +} +void ETSAnalyzer::CheckInstantatedClass(ir::ETSNewClassInstanceExpression *expr, ETSObjectType *&calleeObj) const +{ + ETSChecker *checker = GetETSChecker(); if (expr->ClassDefinition() != nullptr) { if (!calleeObj->HasObjectFlag(checker::ETSObjectFlags::ABSTRACT) && calleeObj->GetDeclNode()->IsFinal()) { checker->ThrowTypeError({"Class ", calleeObj->Name(), " cannot be both 'abstract' and 'final'."}, @@ -582,6 +587,17 @@ checker::Type *ETSAnalyzer::Check(ir::ETSNewClassInstanceExpression *expr) const } else if (calleeObj->HasObjectFlag(checker::ETSObjectFlags::ABSTRACT)) { checker->ThrowTypeError({calleeObj->Name(), " is abstract therefore cannot be instantiated."}, expr->Start()); } +} + +checker::Type *ETSAnalyzer::Check(ir::ETSNewClassInstanceExpression *expr) const +{ + ETSChecker *checker = GetETSChecker(); + auto *calleeType = GetCalleeType(checker, expr); + auto *calleeObj = calleeType->AsETSObjectType(); + expr->SetTsType(calleeObj); + + CheckLocalClassInstantiation(expr, calleeObj); + CheckInstantatedClass(expr, calleeObj); if (calleeType->IsETSDynamicType() && !calleeType->AsETSDynamicType()->HasDecl()) { auto lang = calleeType->AsETSDynamicType()->Language(); diff --git a/ets2panda/checker/ETSAnalyzer.h b/ets2panda/checker/ETSAnalyzer.h index 4f63eeaed4..8350294baf 100644 --- a/ets2panda/checker/ETSAnalyzer.h +++ b/ets2panda/checker/ETSAnalyzer.h @@ -42,6 +42,8 @@ public: private: ETSChecker *GetETSChecker() const; + void CheckInstantatedClass(ir::ETSNewClassInstanceExpression *expr, ETSObjectType *&calleeObj) const; + void CheckLocalClassInstantiation(ir::ETSNewClassInstanceExpression *expr, ETSObjectType *calleeObj) const; void CheckMethodModifiers(ir::MethodDefinition *node) const; checker::Signature *ResolveSignature(ETSChecker *checker, ir::CallExpression *expr, checker::Type *calleeType, bool isFunctionalInterface, bool isUnionTypeWithFunctionalInterface) const; diff --git a/ets2panda/checker/ETSchecker.cpp b/ets2panda/checker/ETSchecker.cpp index 1968b6b553..29c64c2734 100644 --- a/ets2panda/checker/ETSchecker.cpp +++ b/ets2panda/checker/ETSchecker.cpp @@ -137,6 +137,21 @@ void ETSChecker::InitializeBuiltin(varbinder::Variable *var, const util::StringV GetGlobalTypesHolder()->InitializeBuiltin(name, type); } +const ArenaList &ETSChecker::GetLocalClasses() const +{ + return localClasses_; +} + +const ArenaList &ETSChecker::GetLocalClassInstantiations() const +{ + return localClassInstantiations_; +} + +void ETSChecker::AddToLocalClassInstantiationList(ir::ETSNewClassInstanceExpression *newExpr) +{ + localClassInstantiations_.push_back(newExpr); +} + bool ETSChecker::StartChecker([[maybe_unused]] varbinder::VarBinder *varbinder, const CompilerOptions &options) { Initialize(varbinder); @@ -168,7 +183,6 @@ bool ETSChecker::StartChecker([[maybe_unused]] varbinder::VarBinder *varbinder, } CheckProgram(Program(), true); - BuildDynamicCallClass(true); BuildDynamicCallClass(false); diff --git a/ets2panda/checker/ETSchecker.h b/ets2panda/checker/ETSchecker.h index 8c0b13990c..f401c4bdf1 100644 --- a/ets2panda/checker/ETSchecker.h +++ b/ets2panda/checker/ETSchecker.h @@ -61,6 +61,8 @@ public: // NOLINTNEXTLINE(readability-redundant-member-init) : Checker(), arrayTypes_(Allocator()->Adapter()), + localClasses_(Allocator()->Adapter()), + localClassInstantiations_(Allocator()->Adapter()), globalArraySignatures_(Allocator()->Adapter()), primitiveWrappers_(Allocator()), cachedComputedAbstracts_(Allocator()->Adapter()), @@ -159,6 +161,7 @@ public: void AddImplementedSignature(std::vector *implementedSignatures, varbinder::LocalVariable *function, ETSFunctionType *it); void CheckInnerClassMembers(const ETSObjectType *classType); + void CheckLocalClass(ir::ClassDefinition *classDef, CheckerStatus &checkerStatus); void CheckClassDefinition(ir::ClassDefinition *classDef); void FindAssignment(const ir::AstNode *node, const varbinder::LocalVariable *classVar, bool &initialized); void FindAssignments(const ir::AstNode *node, const varbinder::LocalVariable *classVar, bool &initialized); @@ -506,11 +509,13 @@ public: std::pair FindVariableInClassOrEnclosing( util::StringView name, const ETSObjectType *classType); varbinder::Variable *FindVariableInGlobal(const ir::Identifier *identifier); + void ExtraCheckForResolvedError(ir::Identifier *ident); void ValidateResolvedIdentifier(ir::Identifier *ident, varbinder::Variable *resolved); static bool IsVariableStatic(const varbinder::Variable *var); static bool IsVariableGetterSetter(const varbinder::Variable *var); bool IsSameDeclarationType(varbinder::LocalVariable *target, varbinder::LocalVariable *compare); - void SaveCapturedVariable(varbinder::Variable *var, const lexer::SourcePosition &pos); + void SaveCapturedVariable(varbinder::Variable *var, ir::Identifier *ident); + bool SaveCapturedVariableInLocalClass(varbinder::Variable *var, ir::Identifier *ident); void AddBoxingFlagToPrimitiveType(TypeRelation *relation, Type *target); void AddUnboxingFlagToPrimitiveType(TypeRelation *relation, Type *source, Type *self); void CheckUnboxedTypeWidenable(TypeRelation *relation, Type *target, Type *self); @@ -547,6 +552,7 @@ public: static ir::MethodDefinition *GenerateDefaultGetterSetter(ir::ClassProperty *field, varbinder::ClassScope *scope, bool isSetter, ETSChecker *checker); + bool IsInLocalClass(const ir::AstNode *node) const; // Exception ETSObjectType *CheckExceptionOrErrorType(checker::Type *type, lexer::SourcePosition pos); @@ -606,6 +612,12 @@ public: ETSObjectType *GetCachedFunctionlInterface(ir::ETSFunctionType *type); void CacheFunctionalInterface(ir::ETSFunctionType *type, ETSObjectType *ifaceType); + const ArenaList &GetLocalClasses() const; + const ArenaList &GetLocalClassInstantiations() const; + void AddToLocalClassInstantiationList(ir::ETSNewClassInstanceExpression *newExpr); + + ir::ETSParameterExpression *AddParam(varbinder::FunctionParamScope *paramScope, util::StringView name, + checker::Type *type); private: using ClassBuilder = std::function *)>; @@ -615,9 +627,10 @@ private: ArenaVector *, Type **)>; std::pair GetTargetIdentifierAndType(ir::Identifier *ident); - void ThrowError(ir::Identifier *ident); + [[noreturn]] void ThrowError(ir::Identifier *ident); void CheckEtsFunctionType(ir::Identifier *ident, ir::Identifier const *id, ir::TypeNode const *annotation); - void NotResolvedError(ir::Identifier *ident); + [[noreturn]] void NotResolvedError(ir::Identifier *ident, const varbinder::Variable *classVar, + const ETSObjectType *classType); void ValidateCallExpressionIdentifier(ir::Identifier *ident, Type *type); void ValidateNewClassInstanceIdentifier(ir::Identifier *ident, varbinder::Variable *resolved); void ValidateMemberIdentifier(ir::Identifier *ident, varbinder::Variable *resolved, Type *type); @@ -643,9 +656,6 @@ private: std::conditional_t CreateClassInitializer( varbinder::ClassScope *classScope, const ClassInitializerBuilder &builder, ETSObjectType *type = nullptr); - ir::ETSParameterExpression *AddParam(varbinder::FunctionParamScope *paramScope, util::StringView name, - checker::Type *type); - template ir::MethodDefinition *CreateClassMethod(varbinder::ClassScope *classScope, std::string_view name, ir::ModifierFlags modifierFlags, const MethodBuilder &builder); @@ -711,6 +721,8 @@ private: bool TryTransformingToStaticInvoke(ir::Identifier *ident, const Type *resolvedType); ArrayMap arrayTypes_; + ArenaList localClasses_; + ArenaList localClassInstantiations_; GlobalArraySignatureMap globalArraySignatures_; PrimitiveWrappers primitiveWrappers_; ComputedAbstracts cachedComputedAbstracts_; diff --git a/ets2panda/checker/checkerContext.h b/ets2panda/checker/checkerContext.h index 79c59a3fab..11ff0c4f3c 100644 --- a/ets2panda/checker/checkerContext.h +++ b/ets2panda/checker/checkerContext.h @@ -45,6 +45,7 @@ enum class CheckerStatus : uint32_t { IN_LAMBDA = 1U << 13U, IGNORE_VISIBILITY = 1U << 14U, IN_INSTANCE_EXTENSION_METHOD = 1U << 15U, + IN_LOCAL_CLASS = 1U << 16U }; DEFINE_BITOPS(CheckerStatus) diff --git a/ets2panda/checker/ets/function.cpp b/ets2panda/checker/ets/function.cpp index 34473739d3..bb5d421349 100644 --- a/ets2panda/checker/ets/function.cpp +++ b/ets2panda/checker/ets/function.cpp @@ -1308,7 +1308,9 @@ void ETSChecker::CheckCapturedVariable(ir::AstNode *const node, varbinder::Varia void ETSChecker::CheckCapturedVariableInSubnodes(ir::AstNode *node, varbinder::Variable *var) { - node->Iterate([this, var](ir::AstNode *childNode) { CheckCapturedVariable(childNode, var); }); + if (!node->IsClassDefinition()) { + node->Iterate([this, var](ir::AstNode *childNode) { CheckCapturedVariable(childNode, var); }); + } } void ETSChecker::CheckCapturedVariables() @@ -2110,13 +2112,14 @@ ir::ClassProperty *ETSChecker::CreateLambdaCapturedField(const varbinder::Variab auto fieldCtx = varbinder::LexicalScope::Enter(VarBinder(), scope->InstanceFieldScope()); // Create the name for the synthetic property node - util::UString fieldName(util::StringView("field"), Allocator()); + util::UString fieldName(util::StringView("field#"), Allocator()); fieldName.Append(std::to_string(idx)); auto *fieldIdent = Allocator()->New(fieldName.View(), Allocator()); // Create the synthetic class property node auto *field = Allocator()->New(fieldIdent, nullptr, nullptr, ir::ModifierFlags::NONE, Allocator(), false); + fieldIdent->SetParent(field); // Add the declaration to the scope, and set the type based on the captured variable's scope auto [decl, var] = VarBinder()->NewVarDecl(pos, fieldIdent->Name()); diff --git a/ets2panda/checker/ets/helpers.cpp b/ets2panda/checker/ets/helpers.cpp index a4e7677631..eb8f1a1d82 100644 --- a/ets2panda/checker/ets/helpers.cpp +++ b/ets2panda/checker/ets/helpers.cpp @@ -490,16 +490,16 @@ void ETSChecker::CheckEtsFunctionType(ir::Identifier *const ident, ir::Identifie } } -void ETSChecker::NotResolvedError(ir::Identifier *const ident) +void ETSChecker::NotResolvedError(ir::Identifier *const ident, const varbinder::Variable *classVar, + const ETSObjectType *classType) { - const auto [class_var, class_type] = FindVariableInClassOrEnclosing(ident->Name(), Context().ContainingClass()); - if (class_var == nullptr) { + if (classVar == nullptr) { ThrowError(ident); } - if (IsVariableStatic(class_var)) { + if (IsVariableStatic(classVar)) { ThrowTypeError( - {"Static property '", ident->Name(), "' must be accessed through it's class '", class_type->Name(), "'"}, + {"Static property '", ident->Name(), "' must be accessed through it's class '", classType->Name(), "'"}, ident->Start()); } else { ThrowTypeError({"Property '", ident->Name(), "' must be accessed through 'this'"}, ident->Start()); @@ -614,10 +614,25 @@ bool ETSChecker::ValidateBinaryExpressionIdentifier(ir::Identifier *const ident, return isFinished; } +void ETSChecker::ExtraCheckForResolvedError(ir::Identifier *const ident) +{ + const auto [class_var, class_type] = FindVariableInClassOrEnclosing(ident->Name(), Context().ContainingClass()); + auto *parentClass = FindAncestorGivenByType(ident, ir::AstNodeType::CLASS_DEFINITION); + if (parentClass != nullptr && parentClass->AsClassDefinition()->IsLocal()) { + if (parentClass != class_type->GetDeclNode()) { + ThrowTypeError({"Property '", ident->Name(), "' of enclosing class '", class_type->Name(), + "' is not allowed to be captured from the local class '", + parentClass->AsClassDefinition()->Ident()->Name(), "'"}, + ident->Start()); + } + } + NotResolvedError(ident, class_var, class_type); +} + void ETSChecker::ValidateResolvedIdentifier(ir::Identifier *const ident, varbinder::Variable *const resolved) { if (resolved == nullptr) { - NotResolvedError(ident); + ExtraCheckForResolvedError(ident); } auto *const resolvedType = GetApparentType(GetTypeOfVariable(resolved)); @@ -667,8 +682,77 @@ void ETSChecker::ValidateResolvedIdentifier(ir::Identifier *const ident, varbind } } -void ETSChecker::SaveCapturedVariable(varbinder::Variable *const var, const lexer::SourcePosition &pos) +bool ETSChecker::SaveCapturedVariableInLocalClass(varbinder::Variable *const var, ir::Identifier *ident) { + const auto &pos = ident->Start(); + + if (!HasStatus(CheckerStatus::IN_LOCAL_CLASS)) { + return false; + } + + if (!var->HasFlag(varbinder::VariableFlags::LOCAL)) { + return false; + } + + LOG(DEBUG, ES2PANDA) << "Checking variable (line:" << pos.line << "): " << var->Name(); + auto *scopeIter = Scope(); + bool inStaticMethod = false; + + auto captureVariable = [this, var, ident, &scopeIter, &inStaticMethod, &pos]() { + if (inStaticMethod) { + ThrowTypeError({"Not allowed to capture variable '", var->Name(), "' in static method"}, pos); + } + if (scopeIter->Node()->AsClassDefinition()->CaptureVariable(var)) { + LOG(DEBUG, ES2PANDA) << " Captured in class:" << scopeIter->Node()->AsClassDefinition()->Ident()->Name(); + } + + auto *parent = ident->Parent(); + + if (parent->IsVariableDeclarator()) { + parent = parent->Parent()->Parent(); + } + + if (!(parent->IsUpdateExpression() || + (parent->IsAssignmentExpression() && parent->AsAssignmentExpression()->Left() == ident)) || + var->Declaration() == nullptr) { + return; + } + + if (var->Declaration()->IsParameterDecl()) { + LOG(DEBUG, ES2PANDA) << " - Modified parameter "; + if (!var->HasFlag(varbinder::VariableFlags::BOXED)) { + scopeIter->Node()->AsClassDefinition()->AddToLocalVariableIsNeeded(var); + } + } else { + var->AddFlag(varbinder::VariableFlags::BOXED); + } + }; + + while (scopeIter != var->GetScope()) { + if (scopeIter->Node() != nullptr) { + if (scopeIter->Node()->IsScriptFunction() && scopeIter->Node()->AsScriptFunction()->IsStatic()) { + inStaticMethod = true; + } + + if (scopeIter->Node()->IsClassDefinition()) { + captureVariable(); + return true; + } + } + scopeIter = scopeIter->Parent(); + } + + return false; +} + +void ETSChecker::SaveCapturedVariable(varbinder::Variable *const var, ir::Identifier *ident) +{ + const auto &pos = ident->Start(); + + if (SaveCapturedVariableInLocalClass(var, ident)) { + return; + } + if (!HasStatus(CheckerStatus::IN_LAMBDA)) { return; } @@ -697,7 +781,7 @@ Type *ETSChecker::ResolveIdentifier(ir::Identifier *const ident) { if (ident->Variable() != nullptr) { auto *const resolved = ident->Variable(); - SaveCapturedVariable(resolved, ident->Start()); + SaveCapturedVariable(resolved, ident); return GetTypeOfVariable(resolved); } @@ -711,7 +795,7 @@ Type *ETSChecker::ResolveIdentifier(ir::Identifier *const ident) ValidateResolvedIdentifier(ident, resolved); ValidatePropertyAccess(resolved, Context().ContainingClass(), ident->Start()); - SaveCapturedVariable(resolved, ident->Start()); + SaveCapturedVariable(resolved, ident); ident->SetVariable(resolved); return GetTypeOfVariable(resolved); @@ -2618,6 +2702,18 @@ void ETSChecker::ModifyPreferredType(ir::ArrayExpression *const arrayExpr, Type } } +bool ETSChecker::IsInLocalClass(const ir::AstNode *node) const +{ + while (node != nullptr) { + if (node->Type() == ir::AstNodeType::CLASS_DEFINITION) { + return node->AsClassDefinition()->IsLocal(); + } + node = node->Parent(); + } + + return false; +} + ir::Expression *ETSChecker::GenerateImplicitInstantiateArg(varbinder::LocalVariable *instantiateMethod, const std::string &className) { diff --git a/ets2panda/checker/ets/object.cpp b/ets2panda/checker/ets/object.cpp index d7c3f9dea3..82f9371201 100644 --- a/ets2panda/checker/ets/object.cpp +++ b/ets2panda/checker/ets/object.cpp @@ -814,12 +814,22 @@ void ETSChecker::AddImplementedSignature(std::vector *implementedSi } } +void ETSChecker::CheckLocalClass(ir::ClassDefinition *classDef, CheckerStatus &checkerStatus) +{ + if (classDef->IsLocal()) { + checkerStatus |= CheckerStatus::IN_LOCAL_CLASS; + if (!classDef->Parent()->Parent()->IsBlockStatement()) { + ThrowTypeError("Local classes must be defined between balanced braces", classDef->Start()); + } + localClasses_.push_back(classDef); + } +} + void ETSChecker::CheckClassDefinition(ir::ClassDefinition *classDef) { auto *classType = classDef->TsType()->AsETSObjectType(); - auto *enclosingClass = Context().ContainingClass(); auto newStatus = checker::CheckerStatus::IN_CLASS; - classType->SetEnclosingType(enclosingClass); + classType->SetEnclosingType(Context().ContainingClass()); if (classDef->IsInner()) { newStatus |= CheckerStatus::INNER_CLASS; @@ -828,6 +838,8 @@ void ETSChecker::CheckClassDefinition(ir::ClassDefinition *classDef) if (classDef->IsGlobal()) { classType->AddObjectFlag(checker::ETSObjectFlags::GLOBAL); + } else { + CheckLocalClass(classDef, newStatus); } checker::ScopeContext scopeCtx(this, classDef->Scope()); diff --git a/ets2panda/checker/ets/typeCreation.cpp b/ets2panda/checker/ets/typeCreation.cpp index b02188e7a1..cf746be38b 100644 --- a/ets2panda/checker/ets/typeCreation.cpp +++ b/ets2panda/checker/ets/typeCreation.cpp @@ -25,6 +25,7 @@ #include "checker/types/ets/shortType.h" #include "generated/signatures.h" #include "ir/base/classDefinition.h" +#include "ir/statements/classDeclaration.h" #include "ir/base/scriptFunction.h" #include "ir/ets/etsScript.h" #include "ir/expressions/identifier.h" @@ -499,6 +500,14 @@ ETSObjectType *ETSChecker::CreateNewETSObjectType(util::StringView name, ir::Ast auto *containingObjType = util::Helpers::GetContainingObjectType(declNode->Parent()); + if (declNode->IsClassDefinition()) { + if (declNode->AsClassDefinition()->IsLocal()) { + util::UString localName(declNode->AsClassDefinition()->LocalPrefix(), Allocator()); + localName.Append(name); + assemblerName = localName.View(); + } + } + if (containingObjType != nullptr) { prefix = containingObjType->AssemblerName(); } else if (const auto *topStatement = declNode->GetTopStatement(); @@ -507,14 +516,13 @@ ETSObjectType *ETSChecker::CreateNewETSObjectType(util::StringView name, ir::Ast ASSERT(declNode->IsTSInterfaceDeclaration()); assemblerName = declNode->AsTSInterfaceDeclaration()->InternalName(); } else { - auto *program = static_cast(declNode->GetTopStatement())->Program(); - prefix = program->GetPackageName(); + prefix = static_cast(declNode->GetTopStatement())->Program()->GetPackageName(); } if (!prefix.Empty()) { util::UString fullPath(prefix, Allocator()); fullPath.Append('.'); - fullPath.Append(name); + fullPath.Append(assemblerName); assemblerName = fullPath.View(); } diff --git a/ets2panda/compiler/base/lreference.cpp b/ets2panda/compiler/base/lreference.cpp index 8b00d8c3c0..a047c992aa 100644 --- a/ets2panda/compiler/base/lreference.cpp +++ b/ets2panda/compiler/base/lreference.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 @@ -208,14 +208,24 @@ ETSLReference::ETSLReference(CodeGen *cg, const ir::AstNode *node, ReferenceKind ETSLReference ETSLReference::Create(CodeGen *const cg, const ir::AstNode *const node, const bool isDeclaration) { if (node->Type() == ir::AstNodeType::IDENTIFIER) { + if (node->AsIdentifier()->Variable() != nullptr) { + auto *var = node->AsIdentifier()->Variable(); + varbinder::ConstScopeFindResult res; + res.name = var->Name(); + res.variable = var; + res.scope = var->GetScope(); + auto refKind = ReferenceKind::VAR_OR_GLOBAL; + if (var->HasFlag(varbinder::VariableFlags::PROPERTY)) { + refKind = ReferenceKind::FIELD; + } + return {cg, node, refKind, res, isDeclaration}; + } + const auto &name = node->AsIdentifier()->Name(); auto res = cg->Scope()->FindInFunctionScope(name, varbinder::ResolveBindingOptions::ALL); if (res.variable == nullptr) { res = cg->Scope()->FindInGlobal(name, varbinder::ResolveBindingOptions::ALL_VARIABLES | varbinder::ResolveBindingOptions::ALL_METHOD); - if (res.variable == nullptr) { - res.variable = node->AsIdentifier()->Variable(); - } } return {cg, node, ReferenceKind::VAR_OR_GLOBAL, res, isDeclaration}; diff --git a/ets2panda/compiler/core/ETSCompiler.cpp b/ets2panda/compiler/core/ETSCompiler.cpp index e7c26b723e..eeb5b8624f 100644 --- a/ets2panda/compiler/core/ETSCompiler.cpp +++ b/ets2panda/compiler/core/ETSCompiler.cpp @@ -321,6 +321,7 @@ void ETSCompiler::Compile(const ir::ETSNewClassInstanceExpression *expr) const { ETSGen *etsg = GetETSGen(); if (expr->TsType()->IsETSDynamicType()) { + compiler::RegScope rs(etsg); auto objReg = etsg->AllocReg(); auto *name = expr->GetTypeRef()->AsETSTypeReference()->Part()->Name(); CreateDynamicObject(expr, etsg, objReg, name, expr->signature_, expr->GetArguments()); @@ -1559,10 +1560,7 @@ void ETSCompiler::Compile(const ir::BreakStatement *st) const CompileImpl(st, etsg); } -void ETSCompiler::Compile([[maybe_unused]] const ir::ClassDeclaration *st) const -{ - UNREACHABLE(); -} +void ETSCompiler::Compile([[maybe_unused]] const ir::ClassDeclaration *st) const {} static void CompileImpl(const ir::ContinueStatement *self, ETSGen *etsg) { @@ -2175,10 +2173,7 @@ void ETSCompiler::Compile([[maybe_unused]] const ir::TSInterfaceBody *expr) cons UNREACHABLE(); } -void ETSCompiler::Compile([[maybe_unused]] const ir::TSInterfaceDeclaration *st) const -{ - UNREACHABLE(); -} +void ETSCompiler::Compile([[maybe_unused]] const ir::TSInterfaceDeclaration *st) const {} void ETSCompiler::Compile([[maybe_unused]] const ir::TSInterfaceHeritage *expr) const { diff --git a/ets2panda/compiler/core/ETSGen.cpp b/ets2panda/compiler/core/ETSGen.cpp index 1d6a51b9ab..49a17fb370 100644 --- a/ets2panda/compiler/core/ETSGen.cpp +++ b/ets2panda/compiler/core/ETSGen.cpp @@ -320,7 +320,7 @@ void ETSGen::LoadVar(const ir::AstNode *node, varbinder::Variable const *const v } case ReferenceKind::LOCAL: { LoadAccumulator(node, local->Vreg()); - SetAccumulatorType(var->TsType()); + SetAccumulatorType(TypeForVar(var)); break; } default: { @@ -345,7 +345,11 @@ void ETSGen::StoreVar(const ir::AstNode *node, const varbinder::ConstScopeFindRe break; } case ReferenceKind::FIELD: { - StoreProperty(node, result.variable->TsType(), GetThisReg(), result.name); + if (local->HasFlag(varbinder::VariableFlags::BOXED)) { + EmitPropertyBoxSet(node, result.variable->TsType(), GetThisReg(), result.name); + } else { + StoreProperty(node, result.variable->TsType(), GetThisReg(), result.name); + } break; } case ReferenceKind::LOCAL: { @@ -371,7 +375,9 @@ util::StringView ETSGen::FormClassPropReference(const checker::ETSObjectType *cl std::string fullName = classType->AssemblerName().Mutf8(); while (iter->EnclosingType() != nullptr) { auto enclosingName = iter->EnclosingType()->Name().Mutf8().append(".").append(fullName); - fullName = enclosingName; + if (iter->EnclosingType()->GetDeclNode()->Type() == ir::AstNodeType::IDENTIFIER) { + fullName = enclosingName; + } iter = iter->EnclosingType(); } @@ -1395,6 +1401,54 @@ void ETSGen::EmitLocalBoxSet(ir::AstNode const *node, varbinder::LocalVariable * SetAccumulatorType(Checker()->GetGlobalTypesHolder()->GlobalVoidType()); } +void ETSGen::EmitPropertyBoxSet(const ir::AstNode *const node, const checker::Type *propType, const VReg objectReg, + const util::StringView &name) +{ + const auto fullName = FormClassPropReference(GetVRegType(objectReg)->AsETSObjectType(), name); + const RegScope rs(this); + + auto inputValue = AllocReg(); + StoreAccumulator(node, inputValue); + + Ra().Emit(node, objectReg, fullName); + SetAccumulatorType(Checker()->GetGlobalTypesHolder()->GlobalETSObjectType()); + + auto field = AllocReg(); + StoreAccumulator(node, field); + LoadAccumulator(node, inputValue); + + switch (checker::ETSChecker::TypeKind(propType)) { + case checker::TypeFlag::ETS_BOOLEAN: + Ra().Emit(node, Signatures::BUILTIN_BOOLEAN_BOX_SET, field, 1); + break; + case checker::TypeFlag::BYTE: + Ra().Emit(node, Signatures::BUILTIN_BYTE_BOX_SET, field, 1); + break; + case checker::TypeFlag::CHAR: + Ra().Emit(node, Signatures::BUILTIN_CHAR_BOX_SET, field, 1); + break; + case checker::TypeFlag::SHORT: + Ra().Emit(node, Signatures::BUILTIN_SHORT_BOX_SET, field, 1); + break; + case checker::TypeFlag::INT: + Ra().Emit(node, Signatures::BUILTIN_INT_BOX_SET, field, 1); + break; + case checker::TypeFlag::LONG: + Ra().Emit(node, Signatures::BUILTIN_LONG_BOX_SET, field, 1); + break; + case checker::TypeFlag::FLOAT: + Ra().Emit(node, Signatures::BUILTIN_FLOAT_BOX_SET, field, 1); + break; + case checker::TypeFlag::DOUBLE: + Ra().Emit(node, Signatures::BUILTIN_DOUBLE_BOX_SET, field, 1); + break; + default: + Ra().Emit(node, Signatures::BUILTIN_BOX_SET, field, 1); + break; + } + SetAccumulatorType(Checker()->GetGlobalTypesHolder()->GlobalVoidType()); +} + void ETSGen::CastToBoolean([[maybe_unused]] const ir::AstNode *node) { auto typeKind = checker::ETSChecker::TypeKind(GetAccumulatorType()); @@ -1765,6 +1819,7 @@ void ETSGen::CastDynamicToObject(const ir::AstNode *node, const checker::Type *t // NOTE(vpukhov): #14626 remove, replace targetType with interface if (targetType->IsLambdaObject()) { + RegScope rs(this); VReg dynObjReg = AllocReg(); StoreAccumulator(node, dynObjReg); Ra().Emit(node, targetType->AsETSObjectType()->ConstructSignatures()[0]->InternalName(), diff --git a/ets2panda/compiler/core/ETSGen.h b/ets2panda/compiler/core/ETSGen.h index 1daa3360f7..0ea1091c3e 100644 --- a/ets2panda/compiler/core/ETSGen.h +++ b/ets2panda/compiler/core/ETSGen.h @@ -377,6 +377,8 @@ public: void EmitLocalBoxCtor(ir::AstNode const *node); void EmitLocalBoxGet(ir::AstNode const *node, checker::Type const *contentType); void EmitLocalBoxSet(ir::AstNode const *node, varbinder::LocalVariable *lhsVar); + void EmitPropertyBoxSet(const ir::AstNode *node, const checker::Type *propType, VReg objectReg, + const util::StringView &name); void LoadArrayLength(const ir::AstNode *node, VReg arrayReg); void LoadArrayElement(const ir::AstNode *node, VReg objectReg); @@ -704,6 +706,7 @@ private: void BinaryDynamicStrictEquality(const ir::AstNode *node, VReg lhs, Label *ifFalse) { ASSERT(GetAccumulatorType()->IsETSDynamicType() && GetVRegType(lhs)->IsETSDynamicType()); + RegScope scope(this); Ra().Emit(node, Signatures::BUILTIN_JSRUNTIME_STRICT_EQUAL, lhs, MoveAccToReg(node)); Ra().Emit(node, ifFalse); } @@ -990,18 +993,18 @@ private: switch (arguments.size()) { case 0U: { - Ra().Emit(node, signature->InternalName(), dummyReg_, dummyReg_); + Ra().Emit(node, signature->InternalName(), dummyReg_, dummyReg_); break; } case 1U: { COMPILE_ARG(0); - Ra().Emit(node, signature->InternalName(), arg0, dummyReg_); + Ra().Emit(node, signature->InternalName(), arg0, dummyReg_); break; } case 2U: { COMPILE_ARG(0); COMPILE_ARG(1); - Ra().Emit(node, signature->InternalName(), arg0, arg1); + Ra().Emit(node, signature->InternalName(), arg0, arg1); break; } case 3U: { @@ -1016,7 +1019,7 @@ private: COMPILE_ARG(1); COMPILE_ARG(2); COMPILE_ARG(3); - Ra().Emit(node, signature->InternalName(), arg0, arg1, arg2, arg3); + Ra().Emit(node, signature->InternalName(), arg0, arg1, arg2, arg3); break; } default: { diff --git a/ets2panda/compiler/lowering/ets/localClassLowering.cpp b/ets2panda/compiler/lowering/ets/localClassLowering.cpp new file mode 100644 index 0000000000..0ddf07117c --- /dev/null +++ b/ets2panda/compiler/lowering/ets/localClassLowering.cpp @@ -0,0 +1,279 @@ +/* + * 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 "localClassLowering.h" +#include "checker/ETSchecker.h" +#include "varbinder/ETSBinder.h" +#include "../util.h" + +namespace ark::es2panda::compiler { + +std::string_view LocalClassConstructionPhase::Name() const +{ + return "LocalClassConstructionPhase"; +} + +void LocalClassConstructionPhase::ReplaceReferencesFromTheParametersToTheLocalVariavbles( + ir::ClassDefinition *classDef, const ArenaMap &newLocalVariablesMap, + const ArenaSet &initializers) +{ + // Replace the parameter variables with the newly created temporal variables and change all the references to + // the new temporal variable + for (auto boxedVarParamsIt = newLocalVariablesMap.begin(); boxedVarParamsIt != newLocalVariablesMap.end(); + ++boxedVarParamsIt) { + auto paramVar = boxedVarParamsIt->first; + auto newVar = boxedVarParamsIt->second; + + classDef->EraseCapturedVariable(paramVar); + classDef->CaptureVariable(newVar); + + auto *scope = paramVar->GetScope(); + scope = scope->AsFunctionParamScope()->GetFunctionScope(); + + auto *block = scope->AsFunctionScope()->Node()->AsScriptFunction()->Body()->AsBlockStatement(); + + block->IterateRecursively([&newLocalVariablesMap, &initializers](ir::AstNode *childNode) { + if (childNode->Type() != ir::AstNodeType::IDENTIFIER || + initializers.find(childNode->AsIdentifier()) != initializers.end()) { + return; + } + const auto &newMapIt = newLocalVariablesMap.find(childNode->AsIdentifier()->Variable()); + if (newMapIt != newLocalVariablesMap.end()) { + LOG(DEBUG, ES2PANDA) << " Remap param variable: " << childNode->AsIdentifier()->Name() + << " (identifier:" << (void *)childNode + << ") variable:" << (void *)childNode->AsIdentifier()->Variable() + << " -> temporal variable:" << (void *)newMapIt->second; + childNode->AsIdentifier()->SetVariable(newMapIt->second); + } + }); + } +} + +void LocalClassConstructionPhase::CreateTemporalLocalVariableForModifiedParameters(public_lib::Context *ctx, + ir::ClassDefinition *classDef) +{ + // Store the new variables created for the function parameters needed to be boxed + ArenaMap newLocalVariablesMap(ctx->allocator->Adapter()); + + // Store the new variables created for the function parameters needed to be boxed + ArenaSet initializers(ctx->allocator->Adapter()); + + // Create local variables for modified parameters since the parameters can not be boxed + for (auto var : classDef->CapturedVariables()) { + if (var->Declaration() != nullptr && var->Declaration()->IsParameterDecl() && + classDef->IsLocalVariableNeeded(var)) { + auto *scope = var->GetScope(); + ASSERT(scope->IsFunctionParamScope()); + scope = scope->AsFunctionParamScope()->GetFunctionScope(); + ASSERT(scope->AsFunctionScope()->Node()->IsScriptFunction()); + ASSERT(scope->AsFunctionScope()->Node()->AsScriptFunction()->Body()->IsBlockStatement()); + auto *param = var->Declaration()->AsParameterDecl(); + auto *block = scope->AsFunctionScope()->Node()->AsScriptFunction()->Body()->AsBlockStatement(); + + auto *newVarIdentifier = Gensym(ctx->allocator); + + auto *newVar = scope->AddDecl( + ctx->allocator, newVarIdentifier->Name(), varbinder::VariableFlags::LOCAL); + + newVarIdentifier->SetVariable(newVar); + newVar->SetTsType(var->TsType()); + newVar->AddFlag(varbinder::VariableFlags::BOXED); + + auto *initializer = ctx->allocator->New(param->Name(), ctx->allocator); + initializer->SetVariable(var); + initializer->SetTsType(var->TsType()); + + initializers.insert(initializer); + auto *declarator = ctx->allocator->New(ir::VariableDeclaratorFlag::LET, + newVarIdentifier, initializer); + + newVarIdentifier->SetParent(declarator); + initializer->SetParent(declarator); + + ArenaVector declarators(ctx->allocator->Adapter()); + declarators.push_back(declarator); + + auto *newVariableDeclaration = ctx->allocator->New( + ir::VariableDeclaration::VariableDeclarationKind::LET, ctx->allocator, std::move(declarators), false); + + declarator->SetParent(newVariableDeclaration); + newVariableDeclaration->SetParent(block); + block->Statements().insert(block->Statements().begin(), newVariableDeclaration); + + newLocalVariablesMap[var] = newVar; + } + } + + ReplaceReferencesFromTheParametersToTheLocalVariavbles(classDef, newLocalVariablesMap, initializers); +} + +void LocalClassConstructionPhase::CreateClassPropertiesForCapturedVariables( + public_lib::Context *ctx, ir::ClassDefinition *classDef, + ArenaMap &variableMap, + ArenaMap &propertyMap) +{ + checker::ETSChecker *const checker = ctx->checker->AsETSChecker(); + size_t idx = 0; + ArenaVector properties(ctx->allocator->Adapter()); + for (auto var : classDef->CapturedVariables()) { + ASSERT(classDef->Scope()->Type() == varbinder::ScopeType::CLASS); + auto *property = checker->CreateLambdaCapturedField( + var, reinterpret_cast(classDef->Scope()), idx, classDef->Start()); + LOG(DEBUG, ES2PANDA) << " - Creating property (" << property->Id()->Name() + << ") for captured variable: " << var->Name(); + properties.push_back(property); + variableMap[var] = property->Id()->Variable(); + propertyMap[var] = property; + idx++; + } + + classDef->AddProperties(std::move(properties)); +} + +void LocalClassConstructionPhase::ModifyConstructorParameters( + public_lib::Context *ctx, ir::ClassDefinition *classDef, + ArenaMap &variableMap, + ArenaMap ¶meterMap) + +{ + auto *classType = classDef->TsType()->AsETSObjectType(); + checker::ETSChecker *const checker = ctx->checker->AsETSChecker(); + + for (auto *signature : classType->ConstructSignatures()) { + LOG(DEBUG, ES2PANDA) << " - Modifying Constructor: " << signature->InternalName(); + auto constructor = signature->Function(); + auto ¶meters = constructor->Params(); + auto &sigParams = signature->Params(); + signature->GetSignatureInfo()->minArgCount += classDef->CapturedVariables().size(); + + ASSERT(signature == constructor->Signature()); + for (auto var : classDef->CapturedVariables()) { + auto *newParam = + checker->AddParam(constructor->Scope()->ParamScope(), var->Name(), checker->MaybeBoxedType(var)); + newParam->SetParent(constructor); + // NOTE(psiket) : Moving the parameter after the 'this'. Should modify the AddParam + // to be able to insert after the this. + auto ¶mScopeParams = constructor->Scope()->ParamScope()->Params(); + auto thisParamIt = ++paramScopeParams.begin(); + paramScopeParams.insert(thisParamIt, paramScopeParams.back()); + paramScopeParams.pop_back(); + + parameters.insert(parameters.begin(), newParam); + ASSERT(newParam->Variable()->Type() == varbinder::VariableType::LOCAL); + sigParams.insert(sigParams.begin(), newParam->Ident()->Variable()->AsLocalVariable()); + parameterMap[var] = newParam->Ident()->Variable()->AsLocalVariable(); + } + reinterpret_cast(checker->VarBinder())->BuildFunctionName(constructor); + LOG(DEBUG, ES2PANDA) << " Transformed Constructor: " << signature->InternalName(); + + auto *body = constructor->Body(); + ArenaVector initStatements(ctx->allocator->Adapter()); + for (auto var : classDef->CapturedVariables()) { + auto *propertyVar = variableMap[var]; + auto *initStatement = checker->CreateLambdaCtorFieldInit(propertyVar->Name(), propertyVar); + auto *fieldInit = initStatement->AsExpressionStatement()->GetExpression()->AsAssignmentExpression(); + auto *ctorParamVar = parameterMap[var]; + auto *fieldVar = variableMap[var]; + auto *leftHandSide = fieldInit->Left(); + leftHandSide->AsMemberExpression()->SetObjectType(classType); + leftHandSide->AsMemberExpression()->SetPropVar(fieldVar->AsLocalVariable()); + leftHandSide->AsMemberExpression()->SetIgnoreBox(); + leftHandSide->AsMemberExpression()->SetTsType(fieldVar->TsType()); + leftHandSide->AsMemberExpression()->Object()->SetTsType(classType); + fieldInit->Right()->AsIdentifier()->SetVariable(ctorParamVar); + fieldInit->Right()->SetTsType(ctorParamVar->TsType()); + initStatement->SetParent(body); + initStatements.push_back(initStatement); + } + auto &statements = body->AsBlockStatement()->Statements(); + statements.insert(statements.begin(), initStatements.begin(), initStatements.end()); + } +} + +void LocalClassConstructionPhase::RemapReferencesFromCapturedVariablesToClassProperties( + ir::ClassDefinition *classDef, ArenaMap &variableMap) +{ + auto *classType = classDef->TsType()->AsETSObjectType(); + auto remapCapturedVariables = [&variableMap](ir::AstNode *childNode) { + if (childNode->Type() == ir::AstNodeType::IDENTIFIER) { + LOG(DEBUG, ES2PANDA) << " checking var:" << (void *)childNode; + const auto &mapIt = variableMap.find(childNode->AsIdentifier()->Variable()); + if (mapIt != variableMap.end()) { + LOG(DEBUG, ES2PANDA) << " Remap: " << childNode->AsIdentifier()->Name() + << " (identifier:" << (void *)childNode + << ") variable:" << (void *)childNode->AsIdentifier()->Variable() + << " -> property variable:" << (void *)mapIt->second; + childNode->AsIdentifier()->SetVariable(mapIt->second); + } else { + } + } + }; + + for (auto *it : classDef->Body()) { + if (it->IsMethodDefinition() && !it->AsMethodDefinition()->IsConstructor()) { + LOG(DEBUG, ES2PANDA) << " - Rebinding variable rerferences in: " + << it->AsMethodDefinition()->Id()->Name().Mutf8().c_str(); + it->AsMethodDefinition()->Function()->Body()->IterateRecursively(remapCapturedVariables); + } + } + // Since the constructor with zero parameter is not listed in the class_def body the constructors + // processed separately + for (auto *signature : classType->ConstructSignatures()) { + auto *constructor = signature->Function(); + LOG(DEBUG, ES2PANDA) << " - Rebinding variable rerferences in: " << constructor->Id()->Name(); + constructor->Body()->IterateRecursively(remapCapturedVariables); + } +} + +bool LocalClassConstructionPhase::Perform(public_lib::Context *ctx, parser::Program * /*program*/) +{ + checker::ETSChecker *const checker = ctx->checker->AsETSChecker(); + for (auto *classDef : checker->GetLocalClasses()) { + LOG(DEBUG, ES2PANDA) << "Altering local class with the captured variables: " << classDef->InternalName(); + // Map the captured variable to the variable of the class property + ArenaMap variableMap(ctx->allocator->Adapter()); + // Map the captured variable to the class property + ArenaMap propertyMap(ctx->allocator->Adapter()); + // Map the captured variable to the constructor parameter + ArenaMap parameterMap(ctx->allocator->Adapter()); + + CreateTemporalLocalVariableForModifiedParameters(ctx, classDef); + CreateClassPropertiesForCapturedVariables(ctx, classDef, variableMap, propertyMap); + ModifyConstructorParameters(ctx, classDef, variableMap, parameterMap); + RemapReferencesFromCapturedVariablesToClassProperties(classDef, variableMap); + } + + // Alter the instantiations + for (auto *newExpr : checker->GetLocalClassInstantiations()) { + checker::Type *calleeType = newExpr->GetTypeRef()->Check(checker); + auto *calleeObj = calleeType->AsETSObjectType(); + auto *classDef = calleeObj->GetDeclNode()->AsClassDefinition(); + LOG(DEBUG, ES2PANDA) << "Instantiating local class: " << classDef->Ident()->Name(); + for (auto *var : classDef->CapturedVariables()) { + LOG(DEBUG, ES2PANDA) << " - Extending constructor argument with captured variable: " << var->Name(); + + auto *param = checker->AllocNode(var->Name(), ctx->allocator); + param->SetVariable(var); + param->SetIgnoreBox(); + param->SetTsType(checker->AsETSChecker()->MaybeBoxedType(param->Variable())); + param->SetParent(newExpr); + newExpr->AddToArgumentsFront(param); + } + } + + return true; +} + +} // namespace ark::es2panda::compiler diff --git a/ets2panda/compiler/lowering/ets/localClassLowering.h b/ets2panda/compiler/lowering/ets/localClassLowering.h new file mode 100644 index 0000000000..297ca7c0ed --- /dev/null +++ b/ets2panda/compiler/lowering/ets/localClassLowering.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ES2PANDA_COMPILER_LOWERING_LOCAL_CLASS_LOWERING_H +#define ES2PANDA_COMPILER_LOWERING_LOCAL_CLASS_LOWERING_H + +#include "compiler/lowering/phase.h" + +namespace ark::es2panda::compiler { + +class LocalClassConstructionPhase : public Phase { +public: + std::string_view Name() const override; + bool Perform(public_lib::Context *ctx, parser::Program *program) override; + +protected: + void ReplaceReferencesFromTheParametersToTheLocalVariavbles( + ir::ClassDefinition *classDef, + const ArenaMap &newLocalVariablesMap, + const ArenaSet &initializers); + + void CreateTemporalLocalVariableForModifiedParameters(public_lib::Context *ctx, ir::ClassDefinition *classDef); + + void CreateClassPropertiesForCapturedVariables(public_lib::Context *ctx, ir::ClassDefinition *classDef, + ArenaMap &variableMap, + ArenaMap &propertyMap); + + void ModifyConstructorParameters(public_lib::Context *ctx, ir::ClassDefinition *classDef, + ArenaMap &variableMap, + ArenaMap ¶meterMap); + + void RemapReferencesFromCapturedVariablesToClassProperties( + ir::ClassDefinition *classDef, ArenaMap &variableMap); +}; + +} // namespace ark::es2panda::compiler + +#endif diff --git a/ets2panda/compiler/lowering/phase.cpp b/ets2panda/compiler/lowering/phase.cpp index e42c608c4d..475224675f 100644 --- a/ets2panda/compiler/lowering/phase.cpp +++ b/ets2panda/compiler/lowering/phase.cpp @@ -25,6 +25,7 @@ #include "compiler/lowering/ets/interfacePropertyDeclarations.h" #include "compiler/lowering/ets/objectIndexAccess.h" #include "compiler/lowering/ets/objectIterator.h" +#include "compiler/lowering/ets/localClassLowering.h" #include "compiler/lowering/ets/opAssignment.h" #include "compiler/lowering/ets/optionalLowering.h" #include "compiler/lowering/ets/promiseVoid.h" @@ -65,6 +66,7 @@ static PromiseVoidInferencePhase g_promiseVoidInferencePhase; static RecordLowering g_recordLowering; static StructLowering g_structLowering; static DefaultParameterLowering g_defaultParameterLowering; +static LocalClassConstructionPhase g_localClassLowering; static PluginPhase g_pluginsAfterParse {"plugins-after-parse", ES2PANDA_STATE_PARSED, &util::Plugin::AfterParse}; static PluginPhase g_pluginsAfterCheck {"plugins-after-check", ES2PANDA_STATE_CHECKED, &util::Plugin::AfterCheck}; static PluginPhase g_pluginsAfterLowerings {"plugins-after-lowering", ES2PANDA_STATE_LOWERED, @@ -98,6 +100,7 @@ std::vector GetETSPhaseList() &g_tupleLowering, &g_unionLowering, &g_expandBracketsPhase, + &g_localClassLowering, &g_pluginsAfterLowerings, }; } diff --git a/ets2panda/ir/base/classDefinition.cpp b/ets2panda/ir/base/classDefinition.cpp index 63a0e697e2..ff13e4cb42 100644 --- a/ets2panda/ir/base/classDefinition.cpp +++ b/ets2panda/ir/base/classDefinition.cpp @@ -214,4 +214,7 @@ checker::Type *ClassDefinition::Check(checker::ETSChecker *checker) { return checker->GetAnalyzer()->Check(this); } + +int ClassDefinition::classCounter_ = 0; + } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/base/classDefinition.h b/ets2panda/ir/base/classDefinition.h index c449678822..14e88c6602 100644 --- a/ets2panda/ir/base/classDefinition.h +++ b/ets2panda/ir/base/classDefinition.h @@ -19,6 +19,7 @@ #include "varbinder/scope.h" #include "varbinder/variable.h" #include "ir/astNode.h" +#include "ir/expressions/identifier.h" #include "util/bitset.h" #include "util/language.h" @@ -44,6 +45,7 @@ enum class ClassDefinitionModifiers : uint32_t { CLASS_DECL = 1U << 8U, INNER = 1U << 9U, FROM_EXTERNAL = 1U << 10U, + LOCAL = 1U << 11U, DECLARATION_ID_REQUIRED = DECLARATION | ID_REQUIRED }; @@ -72,7 +74,11 @@ public: superClass_(superClass), body_(std::move(body)), modifiers_(modifiers), - lang_(lang) + lang_(lang), + capturedVars_(body_.get_allocator()), + localVariableIsNeeded_(body_.get_allocator()), + localIndex_(classCounter_++), + localPrefix_("$" + std::to_string(localIndex_)) { } @@ -83,7 +89,11 @@ public: implements_(allocator->Adapter()), body_(std::move(body)), modifiers_(modifiers), - lang_(lang) + lang_(lang), + capturedVars_(allocator->Adapter()), + localVariableIsNeeded_(allocator->Adapter()), + localIndex_(classCounter_++), + localPrefix_("$" + std::to_string(localIndex_)) { } @@ -94,7 +104,12 @@ public: implements_(allocator->Adapter()), body_(allocator->Adapter()), modifiers_(modifiers), - lang_(lang) + lang_(lang), + capturedVars_(allocator->Adapter()), + localVariableIsNeeded_(allocator->Adapter()), + localIndex_(classCounter_++), + localPrefix_("$" + std::to_string(localIndex_)) + { } @@ -163,6 +178,11 @@ public: return (modifiers_ & ClassDefinitionModifiers::GLOBAL) != 0; } + [[nodiscard]] bool IsLocal() const noexcept + { + return (modifiers_ & ClassDefinitionModifiers::LOCAL) != 0; + } + [[nodiscard]] bool IsExtern() const noexcept { return (modifiers_ & ClassDefinitionModifiers::EXTERN) != 0; @@ -266,6 +286,46 @@ public: return superTypeParams_; } + [[nodiscard]] static int LocalTypeCounter() noexcept + { + return classCounter_; + } + + [[nodiscard]] int LocalIndex() const noexcept + { + return localIndex_; + } + + [[nodiscard]] const std::string &LocalPrefix() const noexcept + { + return localPrefix_; + } + + bool CaptureVariable(varbinder::Variable *var) + { + return capturedVars_.insert(var).second; + } + + bool AddToLocalVariableIsNeeded(varbinder::Variable *var) + { + return localVariableIsNeeded_.insert(var).second; + } + + bool IsLocalVariableNeeded(varbinder::Variable *var) const + { + return localVariableIsNeeded_.find(var) != localVariableIsNeeded_.end(); + } + + [[nodiscard]] const ArenaSet &CapturedVariables() const noexcept + { + return capturedVars_; + } + + bool EraseCapturedVariable(varbinder::Variable *var) + { + return capturedVars_.erase(var) != 0; + } + const FunctionExpression *Ctor() const; bool HasPrivateMethod() const; bool HasComputedInstanceField() const; @@ -301,6 +361,11 @@ private: ArenaVector body_; ClassDefinitionModifiers modifiers_; es2panda::Language lang_; + ArenaSet capturedVars_; + ArenaSet localVariableIsNeeded_; + static int classCounter_; + const int localIndex_ {}; + const std::string localPrefix_ {}; }; } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/ets/etsNewClassInstanceExpression.h b/ets2panda/ir/ets/etsNewClassInstanceExpression.h index 2ce17a38e3..8a61de6288 100644 --- a/ets2panda/ir/ets/etsNewClassInstanceExpression.h +++ b/ets2panda/ir/ets/etsNewClassInstanceExpression.h @@ -85,6 +85,11 @@ public: signature_ = signature; } + void AddToArgumentsFront(ir::Expression *expr) + { + arguments_.insert(arguments_.begin(), expr); + } + [[nodiscard]] ETSNewClassInstanceExpression *Clone(ArenaAllocator *allocator, AstNode *parent) override; void TransformChildren(const NodeTransformer &cb) override; diff --git a/ets2panda/parser/ETSparser.cpp b/ets2panda/parser/ETSparser.cpp index b9dda5ffca..9acf87f03a 100644 --- a/ets2panda/parser/ETSparser.cpp +++ b/ets2panda/parser/ETSparser.cpp @@ -863,6 +863,12 @@ std::tuple ETSParser::ParseClassMemberAccessModifiers() UNREACHABLE(); } } + if (((GetContext().Status() & ParserStatus::FUNCTION) != 0) && + (accessFlag == ir::ModifierFlags::PUBLIC || accessFlag == ir::ModifierFlags::PRIVATE || + accessFlag == ir::ModifierFlags::PROTECTED)) { + ThrowSyntaxError("Local class declaration members can not have access modifies", + Lexer()->GetToken().Start()); + } Lexer()->NextToken(lexer::NextTokenFlags::KEYWORD_TO_IDENT); return {accessFlag, true}; @@ -1663,10 +1669,6 @@ ir::TSInterfaceDeclaration *ETSParser::ParseInterfaceBody(ir::Identifier *name, ir::Statement *ETSParser::ParseInterfaceDeclaration(bool isStatic) { - if ((GetContext().Status() & parser::ParserStatus::FUNCTION) != 0U) { - ThrowSyntaxError("Local interface declaration support is not yet implemented."); - } - lexer::SourcePosition interfaceStart = Lexer()->GetToken().Start(); Lexer()->NextToken(); // eat interface keyword @@ -1765,7 +1767,9 @@ ir::ClassDefinition *ETSParser::ParseClassDefinition(ir::ClassDefinitionModifier static bool IsInterfaceMethodModifier(lexer::TokenType type) { - return type == lexer::TokenType::KEYW_STATIC || type == lexer::TokenType::KEYW_PRIVATE; + // NOTE (psiket) Rewrite this + return type == lexer::TokenType::KEYW_STATIC || type == lexer::TokenType::KEYW_PRIVATE || + type == lexer::TokenType::KEYW_PROTECTED || type == lexer::TokenType::KEYW_PUBLIC; } ir::ModifierFlags ETSParser::ParseInterfaceMethodModifiers() @@ -1775,6 +1779,17 @@ ir::ModifierFlags ETSParser::ParseInterfaceMethodModifiers() while (IsInterfaceMethodModifier(Lexer()->GetToken().Type())) { ir::ModifierFlags currentFlag = ir::ModifierFlags::NONE; + if ((GetContext().Status() & ParserStatus::FUNCTION) != 0) { + if (Lexer()->GetToken().Type() == lexer::TokenType::KEYW_PUBLIC || + Lexer()->GetToken().Type() == lexer::TokenType::KEYW_PROTECTED || + Lexer()->GetToken().Type() == lexer::TokenType::KEYW_PRIVATE) { + ThrowSyntaxError("Local interface declaration members can not have access modifies", + Lexer()->GetToken().Start()); + } + } else if (Lexer()->GetToken().Type() == lexer::TokenType::KEYW_PUBLIC || + Lexer()->GetToken().Type() == lexer::TokenType::KEYW_PROTECTED) { + break; + } switch (Lexer()->GetToken().Type()) { case lexer::TokenType::KEYW_STATIC: { currentFlag = ir::ModifierFlags::STATIC; @@ -4145,7 +4160,9 @@ ir::ClassDeclaration *ETSParser::ParseClassStatement([[maybe_unused]] StatementP [[maybe_unused]] ir::ClassDefinitionModifiers modifiers, [[maybe_unused]] ir::ModifierFlags modFlags) { - ThrowSyntaxError("Illegal start of expression", Lexer()->GetToken().Start()); + return ParseClassDeclaration(modifiers | ir::ClassDefinitionModifiers::ID_REQUIRED | + ir::ClassDefinitionModifiers::CLASS_DECL | ir::ClassDefinitionModifiers::LOCAL, + modFlags); } // NOLINTNEXTLINE(google-default-arguments) diff --git a/ets2panda/parser/statementParser.cpp b/ets2panda/parser/statementParser.cpp index 99e669f255..5c94e99926 100644 --- a/ets2panda/parser/statementParser.cpp +++ b/ets2panda/parser/statementParser.cpp @@ -619,6 +619,18 @@ ir::Statement *ParserImpl::ParseExpressionStatement(StatementParsingFlags flags) const auto startPos = lexer_->Save(); ParserStatus savedStatus = context_.Status(); + auto tokenType = lexer_->GetToken().Type(); + if (tokenType == lexer::TokenType::KEYW_PUBLIC || tokenType == lexer::TokenType::KEYW_PRIVATE || + tokenType == lexer::TokenType::KEYW_PROTECTED) { + lexer_->NextToken(); + if (lexer_->GetToken().Type() == lexer::TokenType::KEYW_CLASS || + lexer_->GetToken().Type() == lexer::TokenType::KEYW_INTERFACE) { + ThrowSyntaxError("A local class or interface declaration can not have access modifier", + startPos.GetToken().Start()); + } + lexer_->Rewind(startPos); + } + if (lexer_->GetToken().IsAsyncModifier()) { lexer_->NextToken(); diff --git a/ets2panda/test/compiler/ets/identifierReference1-expected.txt b/ets2panda/test/compiler/ets/identifierReference1-expected.txt index 5a98acf91b..df7fd437f9 100644 --- a/ets2panda/test/compiler/ets/identifierReference1-expected.txt +++ b/ets2panda/test/compiler/ets/identifierReference1-expected.txt @@ -1,1966 +1 @@ -{ - "type": "Program", - "statements": [ - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "B", - "decorators": [], - "loc": { - "start": { - "line": 9, - "column": 12 - }, - "end": { - "line": 9, - "column": 13 - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "b", - "decorators": [], - "loc": { - "start": { - "line": 10, - "column": 3 - }, - "end": { - "line": 10, - "column": 4 - } - } - }, - "value": { - "type": "NumberLiteral", - "value": 2, - "loc": { - "start": { - "line": 10, - "column": 12 - }, - "end": { - "line": 10, - "column": 13 - } - } - }, - "accessibility": "public", - "static": false, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 10, - "column": 6 - }, - "end": { - "line": 10, - "column": 9 - } - } - }, - "definite": false, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "c", - "decorators": [], - "loc": { - "start": { - "line": 11, - "column": 10 - }, - "end": { - "line": 11, - "column": 11 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "ETSFunctionType", - "params": [ - { - "type": "Identifier", - "name": "a", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 11, - "column": 17 - }, - "end": { - "line": 11, - "column": 20 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 11, - "column": 14 - }, - "end": { - "line": 11, - "column": 20 - } - } - } - ], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 11, - "column": 25 - }, - "end": { - "line": 11, - "column": 29 - } - } - }, - "loc": { - "start": { - "line": 11, - "column": 13 - }, - "end": { - "line": 11, - "column": 29 - } - } - }, - "definite": false, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "foo", - "decorators": [], - "loc": { - "start": { - "line": 12, - "column": 3 - }, - "end": { - "line": 12, - "column": 6 - } - } - }, - "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": 12, - "column": 3 - }, - "end": { - "line": 12, - "column": 6 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "Identifier", - "name": "a", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 12, - "column": 10 - }, - "end": { - "line": 12, - "column": 13 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 12, - "column": 7 - }, - "end": { - "line": 12, - "column": 13 - } - } - } - ], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 12, - "column": 16 - }, - "end": { - "line": 12, - "column": 20 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [], - "loc": { - "start": { - "line": 12, - "column": 21 - }, - "end": { - "line": 14, - "column": 4 - } - } - }, - "loc": { - "start": { - "line": 12, - "column": 6 - }, - "end": { - "line": 14, - "column": 4 - } - } - }, - "loc": { - "start": { - "line": 12, - "column": 6 - }, - "end": { - "line": 14, - "column": 4 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 12, - "column": 3 - }, - "end": { - "line": 14, - "column": 4 - } - } - }, - { - "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": 15, - "column": 2 - }, - "end": { - "line": 15, - "column": 2 - } - } - } - ], - "loc": { - "start": { - "line": 9, - "column": 14 - }, - "end": { - "line": 15, - "column": 2 - } - } - }, - "loc": { - "start": { - "line": 9, - "column": 6 - }, - "end": { - "line": 15, - "column": 2 - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 17, - "column": 7 - }, - "end": { - "line": 17, - "column": 8 - } - } - }, - "superClass": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "B", - "decorators": [], - "loc": { - "start": { - "line": 17, - "column": 17 - }, - "end": { - "line": 17, - "column": 18 - } - } - }, - "loc": { - "start": { - "line": 17, - "column": 17 - }, - "end": { - "line": 17, - "column": 20 - } - } - }, - "loc": { - "start": { - "line": 17, - "column": 17 - }, - "end": { - "line": 17, - "column": 20 - } - } - }, - "implements": [], - "body": [ - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "foo", - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 3 - }, - "end": { - "line": 18, - "column": 6 - } - } - }, - "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": 3 - }, - "end": { - "line": 18, - "column": 6 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "Identifier", - "name": "a", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 18, - "column": 10 - }, - "end": { - "line": 18, - "column": 13 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 7 - }, - "end": { - "line": 18, - "column": 13 - } - } - }, - { - "type": "Identifier", - "name": "b", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 18, - "column": 18 - }, - "end": { - "line": 18, - "column": 21 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 15 - }, - "end": { - "line": 18, - "column": 21 - } - } - } - ], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 18, - "column": 24 - }, - "end": { - "line": 18, - "column": 28 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "b", - "decorators": [], - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 6 - } - } - }, - "right": { - "type": "NumberLiteral", - "value": 3, - "loc": { - "start": { - "line": 19, - "column": 9 - }, - "end": { - "line": 19, - "column": 10 - } - } - }, - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 10 - } - } - }, - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 11 - } - } - } - ], - "loc": { - "start": { - "line": 18, - "column": 29 - }, - "end": { - "line": 20, - "column": 4 - } - } - }, - "loc": { - "start": { - "line": 18, - "column": 6 - }, - "end": { - "line": 20, - "column": 4 - } - } - }, - "loc": { - "start": { - "line": 18, - "column": 6 - }, - "end": { - "line": 20, - "column": 4 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 3 - }, - "end": { - "line": 20, - "column": 4 - } - } - }, - { - "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": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 23, - "column": 5 - }, - "end": { - "line": 23, - "column": 6 - } - } - }, - "property": { - "type": "Identifier", - "name": "c", - "decorators": [], - "loc": { - "start": { - "line": 23, - "column": 7 - }, - "end": { - "line": 23, - "column": 8 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 23, - "column": 5 - }, - "end": { - "line": 23, - "column": 8 - } - } - }, - "right": { - "type": "Identifier", - "name": "bar", - "decorators": [], - "loc": { - "start": { - "line": 23, - "column": 11 - }, - "end": { - "line": 23, - "column": 14 - } - } - }, - "loc": { - "start": { - "line": 23, - "column": 5 - }, - "end": { - "line": 23, - "column": 14 - } - } - }, - "loc": { - "start": { - "line": 23, - "column": 5 - }, - "end": { - "line": 23, - "column": 15 - } - } - } - ], - "loc": { - "start": { - "line": 22, - "column": 22 - }, - "end": { - "line": 24, - "column": 4 - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 13 - }, - "end": { - "line": 24, - "column": 4 - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 13 - }, - "end": { - "line": 24, - "column": 4 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 3 - }, - "end": { - "line": 24, - "column": 4 - } - } - }, - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "baz", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 3 - }, - "end": { - "line": 26, - "column": 6 - } - } - }, - "kind": "method", - "accessibility": "public", - "static": false, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "baz", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 3 - }, - "end": { - "line": 26, - "column": 6 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 26, - "column": 10 - }, - "end": { - "line": 26, - "column": 14 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "ThisExpression", - "loc": { - "start": { - "line": 27, - "column": 5 - }, - "end": { - "line": 27, - "column": 9 - } - } - }, - "property": { - "type": "Identifier", - "name": "foo", - "decorators": [], - "loc": { - "start": { - "line": 27, - "column": 10 - }, - "end": { - "line": 27, - "column": 13 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 27, - "column": 5 - }, - "end": { - "line": 27, - "column": 13 - } - } - }, - "arguments": [ - { - "type": "NumberLiteral", - "value": 1, - "loc": { - "start": { - "line": 27, - "column": 14 - }, - "end": { - "line": 27, - "column": 15 - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 27, - "column": 5 - }, - "end": { - "line": 27, - "column": 16 - } - } - }, - "loc": { - "start": { - "line": 27, - "column": 5 - }, - "end": { - "line": 27, - "column": 17 - } - } - } - ], - "loc": { - "start": { - "line": 26, - "column": 15 - }, - "end": { - "line": 28, - "column": 4 - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 6 - }, - "end": { - "line": 28, - "column": 4 - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 6 - }, - "end": { - "line": 28, - "column": 4 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 3 - }, - "end": { - "line": 28, - "column": 4 - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "C", - "decorators": [], - "loc": { - "start": { - "line": 30, - "column": 9 - }, - "end": { - "line": 30, - "column": 10 - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "foo", - "decorators": [], - "loc": { - "start": { - "line": 31, - "column": 5 - }, - "end": { - "line": 31, - "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": 31, - "column": 5 - }, - "end": { - "line": 31, - "column": 8 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 31, - "column": 12 - }, - "end": { - "line": 31, - "column": 16 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "MemberExpression", - "object": { - "type": "ThisExpression", - "loc": { - "start": { - "line": 32, - "column": 7 - }, - "end": { - "line": 32, - "column": 11 - } - } - }, - "property": { - "type": "Identifier", - "name": "b", - "decorators": [], - "loc": { - "start": { - "line": 32, - "column": 12 - }, - "end": { - "line": 32, - "column": 13 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 32, - "column": 7 - }, - "end": { - "line": 32, - "column": 13 - } - } - }, - "right": { - "type": "NumberLiteral", - "value": 4, - "loc": { - "start": { - "line": 32, - "column": 16 - }, - "end": { - "line": 32, - "column": 17 - } - } - }, - "loc": { - "start": { - "line": 32, - "column": 7 - }, - "end": { - "line": 32, - "column": 17 - } - } - }, - "loc": { - "start": { - "line": 32, - "column": 7 - }, - "end": { - "line": 32, - "column": 18 - } - } - } - ], - "loc": { - "start": { - "line": 31, - "column": 17 - }, - "end": { - "line": 33, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 31, - "column": 8 - }, - "end": { - "line": 33, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 31, - "column": 8 - }, - "end": { - "line": 33, - "column": 6 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 31, - "column": 5 - }, - "end": { - "line": 33, - "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": 34, - "column": 4 - }, - "end": { - "line": 34, - "column": 4 - } - } - } - ], - "loc": { - "start": { - "line": 30, - "column": 11 - }, - "end": { - "line": 34, - "column": 4 - } - } - }, - "loc": { - "start": { - "line": 30, - "column": 3 - }, - "end": { - "line": 34, - "column": 4 - } - } - }, - { - "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": 35, - "column": 2 - }, - "end": { - "line": 35, - "column": 2 - } - } - } - ], - "loc": { - "start": { - "line": 17, - "column": 19 - }, - "end": { - "line": 35, - "column": 2 - } - } - }, - "loc": { - "start": { - "line": 17, - "column": 1 - }, - "end": { - "line": 35, - "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": "ClassProperty", - "key": { - "type": "Identifier", - "name": "a", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 5 - }, - "end": { - "line": 1, - "column": 6 - } - } - }, - "value": { - "type": "Identifier", - "name": "max", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 33 - }, - "end": { - "line": 1, - "column": 36 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "ETSFunctionType", - "params": [ - { - "type": "Identifier", - "name": "a", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 1, - "column": 11 - }, - "end": { - "line": 1, - "column": 14 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 8 - }, - "end": { - "line": 1, - "column": 14 - } - } - }, - { - "type": "Identifier", - "name": "b", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 1, - "column": 19 - }, - "end": { - "line": 1, - "column": 22 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 16 - }, - "end": { - "line": 1, - "column": 22 - } - } - } - ], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 1, - "column": 27 - }, - "end": { - "line": 1, - "column": 30 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 7 - }, - "end": { - "line": 1, - "column": 30 - } - } - }, - "definite": false, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "b", - "decorators": [], - "loc": { - "start": { - "line": 3, - "column": 5 - }, - "end": { - "line": 3, - "column": 6 - } - } - }, - "value": { - "type": "StringLiteral", - "value": "foo", - "loc": { - "start": { - "line": 3, - "column": 17 - }, - "end": { - "line": 3, - "column": 22 - } - } - }, - "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": 3, - "column": 8 - }, - "end": { - "line": 3, - "column": 14 - } - } - }, - "loc": { - "start": { - "line": 3, - "column": 8 - }, - "end": { - "line": 3, - "column": 16 - } - } - }, - "loc": { - "start": { - "line": 3, - "column": 8 - }, - "end": { - "line": 3, - "column": 16 - } - } - }, - "definite": false, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "bar", - "decorators": [], - "loc": { - "start": { - "line": 5, - "column": 10 - }, - "end": { - "line": 5, - "column": 13 - } - } - }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "bar", - "decorators": [], - "loc": { - "start": { - "line": 5, - "column": 10 - }, - "end": { - "line": 5, - "column": 13 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "Identifier", - "name": "a", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 5, - "column": 18 - }, - "end": { - "line": 5, - "column": 21 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 5, - "column": 15 - }, - "end": { - "line": 5, - "column": 21 - } - } - } - ], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 5, - "column": 24 - }, - "end": { - "line": 5, - "column": 28 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [], - "loc": { - "start": { - "line": 5, - "column": 29 - }, - "end": { - "line": 7, - "column": 2 - } - } - }, - "loc": { - "start": { - "line": 5, - "column": 14 - }, - "end": { - "line": 7, - "column": 2 - } - } - }, - "loc": { - "start": { - "line": 5, - "column": 14 - }, - "end": { - "line": 7, - "column": 2 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 5, - "column": 1 - }, - "end": { - "line": 7, - "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": 36, - "column": 1 - } - } -} -TypeError: Property 'b' does not exist on type 'C' [identifierReference1.ets:32:12] +SyntaxError: Local type declaration (class, struct, interface and enum) support is not yet implemented. [identifierReference1.ets:45:3] diff --git a/ets2panda/test/compiler/ets/identifierReference15-expected.txt b/ets2panda/test/compiler/ets/identifierReference15-expected.txt index 888dd8d8b5..f90eb8dfdd 100644 --- a/ets2panda/test/compiler/ets/identifierReference15-expected.txt +++ b/ets2panda/test/compiler/ets/identifierReference15-expected.txt @@ -1,892 +1 @@ -{ - "type": "Program", - "statements": [ - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 7 - }, - "end": { - "line": 1, - "column": 8 - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "foo", - "decorators": [], - "loc": { - "start": { - "line": 2, - "column": 3 - }, - "end": { - "line": 2, - "column": 6 - } - } - }, - "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": 2, - "column": 3 - }, - "end": { - "line": 2, - "column": 6 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "Identifier", - "name": "a", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 2, - "column": 10 - }, - "end": { - "line": 2, - "column": 13 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 2, - "column": 7 - }, - "end": { - "line": 2, - "column": 13 - } - } - } - ], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 2, - "column": 16 - }, - "end": { - "line": 2, - "column": 20 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [], - "loc": { - "start": { - "line": 2, - "column": 21 - }, - "end": { - "line": 4, - "column": 4 - } - } - }, - "loc": { - "start": { - "line": 2, - "column": 6 - }, - "end": { - "line": 4, - "column": 4 - } - } - }, - "loc": { - "start": { - "line": 2, - "column": 6 - }, - "end": { - "line": 4, - "column": 4 - } - } - }, - "overloads": [ - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "foo", - "decorators": [], - "loc": { - "start": { - "line": 6, - "column": 3 - }, - "end": { - "line": 6, - "column": 6 - } - } - }, - "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": 6, - "column": 3 - }, - "end": { - "line": 6, - "column": 6 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 6, - "column": 10 - }, - "end": { - "line": 6, - "column": 14 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [], - "loc": { - "start": { - "line": 6, - "column": 15 - }, - "end": { - "line": 8, - "column": 4 - } - } - }, - "loc": { - "start": { - "line": 6, - "column": 6 - }, - "end": { - "line": 8, - "column": 4 - } - } - }, - "loc": { - "start": { - "line": 6, - "column": 6 - }, - "end": { - "line": 8, - "column": 4 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 6, - "column": 3 - }, - "end": { - "line": 8, - "column": 4 - } - } - } - ], - "decorators": [], - "loc": { - "start": { - "line": 2, - "column": 3 - }, - "end": { - "line": 4, - "column": 4 - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "B", - "decorators": [], - "loc": { - "start": { - "line": 10, - "column": 9 - }, - "end": { - "line": 10, - "column": 10 - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "foo", - "decorators": [], - "loc": { - "start": { - "line": 11, - "column": 5 - }, - "end": { - "line": 11, - "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": 11, - "column": 5 - }, - "end": { - "line": 11, - "column": 8 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "Identifier", - "name": "a", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 11, - "column": 12 - }, - "end": { - "line": 11, - "column": 15 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 11, - "column": 9 - }, - "end": { - "line": 11, - "column": 15 - } - } - } - ], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 11, - "column": 18 - }, - "end": { - "line": 11, - "column": 22 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [], - "loc": { - "start": { - "line": 11, - "column": 23 - }, - "end": { - "line": 13, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 11, - "column": 8 - }, - "end": { - "line": 13, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 11, - "column": 8 - }, - "end": { - "line": 13, - "column": 6 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 11, - "column": 5 - }, - "end": { - "line": 13, - "column": 6 - } - } - }, - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "baz", - "decorators": [], - "loc": { - "start": { - "line": 15, - "column": 5 - }, - "end": { - "line": 15, - "column": 8 - } - } - }, - "kind": "method", - "accessibility": "public", - "static": false, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "baz", - "decorators": [], - "loc": { - "start": { - "line": 15, - "column": 5 - }, - "end": { - "line": 15, - "column": 8 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 15, - "column": 12 - }, - "end": { - "line": 15, - "column": 16 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "ThisExpression", - "loc": { - "start": { - "line": 16, - "column": 7 - }, - "end": { - "line": 16, - "column": 11 - } - } - }, - "property": { - "type": "Identifier", - "name": "foo", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 12 - }, - "end": { - "line": 16, - "column": 15 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 16, - "column": 7 - }, - "end": { - "line": 16, - "column": 15 - } - } - }, - "arguments": [], - "optional": false, - "loc": { - "start": { - "line": 16, - "column": 7 - }, - "end": { - "line": 16, - "column": 17 - } - } - }, - "loc": { - "start": { - "line": 16, - "column": 7 - }, - "end": { - "line": 16, - "column": 18 - } - } - } - ], - "loc": { - "start": { - "line": 15, - "column": 17 - }, - "end": { - "line": 17, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 15, - "column": 8 - }, - "end": { - "line": 17, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 15, - "column": 8 - }, - "end": { - "line": 17, - "column": 6 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 15, - "column": 5 - }, - "end": { - "line": 17, - "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": 18, - "column": 4 - }, - "end": { - "line": 18, - "column": 4 - } - } - } - ], - "loc": { - "start": { - "line": 10, - "column": 11 - }, - "end": { - "line": 18, - "column": 4 - } - } - }, - "loc": { - "start": { - "line": 10, - "column": 3 - }, - "end": { - "line": 18, - "column": 4 - } - } - }, - { - "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": 1, - "column": 9 - }, - "end": { - "line": 19, - "column": 2 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 19, - "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 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 20, - "column": 1 - } - } -} -TypeError: No matching call signature [identifierReference15.ets:16:7] +SyntaxError: Local type declaration (class, struct, interface and enum) support is not yet implemented. [identifierReference15.ets:25:3] diff --git a/ets2panda/test/compiler/ets/identifierReference16-expected.txt b/ets2panda/test/compiler/ets/identifierReference16-expected.txt index a94ef69ecf..292343f60c 100644 --- a/ets2panda/test/compiler/ets/identifierReference16-expected.txt +++ b/ets2panda/test/compiler/ets/identifierReference16-expected.txt @@ -1,1396 +1 @@ -{ - "type": "Program", - "statements": [ - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "B", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 12 - }, - "end": { - "line": 1, - "column": 13 - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "foo", - "decorators": [], - "loc": { - "start": { - "line": 2, - "column": 3 - }, - "end": { - "line": 2, - "column": 6 - } - } - }, - "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": 2, - "column": 3 - }, - "end": { - "line": 2, - "column": 6 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "Identifier", - "name": "a", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 2, - "column": 10 - }, - "end": { - "line": 2, - "column": 13 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 2, - "column": 7 - }, - "end": { - "line": 2, - "column": 13 - } - } - } - ], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 2, - "column": 16 - }, - "end": { - "line": 2, - "column": 20 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [], - "loc": { - "start": { - "line": 2, - "column": 21 - }, - "end": { - "line": 4, - "column": 4 - } - } - }, - "loc": { - "start": { - "line": 2, - "column": 6 - }, - "end": { - "line": 4, - "column": 4 - } - } - }, - "loc": { - "start": { - "line": 2, - "column": 6 - }, - "end": { - "line": 4, - "column": 4 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 2, - "column": 3 - }, - "end": { - "line": 4, - "column": 4 - } - } - }, - { - "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": 5, - "column": 2 - }, - "end": { - "line": 5, - "column": 2 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 14 - }, - "end": { - "line": 5, - "column": 2 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 6 - }, - "end": { - "line": 5, - "column": 2 - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "C", - "decorators": [], - "loc": { - "start": { - "line": 7, - "column": 12 - }, - "end": { - "line": 7, - "column": 13 - } - } - }, - "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": 9, - "column": 2 - }, - "end": { - "line": 9, - "column": 2 - } - } - } - ], - "loc": { - "start": { - "line": 7, - "column": 14 - }, - "end": { - "line": 9, - "column": 2 - } - } - }, - "loc": { - "start": { - "line": 7, - "column": 6 - }, - "end": { - "line": 9, - "column": 2 - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 11, - "column": 7 - }, - "end": { - "line": 11, - "column": 8 - } - } - }, - "superClass": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "B", - "decorators": [], - "loc": { - "start": { - "line": 11, - "column": 17 - }, - "end": { - "line": 11, - "column": 18 - } - } - }, - "loc": { - "start": { - "line": 11, - "column": 17 - }, - "end": { - "line": 11, - "column": 20 - } - } - }, - "loc": { - "start": { - "line": 11, - "column": 17 - }, - "end": { - "line": 11, - "column": 20 - } - } - }, - "implements": [], - "body": [ - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "foo", - "decorators": [], - "loc": { - "start": { - "line": 12, - "column": 3 - }, - "end": { - "line": 12, - "column": 6 - } - } - }, - "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": 12, - "column": 3 - }, - "end": { - "line": 12, - "column": 6 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "Identifier", - "name": "a", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 12, - "column": 10 - }, - "end": { - "line": 12, - "column": 13 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 12, - "column": 7 - }, - "end": { - "line": 12, - "column": 13 - } - } - }, - { - "type": "Identifier", - "name": "b", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 12, - "column": 18 - }, - "end": { - "line": 12, - "column": 21 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 12, - "column": 15 - }, - "end": { - "line": 12, - "column": 21 - } - } - } - ], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 12, - "column": 24 - }, - "end": { - "line": 12, - "column": 28 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [], - "loc": { - "start": { - "line": 12, - "column": 29 - }, - "end": { - "line": 14, - "column": 4 - } - } - }, - "loc": { - "start": { - "line": 12, - "column": 6 - }, - "end": { - "line": 14, - "column": 4 - } - } - }, - "loc": { - "start": { - "line": 12, - "column": 6 - }, - "end": { - "line": 14, - "column": 4 - } - } - }, - "overloads": [ - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "foo", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 3 - }, - "end": { - "line": 16, - "column": 6 - } - } - }, - "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": 16, - "column": 3 - }, - "end": { - "line": 16, - "column": 6 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 16, - "column": 10 - }, - "end": { - "line": 16, - "column": 14 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [], - "loc": { - "start": { - "line": 16, - "column": 15 - }, - "end": { - "line": 18, - "column": 4 - } - } - }, - "loc": { - "start": { - "line": 16, - "column": 6 - }, - "end": { - "line": 18, - "column": 4 - } - } - }, - "loc": { - "start": { - "line": 16, - "column": 6 - }, - "end": { - "line": 18, - "column": 4 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 3 - }, - "end": { - "line": 18, - "column": 4 - } - } - } - ], - "decorators": [], - "loc": { - "start": { - "line": 12, - "column": 3 - }, - "end": { - "line": 14, - "column": 4 - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "D", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 9 - }, - "end": { - "line": 20, - "column": 10 - } - } - }, - "superClass": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "C", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 19 - }, - "end": { - "line": 20, - "column": 20 - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 19 - }, - "end": { - "line": 20, - "column": 22 - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 19 - }, - "end": { - "line": 20, - "column": 22 - } - } - }, - "implements": [], - "body": [ - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "foo", - "decorators": [], - "loc": { - "start": { - "line": 21, - "column": 5 - }, - "end": { - "line": 21, - "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": 21, - "column": 5 - }, - "end": { - "line": 21, - "column": 8 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 21, - "column": 12 - }, - "end": { - "line": 21, - "column": 16 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [], - "loc": { - "start": { - "line": 21, - "column": 17 - }, - "end": { - "line": 23, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 21, - "column": 8 - }, - "end": { - "line": 23, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 21, - "column": 8 - }, - "end": { - "line": 23, - "column": 6 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 21, - "column": 5 - }, - "end": { - "line": 23, - "column": 6 - } - } - }, - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "baz", - "decorators": [], - "loc": { - "start": { - "line": 25, - "column": 5 - }, - "end": { - "line": 25, - "column": 8 - } - } - }, - "kind": "method", - "accessibility": "public", - "static": false, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "baz", - "decorators": [], - "loc": { - "start": { - "line": 25, - "column": 5 - }, - "end": { - "line": 25, - "column": 8 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 25, - "column": 12 - }, - "end": { - "line": 25, - "column": 16 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "ThisExpression", - "loc": { - "start": { - "line": 26, - "column": 7 - }, - "end": { - "line": 26, - "column": 11 - } - } - }, - "property": { - "type": "Identifier", - "name": "foo", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 12 - }, - "end": { - "line": 26, - "column": 15 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 26, - "column": 7 - }, - "end": { - "line": 26, - "column": 15 - } - } - }, - "arguments": [ - { - "type": "NumberLiteral", - "value": 1, - "loc": { - "start": { - "line": 26, - "column": 16 - }, - "end": { - "line": 26, - "column": 17 - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 26, - "column": 7 - }, - "end": { - "line": 26, - "column": 18 - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 7 - }, - "end": { - "line": 26, - "column": 19 - } - } - } - ], - "loc": { - "start": { - "line": 25, - "column": 17 - }, - "end": { - "line": 27, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 25, - "column": 8 - }, - "end": { - "line": 27, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 25, - "column": 8 - }, - "end": { - "line": 27, - "column": 6 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 25, - "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, - "column": 1 - }, - "end": { - "line": 1, - "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": 28, - "column": 4 - }, - "end": { - "line": 28, - "column": 4 - } - } - } - ], - "loc": { - "start": { - "line": 20, - "column": 21 - }, - "end": { - "line": 28, - "column": 4 - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 3 - }, - "end": { - "line": 28, - "column": 4 - } - } - }, - { - "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": 29, - "column": 2 - }, - "end": { - "line": 29, - "column": 2 - } - } - } - ], - "loc": { - "start": { - "line": 11, - "column": 19 - }, - "end": { - "line": 29, - "column": 2 - } - } - }, - "loc": { - "start": { - "line": 11, - "column": 1 - }, - "end": { - "line": 29, - "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 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 30, - "column": 1 - } - } -} -TypeError: No matching call signature [identifierReference16.ets:26:7] +SyntaxError: Local type declaration (class, struct, interface and enum) support is not yet implemented. [identifierReference16.ets:35:3] diff --git a/ets2panda/test/compiler/ets/identifierReference6-expected.txt b/ets2panda/test/compiler/ets/identifierReference6-expected.txt index f2cea78672..f1e23a8849 100644 --- a/ets2panda/test/compiler/ets/identifierReference6-expected.txt +++ b/ets2panda/test/compiler/ets/identifierReference6-expected.txt @@ -1,575 +1 @@ -{ - "type": "Program", - "statements": [ - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 2, - "column": 7 - }, - "end": { - "line": 2, - "column": 8 - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "a", - "decorators": [], - "loc": { - "start": { - "line": 3, - "column": 3 - }, - "end": { - "line": 3, - "column": 4 - } - } - }, - "value": { - "type": "NumberLiteral", - "value": 2, - "loc": { - "start": { - "line": 3, - "column": 12 - }, - "end": { - "line": 3, - "column": 13 - } - } - }, - "accessibility": "public", - "static": false, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 3, - "column": 6 - }, - "end": { - "line": 3, - "column": 9 - } - } - }, - "definite": false, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "B", - "decorators": [], - "loc": { - "start": { - "line": 5, - "column": 16 - }, - "end": { - "line": 5, - "column": 17 - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "foo", - "decorators": [], - "loc": { - "start": { - "line": 6, - "column": 5 - }, - "end": { - "line": 6, - "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": 6, - "column": 5 - }, - "end": { - "line": 6, - "column": 8 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 6, - "column": 12 - }, - "end": { - "line": 6, - "column": 16 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "UpdateExpression", - "operator": "++", - "prefix": false, - "argument": { - "type": "MemberExpression", - "object": { - "type": "ThisExpression", - "loc": { - "start": { - "line": 7, - "column": 7 - }, - "end": { - "line": 7, - "column": 11 - } - } - }, - "property": { - "type": "Identifier", - "name": "a", - "decorators": [], - "loc": { - "start": { - "line": 7, - "column": 12 - }, - "end": { - "line": 7, - "column": 13 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 7, - "column": 7 - }, - "end": { - "line": 7, - "column": 13 - } - } - }, - "loc": { - "start": { - "line": 7, - "column": 7 - }, - "end": { - "line": 7, - "column": 15 - } - } - }, - "loc": { - "start": { - "line": 7, - "column": 7 - }, - "end": { - "line": 7, - "column": 16 - } - } - } - ], - "loc": { - "start": { - "line": 6, - "column": 17 - }, - "end": { - "line": 8, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 6, - "column": 8 - }, - "end": { - "line": 8, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 6, - "column": 8 - }, - "end": { - "line": 8, - "column": 6 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 6, - "column": 5 - }, - "end": { - "line": 8, - "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": 9, - "column": 4 - }, - "end": { - "line": 9, - "column": 4 - } - } - } - ], - "loc": { - "start": { - "line": 5, - "column": 18 - }, - "end": { - "line": 9, - "column": 4 - } - } - }, - "loc": { - "start": { - "line": 5, - "column": 10 - }, - "end": { - "line": 9, - "column": 4 - } - } - }, - { - "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": 10, - "column": 2 - }, - "end": { - "line": 10, - "column": 2 - } - } - } - ], - "loc": { - "start": { - "line": 2, - "column": 9 - }, - "end": { - "line": 10, - "column": 2 - } - } - }, - "loc": { - "start": { - "line": 2, - "column": 1 - }, - "end": { - "line": 10, - "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 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 11, - "column": 1 - } - } -} -TypeError: 'this' cannot be referenced from a static context [identifierReference6.ets:7:7] +SyntaxError: Local type declaration (class, struct, interface and enum) support is not yet implemented. [identifierReference6.ets:19:10] diff --git a/ets2panda/test/compiler/ets/identifierReference7-expected.txt b/ets2panda/test/compiler/ets/identifierReference7-expected.txt index 5ff90818b1..c1c52eb11f 100644 --- a/ets2panda/test/compiler/ets/identifierReference7-expected.txt +++ b/ets2panda/test/compiler/ets/identifierReference7-expected.txt @@ -1,829 +1 @@ -{ - "type": "Program", - "statements": [ - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "C", - "decorators": [], - "loc": { - "start": { - "line": 2, - "column": 12 - }, - "end": { - "line": 2, - "column": 13 - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "a", - "decorators": [], - "loc": { - "start": { - "line": 3, - "column": 3 - }, - "end": { - "line": 3, - "column": 4 - } - } - }, - "accessibility": "public", - "static": false, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Object", - "decorators": [], - "loc": { - "start": { - "line": 3, - "column": 6 - }, - "end": { - "line": 3, - "column": 12 - } - } - }, - "loc": { - "start": { - "line": 3, - "column": 6 - }, - "end": { - "line": 3, - "column": 13 - } - } - }, - "loc": { - "start": { - "line": 3, - "column": 6 - }, - "end": { - "line": 3, - "column": 13 - } - } - }, - "definite": false, - "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", - "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": 4, - "column": 2 - }, - "end": { - "line": 4, - "column": 2 - } - } - } - ], - "loc": { - "start": { - "line": 2, - "column": 14 - }, - "end": { - "line": 4, - "column": 2 - } - } - }, - "loc": { - "start": { - "line": 2, - "column": 6 - }, - "end": { - "line": 4, - "column": 2 - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 6, - "column": 7 - }, - "end": { - "line": 6, - "column": 8 - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "a", - "decorators": [], - "loc": { - "start": { - "line": 7, - "column": 3 - }, - "end": { - "line": 7, - "column": 4 - } - } - }, - "value": { - "type": "NumberLiteral", - "value": 2, - "loc": { - "start": { - "line": 7, - "column": 12 - }, - "end": { - "line": 7, - "column": 13 - } - } - }, - "accessibility": "public", - "static": false, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 7, - "column": 6 - }, - "end": { - "line": 7, - "column": 9 - } - } - }, - "definite": false, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "B", - "decorators": [], - "loc": { - "start": { - "line": 9, - "column": 9 - }, - "end": { - "line": 9, - "column": 10 - } - } - }, - "superClass": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "C", - "decorators": [], - "loc": { - "start": { - "line": 9, - "column": 19 - }, - "end": { - "line": 9, - "column": 20 - } - } - }, - "loc": { - "start": { - "line": 9, - "column": 19 - }, - "end": { - "line": 9, - "column": 22 - } - } - }, - "loc": { - "start": { - "line": 9, - "column": 19 - }, - "end": { - "line": 9, - "column": 22 - } - } - }, - "implements": [], - "body": [ - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "foo", - "decorators": [], - "loc": { - "start": { - "line": 10, - "column": 5 - }, - "end": { - "line": 10, - "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": 10, - "column": 5 - }, - "end": { - "line": 10, - "column": 8 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 10, - "column": 12 - }, - "end": { - "line": 10, - "column": 16 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "UpdateExpression", - "operator": "++", - "prefix": false, - "argument": { - "type": "MemberExpression", - "object": { - "type": "ThisExpression", - "loc": { - "start": { - "line": 11, - "column": 7 - }, - "end": { - "line": 11, - "column": 11 - } - } - }, - "property": { - "type": "Identifier", - "name": "a", - "decorators": [], - "loc": { - "start": { - "line": 11, - "column": 12 - }, - "end": { - "line": 11, - "column": 13 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 11, - "column": 7 - }, - "end": { - "line": 11, - "column": 13 - } - } - }, - "loc": { - "start": { - "line": 11, - "column": 7 - }, - "end": { - "line": 11, - "column": 15 - } - } - }, - "loc": { - "start": { - "line": 11, - "column": 7 - }, - "end": { - "line": 11, - "column": 16 - } - } - } - ], - "loc": { - "start": { - "line": 10, - "column": 17 - }, - "end": { - "line": 12, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 10, - "column": 8 - }, - "end": { - "line": 12, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 10, - "column": 8 - }, - "end": { - "line": 12, - "column": 6 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 10, - "column": 5 - }, - "end": { - "line": 12, - "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": 13, - "column": 4 - }, - "end": { - "line": 13, - "column": 4 - } - } - } - ], - "loc": { - "start": { - "line": 9, - "column": 21 - }, - "end": { - "line": 13, - "column": 4 - } - } - }, - "loc": { - "start": { - "line": 9, - "column": 3 - }, - "end": { - "line": 13, - "column": 4 - } - } - }, - { - "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": 14, - "column": 2 - }, - "end": { - "line": 14, - "column": 2 - } - } - } - ], - "loc": { - "start": { - "line": 6, - "column": 9 - }, - "end": { - "line": 14, - "column": 2 - } - } - }, - "loc": { - "start": { - "line": 6, - "column": 1 - }, - "end": { - "line": 14, - "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 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 15, - "column": 1 - } - } -} -TypeError: Bad operand type, the type of the operand must be numeric type. [identifierReference7.ets:11:7] +SyntaxError: Local type declaration (class, struct, interface and enum) support is not yet implemented. [identifierReference7.ets:23:3] diff --git a/ets2panda/test/compiler/ets/invalidInheritance2-expected.txt b/ets2panda/test/compiler/ets/invalidInheritance2-expected.txt index cd295e75f1..de48ad4ea2 100644 --- a/ets2panda/test/compiler/ets/invalidInheritance2-expected.txt +++ b/ets2panda/test/compiler/ets/invalidInheritance2-expected.txt @@ -1,750 +1 @@ -{ - "type": "Program", - "statements": [ - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 12 - }, - "end": { - "line": 1, - "column": 13 - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "a", - "decorators": [], - "loc": { - "start": { - "line": 2, - "column": 5 - }, - "end": { - "line": 2, - "column": 6 - } - } - }, - "value": { - "type": "NumberLiteral", - "value": 1, - "loc": { - "start": { - "line": 2, - "column": 14 - }, - "end": { - "line": 2, - "column": 15 - } - } - }, - "accessibility": "public", - "static": false, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 2, - "column": 8 - }, - "end": { - "line": 2, - "column": 11 - } - } - }, - "definite": false, - "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", - "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": 3, - "column": 2 - }, - "end": { - "line": 3, - "column": 2 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 14 - }, - "end": { - "line": 3, - "column": 2 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 6 - }, - "end": { - "line": 3, - "column": 2 - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "B", - "decorators": [], - "loc": { - "start": { - "line": 5, - "column": 12 - }, - "end": { - "line": 5, - "column": 13 - } - } - }, - "superClass": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 5, - "column": 22 - }, - "end": { - "line": 5, - "column": 23 - } - } - }, - "loc": { - "start": { - "line": 5, - "column": 22 - }, - "end": { - "line": 5, - "column": 25 - } - } - }, - "loc": { - "start": { - "line": 5, - "column": 22 - }, - "end": { - "line": 5, - "column": 25 - } - } - }, - "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": 6, - "column": 2 - }, - "end": { - "line": 6, - "column": 2 - } - } - } - ], - "loc": { - "start": { - "line": 5, - "column": 24 - }, - "end": { - "line": 6, - "column": 2 - } - } - }, - "loc": { - "start": { - "line": 5, - "column": 6 - }, - "end": { - "line": 6, - "column": 2 - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "C", - "decorators": [], - "loc": { - "start": { - "line": 8, - "column": 7 - }, - "end": { - "line": 8, - "column": 8 - } - } - }, - "superClass": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "B", - "decorators": [], - "loc": { - "start": { - "line": 8, - "column": 17 - }, - "end": { - "line": 8, - "column": 18 - } - } - }, - "loc": { - "start": { - "line": 8, - "column": 17 - }, - "end": { - "line": 8, - "column": 20 - } - } - }, - "loc": { - "start": { - "line": 8, - "column": 17 - }, - "end": { - "line": 8, - "column": 20 - } - } - }, - "implements": [], - "body": [ - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "a", - "decorators": [], - "loc": { - "start": { - "line": 9, - "column": 11 - }, - "end": { - "line": 9, - "column": 12 - } - } - }, - "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": 11, - "column": 6 - }, - "end": { - "line": 11, - "column": 6 - } - } - } - ], - "loc": { - "start": { - "line": 9, - "column": 13 - }, - "end": { - "line": 11, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 9, - "column": 5 - }, - "end": { - "line": 11, - "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": 12, - "column": 2 - }, - "end": { - "line": 12, - "column": 2 - } - } - } - ], - "loc": { - "start": { - "line": 8, - "column": 19 - }, - "end": { - "line": 12, - "column": 2 - } - } - }, - "loc": { - "start": { - "line": 8, - "column": 1 - }, - "end": { - "line": 12, - "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 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 13, - "column": 1 - } - } -} -TypeError: Cannot inherit from class B, because class a is inherited with a different declaration type [invalidInheritance2.ets:8:17] +SyntaxError: Local type declaration (class, struct, interface and enum) support is not yet implemented. [invalidInheritance2.ets:24:5] diff --git a/ets2panda/test/compiler/ets/invalidPrivateAccess5-expected.txt b/ets2panda/test/compiler/ets/invalidPrivateAccess5-expected.txt index 545b5159fd..93ceff48c7 100644 --- a/ets2panda/test/compiler/ets/invalidPrivateAccess5-expected.txt +++ b/ets2panda/test/compiler/ets/invalidPrivateAccess5-expected.txt @@ -1,1009 +1 @@ -{ - "type": "Program", - "statements": [ - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "Outer", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 7 - }, - "end": { - "line": 1, - "column": 12 - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "Base", - "decorators": [], - "loc": { - "start": { - "line": 2, - "column": 16 - }, - "end": { - "line": 2, - "column": 20 - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "a", - "decorators": [], - "loc": { - "start": { - "line": 3, - "column": 17 - }, - "end": { - "line": 3, - "column": 18 - } - } - }, - "kind": "method", - "accessibility": "private", - "static": false, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "a", - "decorators": [], - "loc": { - "start": { - "line": 3, - "column": 17 - }, - "end": { - "line": 3, - "column": 18 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 3, - "column": 22 - }, - "end": { - "line": 3, - "column": 26 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [], - "loc": { - "start": { - "line": 3, - "column": 27 - }, - "end": { - "line": 3, - "column": 29 - } - } - }, - "loc": { - "start": { - "line": 3, - "column": 18 - }, - "end": { - "line": 3, - "column": 29 - } - } - }, - "loc": { - "start": { - "line": 3, - "column": 18 - }, - "end": { - "line": 3, - "column": 29 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 3, - "column": 9 - }, - "end": { - "line": 3, - "column": 29 - } - } - }, - { - "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": 4, - "column": 6 - }, - "end": { - "line": 4, - "column": 6 - } - } - } - ], - "loc": { - "start": { - "line": 2, - "column": 21 - }, - "end": { - "line": 4, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 2, - "column": 10 - }, - "end": { - "line": 4, - "column": 6 - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "Derived", - "decorators": [], - "loc": { - "start": { - "line": 6, - "column": 11 - }, - "end": { - "line": 6, - "column": 18 - } - } - }, - "superClass": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Base", - "decorators": [], - "loc": { - "start": { - "line": 6, - "column": 27 - }, - "end": { - "line": 6, - "column": 31 - } - } - }, - "loc": { - "start": { - "line": 6, - "column": 27 - }, - "end": { - "line": 6, - "column": 33 - } - } - }, - "loc": { - "start": { - "line": 6, - "column": 27 - }, - "end": { - "line": 6, - "column": 33 - } - } - }, - "implements": [], - "body": [ - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "foo", - "decorators": [], - "loc": { - "start": { - "line": 7, - "column": 9 - }, - "end": { - "line": 7, - "column": 12 - } - } - }, - "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": 7, - "column": 9 - }, - "end": { - "line": 7, - "column": 12 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 7, - "column": 16 - }, - "end": { - "line": 7, - "column": 20 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "base", - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Base", - "decorators": [], - "loc": { - "start": { - "line": 8, - "column": 23 - }, - "end": { - "line": 8, - "column": 27 - } - } - }, - "loc": { - "start": { - "line": 8, - "column": 23 - }, - "end": { - "line": 8, - "column": 29 - } - } - }, - "loc": { - "start": { - "line": 8, - "column": 23 - }, - "end": { - "line": 8, - "column": 29 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 8, - "column": 17 - }, - "end": { - "line": 8, - "column": 21 - } - } - }, - "init": { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Base", - "decorators": [], - "loc": { - "start": { - "line": 8, - "column": 34 - }, - "end": { - "line": 8, - "column": 38 - } - } - }, - "loc": { - "start": { - "line": 8, - "column": 34 - }, - "end": { - "line": 8, - "column": 39 - } - } - }, - "loc": { - "start": { - "line": 8, - "column": 34 - }, - "end": { - "line": 8, - "column": 39 - } - } - }, - "arguments": [], - "loc": { - "start": { - "line": 8, - "column": 30 - }, - "end": { - "line": 8, - "column": 41 - } - } - }, - "loc": { - "start": { - "line": 8, - "column": 17 - }, - "end": { - "line": 8, - "column": 41 - } - } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 8, - "column": 13 - }, - "end": { - "line": 8, - "column": 41 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "base", - "decorators": [], - "loc": { - "start": { - "line": 9, - "column": 13 - }, - "end": { - "line": 9, - "column": 17 - } - } - }, - "property": { - "type": "Identifier", - "name": "a", - "decorators": [], - "loc": { - "start": { - "line": 9, - "column": 18 - }, - "end": { - "line": 9, - "column": 19 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 9, - "column": 13 - }, - "end": { - "line": 9, - "column": 19 - } - } - }, - "arguments": [], - "optional": false, - "loc": { - "start": { - "line": 9, - "column": 13 - }, - "end": { - "line": 9, - "column": 21 - } - } - }, - "loc": { - "start": { - "line": 9, - "column": 13 - }, - "end": { - "line": 9, - "column": 22 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "ThisExpression", - "loc": { - "start": { - "line": 10, - "column": 13 - }, - "end": { - "line": 10, - "column": 17 - } - } - }, - "property": { - "type": "Identifier", - "name": "a", - "decorators": [], - "loc": { - "start": { - "line": 10, - "column": 18 - }, - "end": { - "line": 10, - "column": 19 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 10, - "column": 13 - }, - "end": { - "line": 10, - "column": 19 - } - } - }, - "arguments": [], - "optional": false, - "loc": { - "start": { - "line": 10, - "column": 13 - }, - "end": { - "line": 10, - "column": 21 - } - } - }, - "loc": { - "start": { - "line": 10, - "column": 13 - }, - "end": { - "line": 10, - "column": 22 - } - } - } - ], - "loc": { - "start": { - "line": 7, - "column": 21 - }, - "end": { - "line": 11, - "column": 10 - } - } - }, - "loc": { - "start": { - "line": 7, - "column": 12 - }, - "end": { - "line": 11, - "column": 10 - } - } - }, - "loc": { - "start": { - "line": 7, - "column": 12 - }, - "end": { - "line": 11, - "column": 10 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 7, - "column": 9 - }, - "end": { - "line": 11, - "column": 10 - } - } - }, - { - "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": 12, - "column": 6 - }, - "end": { - "line": 12, - "column": 6 - } - } - } - ], - "loc": { - "start": { - "line": 6, - "column": 32 - }, - "end": { - "line": 12, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 6, - "column": 5 - }, - "end": { - "line": 12, - "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": 13, - "column": 2 - }, - "end": { - "line": 13, - "column": 2 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 13 - }, - "end": { - "line": 13, - "column": 2 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 13, - "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 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 14, - "column": 1 - } - } -} -TypeError: Signature a(): void is not visible here. [invalidPrivateAccess5.ets:10:13] +SyntaxError: Local type declaration (class, struct, interface and enum) support is not yet implemented. [invalidPrivateAccess5.ets:17:5] diff --git a/ets2panda/test/compiler/ets/invalidPrivateAccess6-expected.txt b/ets2panda/test/compiler/ets/invalidPrivateAccess6-expected.txt index 7fa94c600b..d70beb714c 100644 --- a/ets2panda/test/compiler/ets/invalidPrivateAccess6-expected.txt +++ b/ets2panda/test/compiler/ets/invalidPrivateAccess6-expected.txt @@ -1,1538 +1 @@ -{ - "type": "Program", - "statements": [ - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "Outer", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 7 - }, - "end": { - "line": 1, - "column": 12 - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 2, - "column": 11 - }, - "end": { - "line": 2, - "column": 12 - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "a", - "decorators": [], - "loc": { - "start": { - "line": 3, - "column": 17 - }, - "end": { - "line": 3, - "column": 18 - } - } - }, - "value": { - "type": "NumberLiteral", - "value": 12, - "loc": { - "start": { - "line": 3, - "column": 26 - }, - "end": { - "line": 3, - "column": 28 - } - } - }, - "accessibility": "private", - "static": false, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 3, - "column": 20 - }, - "end": { - "line": 3, - "column": 23 - } - } - }, - "definite": false, - "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", - "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": 4, - "column": 6 - }, - "end": { - "line": 4, - "column": 6 - } - } - } - ], - "loc": { - "start": { - "line": 2, - "column": 13 - }, - "end": { - "line": 4, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 2, - "column": 5 - }, - "end": { - "line": 4, - "column": 6 - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "B", - "decorators": [], - "loc": { - "start": { - "line": 6, - "column": 11 - }, - "end": { - "line": 6, - "column": 12 - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "foo", - "decorators": [], - "loc": { - "start": { - "line": 7, - "column": 9 - }, - "end": { - "line": 7, - "column": 12 - } - } - }, - "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": 7, - "column": 9 - }, - "end": { - "line": 7, - "column": 12 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 7, - "column": 16 - }, - "end": { - "line": 7, - "column": 20 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "a", - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 8, - "column": 20 - }, - "end": { - "line": 8, - "column": 21 - } - } - }, - "loc": { - "start": { - "line": 8, - "column": 20 - }, - "end": { - "line": 8, - "column": 23 - } - } - }, - "loc": { - "start": { - "line": 8, - "column": 20 - }, - "end": { - "line": 8, - "column": 23 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 8, - "column": 17 - }, - "end": { - "line": 8, - "column": 18 - } - } - }, - "init": { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 8, - "column": 28 - }, - "end": { - "line": 8, - "column": 29 - } - } - }, - "loc": { - "start": { - "line": 8, - "column": 28 - }, - "end": { - "line": 8, - "column": 30 - } - } - }, - "loc": { - "start": { - "line": 8, - "column": 28 - }, - "end": { - "line": 8, - "column": 30 - } - } - }, - "arguments": [], - "loc": { - "start": { - "line": 8, - "column": 24 - }, - "end": { - "line": 8, - "column": 32 - } - } - }, - "loc": { - "start": { - "line": 8, - "column": 17 - }, - "end": { - "line": 8, - "column": 32 - } - } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 8, - "column": 13 - }, - "end": { - "line": 8, - "column": 32 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "a", - "decorators": [], - "loc": { - "start": { - "line": 9, - "column": 13 - }, - "end": { - "line": 9, - "column": 14 - } - } - }, - "property": { - "type": "Identifier", - "name": "a", - "decorators": [], - "loc": { - "start": { - "line": 9, - "column": 15 - }, - "end": { - "line": 9, - "column": 16 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 9, - "column": 13 - }, - "end": { - "line": 9, - "column": 16 - } - } - }, - "right": { - "type": "NumberLiteral", - "value": 13, - "loc": { - "start": { - "line": 9, - "column": 19 - }, - "end": { - "line": 9, - "column": 21 - } - } - }, - "loc": { - "start": { - "line": 9, - "column": 13 - }, - "end": { - "line": 9, - "column": 21 - } - } - }, - "loc": { - "start": { - "line": 9, - "column": 13 - }, - "end": { - "line": 9, - "column": 22 - } - } - } - ], - "loc": { - "start": { - "line": 7, - "column": 21 - }, - "end": { - "line": 10, - "column": 10 - } - } - }, - "loc": { - "start": { - "line": 7, - "column": 12 - }, - "end": { - "line": 10, - "column": 10 - } - } - }, - "loc": { - "start": { - "line": 7, - "column": 12 - }, - "end": { - "line": 10, - "column": 10 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 7, - "column": 9 - }, - "end": { - "line": 10, - "column": 10 - } - } - }, - { - "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": 11, - "column": 6 - }, - "end": { - "line": 11, - "column": 6 - } - } - } - ], - "loc": { - "start": { - "line": 6, - "column": 13 - }, - "end": { - "line": 11, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 6, - "column": 5 - }, - "end": { - "line": 11, - "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": 12, - "column": 2 - }, - "end": { - "line": 12, - "column": 2 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 13 - }, - "end": { - "line": 12, - "column": 2 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 12, - "column": 2 - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "C", - "decorators": [], - "loc": { - "start": { - "line": 15, - "column": 7 - }, - "end": { - "line": 15, - "column": 8 - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "c", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 13 - }, - "end": { - "line": 16, - "column": 14 - } - } - }, - "value": { - "type": "NumberLiteral", - "value": 12, - "loc": { - "start": { - "line": 16, - "column": 22 - }, - "end": { - "line": 16, - "column": 24 - } - } - }, - "accessibility": "private", - "static": false, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 16, - "column": 16 - }, - "end": { - "line": 16, - "column": 19 - } - } - }, - "definite": false, - "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", - "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": 17, - "column": 2 - }, - "end": { - "line": 17, - "column": 2 - } - } - } - ], - "loc": { - "start": { - "line": 15, - "column": 9 - }, - "end": { - "line": 17, - "column": 2 - } - } - }, - "loc": { - "start": { - "line": 15, - "column": 1 - }, - "end": { - "line": 17, - "column": 2 - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "D", - "decorators": [], - "loc": { - "start": { - "line": 19, - "column": 7 - }, - "end": { - "line": 19, - "column": 8 - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "foo", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 5 - }, - "end": { - "line": 20, - "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": 20, - "column": 5 - }, - "end": { - "line": 20, - "column": 8 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 20, - "column": 12 - }, - "end": { - "line": 20, - "column": 16 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "c", - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "C", - "decorators": [], - "loc": { - "start": { - "line": 21, - "column": 16 - }, - "end": { - "line": 21, - "column": 17 - } - } - }, - "loc": { - "start": { - "line": 21, - "column": 16 - }, - "end": { - "line": 21, - "column": 19 - } - } - }, - "loc": { - "start": { - "line": 21, - "column": 16 - }, - "end": { - "line": 21, - "column": 19 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 21, - "column": 13 - }, - "end": { - "line": 21, - "column": 14 - } - } - }, - "init": { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "C", - "decorators": [], - "loc": { - "start": { - "line": 21, - "column": 24 - }, - "end": { - "line": 21, - "column": 25 - } - } - }, - "loc": { - "start": { - "line": 21, - "column": 24 - }, - "end": { - "line": 21, - "column": 26 - } - } - }, - "loc": { - "start": { - "line": 21, - "column": 24 - }, - "end": { - "line": 21, - "column": 26 - } - } - }, - "arguments": [], - "loc": { - "start": { - "line": 21, - "column": 20 - }, - "end": { - "line": 21, - "column": 28 - } - } - }, - "loc": { - "start": { - "line": 21, - "column": 13 - }, - "end": { - "line": 21, - "column": 28 - } - } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 21, - "column": 9 - }, - "end": { - "line": 21, - "column": 28 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "c", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 9 - }, - "end": { - "line": 22, - "column": 10 - } - } - }, - "property": { - "type": "Identifier", - "name": "c", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 11 - }, - "end": { - "line": 22, - "column": 12 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 22, - "column": 9 - }, - "end": { - "line": 22, - "column": 12 - } - } - }, - "right": { - "type": "NumberLiteral", - "value": 13, - "loc": { - "start": { - "line": 22, - "column": 15 - }, - "end": { - "line": 22, - "column": 17 - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 9 - }, - "end": { - "line": 22, - "column": 17 - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 9 - }, - "end": { - "line": 22, - "column": 18 - } - } - } - ], - "loc": { - "start": { - "line": 20, - "column": 17 - }, - "end": { - "line": 23, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 8 - }, - "end": { - "line": 23, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 8 - }, - "end": { - "line": 23, - "column": 6 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 5 - }, - "end": { - "line": 23, - "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": 24, - "column": 2 - }, - "end": { - "line": 24, - "column": 2 - } - } - } - ], - "loc": { - "start": { - "line": 19, - "column": 9 - }, - "end": { - "line": 24, - "column": 2 - } - } - }, - "loc": { - "start": { - "line": 19, - "column": 1 - }, - "end": { - "line": 24, - "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 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 25, - "column": 1 - } - } -} -TypeError: Property c is not visible here. [invalidPrivateAccess6.ets:22:11] +SyntaxError: Local type declaration (class, struct, interface and enum) support is not yet implemented. [invalidPrivateAccess6.ets:17:5] diff --git a/ets2panda/test/compiler/ets/override13-expected.txt b/ets2panda/test/compiler/ets/override13-expected.txt index 6d19ccb713..36b7fc2bb3 100644 --- a/ets2panda/test/compiler/ets/override13-expected.txt +++ b/ets2panda/test/compiler/ets/override13-expected.txt @@ -1618,4 +1618,4 @@ } } } -TypeError: fn2(t: Object): String in B cannot override fn2(t: T): T in A because overriding return type is not compatible with the other return type. [override13.ets:25:15] +TypeError: Cannot access property of non-object or non-enum type [override13.ets:25:52] diff --git a/ets2panda/test/compiler/ets/staticInitializerInInnerClass-expected.txt b/ets2panda/test/compiler/ets/staticInitializerInInnerClass-expected.txt index 5834ed9c38..f5c2bf1123 100644 --- a/ets2panda/test/compiler/ets/staticInitializerInInnerClass-expected.txt +++ b/ets2panda/test/compiler/ets/staticInitializerInInnerClass-expected.txt @@ -1,686 +1 @@ -{ - "type": "Program", - "statements": [ - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "Outer", - "decorators": [], - "loc": { - "start": { - "line": 2, - "column": 7 - }, - "end": { - "line": 2, - "column": 12 - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "Inner", - "decorators": [], - "loc": { - "start": { - "line": 3, - "column": 11 - }, - "end": { - "line": 3, - "column": 16 - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "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": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 6, - "column": 9 - }, - "end": { - "line": 6, - "column": 10 - } - } - }, - { - "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": 7, - "column": 6 - }, - "end": { - "line": 7, - "column": 6 - } - } - } - ], - "loc": { - "start": { - "line": 3, - "column": 17 - }, - "end": { - "line": 7, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 3, - "column": 5 - }, - "end": { - "line": 7, - "column": 6 - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "Inner2", - "decorators": [], - "loc": { - "start": { - "line": 9, - "column": 18 - }, - "end": { - "line": 9, - "column": 24 - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "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": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 12, - "column": 9 - }, - "end": { - "line": 12, - "column": 10 - } - } - }, - { - "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": 13, - "column": 6 - }, - "end": { - "line": 13, - "column": 6 - } - } - } - ], - "loc": { - "start": { - "line": 9, - "column": 25 - }, - "end": { - "line": 13, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 9, - "column": 12 - }, - "end": { - "line": 13, - "column": 6 - } - } - }, - { - "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": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "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": 5 - }, - "end": { - "line": 17, - "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": 18, - "column": 2 - }, - "end": { - "line": 18, - "column": 2 - } - } - } - ], - "loc": { - "start": { - "line": 2, - "column": 13 - }, - "end": { - "line": 18, - "column": 2 - } - } - }, - "loc": { - "start": { - "line": 2, - "column": 1 - }, - "end": { - "line": 18, - "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 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 19, - "column": 1 - } - } -} -TypeError: Static initializer is not allowed in inner class. [staticInitializerInInnerClass.ets:6:9] +SyntaxError: Local type declaration (class, struct, interface and enum) support is not yet implemented. [staticInitializerInInnerClass.ets:17:5] diff --git a/ets2panda/test/parser/ets/StringFasta-expected.txt b/ets2panda/test/parser/ets/StringFasta-expected.txt index da90de55e7..0c8c91c32c 100644 --- a/ets2panda/test/parser/ets/StringFasta-expected.txt +++ b/ets2panda/test/parser/ets/StringFasta-expected.txt @@ -1,9690 +1 @@ -{ - "type": "Program", - "statements": [ - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "StringFasta", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 19 - }, - "end": { - "line": 16, - "column": 30 - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "ALU", - "decorators": [], - "loc": { - "start": { - "line": 17, - "column": 21 - }, - "end": { - "line": 17, - "column": 24 - } - } - }, - "value": { - "type": "BinaryExpression", - "operator": "+", - "left": { - "type": "BinaryExpression", - "operator": "+", - "left": { - "type": "BinaryExpression", - "operator": "+", - "left": { - "type": "BinaryExpression", - "operator": "+", - "left": { - "type": "BinaryExpression", - "operator": "+", - "left": { - "type": "BinaryExpression", - "operator": "+", - "left": { - "type": "StringLiteral", - "value": "GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG", - "loc": { - "start": { - "line": 17, - "column": 36 - }, - "end": { - "line": 17, - "column": 80 - } - } - }, - "right": { - "type": "StringLiteral", - "value": "GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA", - "loc": { - "start": { - "line": 17, - "column": 83 - }, - "end": { - "line": 17, - "column": 127 - } - } - }, - "loc": { - "start": { - "line": 17, - "column": 36 - }, - "end": { - "line": 17, - "column": 127 - } - } - }, - "right": { - "type": "StringLiteral", - "value": "CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT", - "loc": { - "start": { - "line": 17, - "column": 130 - }, - "end": { - "line": 17, - "column": 174 - } - } - }, - "loc": { - "start": { - "line": 17, - "column": 36 - }, - "end": { - "line": 17, - "column": 174 - } - } - }, - "right": { - "type": "StringLiteral", - "value": "ACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCA", - "loc": { - "start": { - "line": 17, - "column": 177 - }, - "end": { - "line": 17, - "column": 221 - } - } - }, - "loc": { - "start": { - "line": 17, - "column": 36 - }, - "end": { - "line": 17, - "column": 221 - } - } - }, - "right": { - "type": "StringLiteral", - "value": "GCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGG", - "loc": { - "start": { - "line": 17, - "column": 224 - }, - "end": { - "line": 17, - "column": 268 - } - } - }, - "loc": { - "start": { - "line": 17, - "column": 36 - }, - "end": { - "line": 17, - "column": 268 - } - } - }, - "right": { - "type": "StringLiteral", - "value": "AGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC", - "loc": { - "start": { - "line": 17, - "column": 271 - }, - "end": { - "line": 17, - "column": 315 - } - } - }, - "loc": { - "start": { - "line": 17, - "column": 36 - }, - "end": { - "line": 17, - "column": 315 - } - } - }, - "right": { - "type": "StringLiteral", - "value": "AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA", - "loc": { - "start": { - "line": 17, - "column": 318 - }, - "end": { - "line": 17, - "column": 355 - } - } - }, - "loc": { - "start": { - "line": 17, - "column": 36 - }, - "end": { - "line": 17, - "column": 355 - } - } - }, - "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": 17, - "column": 27 - }, - "end": { - "line": 17, - "column": 33 - } - } - }, - "loc": { - "start": { - "line": 17, - "column": 27 - }, - "end": { - "line": 17, - "column": 35 - } - } - }, - "loc": { - "start": { - "line": 17, - "column": 27 - }, - "end": { - "line": 17, - "column": 35 - } - } - }, - "definite": false, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "IUB", - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 12 - }, - "end": { - "line": 18, - "column": 15 - } - } - }, - "value": { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "HashMap", - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 46 - }, - "end": { - "line": 18, - "column": 53 - } - } - }, - "loc": { - "start": { - "line": 18, - "column": 46 - }, - "end": { - "line": 18, - "column": 54 - } - } - }, - "loc": { - "start": { - "line": 18, - "column": 46 - }, - "end": { - "line": 18, - "column": 54 - } - } - }, - "arguments": [], - "loc": { - "start": { - "line": 18, - "column": 42 - }, - "end": { - "line": 18, - "column": 56 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "HashMap", - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 18 - }, - "end": { - "line": 18, - "column": 25 - } - } - }, - "typeParams": { - "type": "TSTypeParameterInstantiation", - "params": [ - { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Char", - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 26 - }, - "end": { - "line": 18, - "column": 30 - } - } - }, - "loc": { - "start": { - "line": 18, - "column": 26 - }, - "end": { - "line": 18, - "column": 31 - } - } - }, - "loc": { - "start": { - "line": 18, - "column": 26 - }, - "end": { - "line": 18, - "column": 31 - } - } - }, - { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Double", - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 32 - }, - "end": { - "line": 18, - "column": 38 - } - } - }, - "loc": { - "start": { - "line": 18, - "column": 32 - }, - "end": { - "line": 18, - "column": 39 - } - } - }, - "loc": { - "start": { - "line": 18, - "column": 32 - }, - "end": { - "line": 18, - "column": 39 - } - } - } - ], - "loc": { - "start": { - "line": 18, - "column": 25 - }, - "end": { - "line": 18, - "column": 39 - } - } - }, - "loc": { - "start": { - "line": 18, - "column": 18 - }, - "end": { - "line": 18, - "column": 41 - } - } - }, - "loc": { - "start": { - "line": 18, - "column": 18 - }, - "end": { - "line": 18, - "column": 41 - } - } - }, - "definite": false, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "HomoSap", - "decorators": [], - "loc": { - "start": { - "line": 19, - "column": 12 - }, - "end": { - "line": 19, - "column": 19 - } - } - }, - "value": { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "HashMap", - "decorators": [], - "loc": { - "start": { - "line": 19, - "column": 50 - }, - "end": { - "line": 19, - "column": 57 - } - } - }, - "loc": { - "start": { - "line": 19, - "column": 50 - }, - "end": { - "line": 19, - "column": 58 - } - } - }, - "loc": { - "start": { - "line": 19, - "column": 50 - }, - "end": { - "line": 19, - "column": 58 - } - } - }, - "arguments": [], - "loc": { - "start": { - "line": 19, - "column": 46 - }, - "end": { - "line": 19, - "column": 60 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "HashMap", - "decorators": [], - "loc": { - "start": { - "line": 19, - "column": 22 - }, - "end": { - "line": 19, - "column": 29 - } - } - }, - "typeParams": { - "type": "TSTypeParameterInstantiation", - "params": [ - { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Char", - "decorators": [], - "loc": { - "start": { - "line": 19, - "column": 30 - }, - "end": { - "line": 19, - "column": 34 - } - } - }, - "loc": { - "start": { - "line": 19, - "column": 30 - }, - "end": { - "line": 19, - "column": 35 - } - } - }, - "loc": { - "start": { - "line": 19, - "column": 30 - }, - "end": { - "line": 19, - "column": 35 - } - } - }, - { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Double", - "decorators": [], - "loc": { - "start": { - "line": 19, - "column": 36 - }, - "end": { - "line": 19, - "column": 42 - } - } - }, - "loc": { - "start": { - "line": 19, - "column": 36 - }, - "end": { - "line": 19, - "column": 43 - } - } - }, - "loc": { - "start": { - "line": 19, - "column": 36 - }, - "end": { - "line": 19, - "column": 43 - } - } - } - ], - "loc": { - "start": { - "line": 19, - "column": 29 - }, - "end": { - "line": 19, - "column": 43 - } - } - }, - "loc": { - "start": { - "line": 19, - "column": 22 - }, - "end": { - "line": 19, - "column": 45 - } - } - }, - "loc": { - "start": { - "line": 19, - "column": 22 - }, - "end": { - "line": 19, - "column": 45 - } - } - }, - "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": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "IUB", - "decorators": [], - "loc": { - "start": { - "line": 21, - "column": 9 - }, - "end": { - "line": 21, - "column": 12 - } - } - }, - "property": { - "type": "Identifier", - "name": "put", - "decorators": [], - "loc": { - "start": { - "line": 21, - "column": 13 - }, - "end": { - "line": 21, - "column": 16 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 21, - "column": 9 - }, - "end": { - "line": 21, - "column": 16 - } - } - }, - "arguments": [ - { - "type": "CharLiteral", - "value": "a", - "loc": { - "start": { - "line": 21, - "column": 17 - }, - "end": { - "line": 21, - "column": 20 - } - } - }, - { - "type": "NumberLiteral", - "value": 0.2, - "loc": { - "start": { - "line": 21, - "column": 22 - }, - "end": { - "line": 21, - "column": 25 - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 21, - "column": 9 - }, - "end": { - "line": 21, - "column": 26 - } - } - }, - "loc": { - "start": { - "line": 21, - "column": 9 - }, - "end": { - "line": 21, - "column": 27 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "IUB", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 9 - }, - "end": { - "line": 22, - "column": 12 - } - } - }, - "property": { - "type": "Identifier", - "name": "put", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 13 - }, - "end": { - "line": 22, - "column": 16 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 22, - "column": 9 - }, - "end": { - "line": 22, - "column": 16 - } - } - }, - "arguments": [ - { - "type": "CharLiteral", - "value": "c", - "loc": { - "start": { - "line": 22, - "column": 17 - }, - "end": { - "line": 22, - "column": 20 - } - } - }, - { - "type": "NumberLiteral", - "value": 0.2, - "loc": { - "start": { - "line": 22, - "column": 22 - }, - "end": { - "line": 22, - "column": 25 - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 22, - "column": 9 - }, - "end": { - "line": 22, - "column": 26 - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 9 - }, - "end": { - "line": 22, - "column": 27 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "IUB", - "decorators": [], - "loc": { - "start": { - "line": 23, - "column": 9 - }, - "end": { - "line": 23, - "column": 12 - } - } - }, - "property": { - "type": "Identifier", - "name": "put", - "decorators": [], - "loc": { - "start": { - "line": 23, - "column": 13 - }, - "end": { - "line": 23, - "column": 16 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 23, - "column": 9 - }, - "end": { - "line": 23, - "column": 16 - } - } - }, - "arguments": [ - { - "type": "CharLiteral", - "value": "g", - "loc": { - "start": { - "line": 23, - "column": 17 - }, - "end": { - "line": 23, - "column": 20 - } - } - }, - { - "type": "NumberLiteral", - "value": 0.2, - "loc": { - "start": { - "line": 23, - "column": 22 - }, - "end": { - "line": 23, - "column": 25 - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 23, - "column": 9 - }, - "end": { - "line": 23, - "column": 26 - } - } - }, - "loc": { - "start": { - "line": 23, - "column": 9 - }, - "end": { - "line": 23, - "column": 27 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "IUB", - "decorators": [], - "loc": { - "start": { - "line": 24, - "column": 9 - }, - "end": { - "line": 24, - "column": 12 - } - } - }, - "property": { - "type": "Identifier", - "name": "put", - "decorators": [], - "loc": { - "start": { - "line": 24, - "column": 13 - }, - "end": { - "line": 24, - "column": 16 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 24, - "column": 9 - }, - "end": { - "line": 24, - "column": 16 - } - } - }, - "arguments": [ - { - "type": "CharLiteral", - "value": "t", - "loc": { - "start": { - "line": 24, - "column": 17 - }, - "end": { - "line": 24, - "column": 20 - } - } - }, - { - "type": "NumberLiteral", - "value": 0.2, - "loc": { - "start": { - "line": 24, - "column": 22 - }, - "end": { - "line": 24, - "column": 25 - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 24, - "column": 9 - }, - "end": { - "line": 24, - "column": 26 - } - } - }, - "loc": { - "start": { - "line": 24, - "column": 9 - }, - "end": { - "line": 24, - "column": 27 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "IUB", - "decorators": [], - "loc": { - "start": { - "line": 25, - "column": 9 - }, - "end": { - "line": 25, - "column": 12 - } - } - }, - "property": { - "type": "Identifier", - "name": "put", - "decorators": [], - "loc": { - "start": { - "line": 25, - "column": 13 - }, - "end": { - "line": 25, - "column": 16 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 25, - "column": 9 - }, - "end": { - "line": 25, - "column": 16 - } - } - }, - "arguments": [ - { - "type": "CharLiteral", - "value": "B", - "loc": { - "start": { - "line": 25, - "column": 17 - }, - "end": { - "line": 25, - "column": 20 - } - } - }, - { - "type": "NumberLiteral", - "value": 0.2, - "loc": { - "start": { - "line": 25, - "column": 22 - }, - "end": { - "line": 25, - "column": 25 - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 25, - "column": 9 - }, - "end": { - "line": 25, - "column": 26 - } - } - }, - "loc": { - "start": { - "line": 25, - "column": 9 - }, - "end": { - "line": 25, - "column": 27 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "IUB", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 9 - }, - "end": { - "line": 26, - "column": 12 - } - } - }, - "property": { - "type": "Identifier", - "name": "put", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 13 - }, - "end": { - "line": 26, - "column": 16 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 26, - "column": 9 - }, - "end": { - "line": 26, - "column": 16 - } - } - }, - "arguments": [ - { - "type": "CharLiteral", - "value": "D", - "loc": { - "start": { - "line": 26, - "column": 17 - }, - "end": { - "line": 26, - "column": 20 - } - } - }, - { - "type": "NumberLiteral", - "value": 0.2, - "loc": { - "start": { - "line": 26, - "column": 22 - }, - "end": { - "line": 26, - "column": 25 - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 26, - "column": 9 - }, - "end": { - "line": 26, - "column": 26 - } - } - }, - "loc": { - "start": { - "line": 26, - "column": 9 - }, - "end": { - "line": 26, - "column": 27 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "IUB", - "decorators": [], - "loc": { - "start": { - "line": 27, - "column": 9 - }, - "end": { - "line": 27, - "column": 12 - } - } - }, - "property": { - "type": "Identifier", - "name": "put", - "decorators": [], - "loc": { - "start": { - "line": 27, - "column": 13 - }, - "end": { - "line": 27, - "column": 16 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 27, - "column": 9 - }, - "end": { - "line": 27, - "column": 16 - } - } - }, - "arguments": [ - { - "type": "CharLiteral", - "value": "H", - "loc": { - "start": { - "line": 27, - "column": 17 - }, - "end": { - "line": 27, - "column": 20 - } - } - }, - { - "type": "NumberLiteral", - "value": 0.2, - "loc": { - "start": { - "line": 27, - "column": 22 - }, - "end": { - "line": 27, - "column": 25 - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 27, - "column": 9 - }, - "end": { - "line": 27, - "column": 26 - } - } - }, - "loc": { - "start": { - "line": 27, - "column": 9 - }, - "end": { - "line": 27, - "column": 27 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "IUB", - "decorators": [], - "loc": { - "start": { - "line": 28, - "column": 9 - }, - "end": { - "line": 28, - "column": 12 - } - } - }, - "property": { - "type": "Identifier", - "name": "put", - "decorators": [], - "loc": { - "start": { - "line": 28, - "column": 13 - }, - "end": { - "line": 28, - "column": 16 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 28, - "column": 9 - }, - "end": { - "line": 28, - "column": 16 - } - } - }, - "arguments": [ - { - "type": "CharLiteral", - "value": "K", - "loc": { - "start": { - "line": 28, - "column": 17 - }, - "end": { - "line": 28, - "column": 20 - } - } - }, - { - "type": "NumberLiteral", - "value": 0.2, - "loc": { - "start": { - "line": 28, - "column": 22 - }, - "end": { - "line": 28, - "column": 25 - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 28, - "column": 9 - }, - "end": { - "line": 28, - "column": 26 - } - } - }, - "loc": { - "start": { - "line": 28, - "column": 9 - }, - "end": { - "line": 28, - "column": 27 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "IUB", - "decorators": [], - "loc": { - "start": { - "line": 29, - "column": 9 - }, - "end": { - "line": 29, - "column": 12 - } - } - }, - "property": { - "type": "Identifier", - "name": "put", - "decorators": [], - "loc": { - "start": { - "line": 29, - "column": 13 - }, - "end": { - "line": 29, - "column": 16 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 29, - "column": 9 - }, - "end": { - "line": 29, - "column": 16 - } - } - }, - "arguments": [ - { - "type": "CharLiteral", - "value": "M", - "loc": { - "start": { - "line": 29, - "column": 17 - }, - "end": { - "line": 29, - "column": 20 - } - } - }, - { - "type": "NumberLiteral", - "value": 0.2, - "loc": { - "start": { - "line": 29, - "column": 22 - }, - "end": { - "line": 29, - "column": 25 - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 29, - "column": 9 - }, - "end": { - "line": 29, - "column": 26 - } - } - }, - "loc": { - "start": { - "line": 29, - "column": 9 - }, - "end": { - "line": 29, - "column": 27 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "IUB", - "decorators": [], - "loc": { - "start": { - "line": 30, - "column": 9 - }, - "end": { - "line": 30, - "column": 12 - } - } - }, - "property": { - "type": "Identifier", - "name": "put", - "decorators": [], - "loc": { - "start": { - "line": 30, - "column": 13 - }, - "end": { - "line": 30, - "column": 16 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 30, - "column": 9 - }, - "end": { - "line": 30, - "column": 16 - } - } - }, - "arguments": [ - { - "type": "CharLiteral", - "value": "N", - "loc": { - "start": { - "line": 30, - "column": 17 - }, - "end": { - "line": 30, - "column": 20 - } - } - }, - { - "type": "NumberLiteral", - "value": 0.2, - "loc": { - "start": { - "line": 30, - "column": 22 - }, - "end": { - "line": 30, - "column": 25 - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 30, - "column": 9 - }, - "end": { - "line": 30, - "column": 26 - } - } - }, - "loc": { - "start": { - "line": 30, - "column": 9 - }, - "end": { - "line": 30, - "column": 27 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "IUB", - "decorators": [], - "loc": { - "start": { - "line": 31, - "column": 9 - }, - "end": { - "line": 31, - "column": 12 - } - } - }, - "property": { - "type": "Identifier", - "name": "put", - "decorators": [], - "loc": { - "start": { - "line": 31, - "column": 13 - }, - "end": { - "line": 31, - "column": 16 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 31, - "column": 9 - }, - "end": { - "line": 31, - "column": 16 - } - } - }, - "arguments": [ - { - "type": "CharLiteral", - "value": "R", - "loc": { - "start": { - "line": 31, - "column": 17 - }, - "end": { - "line": 31, - "column": 20 - } - } - }, - { - "type": "NumberLiteral", - "value": 0.2, - "loc": { - "start": { - "line": 31, - "column": 22 - }, - "end": { - "line": 31, - "column": 25 - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 31, - "column": 9 - }, - "end": { - "line": 31, - "column": 26 - } - } - }, - "loc": { - "start": { - "line": 31, - "column": 9 - }, - "end": { - "line": 31, - "column": 27 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "IUB", - "decorators": [], - "loc": { - "start": { - "line": 32, - "column": 9 - }, - "end": { - "line": 32, - "column": 12 - } - } - }, - "property": { - "type": "Identifier", - "name": "put", - "decorators": [], - "loc": { - "start": { - "line": 32, - "column": 13 - }, - "end": { - "line": 32, - "column": 16 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 32, - "column": 9 - }, - "end": { - "line": 32, - "column": 16 - } - } - }, - "arguments": [ - { - "type": "CharLiteral", - "value": "S", - "loc": { - "start": { - "line": 32, - "column": 17 - }, - "end": { - "line": 32, - "column": 20 - } - } - }, - { - "type": "NumberLiteral", - "value": 0.2, - "loc": { - "start": { - "line": 32, - "column": 22 - }, - "end": { - "line": 32, - "column": 25 - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 32, - "column": 9 - }, - "end": { - "line": 32, - "column": 26 - } - } - }, - "loc": { - "start": { - "line": 32, - "column": 9 - }, - "end": { - "line": 32, - "column": 27 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "IUB", - "decorators": [], - "loc": { - "start": { - "line": 33, - "column": 9 - }, - "end": { - "line": 33, - "column": 12 - } - } - }, - "property": { - "type": "Identifier", - "name": "put", - "decorators": [], - "loc": { - "start": { - "line": 33, - "column": 13 - }, - "end": { - "line": 33, - "column": 16 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 33, - "column": 9 - }, - "end": { - "line": 33, - "column": 16 - } - } - }, - "arguments": [ - { - "type": "CharLiteral", - "value": "V", - "loc": { - "start": { - "line": 33, - "column": 17 - }, - "end": { - "line": 33, - "column": 20 - } - } - }, - { - "type": "NumberLiteral", - "value": 0.2, - "loc": { - "start": { - "line": 33, - "column": 22 - }, - "end": { - "line": 33, - "column": 25 - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 33, - "column": 9 - }, - "end": { - "line": 33, - "column": 26 - } - } - }, - "loc": { - "start": { - "line": 33, - "column": 9 - }, - "end": { - "line": 33, - "column": 27 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "IUB", - "decorators": [], - "loc": { - "start": { - "line": 34, - "column": 9 - }, - "end": { - "line": 34, - "column": 12 - } - } - }, - "property": { - "type": "Identifier", - "name": "put", - "decorators": [], - "loc": { - "start": { - "line": 34, - "column": 13 - }, - "end": { - "line": 34, - "column": 16 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 34, - "column": 9 - }, - "end": { - "line": 34, - "column": 16 - } - } - }, - "arguments": [ - { - "type": "CharLiteral", - "value": "W", - "loc": { - "start": { - "line": 34, - "column": 17 - }, - "end": { - "line": 34, - "column": 20 - } - } - }, - { - "type": "NumberLiteral", - "value": 0.2, - "loc": { - "start": { - "line": 34, - "column": 22 - }, - "end": { - "line": 34, - "column": 25 - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 34, - "column": 9 - }, - "end": { - "line": 34, - "column": 26 - } - } - }, - "loc": { - "start": { - "line": 34, - "column": 9 - }, - "end": { - "line": 34, - "column": 27 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "IUB", - "decorators": [], - "loc": { - "start": { - "line": 35, - "column": 9 - }, - "end": { - "line": 35, - "column": 12 - } - } - }, - "property": { - "type": "Identifier", - "name": "put", - "decorators": [], - "loc": { - "start": { - "line": 35, - "column": 13 - }, - "end": { - "line": 35, - "column": 16 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 35, - "column": 9 - }, - "end": { - "line": 35, - "column": 16 - } - } - }, - "arguments": [ - { - "type": "CharLiteral", - "value": "Y", - "loc": { - "start": { - "line": 35, - "column": 17 - }, - "end": { - "line": 35, - "column": 20 - } - } - }, - { - "type": "NumberLiteral", - "value": 0.2, - "loc": { - "start": { - "line": 35, - "column": 22 - }, - "end": { - "line": 35, - "column": 25 - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 35, - "column": 9 - }, - "end": { - "line": 35, - "column": 26 - } - } - }, - "loc": { - "start": { - "line": 35, - "column": 9 - }, - "end": { - "line": 35, - "column": 27 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "HomoSap", - "decorators": [], - "loc": { - "start": { - "line": 36, - "column": 9 - }, - "end": { - "line": 36, - "column": 16 - } - } - }, - "property": { - "type": "Identifier", - "name": "put", - "decorators": [], - "loc": { - "start": { - "line": 36, - "column": 17 - }, - "end": { - "line": 36, - "column": 20 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 36, - "column": 9 - }, - "end": { - "line": 36, - "column": 20 - } - } - }, - "arguments": [ - { - "type": "CharLiteral", - "value": "a", - "loc": { - "start": { - "line": 36, - "column": 21 - }, - "end": { - "line": 36, - "column": 24 - } - } - }, - { - "type": "NumberLiteral", - "value": 0.302955, - "loc": { - "start": { - "line": 36, - "column": 26 - }, - "end": { - "line": 36, - "column": 41 - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 36, - "column": 9 - }, - "end": { - "line": 36, - "column": 42 - } - } - }, - "loc": { - "start": { - "line": 36, - "column": 9 - }, - "end": { - "line": 36, - "column": 43 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "HomoSap", - "decorators": [], - "loc": { - "start": { - "line": 37, - "column": 9 - }, - "end": { - "line": 37, - "column": 16 - } - } - }, - "property": { - "type": "Identifier", - "name": "put", - "decorators": [], - "loc": { - "start": { - "line": 37, - "column": 17 - }, - "end": { - "line": 37, - "column": 20 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 37, - "column": 9 - }, - "end": { - "line": 37, - "column": 20 - } - } - }, - "arguments": [ - { - "type": "CharLiteral", - "value": "c", - "loc": { - "start": { - "line": 37, - "column": 21 - }, - "end": { - "line": 37, - "column": 24 - } - } - }, - { - "type": "NumberLiteral", - "value": 0.197988, - "loc": { - "start": { - "line": 37, - "column": 26 - }, - "end": { - "line": 37, - "column": 41 - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 37, - "column": 9 - }, - "end": { - "line": 37, - "column": 42 - } - } - }, - "loc": { - "start": { - "line": 37, - "column": 9 - }, - "end": { - "line": 37, - "column": 43 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "HomoSap", - "decorators": [], - "loc": { - "start": { - "line": 38, - "column": 9 - }, - "end": { - "line": 38, - "column": 16 - } - } - }, - "property": { - "type": "Identifier", - "name": "put", - "decorators": [], - "loc": { - "start": { - "line": 38, - "column": 17 - }, - "end": { - "line": 38, - "column": 20 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 38, - "column": 9 - }, - "end": { - "line": 38, - "column": 20 - } - } - }, - "arguments": [ - { - "type": "CharLiteral", - "value": "g", - "loc": { - "start": { - "line": 38, - "column": 21 - }, - "end": { - "line": 38, - "column": 24 - } - } - }, - { - "type": "NumberLiteral", - "value": 0.197547, - "loc": { - "start": { - "line": 38, - "column": 26 - }, - "end": { - "line": 38, - "column": 41 - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 38, - "column": 9 - }, - "end": { - "line": 38, - "column": 42 - } - } - }, - "loc": { - "start": { - "line": 38, - "column": 9 - }, - "end": { - "line": 38, - "column": 43 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "HomoSap", - "decorators": [], - "loc": { - "start": { - "line": 39, - "column": 9 - }, - "end": { - "line": 39, - "column": 16 - } - } - }, - "property": { - "type": "Identifier", - "name": "put", - "decorators": [], - "loc": { - "start": { - "line": 39, - "column": 17 - }, - "end": { - "line": 39, - "column": 20 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 39, - "column": 9 - }, - "end": { - "line": 39, - "column": 20 - } - } - }, - "arguments": [ - { - "type": "CharLiteral", - "value": "t", - "loc": { - "start": { - "line": 39, - "column": 21 - }, - "end": { - "line": 39, - "column": 24 - } - } - }, - { - "type": "NumberLiteral", - "value": 0.301509, - "loc": { - "start": { - "line": 39, - "column": 26 - }, - "end": { - "line": 39, - "column": 41 - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 39, - "column": 9 - }, - "end": { - "line": 39, - "column": 42 - } - } - }, - "loc": { - "start": { - "line": 39, - "column": 9 - }, - "end": { - "line": 39, - "column": 43 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 40, - "column": 5 - }, - "end": { - "line": 40, - "column": 6 - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "Random", - "decorators": [], - "loc": { - "start": { - "line": 41, - "column": 23 - }, - "end": { - "line": 41, - "column": 29 - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "last", - "decorators": [], - "loc": { - "start": { - "line": 42, - "column": 16 - }, - "end": { - "line": 42, - "column": 20 - } - } - }, - "value": { - "type": "NumberLiteral", - "value": 42, - "loc": { - "start": { - "line": 42, - "column": 29 - }, - "end": { - "line": 42, - "column": 31 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 42, - "column": 23 - }, - "end": { - "line": 42, - "column": 26 - } - } - }, - "definite": false, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 43, - "column": 16 - }, - "end": { - "line": 43, - "column": 17 - } - } - }, - "value": { - "type": "NumberLiteral", - "value": 3877, - "loc": { - "start": { - "line": 43, - "column": 26 - }, - "end": { - "line": 43, - "column": 30 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 43, - "column": 20 - }, - "end": { - "line": 43, - "column": 23 - } - } - }, - "definite": false, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "C", - "decorators": [], - "loc": { - "start": { - "line": 44, - "column": 16 - }, - "end": { - "line": 44, - "column": 17 - } - } - }, - "value": { - "type": "NumberLiteral", - "value": 29573, - "loc": { - "start": { - "line": 44, - "column": 26 - }, - "end": { - "line": 44, - "column": 31 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 44, - "column": 20 - }, - "end": { - "line": 44, - "column": 23 - } - } - }, - "definite": false, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "M", - "decorators": [], - "loc": { - "start": { - "line": 45, - "column": 16 - }, - "end": { - "line": 45, - "column": 17 - } - } - }, - "value": { - "type": "NumberLiteral", - "value": 139968, - "loc": { - "start": { - "line": 45, - "column": 26 - }, - "end": { - "line": 45, - "column": 32 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 45, - "column": 20 - }, - "end": { - "line": 45, - "column": 23 - } - } - }, - "definite": false, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "rand", - "decorators": [], - "loc": { - "start": { - "line": 46, - "column": 23 - }, - "end": { - "line": 46, - "column": 27 - } - } - }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "rand", - "decorators": [], - "loc": { - "start": { - "line": 46, - "column": 23 - }, - "end": { - "line": 46, - "column": 27 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "Identifier", - "name": "max", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 46, - "column": 34 - }, - "end": { - "line": 46, - "column": 40 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 46, - "column": 28 - }, - "end": { - "line": 46, - "column": 40 - } - } - } - ], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 46, - "column": 43 - }, - "end": { - "line": 46, - "column": 49 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "last", - "decorators": [], - "loc": { - "start": { - "line": 47, - "column": 13 - }, - "end": { - "line": 47, - "column": 17 - } - } - }, - "right": { - "type": "BinaryExpression", - "operator": "%", - "left": { - "type": "BinaryExpression", - "operator": "+", - "left": { - "type": "BinaryExpression", - "operator": "*", - "left": { - "type": "Identifier", - "name": "last", - "decorators": [], - "loc": { - "start": { - "line": 47, - "column": 21 - }, - "end": { - "line": 47, - "column": 25 - } - } - }, - "right": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 47, - "column": 28 - }, - "end": { - "line": 47, - "column": 29 - } - } - }, - "loc": { - "start": { - "line": 47, - "column": 21 - }, - "end": { - "line": 47, - "column": 29 - } - } - }, - "right": { - "type": "Identifier", - "name": "C", - "decorators": [], - "loc": { - "start": { - "line": 47, - "column": 32 - }, - "end": { - "line": 47, - "column": 33 - } - } - }, - "loc": { - "start": { - "line": 47, - "column": 20 - }, - "end": { - "line": 47, - "column": 34 - } - } - }, - "right": { - "type": "Identifier", - "name": "M", - "decorators": [], - "loc": { - "start": { - "line": 47, - "column": 37 - }, - "end": { - "line": 47, - "column": 38 - } - } - }, - "loc": { - "start": { - "line": 47, - "column": 20 - }, - "end": { - "line": 47, - "column": 38 - } - } - }, - "loc": { - "start": { - "line": 47, - "column": 13 - }, - "end": { - "line": 47, - "column": 38 - } - } - }, - "loc": { - "start": { - "line": 47, - "column": 13 - }, - "end": { - "line": 47, - "column": 39 - } - } - }, - { - "type": "ReturnStatement", - "argument": { - "type": "BinaryExpression", - "operator": "/", - "left": { - "type": "BinaryExpression", - "operator": "*", - "left": { - "type": "Identifier", - "name": "max", - "decorators": [], - "loc": { - "start": { - "line": 48, - "column": 20 - }, - "end": { - "line": 48, - "column": 23 - } - } - }, - "right": { - "type": "Identifier", - "name": "last", - "decorators": [], - "loc": { - "start": { - "line": 48, - "column": 26 - }, - "end": { - "line": 48, - "column": 30 - } - } - }, - "loc": { - "start": { - "line": 48, - "column": 20 - }, - "end": { - "line": 48, - "column": 30 - } - } - }, - "right": { - "type": "Identifier", - "name": "M", - "decorators": [], - "loc": { - "start": { - "line": 48, - "column": 33 - }, - "end": { - "line": 48, - "column": 34 - } - } - }, - "loc": { - "start": { - "line": 48, - "column": 20 - }, - "end": { - "line": 48, - "column": 34 - } - } - }, - "loc": { - "start": { - "line": 48, - "column": 13 - }, - "end": { - "line": 48, - "column": 35 - } - } - } - ], - "loc": { - "start": { - "line": 46, - "column": 50 - }, - "end": { - "line": 49, - "column": 10 - } - } - }, - "loc": { - "start": { - "line": 46, - "column": 27 - }, - "end": { - "line": 49, - "column": 10 - } - } - }, - "loc": { - "start": { - "line": 46, - "column": 27 - }, - "end": { - "line": 49, - "column": 10 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 46, - "column": 9 - }, - "end": { - "line": 49, - "column": 10 - } - } - }, - { - "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": 50, - "column": 6 - }, - "end": { - "line": 50, - "column": 6 - } - } - } - ], - "loc": { - "start": { - "line": 41, - "column": 31 - }, - "end": { - "line": 50, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 41, - "column": 17 - }, - "end": { - "line": 50, - "column": 6 - } - } - }, - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "makeCumulative", - "decorators": [], - "loc": { - "start": { - "line": 52, - "column": 12 - }, - "end": { - "line": 52, - "column": 26 - } - } - }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "makeCumulative", - "decorators": [], - "loc": { - "start": { - "line": 52, - "column": 12 - }, - "end": { - "line": 52, - "column": 26 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "Identifier", - "name": "table", - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "HashMap", - "decorators": [], - "loc": { - "start": { - "line": 52, - "column": 35 - }, - "end": { - "line": 52, - "column": 42 - } - } - }, - "typeParams": { - "type": "TSTypeParameterInstantiation", - "params": [ - { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Char", - "decorators": [], - "loc": { - "start": { - "line": 52, - "column": 43 - }, - "end": { - "line": 52, - "column": 47 - } - } - }, - "loc": { - "start": { - "line": 52, - "column": 43 - }, - "end": { - "line": 52, - "column": 48 - } - } - }, - "loc": { - "start": { - "line": 52, - "column": 43 - }, - "end": { - "line": 52, - "column": 48 - } - } - }, - { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Double", - "decorators": [], - "loc": { - "start": { - "line": 52, - "column": 49 - }, - "end": { - "line": 52, - "column": 55 - } - } - }, - "loc": { - "start": { - "line": 52, - "column": 49 - }, - "end": { - "line": 52, - "column": 56 - } - } - }, - "loc": { - "start": { - "line": 52, - "column": 49 - }, - "end": { - "line": 52, - "column": 56 - } - } - } - ], - "loc": { - "start": { - "line": 52, - "column": 42 - }, - "end": { - "line": 52, - "column": 56 - } - } - }, - "loc": { - "start": { - "line": 52, - "column": 35 - }, - "end": { - "line": 52, - "column": 57 - } - } - }, - "loc": { - "start": { - "line": 52, - "column": 35 - }, - "end": { - "line": 52, - "column": 57 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 52, - "column": 27 - }, - "end": { - "line": 52, - "column": 57 - } - } - } - ], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 52, - "column": 59 - }, - "end": { - "line": 52, - "column": 63 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "last", - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Char", - "decorators": [], - "loc": { - "start": { - "line": 53, - "column": 20 - }, - "end": { - "line": 53, - "column": 24 - } - } - }, - "loc": { - "start": { - "line": 53, - "column": 20 - }, - "end": { - "line": 53, - "column": 26 - } - } - }, - "loc": { - "start": { - "line": 53, - "column": 20 - }, - "end": { - "line": 53, - "column": 26 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 53, - "column": 13 - }, - "end": { - "line": 53, - "column": 17 - } - } - }, - "init": { - "type": "NullLiteral", - "value": null, - "loc": { - "start": { - "line": 53, - "column": 27 - }, - "end": { - "line": 53, - "column": 31 - } - } - }, - "loc": { - "start": { - "line": 53, - "column": 13 - }, - "end": { - "line": 53, - "column": 31 - } - } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 53, - "column": 9 - }, - "end": { - "line": 53, - "column": 32 - } - } - }, - { - "type": "ForOfStatement", - "await": false, - "left": { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "entry", - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "TSQualifiedName", - "left": { - "type": "Identifier", - "name": "HashMap", - "decorators": [], - "loc": { - "start": { - "line": 54, - "column": 26 - }, - "end": { - "line": 54, - "column": 33 - } - } - }, - "right": { - "type": "Identifier", - "name": "Entry", - "decorators": [], - "loc": { - "start": { - "line": 54, - "column": 34 - }, - "end": { - "line": 54, - "column": 39 - } - } - }, - "loc": { - "start": { - "line": 54, - "column": 26 - }, - "end": { - "line": 54, - "column": 40 - } - } - }, - "typeParams": { - "type": "TSTypeParameterInstantiation", - "params": [ - { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Char", - "decorators": [], - "loc": { - "start": { - "line": 54, - "column": 40 - }, - "end": { - "line": 54, - "column": 44 - } - } - }, - "loc": { - "start": { - "line": 54, - "column": 40 - }, - "end": { - "line": 54, - "column": 45 - } - } - }, - "loc": { - "start": { - "line": 54, - "column": 40 - }, - "end": { - "line": 54, - "column": 45 - } - } - }, - { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Double", - "decorators": [], - "loc": { - "start": { - "line": 54, - "column": 46 - }, - "end": { - "line": 54, - "column": 52 - } - } - }, - "loc": { - "start": { - "line": 54, - "column": 46 - }, - "end": { - "line": 54, - "column": 53 - } - } - }, - "loc": { - "start": { - "line": 54, - "column": 46 - }, - "end": { - "line": 54, - "column": 53 - } - } - } - ], - "loc": { - "start": { - "line": 54, - "column": 39 - }, - "end": { - "line": 54, - "column": 53 - } - } - }, - "loc": { - "start": { - "line": 54, - "column": 26 - }, - "end": { - "line": 54, - "column": 56 - } - } - }, - "loc": { - "start": { - "line": 54, - "column": 26 - }, - "end": { - "line": 54, - "column": 56 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 54, - "column": 18 - }, - "end": { - "line": 54, - "column": 23 - } - } - }, - "init": null, - "loc": { - "start": { - "line": 54, - "column": 18 - }, - "end": { - "line": 54, - "column": 23 - } - } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 54, - "column": 14 - }, - "end": { - "line": 54, - "column": 23 - } - } - }, - "right": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "table", - "decorators": [], - "loc": { - "start": { - "line": 54, - "column": 57 - }, - "end": { - "line": 54, - "column": 62 - } - } - }, - "property": { - "type": "Identifier", - "name": "entrySet", - "decorators": [], - "loc": { - "start": { - "line": 54, - "column": 63 - }, - "end": { - "line": 54, - "column": 71 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 54, - "column": 57 - }, - "end": { - "line": 54, - "column": 71 - } - } - }, - "arguments": [], - "optional": false, - "loc": { - "start": { - "line": 54, - "column": 57 - }, - "end": { - "line": 54, - "column": 73 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "c", - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Char", - "decorators": [], - "loc": { - "start": { - "line": 55, - "column": 21 - }, - "end": { - "line": 55, - "column": 25 - } - } - }, - "loc": { - "start": { - "line": 55, - "column": 21 - }, - "end": { - "line": 55, - "column": 27 - } - } - }, - "loc": { - "start": { - "line": 55, - "column": 21 - }, - "end": { - "line": 55, - "column": 27 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 55, - "column": 17 - }, - "end": { - "line": 55, - "column": 18 - } - } - }, - "init": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "entry", - "decorators": [], - "loc": { - "start": { - "line": 55, - "column": 28 - }, - "end": { - "line": 55, - "column": 33 - } - } - }, - "property": { - "type": "Identifier", - "name": "getKey", - "decorators": [], - "loc": { - "start": { - "line": 55, - "column": 34 - }, - "end": { - "line": 55, - "column": 40 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 55, - "column": 28 - }, - "end": { - "line": 55, - "column": 40 - } - } - }, - "arguments": [], - "optional": false, - "loc": { - "start": { - "line": 55, - "column": 28 - }, - "end": { - "line": 55, - "column": 42 - } - } - }, - "loc": { - "start": { - "line": 55, - "column": 17 - }, - "end": { - "line": 55, - "column": 42 - } - } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 55, - "column": 13 - }, - "end": { - "line": 55, - "column": 43 - } - } - }, - { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "!=", - "left": { - "type": "Identifier", - "name": "last", - "decorators": [], - "loc": { - "start": { - "line": 56, - "column": 17 - }, - "end": { - "line": 56, - "column": 21 - } - } - }, - "right": { - "type": "NullLiteral", - "value": null, - "loc": { - "start": { - "line": 56, - "column": 25 - }, - "end": { - "line": 56, - "column": 29 - } - } - }, - "loc": { - "start": { - "line": 56, - "column": 17 - }, - "end": { - "line": 56, - "column": 29 - } - } - }, - "consequent": { - "type": "BlockStatement", - "statements": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "table", - "decorators": [], - "loc": { - "start": { - "line": 57, - "column": 17 - }, - "end": { - "line": 57, - "column": 22 - } - } - }, - "property": { - "type": "Identifier", - "name": "put", - "decorators": [], - "loc": { - "start": { - "line": 57, - "column": 23 - }, - "end": { - "line": 57, - "column": 26 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 57, - "column": 17 - }, - "end": { - "line": 57, - "column": 26 - } - } - }, - "arguments": [ - { - "type": "Identifier", - "name": "c", - "decorators": [], - "loc": { - "start": { - "line": 57, - "column": 27 - }, - "end": { - "line": 57, - "column": 28 - } - } - }, - { - "type": "BinaryExpression", - "operator": "+", - "left": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "entry", - "decorators": [], - "loc": { - "start": { - "line": 57, - "column": 30 - }, - "end": { - "line": 57, - "column": 35 - } - } - }, - "property": { - "type": "Identifier", - "name": "getValue", - "decorators": [], - "loc": { - "start": { - "line": 57, - "column": 36 - }, - "end": { - "line": 57, - "column": 44 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 57, - "column": 30 - }, - "end": { - "line": 57, - "column": 44 - } - } - }, - "arguments": [], - "optional": false, - "loc": { - "start": { - "line": 57, - "column": 30 - }, - "end": { - "line": 57, - "column": 46 - } - } - }, - "right": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "table", - "decorators": [], - "loc": { - "start": { - "line": 57, - "column": 49 - }, - "end": { - "line": 57, - "column": 54 - } - } - }, - "property": { - "type": "Identifier", - "name": "get", - "decorators": [], - "loc": { - "start": { - "line": 57, - "column": 55 - }, - "end": { - "line": 57, - "column": 58 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 57, - "column": 49 - }, - "end": { - "line": 57, - "column": 58 - } - } - }, - "arguments": [ - { - "type": "Identifier", - "name": "last", - "decorators": [], - "loc": { - "start": { - "line": 57, - "column": 59 - }, - "end": { - "line": 57, - "column": 63 - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 57, - "column": 49 - }, - "end": { - "line": 57, - "column": 64 - } - } - }, - "loc": { - "start": { - "line": 57, - "column": 30 - }, - "end": { - "line": 57, - "column": 64 - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 57, - "column": 17 - }, - "end": { - "line": 57, - "column": 65 - } - } - }, - "loc": { - "start": { - "line": 57, - "column": 17 - }, - "end": { - "line": 57, - "column": 66 - } - } - } - ], - "loc": { - "start": { - "line": 56, - "column": 31 - }, - "end": { - "line": 58, - "column": 14 - } - } - }, - "alternate": null, - "loc": { - "start": { - "line": 56, - "column": 13 - }, - "end": { - "line": 58, - "column": 14 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "last", - "decorators": [], - "loc": { - "start": { - "line": 59, - "column": 13 - }, - "end": { - "line": 59, - "column": 17 - } - } - }, - "right": { - "type": "Identifier", - "name": "c", - "decorators": [], - "loc": { - "start": { - "line": 59, - "column": 20 - }, - "end": { - "line": 59, - "column": 21 - } - } - }, - "loc": { - "start": { - "line": 59, - "column": 13 - }, - "end": { - "line": 59, - "column": 21 - } - } - }, - "loc": { - "start": { - "line": 59, - "column": 13 - }, - "end": { - "line": 59, - "column": 22 - } - } - } - ], - "loc": { - "start": { - "line": 54, - "column": 74 - }, - "end": { - "line": 60, - "column": 10 - } - } - }, - "loc": { - "start": { - "line": 54, - "column": 9 - }, - "end": { - "line": 60, - "column": 10 - } - } - } - ], - "loc": { - "start": { - "line": 52, - "column": 64 - }, - "end": { - "line": 61, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 52, - "column": 26 - }, - "end": { - "line": 61, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 52, - "column": 26 - }, - "end": { - "line": 61, - "column": 6 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 52, - "column": 5 - }, - "end": { - "line": 61, - "column": 6 - } - } - }, - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "fastaRepeat", - "decorators": [], - "loc": { - "start": { - "line": 62, - "column": 12 - }, - "end": { - "line": 62, - "column": 23 - } - } - }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "fastaRepeat", - "decorators": [], - "loc": { - "start": { - "line": 62, - "column": 12 - }, - "end": { - "line": 62, - "column": 23 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "Identifier", - "name": "n", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 62, - "column": 28 - }, - "end": { - "line": 62, - "column": 31 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 62, - "column": 24 - }, - "end": { - "line": 62, - "column": 31 - } - } - }, - { - "type": "Identifier", - "name": "seq", - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 62, - "column": 39 - }, - "end": { - "line": 62, - "column": 45 - } - } - }, - "loc": { - "start": { - "line": 62, - "column": 39 - }, - "end": { - "line": 62, - "column": 46 - } - } - }, - "loc": { - "start": { - "line": 62, - "column": 39 - }, - "end": { - "line": 62, - "column": 46 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 62, - "column": 33 - }, - "end": { - "line": 62, - "column": 46 - } - } - } - ], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 62, - "column": 48 - }, - "end": { - "line": 62, - "column": 51 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "seqi", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 63, - "column": 20 - }, - "end": { - "line": 63, - "column": 23 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 63, - "column": 13 - }, - "end": { - "line": 63, - "column": 17 - } - } - }, - "init": { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 63, - "column": 26 - }, - "end": { - "line": 63, - "column": 27 - } - } - }, - "loc": { - "start": { - "line": 63, - "column": 13 - }, - "end": { - "line": 63, - "column": 27 - } - } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 63, - "column": 9 - }, - "end": { - "line": 63, - "column": 28 - } - } - }, - { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "lenOut", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 64, - "column": 22 - }, - "end": { - "line": 64, - "column": 25 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 64, - "column": 13 - }, - "end": { - "line": 64, - "column": 19 - } - } - }, - "init": { - "type": "NumberLiteral", - "value": 60, - "loc": { - "start": { - "line": 64, - "column": 28 - }, - "end": { - "line": 64, - "column": 30 - } - } - }, - "loc": { - "start": { - "line": 64, - "column": 13 - }, - "end": { - "line": 64, - "column": 30 - } - } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 64, - "column": 9 - }, - "end": { - "line": 64, - "column": 31 - } - } - }, - { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "ret", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 65, - "column": 19 - }, - "end": { - "line": 65, - "column": 22 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 65, - "column": 13 - }, - "end": { - "line": 65, - "column": 16 - } - } - }, - "init": { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 65, - "column": 25 - }, - "end": { - "line": 65, - "column": 26 - } - } - }, - "loc": { - "start": { - "line": 65, - "column": 13 - }, - "end": { - "line": 65, - "column": 26 - } - } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 65, - "column": 9 - }, - "end": { - "line": 65, - "column": 27 - } - } - }, - { - "type": "WhileStatement", - "test": { - "type": "BinaryExpression", - "operator": ">", - "left": { - "type": "Identifier", - "name": "n", - "decorators": [], - "loc": { - "start": { - "line": 66, - "column": 15 - }, - "end": { - "line": 66, - "column": 16 - } - } - }, - "right": { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 66, - "column": 19 - }, - "end": { - "line": 66, - "column": 20 - } - } - }, - "loc": { - "start": { - "line": 66, - "column": 15 - }, - "end": { - "line": 66, - "column": 20 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "<", - "left": { - "type": "Identifier", - "name": "n", - "decorators": [], - "loc": { - "start": { - "line": 68, - "column": 17 - }, - "end": { - "line": 68, - "column": 18 - } - } - }, - "right": { - "type": "Identifier", - "name": "lenOut", - "decorators": [], - "loc": { - "start": { - "line": 68, - "column": 21 - }, - "end": { - "line": 68, - "column": 27 - } - } - }, - "loc": { - "start": { - "line": 68, - "column": 17 - }, - "end": { - "line": 68, - "column": 27 - } - } - }, - "consequent": { - "type": "BlockStatement", - "statements": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "lenOut", - "decorators": [], - "loc": { - "start": { - "line": 69, - "column": 17 - }, - "end": { - "line": 69, - "column": 23 - } - } - }, - "right": { - "type": "Identifier", - "name": "n", - "decorators": [], - "loc": { - "start": { - "line": 69, - "column": 26 - }, - "end": { - "line": 69, - "column": 27 - } - } - }, - "loc": { - "start": { - "line": 69, - "column": 17 - }, - "end": { - "line": 69, - "column": 27 - } - } - }, - "loc": { - "start": { - "line": 69, - "column": 17 - }, - "end": { - "line": 69, - "column": 28 - } - } - } - ], - "loc": { - "start": { - "line": 68, - "column": 29 - }, - "end": { - "line": 70, - "column": 14 - } - } - }, - "alternate": null, - "loc": { - "start": { - "line": 68, - "column": 13 - }, - "end": { - "line": 70, - "column": 14 - } - } - }, - { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "<", - "left": { - "type": "BinaryExpression", - "operator": "+", - "left": { - "type": "Identifier", - "name": "seqi", - "decorators": [], - "loc": { - "start": { - "line": 71, - "column": 17 - }, - "end": { - "line": 71, - "column": 21 - } - } - }, - "right": { - "type": "Identifier", - "name": "lenOut", - "decorators": [], - "loc": { - "start": { - "line": 71, - "column": 24 - }, - "end": { - "line": 71, - "column": 30 - } - } - }, - "loc": { - "start": { - "line": 71, - "column": 17 - }, - "end": { - "line": 71, - "column": 30 - } - } - }, - "right": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "seq", - "decorators": [], - "loc": { - "start": { - "line": 71, - "column": 33 - }, - "end": { - "line": 71, - "column": 36 - } - } - }, - "property": { - "type": "Identifier", - "name": "length", - "decorators": [], - "loc": { - "start": { - "line": 71, - "column": 37 - }, - "end": { - "line": 71, - "column": 43 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 71, - "column": 33 - }, - "end": { - "line": 71, - "column": 43 - } - } - }, - "arguments": [], - "optional": false, - "loc": { - "start": { - "line": 71, - "column": 33 - }, - "end": { - "line": 71, - "column": 45 - } - } - }, - "loc": { - "start": { - "line": 71, - "column": 17 - }, - "end": { - "line": 71, - "column": 45 - } - } - }, - "consequent": { - "type": "BlockStatement", - "statements": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "+=", - "left": { - "type": "Identifier", - "name": "ret", - "decorators": [], - "loc": { - "start": { - "line": 72, - "column": 17 - }, - "end": { - "line": 72, - "column": 20 - } - } - }, - "right": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "seq", - "decorators": [], - "loc": { - "start": { - "line": 72, - "column": 24 - }, - "end": { - "line": 72, - "column": 27 - } - } - }, - "property": { - "type": "Identifier", - "name": "substring", - "decorators": [], - "loc": { - "start": { - "line": 72, - "column": 28 - }, - "end": { - "line": 72, - "column": 37 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 72, - "column": 24 - }, - "end": { - "line": 72, - "column": 37 - } - } - }, - "arguments": [ - { - "type": "Identifier", - "name": "seqi", - "decorators": [], - "loc": { - "start": { - "line": 72, - "column": 38 - }, - "end": { - "line": 72, - "column": 42 - } - } - }, - { - "type": "BinaryExpression", - "operator": "+", - "left": { - "type": "Identifier", - "name": "seqi", - "decorators": [], - "loc": { - "start": { - "line": 72, - "column": 44 - }, - "end": { - "line": 72, - "column": 48 - } - } - }, - "right": { - "type": "Identifier", - "name": "lenOut", - "decorators": [], - "loc": { - "start": { - "line": 72, - "column": 51 - }, - "end": { - "line": 72, - "column": 57 - } - } - }, - "loc": { - "start": { - "line": 72, - "column": 44 - }, - "end": { - "line": 72, - "column": 57 - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 72, - "column": 24 - }, - "end": { - "line": 72, - "column": 58 - } - } - }, - "property": { - "type": "Identifier", - "name": "length", - "decorators": [], - "loc": { - "start": { - "line": 72, - "column": 59 - }, - "end": { - "line": 72, - "column": 65 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 72, - "column": 24 - }, - "end": { - "line": 72, - "column": 65 - } - } - }, - "arguments": [], - "optional": false, - "loc": { - "start": { - "line": 72, - "column": 24 - }, - "end": { - "line": 72, - "column": 67 - } - } - }, - "loc": { - "start": { - "line": 72, - "column": 17 - }, - "end": { - "line": 72, - "column": 67 - } - } - }, - "loc": { - "start": { - "line": 72, - "column": 17 - }, - "end": { - "line": 72, - "column": 68 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "+=", - "left": { - "type": "Identifier", - "name": "seqi", - "decorators": [], - "loc": { - "start": { - "line": 73, - "column": 17 - }, - "end": { - "line": 73, - "column": 21 - } - } - }, - "right": { - "type": "Identifier", - "name": "lenOut", - "decorators": [], - "loc": { - "start": { - "line": 73, - "column": 25 - }, - "end": { - "line": 73, - "column": 31 - } - } - }, - "loc": { - "start": { - "line": 73, - "column": 17 - }, - "end": { - "line": 73, - "column": 31 - } - } - }, - "loc": { - "start": { - "line": 73, - "column": 17 - }, - "end": { - "line": 73, - "column": 32 - } - } - } - ], - "loc": { - "start": { - "line": 71, - "column": 47 - }, - "end": { - "line": 74, - "column": 14 - } - } - }, - "alternate": { - "type": "BlockStatement", - "statements": [ - { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "s", - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 76, - "column": 25 - }, - "end": { - "line": 76, - "column": 31 - } - } - }, - "loc": { - "start": { - "line": 76, - "column": 25 - }, - "end": { - "line": 76, - "column": 33 - } - } - }, - "loc": { - "start": { - "line": 76, - "column": 25 - }, - "end": { - "line": 76, - "column": 33 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 76, - "column": 21 - }, - "end": { - "line": 76, - "column": 22 - } - } - }, - "init": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "seq", - "decorators": [], - "loc": { - "start": { - "line": 76, - "column": 34 - }, - "end": { - "line": 76, - "column": 37 - } - } - }, - "property": { - "type": "Identifier", - "name": "substring", - "decorators": [], - "loc": { - "start": { - "line": 76, - "column": 38 - }, - "end": { - "line": 76, - "column": 47 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 76, - "column": 34 - }, - "end": { - "line": 76, - "column": 47 - } - } - }, - "arguments": [ - { - "type": "Identifier", - "name": "seqi", - "decorators": [], - "loc": { - "start": { - "line": 76, - "column": 48 - }, - "end": { - "line": 76, - "column": 52 - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 76, - "column": 34 - }, - "end": { - "line": 76, - "column": 53 - } - } - }, - "loc": { - "start": { - "line": 76, - "column": 21 - }, - "end": { - "line": 76, - "column": 53 - } - } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 76, - "column": 17 - }, - "end": { - "line": 76, - "column": 54 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "seqi", - "decorators": [], - "loc": { - "start": { - "line": 77, - "column": 17 - }, - "end": { - "line": 77, - "column": 21 - } - } - }, - "right": { - "type": "BinaryExpression", - "operator": "-", - "left": { - "type": "Identifier", - "name": "lenOut", - "decorators": [], - "loc": { - "start": { - "line": 77, - "column": 24 - }, - "end": { - "line": 77, - "column": 30 - } - } - }, - "right": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "s", - "decorators": [], - "loc": { - "start": { - "line": 77, - "column": 33 - }, - "end": { - "line": 77, - "column": 34 - } - } - }, - "property": { - "type": "Identifier", - "name": "length", - "decorators": [], - "loc": { - "start": { - "line": 77, - "column": 35 - }, - "end": { - "line": 77, - "column": 41 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 77, - "column": 33 - }, - "end": { - "line": 77, - "column": 41 - } - } - }, - "arguments": [], - "optional": false, - "loc": { - "start": { - "line": 77, - "column": 33 - }, - "end": { - "line": 77, - "column": 43 - } - } - }, - "loc": { - "start": { - "line": 77, - "column": 24 - }, - "end": { - "line": 77, - "column": 43 - } - } - }, - "loc": { - "start": { - "line": 77, - "column": 17 - }, - "end": { - "line": 77, - "column": 43 - } - } - }, - "loc": { - "start": { - "line": 77, - "column": 17 - }, - "end": { - "line": 77, - "column": 44 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "+=", - "left": { - "type": "Identifier", - "name": "ret", - "decorators": [], - "loc": { - "start": { - "line": 78, - "column": 17 - }, - "end": { - "line": 78, - "column": 20 - } - } - }, - "right": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "BinaryExpression", - "operator": "+", - "left": { - "type": "Identifier", - "name": "s", - "decorators": [], - "loc": { - "start": { - "line": 78, - "column": 25 - }, - "end": { - "line": 78, - "column": 26 - } - } - }, - "right": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "seq", - "decorators": [], - "loc": { - "start": { - "line": 78, - "column": 29 - }, - "end": { - "line": 78, - "column": 32 - } - } - }, - "property": { - "type": "Identifier", - "name": "substring", - "decorators": [], - "loc": { - "start": { - "line": 78, - "column": 33 - }, - "end": { - "line": 78, - "column": 42 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 78, - "column": 29 - }, - "end": { - "line": 78, - "column": 42 - } - } - }, - "arguments": [ - { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 78, - "column": 43 - }, - "end": { - "line": 78, - "column": 44 - } - } - }, - { - "type": "Identifier", - "name": "seqi", - "decorators": [], - "loc": { - "start": { - "line": 78, - "column": 46 - }, - "end": { - "line": 78, - "column": 50 - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 78, - "column": 29 - }, - "end": { - "line": 78, - "column": 51 - } - } - }, - "loc": { - "start": { - "line": 78, - "column": 24 - }, - "end": { - "line": 78, - "column": 52 - } - } - }, - "property": { - "type": "Identifier", - "name": "length", - "decorators": [], - "loc": { - "start": { - "line": 78, - "column": 53 - }, - "end": { - "line": 78, - "column": 59 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 78, - "column": 24 - }, - "end": { - "line": 78, - "column": 59 - } - } - }, - "arguments": [], - "optional": false, - "loc": { - "start": { - "line": 78, - "column": 24 - }, - "end": { - "line": 78, - "column": 61 - } - } - }, - "loc": { - "start": { - "line": 78, - "column": 17 - }, - "end": { - "line": 78, - "column": 61 - } - } - }, - "loc": { - "start": { - "line": 78, - "column": 17 - }, - "end": { - "line": 78, - "column": 62 - } - } - } - ], - "loc": { - "start": { - "line": 75, - "column": 18 - }, - "end": { - "line": 79, - "column": 14 - } - } - }, - "loc": { - "start": { - "line": 71, - "column": 13 - }, - "end": { - "line": 79, - "column": 14 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "-=", - "left": { - "type": "Identifier", - "name": "n", - "decorators": [], - "loc": { - "start": { - "line": 80, - "column": 13 - }, - "end": { - "line": 80, - "column": 14 - } - } - }, - "right": { - "type": "Identifier", - "name": "lenOut", - "decorators": [], - "loc": { - "start": { - "line": 80, - "column": 18 - }, - "end": { - "line": 80, - "column": 24 - } - } - }, - "loc": { - "start": { - "line": 80, - "column": 13 - }, - "end": { - "line": 80, - "column": 24 - } - } - }, - "loc": { - "start": { - "line": 80, - "column": 13 - }, - "end": { - "line": 80, - "column": 25 - } - } - } - ], - "loc": { - "start": { - "line": 67, - "column": 9 - }, - "end": { - "line": 81, - "column": 10 - } - } - }, - "loc": { - "start": { - "line": 66, - "column": 9 - }, - "end": { - "line": 81, - "column": 10 - } - } - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "ret", - "decorators": [], - "loc": { - "start": { - "line": 82, - "column": 16 - }, - "end": { - "line": 82, - "column": 19 - } - } - }, - "loc": { - "start": { - "line": 82, - "column": 9 - }, - "end": { - "line": 82, - "column": 20 - } - } - } - ], - "loc": { - "start": { - "line": 62, - "column": 52 - }, - "end": { - "line": 83, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 62, - "column": 23 - }, - "end": { - "line": 83, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 62, - "column": 23 - }, - "end": { - "line": 83, - "column": 6 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 62, - "column": 5 - }, - "end": { - "line": 83, - "column": 6 - } - } - }, - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "fastaRandom", - "decorators": [], - "loc": { - "start": { - "line": 84, - "column": 12 - }, - "end": { - "line": 84, - "column": 23 - } - } - }, - "kind": "method", - "accessibility": "public", - "static": true, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "fastaRandom", - "decorators": [], - "loc": { - "start": { - "line": 84, - "column": 12 - }, - "end": { - "line": 84, - "column": 23 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "Identifier", - "name": "n", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 84, - "column": 28 - }, - "end": { - "line": 84, - "column": 31 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 84, - "column": 24 - }, - "end": { - "line": 84, - "column": 31 - } - } - }, - { - "type": "Identifier", - "name": "table", - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "HashMap", - "decorators": [], - "loc": { - "start": { - "line": 84, - "column": 41 - }, - "end": { - "line": 84, - "column": 48 - } - } - }, - "typeParams": { - "type": "TSTypeParameterInstantiation", - "params": [ - { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Char", - "decorators": [], - "loc": { - "start": { - "line": 84, - "column": 49 - }, - "end": { - "line": 84, - "column": 53 - } - } - }, - "loc": { - "start": { - "line": 84, - "column": 49 - }, - "end": { - "line": 84, - "column": 54 - } - } - }, - "loc": { - "start": { - "line": 84, - "column": 49 - }, - "end": { - "line": 84, - "column": 54 - } - } - }, - { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Double", - "decorators": [], - "loc": { - "start": { - "line": 84, - "column": 55 - }, - "end": { - "line": 84, - "column": 61 - } - } - }, - "loc": { - "start": { - "line": 84, - "column": 55 - }, - "end": { - "line": 84, - "column": 62 - } - } - }, - "loc": { - "start": { - "line": 84, - "column": 55 - }, - "end": { - "line": 84, - "column": 62 - } - } - } - ], - "loc": { - "start": { - "line": 84, - "column": 48 - }, - "end": { - "line": 84, - "column": 62 - } - } - }, - "loc": { - "start": { - "line": 84, - "column": 41 - }, - "end": { - "line": 84, - "column": 63 - } - } - }, - "loc": { - "start": { - "line": 84, - "column": 41 - }, - "end": { - "line": 84, - "column": 63 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 84, - "column": 33 - }, - "end": { - "line": 84, - "column": 63 - } - } - } - ], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 84, - "column": 65 - }, - "end": { - "line": 84, - "column": 68 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "line", - "typeAnnotation": { - "type": "TSArrayType", - "elementType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 85, - "column": 20 - }, - "end": { - "line": 85, - "column": 24 - } - } - }, - "loc": { - "start": { - "line": 85, - "column": 27 - }, - "end": { - "line": 85, - "column": 28 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 85, - "column": 13 - }, - "end": { - "line": 85, - "column": 17 - } - } - }, - "init": { - "type": "ETSNewArrayInstanceExpression", - "typeReference": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 85, - "column": 33 - }, - "end": { - "line": 85, - "column": 37 - } - } - }, - "dimension": { - "type": "NumberLiteral", - "value": 60, - "loc": { - "start": { - "line": 85, - "column": 38 - }, - "end": { - "line": 85, - "column": 40 - } - } - }, - "loc": { - "start": { - "line": 85, - "column": 29 - }, - "end": { - "line": 85, - "column": 41 - } - } - }, - "loc": { - "start": { - "line": 85, - "column": 13 - }, - "end": { - "line": 85, - "column": 41 - } - } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 85, - "column": 9 - }, - "end": { - "line": 85, - "column": 42 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "makeCumulative", - "decorators": [], - "loc": { - "start": { - "line": 86, - "column": 9 - }, - "end": { - "line": 86, - "column": 23 - } - } - }, - "arguments": [ - { - "type": "Identifier", - "name": "table", - "decorators": [], - "loc": { - "start": { - "line": 86, - "column": 24 - }, - "end": { - "line": 86, - "column": 29 - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 86, - "column": 9 - }, - "end": { - "line": 86, - "column": 30 - } - } - }, - "loc": { - "start": { - "line": 86, - "column": 9 - }, - "end": { - "line": 86, - "column": 31 - } - } - }, - { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "ret", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 87, - "column": 19 - }, - "end": { - "line": 87, - "column": 22 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 87, - "column": 13 - }, - "end": { - "line": 87, - "column": 16 - } - } - }, - "init": { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 87, - "column": 25 - }, - "end": { - "line": 87, - "column": 26 - } - } - }, - "loc": { - "start": { - "line": 87, - "column": 13 - }, - "end": { - "line": 87, - "column": 26 - } - } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 87, - "column": 9 - }, - "end": { - "line": 87, - "column": 27 - } - } - }, - { - "type": "WhileStatement", - "test": { - "type": "BinaryExpression", - "operator": ">", - "left": { - "type": "Identifier", - "name": "n", - "decorators": [], - "loc": { - "start": { - "line": 88, - "column": 15 - }, - "end": { - "line": 88, - "column": 16 - } - } - }, - "right": { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 88, - "column": 19 - }, - "end": { - "line": 88, - "column": 20 - } - } - }, - "loc": { - "start": { - "line": 88, - "column": 15 - }, - "end": { - "line": 88, - "column": 20 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "<", - "left": { - "type": "Identifier", - "name": "n", - "decorators": [], - "loc": { - "start": { - "line": 90, - "column": 17 - }, - "end": { - "line": 90, - "column": 18 - } - } - }, - "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "line", - "decorators": [], - "loc": { - "start": { - "line": 90, - "column": 21 - }, - "end": { - "line": 90, - "column": 25 - } - } - }, - "property": { - "type": "Identifier", - "name": "length", - "decorators": [], - "loc": { - "start": { - "line": 90, - "column": 26 - }, - "end": { - "line": 90, - "column": 32 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 90, - "column": 21 - }, - "end": { - "line": 90, - "column": 32 - } - } - }, - "loc": { - "start": { - "line": 90, - "column": 17 - }, - "end": { - "line": 90, - "column": 32 - } - } - }, - "consequent": { - "type": "BlockStatement", - "statements": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "line", - "decorators": [], - "loc": { - "start": { - "line": 91, - "column": 17 - }, - "end": { - "line": 91, - "column": 21 - } - } - }, - "right": { - "type": "ETSNewArrayInstanceExpression", - "typeReference": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 91, - "column": 28 - }, - "end": { - "line": 91, - "column": 32 - } - } - }, - "dimension": { - "type": "Identifier", - "name": "n", - "decorators": [], - "loc": { - "start": { - "line": 91, - "column": 33 - }, - "end": { - "line": 91, - "column": 34 - } - } - }, - "loc": { - "start": { - "line": 91, - "column": 24 - }, - "end": { - "line": 91, - "column": 35 - } - } - }, - "loc": { - "start": { - "line": 91, - "column": 17 - }, - "end": { - "line": 91, - "column": 35 - } - } - }, - "loc": { - "start": { - "line": 91, - "column": 17 - }, - "end": { - "line": 91, - "column": 36 - } - } - } - ], - "loc": { - "start": { - "line": 90, - "column": 34 - }, - "end": { - "line": 92, - "column": 14 - } - } - }, - "alternate": null, - "loc": { - "start": { - "line": 90, - "column": 13 - }, - "end": { - "line": 92, - "column": 14 - } - } - }, - { - "type": "ForUpdateStatement", - "init": { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "i", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 93, - "column": 26 - }, - "end": { - "line": 93, - "column": 29 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 93, - "column": 22 - }, - "end": { - "line": 93, - "column": 23 - } - } - }, - "init": { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 93, - "column": 32 - }, - "end": { - "line": 93, - "column": 33 - } - } - }, - "loc": { - "start": { - "line": 93, - "column": 22 - }, - "end": { - "line": 93, - "column": 33 - } - } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 93, - "column": 18 - }, - "end": { - "line": 93, - "column": 33 - } - } - }, - "test": { - "type": "BinaryExpression", - "operator": "<", - "left": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 93, - "column": 35 - }, - "end": { - "line": 93, - "column": 36 - } - } - }, - "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "line", - "decorators": [], - "loc": { - "start": { - "line": 93, - "column": 39 - }, - "end": { - "line": 93, - "column": 43 - } - } - }, - "property": { - "type": "Identifier", - "name": "length", - "decorators": [], - "loc": { - "start": { - "line": 93, - "column": 44 - }, - "end": { - "line": 93, - "column": 50 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 93, - "column": 39 - }, - "end": { - "line": 93, - "column": 50 - } - } - }, - "loc": { - "start": { - "line": 93, - "column": 35 - }, - "end": { - "line": 93, - "column": 50 - } - } - }, - "update": { - "type": "UpdateExpression", - "operator": "++", - "prefix": false, - "argument": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 93, - "column": 52 - }, - "end": { - "line": 93, - "column": 53 - } - } - }, - "loc": { - "start": { - "line": 93, - "column": 52 - }, - "end": { - "line": 93, - "column": 55 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "r", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 94, - "column": 25 - }, - "end": { - "line": 94, - "column": 31 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 94, - "column": 21 - }, - "end": { - "line": 94, - "column": 22 - } - } - }, - "init": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "Random", - "decorators": [], - "loc": { - "start": { - "line": 94, - "column": 34 - }, - "end": { - "line": 94, - "column": 40 - } - } - }, - "property": { - "type": "Identifier", - "name": "rand", - "decorators": [], - "loc": { - "start": { - "line": 94, - "column": 41 - }, - "end": { - "line": 94, - "column": 45 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 94, - "column": 34 - }, - "end": { - "line": 94, - "column": 45 - } - } - }, - "arguments": [ - { - "type": "NumberLiteral", - "value": 1, - "loc": { - "start": { - "line": 94, - "column": 46 - }, - "end": { - "line": 94, - "column": 47 - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 94, - "column": 34 - }, - "end": { - "line": 94, - "column": 48 - } - } - }, - "loc": { - "start": { - "line": 94, - "column": 21 - }, - "end": { - "line": 94, - "column": 48 - } - } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 94, - "column": 17 - }, - "end": { - "line": 94, - "column": 49 - } - } - }, - { - "type": "ForOfStatement", - "await": false, - "left": { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "entry", - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "TSQualifiedName", - "left": { - "type": "Identifier", - "name": "HashMap", - "decorators": [], - "loc": { - "start": { - "line": 95, - "column": 34 - }, - "end": { - "line": 95, - "column": 41 - } - } - }, - "right": { - "type": "Identifier", - "name": "Entry", - "decorators": [], - "loc": { - "start": { - "line": 95, - "column": 42 - }, - "end": { - "line": 95, - "column": 47 - } - } - }, - "loc": { - "start": { - "line": 95, - "column": 34 - }, - "end": { - "line": 95, - "column": 48 - } - } - }, - "typeParams": { - "type": "TSTypeParameterInstantiation", - "params": [ - { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Char", - "decorators": [], - "loc": { - "start": { - "line": 95, - "column": 48 - }, - "end": { - "line": 95, - "column": 52 - } - } - }, - "loc": { - "start": { - "line": 95, - "column": 48 - }, - "end": { - "line": 95, - "column": 53 - } - } - }, - "loc": { - "start": { - "line": 95, - "column": 48 - }, - "end": { - "line": 95, - "column": 53 - } - } - }, - { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Double", - "decorators": [], - "loc": { - "start": { - "line": 95, - "column": 54 - }, - "end": { - "line": 95, - "column": 60 - } - } - }, - "loc": { - "start": { - "line": 95, - "column": 54 - }, - "end": { - "line": 95, - "column": 61 - } - } - }, - "loc": { - "start": { - "line": 95, - "column": 54 - }, - "end": { - "line": 95, - "column": 61 - } - } - } - ], - "loc": { - "start": { - "line": 95, - "column": 47 - }, - "end": { - "line": 95, - "column": 61 - } - } - }, - "loc": { - "start": { - "line": 95, - "column": 34 - }, - "end": { - "line": 95, - "column": 64 - } - } - }, - "loc": { - "start": { - "line": 95, - "column": 34 - }, - "end": { - "line": 95, - "column": 64 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 95, - "column": 26 - }, - "end": { - "line": 95, - "column": 31 - } - } - }, - "init": null, - "loc": { - "start": { - "line": 95, - "column": 26 - }, - "end": { - "line": 95, - "column": 31 - } - } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 95, - "column": 22 - }, - "end": { - "line": 95, - "column": 31 - } - } - }, - "right": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "table", - "decorators": [], - "loc": { - "start": { - "line": 95, - "column": 65 - }, - "end": { - "line": 95, - "column": 70 - } - } - }, - "property": { - "type": "Identifier", - "name": "entrySet", - "decorators": [], - "loc": { - "start": { - "line": 95, - "column": 71 - }, - "end": { - "line": 95, - "column": 79 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 95, - "column": 65 - }, - "end": { - "line": 95, - "column": 79 - } - } - }, - "arguments": [], - "optional": false, - "loc": { - "start": { - "line": 95, - "column": 65 - }, - "end": { - "line": 95, - "column": 81 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "c", - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "Char", - "decorators": [], - "loc": { - "start": { - "line": 96, - "column": 29 - }, - "end": { - "line": 96, - "column": 33 - } - } - }, - "loc": { - "start": { - "line": 96, - "column": 29 - }, - "end": { - "line": 96, - "column": 35 - } - } - }, - "loc": { - "start": { - "line": 96, - "column": 29 - }, - "end": { - "line": 96, - "column": 35 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 96, - "column": 25 - }, - "end": { - "line": 96, - "column": 26 - } - } - }, - "init": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "entry", - "decorators": [], - "loc": { - "start": { - "line": 96, - "column": 36 - }, - "end": { - "line": 96, - "column": 41 - } - } - }, - "property": { - "type": "Identifier", - "name": "getKey", - "decorators": [], - "loc": { - "start": { - "line": 96, - "column": 42 - }, - "end": { - "line": 96, - "column": 48 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 96, - "column": 36 - }, - "end": { - "line": 96, - "column": 48 - } - } - }, - "arguments": [], - "optional": false, - "loc": { - "start": { - "line": 96, - "column": 36 - }, - "end": { - "line": 96, - "column": 50 - } - } - }, - "loc": { - "start": { - "line": 96, - "column": 25 - }, - "end": { - "line": 96, - "column": 50 - } - } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 96, - "column": 21 - }, - "end": { - "line": 96, - "column": 51 - } - } - }, - { - "type": "IfStatement", - "test": { - "type": "BinaryExpression", - "operator": "<", - "left": { - "type": "Identifier", - "name": "r", - "decorators": [], - "loc": { - "start": { - "line": 97, - "column": 25 - }, - "end": { - "line": 97, - "column": 26 - } - } - }, - "right": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "entry", - "decorators": [], - "loc": { - "start": { - "line": 97, - "column": 29 - }, - "end": { - "line": 97, - "column": 34 - } - } - }, - "property": { - "type": "Identifier", - "name": "getValue", - "decorators": [], - "loc": { - "start": { - "line": 97, - "column": 35 - }, - "end": { - "line": 97, - "column": 43 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 97, - "column": 29 - }, - "end": { - "line": 97, - "column": 43 - } - } - }, - "arguments": [], - "optional": false, - "loc": { - "start": { - "line": 97, - "column": 29 - }, - "end": { - "line": 97, - "column": 45 - } - } - }, - "loc": { - "start": { - "line": 97, - "column": 25 - }, - "end": { - "line": 97, - "column": 45 - } - } - }, - "consequent": { - "type": "BlockStatement", - "statements": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "line", - "decorators": [], - "loc": { - "start": { - "line": 98, - "column": 25 - }, - "end": { - "line": 98, - "column": 29 - } - } - }, - "property": { - "type": "Identifier", - "name": "i", - "decorators": [], - "loc": { - "start": { - "line": 98, - "column": 30 - }, - "end": { - "line": 98, - "column": 31 - } - } - }, - "computed": true, - "optional": false, - "loc": { - "start": { - "line": 98, - "column": 25 - }, - "end": { - "line": 98, - "column": 32 - } - } - }, - "right": { - "type": "Identifier", - "name": "c", - "decorators": [], - "loc": { - "start": { - "line": 98, - "column": 35 - }, - "end": { - "line": 98, - "column": 36 - } - } - }, - "loc": { - "start": { - "line": 98, - "column": 25 - }, - "end": { - "line": 98, - "column": 36 - } - } - }, - "loc": { - "start": { - "line": 98, - "column": 25 - }, - "end": { - "line": 98, - "column": 37 - } - } - }, - { - "type": "BreakStatement", - "label": null, - "loc": { - "start": { - "line": 99, - "column": 25 - }, - "end": { - "line": 99, - "column": 31 - } - } - } - ], - "loc": { - "start": { - "line": 97, - "column": 47 - }, - "end": { - "line": 100, - "column": 22 - } - } - }, - "alternate": null, - "loc": { - "start": { - "line": 97, - "column": 21 - }, - "end": { - "line": 100, - "column": 22 - } - } - } - ], - "loc": { - "start": { - "line": 95, - "column": 82 - }, - "end": { - "line": 101, - "column": 18 - } - } - }, - "loc": { - "start": { - "line": 95, - "column": 17 - }, - "end": { - "line": 101, - "column": 18 - } - } - } - ], - "loc": { - "start": { - "line": 93, - "column": 57 - }, - "end": { - "line": 102, - "column": 14 - } - } - }, - "loc": { - "start": { - "line": 93, - "column": 13 - }, - "end": { - "line": 102, - "column": 14 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "+=", - "left": { - "type": "Identifier", - "name": "ret", - "decorators": [], - "loc": { - "start": { - "line": 103, - "column": 13 - }, - "end": { - "line": 103, - "column": 16 - } - } - }, - "right": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 103, - "column": 24 - }, - "end": { - "line": 103, - "column": 30 - } - } - }, - "loc": { - "start": { - "line": 103, - "column": 24 - }, - "end": { - "line": 103, - "column": 31 - } - } - }, - "loc": { - "start": { - "line": 103, - "column": 24 - }, - "end": { - "line": 103, - "column": 31 - } - } - }, - "arguments": [ - { - "type": "Identifier", - "name": "line", - "decorators": [], - "loc": { - "start": { - "line": 103, - "column": 31 - }, - "end": { - "line": 103, - "column": 35 - } - } - } - ], - "loc": { - "start": { - "line": 103, - "column": 20 - }, - "end": { - "line": 103, - "column": 37 - } - } - }, - "property": { - "type": "Identifier", - "name": "length", - "decorators": [], - "loc": { - "start": { - "line": 103, - "column": 37 - }, - "end": { - "line": 103, - "column": 43 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 103, - "column": 20 - }, - "end": { - "line": 103, - "column": 43 - } - } - }, - "arguments": [], - "optional": false, - "loc": { - "start": { - "line": 103, - "column": 20 - }, - "end": { - "line": 103, - "column": 45 - } - } - }, - "loc": { - "start": { - "line": 103, - "column": 13 - }, - "end": { - "line": 103, - "column": 45 - } - } - }, - "loc": { - "start": { - "line": 103, - "column": 13 - }, - "end": { - "line": 103, - "column": 46 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "-=", - "left": { - "type": "Identifier", - "name": "n", - "decorators": [], - "loc": { - "start": { - "line": 104, - "column": 13 - }, - "end": { - "line": 104, - "column": 14 - } - } - }, - "right": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "line", - "decorators": [], - "loc": { - "start": { - "line": 104, - "column": 18 - }, - "end": { - "line": 104, - "column": 22 - } - } - }, - "property": { - "type": "Identifier", - "name": "length", - "decorators": [], - "loc": { - "start": { - "line": 104, - "column": 23 - }, - "end": { - "line": 104, - "column": 29 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 104, - "column": 18 - }, - "end": { - "line": 104, - "column": 29 - } - } - }, - "loc": { - "start": { - "line": 104, - "column": 13 - }, - "end": { - "line": 104, - "column": 29 - } - } - }, - "loc": { - "start": { - "line": 104, - "column": 13 - }, - "end": { - "line": 104, - "column": 30 - } - } - } - ], - "loc": { - "start": { - "line": 89, - "column": 9 - }, - "end": { - "line": 105, - "column": 10 - } - } - }, - "loc": { - "start": { - "line": 88, - "column": 9 - }, - "end": { - "line": 105, - "column": 10 - } - } - }, - { - "type": "ReturnStatement", - "argument": { - "type": "Identifier", - "name": "ret", - "decorators": [], - "loc": { - "start": { - "line": 106, - "column": 16 - }, - "end": { - "line": 106, - "column": 19 - } - } - }, - "loc": { - "start": { - "line": 106, - "column": 9 - }, - "end": { - "line": 106, - "column": 20 - } - } - } - ], - "loc": { - "start": { - "line": 84, - "column": 69 - }, - "end": { - "line": 107, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 84, - "column": 23 - }, - "end": { - "line": 107, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 84, - "column": 23 - }, - "end": { - "line": 107, - "column": 6 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 84, - "column": 5 - }, - "end": { - "line": 107, - "column": 6 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "count", - "decorators": [], - "loc": { - "start": { - "line": 108, - "column": 5 - }, - "end": { - "line": 108, - "column": 10 - } - } - }, - "value": { - "type": "NumberLiteral", - "value": 7, - "loc": { - "start": { - "line": 108, - "column": 19 - }, - "end": { - "line": 108, - "column": 20 - } - } - }, - "accessibility": "public", - "static": false, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 108, - "column": 13 - }, - "end": { - "line": 108, - "column": 16 - } - } - }, - "definite": false, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "expected", - "decorators": [], - "loc": { - "start": { - "line": 109, - "column": 21 - }, - "end": { - "line": 109, - "column": 29 - } - } - }, - "value": { - "type": "NumberLiteral", - "value": 1456000, - "loc": { - "start": { - "line": 109, - "column": 38 - }, - "end": { - "line": 109, - "column": 45 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 109, - "column": 32 - }, - "end": { - "line": 109, - "column": 35 - } - } - }, - "definite": false, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "run", - "decorators": [], - "loc": { - "start": { - "line": 110, - "column": 17 - }, - "end": { - "line": 110, - "column": 20 - } - } - }, - "kind": "method", - "accessibility": "public", - "static": false, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "run", - "decorators": [], - "loc": { - "start": { - "line": 110, - "column": 17 - }, - "end": { - "line": 110, - "column": 20 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 110, - "column": 24 - }, - "end": { - "line": 110, - "column": 28 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "ret", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 111, - "column": 19 - }, - "end": { - "line": 111, - "column": 22 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 111, - "column": 13 - }, - "end": { - "line": 111, - "column": 16 - } - } - }, - "init": { - "type": "NumberLiteral", - "value": 0, - "loc": { - "start": { - "line": 111, - "column": 25 - }, - "end": { - "line": 111, - "column": 26 - } - } - }, - "loc": { - "start": { - "line": 111, - "column": 13 - }, - "end": { - "line": 111, - "column": 26 - } - } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 111, - "column": 9 - }, - "end": { - "line": 111, - "column": 27 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "+=", - "left": { - "type": "Identifier", - "name": "ret", - "decorators": [], - "loc": { - "start": { - "line": 112, - "column": 9 - }, - "end": { - "line": 112, - "column": 12 - } - } - }, - "right": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "fastaRepeat", - "decorators": [], - "loc": { - "start": { - "line": 112, - "column": 16 - }, - "end": { - "line": 112, - "column": 27 - } - } - }, - "arguments": [ - { - "type": "BinaryExpression", - "operator": "*", - "left": { - "type": "BinaryExpression", - "operator": "*", - "left": { - "type": "NumberLiteral", - "value": 2, - "loc": { - "start": { - "line": 112, - "column": 28 - }, - "end": { - "line": 112, - "column": 29 - } - } - }, - "right": { - "type": "Identifier", - "name": "count", - "decorators": [], - "loc": { - "start": { - "line": 112, - "column": 32 - }, - "end": { - "line": 112, - "column": 37 - } - } - }, - "loc": { - "start": { - "line": 112, - "column": 28 - }, - "end": { - "line": 112, - "column": 37 - } - } - }, - "right": { - "type": "NumberLiteral", - "value": 100000, - "loc": { - "start": { - "line": 112, - "column": 40 - }, - "end": { - "line": 112, - "column": 46 - } - } - }, - "loc": { - "start": { - "line": 112, - "column": 28 - }, - "end": { - "line": 112, - "column": 46 - } - } - }, - { - "type": "Identifier", - "name": "ALU", - "decorators": [], - "loc": { - "start": { - "line": 112, - "column": 48 - }, - "end": { - "line": 112, - "column": 51 - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 112, - "column": 16 - }, - "end": { - "line": 112, - "column": 52 - } - } - }, - "loc": { - "start": { - "line": 112, - "column": 9 - }, - "end": { - "line": 112, - "column": 52 - } - } - }, - "loc": { - "start": { - "line": 112, - "column": 9 - }, - "end": { - "line": 112, - "column": 53 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "+=", - "left": { - "type": "Identifier", - "name": "ret", - "decorators": [], - "loc": { - "start": { - "line": 113, - "column": 9 - }, - "end": { - "line": 113, - "column": 12 - } - } - }, - "right": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "fastaRandom", - "decorators": [], - "loc": { - "start": { - "line": 113, - "column": 16 - }, - "end": { - "line": 113, - "column": 27 - } - } - }, - "arguments": [ - { - "type": "BinaryExpression", - "operator": "*", - "left": { - "type": "BinaryExpression", - "operator": "*", - "left": { - "type": "NumberLiteral", - "value": 3, - "loc": { - "start": { - "line": 113, - "column": 28 - }, - "end": { - "line": 113, - "column": 29 - } - } - }, - "right": { - "type": "Identifier", - "name": "count", - "decorators": [], - "loc": { - "start": { - "line": 113, - "column": 32 - }, - "end": { - "line": 113, - "column": 37 - } - } - }, - "loc": { - "start": { - "line": 113, - "column": 28 - }, - "end": { - "line": 113, - "column": 37 - } - } - }, - "right": { - "type": "NumberLiteral", - "value": 1000, - "loc": { - "start": { - "line": 113, - "column": 40 - }, - "end": { - "line": 113, - "column": 44 - } - } - }, - "loc": { - "start": { - "line": 113, - "column": 28 - }, - "end": { - "line": 113, - "column": 44 - } - } - }, - { - "type": "Identifier", - "name": "IUB", - "decorators": [], - "loc": { - "start": { - "line": 113, - "column": 46 - }, - "end": { - "line": 113, - "column": 49 - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 113, - "column": 16 - }, - "end": { - "line": 113, - "column": 50 - } - } - }, - "loc": { - "start": { - "line": 113, - "column": 9 - }, - "end": { - "line": 113, - "column": 50 - } - } - }, - "loc": { - "start": { - "line": 113, - "column": 9 - }, - "end": { - "line": 113, - "column": 51 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "+=", - "left": { - "type": "Identifier", - "name": "ret", - "decorators": [], - "loc": { - "start": { - "line": 114, - "column": 9 - }, - "end": { - "line": 114, - "column": 12 - } - } - }, - "right": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "fastaRandom", - "decorators": [], - "loc": { - "start": { - "line": 114, - "column": 16 - }, - "end": { - "line": 114, - "column": 27 - } - } - }, - "arguments": [ - { - "type": "BinaryExpression", - "operator": "*", - "left": { - "type": "BinaryExpression", - "operator": "*", - "left": { - "type": "NumberLiteral", - "value": 5, - "loc": { - "start": { - "line": 114, - "column": 28 - }, - "end": { - "line": 114, - "column": 29 - } - } - }, - "right": { - "type": "Identifier", - "name": "count", - "decorators": [], - "loc": { - "start": { - "line": 114, - "column": 32 - }, - "end": { - "line": 114, - "column": 37 - } - } - }, - "loc": { - "start": { - "line": 114, - "column": 28 - }, - "end": { - "line": 114, - "column": 37 - } - } - }, - "right": { - "type": "NumberLiteral", - "value": 1000, - "loc": { - "start": { - "line": 114, - "column": 40 - }, - "end": { - "line": 114, - "column": 44 - } - } - }, - "loc": { - "start": { - "line": 114, - "column": 28 - }, - "end": { - "line": 114, - "column": 44 - } - } - }, - { - "type": "Identifier", - "name": "HomoSap", - "decorators": [], - "loc": { - "start": { - "line": 114, - "column": 46 - }, - "end": { - "line": 114, - "column": 53 - } - } - } - ], - "optional": false, - "loc": { - "start": { - "line": 114, - "column": 16 - }, - "end": { - "line": 114, - "column": 54 - } - } - }, - "loc": { - "start": { - "line": 114, - "column": 9 - }, - "end": { - "line": 114, - "column": 54 - } - } - }, - "loc": { - "start": { - "line": 114, - "column": 9 - }, - "end": { - "line": 114, - "column": 55 - } - } - }, - { - "type": "AssertStatement", - "test": { - "type": "BinaryExpression", - "operator": "==", - "left": { - "type": "Identifier", - "name": "ret", - "decorators": [], - "loc": { - "start": { - "line": 116, - "column": 16 - }, - "end": { - "line": 116, - "column": 19 - } - } - }, - "right": { - "type": "MemberExpression", - "object": { - "type": "ThisExpression", - "loc": { - "start": { - "line": 116, - "column": 23 - }, - "end": { - "line": 116, - "column": 27 - } - } - }, - "property": { - "type": "Identifier", - "name": "expected", - "decorators": [], - "loc": { - "start": { - "line": 116, - "column": 28 - }, - "end": { - "line": 116, - "column": 36 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 116, - "column": 23 - }, - "end": { - "line": 116, - "column": 36 - } - } - }, - "loc": { - "start": { - "line": 116, - "column": 16 - }, - "end": { - "line": 116, - "column": 36 - } - } - }, - "second": { - "type": "StringLiteral", - "value": "Incorrect result", - "loc": { - "start": { - "line": 116, - "column": 38 - }, - "end": { - "line": 116, - "column": 56 - } - } - }, - "loc": { - "start": { - "line": 116, - "column": 9 - }, - "end": { - "line": 116, - "column": 57 - } - } - } - ], - "loc": { - "start": { - "line": 110, - "column": 29 - }, - "end": { - "line": 117, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 110, - "column": 20 - }, - "end": { - "line": 117, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 110, - "column": 20 - }, - "end": { - "line": 117, - "column": 6 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 110, - "column": 5 - }, - "end": { - "line": 117, - "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": 118, - "column": 2 - }, - "end": { - "line": 118, - "column": 2 - } - } - } - ], - "loc": { - "start": { - "line": 16, - "column": 32 - }, - "end": { - "line": 118, - "column": 2 - } - } - }, - "loc": { - "start": { - "line": 16, - "column": 13 - }, - "end": { - "line": 118, - "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": 120, - "column": 10 - }, - "end": { - "line": 120, - "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": 120, - "column": 10 - }, - "end": { - "line": 120, - "column": 14 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 120, - "column": 18 - }, - "end": { - "line": 120, - "column": 22 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "a", - "decorators": [], - "loc": { - "start": { - "line": 121, - "column": 7 - }, - "end": { - "line": 121, - "column": 8 - } - } - }, - "init": { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "StringFasta", - "decorators": [], - "loc": { - "start": { - "line": 121, - "column": 15 - }, - "end": { - "line": 121, - "column": 26 - } - } - }, - "loc": { - "start": { - "line": 121, - "column": 15 - }, - "end": { - "line": 121, - "column": 27 - } - } - }, - "loc": { - "start": { - "line": 121, - "column": 15 - }, - "end": { - "line": 121, - "column": 27 - } - } - }, - "arguments": [], - "loc": { - "start": { - "line": 121, - "column": 11 - }, - "end": { - "line": 121, - "column": 27 - } - } - }, - "loc": { - "start": { - "line": 121, - "column": 7 - }, - "end": { - "line": 121, - "column": 27 - } - } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 121, - "column": 3 - }, - "end": { - "line": 121, - "column": 27 - } - } - }, - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "a", - "decorators": [], - "loc": { - "start": { - "line": 122, - "column": 3 - }, - "end": { - "line": 122, - "column": 4 - } - } - }, - "property": { - "type": "Identifier", - "name": "run", - "decorators": [], - "loc": { - "start": { - "line": 122, - "column": 5 - }, - "end": { - "line": 122, - "column": 8 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 122, - "column": 3 - }, - "end": { - "line": 122, - "column": 8 - } - } - }, - "arguments": [], - "optional": false, - "loc": { - "start": { - "line": 122, - "column": 3 - }, - "end": { - "line": 122, - "column": 10 - } - } - }, - "loc": { - "start": { - "line": 122, - "column": 3 - }, - "end": { - "line": 122, - "column": 11 - } - } - } - ], - "loc": { - "start": { - "line": 120, - "column": 23 - }, - "end": { - "line": 123, - "column": 2 - } - } - }, - "loc": { - "start": { - "line": 120, - "column": 14 - }, - "end": { - "line": 123, - "column": 2 - } - } - }, - "loc": { - "start": { - "line": 120, - "column": 14 - }, - "end": { - "line": 123, - "column": 2 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 120, - "column": 1 - }, - "end": { - "line": 123, - "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": 124, - "column": 1 - } - } -} -SyntaxError: Cannot find type 'HashMap'. [StringFasta.ets:18:46] +SyntaxError: Local type declaration (class, struct, interface and enum) support is not yet implemented. [StringFasta.ets:41:12] diff --git a/ets2panda/test/parser/ets/class_interface_enum_only_top_level_4-expected.txt b/ets2panda/test/parser/ets/class_interface_enum_only_top_level_4-expected.txt index 5c83602e3c..5445391d65 100644 --- a/ets2panda/test/parser/ets/class_interface_enum_only_top_level_4-expected.txt +++ b/ets2panda/test/parser/ets/class_interface_enum_only_top_level_4-expected.txt @@ -1 +1,469 @@ -SyntaxError: Local interface declaration support is not yet implemented. [class_interface_enum_only_top_level_4.ets:18:3] +{ + "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": "main", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 10 + }, + "end": { + "line": 16, + "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": 16, + "column": 10 + }, + "end": { + "line": 16, + "column": 14 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "void", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 19 + }, + "end": { + "line": 16, + "column": 23 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 19 + }, + "end": { + "line": 17, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 19 + }, + "end": { + "line": 17, + "column": 2 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "TSInterfaceDeclaration", + "body": { + "type": "TSInterfaceBody", + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "foo", + "decorators": [], + "loc": { + "start": { + "line": 19, + "column": 5 + }, + "end": { + "line": 19, + "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": 19, + "column": 5 + }, + "end": { + "line": 19, + "column": 8 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "a", + "typeAnnotation": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 19, + "column": 12 + }, + "end": { + "line": 19, + "column": 15 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 19, + "column": 9 + }, + "end": { + "line": 19, + "column": 15 + } + } + }, + "loc": { + "start": { + "line": 19, + "column": 9 + }, + "end": { + "line": 19, + "column": 15 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 19, + "column": 18 + }, + "end": { + "line": 19, + "column": 21 + } + } + }, + "declare": true, + "loc": { + "start": { + "line": 19, + "column": 8 + }, + "end": { + "line": 19, + "column": 21 + } + } + }, + "loc": { + "start": { + "line": 19, + "column": 8 + }, + "end": { + "line": 19, + "column": 21 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 19, + "column": 5 + }, + "end": { + "line": 19, + "column": 22 + } + } + } + ], + "loc": { + "start": { + "line": 18, + "column": 15 + }, + "end": { + "line": 20, + "column": 4 + } + } + }, + "id": { + "type": "Identifier", + "name": "C", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 13 + }, + "end": { + "line": 18, + "column": 14 + } + } + }, + "extends": [], + "loc": { + "start": { + "line": 18, + "column": 3 + }, + "end": { + "line": 21, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 17, + "column": 1 + }, + "end": { + "line": 21, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 14 + }, + "end": { + "line": 21, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 14 + }, + "end": { + "line": 21, + "column": 2 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 1 + }, + "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/class_property_access-expected.txt b/ets2panda/test/parser/ets/class_property_access-expected.txt index b10c7fcfb9..0d95692993 100644 --- a/ets2panda/test/parser/ets/class_property_access-expected.txt +++ b/ets2panda/test/parser/ets/class_property_access-expected.txt @@ -1,785 +1 @@ -{ - "type": "Program", - "statements": [ - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "outer", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 7 - }, - "end": { - "line": 16, - "column": 12 - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "foo", - "decorators": [], - "loc": { - "start": { - "line": 17, - "column": 10 - }, - "end": { - "line": 17, - "column": 13 - } - } - }, - "value": { - "type": "NumberLiteral", - "value": 1, - "loc": { - "start": { - "line": 17, - "column": 24 - }, - "end": { - "line": 17, - "column": 27 - } - } - }, - "accessibility": "public", - "static": true, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 17, - "column": 15 - }, - "end": { - "line": 17, - "column": 21 - } - } - }, - "definite": false, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "inner", - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 9 - }, - "end": { - "line": 18, - "column": 14 - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "getFoo", - "decorators": [], - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 11 - } - } - }, - "kind": "method", - "accessibility": "public", - "static": false, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "getFoo", - "decorators": [], - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 19, - "column": 11 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 19, - "column": 15 - }, - "end": { - "line": 19, - "column": 21 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "outer", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 16 - }, - "end": { - "line": 20, - "column": 21 - } - } - }, - "property": { - "type": "Identifier", - "name": "foo", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 22 - }, - "end": { - "line": 20, - "column": 25 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 20, - "column": 16 - }, - "end": { - "line": 20, - "column": 25 - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 9 - }, - "end": { - "line": 20, - "column": 26 - } - } - } - ], - "loc": { - "start": { - "line": 19, - "column": 22 - }, - "end": { - "line": 21, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 19, - "column": 11 - }, - "end": { - "line": 21, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 19, - "column": 11 - }, - "end": { - "line": 21, - "column": 6 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 19, - "column": 5 - }, - "end": { - "line": 21, - "column": 6 - } - } - }, - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "setFoo", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 5 - }, - "end": { - "line": 22, - "column": 11 - } - } - }, - "kind": "method", - "accessibility": "public", - "static": false, - "optional": false, - "computed": false, - "value": { - "type": "FunctionExpression", - "function": { - "type": "ScriptFunction", - "id": { - "type": "Identifier", - "name": "setFoo", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 5 - }, - "end": { - "line": 22, - "column": 11 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [ - { - "type": "Identifier", - "name": "arg", - "typeAnnotation": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 22, - "column": 17 - }, - "end": { - "line": 22, - "column": 23 - } - } - }, - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 12 - }, - "end": { - "line": 22, - "column": 23 - } - } - } - ], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 22, - "column": 26 - }, - "end": { - "line": 22, - "column": 30 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "outer", - "decorators": [], - "loc": { - "start": { - "line": 23, - "column": 9 - }, - "end": { - "line": 23, - "column": 14 - } - } - }, - "property": { - "type": "Identifier", - "name": "foo", - "decorators": [], - "loc": { - "start": { - "line": 23, - "column": 15 - }, - "end": { - "line": 23, - "column": 18 - } - } - }, - "computed": false, - "optional": false, - "loc": { - "start": { - "line": 23, - "column": 9 - }, - "end": { - "line": 23, - "column": 18 - } - } - }, - "right": { - "type": "Identifier", - "name": "arg", - "decorators": [], - "loc": { - "start": { - "line": 23, - "column": 21 - }, - "end": { - "line": 23, - "column": 24 - } - } - }, - "loc": { - "start": { - "line": 23, - "column": 9 - }, - "end": { - "line": 23, - "column": 24 - } - } - }, - "loc": { - "start": { - "line": 23, - "column": 9 - }, - "end": { - "line": 23, - "column": 25 - } - } - } - ], - "loc": { - "start": { - "line": 22, - "column": 31 - }, - "end": { - "line": 24, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 11 - }, - "end": { - "line": 24, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 11 - }, - "end": { - "line": 24, - "column": 6 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 5 - }, - "end": { - "line": 24, - "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": 25, - "column": 4 - }, - "end": { - "line": 25, - "column": 4 - } - } - } - ], - "loc": { - "start": { - "line": 18, - "column": 15 - }, - "end": { - "line": 25, - "column": 4 - } - } - }, - "loc": { - "start": { - "line": 18, - "column": 3 - }, - "end": { - "line": 25, - "column": 4 - } - } - }, - { - "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": 16, - "column": 13 - }, - "end": { - "line": 26, - "column": 2 - } - } - }, - "loc": { - "start": { - "line": 16, - "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": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "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 - } - } -} +SyntaxError: Local type declaration (class, struct, interface and enum) support is not yet implemented. [class_property_access.ets:18:3] diff --git a/ets2panda/test/parser/ets/declare_iface-expected.txt b/ets2panda/test/parser/ets/declare_iface-expected.txt index db0f6ba96b..8f7f8206d4 100644 --- a/ets2panda/test/parser/ets/declare_iface-expected.txt +++ b/ets2panda/test/parser/ets/declare_iface-expected.txt @@ -32,23 +32,23 @@ }, "loc": { "start": { - "line": 17, - "column": 9 + "line": 1, + "column": 1 }, "end": { - "line": 17, - "column": 16 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 17, - "column": 9 + "line": 1, + "column": 1 }, "end": { - "line": 17, - "column": 16 + "line": 1, + "column": 1 } } }, @@ -97,23 +97,23 @@ }, "loc": { "start": { - "line": 17, - "column": 9 + "line": 1, + "column": 1 }, "end": { - "line": 17, - "column": 16 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 17, - "column": 9 + "line": 1, + "column": 1 }, "end": { - "line": 17, - "column": 16 + "line": 1, + "column": 1 } } }, @@ -224,23 +224,23 @@ }, "loc": { "start": { - "line": 17, - "column": 9 + "line": 1, + "column": 1 }, "end": { - "line": 17, - "column": 16 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 17, - "column": 9 + "line": 1, + "column": 1 }, "end": { - "line": 17, - "column": 16 + "line": 1, + "column": 1 } } }, @@ -289,23 +289,23 @@ }, "loc": { "start": { - "line": 17, - "column": 9 + "line": 1, + "column": 1 }, "end": { - "line": 17, - "column": 16 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 17, - "column": 9 + "line": 1, + "column": 1 }, "end": { - "line": 17, - "column": 16 + "line": 1, + "column": 1 } } }, @@ -351,23 +351,23 @@ }, "loc": { "start": { - "line": 17, - "column": 9 + "line": 1, + "column": 1 }, "end": { - "line": 17, - "column": 16 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 17, - "column": 9 + "line": 1, + "column": 1 }, "end": { - "line": 17, - "column": 16 + "line": 1, + "column": 1 } } }, @@ -470,23 +470,23 @@ }, "loc": { "start": { - "line": 17, - "column": 9 + "line": 1, + "column": 1 }, "end": { - "line": 17, - "column": 16 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 17, - "column": 9 + "line": 1, + "column": 1 }, "end": { - "line": 17, - "column": 16 + "line": 1, + "column": 1 } } }, @@ -535,23 +535,23 @@ }, "loc": { "start": { - "line": 17, - "column": 9 + "line": 1, + "column": 1 }, "end": { - "line": 17, - "column": 16 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 17, - "column": 9 + "line": 1, + "column": 1 }, "end": { - "line": 17, - "column": 16 + "line": 1, + "column": 1 } } }, @@ -597,23 +597,23 @@ }, "loc": { "start": { - "line": 17, - "column": 9 + "line": 1, + "column": 1 }, "end": { - "line": 17, - "column": 16 + "line": 1, + "column": 1 } } }, "loc": { "start": { - "line": 17, - "column": 9 + "line": 1, + "column": 1 }, "end": { - "line": 17, - "column": 16 + "line": 1, + "column": 1 } } }, diff --git a/ets2panda/test/parser/ets/import_tests/import_recursive-expected.txt b/ets2panda/test/parser/ets/import_tests/import_recursive-expected.txt index 8d3a68b63a..737a20a76e 100755 --- a/ets2panda/test/parser/ets/import_tests/import_recursive-expected.txt +++ b/ets2panda/test/parser/ets/import_tests/import_recursive-expected.txt @@ -1 +1,210 @@ -SyntaxError: Recursive import not allowed [subpackage_module_1.ets:18:1] +{ + "type": "Program", + "statements": [ + { + "type": "ImportDeclaration", + "source": { + "type": "StringLiteral", + "value": "import_tests/packages/recursive", + "loc": { + "start": { + "line": 16, + "column": 15 + }, + "end": { + "line": 16, + "column": 48 + } + } + }, + "specifiers": [ + { + "type": "ImportNamespaceSpecifier", + "local": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 8 + }, + "end": { + "line": 16, + "column": 14 + } + } + } + ], + "loc": { + "start": { + "line": 16, + "column": 1 + }, + "end": { + "line": 16, + "column": 49 + } + } + }, + { + "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": 17, + "column": 1 + } + } +} diff --git a/ets2panda/test/parser/ets/import_tests/packages/recursive/subpackage/subpackage_module_1-expected.txt b/ets2panda/test/parser/ets/import_tests/packages/recursive/subpackage/subpackage_module_1-expected.txt index 8d3a68b63a..700e1ee2c7 100755 --- a/ets2panda/test/parser/ets/import_tests/packages/recursive/subpackage/subpackage_module_1-expected.txt +++ b/ets2panda/test/parser/ets/import_tests/packages/recursive/subpackage/subpackage_module_1-expected.txt @@ -1 +1,319 @@ -SyntaxError: Recursive import not allowed [subpackage_module_1.ets:18:1] +{ + "type": "Program", + "statements": [ + { + "type": "ETSPackageDeclaration", + "name": { + "type": "TSQualifiedName", + "left": { + "type": "TSQualifiedName", + "left": { + "type": "TSQualifiedName", + "left": { + "type": "Identifier", + "name": "import_tests", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 9 + }, + "end": { + "line": 16, + "column": 21 + } + } + }, + "right": { + "type": "Identifier", + "name": "packages", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 22 + }, + "end": { + "line": 16, + "column": 30 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 9 + }, + "end": { + "line": 16, + "column": 30 + } + } + }, + "right": { + "type": "Identifier", + "name": "recursive", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 31 + }, + "end": { + "line": 16, + "column": 40 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 9 + }, + "end": { + "line": 16, + "column": 40 + } + } + }, + "right": { + "type": "Identifier", + "name": "subpackage", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 41 + }, + "end": { + "line": 16, + "column": 51 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 9 + }, + "end": { + "line": 16, + "column": 52 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 1 + }, + "end": { + "line": 16, + "column": 52 + } + } + }, + { + "type": "ImportDeclaration", + "source": { + "type": "StringLiteral", + "value": "import_tests/packages/recursive", + "loc": { + "start": { + "line": 18, + "column": 15 + }, + "end": { + "line": 18, + "column": 48 + } + } + }, + "specifiers": [ + { + "type": "ImportNamespaceSpecifier", + "local": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 8 + }, + "end": { + "line": 18, + "column": 14 + } + } + } + ], + "loc": { + "start": { + "line": 18, + "column": 1 + }, + "end": { + "line": 18, + "column": 49 + } + } + }, + { + "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": "ClassProperty", + "key": { + "type": "Identifier", + "name": "b", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 12 + }, + "end": { + "line": 20, + "column": 13 + } + } + }, + "value": { + "type": "StringLiteral", + "value": "hello", + "loc": { + "start": { + "line": 20, + "column": 24 + }, + "end": { + "line": 20, + "column": 31 + } + } + }, + "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": 20, + "column": 15 + }, + "end": { + "line": 20, + "column": 21 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 15 + }, + "end": { + "line": 20, + "column": 23 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 15 + }, + "end": { + "line": 20, + "column": 23 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 12 + }, + "end": { + "line": 20, + "column": 31 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "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/import_tests/packages/recursive/subpackage_module_1-expected.txt b/ets2panda/test/parser/ets/import_tests/packages/recursive/subpackage_module_1-expected.txt index 8d3a68b63a..3bc4bcc1f0 100755 --- a/ets2panda/test/parser/ets/import_tests/packages/recursive/subpackage_module_1-expected.txt +++ b/ets2panda/test/parser/ets/import_tests/packages/recursive/subpackage_module_1-expected.txt @@ -1 +1,291 @@ -SyntaxError: Recursive import not allowed [subpackage_module_1.ets:18:1] +{ + "type": "Program", + "statements": [ + { + "type": "ETSPackageDeclaration", + "name": { + "type": "TSQualifiedName", + "left": { + "type": "TSQualifiedName", + "left": { + "type": "Identifier", + "name": "import_tests", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 9 + }, + "end": { + "line": 16, + "column": 21 + } + } + }, + "right": { + "type": "Identifier", + "name": "packages", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 22 + }, + "end": { + "line": 16, + "column": 30 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 9 + }, + "end": { + "line": 16, + "column": 30 + } + } + }, + "right": { + "type": "Identifier", + "name": "recursive", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 31 + }, + "end": { + "line": 16, + "column": 40 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 9 + }, + "end": { + "line": 16, + "column": 41 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 1 + }, + "end": { + "line": 16, + "column": 41 + } + } + }, + { + "type": "ImportDeclaration", + "source": { + "type": "StringLiteral", + "value": "import_tests/packages/recursive/subpackage", + "loc": { + "start": { + "line": 18, + "column": 15 + }, + "end": { + "line": 18, + "column": 59 + } + } + }, + "specifiers": [ + { + "type": "ImportNamespaceSpecifier", + "local": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 8 + }, + "end": { + "line": 18, + "column": 14 + } + } + } + ], + "loc": { + "start": { + "line": 18, + "column": 1 + }, + "end": { + "line": 18, + "column": 60 + } + } + }, + { + "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": "ClassProperty", + "key": { + "type": "Identifier", + "name": "a", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 12 + }, + "end": { + "line": 20, + "column": 13 + } + } + }, + "value": { + "type": "StringLiteral", + "value": "hello", + "loc": { + "start": { + "line": 20, + "column": 24 + }, + "end": { + "line": 20, + "column": 31 + } + } + }, + "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": 20, + "column": 15 + }, + "end": { + "line": 20, + "column": 21 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 15 + }, + "end": { + "line": 20, + "column": 23 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 15 + }, + "end": { + "line": 20, + "column": 23 + } + } + }, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 12 + }, + "end": { + "line": 20, + "column": 31 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "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/interfaces-expected.txt b/ets2panda/test/parser/ets/interfaces-expected.txt index 5867d9032d..04999df991 100644 --- a/ets2panda/test/parser/ets/interfaces-expected.txt +++ b/ets2panda/test/parser/ets/interfaces-expected.txt @@ -15,12 +15,12 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 17, - "column": 8 + "line": 1, + "column": 1 }, "end": { - "line": 17, - "column": 11 + "line": 1, + "column": 1 } } }, @@ -52,12 +52,12 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 17, - "column": 8 + "line": 1, + "column": 1 }, "end": { - "line": 17, - "column": 11 + "line": 1, + "column": 1 } } }, @@ -123,12 +123,12 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 17, - "column": 8 + "line": 1, + "column": 1 }, "end": { - "line": 17, - "column": 11 + "line": 1, + "column": 1 } } }, @@ -160,12 +160,12 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 17, - "column": 8 + "line": 1, + "column": 1 }, "end": { - "line": 17, - "column": 11 + "line": 1, + "column": 1 } } }, @@ -194,12 +194,12 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 17, - "column": 8 + "line": 1, + "column": 1 }, "end": { - "line": 17, - "column": 11 + "line": 1, + "column": 1 } } }, @@ -285,12 +285,12 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 17, - "column": 8 + "line": 1, + "column": 1 }, "end": { - "line": 17, - "column": 11 + "line": 1, + "column": 1 } } }, @@ -322,12 +322,12 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 17, - "column": 8 + "line": 1, + "column": 1 }, "end": { - "line": 17, - "column": 11 + "line": 1, + "column": 1 } } }, @@ -356,12 +356,12 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 17, - "column": 8 + "line": 1, + "column": 1 }, "end": { - "line": 17, - "column": 11 + "line": 1, + "column": 1 } } }, @@ -434,12 +434,12 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 18, - "column": 8 + "line": 1, + "column": 1 }, "end": { - "line": 18, - "column": 11 + "line": 1, + "column": 1 } } }, @@ -471,12 +471,12 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 18, - "column": 8 + "line": 1, + "column": 1 }, "end": { - "line": 18, - "column": 11 + "line": 1, + "column": 1 } } }, @@ -542,12 +542,12 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 18, - "column": 8 + "line": 1, + "column": 1 }, "end": { - "line": 18, - "column": 11 + "line": 1, + "column": 1 } } }, @@ -579,12 +579,12 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 18, - "column": 8 + "line": 1, + "column": 1 }, "end": { - "line": 18, - "column": 11 + "line": 1, + "column": 1 } } }, @@ -613,12 +613,12 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 18, - "column": 8 + "line": 1, + "column": 1 }, "end": { - "line": 18, - "column": 11 + "line": 1, + "column": 1 } } }, @@ -704,12 +704,12 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 18, - "column": 8 + "line": 1, + "column": 1 }, "end": { - "line": 18, - "column": 11 + "line": 1, + "column": 1 } } }, @@ -741,12 +741,12 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 18, - "column": 8 + "line": 1, + "column": 1 }, "end": { - "line": 18, - "column": 11 + "line": 1, + "column": 1 } } }, @@ -775,12 +775,12 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 18, - "column": 8 + "line": 1, + "column": 1 }, "end": { - "line": 18, - "column": 11 + "line": 1, + "column": 1 } } }, diff --git a/ets2panda/test/parser/ets/local-class-access-modifier-private-expected.txt b/ets2panda/test/parser/ets/local-class-access-modifier-private-expected.txt new file mode 100644 index 0000000000..e56659bd52 --- /dev/null +++ b/ets2panda/test/parser/ets/local-class-access-modifier-private-expected.txt @@ -0,0 +1 @@ +SyntaxError: A local class or interface declaration can not have access modifier [local-class-access-modifier-private.ets:19:5] diff --git a/ets2panda/test/parser/ets/local-class-access-modifier-private.ets b/ets2panda/test/parser/ets/local-class-access-modifier-private.ets new file mode 100644 index 0000000000..ebe906434c --- /dev/null +++ b/ets2panda/test/parser/ets/local-class-access-modifier-private.ets @@ -0,0 +1,22 @@ + +/* + * 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. + */ + +function foo() +{ + private class LocalClass + { + } +} \ No newline at end of file diff --git a/ets2panda/test/parser/ets/local-class-access-modifier-protected-expected.txt b/ets2panda/test/parser/ets/local-class-access-modifier-protected-expected.txt new file mode 100644 index 0000000000..ecb0378aa5 --- /dev/null +++ b/ets2panda/test/parser/ets/local-class-access-modifier-protected-expected.txt @@ -0,0 +1 @@ +SyntaxError: A local class or interface declaration can not have access modifier [local-class-access-modifier-protected.ets:18:5] diff --git a/ets2panda/test/parser/ets/local-class-access-modifier-protected.ets b/ets2panda/test/parser/ets/local-class-access-modifier-protected.ets new file mode 100644 index 0000000000..566c817513 --- /dev/null +++ b/ets2panda/test/parser/ets/local-class-access-modifier-protected.ets @@ -0,0 +1,21 @@ +/* + * 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. + */ + +function foo() +{ + protected class LocalClass + { + } +} \ No newline at end of file diff --git a/ets2panda/test/parser/ets/local-class-access-modifier-public-expected.txt b/ets2panda/test/parser/ets/local-class-access-modifier-public-expected.txt new file mode 100644 index 0000000000..b8826e134b --- /dev/null +++ b/ets2panda/test/parser/ets/local-class-access-modifier-public-expected.txt @@ -0,0 +1 @@ +SyntaxError: A local class or interface declaration can not have access modifier [local-class-access-modifier-public.ets:18:5] diff --git a/ets2panda/test/parser/ets/local-class-access-modifier-public.ets b/ets2panda/test/parser/ets/local-class-access-modifier-public.ets new file mode 100644 index 0000000000..58787a9afe --- /dev/null +++ b/ets2panda/test/parser/ets/local-class-access-modifier-public.ets @@ -0,0 +1,21 @@ +/* + * 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. + */ + +function foo() +{ + public class LocalClass + { + } +} \ No newline at end of file diff --git a/ets2panda/test/parser/ets/local-class-expected.txt b/ets2panda/test/parser/ets/local-class-expected.txt new file mode 100644 index 0000000000..f317ab4ea7 --- /dev/null +++ b/ets2panda/test/parser/ets/local-class-expected.txt @@ -0,0 +1,425 @@ +{ + "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": "main", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 10 + }, + "end": { + "line": 16, + "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": 16, + "column": 10 + }, + "end": { + "line": 16, + "column": 14 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 16, + "column": 19 + }, + "end": { + "line": 16, + "column": 22 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "LocalClass", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 11 + }, + "end": { + "line": 18, + "column": 21 + } + } + }, + "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": 18, + "column": 25 + }, + "end": { + "line": 18, + "column": 25 + } + } + } + ], + "loc": { + "start": { + "line": 18, + "column": 22 + }, + "end": { + "line": 18, + "column": 25 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 18, + "column": 25 + } + } + }, + { + "type": "ReturnStatement", + "argument": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 19, + "column": 12 + }, + "end": { + "line": 19, + "column": 13 + } + } + }, + "loc": { + "start": { + "line": 19, + "column": 5 + }, + "end": { + "line": 19, + "column": 14 + } + } + } + ], + "loc": { + "start": { + "line": 17, + "column": 1 + }, + "end": { + "line": 20, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 14 + }, + "end": { + "line": 20, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 14 + }, + "end": { + "line": 20, + "column": 2 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 16, + "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": 20, + "column": 2 + } + } +} diff --git a/ets2panda/test/parser/ets/local-class-member-access-modifier-private1-expected.txt b/ets2panda/test/parser/ets/local-class-member-access-modifier-private1-expected.txt new file mode 100644 index 0000000000..a5a73903e0 --- /dev/null +++ b/ets2panda/test/parser/ets/local-class-member-access-modifier-private1-expected.txt @@ -0,0 +1 @@ +SyntaxError: Local class declaration members can not have access modifies [local-class-member-access-modifier-private1.ets:20:9] diff --git a/ets2panda/test/parser/ets/local-class-member-access-modifier-private1.ets b/ets2panda/test/parser/ets/local-class-member-access-modifier-private1.ets new file mode 100644 index 0000000000..4842198e5e --- /dev/null +++ b/ets2panda/test/parser/ets/local-class-member-access-modifier-private1.ets @@ -0,0 +1,22 @@ +/* + * 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. + */ + +function foo() +{ + class LocalClass + { + private property : int; + } +} \ No newline at end of file diff --git a/ets2panda/test/parser/ets/local-class-member-access-modifier-private2-expected.txt b/ets2panda/test/parser/ets/local-class-member-access-modifier-private2-expected.txt new file mode 100644 index 0000000000..1794411ab8 --- /dev/null +++ b/ets2panda/test/parser/ets/local-class-member-access-modifier-private2-expected.txt @@ -0,0 +1 @@ +SyntaxError: Local class declaration members can not have access modifies [local-class-member-access-modifier-private2.ets:20:9] diff --git a/ets2panda/test/parser/ets/local-class-member-access-modifier-private2.ets b/ets2panda/test/parser/ets/local-class-member-access-modifier-private2.ets new file mode 100644 index 0000000000..d076baa1a7 --- /dev/null +++ b/ets2panda/test/parser/ets/local-class-member-access-modifier-private2.ets @@ -0,0 +1,22 @@ +/* + * 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. + */ + +function foo() +{ + class LocalClass + { + private method() : void; + } +} \ No newline at end of file diff --git a/ets2panda/test/parser/ets/local-class-member-access-modifier-protected1-expected.txt b/ets2panda/test/parser/ets/local-class-member-access-modifier-protected1-expected.txt new file mode 100644 index 0000000000..cf37e0b470 --- /dev/null +++ b/ets2panda/test/parser/ets/local-class-member-access-modifier-protected1-expected.txt @@ -0,0 +1 @@ +SyntaxError: Local class declaration members can not have access modifies [local-class-member-access-modifier-protected1.ets:20:9] diff --git a/ets2panda/test/parser/ets/local-class-member-access-modifier-protected1.ets b/ets2panda/test/parser/ets/local-class-member-access-modifier-protected1.ets new file mode 100644 index 0000000000..7c292c50dd --- /dev/null +++ b/ets2panda/test/parser/ets/local-class-member-access-modifier-protected1.ets @@ -0,0 +1,22 @@ +/* + * 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. + */ + +function foo() +{ + class LocalClass + { + protected property : int; + } +} \ No newline at end of file diff --git a/ets2panda/test/parser/ets/local-class-member-access-modifier-protected2-expected.txt b/ets2panda/test/parser/ets/local-class-member-access-modifier-protected2-expected.txt new file mode 100644 index 0000000000..e78b256b22 --- /dev/null +++ b/ets2panda/test/parser/ets/local-class-member-access-modifier-protected2-expected.txt @@ -0,0 +1 @@ +SyntaxError: Local class declaration members can not have access modifies [local-class-member-access-modifier-protected2.ets:20:9] diff --git a/ets2panda/test/parser/ets/local-class-member-access-modifier-protected2.ets b/ets2panda/test/parser/ets/local-class-member-access-modifier-protected2.ets new file mode 100644 index 0000000000..d4334b411f --- /dev/null +++ b/ets2panda/test/parser/ets/local-class-member-access-modifier-protected2.ets @@ -0,0 +1,22 @@ +/* + * 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. + */ + +function foo() +{ + class LocalClass + { + protected method() : void; + } +} \ No newline at end of file diff --git a/ets2panda/test/parser/ets/local-class-member-access-modifier-public1-expected.txt b/ets2panda/test/parser/ets/local-class-member-access-modifier-public1-expected.txt new file mode 100644 index 0000000000..6e312819bb --- /dev/null +++ b/ets2panda/test/parser/ets/local-class-member-access-modifier-public1-expected.txt @@ -0,0 +1 @@ +SyntaxError: Local class declaration members can not have access modifies [local-class-member-access-modifier-public1.ets:20:9] diff --git a/ets2panda/test/parser/ets/local-class-member-access-modifier-public1.ets b/ets2panda/test/parser/ets/local-class-member-access-modifier-public1.ets new file mode 100644 index 0000000000..1a4cf2c419 --- /dev/null +++ b/ets2panda/test/parser/ets/local-class-member-access-modifier-public1.ets @@ -0,0 +1,22 @@ +/* + * 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. + */ + +function foo() +{ + class LocalClass + { + public property : int; + } +} \ No newline at end of file diff --git a/ets2panda/test/parser/ets/local-class-member-access-modifier-public2-expected.txt b/ets2panda/test/parser/ets/local-class-member-access-modifier-public2-expected.txt new file mode 100644 index 0000000000..05bc52458a --- /dev/null +++ b/ets2panda/test/parser/ets/local-class-member-access-modifier-public2-expected.txt @@ -0,0 +1 @@ +SyntaxError: Local class declaration members can not have access modifies [local-class-member-access-modifier-public2.ets:20:9] diff --git a/ets2panda/test/parser/ets/local-class-member-access-modifier-public2.ets b/ets2panda/test/parser/ets/local-class-member-access-modifier-public2.ets new file mode 100644 index 0000000000..57f75dbd3c --- /dev/null +++ b/ets2panda/test/parser/ets/local-class-member-access-modifier-public2.ets @@ -0,0 +1,22 @@ +/* + * 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. + */ + +function foo() +{ + class LocalClass + { + public method() : void; + } +} \ No newline at end of file diff --git a/ets2panda/test/parser/ets/local-class.ets b/ets2panda/test/parser/ets/local-class.ets new file mode 100644 index 0000000000..52237f9168 --- /dev/null +++ b/ets2panda/test/parser/ets/local-class.ets @@ -0,0 +1,20 @@ +/* + * 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. + */ + +function main() : int +{ + class LocalClass { } + return 0; +} \ No newline at end of file diff --git a/ets2panda/test/parser/ets/local-interface-access-modifier-private-expected.txt b/ets2panda/test/parser/ets/local-interface-access-modifier-private-expected.txt new file mode 100644 index 0000000000..b2b274ff4c --- /dev/null +++ b/ets2panda/test/parser/ets/local-interface-access-modifier-private-expected.txt @@ -0,0 +1 @@ +SyntaxError: A local class or interface declaration can not have access modifier [local-interface-access-modifier-private.ets:18:5] diff --git a/ets2panda/test/parser/ets/local-interface-access-modifier-private.ets b/ets2panda/test/parser/ets/local-interface-access-modifier-private.ets new file mode 100644 index 0000000000..ebb78d7e7f --- /dev/null +++ b/ets2panda/test/parser/ets/local-interface-access-modifier-private.ets @@ -0,0 +1,21 @@ +/* + * 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. + */ + +function foo() +{ + private interface LocalInterface + { + } +} \ No newline at end of file diff --git a/ets2panda/test/parser/ets/local-interface-access-modifier-protected-expected.txt b/ets2panda/test/parser/ets/local-interface-access-modifier-protected-expected.txt new file mode 100644 index 0000000000..3b79eeef88 --- /dev/null +++ b/ets2panda/test/parser/ets/local-interface-access-modifier-protected-expected.txt @@ -0,0 +1 @@ +SyntaxError: A local class or interface declaration can not have access modifier [local-interface-access-modifier-protected.ets:18:5] diff --git a/ets2panda/test/parser/ets/local-interface-access-modifier-protected.ets b/ets2panda/test/parser/ets/local-interface-access-modifier-protected.ets new file mode 100644 index 0000000000..4820997507 --- /dev/null +++ b/ets2panda/test/parser/ets/local-interface-access-modifier-protected.ets @@ -0,0 +1,21 @@ +/* + * 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. + */ + +function foo() +{ + protected interface LocalInterface + { + } +} \ No newline at end of file diff --git a/ets2panda/test/parser/ets/local-interface-access-modifier-public-expected.txt b/ets2panda/test/parser/ets/local-interface-access-modifier-public-expected.txt new file mode 100644 index 0000000000..1a1bef4653 --- /dev/null +++ b/ets2panda/test/parser/ets/local-interface-access-modifier-public-expected.txt @@ -0,0 +1 @@ +SyntaxError: A local class or interface declaration can not have access modifier [local-interface-access-modifier-public.ets:18:5] diff --git a/ets2panda/test/parser/ets/local-interface-access-modifier-public.ets b/ets2panda/test/parser/ets/local-interface-access-modifier-public.ets new file mode 100644 index 0000000000..b0b8d4d371 --- /dev/null +++ b/ets2panda/test/parser/ets/local-interface-access-modifier-public.ets @@ -0,0 +1,21 @@ +/* + * 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. + */ + +function foo() +{ + public interface LocalInterface + { + } +} \ No newline at end of file diff --git a/ets2panda/test/parser/ets/local-interface-expected.txt b/ets2panda/test/parser/ets/local-interface-expected.txt new file mode 100644 index 0000000000..e01cce77f7 --- /dev/null +++ b/ets2panda/test/parser/ets/local-interface-expected.txt @@ -0,0 +1,331 @@ +{ + "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": "main", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 10 + }, + "end": { + "line": 16, + "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": 16, + "column": 10 + }, + "end": { + "line": 16, + "column": 14 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 16, + "column": 19 + }, + "end": { + "line": 16, + "column": 22 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "TSInterfaceDeclaration", + "body": { + "type": "TSInterfaceBody", + "body": [], + "loc": { + "start": { + "line": 18, + "column": 30 + }, + "end": { + "line": 18, + "column": 33 + } + } + }, + "id": { + "type": "Identifier", + "name": "LocalInterface", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 15 + }, + "end": { + "line": 18, + "column": 29 + } + } + }, + "extends": [], + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 19, + "column": 11 + } + } + }, + { + "type": "ReturnStatement", + "argument": { + "type": "NumberLiteral", + "value": 0, + "loc": { + "start": { + "line": 19, + "column": 12 + }, + "end": { + "line": 19, + "column": 13 + } + } + }, + "loc": { + "start": { + "line": 19, + "column": 5 + }, + "end": { + "line": 19, + "column": 14 + } + } + } + ], + "loc": { + "start": { + "line": 17, + "column": 1 + }, + "end": { + "line": 20, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 14 + }, + "end": { + "line": 20, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 14 + }, + "end": { + "line": 20, + "column": 2 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 16, + "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": 20, + "column": 2 + } + } +} diff --git a/ets2panda/test/parser/ets/local-interface-member-access-modifier-private1-expected.txt b/ets2panda/test/parser/ets/local-interface-member-access-modifier-private1-expected.txt new file mode 100644 index 0000000000..190c83aa9b --- /dev/null +++ b/ets2panda/test/parser/ets/local-interface-member-access-modifier-private1-expected.txt @@ -0,0 +1 @@ +SyntaxError: Local interface declaration members can not have access modifies [local-interface-member-access-modifier-private1.ets:20:9] diff --git a/ets2panda/test/parser/ets/local-interface-member-access-modifier-private1.ets b/ets2panda/test/parser/ets/local-interface-member-access-modifier-private1.ets new file mode 100644 index 0000000000..b772614d55 --- /dev/null +++ b/ets2panda/test/parser/ets/local-interface-member-access-modifier-private1.ets @@ -0,0 +1,22 @@ +/* + * 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. + */ + +function foo() +{ + interface LocalInterface + { + private property : int; + } +} \ No newline at end of file diff --git a/ets2panda/test/parser/ets/local-interface-member-access-modifier-private2-expected.txt b/ets2panda/test/parser/ets/local-interface-member-access-modifier-private2-expected.txt new file mode 100644 index 0000000000..c10786f859 --- /dev/null +++ b/ets2panda/test/parser/ets/local-interface-member-access-modifier-private2-expected.txt @@ -0,0 +1 @@ +SyntaxError: Local interface declaration members can not have access modifies [local-interface-member-access-modifier-private2.ets:20:9] diff --git a/ets2panda/test/parser/ets/local-interface-member-access-modifier-private2.ets b/ets2panda/test/parser/ets/local-interface-member-access-modifier-private2.ets new file mode 100644 index 0000000000..fea47b8530 --- /dev/null +++ b/ets2panda/test/parser/ets/local-interface-member-access-modifier-private2.ets @@ -0,0 +1,22 @@ +/* + * 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. + */ + +function foo() +{ + interface LocalInterface + { + private method() : void; + } +} \ No newline at end of file diff --git a/ets2panda/test/parser/ets/local-interface-member-access-modifier-protected1-expected.txt b/ets2panda/test/parser/ets/local-interface-member-access-modifier-protected1-expected.txt new file mode 100644 index 0000000000..c648044306 --- /dev/null +++ b/ets2panda/test/parser/ets/local-interface-member-access-modifier-protected1-expected.txt @@ -0,0 +1 @@ +SyntaxError: Local interface declaration members can not have access modifies [local-interface-member-access-modifier-protected1.ets:20:9] diff --git a/ets2panda/test/parser/ets/local-interface-member-access-modifier-protected1.ets b/ets2panda/test/parser/ets/local-interface-member-access-modifier-protected1.ets new file mode 100644 index 0000000000..4b239afd40 --- /dev/null +++ b/ets2panda/test/parser/ets/local-interface-member-access-modifier-protected1.ets @@ -0,0 +1,22 @@ +/* + * 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. + */ + +function foo() +{ + interface LocalInterface + { + protected property : int; + } +} \ No newline at end of file diff --git a/ets2panda/test/parser/ets/local-interface-member-access-modifier-protected2-expected.txt b/ets2panda/test/parser/ets/local-interface-member-access-modifier-protected2-expected.txt new file mode 100644 index 0000000000..f245a63431 --- /dev/null +++ b/ets2panda/test/parser/ets/local-interface-member-access-modifier-protected2-expected.txt @@ -0,0 +1 @@ +SyntaxError: Local interface declaration members can not have access modifies [local-interface-member-access-modifier-protected2.ets:20:9] diff --git a/ets2panda/test/parser/ets/local-interface-member-access-modifier-protected2.ets b/ets2panda/test/parser/ets/local-interface-member-access-modifier-protected2.ets new file mode 100644 index 0000000000..11ff6ffd2b --- /dev/null +++ b/ets2panda/test/parser/ets/local-interface-member-access-modifier-protected2.ets @@ -0,0 +1,22 @@ +/* + * 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. + */ + +function foo() +{ + interface LocalInterface + { + protected method() : void; + } +} \ No newline at end of file diff --git a/ets2panda/test/parser/ets/local-interface-member-access-modifier-public1-expected.txt b/ets2panda/test/parser/ets/local-interface-member-access-modifier-public1-expected.txt new file mode 100644 index 0000000000..984d6657ff --- /dev/null +++ b/ets2panda/test/parser/ets/local-interface-member-access-modifier-public1-expected.txt @@ -0,0 +1 @@ +SyntaxError: Local interface declaration members can not have access modifies [local-interface-member-access-modifier-public1.ets:20:9] diff --git a/ets2panda/test/parser/ets/local-interface-member-access-modifier-public1.ets b/ets2panda/test/parser/ets/local-interface-member-access-modifier-public1.ets new file mode 100644 index 0000000000..9d01a6df98 --- /dev/null +++ b/ets2panda/test/parser/ets/local-interface-member-access-modifier-public1.ets @@ -0,0 +1,22 @@ +/* + * 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. + */ + +function foo() +{ + interface LocalInterface + { + public property : int; + } +} \ No newline at end of file diff --git a/ets2panda/test/parser/ets/local-interface-member-access-modifier-public2-expected.txt b/ets2panda/test/parser/ets/local-interface-member-access-modifier-public2-expected.txt new file mode 100644 index 0000000000..8f48cf7201 --- /dev/null +++ b/ets2panda/test/parser/ets/local-interface-member-access-modifier-public2-expected.txt @@ -0,0 +1 @@ +SyntaxError: Local interface declaration members can not have access modifies [local-interface-member-access-modifier-public2.ets:20:9] diff --git a/ets2panda/test/parser/ets/local-interface-member-access-modifier-public2.ets b/ets2panda/test/parser/ets/local-interface-member-access-modifier-public2.ets new file mode 100644 index 0000000000..26211d4f8c --- /dev/null +++ b/ets2panda/test/parser/ets/local-interface-member-access-modifier-public2.ets @@ -0,0 +1,22 @@ +/* + * 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. + */ + +function foo() +{ + interface LocalInterface + { + public method() : void; + } +} \ No newline at end of file diff --git a/ets2panda/test/parser/ets/local-interface.ets b/ets2panda/test/parser/ets/local-interface.ets new file mode 100644 index 0000000000..ba355d70cc --- /dev/null +++ b/ets2panda/test/parser/ets/local-interface.ets @@ -0,0 +1,20 @@ +/* + * 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. + */ + +function main() : int +{ + interface LocalInterface { } + return 0; +} \ No newline at end of file diff --git a/ets2panda/test/parser/ets/localClassIsPermitted-expected.txt b/ets2panda/test/parser/ets/localClassIsPermitted-expected.txt index 2935597f31..bac179ba08 100644 --- a/ets2panda/test/parser/ets/localClassIsPermitted-expected.txt +++ b/ets2panda/test/parser/ets/localClassIsPermitted-expected.txt @@ -1 +1,500 @@ -SyntaxError: Illegal start of expression [localClassIsPermitted.ets:18:9] +{ + "type": "Program", + "statements": [ + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "Klass", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 7 + }, + "end": { + "line": 16, + "column": 12 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "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": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "Local", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 15 + }, + "end": { + "line": 18, + "column": 20 + } + } + }, + "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": 10 + }, + "end": { + "line": 20, + "column": 10 + } + } + } + ], + "loc": { + "start": { + "line": 18, + "column": 21 + }, + "end": { + "line": 20, + "column": 10 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 9 + }, + "end": { + "line": 20, + "column": 10 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "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": 22, + "column": 2 + }, + "end": { + "line": 22, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 16, + "column": 13 + }, + "end": { + "line": 22, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 16, + "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/parser/ets/named_types-expected.txt b/ets2panda/test/parser/ets/named_types-expected.txt index a5c932661c..0080c199f0 100644 --- a/ets2panda/test/parser/ets/named_types-expected.txt +++ b/ets2panda/test/parser/ets/named_types-expected.txt @@ -1,1086 +1 @@ -{ - "type": "Program", - "statements": [ - { - "type": "ETSPackageDeclaration", - "name": { - "type": "TSQualifiedName", - "left": { - "type": "TSQualifiedName", - "left": { - "type": "TSQualifiedName", - "left": { - "type": "TSQualifiedName", - "left": { - "type": "Identifier", - "name": "com", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 9 - }, - "end": { - "line": 16, - "column": 12 - } - } - }, - "right": { - "type": "Identifier", - "name": "huawei", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 13 - }, - "end": { - "line": 16, - "column": 19 - } - } - }, - "loc": { - "start": { - "line": 16, - "column": 9 - }, - "end": { - "line": 16, - "column": 19 - } - } - }, - "right": { - "type": "Identifier", - "name": "migrationtool", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 20 - }, - "end": { - "line": 16, - "column": 33 - } - } - }, - "loc": { - "start": { - "line": 16, - "column": 9 - }, - "end": { - "line": 16, - "column": 33 - } - } - }, - "right": { - "type": "Identifier", - "name": "test", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 34 - }, - "end": { - "line": 16, - "column": 38 - } - } - }, - "loc": { - "start": { - "line": 16, - "column": 9 - }, - "end": { - "line": 16, - "column": 38 - } - } - }, - "right": { - "type": "Identifier", - "name": "ets", - "decorators": [], - "loc": { - "start": { - "line": 16, - "column": 39 - }, - "end": { - "line": 16, - "column": 42 - } - } - }, - "loc": { - "start": { - "line": 16, - "column": 9 - }, - "end": { - "line": 16, - "column": 43 - } - } - }, - "loc": { - "start": { - "line": 16, - "column": 1 - }, - "end": { - "line": 16, - "column": 43 - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "named_types", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 12 - }, - "end": { - "line": 20, - "column": 23 - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "ClassProperty", - "key": { - "type": "Identifier", - "name": "text", - "decorators": [], - "loc": { - "start": { - "line": 21, - "column": 5 - }, - "end": { - "line": 21, - "column": 9 - } - } - }, - "accessibility": "public", - "static": false, - "readonly": false, - "declare": false, - "optional": false, - "computed": false, - "typeAnnotation": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "TSQualifiedName", - "left": { - "type": "TSQualifiedName", - "left": { - "type": "Identifier", - "name": "ets", - "decorators": [], - "loc": { - "start": { - "line": 21, - "column": 12 - }, - "end": { - "line": 21, - "column": 15 - } - } - }, - "right": { - "type": "Identifier", - "name": "lang", - "decorators": [], - "loc": { - "start": { - "line": 21, - "column": 16 - }, - "end": { - "line": 21, - "column": 20 - } - } - }, - "loc": { - "start": { - "line": 21, - "column": 12 - }, - "end": { - "line": 21, - "column": 20 - } - } - }, - "right": { - "type": "Identifier", - "name": "String", - "decorators": [], - "loc": { - "start": { - "line": 21, - "column": 21 - }, - "end": { - "line": 21, - "column": 27 - } - } - }, - "loc": { - "start": { - "line": 21, - "column": 12 - }, - "end": { - "line": 21, - "column": 29 - } - } - }, - "loc": { - "start": { - "line": 21, - "column": 12 - }, - "end": { - "line": 21, - "column": 29 - } - } - }, - "loc": { - "start": { - "line": 21, - "column": 12 - }, - "end": { - "line": 21, - "column": 29 - } - } - }, - "definite": false, - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "inner", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 30 - }, - "end": { - "line": 22, - "column": 35 - } - } - }, - "typeParameters": { - "type": "TSTypeParameterDeclaration", - "params": [ - { - "type": "TSTypeParameter", - "name": { - "type": "Identifier", - "name": "T", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 36 - }, - "end": { - "line": 22, - "column": 37 - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 36 - }, - "end": { - "line": 22, - "column": 38 - } - } - } - ], - "loc": { - "start": { - "line": 22, - "column": 35 - }, - "end": { - "line": 22, - "column": 38 - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "innertoo", - "decorators": [], - "loc": { - "start": { - "line": 23, - "column": 27 - }, - "end": { - "line": 23, - "column": 35 - } - } - }, - "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": 24, - "column": 10 - }, - "end": { - "line": 24, - "column": 10 - } - } - } - ], - "loc": { - "start": { - "line": 23, - "column": 37 - }, - "end": { - "line": 24, - "column": 10 - } - } - }, - "loc": { - "start": { - "line": 23, - "column": 21 - }, - "end": { - "line": 24, - "column": 10 - } - } - }, - { - "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": 6 - }, - "end": { - "line": 26, - "column": 6 - } - } - } - ], - "loc": { - "start": { - "line": 22, - "column": 39 - }, - "end": { - "line": 26, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 22, - "column": 24 - }, - "end": { - "line": 26, - "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": 28, - "column": 2 - }, - "end": { - "line": 28, - "column": 2 - } - } - } - ], - "loc": { - "start": { - "line": 20, - "column": 25 - }, - "end": { - "line": 28, - "column": 2 - } - } - }, - "loc": { - "start": { - "line": 20, - "column": 6 - }, - "end": { - "line": 28, - "column": 2 - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "auxilliary", - "decorators": [], - "loc": { - "start": { - "line": 30, - "column": 12 - }, - "end": { - "line": 30, - "column": 22 - } - } - }, - "superClass": null, - "implements": [], - "body": [ - { - "type": "MethodDefinition", - "key": { - "type": "Identifier", - "name": "foo", - "decorators": [], - "loc": { - "start": { - "line": 31, - "column": 17 - }, - "end": { - "line": 31, - "column": 20 - } - } - }, - "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": 31, - "column": 17 - }, - "end": { - "line": 31, - "column": 20 - } - } - }, - "generator": false, - "async": false, - "expression": false, - "params": [], - "returnType": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "TSQualifiedName", - "left": { - "type": "Identifier", - "name": "named_types", - "decorators": [], - "loc": { - "start": { - "line": 31, - "column": 24 - }, - "end": { - "line": 31, - "column": 35 - } - } - }, - "right": { - "type": "Identifier", - "name": "inner", - "decorators": [], - "loc": { - "start": { - "line": 31, - "column": 36 - }, - "end": { - "line": 31, - "column": 41 - } - } - }, - "loc": { - "start": { - "line": 31, - "column": 24 - }, - "end": { - "line": 31, - "column": 43 - } - } - }, - "loc": { - "start": { - "line": 31, - "column": 24 - }, - "end": { - "line": 31, - "column": 43 - } - } - }, - "loc": { - "start": { - "line": 31, - "column": 24 - }, - "end": { - "line": 31, - "column": 43 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [], - "loc": { - "start": { - "line": 31, - "column": 42 - }, - "end": { - "line": 32, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 31, - "column": 20 - }, - "end": { - "line": 32, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 31, - "column": 20 - }, - "end": { - "line": 32, - "column": 6 - } - } - }, - "overloads": [], - "decorators": [], - "loc": { - "start": { - "line": 31, - "column": 5 - }, - "end": { - "line": 32, - "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": 33, - "column": 2 - }, - "end": { - "line": 33, - "column": 2 - } - } - } - ], - "loc": { - "start": { - "line": 30, - "column": 24 - }, - "end": { - "line": 33, - "column": 2 - } - } - }, - "loc": { - "start": { - "line": 30, - "column": 6 - }, - "end": { - "line": 33, - "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 - } - } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 35, - "column": 1 - } - } -} -SyntaxError: Cannot find type 'ets'. [named_types.ets:21:12] +SyntaxError: Local type declaration (class, struct, interface and enum) support is not yet implemented. [named_types.ets:22:19] diff --git a/ets2panda/test/parser/ets/null-coalesc-negative-expected.txt b/ets2panda/test/parser/ets/null-coalesc-negative-expected.txt index aef2a178ed..c187e0df58 100644 --- a/ets2panda/test/parser/ets/null-coalesc-negative-expected.txt +++ b/ets2panda/test/parser/ets/null-coalesc-negative-expected.txt @@ -62,12 +62,12 @@ "decorators": [], "loc": { "start": { - "line": 1, - "column": 1 + "line": 17, + "column": 13 }, "end": { - "line": 1, - "column": 1 + "line": 17, + "column": 23 } } }, @@ -458,7 +458,35 @@ "expression": false, "params": [], "returnType": { - "type": "ETSPrimitiveType", + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "void", + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 16 + }, + "end": { + "line": 24, + "column": 20 + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 16 + }, + "end": { + "line": 24, + "column": 22 + } + } + }, "loc": { "start": { "line": 24, @@ -466,7 +494,7 @@ }, "end": { "line": 24, - "column": 20 + "column": 22 } } }, @@ -905,6 +933,100 @@ "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": { @@ -951,7 +1073,35 @@ "expression": false, "params": [], "returnType": { - "type": "ETSPrimitiveType", + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "void", + "decorators": [], + "loc": { + "start": { + "line": 32, + "column": 18 + }, + "end": { + "line": 32, + "column": 22 + } + } + }, + "loc": { + "start": { + "line": 32, + "column": 18 + }, + "end": { + "line": 32, + "column": 24 + } + } + }, "loc": { "start": { "line": 32, @@ -959,7 +1109,7 @@ }, "end": { "line": 32, - "column": 22 + "column": 24 } } }, diff --git a/ets2panda/test/parser/ets/test_interface-expected.txt b/ets2panda/test/parser/ets/test_interface-expected.txt index 176f14aabf..f9d22cdea2 100644 --- a/ets2panda/test/parser/ets/test_interface-expected.txt +++ b/ets2panda/test/parser/ets/test_interface-expected.txt @@ -155,12 +155,12 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 21, - "column": 9 + "line": 1, + "column": 1 }, "end": { - "line": 21, - "column": 12 + "line": 1, + "column": 1 } } }, @@ -192,12 +192,12 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 21, - "column": 9 + "line": 1, + "column": 1 }, "end": { - "line": 21, - "column": 12 + "line": 1, + "column": 1 } } }, @@ -263,12 +263,12 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 21, - "column": 9 + "line": 1, + "column": 1 }, "end": { - "line": 21, - "column": 12 + "line": 1, + "column": 1 } } }, @@ -300,12 +300,12 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 21, - "column": 9 + "line": 1, + "column": 1 }, "end": { - "line": 21, - "column": 12 + "line": 1, + "column": 1 } } }, @@ -334,12 +334,12 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 21, - "column": 9 + "line": 1, + "column": 1 }, "end": { - "line": 21, - "column": 12 + "line": 1, + "column": 1 } } }, @@ -425,12 +425,12 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 21, - "column": 9 + "line": 1, + "column": 1 }, "end": { - "line": 21, - "column": 12 + "line": 1, + "column": 1 } } }, @@ -462,12 +462,12 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 21, - "column": 9 + "line": 1, + "column": 1 }, "end": { - "line": 21, - "column": 12 + "line": 1, + "column": 1 } } }, @@ -496,12 +496,12 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 21, - "column": 9 + "line": 1, + "column": 1 }, "end": { - "line": 21, - "column": 12 + "line": 1, + "column": 1 } } }, @@ -574,12 +574,12 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 22, - "column": 10 + "line": 1, + "column": 1 }, "end": { - "line": 22, - "column": 16 + "line": 1, + "column": 1 } } }, @@ -611,12 +611,12 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 22, - "column": 10 + "line": 1, + "column": 1 }, "end": { - "line": 22, - "column": 16 + "line": 1, + "column": 1 } } }, @@ -682,12 +682,12 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 22, - "column": 10 + "line": 1, + "column": 1 }, "end": { - "line": 22, - "column": 16 + "line": 1, + "column": 1 } } }, @@ -719,12 +719,12 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 22, - "column": 10 + "line": 1, + "column": 1 }, "end": { - "line": 22, - "column": 16 + "line": 1, + "column": 1 } } }, @@ -753,12 +753,12 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 22, - "column": 10 + "line": 1, + "column": 1 }, "end": { - "line": 22, - "column": 16 + "line": 1, + "column": 1 } } }, @@ -844,12 +844,12 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 22, - "column": 10 + "line": 1, + "column": 1 }, "end": { - "line": 22, - "column": 16 + "line": 1, + "column": 1 } } }, @@ -881,12 +881,12 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 22, - "column": 10 + "line": 1, + "column": 1 }, "end": { - "line": 22, - "column": 16 + "line": 1, + "column": 1 } } }, @@ -915,12 +915,12 @@ "type": "ETSPrimitiveType", "loc": { "start": { - "line": 22, - "column": 10 + "line": 1, + "column": 1 }, "end": { - "line": 22, - "column": 16 + "line": 1, + "column": 1 } } }, diff --git a/ets2panda/test/parser/ets/trailing_lambda_tests/trailing_lambda_define_lambda_in_body_capture_variable-expected.txt b/ets2panda/test/parser/ets/trailing_lambda_tests/trailing_lambda_define_lambda_in_body_capture_variable-expected.txt index e69de29bb2..fe90d86434 100644 --- a/ets2panda/test/parser/ets/trailing_lambda_tests/trailing_lambda_define_lambda_in_body_capture_variable-expected.txt +++ b/ets2panda/test/parser/ets/trailing_lambda_tests/trailing_lambda_define_lambda_in_body_capture_variable-expected.txt @@ -0,0 +1,595 @@ +{ + "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": "a0", + "typeAnnotation": { + "type": "ETSFunctionType", + "params": [], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "void", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 24 + }, + "end": { + "line": 16, + "column": 28 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 24 + }, + "end": { + "line": 16, + "column": 29 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 24 + }, + "end": { + "line": 16, + "column": 29 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 18 + }, + "end": { + "line": 16, + "column": 29 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 14 + }, + "end": { + "line": 16, + "column": 29 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 14 + }, + "end": { + "line": 16, + "column": 29 + } + } + } + ], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "void", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 31 + }, + "end": { + "line": 16, + "column": 35 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 31 + }, + "end": { + "line": 16, + "column": 37 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 31 + }, + "end": { + "line": 16, + "column": 37 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "a0", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 17, + "column": 7 + } + } + }, + "arguments": [], + "optional": false, + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 17, + "column": 9 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 17, + "column": 10 + } + } + } + ], + "loc": { + "start": { + "line": 16, + "column": 36 + }, + "end": { + "line": 18, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 13 + }, + "end": { + "line": 18, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 13 + }, + "end": { + "line": 18, + "column": 2 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 1 + }, + "end": { + "line": 18, + "column": 2 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "main", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 10 + }, + "end": { + "line": 20, + "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": 20, + "column": 10 + }, + "end": { + "line": 20, + "column": 14 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "returnType": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "void", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 18 + }, + "end": { + "line": 20, + "column": 22 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 18 + }, + "end": { + "line": 20, + "column": 24 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 18 + }, + "end": { + "line": 20, + "column": 24 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "foo", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "column": 8 + } + } + }, + "arguments": [], + "optional": false, + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "column": 10 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "column": 10 + } + } + } + ], + "loc": { + "start": { + "line": 20, + "column": 23 + }, + "end": { + "line": 28, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 14 + }, + "end": { + "line": 28, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 14 + }, + "end": { + "line": 28, + "column": 2 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 1 + }, + "end": { + "line": 28, + "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": 29, + "column": 1 + } + } +} diff --git a/ets2panda/test/runtime/ets/local-class-capture-boxing.ets b/ets2panda/test/runtime/ets/local-class-capture-boxing.ets new file mode 100644 index 0000000000..229e73d411 --- /dev/null +++ b/ets2panda/test/runtime/ets/local-class-capture-boxing.ets @@ -0,0 +1,218 @@ +/* + * 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 UserClassType +{ + v : int = 0; + constructor (p : int) + { + this.v = p; + } + + override toString() : string { + return Int.valueOf(this.v).toString(); + } +} + +enum UserEnumType +{ + Red, + Green, + Blue +}; + +let g_array : int [] = [1,2,3]; +let g_array2 : int [] = [11,12,13]; +let g_Array : Array = new Array(new Int(4), new Int(5), new Int(6)); +let g_Array2 : Array = new Array(new Int(14), new Int(15), new Int(16)); +let g_Object : Object = new Object(); +let g_Object2 : Object = new Object(); +let g_Class : UserClassType = new UserClassType(25); +let g_Class2 : UserClassType = new UserClassType(250); + + + +class GlobalClass +{ + static s_field : int = 13; + field : int = 14; + + static s_method_boxing_local_class() { + // predefined value types + let l_number : number = 1; + let l_byte : byte = 2; + let l_short : short = 3; + let l_int : int = 4; + let l_long : long = 5; + let l_float : float = 6.0; + let l_double : double = 7.0; + let l_boolean : boolean = false; + let l_char : char = c'x'; + + // user defined value types + let l_enum : UserEnumType = UserEnumType.Red; + + // predefined reference types + let l_Number : Number = new Number(11); + let l_Byte : Byte = new Byte(12 as byte); + let l_Short : Short = new Short(13 as short); + let l_Int : Int = new Int(14 as int); + let l_Long : Long = new Long(15 as long); + let l_Float : Float = new Float(16.0); + let l_Double : Double = new Double(17.0); + let l_Boolean: Boolean = new Boolean(false); + let l_Char : Char = new Char(c'X'); + + let l_string : string = "something"; + let l_String : String = new String("Something"); + let l_array : int [] = g_array; + let l_Array : Array = g_Array; + //let l_bigint : bigint = 20n; + //let l_BigInt : BigInt = new BigInt(21n); + let l_Object : Object = g_Object; + + // user defined reference types + let l_Class : UserClassType = g_Class; + + class LocalClassBoxing + { + local_field : int = 1000; + static local_s_field : int = 2000; + + static local_s_method(lp : int) : void + { + assert(lp == 300); + assert(LocalClassBoxing.local_s_field == 2000); + + LocalClassBoxing.local_s_field = 5000; + assert(LocalClassBoxing.local_s_field == 5000); + } + + local_method(lp : int) : void + { + // Parameter + assert(lp == 400); + // Local class object field + assert(this.local_field == 1000); + // Local class static field + assert(LocalClassBoxing.local_s_field == 5000); + // Outer class static field + assert(GlobalClass.s_field == 13); + // Predefined value types + assert(l_number == 1); + assert(l_byte == 2); + assert(l_short == 3); + assert(l_int == 4); + assert(l_long == 5); + assert(l_float == 6); + assert(l_double == 7); + assert(l_boolean == false); + assert(l_char == c'x'); + // User defined value type + assert(l_enum == UserEnumType.Red); + // Predefined reference types + assert(l_Number == Number.valueOf(11)); + assert(l_Byte == Byte.valueOf(12 as byte)); + assert(l_Short == Short.valueOf(13 as short)); + assert(l_Int == Int.valueOf(14 as int)); + assert(l_Long == Long.valueOf(15 as long)); + assert(l_Float == Float.valueOf(16 as float)); + assert(l_Double == Double.valueOf(17 as double)); + assert(l_Boolean == Boolean.valueOf(false)); + assert(l_Char == Char.valueOf(c'X')); + assert(l_string == "something"); + assert(l_String == "Something"); + // assert(l_array == g_array); + // assert(l_Array == g_Array); + assert(l_Object == g_Object); + assert(l_Class == g_Class); + + this.local_field = 1100; + LocalClassBoxing.local_s_field = 5100; + + l_number = 101; + l_byte = 102; + l_short = 103; + l_int = 104; + l_long = 105; + l_float = 106.0; + l_double = 107.0; + l_boolean = true; + l_char = c'y'; + //l_enum = UserEnumType.Green; + + l_Number = new Number(111); + l_Byte = new Byte(112 as byte); + l_Short = new Short(113 as short); + l_Int = new Int(114 as int); + l_Long = new Long(115 as long); + l_Float = new Float(116.0); + l_Double = new Double(117.0); + l_Boolean = new Boolean(true); + l_Char = new Char(c'Y'); + + l_string = "something new"; + l_String = new String("Something new"); + l_array = g_array2; + l_Array = g_Array2; + l_Object = g_Object2; + l_Class = g_Class2; + } + }; + LocalClassBoxing.local_s_field = 2000; // due to the jit loop + LocalClassBoxing.local_s_method(300); + + let lcb = new LocalClassBoxing(); + lcb.local_method(400); + + assert(lcb.local_field == 1100); + assert(LocalClassBoxing.local_s_field == 5100); + assert(l_number == 101); + assert(l_byte == 102); + assert(l_short == 103); + assert(l_int == 104); + assert(l_long == 105); + assert(l_float == 106); + assert(l_double == 107); + assert(l_boolean == true); + assert(l_char == c'y'); + + //assert(l_enum == UserEnumType.Green); + + // Predefined reference types + assert(l_Number == Number.valueOf(111)); + assert(l_Byte == Byte.valueOf(112 as byte)); + assert(l_Short == Short.valueOf(113 as short)); + assert(l_Int == Int.valueOf(114 as int)); + assert(l_Long == Long.valueOf(115 as long)); + assert(l_Float == Float.valueOf(116 as float)); + assert(l_Double == Double.valueOf(117 as double)); + assert(l_Boolean == Boolean.valueOf(true)); + assert(l_Char == Char.valueOf(c'Y')); + assert(l_string == "something new"); + assert(l_String == "Something new"); + //assert(l_array == g_array2); + //assert(l_Array == g_Array2); + assert(l_Object == g_Object2); + assert(l_Class == g_Class2); + } +} + + +function main() : int +{ + GlobalClass.s_method_boxing_local_class(); + return 0; +} diff --git a/ets2panda/test/runtime/ets/local-class-capture-not-boxing.ets b/ets2panda/test/runtime/ets/local-class-capture-not-boxing.ets new file mode 100644 index 0000000000..38c95a41fd --- /dev/null +++ b/ets2panda/test/runtime/ets/local-class-capture-not-boxing.ets @@ -0,0 +1,151 @@ +/* + * 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 UserClassType +{ + v : int = 0; + constructor (p : int) + { + this.v = p; + } + + override toString() : string { + return Int.valueOf(this.v).toString(); + } +} + +enum UserEnumType +{ + Red, + Green, + Blue +}; + +let g_array : int [] = [1,2,3]; +let g_array2 : int [] = [11,12,13]; +let g_Array : Array = new Array(new Int(4), new Int(5), new Int(6)); +let g_Array2 : Array = new Array(new Int(14), new Int(15), new Int(16)); +let g_Object : Object = new Object(); +let g_Object2 : Object = new Object(); +let g_Class : UserClassType = new UserClassType(25); +let g_Class2 : UserClassType = new UserClassType(250); + + + +class GlobalClass +{ + static s_field : int = 13; + field : int = 14; + + static s_method_not_boxing_local_class() { + // predefined value types + let l_number : number = 1; + let l_byte : byte = 2; + let l_short : short = 3; + let l_int : int = 4; + let l_long : long = 5; + let l_float : float = 6.0; + let l_double : double = 7.0; + let l_boolean : boolean = false; + let l_char : char = c'x'; + + // user defined value types + let l_enum : UserEnumType = UserEnumType.Red; + + // predefined reference types + let l_Number : Number = new Number(11); + let l_Byte : Byte = new Byte(12 as byte); + let l_Short : Short = new Short(13 as short); + let l_Int : Int = new Int(14 as int); + let l_Long : Long = new Long(15 as long); + let l_Float : Float = new Float(16.0); + let l_Double : Double = new Double(17.0); + let l_Boolean: Boolean = new Boolean(false); + let l_Char : Char = new Char(c'X'); + + let l_string : string = "something"; + let l_String : String = new String("Something"); + let l_array : int [] = g_array; + let l_Array : Array = g_Array; + //let l_bigint : bigint = 20n; + //let l_BigInt : BigInt = new BigInt(21n); + let l_Object : Object = g_Object; + + // user defined reference types + let l_Class : UserClassType = g_Class; + + class LocalClassNotBoxing + { + local_field : int = 100; + static local_s_field : int = 200; + + static local_s_method(lp : int) : void + { + assert(lp == 30); + assert(LocalClassNotBoxing.local_s_field == 200); + } + + local_method(lp : int) : void + { + // Parameter + assert(lp == 40); + // Local class object field + assert(this.local_field == 100); + // Local class static field + assert(LocalClassNotBoxing.local_s_field == 200); + // Predefined value types + assert(l_number == 1); + assert(l_byte == 2); + assert(l_short == 3); + assert(l_int == 4); + assert(l_long == 5); + assert(l_float == 6); + assert(l_double == 7); + assert(l_boolean == false); + assert(l_char == c'x'); + // User defined value type + assert(l_enum == UserEnumType.Red); + // Predefined reference types + assert(l_Number == Number.valueOf(11)); + assert(l_Byte == Byte.valueOf(12 as byte)); + assert(l_Short == Short.valueOf(13 as short)); + assert(l_Int == Int.valueOf(14 as int)); + assert(l_Long == Long.valueOf(15 as long)); + assert(l_Float == Float.valueOf(16 as float)); + assert(l_Double == Double.valueOf(17 as double)); + assert(l_Boolean == Boolean.valueOf(false)); + assert(l_Char == Char.valueOf(c'X')); + assert(l_string == "something"); + assert(l_String == "Something"); + assert(l_array == g_array); + assert(l_Array == g_Array); + assert(l_Object == g_Object); + assert(l_Class == g_Class); + } + }; + + LocalClassNotBoxing.local_s_method(30); + + let lc = new LocalClassNotBoxing(); + lc.local_method(40); + } +} + + +function main() : int +{ + GlobalClass.s_method_not_boxing_local_class(); + return 0; +} diff --git a/ets2panda/test/runtime/ets/local-class-capture-parameter.ets b/ets2panda/test/runtime/ets/local-class-capture-parameter.ets new file mode 100644 index 0000000000..048ee9ee37 --- /dev/null +++ b/ets2panda/test/runtime/ets/local-class-capture-parameter.ets @@ -0,0 +1,39 @@ +/* + * 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 GlobalClass +{ + static capture_param_method(param : int) + { + class LocalClass + { + method() + { + assert(param == 1) + } + } + + let lc = new LocalClass(); + lc.method() + } +} + +function main() : int +{ + GlobalClass.capture_param_method(1); + + return 0; +} diff --git a/ets2panda/test/runtime/ets/local-class-in-local-class.ets b/ets2panda/test/runtime/ets/local-class-in-local-class.ets new file mode 100644 index 0000000000..274c8dc669 --- /dev/null +++ b/ets2panda/test/runtime/ets/local-class-in-local-class.ets @@ -0,0 +1,54 @@ +/* + * 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. + */ + + +function main() : int +{ + let l_int = 0; + + class LocalClassLevel1 + { + m_int1 = 11; + + method1() + { + let l_int2 = 12; + assert(this.m_int1 == 11); + assert(l_int == 0); + l_int = 1; + + class LocalClassLevel2 + { + m_int2 : int = 22; + + method2() { + assert(this.m_int2 == 22); + assert(l_int2 == 12); + l_int2 = 13; + } + } + + let lcl2 = new LocalClassLevel2(); + lcl2.method2(); + assert(l_int2 == 13) + } + } + + let lcl1 = new LocalClassLevel1(); + lcl1.method1(); + assert(l_int == 1); + + return 0; +} diff --git a/ets2panda/test/runtime/ets/local-class-mixed-capture.ets b/ets2panda/test/runtime/ets/local-class-mixed-capture.ets new file mode 100644 index 0000000000..c23219be11 --- /dev/null +++ b/ets2panda/test/runtime/ets/local-class-mixed-capture.ets @@ -0,0 +1,46 @@ +/* + * 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. + */ + +function main() : int +{ + // Since the BoxingLocalClass modifies the 'i' it has to be boxed and use it as a boxed + // variable in the NotBoxingLocalClass too + let i : int = 1; + + class NotBoxingLocalClass + { + local_method() + { + assert(i == 1); + } + } + + class BoxingLocalClass + { + local_method() + { + assert(i == 1) + i = 2; + } + } + + let nblc = new NotBoxingLocalClass(); + nblc.local_method(); + + let blc = new BoxingLocalClass(); + blc.local_method(); + assert(i == 2); + return 0; +} diff --git a/ets2panda/test/runtime/ets/local-class-modify-captured-parameter.ets b/ets2panda/test/runtime/ets/local-class-modify-captured-parameter.ets new file mode 100644 index 0000000000..d4c1565317 --- /dev/null +++ b/ets2panda/test/runtime/ets/local-class-modify-captured-parameter.ets @@ -0,0 +1,41 @@ +/* + * 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 GlobalClass +{ + static capture_param_method(param : int) + { + class LocalClass + { + method() + { + assert(param == 1) + param = 3; + } + } + + let lc = new LocalClass(); + lc.method() + assert(param == 3); + } +} + +function main() : int +{ + GlobalClass.capture_param_method(1); + + return 0; +} diff --git a/ets2panda/test/runtime/ets/local-class-standard-example1.ets b/ets2panda/test/runtime/ets/local-class-standard-example1.ets new file mode 100644 index 0000000000..eb561768ec --- /dev/null +++ b/ets2panda/test/runtime/ets/local-class-standard-example1.ets @@ -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. + */ + +function foo (parameter: number) { + let local: string = "function local"; + interface LocalInterface { // Local interface in a top-level function + method (): void; // It has a method + field: string; // and a property + } + class LocalClass implements LocalInterface { // Class implements interface + // Local class in a top-level function + override method () { + console.log ("Instance field = " + this.field + " par = " + parameter + " loc = " + local ) + assert(this.field == "`instance field value`") + assert(parameter == 42) + assert(local == "function local") + } + field: string = "`instance field value`" + static s_method () { + console.log ("Static field = " + LocalClass.s_field) + assert(LocalClass.s_field == "`class/static field value`") + + } + static s_field: string = "`class/static field value`" + } + + let lc: LocalInterface = new LocalClass(); + // Both local types can be freely used in the top-level function scope + lc.method() + LocalClass.s_method() +} + +function main() : int +{ + foo(42); + return 0; +} diff --git a/ets2panda/test/runtime/ets/local-class-standard-example2.ets b/ets2panda/test/runtime/ets/local-class-standard-example2.ets new file mode 100644 index 0000000000..de257c768d --- /dev/null +++ b/ets2panda/test/runtime/ets/local-class-standard-example2.ets @@ -0,0 +1,82 @@ +/* + * 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_class { + field: number = 1234 // Not visible for the local class + method (parameter: number) { + let local: string = "instance local" + + interface LocalInterface { + method (): void + field: string + } + + class LocalClass implements LocalInterface { + override method () { + console.log ("Instance field = " + this.field + " par = " + parameter + " loc = " + local ) + assert(this.field == "`instance method instance field value`") + assert(parameter == 42) + assert(local == "instance local") + + } + field: string = "`instance method instance field value`" + static s_method () { + console.log ("Static field = " + LocalClass.s_field) + assert(LocalClass.s_field == "`instance method class/static field value`") + } + static s_field: string = "`instance method class/static field value`" + } + + let lc: LocalInterface = new LocalClass + lc.method() + LocalClass.s_method() + } + + static s_method (parameter: number) { + let local: string = "class/static local" + interface LocalInterface { + method (): void + field: string + } + + class LocalClass implements LocalInterface { + override method () { + console.log ("Instance field = " + this.field + " par = " + parameter + " loc = " + local) + assert(this.field == "`static method instance field value`") + assert(parameter == 72) + assert(local == "class/static local") + } + field: string = "`static method instance field value`" + static s_method () { + console.log ("Static field = " + LocalClass.s_field) + assert(LocalClass.s_field == "`static method class/static field value`") + } + static s_field: string = "`static method class/static field value`" + } + let lc: LocalInterface = new LocalClass + lc.method() + LocalClass.s_method() + } +} + +function main() : int +{ + A_class.s_method(72); + + let a = new A_class(); + a.method(42) + + return 0; +} diff --git a/ets2panda/test/test-lists/ets-runtime/ets-runtime-ignored.txt b/ets2panda/test/test-lists/ets-runtime/ets-runtime-ignored.txt index c12cc9299c..7b6b2e0d97 100644 --- a/ets2panda/test/test-lists/ets-runtime/ets-runtime-ignored.txt +++ b/ets2panda/test/test-lists/ets-runtime/ets-runtime-ignored.txt @@ -56,3 +56,7 @@ lambdaExpressionWithRestParameter.ets # Non-trivial cast sequence castSequence.ets + +# ignored due to interface implementation modification +local-class-standard-example1.ets +local-class-standard-example2.ets diff --git a/ets2panda/varbinder/ETSBinder.cpp b/ets2panda/varbinder/ETSBinder.cpp index e927733cc3..e7d82c710a 100644 --- a/ets2panda/varbinder/ETSBinder.cpp +++ b/ets2panda/varbinder/ETSBinder.cpp @@ -181,7 +181,7 @@ void ETSBinder::LookupIdentReference(ir::Identifier *ident) auto *outerFunction = GetScope()->EnclosingVariableScope()->Node(); if ((!outerFunction->IsScriptFunction() || !outerFunction->AsScriptFunction()->IsArrow()) && - !res.variable->IsGlobalVariable() && res.level > 1) { + !res.variable->IsGlobalVariable() && res.variable->HasFlag(VariableFlags::LOCAL) && res.level > 1) { ThrowInvalidCapture(ident->Start(), name); } } diff --git a/ets2panda/varbinder/recordTable.cpp b/ets2panda/varbinder/recordTable.cpp index 971257b12c..917107de71 100644 --- a/ets2panda/varbinder/recordTable.cpp +++ b/ets2panda/varbinder/recordTable.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 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 @@ -20,11 +20,15 @@ #include "ir/expressions/identifier.h" #include "ir/ts/tsEnumDeclaration.h" #include "ir/ts/tsInterfaceDeclaration.h" +#include "checker/types/ets/etsObjectType.h" #include "generated/signatures.h" namespace ark::es2panda::varbinder { BoundContext::BoundContext(RecordTable *recordTable, ir::ClassDefinition *classDef) - : prev_(recordTable->boundCtx_), recordTable_(recordTable), savedRecord_(recordTable->record_) + : prev_(recordTable->boundCtx_), + recordTable_(recordTable), + currentRecord_(classDef), + savedRecord_(recordTable->record_) { if (classDef == nullptr || !recordTable_->classDefinitions_.insert(classDef).second) { return; @@ -37,7 +41,10 @@ BoundContext::BoundContext(RecordTable *recordTable, ir::ClassDefinition *classD } BoundContext::BoundContext(RecordTable *recordTable, ir::TSInterfaceDeclaration *interfaceDecl) - : prev_(recordTable->boundCtx_), recordTable_(recordTable), savedRecord_(recordTable->record_) + : prev_(recordTable->boundCtx_), + recordTable_(recordTable), + currentRecord_(interfaceDecl), + savedRecord_(recordTable->record_) { if (interfaceDecl == nullptr || !recordTable_->interfaceDeclarations_.insert(interfaceDecl).second) { return; @@ -73,6 +80,13 @@ util::StringView BoundContext::FormRecordName() const util::UString recordName(recordTable_->program_->Allocator()); recordName.Append(prev_->FormRecordName()); recordName.Append(compiler::Signatures::METHOD_SEPARATOR); + if (std::holds_alternative(currentRecord_)) { + const auto *classDef = std::get(currentRecord_); + if (classDef->IsLocal()) { + recordName.Append(classDef->LocalPrefix()); + } + } + recordName.Append(recordIdent_->Name()); return recordName.View(); } diff --git a/ets2panda/varbinder/recordTable.h b/ets2panda/varbinder/recordTable.h index 1576acf0c7..9486719379 100644 --- a/ets2panda/varbinder/recordTable.h +++ b/ets2panda/varbinder/recordTable.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 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 @@ -180,6 +180,7 @@ public: private: BoundContext *prev_; RecordTable *recordTable_; + RecordTable::RecordHolder currentRecord_ {nullptr}; RecordTable::RecordHolder savedRecord_ {nullptr}; ir::Identifier *recordIdent_ {nullptr}; }; diff --git a/ets2panda/varbinder/scope.cpp b/ets2panda/varbinder/scope.cpp index bba9cd848e..d6bb722e42 100644 --- a/ets2panda/varbinder/scope.cpp +++ b/ets2panda/varbinder/scope.cpp @@ -73,6 +73,38 @@ const VariableScope *Scope::EnclosingVariableScope() const return nullptr; } +// NOTE(psiket): Duplication +ClassScope *Scope::EnclosingClassScope() +{ + Scope *iter = this; + + while (iter != nullptr) { + if (iter->IsClassScope()) { + return iter->AsClassScope(); + } + + iter = iter->Parent(); + } + + return nullptr; +} + +const ClassScope *Scope::EnclosingClassScope() const +{ + const auto *iter = this; + + while (iter != nullptr) { + if (iter->IsVariableScope()) { + return iter->AsClassScope(); + } + + iter = iter->Parent(); + } + + return nullptr; +} + +// NOLINTNEXTLINE(google-default-arguments) Variable *Scope::FindLocal(const util::StringView &name, ResolveBindingOptions options) const { if ((options & ResolveBindingOptions::INTERFACES) != 0) { @@ -147,14 +179,16 @@ ConstScopeFindResult Scope::FindInGlobal(const util::StringView &name, const Res ConstScopeFindResult Scope::FindInFunctionScope(const util::StringView &name, const ResolveBindingOptions options) const { const auto *scopeIter = this; - while (scopeIter != nullptr && !scopeIter->IsClassScope() && !scopeIter->IsGlobalScope()) { - if (auto *const resolved = scopeIter->FindLocal(name, options); resolved != nullptr) { - return {name, scopeIter, 0, 0, resolved}; + while (scopeIter != nullptr && !scopeIter->IsGlobalScope()) { + if (!scopeIter->IsClassScope()) { + if (auto *const resolved = scopeIter->FindLocal(name, options); resolved != nullptr) { + return ConstScopeFindResult(name, scopeIter, 0, 0, resolved); + } } scopeIter = scopeIter->Parent(); } - return {name, scopeIter, 0, 0, nullptr}; + return ConstScopeFindResult(name, scopeIter, 0, 0, nullptr); } ScopeFindResult Scope::Find(const util::StringView &name, const ResolveBindingOptions options) @@ -236,6 +270,10 @@ Variable *Scope::AddLocal(ArenaAllocator *allocator, Variable *currentVariable, return bindings_.insert({newDecl->Name(), allocator->New(newDecl, VariableFlags::INTERFACE)}) .first->second; } + case DeclType::CLASS: { + return bindings_.insert({newDecl->Name(), allocator->New(newDecl, VariableFlags::CLASS)}) + .first->second; + } case DeclType::TYPE_PARAMETER: { return bindings_ .insert({newDecl->Name(), allocator->New(newDecl, VariableFlags::TYPE_PARAMETER)}) @@ -404,8 +442,40 @@ Variable *FunctionScope::AddBinding(ArenaAllocator *allocator, Variable *current case DeclType::ENUM_LITERAL: { return AddTSBinding(allocator, currentVariable, newDecl, VariableFlags::ENUM_LITERAL); } + // NOTE(psiket):Duplication case DeclType::INTERFACE: { - return AddTSBinding(allocator, currentVariable, newDecl, VariableFlags::INTERFACE); + ir::Identifier *ident {}; + ident = newDecl->Node()->AsTSInterfaceDeclaration()->Id(); + + auto *var = InsertBinding(newDecl->Name(), allocator->New(newDecl, VariableFlags::INTERFACE)) + .first->second; + + if (var == nullptr) { + return nullptr; + } + + var->SetScope(this); + if (ident != nullptr) { + ident->SetVariable(var); + } + return var; + } + case DeclType::CLASS: { + ir::Identifier *ident {}; + ident = newDecl->Node()->AsClassDefinition()->Ident(); + + auto *var = InsertBinding(newDecl->Name(), allocator->New(newDecl, VariableFlags::CLASS)) + .first->second; + + if (var == nullptr) { + return nullptr; + } + + var->SetScope(this); + if (ident != nullptr) { + ident->SetVariable(var); + } + return var; } default: { return AddLexical(allocator, currentVariable, newDecl); diff --git a/ets2panda/varbinder/scope.h b/ets2panda/varbinder/scope.h index b179f00b2b..0aa277b0b4 100644 --- a/ets2panda/varbinder/scope.h +++ b/ets2panda/varbinder/scope.h @@ -134,6 +134,9 @@ public: const VariableScope *EnclosingVariableScope() const; + ClassScope *EnclosingClassScope(); + const ClassScope *EnclosingClassScope() const; + void AddFlag(ScopeFlags flag) { flags_ |= flag; -- Gitee