diff --git a/ets2panda/checker/ETSAnalyzer.cpp b/ets2panda/checker/ETSAnalyzer.cpp index 2491daa7f8a299698bce1420854989d082bd1aeb..f55b72e3068857c0d7c19bafe94130a4502982d2 100644 --- a/ets2panda/checker/ETSAnalyzer.cpp +++ b/ets2panda/checker/ETSAnalyzer.cpp @@ -1015,6 +1015,12 @@ static checker::Signature *ResolveCallForETSExtensionFuncHelperType(checker::ETS type->ClassMethodType()->CallSignatures(), expr, expr->Start(), checker::TypeRelationFlag::NO_THROW); if (signature != nullptr) { + if (expr->Callee()->IsMemberExpression()) { + auto memberExpr = expr->Callee()->AsMemberExpression(); + auto var = type->ClassMethodType()->Variable(); + memberExpr->Property()->AsIdentifier()->SetVariable(var); + } + return signature; } @@ -1290,6 +1296,7 @@ checker::Type *ETSAnalyzer::SetAndAdjustType(ETSChecker *checker, ir::MemberExpr expr->SetObjectType(objectType); auto [resType, resVar] = expr->ResolveObjectMember(checker); expr->SetPropVar(resVar); + expr->Property()->AsIdentifier()->SetVariable(resVar); return expr->AdjustType(checker, resType); } @@ -1336,6 +1343,7 @@ checker::Type *ETSAnalyzer::Check(ir::MemberExpression *expr) const checker->AddBoxingUnboxingFlagsToNode(expr, expr->ObjType()); auto [resType, resVar] = expr->ResolveObjectMember(checker); expr->SetPropVar(resVar); + expr->Property()->AsIdentifier()->SetVariable(resVar); return expr->AdjustType(checker, resType); } @@ -1978,7 +1986,7 @@ checker::Type *ETSAnalyzer::Check(ir::BlockStatement *st) const checker::Type *ETSAnalyzer::Check(ir::BreakStatement *st) const { ETSChecker *checker = GetETSChecker(); - st->target_ = checker->FindJumpTarget(st->Type(), st, st->Ident()); + st->target_ = checker->FindJumpTarget(st->Type(), st, st->Label()); return nullptr; } @@ -1992,7 +2000,7 @@ checker::Type *ETSAnalyzer::Check(ir::ClassDeclaration *st) const checker::Type *ETSAnalyzer::Check(ir::ContinueStatement *st) const { ETSChecker *checker = GetETSChecker(); - st->target_ = checker->FindJumpTarget(st->Type(), st, st->Ident()); + st->target_ = checker->FindJumpTarget(st->Type(), st, st->Label()); return nullptr; } diff --git a/ets2panda/checker/ETSchecker.h b/ets2panda/checker/ETSchecker.h index b88160bbd8909012e4be4d1f98d134baa620e483..9180a3e64a601c5169ba5837ff3cc5261c48cbdc 100644 --- a/ets2panda/checker/ETSchecker.h +++ b/ets2panda/checker/ETSchecker.h @@ -475,7 +475,8 @@ public: { return type->IsETSReferenceType(); } - const ir::AstNode *FindJumpTarget(ir::AstNodeType nodeType, const ir::AstNode *node, const ir::Identifier *target); + const ir::AstNode *FindJumpTarget(ir::AstNodeType nodeType, const ir::AstNode *node, + const util::StringView &target); void ValidatePropertyAccess(varbinder::Variable *var, ETSObjectType *obj, const lexer::SourcePosition &pos); varbinder::VariableFlags GetAccessFlagFromNode(const ir::AstNode *node); void CheckSwitchDiscriminant(ir::Expression *discriminant); diff --git a/ets2panda/checker/ets/helpers.cpp b/ets2panda/checker/ets/helpers.cpp index 164d5b6b045c99fde8a1baf944e1face5a4203a2..2e28e09b98b496c8e938c020f20a2b66c48af77f 100644 --- a/ets2panda/checker/ets/helpers.cpp +++ b/ets2panda/checker/ets/helpers.cpp @@ -1642,14 +1642,14 @@ bool ETSChecker::IsTypeBuiltinType(const Type *type) const } const ir::AstNode *ETSChecker::FindJumpTarget(ir::AstNodeType nodeType, const ir::AstNode *node, - const ir::Identifier *target) + const util::StringView &target) { const auto *iter = node->Parent(); while (iter != nullptr) { switch (iter->Type()) { case ir::AstNodeType::LABELLED_STATEMENT: { - if (const auto *labelled = iter->AsLabelledStatement(); labelled->Ident()->Name() == target->Name()) { + if (const auto *labelled = iter->AsLabelledStatement(); labelled->Name() == target) { return nodeType == ir::AstNodeType::CONTINUE_STATEMENT ? labelled->GetReferencedStatement() : labelled; } diff --git a/ets2panda/compiler/core/ASTVerifier.cpp b/ets2panda/compiler/core/ASTVerifier.cpp index 5af36a6f47d4c59c3af5bb13d5882baaadf08907..eb590a55a2a9d42df0f24eb56dc5377ac251a5c0 100644 --- a/ets2panda/compiler/core/ASTVerifier.cpp +++ b/ets2panda/compiler/core/ASTVerifier.cpp @@ -435,19 +435,63 @@ public: return {CheckDecision::CORRECT, CheckAction::CONTINUE}; } + const auto *id = ast->AsIdentifier(); + if (id->Parent() != nullptr && id->Parent()->IsMemberExpression() && id->Name().Is("length")) { + // NOTE(kkonsw): confirm whether this case should be allowed + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; + } + + if (id->Parent() != nullptr && id->Parent()->IsLabelledStatement()) { + // NOTE(kkonsw): confirm whether this case should be allowed + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; + } + + if (id->Parent()->IsImportSpecifier()) { + // NOTE(kkonsw): confirm whether this case should be allowed + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; + } + + if (id->Parent()->IsImportNamespaceSpecifier()) { + // NOTE(kkonsw): confirm whether this case should be allowed + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; + } + + if (id->Parent()->IsImportDefaultSpecifier()) { + // NOTE(kkonsw): confirm whether this case should be allowed + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; + } + + if (id->Parent()->IsTSQualifiedName()) { + // NOTE(kkonsw): confirm whether this case should be allowed + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; + } + + if (id->Parent()->Parent() != nullptr && id->Parent()->Parent()->IsETSNewClassInstanceExpression()) { + // NOTE(kkonsw): confirm whether this case should be allowed + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; + } + /* * NOTICE: That is temporary fix for identifies without variable * That should be removed in future after fix issues in * varbinder and checker */ - if (ast->AsIdentifier()->Variable() != nullptr || ast->AsIdentifier()->IsReference() || - ast->AsIdentifier()->Name().Empty() || ast->AsIdentifier()->Name() == "Void" || - ast->AsIdentifier()->Name().Utf8().find("lambda$invoke$") == 0 || - (ast->AsIdentifier()->Parent() != nullptr && ast->AsIdentifier()->Parent()->IsProperty())) { + if (ast->AsIdentifier()->Variable() != nullptr || + // ast->AsIdentifier()->IsReference() || + ast->AsIdentifier()->Name().Empty() || ast->AsIdentifier()->Name().Utf8().find("lambda$invoke$") == 0) { return {CheckDecision::CORRECT, CheckAction::CONTINUE}; } - const auto *id = ast->AsIdentifier(); + // NOTE(kkonsw): skip package declarations + auto parent = ast->Parent(); + while (parent != nullptr) { + if (parent->IsETSPackageDeclaration()) { + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; + } + + parent = parent->Parent(); + } + ctx.AddCheckMessage("NULL_VARIABLE", *id, id->Start()); return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; } @@ -573,10 +617,10 @@ public: * NOTICE: That is temporary exclusion for identifies without variable * Should removed in future */ - if (ast->AsIdentifier()->IsReference() || ast->AsIdentifier()->TypeAnnotation() != nullptr || - ast->AsIdentifier()->Name().Empty() || ast->AsIdentifier()->Name().Utf8().find("Void") == 0 || - ast->AsIdentifier()->Name().Utf8().find("lambda$invoke$") == 0 || - (ast->AsIdentifier()->Parent() != nullptr && ast->AsIdentifier()->Parent()->IsProperty())) { + if ( + // ast->AsIdentifier()->IsReference() || + ast->AsIdentifier()->TypeAnnotation() != nullptr || ast->AsIdentifier()->Name().Empty() || + ast->AsIdentifier()->Name().Utf8().find("lambda$invoke$") == 0) { return {CheckDecision::CORRECT, CheckAction::CONTINUE}; } @@ -604,15 +648,61 @@ public: return std::nullopt; } + const auto *id = ast->AsIdentifier(); + if (id->Parent()->IsMemberExpression() && id->Name().Is("length")) { + // NOTE(kkonsw): confirm whether this case should be allowed + return std::nullopt; + } + + if (id->Parent()->IsLabelledStatement()) { + // NOTE(kkonsw): confirm whether this case should be allowed + return std::nullopt; + } + + if (id->Parent()->IsImportSpecifier()) { + // NOTE(kkonsw): confirm whether this case should be allowed + return std::nullopt; + } + + if (id->Parent()->IsImportNamespaceSpecifier()) { + // NOTE(kkonsw): confirm whether this case should be allowed + return std::nullopt; + } + + if (id->Parent()->IsImportDefaultSpecifier()) { + // NOTE(kkonsw): confirm whether this case should be allowed + return std::nullopt; + } + + if (id->Parent()->IsTSQualifiedName()) { + // NOTE(kkonsw): confirm whether this case should be allowed + return std::nullopt; + } + + if (id->Parent()->Parent() != nullptr && id->Parent()->Parent()->IsETSNewClassInstanceExpression()) { + // NOTE(kkonsw): confirm whether this case should be allowed + return std::nullopt; + } + + // NOTE(kkonsw): skip package declarations + auto parent = ast->Parent(); + while (parent != nullptr) { + if (parent->IsETSPackageDeclaration()) { + return std::nullopt; + } + + parent = parent->Parent(); + } + /* * NOTICE: That is temporary exclusion for identifies without variable and scope * Should removed in future */ - if (ast->AsIdentifier()->IsReference() || ast->AsIdentifier()->TypeAnnotation() != nullptr || - ast->AsIdentifier()->Name().Empty() || ast->AsIdentifier()->Name().Utf8().find("Void") == 0 || + if ( + // ast->AsIdentifier()->IsReference() || + ast->AsIdentifier()->TypeAnnotation() != nullptr || ast->AsIdentifier()->Name().Empty() || ast->AsIdentifier()->Name().Utf8().find("field") == 0 || - ast->AsIdentifier()->Name().Utf8().find("lambda$invoke$") == 0 || - (ast->AsIdentifier()->Parent() != nullptr && ast->AsIdentifier()->Parent()->IsProperty())) { + ast->AsIdentifier()->Name().Utf8().find("lambda$invoke$") == 0) { return std::nullopt; } @@ -726,7 +816,28 @@ public: const auto node = scope->Node(); auto result = std::make_tuple(CheckDecision::CORRECT, CheckAction::CONTINUE); if (!IsContainedIn(ast, node)) { + if (node->Parent() != nullptr && node->Parent()->IsCatchClause()) { + // NOTE(kkonsw): confirm whether this case should be allowed + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; + } + result = {CheckDecision::INCORRECT, CheckAction::CONTINUE}; + + // NOTE(kkonsw): skip check for lambdas with references outside of lambda + auto parent = node->Parent(); + while (parent != nullptr) { + if (parent->IsFunctionExpression()) { + auto script = parent->AsFunctionExpression()->Function(); + if (script->Id()->Name().Utf8().find("lambda$invoke$") == 0) { + return {CheckDecision::CORRECT, CheckAction::CONTINUE}; + } + + break; + } + + parent = parent->Parent(); + } + ctx.AddCheckMessage("VARIABLE_NOT_ENCLOSE_SCOPE", *ast, ast->Start()); } if (!IsContainedIn(scope, encloseScope)) { diff --git a/ets2panda/compiler/core/ETSCompiler.cpp b/ets2panda/compiler/core/ETSCompiler.cpp index b4294f32735d79ea10d09dc362953ebcda80fd22..441dac41ba0509af261ca3a2b530f6550cd40e83 100644 --- a/ets2panda/compiler/core/ETSCompiler.cpp +++ b/ets2panda/compiler/core/ETSCompiler.cpp @@ -1497,7 +1497,7 @@ void ETSCompiler::Compile(const ir::BlockStatement *st) const template static void CompileImpl(const ir::BreakStatement *self, [[maybe_unused]] CodeGen *cg) { - compiler::Label *target = cg->ControlFlowChangeBreak(self->Ident()); + compiler::Label *target = cg->ControlFlowChangeBreak(self->Label()); cg->Branch(self, target); } @@ -1517,7 +1517,7 @@ void ETSCompiler::Compile([[maybe_unused]] const ir::ClassDeclaration *st) const static void CompileImpl(const ir::ContinueStatement *self, ETSGen *etsg) { - compiler::Label *target = etsg->ControlFlowChangeContinue(self->Ident()); + compiler::Label *target = etsg->ControlFlowChangeContinue(self->Label()); etsg->Branch(self, target); } diff --git a/ets2panda/compiler/core/JSCompiler.cpp b/ets2panda/compiler/core/JSCompiler.cpp index 8d07f3f793126ee17947fd7b3c3a577b744467bb..f6ab02ba6b85a68ee55083aba344aaaf6c05edc9 100644 --- a/ets2panda/compiler/core/JSCompiler.cpp +++ b/ets2panda/compiler/core/JSCompiler.cpp @@ -1470,7 +1470,7 @@ void JSCompiler::Compile(const ir::BlockStatement *st) const template static void CompileImpl(const ir::BreakStatement *self, [[maybe_unused]] CodeGen *cg) { - compiler::Label *target = cg->ControlFlowChangeBreak(self->Ident()); + compiler::Label *target = cg->ControlFlowChangeBreak(self->Label()); cg->Branch(self, target); } void JSCompiler::Compile(const ir::BreakStatement *st) const @@ -1489,7 +1489,7 @@ void JSCompiler::Compile(const ir::ClassDeclaration *st) const static void CompileImpl(const ir::ContinueStatement *self, PandaGen *cg) { - compiler::Label *target = cg->ControlFlowChangeContinue(self->Ident()); + compiler::Label *target = cg->ControlFlowChangeContinue(self->Label()); cg->Branch(self, target); } diff --git a/ets2panda/compiler/core/codeGen.cpp b/ets2panda/compiler/core/codeGen.cpp index f7a00e0dc90ca462c2ffc5c6274d7726a5bd469c..535801aacae2b102cd84f6703b7f8bb7368e1fdc 100644 --- a/ets2panda/compiler/core/codeGen.cpp +++ b/ets2panda/compiler/core/codeGen.cpp @@ -199,11 +199,11 @@ bool CodeGen::CheckControlFlowChange() const return false; } -Label *CodeGen::ControlFlowChangeBreak(const ir::Identifier *label) +Label *CodeGen::ControlFlowChangeBreak(const util::StringView &label) { auto *iter = dynamicContext_; - util::StringView labelName = label != nullptr ? label->Name() : LabelTarget::BREAK_LABEL; + util::StringView labelName = label.Empty() ? LabelTarget::BREAK_LABEL : label; Label *breakTarget = nullptr; while (iter != nullptr) { @@ -226,10 +226,10 @@ Label *CodeGen::ControlFlowChangeBreak(const ir::Identifier *label) return breakTarget; } -Label *CodeGen::ControlFlowChangeContinue(const ir::Identifier *label) +Label *CodeGen::ControlFlowChangeContinue(const util::StringView &label) { auto *iter = dynamicContext_; - util::StringView labelName = label != nullptr ? label->Name() : LabelTarget::CONTINUE_LABEL; + util::StringView labelName = label.Empty() ? LabelTarget::CONTINUE_LABEL : label; Label *continueTarget = nullptr; while (iter != nullptr) { diff --git a/ets2panda/compiler/core/codeGen.h b/ets2panda/compiler/core/codeGen.h index 6fd6a635051fe7d2b6d3cb008735c90dff272fb8..d6b6e1a6564ea0d7521410c980a65ef8ecfed898 100644 --- a/ets2panda/compiler/core/codeGen.h +++ b/ets2panda/compiler/core/codeGen.h @@ -132,8 +132,8 @@ public: void SetLabel(const ir::AstNode *node, Label *label); void Branch(const ir::AstNode *node, class Label *label); [[nodiscard]] bool CheckControlFlowChange() const; - Label *ControlFlowChangeBreak(const ir::Identifier *label = nullptr); - [[nodiscard]] Label *ControlFlowChangeContinue(const ir::Identifier *label); + Label *ControlFlowChangeBreak(const util::StringView &label = ""); + [[nodiscard]] Label *ControlFlowChangeContinue(const util::StringView &label); uint32_t TryDepth() const; [[nodiscard]] CatchTable *CreateCatchTable(util::StringView exceptionType = ""); diff --git a/ets2panda/compiler/core/dynamicContext.cpp b/ets2panda/compiler/core/dynamicContext.cpp index d1d3179c841891e847728859f33b5b8b1fc66a29..476d3163e4689f20a50cc49a4509b810f05cc922 100644 --- a/ets2panda/compiler/core/dynamicContext.cpp +++ b/ets2panda/compiler/core/dynamicContext.cpp @@ -42,7 +42,7 @@ DynamicContext::~DynamicContext() } LabelContext::LabelContext(CodeGen *cg, const ir::LabelledStatement *labelledStmt) - : DynamicContext(cg, LabelTarget(labelledStmt->Ident()->Name())), labelledStmt_(labelledStmt) + : DynamicContext(cg, LabelTarget(labelledStmt->Name())), labelledStmt_(labelledStmt) { if (!labelledStmt->Body()->IsBlockStatement()) { return; @@ -263,10 +263,10 @@ void ETSTryContext::EmitFinalizer( etsg->ReturnAcc(tryStmt_); } } else if (insertion.second->IsBreakStatement()) { - compiler::Label *target = etsg->ControlFlowChangeBreak(insertion.second->AsBreakStatement()->Ident()); + compiler::Label *target = etsg->ControlFlowChangeBreak(insertion.second->AsBreakStatement()->Label()); etsg->Branch(tryStmt_, target); } else if (insertion.second->IsContinueStatement()) { - compiler::Label *target = etsg->ControlFlowChangeContinue(insertion.second->AsContinueStatement()->Ident()); + compiler::Label *target = etsg->ControlFlowChangeContinue(insertion.second->AsContinueStatement()->Label()); etsg->Branch(tryStmt_, target); } else { UNREACHABLE(); diff --git a/ets2panda/compiler/lowering/ets/interfacePropertyDeclarations.cpp b/ets2panda/compiler/lowering/ets/interfacePropertyDeclarations.cpp index 9e099a1f1cca0d3b594bd77d1748d57cc4b0aced..7f4ad11294679bcbe4b8847ef79df0681f2a7d9c 100644 --- a/ets2panda/compiler/lowering/ets/interfacePropertyDeclarations.cpp +++ b/ets2panda/compiler/lowering/ets/interfacePropertyDeclarations.cpp @@ -76,6 +76,7 @@ static ir::MethodDefinition *GenerateGetterOrSetter(checker::ETSChecker *const c auto var = functionScope->AddDecl(checker->Allocator(), decl, ScriptExtension::ETS); methodIdent->SetVariable(var); + methodIdent->SetTsTypeAnnotation(nullptr); auto *funcExpr = checker->AllocNode(func); funcExpr->SetRange(func->Range()); @@ -94,8 +95,8 @@ static ir::MethodDefinition *GenerateGetterOrSetter(checker::ETSChecker *const c return method; } -static ir::Expression *UpdateInterfacePropertys(checker::ETSChecker *const checker, - ir::TSInterfaceBody *const interface) +static ir::Expression *UpdateInterfaceProperties(checker::ETSChecker *const checker, + ir::TSInterfaceBody *const interface) { if (interface->Body().empty()) { return interface; @@ -166,7 +167,7 @@ bool InterfacePropertyDeclarationsPhase::Perform(public_lib::Context *ctx, parse checker::ETSChecker *const checker = ctx->checker->AsETSChecker(); program->Ast()->TransformChildrenRecursively([checker](ir::AstNode *const ast) -> ir::AstNode * { - return ast->IsTSInterfaceBody() ? UpdateInterfacePropertys(checker, ast->AsTSInterfaceBody()) : ast; + return ast->IsTSInterfaceBody() ? UpdateInterfaceProperties(checker, ast->AsTSInterfaceBody()) : ast; }); return true; diff --git a/ets2panda/compiler/lowering/ets/unionLowering.cpp b/ets2panda/compiler/lowering/ets/unionLowering.cpp index ce7cb9be2a40f00d5416b80bf65d85cae5fcb83e..e16500cec0ff49b8f34f10df9c654c72da7b97f2 100644 --- a/ets2panda/compiler/lowering/ets/unionLowering.cpp +++ b/ets2panda/compiler/lowering/ets/unionLowering.cpp @@ -112,8 +112,10 @@ void HandleUnionPropertyAccess(checker::ETSChecker *checker, varbinder::VarBinde !parent->AsCallExpression()->Signature()->HasSignatureFlag(checker::SignatureFlags::TYPE)) { return; } - expr->SetPropVar( - CreateUnionFieldClassProperty(checker, vbind, expr->TsType(), expr->Property()->AsIdentifier()->Name())); + + auto var = CreateUnionFieldClassProperty(checker, vbind, expr->TsType(), expr->Property()->AsIdentifier()->Name()); + expr->SetPropVar(var); + expr->Property()->AsIdentifier()->SetVariable(var); ASSERT(expr->PropVar() != nullptr); } diff --git a/ets2panda/ir/statements/breakStatement.cpp b/ets2panda/ir/statements/breakStatement.cpp index f31ee1cccee1e316a2130dfbbdf445c262d4dbd7..f6e88e2fcf5cda0e67c9ca75744e54896464968d 100644 --- a/ets2panda/ir/statements/breakStatement.cpp +++ b/ets2panda/ir/statements/breakStatement.cpp @@ -24,31 +24,21 @@ #include "checker/ETSchecker.h" namespace ark::es2panda::ir { -void BreakStatement::TransformChildren(const NodeTransformer &cb) -{ - if (ident_ != nullptr) { - ident_ = cb(ident_)->AsIdentifier(); - } -} +void BreakStatement::TransformChildren(const NodeTransformer & /*cb*/) {} -void BreakStatement::Iterate(const NodeTraverser &cb) const -{ - if (ident_ != nullptr) { - cb(ident_); - } -} +void BreakStatement::Iterate(const NodeTraverser & /*cb*/) const {} void BreakStatement::Dump(ir::AstDumper *dumper) const { - dumper->Add({{"type", "BreakStatement"}, {"label", AstDumper::Nullish(ident_)}}); + dumper->Add({{"type", "BreakStatement"}, {"label", label_}}); } void BreakStatement::Dump(ir::SrcDumper *dumper) const { dumper->Add("break"); - if (ident_ != nullptr) { + if (!label_.Empty()) { dumper->Add(" "); - ident_->Dump(dumper); + dumper->Add(std::string(label_)); } dumper->Add(";"); } diff --git a/ets2panda/ir/statements/breakStatement.h b/ets2panda/ir/statements/breakStatement.h index 4e37906e39bb306ab4b9eccffe30fc6daa289514..d4c3de44d0b4d5b23fa55384b1d3339e317b9dff 100644 --- a/ets2panda/ir/statements/breakStatement.h +++ b/ets2panda/ir/statements/breakStatement.h @@ -32,14 +32,14 @@ class Identifier; class BreakStatement : public Statement { public: explicit BreakStatement() : Statement(AstNodeType::BREAK_STATEMENT) {} - explicit BreakStatement(Identifier *ident) : Statement(AstNodeType::BREAK_STATEMENT), ident_(ident) {} + explicit BreakStatement(util::StringView const label) : Statement(AstNodeType::BREAK_STATEMENT), label_(label) {} friend checker::ETSAnalyzer; friend compiler::ETSCompiler; - const Identifier *Ident() const + const util::StringView &Label() const { - return ident_; + return label_; } const ir::AstNode *Target() const @@ -62,7 +62,7 @@ public: } private: - Identifier *ident_ {}; + util::StringView label_ {}; const ir::AstNode *target_ {}; }; } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/statements/continueStatement.cpp b/ets2panda/ir/statements/continueStatement.cpp index d952b40801b62669a55bc178dd21407a62927fa1..13b2176f53c661e3217d74a548e9f7c7e9994d9f 100644 --- a/ets2panda/ir/statements/continueStatement.cpp +++ b/ets2panda/ir/statements/continueStatement.cpp @@ -22,28 +22,23 @@ #include "ir/srcDump.h" namespace ark::es2panda::ir { -void ContinueStatement::TransformChildren(const NodeTransformer &cb) -{ - if (ident_ != nullptr) { - ident_ = cb(ident_)->AsIdentifier(); - } -} +void ContinueStatement::TransformChildren(const NodeTransformer & /*cb*/) {} -void ContinueStatement::Iterate(const NodeTraverser &cb) const -{ - if (ident_ != nullptr) { - cb(ident_); - } -} +void ContinueStatement::Iterate(const NodeTraverser & /*cb*/) const {} void ContinueStatement::Dump(ir::AstDumper *dumper) const { - dumper->Add({{"type", "ContinueStatement"}, {"label", AstDumper::Nullish(ident_)}}); + dumper->Add({{"type", "ContinueStatement"}, {"label", label_}}); } void ContinueStatement::Dump(ir::SrcDumper *dumper) const { - dumper->Add("continue;"); + dumper->Add("continue"); + if (!label_.Empty()) { + dumper->Add(" "); + dumper->Add(std::string(label_)); + } + dumper->Add(";"); } void ContinueStatement::Compile(compiler::PandaGen *pg) const diff --git a/ets2panda/ir/statements/continueStatement.h b/ets2panda/ir/statements/continueStatement.h index 78a1dfda536eb3caa253fc77cfedd13ede7b645e..4b94aa17f01136c27d0ac460103a9c0a141024fd 100644 --- a/ets2panda/ir/statements/continueStatement.h +++ b/ets2panda/ir/statements/continueStatement.h @@ -31,15 +31,17 @@ namespace ark::es2panda::ir { class ContinueStatement : public Statement { public: explicit ContinueStatement() : Statement(AstNodeType::CONTINUE_STATEMENT) {} - explicit ContinueStatement(Identifier *ident) : Statement(AstNodeType::CONTINUE_STATEMENT), ident_(ident) {} + explicit ContinueStatement(util::StringView const label) : Statement(AstNodeType::CONTINUE_STATEMENT), label_(label) + { + } // NOTE (csabahurton): these friend relationships can be removed once there are getters for private fields friend class checker::ETSAnalyzer; friend class compiler::ETSCompiler; - const Identifier *Ident() const + const util::StringView &Label() const { - return ident_; + return label_; } const ir::AstNode *Target() const @@ -62,7 +64,7 @@ public: } private: - Identifier *ident_ {}; + util::StringView label_ {}; const ir::AstNode *target_ {}; }; } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/statements/labelledStatement.cpp b/ets2panda/ir/statements/labelledStatement.cpp index 7f5c185ba5a65fbba356a7c69a92cca0a8c3070a..9b5625f95f1cb0b11f76d74735e79709d9a23a5a 100644 --- a/ets2panda/ir/statements/labelledStatement.cpp +++ b/ets2panda/ir/statements/labelledStatement.cpp @@ -24,25 +24,22 @@ namespace ark::es2panda::ir { void LabelledStatement::TransformChildren(const NodeTransformer &cb) { - ident_ = cb(ident_)->AsIdentifier(); body_ = cb(body_)->AsStatement(); } void LabelledStatement::Iterate(const NodeTraverser &cb) const { - cb(ident_); cb(body_); } void LabelledStatement::Dump(ir::AstDumper *dumper) const { - dumper->Add({{"type", "LabelledStatement"}, {"label", ident_}, {"body", body_}}); + dumper->Add({{"type", "LabelledStatement"}, {"label", name_}, {"body", body_}}); } void LabelledStatement::Dump(ir::SrcDumper *dumper) const { - ASSERT(ident_ != nullptr); - ident_->Dump(dumper); + dumper->Add(std::string(name_)); dumper->Add(":"); dumper->Endl(); body_->Dump(dumper); diff --git a/ets2panda/ir/statements/labelledStatement.h b/ets2panda/ir/statements/labelledStatement.h index 82e5fe5cb0f7decd9ba9405c6c91733ddb96fe40..5bc507b24ca2f40479e75eed4f78de52febea25a 100644 --- a/ets2panda/ir/statements/labelledStatement.h +++ b/ets2panda/ir/statements/labelledStatement.h @@ -28,8 +28,8 @@ class Identifier; class LabelledStatement : public Statement { public: - explicit LabelledStatement(Identifier *ident, Statement *body) - : Statement(AstNodeType::LABELLED_STATEMENT), ident_(ident), body_(body) + explicit LabelledStatement(util::StringView const name, Statement *body) + : Statement(AstNodeType::LABELLED_STATEMENT), name_(name), body_(body) { } @@ -41,9 +41,9 @@ public: return body_; } - const Identifier *Ident() const + const util::StringView &Name() const { - return ident_; + return name_; } const ir::AstNode *GetReferencedStatement() const; @@ -70,7 +70,7 @@ public: } private: - Identifier *ident_; + util::StringView name_; Statement *body_; }; } // namespace ark::es2panda::ir diff --git a/ets2panda/parser/ETSparser.cpp b/ets2panda/parser/ETSparser.cpp index 423ba8807ee015a0e1c27c43a3c52a20c7090f60..ae36178d17b476f245d70e657261519d13c6e2b2 100644 --- a/ets2panda/parser/ETSparser.cpp +++ b/ets2panda/parser/ETSparser.cpp @@ -1126,8 +1126,6 @@ ir::MethodDefinition *ETSParser::ParseClassMethodDefinition(ir::Identifier *meth funcExpr, modifiers, Allocator(), false); method->SetRange(funcExpr->Range()); - func->Id()->SetReference(); - fieldMap_.insert({methodName->Name(), method}); return method; diff --git a/ets2panda/parser/statementParser.cpp b/ets2panda/parser/statementParser.cpp index 99e669f25576d52de7b2d0eca1c13a671871f5a3..18f8d210b65427044d2a9f4a9154d45603c66995 100644 --- a/ets2panda/parser/statementParser.cpp +++ b/ets2panda/parser/statementParser.cpp @@ -460,11 +460,7 @@ ir::BreakStatement *ParserImpl::ParseBreakStatement() ThrowSyntaxError("Undefined label"); } - auto *identNode = AllocNode(label, Allocator()); - identNode->SetReference(); - identNode->SetRange(lexer_->GetToken().Loc()); - - auto *breakStatement = AllocNode(identNode); + auto *breakStatement = AllocNode(label); breakStatement->SetRange({startLoc, lexer_->GetToken().End()}); lexer_->NextToken(); @@ -516,11 +512,7 @@ ir::ContinueStatement *ParserImpl::ParseContinueStatement() ThrowSyntaxError("Undefined label"); } - auto *identNode = AllocNode(label, Allocator()); - identNode->SetReference(); - identNode->SetRange(lexer_->GetToken().Loc()); - - auto *continueStatement = AllocNode(identNode); + auto *continueStatement = AllocNode(label); continueStatement->SetRange({startLoc, lexer_->GetToken().End()}); lexer_->NextToken(); @@ -1007,17 +999,13 @@ ir::LabelledStatement *ParserImpl::ParseLabelledStatement(const lexer::LexerPosi SavedParserContext newCtx(this, ParserStatus::IN_LABELED, actualLabel); - auto *identNode = AllocNode(actualLabel, Allocator()); - identNode->SetReference(); - identNode->SetRange(pos.GetToken().Loc()); - lexer_->NextToken(); ValidateLabeledStatement(Lexer()->GetToken().Type()); ir::Statement *body = ParseStatement(StatementParsingFlags::LABELLED); - auto *labeledStatement = AllocNode(identNode, body); + auto *labeledStatement = AllocNode(actualLabel, body); labeledStatement->SetRange({pos.GetToken().Start(), body->End()}); return labeledStatement; diff --git a/ets2panda/test/compiler/ets/switchStatementCorrectConversion-expected.txt b/ets2panda/test/compiler/ets/switchStatementCorrectConversion-expected.txt index f5a81fbd1934a113053aa29a82de54e32f03ce80..7d0099cd4c375aaac6d014cf3a292506995736ff 100644 --- a/ets2panda/test/compiler/ets/switchStatementCorrectConversion-expected.txt +++ b/ets2panda/test/compiler/ets/switchStatementCorrectConversion-expected.txt @@ -219,7 +219,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 21, @@ -262,7 +262,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 23, @@ -305,7 +305,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 25, @@ -348,7 +348,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 27, @@ -391,7 +391,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 29, @@ -634,7 +634,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 36, @@ -678,7 +678,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 38, diff --git a/ets2panda/test/compiler/ets/switchStatementWrongBoxing-expected.txt b/ets2panda/test/compiler/ets/switchStatementWrongBoxing-expected.txt index f893cf2cf947f21eb13ee07d5a94113356a00a8a..2956874fdda4a419e97c18cce9bfa0ed5a1d6e39 100644 --- a/ets2panda/test/compiler/ets/switchStatementWrongBoxing-expected.txt +++ b/ets2panda/test/compiler/ets/switchStatementWrongBoxing-expected.txt @@ -319,7 +319,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 23, diff --git a/ets2panda/test/parser/ets/AccessFannkuch-expected.txt b/ets2panda/test/parser/ets/AccessFannkuch-expected.txt index bf878c72fa03e37a869114189c2edde404646afe..1c188e0959395aa7a0e153ed4fcf50ac56d7e302 100644 --- a/ets2panda/test/parser/ets/AccessFannkuch-expected.txt +++ b/ets2panda/test/parser/ets/AccessFannkuch-expected.txt @@ -4619,7 +4619,7 @@ }, "consequent": { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 78, diff --git a/ets2panda/test/parser/ets/StringBase64-expected.txt b/ets2panda/test/parser/ets/StringBase64-expected.txt index c47c0dce3208a9aa1d854197f5e92603be3803d0..a29f1210c333d6d0e3acf7e3052f33427292569d 100644 --- a/ets2panda/test/parser/ets/StringBase64-expected.txt +++ b/ets2panda/test/parser/ets/StringBase64-expected.txt @@ -8407,7 +8407,7 @@ "statements": [ { "type": "ContinueStatement", - "label": null, + "label": "", "loc": { "start": { "line": 54, diff --git a/ets2panda/test/parser/ets/break-expected.txt b/ets2panda/test/parser/ets/break-expected.txt index c165861131c3dca33733e7b1a729bb99e726b1c6..ed28aa481e176a773e9c2befc06b9bf60f76f4bf 100644 --- a/ets2panda/test/parser/ets/break-expected.txt +++ b/ets2panda/test/parser/ets/break-expected.txt @@ -480,7 +480,7 @@ }, "consequent": { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 19, diff --git a/ets2panda/test/parser/ets/continue-expected.txt b/ets2panda/test/parser/ets/continue-expected.txt index cd8cfe6fabf65c4e7e0b788ab216c52b559ed281..552307390c85410b2f3839aeb01e0e3d0f0605a1 100644 --- a/ets2panda/test/parser/ets/continue-expected.txt +++ b/ets2panda/test/parser/ets/continue-expected.txt @@ -480,7 +480,7 @@ }, "consequent": { "type": "ContinueStatement", - "label": null, + "label": "", "loc": { "start": { "line": 19, diff --git a/ets2panda/test/parser/ets/for_with_break-expected.txt b/ets2panda/test/parser/ets/for_with_break-expected.txt index ec654926a4c6c689dcc4968235e4a51608ba437c..371da34cb041322c9e8d9b3a56224d765cec9857 100644 --- a/ets2panda/test/parser/ets/for_with_break-expected.txt +++ b/ets2panda/test/parser/ets/for_with_break-expected.txt @@ -618,7 +618,7 @@ "statements": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 23, diff --git a/ets2panda/test/parser/ets/labeledDoWhileStatement-expected.txt b/ets2panda/test/parser/ets/labeledDoWhileStatement-expected.txt index bac5b0dde578c83af3bd1802ea94dd496e2883dd..60e9416276e367058cc5490b32ef46e36148fb50 100644 --- a/ets2panda/test/parser/ets/labeledDoWhileStatement-expected.txt +++ b/ets2panda/test/parser/ets/labeledDoWhileStatement-expected.txt @@ -265,21 +265,7 @@ }, { "type": "LabelledStatement", - "label": { - "type": "Identifier", - "name": "label1", - "decorators": [], - "loc": { - "start": { - "line": 19, - "column": 3 - }, - "end": { - "line": 19, - "column": 9 - } - } - }, + "label": "label1", "body": { "type": "DoWhileStatement", "body": { @@ -419,21 +405,7 @@ "statements": [ { "type": "ContinueStatement", - "label": { - "type": "Identifier", - "name": "label1", - "decorators": [], - "loc": { - "start": { - "line": 23, - "column": 16 - }, - "end": { - "line": 23, - "column": 22 - } - } - }, + "label": "label1", "loc": { "start": { "line": 23, @@ -462,21 +434,7 @@ "statements": [ { "type": "BreakStatement", - "label": { - "type": "Identifier", - "name": "label1", - "decorators": [], - "loc": { - "start": { - "line": 25, - "column": 13 - }, - "end": { - "line": 25, - "column": 19 - } - } - }, + "label": "label1", "loc": { "start": { "line": 25, diff --git a/ets2panda/test/parser/ets/labeledForStatement-expected.txt b/ets2panda/test/parser/ets/labeledForStatement-expected.txt index cc597d92ce59ccab93c30f2b936fbe62b0d0aeb2..b4d3d6be64aa639f96e5d6e6c2b45b5125e3ae1a 100644 --- a/ets2panda/test/parser/ets/labeledForStatement-expected.txt +++ b/ets2panda/test/parser/ets/labeledForStatement-expected.txt @@ -207,21 +207,7 @@ "statements": [ { "type": "LabelledStatement", - "label": { - "type": "Identifier", - "name": "label1", - "decorators": [], - "loc": { - "start": { - "line": 17, - "column": 3 - }, - "end": { - "line": 17, - "column": 9 - } - } - }, + "label": "label1", "body": { "type": "ForUpdateStatement", "init": { @@ -408,21 +394,7 @@ "statements": [ { "type": "ContinueStatement", - "label": { - "type": "Identifier", - "name": "label1", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 16 - }, - "end": { - "line": 20, - "column": 22 - } - } - }, + "label": "label1", "loc": { "start": { "line": 20, @@ -451,21 +423,7 @@ "statements": [ { "type": "BreakStatement", - "label": { - "type": "Identifier", - "name": "label1", - "decorators": [], - "loc": { - "start": { - "line": 22, - "column": 13 - }, - "end": { - "line": 22, - "column": 19 - } - } - }, + "label": "label1", "loc": { "start": { "line": 22, @@ -536,21 +494,7 @@ }, { "type": "LabelledStatement", - "label": { - "type": "Identifier", - "name": "label2", - "decorators": [], - "loc": { - "start": { - "line": 26, - "column": 3 - }, - "end": { - "line": 26, - "column": 9 - } - } - }, + "label": "label2", "body": { "type": "ForUpdateStatement", "init": { @@ -930,21 +874,7 @@ "statements": [ { "type": "ContinueStatement", - "label": { - "type": "Identifier", - "name": "label2", - "decorators": [], - "loc": { - "start": { - "line": 30, - "column": 18 - }, - "end": { - "line": 30, - "column": 24 - } - } - }, + "label": "label2", "loc": { "start": { "line": 30, @@ -973,21 +903,7 @@ "statements": [ { "type": "BreakStatement", - "label": { - "type": "Identifier", - "name": "label2", - "decorators": [], - "loc": { - "start": { - "line": 32, - "column": 15 - }, - "end": { - "line": 32, - "column": 21 - } - } - }, + "label": "label2", "loc": { "start": { "line": 32, diff --git a/ets2panda/test/parser/ets/labeledSwitchStatement-expected.txt b/ets2panda/test/parser/ets/labeledSwitchStatement-expected.txt index a8ffaf63a76f86d1c5b4fb27cfd3a0f933a1f312..8fc72b69f20fbe69f64022be747c7dd140777dae 100644 --- a/ets2panda/test/parser/ets/labeledSwitchStatement-expected.txt +++ b/ets2panda/test/parser/ets/labeledSwitchStatement-expected.txt @@ -336,21 +336,7 @@ }, { "type": "LabelledStatement", - "label": { - "type": "Identifier", - "name": "label1", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 5 - }, - "end": { - "line": 20, - "column": 11 - } - } - }, + "label": "label1", "body": { "type": "ForUpdateStatement", "init": { @@ -608,7 +594,7 @@ }, { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 26, @@ -707,21 +693,7 @@ }, { "type": "ContinueStatement", - "label": { - "type": "Identifier", - "name": "label1", - "decorators": [], - "loc": { - "start": { - "line": 29, - "column": 26 - }, - "end": { - "line": 29, - "column": 32 - } - } - }, + "label": "label1", "loc": { "start": { "line": 29, @@ -1266,21 +1238,7 @@ "statements": [ { "type": "LabelledStatement", - "label": { - "type": "Identifier", - "name": "label1", - "decorators": [], - "loc": { - "start": { - "line": 41, - "column": 9 - }, - "end": { - "line": 41, - "column": 15 - } - } - }, + "label": "label1", "body": { "type": "SwitchStatement", "discriminant": { @@ -1402,7 +1360,7 @@ }, { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 46, @@ -1501,21 +1459,7 @@ }, { "type": "BreakStatement", - "label": { - "type": "Identifier", - "name": "label1", - "decorators": [], - "loc": { - "start": { - "line": 49, - "column": 23 - }, - "end": { - "line": 49, - "column": 29 - } - } - }, + "label": "label1", "loc": { "start": { "line": 49, diff --git a/ets2panda/test/parser/ets/labeledWhileStatement-expected.txt b/ets2panda/test/parser/ets/labeledWhileStatement-expected.txt index c7ac60a0eaab52b232583f06722f3b5842807be9..45b5e30e67c4c980bc40faf2f21e6043e1f216c0 100644 --- a/ets2panda/test/parser/ets/labeledWhileStatement-expected.txt +++ b/ets2panda/test/parser/ets/labeledWhileStatement-expected.txt @@ -381,21 +381,7 @@ }, { "type": "LabelledStatement", - "label": { - "type": "Identifier", - "name": "label1", - "decorators": [], - "loc": { - "start": { - "line": 21, - "column": 3 - }, - "end": { - "line": 21, - "column": 9 - } - } - }, + "label": "label1", "body": { "type": "WhileStatement", "test": { @@ -565,21 +551,7 @@ }, { "type": "ContinueStatement", - "label": { - "type": "Identifier", - "name": "label1", - "decorators": [], - "loc": { - "start": { - "line": 25, - "column": 16 - }, - "end": { - "line": 25, - "column": 22 - } - } - }, + "label": "label1", "loc": { "start": { "line": 25, @@ -608,21 +580,7 @@ "statements": [ { "type": "BreakStatement", - "label": { - "type": "Identifier", - "name": "label1", - "decorators": [], - "loc": { - "start": { - "line": 27, - "column": 13 - }, - "end": { - "line": 27, - "column": 19 - } - } - }, + "label": "label1", "loc": { "start": { "line": 27, @@ -693,21 +651,7 @@ }, { "type": "LabelledStatement", - "label": { - "type": "Identifier", - "name": "label2", - "decorators": [], - "loc": { - "start": { - "line": 31, - "column": 3 - }, - "end": { - "line": 31, - "column": 9 - } - } - }, + "label": "label2", "body": { "type": "WhileStatement", "test": { @@ -806,7 +750,7 @@ "statements": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 34, @@ -941,21 +885,7 @@ "statements": [ { "type": "BreakStatement", - "label": { - "type": "Identifier", - "name": "label2", - "decorators": [], - "loc": { - "start": { - "line": 39, - "column": 15 - }, - "end": { - "line": 39, - "column": 21 - } - } - }, + "label": "label2", "loc": { "start": { "line": 39, @@ -1084,21 +1014,7 @@ }, { "type": "ContinueStatement", - "label": { - "type": "Identifier", - "name": "label2", - "decorators": [], - "loc": { - "start": { - "line": 43, - "column": 18 - }, - "end": { - "line": 43, - "column": 24 - } - } - }, + "label": "label2", "loc": { "start": { "line": 43, diff --git a/ets2panda/test/parser/ets/loops-expected.txt b/ets2panda/test/parser/ets/loops-expected.txt index c30aa0c543d6905a26aa534fdad4bcb7447d2de7..12440139d50ae5d2ee467a7df60f2c2021781129 100644 --- a/ets2panda/test/parser/ets/loops-expected.txt +++ b/ets2panda/test/parser/ets/loops-expected.txt @@ -340,7 +340,7 @@ }, "body": { "type": "ContinueStatement", - "label": null, + "label": "", "loc": { "start": { "line": 17, @@ -541,7 +541,7 @@ }, "body": { "type": "ContinueStatement", - "label": null, + "label": "", "loc": { "start": { "line": 19, @@ -787,7 +787,7 @@ "statements": [ { "type": "ContinueStatement", - "label": null, + "label": "", "loc": { "start": { "line": 23, @@ -1017,7 +1017,7 @@ }, "body": { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 31, @@ -1626,21 +1626,7 @@ "statements": [ { "type": "LabelledStatement", - "label": { - "type": "Identifier", - "name": "loop1", - "decorators": [], - "loc": { - "start": { - "line": 47, - "column": 3 - }, - "end": { - "line": 47, - "column": 8 - } - } - }, + "label": "loop1", "body": { "type": "ForUpdateStatement", "init": { @@ -1779,21 +1765,7 @@ "statements": [ { "type": "LabelledStatement", - "label": { - "type": "Identifier", - "name": "loop2", - "decorators": [], - "loc": { - "start": { - "line": 49, - "column": 5 - }, - "end": { - "line": 49, - "column": 10 - } - } - }, + "label": "loop2", "body": { "type": "ForUpdateStatement", "init": { @@ -1932,21 +1904,7 @@ "statements": [ { "type": "BreakStatement", - "label": { - "type": "Identifier", - "name": "loop1", - "decorators": [], - "loc": { - "start": { - "line": 51, - "column": 13 - }, - "end": { - "line": 51, - "column": 18 - } - } - }, + "label": "loop1", "loc": { "start": { "line": 51, @@ -2164,21 +2122,7 @@ "statements": [ { "type": "LabelledStatement", - "label": { - "type": "Identifier", - "name": "loop1", - "decorators": [], - "loc": { - "start": { - "line": 58, - "column": 3 - }, - "end": { - "line": 58, - "column": 8 - } - } - }, + "label": "loop1", "body": { "type": "ForUpdateStatement", "init": { @@ -2317,21 +2261,7 @@ "statements": [ { "type": "LabelledStatement", - "label": { - "type": "Identifier", - "name": "loop2", - "decorators": [], - "loc": { - "start": { - "line": 60, - "column": 5 - }, - "end": { - "line": 60, - "column": 10 - } - } - }, + "label": "loop2", "body": { "type": "ForUpdateStatement", "init": { @@ -2470,21 +2400,7 @@ "statements": [ { "type": "ContinueStatement", - "label": { - "type": "Identifier", - "name": "loop1", - "decorators": [], - "loc": { - "start": { - "line": 62, - "column": 16 - }, - "end": { - "line": 62, - "column": 21 - } - } - }, + "label": "loop1", "loc": { "start": { "line": 62, diff --git a/ets2panda/test/parser/ets/switch-expected.txt b/ets2panda/test/parser/ets/switch-expected.txt index bf956fcd086802d94b8b28740a56183a281625f9..ad6b40e789c0a9623c4fe1c7d69d131f35944b69 100644 --- a/ets2panda/test/parser/ets/switch-expected.txt +++ b/ets2panda/test/parser/ets/switch-expected.txt @@ -511,7 +511,7 @@ }, { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 24, @@ -610,7 +610,7 @@ }, { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 27, diff --git a/ets2panda/test/parser/ets/switch2-expected.txt b/ets2panda/test/parser/ets/switch2-expected.txt index 0f1939f693fbe2e2e122aadc5cc8d691f270d99d..c63e4340424404fc29021069f817b9d969dbca24 100644 --- a/ets2panda/test/parser/ets/switch2-expected.txt +++ b/ets2panda/test/parser/ets/switch2-expected.txt @@ -468,7 +468,7 @@ }, { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 24, @@ -567,7 +567,7 @@ }, { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 27, diff --git a/ets2panda/test/parser/ets/switch_alive_3-expected.txt b/ets2panda/test/parser/ets/switch_alive_3-expected.txt index 192c2db57d8dfcf9819bdfc12452885675ad3a5e..6aae12bfbf5ae85999dca46de3ad3abb6e88d49a 100644 --- a/ets2panda/test/parser/ets/switch_alive_3-expected.txt +++ b/ets2panda/test/parser/ets/switch_alive_3-expected.txt @@ -250,21 +250,7 @@ }, { "type": "LabelledStatement", - "label": { - "type": "Identifier", - "name": "label", - "decorators": [], - "loc": { - "start": { - "line": 18, - "column": 2 - }, - "end": { - "line": 18, - "column": 7 - } - } - }, + "label": "label", "body": { "type": "SwitchStatement", "discriminant": { @@ -430,21 +416,7 @@ "consequent": [ { "type": "BreakStatement", - "label": { - "type": "Identifier", - "name": "label", - "decorators": [], - "loc": { - "start": { - "line": 24, - "column": 10 - }, - "end": { - "line": 24, - "column": 15 - } - } - }, + "label": "label", "loc": { "start": { "line": 24, diff --git a/ets2panda/test/parser/ets/switch_alive_4-expected.txt b/ets2panda/test/parser/ets/switch_alive_4-expected.txt index 82326cbb0ae882638b1dc4090b539ad6834fb385..2f5609578502f1e3a64952569c7ef4c06174121e 100644 --- a/ets2panda/test/parser/ets/switch_alive_4-expected.txt +++ b/ets2panda/test/parser/ets/switch_alive_4-expected.txt @@ -256,7 +256,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 19, @@ -299,7 +299,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 21, diff --git a/ets2panda/test/parser/ets/switch_char_compare_num-expected.txt b/ets2panda/test/parser/ets/switch_char_compare_num-expected.txt index 8036ad04b7034c0f3225e2e5a51452d64ea77907..283fe753c4b2b3951dd238d98a163cf90442e704 100644 --- a/ets2panda/test/parser/ets/switch_char_compare_num-expected.txt +++ b/ets2panda/test/parser/ets/switch_char_compare_num-expected.txt @@ -259,7 +259,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 20, @@ -302,7 +302,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 22, diff --git a/ets2panda/test/parser/ets/switch_const_int_compare_char_duplicate-expected.txt b/ets2panda/test/parser/ets/switch_const_int_compare_char_duplicate-expected.txt index f9440905719bc3e9821b2c7d3088f0cdabbec217..6d9cfea92479880689d57cfef48cde8d0af673b4 100644 --- a/ets2panda/test/parser/ets/switch_const_int_compare_char_duplicate-expected.txt +++ b/ets2panda/test/parser/ets/switch_const_int_compare_char_duplicate-expected.txt @@ -331,7 +331,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 21, @@ -374,7 +374,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 23, @@ -404,7 +404,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 25, diff --git a/ets2panda/test/parser/ets/switch_enum-expected.txt b/ets2panda/test/parser/ets/switch_enum-expected.txt index f4d9debe2d3c00c3b64e1134432875b7e5a97fe1..2dd8d9657afa8be71282deecbdcd87f0d4f11535 100644 --- a/ets2panda/test/parser/ets/switch_enum-expected.txt +++ b/ets2panda/test/parser/ets/switch_enum-expected.txt @@ -460,7 +460,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 20, @@ -534,7 +534,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 21, @@ -564,7 +564,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 23, diff --git a/ets2panda/test/parser/ets/switch_enum2-expected.txt b/ets2panda/test/parser/ets/switch_enum2-expected.txt index 59ed0f5ca2428204a9f25a66938e7acf8ff9599f..d82145106cbe5e56f2f4769d125470954154bd81 100644 --- a/ets2panda/test/parser/ets/switch_enum2-expected.txt +++ b/ets2panda/test/parser/ets/switch_enum2-expected.txt @@ -429,7 +429,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 20, @@ -459,7 +459,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 22, diff --git a/ets2panda/test/parser/ets/switch_enum_case_duplicate-expected.txt b/ets2panda/test/parser/ets/switch_enum_case_duplicate-expected.txt index 7a8067085bf7854c587c93d7f1cef7c3622c47dc..6bf4b5f3244f7ea62578a940e5ca5853a59612da 100644 --- a/ets2panda/test/parser/ets/switch_enum_case_duplicate-expected.txt +++ b/ets2panda/test/parser/ets/switch_enum_case_duplicate-expected.txt @@ -519,7 +519,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 24, @@ -593,7 +593,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 26, @@ -667,7 +667,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 28, diff --git a/ets2panda/test/parser/ets/switch_num_compare_char-expected.txt b/ets2panda/test/parser/ets/switch_num_compare_char-expected.txt index 2882c10890872801018770825935240251c2049a..3ec3a360582b2997b7d429b8bb592b9d2bd78e71 100644 --- a/ets2panda/test/parser/ets/switch_num_compare_char-expected.txt +++ b/ets2panda/test/parser/ets/switch_num_compare_char-expected.txt @@ -259,7 +259,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 20, @@ -302,7 +302,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 22, diff --git a/ets2panda/test/parser/ets/switch_num_compare_char_duplicate-expected.txt b/ets2panda/test/parser/ets/switch_num_compare_char_duplicate-expected.txt index e57b79c726a49993c241776299f4ccf166d8ddf9..17d261e96f274f236e18c31c000c0a7a4bbf8c44 100644 --- a/ets2panda/test/parser/ets/switch_num_compare_char_duplicate-expected.txt +++ b/ets2panda/test/parser/ets/switch_num_compare_char_duplicate-expected.txt @@ -259,7 +259,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 20, @@ -302,7 +302,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 22, diff --git a/ets2panda/test/parser/ets/switch_readonly_member-expected.txt b/ets2panda/test/parser/ets/switch_readonly_member-expected.txt index a0429f6a7db7e3a089173aa136253133094a590e..5371c7c87fb3ebbea348ff51cea173986a6c62dc 100644 --- a/ets2panda/test/parser/ets/switch_readonly_member-expected.txt +++ b/ets2panda/test/parser/ets/switch_readonly_member-expected.txt @@ -664,7 +664,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 28, @@ -738,7 +738,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 30, @@ -768,7 +768,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 31, diff --git a/ets2panda/test/parser/ets/switch_readonly_member_compare_char-expected.txt b/ets2panda/test/parser/ets/switch_readonly_member_compare_char-expected.txt index 04b54186be83e3fcdd5aeaf816dea2c58e7b2b34..9305a66978acdfdb35b1d971a9d3bbd5f121331f 100644 --- a/ets2panda/test/parser/ets/switch_readonly_member_compare_char-expected.txt +++ b/ets2panda/test/parser/ets/switch_readonly_member_compare_char-expected.txt @@ -664,7 +664,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 28, @@ -738,7 +738,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 30, @@ -781,7 +781,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 32, @@ -811,7 +811,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 33, diff --git a/ets2panda/test/parser/ets/switch_readonly_member_compare_char_2-expected.txt b/ets2panda/test/parser/ets/switch_readonly_member_compare_char_2-expected.txt index 0f99422e115d451281e74d7b5b26e20b74623338..cb2b99415a5ff18aa6dcec8917ab3d541330af04 100644 --- a/ets2panda/test/parser/ets/switch_readonly_member_compare_char_2-expected.txt +++ b/ets2panda/test/parser/ets/switch_readonly_member_compare_char_2-expected.txt @@ -633,7 +633,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 28, @@ -707,7 +707,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 30, @@ -781,7 +781,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 32, @@ -811,7 +811,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 33, diff --git a/ets2panda/test/parser/ets/switch_readonly_member_different_enum-expected.txt b/ets2panda/test/parser/ets/switch_readonly_member_different_enum-expected.txt index 8ce637786ed4b25f6795d7702a6ff7bbf84107ff..69de309c1a737ff29f571d16c68d1f4bef9c9405 100644 --- a/ets2panda/test/parser/ets/switch_readonly_member_different_enum-expected.txt +++ b/ets2panda/test/parser/ets/switch_readonly_member_different_enum-expected.txt @@ -1071,7 +1071,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 36, @@ -1145,7 +1145,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 38, @@ -1175,7 +1175,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 39, diff --git a/ets2panda/test/parser/ets/switch_readonly_member_different_enum_2-expected.txt b/ets2panda/test/parser/ets/switch_readonly_member_different_enum_2-expected.txt index 5891ffb6e13f852b8cc5f8a4a7e84a53ebbba50b..a6a6fe042a8b24e43788ae4b2b1db71fdd60b14b 100644 --- a/ets2panda/test/parser/ets/switch_readonly_member_different_enum_2-expected.txt +++ b/ets2panda/test/parser/ets/switch_readonly_member_different_enum_2-expected.txt @@ -1071,7 +1071,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 35, @@ -1145,7 +1145,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 37, @@ -1175,7 +1175,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 38, diff --git a/ets2panda/test/parser/ets/switch_readonly_member_enum_duplicate-expected.txt b/ets2panda/test/parser/ets/switch_readonly_member_enum_duplicate-expected.txt index c37cacffebdfd380c90cdc1ad55f41fe2d790157..ad5e2627ae91a6d8c1cf9822debdde80cbc623c8 100644 --- a/ets2panda/test/parser/ets/switch_readonly_member_enum_duplicate-expected.txt +++ b/ets2panda/test/parser/ets/switch_readonly_member_enum_duplicate-expected.txt @@ -1071,7 +1071,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 36, @@ -1145,7 +1145,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 38, @@ -1175,7 +1175,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 39, diff --git a/ets2panda/test/parser/ets/switch_readonly_member_number_duplicate-expected.txt b/ets2panda/test/parser/ets/switch_readonly_member_number_duplicate-expected.txt index 2ce1ff962ac981cf80603be3f45e0c24c4a9b352..ba97b752622011eb4debc4dca60aeef41b8c316b 100644 --- a/ets2panda/test/parser/ets/switch_readonly_member_number_duplicate-expected.txt +++ b/ets2panda/test/parser/ets/switch_readonly_member_number_duplicate-expected.txt @@ -664,7 +664,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 28, @@ -738,7 +738,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 30, @@ -768,7 +768,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 31, diff --git a/ets2panda/test/parser/ets/swtich_not_const-expected.txt b/ets2panda/test/parser/ets/swtich_not_const-expected.txt index a049cd5919a301c9c93116adb261876c4061ce4a..1dbeda6226a139f0c3aaba8138ffb0f849e277ee 100644 --- a/ets2panda/test/parser/ets/swtich_not_const-expected.txt +++ b/ets2panda/test/parser/ets/swtich_not_const-expected.txt @@ -318,7 +318,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 21, @@ -361,7 +361,7 @@ "consequent": [ { "type": "BreakStatement", - "label": null, + "label": "", "loc": { "start": { "line": 23,