From 3771cea6a6e1d6bebae826bd68c021c26f567b18 Mon Sep 17 00:00:00 2001 From: Peter Pronai Date: Thu, 17 Jul 2025 13:43:35 +0000 Subject: [PATCH] Remove assert keyword leftovers Remove legacy assert statement in favor of assert function. Fixes #27950 internal issue. Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICN2ZM Testing: ast, astchecker, parser, func, ninja tests Change-Id: I6ae14c6bbd9d0369d9f9d3c55ec0585d295b82f6 Signed-off-by: Peter Pronai --- ets2panda/BUILD.gn | 3 - ets2panda/CMakeLists.txt | 1 - ets2panda/checker/ETSAnalyzer.cpp | 6 -- ets2panda/checker/SemanticAnalyzer.h | 1 - ets2panda/checker/TSAnalyzerUnreachable.cpp | 5 -- ets2panda/compiler/core/ASTCompiler.h | 1 - ets2panda/compiler/core/ETSCompiler.cpp | 5 -- .../compiler/core/JSCompilerUnreachable.cpp | 5 -- ets2panda/ir/astNodeMapping.h | 1 - ets2panda/ir/statements/assertStatement.cpp | 75 ------------------- ets2panda/ir/statements/assertStatement.h | 71 ------------------ ets2panda/lsp/src/script_element_kind.cpp | 1 - ets2panda/public/CMakeLists.txt | 2 - .../public/headers_parser/supported_types.py | 1 - 14 files changed, 178 deletions(-) delete mode 100644 ets2panda/ir/statements/assertStatement.cpp delete mode 100644 ets2panda/ir/statements/assertStatement.h diff --git a/ets2panda/BUILD.gn b/ets2panda/BUILD.gn index 60c32ea888..2c63cfc3e1 100644 --- a/ets2panda/BUILD.gn +++ b/ets2panda/BUILD.gn @@ -390,7 +390,6 @@ libes2panda_sources = [ "ir/statement.cpp", "ir/statements/annotationDeclaration.cpp", "ir/statements/annotationUsage.cpp", - "ir/statements/assertStatement.cpp", "ir/statements/blockStatement.cpp", "ir/statements/breakStatement.cpp", "ir/statements/classDeclaration.cpp", @@ -708,7 +707,6 @@ HEADERS_TO_BE_PARSED = [ "ir/ts/tsVoidKeyword.h", "ir/statements/whileStatement.h", "ir/expressions/taggedTemplateExpression.h", - "ir/statements/assertStatement.h", "checker/types/ets/etsUnionType.h", "checker/types/ts/stringType.h", "ir/expressions/literals/booleanLiteral.h", @@ -899,7 +897,6 @@ ES2PANDA_API_GENERATED = [ "$LIBGEN_DIR/gen/headers/ir/expressions/binaryExpression.yaml", "$LIBGEN_DIR/gen/headers/checker/types/ts/bigintLiteralType.yaml", "$LIBGEN_DIR/gen/headers/ir/expressions/superExpression.yaml", - "$LIBGEN_DIR/gen/headers/ir/statements/assertStatement.yaml", "$LIBGEN_DIR/gen/headers/ir/ts/tsStringKeyword.yaml", "$LIBGEN_DIR/gen/headers/checker/types/ets/etsAsyncFuncReturnType.yaml", "$LIBGEN_DIR/gen/headers/ir/expressions/assignmentExpression.yaml", diff --git a/ets2panda/CMakeLists.txt b/ets2panda/CMakeLists.txt index 73d465ae36..c71cc1f47c 100644 --- a/ets2panda/CMakeLists.txt +++ b/ets2panda/CMakeLists.txt @@ -402,7 +402,6 @@ set(ES2PANDA_LIB_SRC ir/statement.cpp ir/statements/annotationDeclaration.cpp ir/statements/annotationUsage.cpp - ir/statements/assertStatement.cpp ir/statements/blockStatement.cpp ir/statements/breakStatement.cpp ir/statements/classDeclaration.cpp diff --git a/ets2panda/checker/ETSAnalyzer.cpp b/ets2panda/checker/ETSAnalyzer.cpp index 50390d0209..6adeea6e96 100644 --- a/ets2panda/checker/ETSAnalyzer.cpp +++ b/ets2panda/checker/ETSAnalyzer.cpp @@ -2972,12 +2972,6 @@ checker::Type *ETSAnalyzer::Check(ir::ImportNamespaceSpecifier *st) const return checker->GetImportSpecifierObjectType(importDecl, st->Local()->AsIdentifier()); } -// compile methods for STATEMENTS in alphabetical order -checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::AssertStatement *st) const -{ - ES2PANDA_UNREACHABLE(); -} - checker::Type *ETSAnalyzer::Check(ir::BlockStatement *st) const { ETSChecker *checker = GetETSChecker(); diff --git a/ets2panda/checker/SemanticAnalyzer.h b/ets2panda/checker/SemanticAnalyzer.h index 1126ba93c0..6be27b5e61 100644 --- a/ets2panda/checker/SemanticAnalyzer.h +++ b/ets2panda/checker/SemanticAnalyzer.h @@ -98,7 +98,6 @@ #include "ir/module/importDefaultSpecifier.h" #include "ir/module/importNamespaceSpecifier.h" #include "ir/module/importSpecifier.h" -#include "ir/statements/assertStatement.h" #include "ir/statements/blockStatement.h" #include "ir/statements/breakStatement.h" #include "ir/statements/classDeclaration.h" diff --git a/ets2panda/checker/TSAnalyzerUnreachable.cpp b/ets2panda/checker/TSAnalyzerUnreachable.cpp index 43a987d1cb..79478d7dbd 100644 --- a/ets2panda/checker/TSAnalyzerUnreachable.cpp +++ b/ets2panda/checker/TSAnalyzerUnreachable.cpp @@ -259,11 +259,6 @@ checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ImportSpecifier *st) const { ES2PANDA_UNREACHABLE(); } -// compile methods for STATEMENTS in alphabetical order -checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::AssertStatement *st) const -{ - ES2PANDA_UNREACHABLE(); -} checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ClassDeclaration *st) const { diff --git a/ets2panda/compiler/core/ASTCompiler.h b/ets2panda/compiler/core/ASTCompiler.h index d7925c2f44..69ee967dad 100644 --- a/ets2panda/compiler/core/ASTCompiler.h +++ b/ets2panda/compiler/core/ASTCompiler.h @@ -90,7 +90,6 @@ #include "ir/module/importDefaultSpecifier.h" #include "ir/module/importNamespaceSpecifier.h" #include "ir/module/importSpecifier.h" -#include "ir/statements/assertStatement.h" #include "ir/statements/blockStatement.h" #include "ir/statements/breakStatement.h" #include "ir/statements/classDeclaration.h" diff --git a/ets2panda/compiler/core/ETSCompiler.cpp b/ets2panda/compiler/core/ETSCompiler.cpp index 75fd7d3de5..67790b0ae9 100644 --- a/ets2panda/compiler/core/ETSCompiler.cpp +++ b/ets2panda/compiler/core/ETSCompiler.cpp @@ -1180,11 +1180,6 @@ void ETSCompiler::Compile(const ir::StringLiteral *expr) const etsg->SetAccumulatorType(expr->TsType()); } -void ETSCompiler::Compile([[maybe_unused]] const ir::AssertStatement *st) const -{ - ES2PANDA_UNREACHABLE(); -} - void ETSCompiler::Compile(const ir::BlockStatement *st) const { ETSGen *etsg = GetETSGen(); diff --git a/ets2panda/compiler/core/JSCompilerUnreachable.cpp b/ets2panda/compiler/core/JSCompilerUnreachable.cpp index d38cf39039..2bcfa08628 100644 --- a/ets2panda/compiler/core/JSCompilerUnreachable.cpp +++ b/ets2panda/compiler/core/JSCompilerUnreachable.cpp @@ -262,11 +262,6 @@ void JSCompiler::Compile([[maybe_unused]] const ir::ImportSpecifier *st) const { ES2PANDA_UNREACHABLE(); } -// Compile methods for STATEMENTS in alphabetical order -void JSCompiler::Compile([[maybe_unused]] const ir::AssertStatement *st) const -{ - ES2PANDA_UNREACHABLE(); -} void JSCompiler::Compile([[maybe_unused]] const ir::SwitchCaseStatement *st) const { diff --git a/ets2panda/ir/astNodeMapping.h b/ets2panda/ir/astNodeMapping.h index 34908d0e7c..8854aeeea4 100644 --- a/ets2panda/ir/astNodeMapping.h +++ b/ets2panda/ir/astNodeMapping.h @@ -22,7 +22,6 @@ _(ARROW_FUNCTION_EXPRESSION, ArrowFunctionExpression) \ _(ANNOTATION_DECLARATION, AnnotationDeclaration) \ _(ANNOTATION_USAGE, AnnotationUsage) \ - _(ASSERT_STATEMENT, AssertStatement) \ _(AWAIT_EXPRESSION, AwaitExpression) \ _(BIGINT_LITERAL, BigIntLiteral) \ _(BINARY_EXPRESSION, BinaryExpression) \ diff --git a/ets2panda/ir/statements/assertStatement.cpp b/ets2panda/ir/statements/assertStatement.cpp deleted file mode 100644 index dce93e6570..0000000000 --- a/ets2panda/ir/statements/assertStatement.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2021-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. - */ - -#include "assertStatement.h" - -#include "varbinder/ETSBinder.h" -#include "compiler/base/condition.h" -#include "compiler/core/pandagen.h" -#include "compiler/core/ETSGen.h" -#include "checker/ETSchecker.h" -#include "checker/TSchecker.h" -#include "ir/astDump.h" -#include "ir/srcDump.h" -#include "ir/expression.h" - -namespace ark::es2panda::ir { -void AssertStatement::TransformChildren([[maybe_unused]] const NodeTransformer &cb, - [[maybe_unused]] std::string_view const transformationName) -{ - ES2PANDA_UNREACHABLE(); -} - -void AssertStatement::Iterate([[maybe_unused]] const NodeTraverser &cb) const -{ - ES2PANDA_UNREACHABLE(); -} - -void AssertStatement::Dump([[maybe_unused]] ir::AstDumper *dumper) const -{ - ES2PANDA_UNREACHABLE(); -} - -void AssertStatement::Dump([[maybe_unused]] ir::SrcDumper *dumper) const -{ - ES2PANDA_UNREACHABLE(); -} - -void AssertStatement::Compile([[maybe_unused]] compiler::PandaGen *pg) const -{ - pg->GetAstCompiler()->Compile(this); -} - -void AssertStatement::Compile([[maybe_unused]] compiler::ETSGen *etsg) const -{ - etsg->GetAstCompiler()->Compile(this); -} - -checker::Type *AssertStatement::Check([[maybe_unused]] checker::TSChecker *checker) -{ - return checker->GetAnalyzer()->Check(this); -} - -checker::VerifiedType AssertStatement::Check([[maybe_unused]] checker::ETSChecker *checker) -{ - return {this, checker->GetAnalyzer()->Check(this)}; -} - -AssertStatement *AssertStatement::Clone([[maybe_unused]] ArenaAllocator *const allocator, - [[maybe_unused]] AstNode *const parent) -{ - ES2PANDA_UNREACHABLE(); -} -} // namespace ark::es2panda::ir diff --git a/ets2panda/ir/statements/assertStatement.h b/ets2panda/ir/statements/assertStatement.h deleted file mode 100644 index 7a63411e30..0000000000 --- a/ets2panda/ir/statements/assertStatement.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2021-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. - */ - -#ifndef ES2PANDA_IR_STATEMENT_ASSERT_STATEMENT_H -#define ES2PANDA_IR_STATEMENT_ASSERT_STATEMENT_H - -#include "ir/statement.h" - -namespace ark::es2panda::checker { -class ETSAnalyzer; -} // namespace ark::es2panda::checker - -namespace ark::es2panda::ir { -class Expression; - -class AssertStatement : public Statement { -public: - explicit AssertStatement([[maybe_unused]] Expression *test, [[maybe_unused]] Expression *second) - : Statement(AstNodeType::ASSERT_STATEMENT) - { - ES2PANDA_UNREACHABLE(); - } - // NOTE (somas): this friend relationship can be removed once there are getters for private fields - friend class checker::ETSAnalyzer; - - const Expression *Test() const - { - ES2PANDA_UNREACHABLE(); - } - - Expression *Test() - { - ES2PANDA_UNREACHABLE(); - } - - const Expression *Second() const - { - ES2PANDA_UNREACHABLE(); - } - - void TransformChildren(const NodeTransformer &cb, std::string_view transformationName) override; - void Iterate(const NodeTraverser &cb) const override; - void Dump(ir::AstDumper *dumper) const override; - void Dump(ir::SrcDumper *dumper) const override; - void Compile([[maybe_unused]] compiler::PandaGen *pg) const override; - void Compile([[maybe_unused]] compiler::ETSGen *etsg) const override; - checker::Type *Check([[maybe_unused]] checker::TSChecker *checker) override; - checker::VerifiedType Check([[maybe_unused]] checker::ETSChecker *checker) override; - - void Accept(ASTVisitorT *v) override - { - v->Accept(this); - } - - AssertStatement *Clone(ArenaAllocator *const allocator, AstNode *const parent) override; -}; -} // namespace ark::es2panda::ir - -#endif diff --git a/ets2panda/lsp/src/script_element_kind.cpp b/ets2panda/lsp/src/script_element_kind.cpp index f31e8d5e06..b4c05869e5 100644 --- a/ets2panda/lsp/src/script_element_kind.cpp +++ b/ets2panda/lsp/src/script_element_kind.cpp @@ -184,7 +184,6 @@ bool IsExpress(ir::AstNodeType type) bool IsStatement(ir::AstNodeType type) { switch (type) { - case ir::AstNodeType::ASSERT_STATEMENT: case ir::AstNodeType::CONTINUE_STATEMENT: case ir::AstNodeType::IF_STATEMENT: case ir::AstNodeType::DEBUGGER_STATEMENT: diff --git a/ets2panda/public/CMakeLists.txt b/ets2panda/public/CMakeLists.txt index 6d07c5e907..b77fbf4822 100644 --- a/ets2panda/public/CMakeLists.txt +++ b/ets2panda/public/CMakeLists.txt @@ -219,7 +219,6 @@ set (HEADERS_TO_BE_PARSED ${ES2PANDA_ROOT}/ir/ts/tsVoidKeyword.h ${ES2PANDA_ROOT}/ir/statements/whileStatement.h ${ES2PANDA_ROOT}/ir/expressions/taggedTemplateExpression.h - ${ES2PANDA_ROOT}/ir/statements/assertStatement.h ${ES2PANDA_ROOT}/checker/types/ets/etsUnionType.h ${ES2PANDA_ROOT}/checker/types/ts/stringType.h ${ES2PANDA_ROOT}/ir/expressions/literals/booleanLiteral.h @@ -409,7 +408,6 @@ set (ES2PANDA_API_GENERATED ${LIBGEN_DIR}/gen/headers/ir/expressions/binaryExpression.yaml ${LIBGEN_DIR}/gen/headers/checker/types/ts/bigintLiteralType.yaml ${LIBGEN_DIR}/gen/headers/ir/expressions/superExpression.yaml - ${LIBGEN_DIR}/gen/headers/ir/statements/assertStatement.yaml ${LIBGEN_DIR}/gen/headers/ir/ts/tsStringKeyword.yaml ${LIBGEN_DIR}/gen/headers/checker/types/ets/etsAsyncFuncReturnType.yaml ${LIBGEN_DIR}/gen/headers/ir/expressions/assignmentExpression.yaml diff --git a/ets2panda/public/headers_parser/supported_types.py b/ets2panda/public/headers_parser/supported_types.py index c10aabea13..529d5ccd70 100644 --- a/ets2panda/public/headers_parser/supported_types.py +++ b/ets2panda/public/headers_parser/supported_types.py @@ -20,7 +20,6 @@ ast_nodes_supported = [ "AstNode", "ArrowFunctionExpression", - "AssertStatement", "AwaitExpression", "BigIntLiteral", "BinaryExpression", -- Gitee