From 7f0878699923f79978c9f1d78dc025d095a3391c Mon Sep 17 00:00:00 2001 From: oh_ci Date: Mon, 25 Aug 2025 09:28:47 +0000 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E9=80=80=20'Pull=20Request=20!8006=20?= =?UTF-8?q?:=20cherry-pick=20fix=5Flabelled=5Fstatement=20to=20master'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../compiler/lowering/ets/objectIterator.cpp | 11 ++++---- ets2panda/ir/statements/continueStatement.cpp | 7 +---- .../test/ast/parser/ets/labelled_for_of.ets | 21 --------------- ets2panda/test/runtime/ets/fix_labelled.ets | 27 ------------------- 4 files changed, 6 insertions(+), 60 deletions(-) delete mode 100644 ets2panda/test/ast/parser/ets/labelled_for_of.ets delete mode 100644 ets2panda/test/runtime/ets/fix_labelled.ets diff --git a/ets2panda/compiler/lowering/ets/objectIterator.cpp b/ets2panda/compiler/lowering/ets/objectIterator.cpp index 6e7bf4535a7..6f6cd05334c 100644 --- a/ets2panda/compiler/lowering/ets/objectIterator.cpp +++ b/ets2panda/compiler/lowering/ets/objectIterator.cpp @@ -176,17 +176,16 @@ ir::Statement *ObjectIteratorLowering::ProcessObjectIterator(public_lib::Context loweringResult->SetParent(forOfStatement->Parent()); loweringResult->SetRange(forOfStatement->Range()); - auto loweredWhile = loweringResult->AsBlockStatement()->Statements()[WHILE_LOOP_POSITION]->AsWhileStatement(); - auto whileBody = loweredWhile->Body()->AsBlockStatement(); - TransferForOfLoopBody(forOfStatement->Body(), whileBody); + TransferForOfLoopBody(forOfStatement->Body(), loweringResult->AsBlockStatement() + ->Statements()[WHILE_LOOP_POSITION] + ->AsWhileStatement() + ->Body() + ->AsBlockStatement()); auto *const checker = ctx->checker->AsETSChecker(); ES2PANDA_ASSERT(checker != nullptr); CheckLoweredNode(varbinder, checker, loweringResult); - if (loweringResult->Parent()->IsLabelledStatement()) { - loweringResult->Parent()->AsLabelledStatement()->Ident()->Variable()->GetScope()->BindNode(loweringResult); - } return loweringResult; } diff --git a/ets2panda/ir/statements/continueStatement.cpp b/ets2panda/ir/statements/continueStatement.cpp index ab35d97e73d..8b73763a7df 100644 --- a/ets2panda/ir/statements/continueStatement.cpp +++ b/ets2panda/ir/statements/continueStatement.cpp @@ -46,12 +46,7 @@ void ContinueStatement::Dump(ir::AstDumper *dumper) const void ContinueStatement::Dump(ir::SrcDumper *dumper) const { - dumper->Add("continue"); - if (Ident() != nullptr) { - dumper->Add(" "); - Ident()->Dump(dumper); - } - dumper->Add(";"); + dumper->Add("continue;"); } void ContinueStatement::Compile(compiler::PandaGen *pg) const diff --git a/ets2panda/test/ast/parser/ets/labelled_for_of.ets b/ets2panda/test/ast/parser/ets/labelled_for_of.ets deleted file mode 100644 index 882614cc8d9..00000000000 --- a/ets2panda/test/ast/parser/ets/labelled_for_of.ets +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2024-2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -function foo(){ - let arr1: int[] = [0,1,2] - loop1: for(let y of arr1){ - continue loop1; - } -} diff --git a/ets2panda/test/runtime/ets/fix_labelled.ets b/ets2panda/test/runtime/ets/fix_labelled.ets deleted file mode 100644 index 4b207bda5c3..00000000000 --- a/ets2panda/test/runtime/ets/fix_labelled.ets +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -function main(){ - let arr1: int[] = [0,1,2,3,4,5] - let arr2: int[] = [6,7,8,9,10,11] - let sum=0 - loop1: for(let y of arr1){ - for(let c of arr2){ - sum+=c*y - continue loop1; - } - } - arktest.assertEQ(sum, 6*(1+2+3+4+5)) -} \ No newline at end of file -- Gitee