From 57d8ff68bd42bed97628eb5f7d8f6da8d1724b80 Mon Sep 17 00:00:00 2001 From: openharmony_ci <120357966@qq.com> Date: Wed, 26 Jul 2023 03:23:12 +0000 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E9=80=80=20'Pull=20Request=20!1127=20?= =?UTF-8?q?:=20Cherry-pick=20of=20PR1114'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- es2panda/compiler/core/envScope.cpp | 9 ----- es2panda/compiler/core/envScope.h | 2 -- es2panda/ir/statements/doWhileStatement.cpp | 7 ++-- .../do-while-body-lexical-break-expected.txt | 1 - .../lexicalEnv/do-while-body-lexical-break.js | 29 ---------------- ...o-while-body-lexical-continue-expected.txt | 1 - .../do-while-body-lexical-continue.js | 34 ------------------- .../do-while-body-lexical-expected.txt | 1 - .../do-while-body-lexical-return-expected.txt | 1 - .../do-while-body-lexical-return.js | 29 ---------------- .../js/lexicalEnv/do-while-body-lexical.js | 29 ---------------- 11 files changed, 4 insertions(+), 139 deletions(-) delete mode 100644 es2panda/test/compiler/js/lexicalEnv/do-while-body-lexical-break-expected.txt delete mode 100644 es2panda/test/compiler/js/lexicalEnv/do-while-body-lexical-break.js delete mode 100644 es2panda/test/compiler/js/lexicalEnv/do-while-body-lexical-continue-expected.txt delete mode 100644 es2panda/test/compiler/js/lexicalEnv/do-while-body-lexical-continue.js delete mode 100644 es2panda/test/compiler/js/lexicalEnv/do-while-body-lexical-expected.txt delete mode 100644 es2panda/test/compiler/js/lexicalEnv/do-while-body-lexical-return-expected.txt delete mode 100644 es2panda/test/compiler/js/lexicalEnv/do-while-body-lexical-return.js delete mode 100644 es2panda/test/compiler/js/lexicalEnv/do-while-body-lexical.js diff --git a/es2panda/compiler/core/envScope.cpp b/es2panda/compiler/core/envScope.cpp index 7aff0e1bfb..aa3e98344a 100644 --- a/es2panda/compiler/core/envScope.cpp +++ b/es2panda/compiler/core/envScope.cpp @@ -81,13 +81,4 @@ void LoopEnvScope::CopyPerIterationCtx() } } -void LoopEnvScope::PopLexEnvBeforeTheNextIter() -{ - if (!HasEnv()) { - return; - } - - pg_->PopLexEnv(scope_->Node()); -} - } // namespace panda::es2panda::compiler diff --git a/es2panda/compiler/core/envScope.h b/es2panda/compiler/core/envScope.h index 147a2230ac..73085741bf 100644 --- a/es2panda/compiler/core/envScope.h +++ b/es2panda/compiler/core/envScope.h @@ -93,8 +93,6 @@ public: void CopyPerIterationCtx(); - void PopLexEnvBeforeTheNextIter(); - private: static bool NeedEnv(binder::VariableScope *scope) { diff --git a/es2panda/ir/statements/doWhileStatement.cpp b/es2panda/ir/statements/doWhileStatement.cpp index 359adf736f..d5b05b8bf5 100644 --- a/es2panda/ir/statements/doWhileStatement.cpp +++ b/es2panda/ir/statements/doWhileStatement.cpp @@ -44,12 +44,13 @@ void DoWhileStatement::Compile(compiler::PandaGen *pg) const pg->SetLabel(this, startLabel); - compiler::LoopEnvScope envScope(pg, labelTarget, scope_); - body_->Compile(pg); + { + compiler::LoopEnvScope envScope(pg, labelTarget, scope_); + body_->Compile(pg); + } pg->SetLabel(this, labelTarget.ContinueTarget()); compiler::Condition::Compile(pg, this->Test(), labelTarget.BreakTarget()); - envScope.PopLexEnvBeforeTheNextIter(); pg->Branch(this, startLabel); pg->SetLabel(this, labelTarget.BreakTarget()); diff --git a/es2panda/test/compiler/js/lexicalEnv/do-while-body-lexical-break-expected.txt b/es2panda/test/compiler/js/lexicalEnv/do-while-body-lexical-break-expected.txt deleted file mode 100644 index d00491fd7e..0000000000 --- a/es2panda/test/compiler/js/lexicalEnv/do-while-body-lexical-break-expected.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/es2panda/test/compiler/js/lexicalEnv/do-while-body-lexical-break.js b/es2panda/test/compiler/js/lexicalEnv/do-while-body-lexical-break.js deleted file mode 100644 index 56f5e8e8f8..0000000000 --- a/es2panda/test/compiler/js/lexicalEnv/do-while-body-lexical-break.js +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -let c; -let b = 1; -function x() { - do { - let a = 1; - c = function b() { - print(a); - } - break; - } while ((() => { return b })() == 1) -} - -x(); -c(); diff --git a/es2panda/test/compiler/js/lexicalEnv/do-while-body-lexical-continue-expected.txt b/es2panda/test/compiler/js/lexicalEnv/do-while-body-lexical-continue-expected.txt deleted file mode 100644 index d00491fd7e..0000000000 --- a/es2panda/test/compiler/js/lexicalEnv/do-while-body-lexical-continue-expected.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/es2panda/test/compiler/js/lexicalEnv/do-while-body-lexical-continue.js b/es2panda/test/compiler/js/lexicalEnv/do-while-body-lexical-continue.js deleted file mode 100644 index 2e06e43af6..0000000000 --- a/es2panda/test/compiler/js/lexicalEnv/do-while-body-lexical-continue.js +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -let c; -let b = 1; -function x() { - do { - let a = 1; - if (b == 1) { - b++; - continue; - } - - c = function b() { - print(a); - } - b++; - } while ((() => { return b })() != 3) -} - -x(); -c(); diff --git a/es2panda/test/compiler/js/lexicalEnv/do-while-body-lexical-expected.txt b/es2panda/test/compiler/js/lexicalEnv/do-while-body-lexical-expected.txt deleted file mode 100644 index d00491fd7e..0000000000 --- a/es2panda/test/compiler/js/lexicalEnv/do-while-body-lexical-expected.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/es2panda/test/compiler/js/lexicalEnv/do-while-body-lexical-return-expected.txt b/es2panda/test/compiler/js/lexicalEnv/do-while-body-lexical-return-expected.txt deleted file mode 100644 index d00491fd7e..0000000000 --- a/es2panda/test/compiler/js/lexicalEnv/do-while-body-lexical-return-expected.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/es2panda/test/compiler/js/lexicalEnv/do-while-body-lexical-return.js b/es2panda/test/compiler/js/lexicalEnv/do-while-body-lexical-return.js deleted file mode 100644 index 2a1db269e7..0000000000 --- a/es2panda/test/compiler/js/lexicalEnv/do-while-body-lexical-return.js +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -let c; -let b = 1; -function x() { - do { - let a = 1; - c = function b() { - print(a); - } - return; - } while ((() => { return b })() == 1) -} - -x() -c(); diff --git a/es2panda/test/compiler/js/lexicalEnv/do-while-body-lexical.js b/es2panda/test/compiler/js/lexicalEnv/do-while-body-lexical.js deleted file mode 100644 index 938eac345a..0000000000 --- a/es2panda/test/compiler/js/lexicalEnv/do-while-body-lexical.js +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -let c; -let b = 1; -function x() { - do { - let a = 1; - c = function b() { - print(a); - } - b++; - } while ((() => { return b })() == 1) -} - -x(); -c(); -- Gitee