From 87a1a180ca8edf83490483aa6a476d7b1f880082 Mon Sep 17 00:00:00 2001 From: Sergey Chernykh Date: Mon, 3 Mar 2025 17:50:59 +0800 Subject: [PATCH] Improve compiler bug diag Description: * Fix output of ES2PANDA_ASSERT * Remove DiagnosticKind::COMPILER_BUG * Rename ES2PANDA_ASSERT3 to ES2PANDA_ASSERT_POS * Dedublicate common code * Rename ASSERT to ES2PANDA_ASSERT * Support ES2PADNA_UNREACHABLE macros with compiler bug diagnostic output * Rename UNREACHABLE to ES2PANDA_UNREACHABLE * Move ES2PANDA macroses to util/es2pandaMacros.h * Implement script for check depricated macroses Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/IBQDHQ Signed-off-by: Sergey Chernykh Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/IBQDHQ Signed-off-by: Sergey Chernykh --- ets2panda/BUILD.gn | 1 + ets2panda/CMakeLists.txt | 1 + ets2panda/checker/ETSAnalyzer.cpp | 18 +- ets2panda/checker/ETSAnalyzerHelpers.cpp | 2 +- ets2panda/checker/ETSAnalyzerUnreachable.cpp | 156 +++++++------- ets2panda/checker/TSAnalyzer.cpp | 8 +- ets2panda/checker/TSAnalyzerUnreachable.cpp | 156 +++++++------- ets2panda/checker/TSchecker.h | 2 +- ets2panda/checker/checkerContext.h | 1 + ets2panda/checker/ets/arithmetic.cpp | 8 +- ets2panda/checker/ets/arithmetic.h | 8 +- ets2panda/checker/ets/assignAnalyzer.cpp | 8 +- ets2panda/checker/ets/boxingConverter.cpp | 2 +- ets2panda/checker/ets/function.cpp | 28 +-- ets2panda/checker/ets/helpers.cpp | 18 +- ets2panda/checker/ets/narrowingConverter.h | 2 +- ets2panda/checker/ets/object.cpp | 10 +- ets2panda/checker/ets/typeCheckingHelpers.cpp | 16 +- ets2panda/checker/ets/typeCreation.cpp | 4 +- ets2panda/checker/ets/typeRelationContext.cpp | 10 +- ets2panda/checker/ets/unboxingConverter.cpp | 2 +- ets2panda/checker/ts/destructuringContext.cpp | 4 +- ets2panda/checker/ts/function.cpp | 8 +- ets2panda/checker/ts/helpers.cpp | 2 +- .../checker/ts/typeElaborationContext.cpp | 2 +- ets2panda/checker/typeChecker/TypeChecker.cpp | 2 +- .../checker/types/ets/etsFunctionType.cpp | 12 +- ets2panda/checker/types/ets/etsFunctionType.h | 14 +- ets2panda/checker/types/ets/etsNeverType.cpp | 2 +- .../checker/types/ets/etsNullishTypes.cpp | 4 +- ets2panda/checker/types/ets/etsObjectType.cpp | 12 +- ets2panda/checker/types/ets/etsTupleType.cpp | 2 +- ets2panda/checker/types/signature.cpp | 6 +- ets2panda/checker/types/signature.h | 4 +- ets2panda/checker/types/ts/objectDescriptor.h | 4 +- ets2panda/checker/types/ts/tupleType.h | 4 +- ets2panda/checker/types/ts/typeParameter.cpp | 12 +- ets2panda/checker/types/ts/typeReference.cpp | 4 +- ets2panda/checker/types/type.h | 2 +- ets2panda/checker/types/typeRelation.h | 1 - ets2panda/compiler/base/lreference.cpp | 6 +- ets2panda/compiler/core/ETSCompiler.cpp | 18 +- .../compiler/core/ETSCompilerUnrechable.cpp | 196 ++++++++--------- ets2panda/compiler/core/ETSGen-inl.h | 2 +- ets2panda/compiler/core/ETSGen.cpp | 82 ++++---- ets2panda/compiler/core/ETSGen.h | 8 +- ets2panda/compiler/core/ETSemitter.cpp | 12 +- ets2panda/compiler/core/ETSfunction.cpp | 2 +- ets2panda/compiler/core/JSCompiler.cpp | 6 +- .../compiler/core/JSCompilerUnreachable.cpp | 198 +++++++++--------- ets2panda/compiler/core/JSemitter.cpp | 6 +- ets2panda/compiler/core/codeGen.cpp | 2 +- ets2panda/compiler/core/compileJob.h | 4 +- ets2panda/compiler/core/compileQueue.h | 2 +- ets2panda/compiler/core/compilerImpl.cpp | 2 +- ets2panda/compiler/core/dynamicContext.cpp | 2 +- ets2panda/compiler/core/emitter.cpp | 10 +- ets2panda/compiler/core/labelPair.h | 4 +- ets2panda/compiler/core/pandagen.cpp | 20 +- ets2panda/compiler/core/pandagen.h | 2 +- ets2panda/compiler/core/programElement.h | 4 +- ets2panda/compiler/core/regAllocator.h | 4 +- ets2panda/compiler/core/regScope.h | 2 +- ets2panda/compiler/core/targetTypeContext.h | 4 +- ets2panda/compiler/core/vReg.h | 4 +- .../compiler/debugger/debuginfoDumper.cpp | 2 +- ets2panda/compiler/debugger/debuginfoDumper.h | 2 +- ets2panda/compiler/function/functionBuilder.h | 6 +- .../compiler/lowering/ets/ambientLowering.cpp | 2 +- .../ets/constantExpressionLowering.cpp | 34 +-- ...defaultParametersInConstructorLowering.cpp | 4 +- .../ets/defaultParametersLowering.cpp | 10 +- .../compiler/lowering/ets/enumLowering.cpp | 2 +- .../lowering/ets/enumPostCheckLowering.cpp | 6 +- .../compiler/lowering/ets/lambdaLowering.cpp | 14 +- .../lowering/ets/localClassLowering.cpp | 2 +- .../compiler/lowering/ets/objectIterator.cpp | 2 +- .../compiler/lowering/ets/opAssignment.cpp | 6 +- .../ets/optionalArgumentsLowering.cpp | 6 +- .../lowering/ets/optionalLowering.cpp | 4 +- .../compiler/lowering/ets/recordLowering.cpp | 6 +- .../compiler/lowering/ets/spreadLowering.cpp | 2 +- .../ets/topLevelStmts/importExportDecls.cpp | 2 +- .../compiler/lowering/ets/unionLowering.cpp | 4 +- ets2panda/compiler/lowering/phase.cpp | 2 +- .../lowering/scopesInit/scopesInitPhase.cpp | 4 +- ets2panda/compiler/templates/signatures.h.erb | 16 +- ets2panda/declgen_ets2ts/declgenEts2Ts.cpp | 4 +- ets2panda/es2panda.h | 7 +- ets2panda/evaluate/helpers.cpp | 4 +- ets2panda/evaluate/helpers.h | 2 +- ets2panda/evaluate/scopedDebugInfoPlugin.cpp | 2 +- ets2panda/ir/astDump.cpp | 2 +- ets2panda/ir/astNode.cpp | 6 +- ets2panda/ir/astNode.h | 8 +- ets2panda/ir/base/metaProperty.cpp | 2 +- ets2panda/ir/base/methodDefinition.cpp | 4 +- ets2panda/ir/base/property.cpp | 2 +- ets2panda/ir/ets/etsNeverType.cpp | 4 +- ets2panda/ir/ets/etsNullishTypes.cpp | 8 +- ets2panda/ir/ets/etsParameterExpression.cpp | 4 +- ets2panda/ir/ets/etsParameterExpression.h | 4 +- ets2panda/ir/ets/etsPrimitiveType.cpp | 4 +- ets2panda/ir/ets/etsStringLiteralType.cpp | 4 +- ets2panda/ir/ets/etsStructDeclaration.cpp | 2 +- ets2panda/ir/expressions/arrayExpression.cpp | 2 +- ets2panda/ir/expressions/blockExpression.cpp | 4 +- .../ir/expressions/literals/numberLiteral.cpp | 8 +- .../ir/expressions/literals/stringLiteral.h | 4 +- ets2panda/ir/expressions/memberExpression.cpp | 4 +- ets2panda/ir/expressions/objectExpression.cpp | 4 +- ets2panda/ir/irnode.h | 2 +- ets2panda/ir/statements/doWhileStatement.cpp | 2 +- ets2panda/ir/statements/forInStatement.cpp | 2 +- .../ir/statements/forUpdateStatement.cpp | 2 +- ets2panda/ir/statements/loopStatement.cpp | 4 +- ets2panda/ir/statements/loopStatement.h | 10 +- .../ir/statements/variableDeclaration.cpp | 4 +- ets2panda/ir/statements/whileStatement.cpp | 2 +- ets2panda/ir/ts/tsInterfaceDeclaration.cpp | 2 +- ets2panda/ir/visitor/AstVisitor.h | 2 +- ets2panda/ir/visitor/IterateAstVisitor.h | 2 +- ets2panda/lexer/keywordString.h | 2 +- ets2panda/lexer/keywordsBase.h | 4 +- ets2panda/lexer/keywordsUtil.h | 2 +- ets2panda/lexer/lexer.cpp | 4 +- ets2panda/lexer/templates/token.inl.erb | 2 +- ets2panda/lexer/token/sourceLocation.h | 6 +- ets2panda/lexer/token/token.h | 2 +- ets2panda/lsp/include/completions.h | 1 + ets2panda/parser/ETSFormattedParser.cpp | 52 ++--- ets2panda/parser/ETSparser.cpp | 8 +- ets2panda/parser/ETSparser.h | 2 +- ets2panda/parser/ETSparserClasses.cpp | 11 +- ets2panda/parser/ETSparserEnums.cpp | 2 +- ets2panda/parser/ETSparserStatements.cpp | 2 +- ets2panda/parser/ETSparserTypes.cpp | 2 +- ets2panda/parser/TSparser.cpp | 2 +- ets2panda/parser/TypedParser.cpp | 4 +- ets2panda/parser/expressionParser.cpp | 12 +- ets2panda/parser/expressionTSParser.cpp | 2 +- ets2panda/parser/parserImpl.cpp | 6 +- ets2panda/parser/parserImpl.h | 2 +- ets2panda/parser/program/entityNameVisitor.h | 4 +- ets2panda/parser/program/program.h | 2 +- ets2panda/parser/statementParser.cpp | 6 +- ets2panda/public/es2panda_lib.cpp | 4 +- ets2panda/public/es2panda_lib_impl.inc.erb | 4 +- ets2panda/scripts/assert_check.sh | 43 ++++ ets2panda/test/utils/scope_init_test.cpp | 6 +- ets2panda/util/bitset.h | 4 +- ets2panda/util/diagnostic.cpp | 6 +- ets2panda/util/diagnostic.h | 3 +- ets2panda/util/diagnosticEngine.cpp | 20 +- ets2panda/util/diagnosticEngine.h | 36 +--- ets2panda/util/dtoa_helper.cpp | 10 +- ets2panda/util/dtoa_helper.h | 4 +- ets2panda/util/errorRecovery.cpp | 4 +- ets2panda/util/es2pandaMacros.cpp | 51 +++++ ets2panda/util/es2pandaMacros.h | 68 ++++++ ets2panda/util/helpers.cpp | 2 +- ets2panda/util/language.h | 8 +- ets2panda/util/plugin.h | 4 +- ets2panda/util/ustring.h | 4 +- ets2panda/varbinder/ETSBinder.cpp | 4 +- ets2panda/varbinder/declaration.h | 2 +- ets2panda/varbinder/recordTable.h | 4 +- ets2panda/varbinder/scope.cpp | 6 +- 168 files changed, 1001 insertions(+), 873 deletions(-) create mode 100755 ets2panda/scripts/assert_check.sh create mode 100644 ets2panda/util/es2pandaMacros.cpp create mode 100644 ets2panda/util/es2pandaMacros.h diff --git a/ets2panda/BUILD.gn b/ets2panda/BUILD.gn index d416ad788a..fbb7b04994 100644 --- a/ets2panda/BUILD.gn +++ b/ets2panda/BUILD.gn @@ -469,6 +469,7 @@ libes2panda_sources = [ "util/diagnosticEngine.cpp", "util/dtoa_helper.cpp", "util/errorRecovery.cpp", + "util/es2pandaMacros.cpp", "util/helpers.cpp", "util/importPathManager.cpp", "util/path.cpp", diff --git a/ets2panda/CMakeLists.txt b/ets2panda/CMakeLists.txt index 6b2b87fad9..e07fe05d8b 100644 --- a/ets2panda/CMakeLists.txt +++ b/ets2panda/CMakeLists.txt @@ -600,6 +600,7 @@ set(ES2PANDA_LIB_SRC util/diagnostic.cpp util/diagnosticEngine.cpp util/errorRecovery.cpp + util/es2pandaMacros.cpp util/helpers.cpp util/importPathManager.cpp util/path.cpp diff --git a/ets2panda/checker/ETSAnalyzer.cpp b/ets2panda/checker/ETSAnalyzer.cpp index 3dcc24ffd2..cf14965ca2 100644 --- a/ets2panda/checker/ETSAnalyzer.cpp +++ b/ets2panda/checker/ETSAnalyzer.cpp @@ -353,7 +353,7 @@ checker::Type *ETSAnalyzer::Check(ir::ETSFunctionType *node) const auto *returnType = checker->ComposeReturnType(node->ReturnType(), node->IsAsync()); auto *const signature = checker->CreateSignature(signatureInfo, returnType, node->Flags()); if (signature == nullptr) { // #23134 - ASSERT(GetChecker()->IsAnyError()); + ES2PANDA_ASSERT(GetChecker()->IsAnyError()); return node->SetTsType(checker->GlobalTypeError()); } @@ -553,8 +553,8 @@ checker::Type *ETSAnalyzer::Check(ir::ETSParameterExpression *expr) const } else { expr->SetTsType(expr->Ident()->Check(checker)); } - ASSERT(!expr->IsOptional() || - checker->Relation()->IsSupertypeOf(expr->TsType(), checker->GlobalETSUndefinedType())); + ES2PANDA_ASSERT(!expr->IsOptional() || + checker->Relation()->IsSupertypeOf(expr->TsType(), checker->GlobalETSUndefinedType())); return expr->TsType(); } @@ -1078,7 +1078,7 @@ std::tuple ETSAnalyzer::CheckAssignmentExprOperatorTyp break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); break; } } @@ -1250,7 +1250,7 @@ static ETSObjectType *GetCallExpressionCalleeObject(ETSChecker *checker, ir::Cal if (callee->IsMemberExpression()) { return callee->AsMemberExpression()->ObjType(); } - ASSERT(callee->IsIdentifier()); + ES2PANDA_ASSERT(callee->IsIdentifier()); return checker->Context().ContainingClass(); } @@ -1285,7 +1285,7 @@ Type *ETSAnalyzer::GetReturnType(ir::CallExpression *expr, Type *calleeType) con } if (calleeType->IsETSMethodType() && signature->Function()->IsDynamic()) { - ASSERT(signature->Function()->IsDynamic()); + ES2PANDA_ASSERT(signature->Function()->IsDynamic()); auto lang = signature->Function()->Language(); expr->SetSignature(checker->ResolveDynamicCallExpression(expr->Callee(), signature->Params(), lang, false)); } else { @@ -1429,7 +1429,7 @@ checker::Type *ETSAnalyzer::Check(ir::CallExpression *expr) const expr->SetUncheckedType(checker->GuaranteedTypeForUncheckedCallReturn(expr->Signature())); } if (expr->UncheckedType() != nullptr) { - ASSERT(expr->UncheckedType()->IsETSReferenceType()); + ES2PANDA_ASSERT(expr->UncheckedType()->IsETSReferenceType()); checker->ComputeApparentType(returnType); } @@ -1503,7 +1503,7 @@ checker::Type *ETSAnalyzer::Check(ir::ConditionalExpression *expr) const // Convert method references to Arrow type if method is used as value static Type *TransformTypeForMethodReference(ETSChecker *checker, ir::Expression *const use, Type *type) { - ASSERT(use->IsIdentifier() || use->IsMemberExpression()); + ES2PANDA_ASSERT(use->IsIdentifier() || use->IsMemberExpression()); if (!type->IsETSMethodType()) { return type; } @@ -1947,7 +1947,7 @@ static checker::Type *GetTypeOfStringType(checker::Type *argType, ETSChecker *ch case TypeFlag::DOUBLE: return checker->CreateETSStringLiteralType("number"); default: - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } if (argType->IsETSUndefinedType()) { diff --git a/ets2panda/checker/ETSAnalyzerHelpers.cpp b/ets2panda/checker/ETSAnalyzerHelpers.cpp index e917c2ec5e..3c7fd517e8 100644 --- a/ets2panda/checker/ETSAnalyzerHelpers.cpp +++ b/ets2panda/checker/ETSAnalyzerHelpers.cpp @@ -590,7 +590,7 @@ void SetTsTypeForUnaryExpression(ETSChecker *checker, ir::UnaryExpression *expr, break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); break; } } diff --git a/ets2panda/checker/ETSAnalyzerUnreachable.cpp b/ets2panda/checker/ETSAnalyzerUnreachable.cpp index a29d5ca198..f0c54c5924 100644 --- a/ets2panda/checker/ETSAnalyzerUnreachable.cpp +++ b/ets2panda/checker/ETSAnalyzerUnreachable.cpp @@ -20,168 +20,168 @@ namespace ark::es2panda::checker { // from as folder checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::NamedType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::PrefixAssertionExpression *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::Decorator *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::MetaProperty *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::ScriptFunction *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSIndexSignature *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSMethodSignature *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSPropertySignature *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSSignatureDeclaration *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } // from ets folder checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::ETSModule *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::ETSImportDeclaration *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::ETSTuple *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::ETSUnionType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::ETSWildcardType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::ChainExpression *expr) const { - UNREACHABLE(); // eliminated in OptionalLowering + ES2PANDA_UNREACHABLE(); // eliminated in OptionalLowering } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::ClassExpression *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::ETSReExportDeclaration *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::DirectEvalExpression *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::FunctionExpression *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::ImportExpression *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::NewExpression *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::OmittedExpression *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TaggedTemplateExpression *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::YieldExpression *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::RegExpLiteral *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::UndefinedLiteral *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } // compile methods for MODULE-related nodes in alphabetical order checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::ExportAllDeclaration *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::ExportDefaultDeclaration *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::ExportNamedDeclaration *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::ExportSpecifier *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::ImportDefaultSpecifier *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::ImportSpecifier *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::DebuggerStatement *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check(ir::ForInStatement *st) const @@ -192,153 +192,153 @@ checker::Type *ETSAnalyzer::Check(ir::ForInStatement *st) const checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::FunctionDeclaration *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::SwitchCaseStatement *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } // from ts folder checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSAnyKeyword *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSBigintKeyword *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSBooleanKeyword *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSClassImplements *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSConditionalType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSConstructorType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSEnumMember *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSExternalModuleReference *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSFunctionType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSImportEqualsDeclaration *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSImportType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSIndexedAccessType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSInferType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSInterfaceBody *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSInterfaceHeritage *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSIntersectionType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSLiteralType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSMappedType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSModuleBlock *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSModuleDeclaration *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSNamedTupleMember *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSNeverKeyword *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSNullKeyword *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSNumberKeyword *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSObjectKeyword *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSParameterProperty *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSParenthesizedType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSStringKeyword *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSThisType *node) const @@ -349,76 +349,76 @@ checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSThisType *node) const checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSTupleType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSTypeAssertion *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSTypeLiteral *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSTypeOperator *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSTypeParameter *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSTypeParameterDeclaration *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSTypeParameterInstantiation *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSTypePredicate *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSTypeQuery *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSTypeReference *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSUndefinedKeyword *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSUnionType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSUnknownKeyword *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::TSVoidKeyword *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::DummyNode *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } // namespace ark::es2panda::checker diff --git a/ets2panda/checker/TSAnalyzer.cpp b/ets2panda/checker/TSAnalyzer.cpp index 478b6bb799..6b68293395 100644 --- a/ets2panda/checker/TSAnalyzer.cpp +++ b/ets2panda/checker/TSAnalyzer.cpp @@ -366,7 +366,7 @@ checker::Type *TSAnalyzer::CheckAssignmentExprOperatorType(ir::AssignmentExpress return rightType; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); break; } } @@ -503,7 +503,7 @@ checker::Type *TSAnalyzer::Check(ir::BinaryExpression *expr) const expr->Right(), expr); } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); break; } } @@ -633,7 +633,7 @@ void TSAnalyzer::CheckComputed(ir::MemberExpression *expr, checker::Type *indexT expr->Property()->Start()); } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } @@ -1028,7 +1028,7 @@ checker::Type *TSAnalyzer::Check(ir::UnaryExpression *expr) const return checker->GlobalBooleanType(); } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } diff --git a/ets2panda/checker/TSAnalyzerUnreachable.cpp b/ets2panda/checker/TSAnalyzerUnreachable.cpp index 1ab907e2da..125e291bfe 100644 --- a/ets2panda/checker/TSAnalyzerUnreachable.cpp +++ b/ets2panda/checker/TSAnalyzerUnreachable.cpp @@ -20,393 +20,393 @@ namespace ark::es2panda::checker { // from as folder checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::NamedType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::PrefixAssertionExpression *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ClassProperty *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ClassStaticBlock *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::Decorator *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::MethodDefinition *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::Property *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ScriptFunction *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::SpreadElement *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::TemplateElement *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } // from ets folder checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ETSModule *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ETSClassLiteral *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ETSFunctionType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ETSImportDeclaration *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ETSLaunchExpression *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ETSNewArrayInstanceExpression *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ETSNewClassInstanceExpression *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ETSNewMultiDimArrayInstanceExpression *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ETSPackageDeclaration *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ETSParameterExpression *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ETSPrimitiveType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ETSStructDeclaration *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ETSTuple *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ETSTypeReference *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ETSTypeReferencePart *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ETSNullType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ETSUndefinedType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ETSNeverType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ETSStringLiteralType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ETSUnionType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ETSWildcardType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::BlockExpression *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ClassExpression *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::DirectEvalExpression *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ImportExpression *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::CharLiteral *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::UndefinedLiteral *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } // compile methods for MODULE-related nodes in alphabetical order checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ExportAllDeclaration *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ExportDefaultDeclaration *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ExportNamedDeclaration *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ExportSpecifier *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ImportDeclaration *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ImportDefaultSpecifier *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ImportNamespaceSpecifier *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ImportSpecifier *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } // compile methods for STATEMENTS in alphabetical order checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::AssertStatement *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ClassDeclaration *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ContinueStatement *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::DebuggerStatement *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ForInStatement *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ForOfStatement *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::LabelledStatement *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::SwitchCaseStatement *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ThrowStatement *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::TSClassImplements *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::TSConditionalType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ETSReExportDeclaration *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::TSEnumMember *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::TSExternalModuleReference *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::TSImportEqualsDeclaration *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::TSImportType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::TSInferType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::TSInterfaceHeritage *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::TSIntersectionType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::TSMappedType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::TSModuleBlock *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::TSModuleDeclaration *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::TSNonNullExpression *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::TSObjectKeyword *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::TSParameterProperty *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::TSThisType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::TSTypeAssertion *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::TSTypeOperator *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::TSTypeParameter *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::TSTypeParameterDeclaration *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::TSTypeParameterInstantiation *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::TSTypePredicate *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::DummyNode *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } // namespace ark::es2panda::checker diff --git a/ets2panda/checker/TSchecker.h b/ets2panda/checker/TSchecker.h index af6dedfb03..b4993e1666 100644 --- a/ets2panda/checker/TSchecker.h +++ b/ets2panda/checker/TSchecker.h @@ -22,7 +22,7 @@ #include "checker/types/ts/types.h" #include "util/enumbitops.h" #include "util/ustring.h" -#include "macros.h" +#include "util/es2pandaMacros.h" #include #include diff --git a/ets2panda/checker/checkerContext.h b/ets2panda/checker/checkerContext.h index 2ab3269279..ac489d0448 100644 --- a/ets2panda/checker/checkerContext.h +++ b/ets2panda/checker/checkerContext.h @@ -16,6 +16,7 @@ #ifndef ES2PANDA_CHECKER_CHECKER_CONTEXT_H #define ES2PANDA_CHECKER_CHECKER_CONTEXT_H +#include "es2panda.h" #include "generated/tokenType.h" #include "lexer/token/sourceLocation.h" #include "util/enumbitops.h" diff --git a/ets2panda/checker/ets/arithmetic.cpp b/ets2panda/checker/ets/arithmetic.cpp index 9f7ccf3ed7..65c8e1027a 100644 --- a/ets2panda/checker/ets/arithmetic.cpp +++ b/ets2panda/checker/ets/arithmetic.cpp @@ -181,7 +181,7 @@ Type *ETSChecker::NegateNumericType(Type *type, ir::Expression *node) break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -229,7 +229,7 @@ Type *ETSChecker::BitwiseNegateNumericType(Type *type, ir::Expression *node) break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -468,7 +468,7 @@ static checker::Type *GetBitwiseCompatibleType(ETSChecker *checker, Type *const return checker->GlobalLongType(); } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } return nullptr; @@ -1001,7 +1001,7 @@ static std::tuple CheckBinaryOperatorHelper(ETSChecker *checker, break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); break; } } diff --git a/ets2panda/checker/ets/arithmetic.h b/ets2panda/checker/ets/arithmetic.h index ffd92dfd06..9e08b1e46e 100644 --- a/ets2panda/checker/ets/arithmetic.h +++ b/ets2panda/checker/ets/arithmetic.h @@ -50,7 +50,7 @@ typename TargetType::UType ETSChecker::GetOperand(Type *type) return type->AsETSBooleanType()->GetValue(); } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } @@ -92,7 +92,7 @@ Type *ETSChecker::PerformRelationOperationOnTypes(Type *left, Type *right, lexer break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -142,7 +142,7 @@ Type *ETSChecker::PerformArithmeticOperationOnTypes(Type *left, Type *right, lex break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -237,7 +237,7 @@ Type *ETSChecker::HandleBitWiseArithmetic(Type *left, Type *right, lexer::TokenT break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } diff --git a/ets2panda/checker/ets/assignAnalyzer.cpp b/ets2panda/checker/ets/assignAnalyzer.cpp index b5ce9dce58..f0e115a8ea 100644 --- a/ets2panda/checker/ets/assignAnalyzer.cpp +++ b/ets2panda/checker/ets/assignAnalyzer.cpp @@ -1228,7 +1228,7 @@ util::StringView AssignAnalyzer::GetVariableType(const ir::AstNode *node) const case ir::AstNodeType::VARIABLE_DECLARATOR: return "variable"; default: - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -1240,7 +1240,7 @@ util::StringView AssignAnalyzer::GetVariableName(const ir::AstNode *node) const case ir::AstNodeType::VARIABLE_DECLARATOR: return node->AsVariableDeclarator()->Id()->AsIdentifier()->Name(); default: - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -1312,7 +1312,7 @@ varbinder::Variable *AssignAnalyzer::GetBoundVariable(const ir::AstNode *node) } else if (node->IsVariableDeclarator()) { ret = node->AsVariableDeclarator()->Id()->AsIdentifier()->Variable(); } else { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } return ret; @@ -1364,7 +1364,7 @@ bool AssignAnalyzer::VariableHasDefaultValue(const ir::AstNode *node) ES2PANDA_ASSERT(variable != nullptr); type = variable->TsType(); } else { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } return type != nullptr && diff --git a/ets2panda/checker/ets/boxingConverter.cpp b/ets2panda/checker/ets/boxingConverter.cpp index b0f1361a50..73bdbf791d 100644 --- a/ets2panda/checker/ets/boxingConverter.cpp +++ b/ets2panda/checker/ets/boxingConverter.cpp @@ -43,7 +43,7 @@ checker::ETSObjectType *BoxingConverter::Convert(ETSChecker const *checker, Type case checker::TypeFlag::DOUBLE: return typeHolder->GlobalDoubleBuiltinType()->AsETSObjectType(); default: - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } diff --git a/ets2panda/checker/ets/function.cpp b/ets2panda/checker/ets/function.cpp index e3576d924a..20003630a7 100644 --- a/ets2panda/checker/ets/function.cpp +++ b/ets2panda/checker/ets/function.cpp @@ -69,7 +69,7 @@ bool ETSChecker::IsCompatibleTypeArgument(ETSTypeParameter *typeParam, Type *typ if (typeArgument->IsETSVoidType()) { typeArgument = GlobalETSUndefinedType(); } - ASSERT(IsReferenceType(typeArgument)); + ES2PANDA_ASSERT(IsReferenceType(typeArgument)); auto constraint = typeParam->GetConstraintType()->Substitute(Relation(), substitution); return Relation()->IsSupertypeOf(constraint, typeArgument); } @@ -199,7 +199,7 @@ bool ETSChecker::EnhanceSubstitutionForFunction(const ArenaVector &typeP // Try to find the base type somewhere in object subtypes. Incomplete, yet safe static ETSObjectType *FindEnhanceTargetInSupertypes(ETSObjectType *object, ETSObjectType *base) { - ASSERT(base == base->GetOriginalBaseType()); + ES2PANDA_ASSERT(base == base->GetOriginalBaseType()); if (object->GetConstOriginalBaseType() == base) { return object; } @@ -235,7 +235,7 @@ bool ETSChecker::EnhanceSubstitutionForObject(const ArenaVector &typePar if (enhanceType == nullptr) { return true; } - ASSERT(enhanceType->GetOriginalBaseType() == paramType->GetOriginalBaseType()); + ES2PANDA_ASSERT(enhanceType->GetOriginalBaseType() == paramType->GetOriginalBaseType()); bool res = true; for (size_t i = 0; i < enhanceType->TypeArguments().size(); i++) { res &= enhance(paramType->TypeArguments()[i], enhanceType->TypeArguments()[i]); @@ -1058,7 +1058,7 @@ Signature *ETSChecker::ComposeSignature(ir::ScriptFunction *func, SignatureInfo { auto *signature = CreateSignature(signatureInfo, returnType, func); if (signature == nullptr) { // #23134 - ASSERT(IsAnyError()); + ES2PANDA_ASSERT(IsAnyError()); return nullptr; } signature->SetOwner(Context().ContainingClass()); @@ -1128,8 +1128,8 @@ static bool AppendSignatureInfoParam(ETSChecker *checker, SignatureInfo *sigInfo if (!param->IsOptional()) { ++sigInfo->minArgCount; } - ASSERT(!param->IsOptional() || - checker->Relation()->IsSupertypeOf(param->Ident()->TsType(), checker->GlobalETSUndefinedType())); + ES2PANDA_ASSERT(!param->IsOptional() || + checker->Relation()->IsSupertypeOf(param->Ident()->TsType(), checker->GlobalETSUndefinedType())); return true; } @@ -1149,7 +1149,7 @@ SignatureInfo *ETSChecker::ComposeSignatureInfo(ir::TSTypeParameterDeclaration * for (auto *const p : params) { if (!p->IsETSParameterExpression() || !AppendSignatureInfoParam(this, signatureInfo, p->AsETSParameterExpression())) { // #23134 - ASSERT(IsAnyError()); + ES2PANDA_ASSERT(IsAnyError()); return nullptr; } } @@ -1157,11 +1157,11 @@ SignatureInfo *ETSChecker::ComposeSignatureInfo(ir::TSTypeParameterDeclaration * if (!params.empty()) { if (auto param = params.back()->AsETSParameterExpression(); param->IsRestParameter()) { if (param->TypeAnnotation() == nullptr) { // #23134 - ASSERT(IsAnyError()); + ES2PANDA_ASSERT(IsAnyError()); return nullptr; } signatureInfo->restVar = SetupSignatureParameter(param, param->TypeAnnotation()->GetType(this)); - ASSERT(signatureInfo->restVar != nullptr); + ES2PANDA_ASSERT(signatureInfo->restVar != nullptr); } } @@ -1204,7 +1204,7 @@ void ETSChecker::BuildFunctionSignature(ir::ScriptFunction *func, bool isConstru auto *returnType = ComposeReturnType(func->ReturnTypeAnnotation(), func->IsAsyncFunc()); auto *signature = ComposeSignature(func, signatureInfo, returnType, nameVar); if (signature == nullptr) { // #23134 - ASSERT(IsAnyError()); + ES2PANDA_ASSERT(IsAnyError()); return; } @@ -1406,7 +1406,7 @@ void ETSChecker::ReportOverrideError(Signature *signature, Signature *overridden break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -1530,7 +1530,7 @@ Signature *ETSChecker::GetSignatureFromMethodDefinition(const ir::MethodDefiniti if (methodDef->TsType()->IsTypeError()) { return nullptr; } - ES2PANDA_ASSERT3(methodDef->TsType() && methodDef->TsType()->IsETSFunctionType(), methodDef->Start()); + ES2PANDA_ASSERT_POS(methodDef->TsType() && methodDef->TsType()->IsETSFunctionType(), methodDef->Start()); for (auto *it : methodDef->TsType()->AsETSFunctionType()->CallSignatures()) { if (it->Function() == methodDef->Function()) { return it; @@ -1681,7 +1681,7 @@ bool ETSChecker::IsReturnTypeSubstitutable(Signature *const s1, Signature *const // is parametrized or not to use a proper subtyping check. To be replaced with IsETSPrimitiveType after #19701. auto const hasPrimitiveReturnType = [](Signature *s) { bool origIsRef = s->Function()->Signature()->ReturnType()->IsETSReferenceType(); - ES2PANDA_ASSERT3(origIsRef == s->ReturnType()->IsETSReferenceType(), s->Function()->Start()); + ES2PANDA_ASSERT_POS(origIsRef == s->ReturnType()->IsETSReferenceType(), s->Function()->Start()); return !origIsRef; }; // - If R1 is a primitive type then R2 is identical to R1. @@ -1705,7 +1705,7 @@ std::string ETSChecker::GetAsyncImplName(const util::StringView &name) std::string ETSChecker::GetAsyncImplName(ir::MethodDefinition *asyncMethod) { ir::Identifier *asyncName = asyncMethod->Function()->Id(); - ES2PANDA_ASSERT3(asyncName != nullptr, asyncMethod->Start()); + ES2PANDA_ASSERT_POS(asyncName != nullptr, asyncMethod->Start()); return GetAsyncImplName(asyncName->Name()); } diff --git a/ets2panda/checker/ets/helpers.cpp b/ets2panda/checker/ets/helpers.cpp index 581160f719..68d09f28c4 100644 --- a/ets2panda/checker/ets/helpers.cpp +++ b/ets2panda/checker/ets/helpers.cpp @@ -361,7 +361,7 @@ checker::Type *ETSChecker::ApplyConditionalOperatorPromotion(checker::ETSChecker if (checkLeftRight.has_value()) { return checkLeftRight.value(); } - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } Type *ETSChecker::ApplyUnaryOperatorPromotion(Type *type, const bool createConst, const bool doPromotion, @@ -443,7 +443,7 @@ Type *ETSChecker::HandleBooleanLogicalOperators(Type *leftType, Type *rightType, } } - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); return nullptr; } @@ -512,7 +512,7 @@ void ETSChecker::ResolveReturnStatement(checker::Type *funcReturnType, checker:: } } else { // Should never in this branch. - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); return; } } @@ -1134,7 +1134,7 @@ std::optional CheckerContext::ResolveSmartCastTypes() return std::nullopt; } - ASSERT(testCondition_.testedType != nullptr); + ES2PANDA_ASSERT(testCondition_.testedType != nullptr); if (!testCondition_.testedType->IsETSReferenceType()) { return std::nullopt; } @@ -1578,7 +1578,7 @@ Type *ETSChecker::ResolveReferencedType(varbinder::LocalVariable *refVar, const return GlobalTypeError(); default: - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -1624,7 +1624,7 @@ void ETSChecker::ConcatConstantString(util::UString &target, Type *type) break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } @@ -1752,7 +1752,7 @@ util::StringView ETSChecker::GetContainingObjectNameFromSignature(Signature *sig iter = iter->Parent(); } - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); return {""}; } @@ -1894,7 +1894,7 @@ std::string ETSChecker::GetStringFromIdentifierValue(checker::Type *caseType) co return "error"; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } @@ -2092,7 +2092,7 @@ std::string ETSChecker::GetStringFromLiteral(ir::Expression *caseTest) const return util::Helpers::LiteralToPropName(caseTest).Mutf8(); } default: - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } diff --git a/ets2panda/checker/ets/narrowingConverter.h b/ets2panda/checker/ets/narrowingConverter.h index b7c25333a7..19f9e14138 100644 --- a/ets2panda/checker/ets/narrowingConverter.h +++ b/ets2panda/checker/ets/narrowingConverter.h @@ -162,7 +162,7 @@ private: return static_cast(value); } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } diff --git a/ets2panda/checker/ets/object.cpp b/ets2panda/checker/ets/object.cpp index 657c99eb3a..b0308a8ff0 100644 --- a/ets2panda/checker/ets/object.cpp +++ b/ets2panda/checker/ets/object.cpp @@ -1490,7 +1490,7 @@ std::optional ETSChecker::GetTupleElementAccessValue(const Type *co return std::nullopt; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } @@ -1631,7 +1631,7 @@ void ETSChecker::ValidateNamespaceProperty(varbinder::Variable *property, const if (property->TsType() != nullptr && property->TsType()->IsETSMethodType()) { auto funcType = property->TsType()->AsETSFunctionType(); property = funcType->CallSignatures()[0]->OwnerVar(); - ASSERT(property != nullptr); + ES2PANDA_ASSERT(property != nullptr); } if (property->Declaration() == nullptr) { @@ -1945,8 +1945,8 @@ bool ETSChecker::FindPropertyInAssignment(const ir::AstNode *it, const std::stri static ResolvedKind DecideResolvedKind(Type *typeOfGlobalFunctionVar) { - ASSERT(typeOfGlobalFunctionVar != nullptr); - ASSERT(typeOfGlobalFunctionVar->IsETSObjectType() || typeOfGlobalFunctionVar->IsETSFunctionType()); + ES2PANDA_ASSERT(typeOfGlobalFunctionVar != nullptr); + ES2PANDA_ASSERT(typeOfGlobalFunctionVar->IsETSObjectType() || typeOfGlobalFunctionVar->IsETSFunctionType()); if (typeOfGlobalFunctionVar->IsETSObjectType()) { return ResolvedKind::EXTENSION_FUNCTION; } @@ -2147,7 +2147,7 @@ void ETSChecker::CheckProperties(ETSObjectType *classType, ir::ClassDefinition * } else if (it->HasFlag(varbinder::VariableFlags::ENUM_LITERAL)) { targetType = "enum"; } else { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } if (interfaceFound != nullptr) { diff --git a/ets2panda/checker/ets/typeCheckingHelpers.cpp b/ets2panda/checker/ets/typeCheckingHelpers.cpp index ed2be72a2c..55badd2535 100644 --- a/ets2panda/checker/ets/typeCheckingHelpers.cpp +++ b/ets2panda/checker/ets/typeCheckingHelpers.cpp @@ -593,14 +593,14 @@ Type *ETSChecker::GuaranteedTypeForUncheckedPropertyAccess(varbinder::Variable * case ir::AstNodeType::CLASS_DEFINITION: return GetTypeOfVariable(prop); default: - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } // Determine if substituted method cast requires cast from erased type Type *ETSChecker::GuaranteedTypeForUncheckedCallReturn(Signature *sig) { - ASSERT(sig->HasFunction()); + ES2PANDA_ASSERT(sig->HasFunction()); if (sig->HasSignatureFlag(SignatureFlags::THIS_RETURN_TYPE)) { return sig->ReturnType(); } @@ -756,7 +756,7 @@ bool ETSChecker::CheckAmbientAnnotationFieldInitializer(ir::Expression *init, ir return false; } default: - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } return true; @@ -813,7 +813,7 @@ bool ETSChecker::CheckAmbientAnnotationFieldInitializerValue(ir::Expression *ini expected->AsUnaryExpression()->Argument()); } default: - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -952,7 +952,7 @@ void ETSChecker::CheckStandardAnnotation(ir::AnnotationUsage *anno) if (anno->GetBaseName()->Variable() == nullptr) { return; } - ASSERT(anno->GetBaseName()->Variable()->Declaration()->Node()->AsAnnotationDeclaration() != nullptr); + ES2PANDA_ASSERT(anno->GetBaseName()->Variable()->Declaration()->Node()->AsAnnotationDeclaration() != nullptr); auto *annoDecl = anno->GetBaseName()->Variable()->Declaration()->Node()->AsAnnotationDeclaration(); auto annoName = annoDecl->InternalName().Mutf8(); if (annoName.rfind(compiler::Signatures::STD_ANNOTATIONS) != 0) { @@ -1133,7 +1133,7 @@ ir::BoxingUnboxingFlags ETSChecker::GetBoxingFlag(Type *const boxingType) case TypeFlag::DOUBLE: return ir::BoxingUnboxingFlags::BOX_TO_DOUBLE; default: - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -1158,7 +1158,7 @@ ir::BoxingUnboxingFlags ETSChecker::GetUnboxingFlag(Type const *const unboxingTy case TypeFlag::DOUBLE: return ir::BoxingUnboxingFlags::UNBOX_TO_DOUBLE; default: - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -1279,7 +1279,7 @@ static ir::AstNode *DerefETSTypeReference(ir::AstNode *node) // #22952: optional arrow leftovers bool ETSChecker::CheckLambdaAssignable(ir::Expression *param, ir::ScriptFunction *lambda) { - ASSERT(param->IsETSParameterExpression()); + ES2PANDA_ASSERT(param->IsETSParameterExpression()); ir::AstNode *typeAnn = param->AsETSParameterExpression()->Ident()->TypeAnnotation(); if (typeAnn->IsETSTypeReference()) { typeAnn = DerefETSTypeReference(typeAnn); diff --git a/ets2panda/checker/ets/typeCreation.cpp b/ets2panda/checker/ets/typeCreation.cpp index a5ef57e129..101e14ba18 100644 --- a/ets2panda/checker/ets/typeCreation.cpp +++ b/ets2panda/checker/ets/typeCreation.cpp @@ -200,7 +200,7 @@ static SignatureFlags ConvertToSignatureFlags(ir::ModifierFlags inModifiers, ir: Signature *ETSChecker::CreateSignature(SignatureInfo *info, Type *returnType, ir::ScriptFunction *func) { if (info == nullptr) { // #23134 - ASSERT(IsAnyError()); + ES2PANDA_ASSERT(IsAnyError()); return nullptr; } auto signature = Allocator()->New(info, returnType, func); @@ -211,7 +211,7 @@ Signature *ETSChecker::CreateSignature(SignatureInfo *info, Type *returnType, ir Signature *ETSChecker::CreateSignature(SignatureInfo *info, Type *returnType, ir::ScriptFunctionFlags sff) { if (info == nullptr) { // #23134 - ASSERT(IsAnyError()); + ES2PANDA_ASSERT(IsAnyError()); return nullptr; } auto signature = Allocator()->New(info, returnType, nullptr); diff --git a/ets2panda/checker/ets/typeRelationContext.cpp b/ets2panda/checker/ets/typeRelationContext.cpp index 3a0ddfbd78..408ddcb599 100644 --- a/ets2panda/checker/ets/typeRelationContext.cpp +++ b/ets2panda/checker/ets/typeRelationContext.cpp @@ -65,6 +65,7 @@ bool InstantiationContext::ValidateTypeArguments(ETSObjectType *type, ir::TSType return false; } +// CC-OFFNXT(huge_depth[C++]) solid logic void InstantiationContext::InstantiateType(ETSObjectType *type, ir::TSTypeParameterInstantiation *typeArgs) { ArenaVector typeArgTypes(checker_->Allocator()->Adapter()); @@ -82,9 +83,12 @@ void InstantiationContext::InstantiateType(ETSObjectType *type, ir::TSTypeParame checker_->Relation()->SetNode(it); auto *const boxedTypeArg = checker_->MaybeBoxInRelation(paramType); - ASSERT(boxedTypeArg != nullptr); - paramType = boxedTypeArg->Instantiate(checker_->Allocator(), checker_->Relation(), - checker_->GetGlobalTypesHolder()); + if (boxedTypeArg != nullptr) { + paramType = boxedTypeArg->Instantiate(checker_->Allocator(), checker_->Relation(), + checker_->GetGlobalTypesHolder()); + } else { + ES2PANDA_UNREACHABLE(); + } } typeArgTypes.push_back(paramType); diff --git a/ets2panda/checker/ets/unboxingConverter.cpp b/ets2panda/checker/ets/unboxingConverter.cpp index 8c10b9170c..e3b958cf6d 100644 --- a/ets2panda/checker/ets/unboxingConverter.cpp +++ b/ets2panda/checker/ets/unboxingConverter.cpp @@ -40,7 +40,7 @@ checker::Type *UnboxingConverter::Convert(checker::ETSChecker const *checker, ET case ETSObjectFlags::BUILTIN_DOUBLE: return checker->GlobalDoubleType(); default: - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } diff --git a/ets2panda/checker/ts/destructuringContext.cpp b/ets2panda/checker/ts/destructuringContext.cpp index b6f17a29a4..e017996260 100644 --- a/ets2panda/checker/ts/destructuringContext.cpp +++ b/ets2panda/checker/ts/destructuringContext.cpp @@ -487,7 +487,7 @@ void ArrayDestructuringContext::HandleElement(ir::Expression *element, Type *nex break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } @@ -708,7 +708,7 @@ void ObjectDestructuringContext::Start() } else if (itType == ir::AstNodeType::REST_ELEMENT) { HandleRest(it->AsRestElement()); } else { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } diff --git a/ets2panda/checker/ts/function.cpp b/ets2panda/checker/ts/function.cpp index 4f2d4ce25a..e4419c3f8c 100644 --- a/ets2panda/checker/ts/function.cpp +++ b/ets2panda/checker/ts/function.cpp @@ -296,7 +296,7 @@ std::tuple TSCheck return {nullptr, nullptr, false}; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } @@ -380,7 +380,7 @@ std::tuple TSCheck break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -447,7 +447,7 @@ void TSChecker::HandlePropertyPatternParameterName(ir::Property *prop, std::stri break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); break; } } @@ -522,7 +522,7 @@ ir::Statement *FindSubsequentFunctionNode(ir::BlockStatement *block, ir::ScriptF } } - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); return nullptr; } diff --git a/ets2panda/checker/ts/helpers.cpp b/ets2panda/checker/ts/helpers.cpp index 7585c53450..1762795939 100644 --- a/ets2panda/checker/ts/helpers.cpp +++ b/ets2panda/checker/ts/helpers.cpp @@ -465,7 +465,7 @@ Type *TSChecker::GetDeclTsType(varbinder::Variable *var, varbinder::Decl *decl) break; } case varbinder::DeclType::ENUM_LITERAL: { - UNREACHABLE(); // NOTE: aszilagyi. + ES2PANDA_UNREACHABLE(); // NOTE: aszilagyi. } default: { break; diff --git a/ets2panda/checker/ts/typeElaborationContext.cpp b/ets2panda/checker/ts/typeElaborationContext.cpp index 8aff5f7d19..275c3459d3 100644 --- a/ets2panda/checker/ts/typeElaborationContext.cpp +++ b/ets2panda/checker/ts/typeElaborationContext.cpp @@ -108,7 +108,7 @@ Type *ObjectElaborationContext::NonComputedPropKeyType(ir::Property *prop) return checker_->Allocator()->New(prop->Key()->AsStringLiteral()->Str()); } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); break; } } diff --git a/ets2panda/checker/typeChecker/TypeChecker.cpp b/ets2panda/checker/typeChecker/TypeChecker.cpp index 8a5c0303d1..191e54e33d 100644 --- a/ets2panda/checker/typeChecker/TypeChecker.cpp +++ b/ets2panda/checker/typeChecker/TypeChecker.cpp @@ -38,7 +38,7 @@ bool RunTypeChecker(Checker *checker, ScriptExtension ext, ir::AstNode *node) case ScriptExtension::AS: return ASTypeChecker(checker).Check(node); default: - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } diff --git a/ets2panda/checker/types/ets/etsFunctionType.cpp b/ets2panda/checker/types/ets/etsFunctionType.cpp index 1f454eece9..db327f239f 100644 --- a/ets2panda/checker/types/ets/etsFunctionType.cpp +++ b/ets2panda/checker/types/ets/etsFunctionType.cpp @@ -67,7 +67,7 @@ static ETSObjectType *FunctionTypeToFunctionalInterfaceType(ETSChecker *checker, return functionN->Substitute(checker->Relation(), substitution, true, isExtensionHack); } - ASSERT(arity >= signature->MinArgCount() && arity <= signature->ArgCount()); + ES2PANDA_ASSERT(arity >= signature->MinArgCount() && arity <= signature->ArgCount()); // Note: FunctionN is not supported yet if (arity >= checker->GetGlobalTypesHolder()->VariadicFunctionTypeThreshold()) { @@ -115,13 +115,13 @@ ETSFunctionType *ETSFunctionType::MethodToArrow(ETSChecker *checker) return cached; } - ASSERT(!IsETSArrowType() && CallSignatures().size() == 1); + ES2PANDA_ASSERT(!IsETSArrowType() && CallSignatures().size() == 1); return cached = checker->CreateETSArrowType(CallSignatures()[0]); } void ETSFunctionType::AddCallSignature(Signature *signature) { - ASSERT(!IsETSArrowType()); + ES2PANDA_ASSERT(!IsETSArrowType()); if (signature->Function()->IsGetter()) { AddTypeFlag(TypeFlag::GETTER); @@ -232,9 +232,9 @@ bool ETSFunctionType::AssignmentSource(TypeRelation *relation, Type *target) // this should be defined by the dynamic type itself if (target->IsETSDynamicType()) { - ASSERT(relation->GetNode() != nullptr); + ES2PANDA_ASSERT(relation->GetNode() != nullptr); if (relation->GetNode()->IsArrowFunctionExpression()) { - ASSERT(callSignatures_.size() == 1 && ArrowSignature()->HasSignatureFlag(SignatureFlags::CALL)); + ES2PANDA_ASSERT(callSignatures_.size() == 1 && ArrowSignature()->HasSignatureFlag(SignatureFlags::CALL)); return relation->Result(true); } return relation->Result(false); @@ -357,7 +357,7 @@ static std::string FunctionAssemblyTypeFromArity(uint32_t arity) void ETSFunctionType::ToDebugInfoType([[maybe_unused]] std::stringstream &ss) const { - ASSERT(IsETSArrowType()); + ES2PANDA_ASSERT(IsETSArrowType()); ss << FunctionAssemblyTypeFromArity(ArrowSignature()->MinArgCount()); } diff --git a/ets2panda/checker/types/ets/etsFunctionType.h b/ets2panda/checker/types/ets/etsFunctionType.h index eb489bd617..d3a880af37 100644 --- a/ets2panda/checker/types/ets/etsFunctionType.h +++ b/ets2panda/checker/types/ets/etsFunctionType.h @@ -32,13 +32,13 @@ public: [[nodiscard]] ArenaVector &CallSignatures() { - ASSERT(!IsETSArrowType()); + ES2PANDA_ASSERT(!IsETSArrowType()); return callSignatures_; } [[nodiscard]] const ArenaVector &CallSignatures() const { - ASSERT(!IsETSArrowType()); + ES2PANDA_ASSERT(!IsETSArrowType()); return callSignatures_; } @@ -50,7 +50,7 @@ public: [[nodiscard]] util::StringView Name() const { - ASSERT(!IsETSArrowType()); + ES2PANDA_ASSERT(!IsETSArrowType()); return name_; } @@ -59,7 +59,7 @@ public: template Signature *FindSpecificSignature(UnaryPredicate predicate) const noexcept { - ASSERT(!IsETSArrowType()); + ES2PANDA_ASSERT(!IsETSArrowType()); auto const it = std::find_if(callSignatures_.cbegin(), callSignatures_.cend(), predicate); return it != callSignatures_.cend() ? *it : nullptr; } @@ -87,10 +87,10 @@ public: Signature *ArrowSignature() const { - ASSERT(IsETSArrowType()); - ASSERT(callSignatures_.size() == 1); + ES2PANDA_ASSERT(IsETSArrowType()); + ES2PANDA_ASSERT(callSignatures_.size() == 1); auto sig = callSignatures_[0]; - ASSERT(!sig->HasFunction()); + ES2PANDA_ASSERT(!sig->HasFunction()); return sig; } diff --git a/ets2panda/checker/types/ets/etsNeverType.cpp b/ets2panda/checker/types/ets/etsNeverType.cpp index b112df060d..e6fa4f3806 100644 --- a/ets2panda/checker/types/ets/etsNeverType.cpp +++ b/ets2panda/checker/types/ets/etsNeverType.cpp @@ -38,7 +38,7 @@ bool ETSNeverType::AssignmentSource(TypeRelation *relation, [[maybe_unused]] Typ void ETSNeverType::Compare([[maybe_unused]] TypeRelation *relation, [[maybe_unused]] Type *other) { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSNeverType::Cast(TypeRelation *relation, Type *target) diff --git a/ets2panda/checker/types/ets/etsNullishTypes.cpp b/ets2panda/checker/types/ets/etsNullishTypes.cpp index 86d49369d0..6e102e1675 100644 --- a/ets2panda/checker/types/ets/etsNullishTypes.cpp +++ b/ets2panda/checker/types/ets/etsNullishTypes.cpp @@ -39,7 +39,7 @@ bool ETSNullType::AssignmentSource(TypeRelation *relation, Type *target) void ETSNullType::Compare([[maybe_unused]] TypeRelation *relation, [[maybe_unused]] Type *other) { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSNullType::Cast(TypeRelation *relation, Type *target) @@ -90,7 +90,7 @@ bool ETSUndefinedType::AssignmentSource(TypeRelation *relation, Type *target) void ETSUndefinedType::Compare([[maybe_unused]] TypeRelation *relation, [[maybe_unused]] Type *other) { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSUndefinedType::Cast(TypeRelation *relation, Type *target) diff --git a/ets2panda/checker/types/ets/etsObjectType.cpp b/ets2panda/checker/types/ets/etsObjectType.cpp index a97a942ac3..9a84a66960 100644 --- a/ets2panda/checker/types/ets/etsObjectType.cpp +++ b/ets2panda/checker/types/ets/etsObjectType.cpp @@ -167,7 +167,7 @@ varbinder::LocalVariable *ETSObjectType::CreateSyntheticVarFromEverySignature(co std::vector signatures; varbinder::LocalVariable *functionalInterface = CollectSignaturesForSyntheticType(signatures, name, flags); // #22952: the called function *always* returns nullptr - ASSERT(functionalInterface == nullptr); + ES2PANDA_ASSERT(functionalInterface == nullptr); (void)functionalInterface; if (signatures.empty()) { @@ -192,7 +192,7 @@ varbinder::LocalVariable *ETSObjectType::CreateSyntheticVarFromEverySignature(co ETSFunctionType *ETSObjectType::CreateMethodTypeForProp(const util::StringView &name) const { - ASSERT(GetRelation() != nullptr); + ES2PANDA_ASSERT(GetRelation() != nullptr); return GetRelation()->GetChecker()->AsETSChecker()->CreateETSMethodType(name, {{}, Allocator()->Adapter()}); } @@ -492,7 +492,7 @@ void ETSObjectType::AssignmentTarget(TypeRelation *const relation, Type *source) ETSFunctionType *ETSObjectType::GetFunctionalInterfaceInvokeType() const { - ASSERT(HasObjectFlag(ETSObjectFlags::FUNCTIONAL)); + ES2PANDA_ASSERT(HasObjectFlag(ETSObjectFlags::FUNCTIONAL)); // NOTE(vpukhov): this is still better than to retain any "functional" state in ETSObjectType auto [foundArity, hasRest] = [this]() { @@ -506,12 +506,12 @@ ETSFunctionType *ETSObjectType::GetFunctionalInterfaceInvokeType() const return std::make_pair(arity, true); } } - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); }(); std::string invokeName = FunctionalInterfaceInvokeName(foundArity, hasRest); auto *invoke = GetOwnProperty(util::StringView(invokeName)); - ASSERT(invoke != nullptr && invoke->TsType() != nullptr && invoke->TsType()->IsETSFunctionType()); + ES2PANDA_ASSERT(invoke != nullptr && invoke->TsType() != nullptr && invoke->TsType()->IsETSFunctionType()); return invoke->TsType()->AsETSFunctionType(); } @@ -756,7 +756,7 @@ void ETSObjectType::IsGenericSupertypeOf(TypeRelation *relation, ETSObjectType * return; } - ASSERT(declNode_ == source->GetDeclNode()); + ES2PANDA_ASSERT(declNode_ == source->GetDeclNode()); auto *typeParamsDecl = GetTypeParams(); ES2PANDA_ASSERT(typeParamsDecl != nullptr || typeArguments_.empty()); diff --git a/ets2panda/checker/types/ets/etsTupleType.cpp b/ets2panda/checker/types/ets/etsTupleType.cpp index d4546021f8..60b2c20e27 100644 --- a/ets2panda/checker/types/ets/etsTupleType.cpp +++ b/ets2panda/checker/types/ets/etsTupleType.cpp @@ -61,7 +61,7 @@ uint32_t ETSTupleType::Rank() const Type *ETSTupleType::GetTypeAtIndex(const TupleSizeType index) const { - ASSERT(index < GetTupleSize()); + ES2PANDA_ASSERT(index < GetTupleSize()); return GetTupleTypesList().at(index); } diff --git a/ets2panda/checker/types/signature.cpp b/ets2panda/checker/types/signature.cpp index b1772fbd4f..ceed788dbb 100644 --- a/ets2panda/checker/types/signature.cpp +++ b/ets2panda/checker/types/signature.cpp @@ -205,8 +205,8 @@ std::string Signature::ToString() const static bool MethodSignaturesAreCompatible(TypeRelation *relation, bool checkIdentical, Signature *const super, Signature *const sub) { - ASSERT(!sub->HasRestParameter() || (sub->ArgCount() == sub->MinArgCount())); - ASSERT(!super->HasRestParameter() || (super->ArgCount() == super->MinArgCount())); + ES2PANDA_ASSERT(!sub->HasRestParameter() || (sub->ArgCount() == sub->MinArgCount())); + ES2PANDA_ASSERT(!super->HasRestParameter() || (super->ArgCount() == super->MinArgCount())); if (sub->ArgCount() != super->ArgCount()) { return false; @@ -298,7 +298,7 @@ Signature *Signature::ToArrowSignature(ETSChecker *checker) resultSig->flags_ = flags_; resultSig->SetOwner(Owner()); resultSig->SetOwnerVar(OwnerVar()); - ASSERT(!resultSig->HasFunction()); + ES2PANDA_ASSERT(!resultSig->HasFunction()); return resultSig; } diff --git a/ets2panda/checker/types/signature.h b/ets2panda/checker/types/signature.h index 4598c7f04f..d616adb638 100644 --- a/ets2panda/checker/types/signature.h +++ b/ets2panda/checker/types/signature.h @@ -188,13 +188,13 @@ public: [[nodiscard]] ir::ScriptFunction *Function() noexcept { - ASSERT(HasFunction()); + ES2PANDA_ASSERT(HasFunction()); return func_; } [[nodiscard]] const ir::ScriptFunction *Function() const noexcept { - ASSERT(HasFunction()); + ES2PANDA_ASSERT(HasFunction()); return func_; } diff --git a/ets2panda/checker/types/ts/objectDescriptor.h b/ets2panda/checker/types/ts/objectDescriptor.h index f14417c1f7..5a126fd4da 100644 --- a/ets2panda/checker/types/ts/objectDescriptor.h +++ b/ets2panda/checker/types/ts/objectDescriptor.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * 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 @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CHECKER_TYPES_TS_OBJECT_DESCRIPTOR_H #define ES2PANDA_COMPILER_CHECKER_TYPES_TS_OBJECT_DESCRIPTOR_H -#include "macros.h" +#include "util/es2pandaMacros.h" #include "util/ustring.h" #include diff --git a/ets2panda/checker/types/ts/tupleType.h b/ets2panda/checker/types/ts/tupleType.h index 94054af236..82f695644d 100644 --- a/ets2panda/checker/types/ts/tupleType.h +++ b/ets2panda/checker/types/ts/tupleType.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * 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 @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CHECKER_TYPES_TS_TUPLE_TYPE_H #define ES2PANDA_COMPILER_CHECKER_TYPES_TS_TUPLE_TYPE_H -#include "macros.h" +#include "util/es2pandaMacros.h" #include "varbinder/variable.h" #include "checker/types/ts/elementFlags.h" diff --git a/ets2panda/checker/types/ts/typeParameter.cpp b/ets2panda/checker/types/ts/typeParameter.cpp index 686db72927..9cd7d90b86 100644 --- a/ets2panda/checker/types/ts/typeParameter.cpp +++ b/ets2panda/checker/types/ts/typeParameter.cpp @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * 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 @@ -18,29 +18,29 @@ namespace ark::es2panda::checker { void TypeParameter::ToString([[maybe_unused]] std::stringstream &ss, [[maybe_unused]] bool precise) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void TypeParameter::Identical([[maybe_unused]] TypeRelation *relation, [[maybe_unused]] Type *other) { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void TypeParameter::AssignmentTarget([[maybe_unused]] TypeRelation *relation, [[maybe_unused]] Type *source) { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } TypeFacts TypeParameter::GetTypeFacts() const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); return TypeFacts::NONE; } Type *TypeParameter::Instantiate([[maybe_unused]] ArenaAllocator *allocator, [[maybe_unused]] TypeRelation *relation, [[maybe_unused]] GlobalTypesHolder *globalTypes) { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); return nullptr; } } // namespace ark::es2panda::checker diff --git a/ets2panda/checker/types/ts/typeReference.cpp b/ets2panda/checker/types/ts/typeReference.cpp index 096deaa077..eb6106ec4f 100644 --- a/ets2panda/checker/types/ts/typeReference.cpp +++ b/ets2panda/checker/types/ts/typeReference.cpp @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * 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 @@ -52,7 +52,7 @@ Type *TypeReference::Instantiate(ArenaAllocator *allocator, TypeRelation *relati return (*ref_)->Instantiate(allocator, relation, globalTypes); } - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); return nullptr; } } // namespace ark::es2panda::checker diff --git a/ets2panda/checker/types/type.h b/ets2panda/checker/types/type.h index b3253037fe..948ea1be83 100644 --- a/ets2panda/checker/types/type.h +++ b/ets2panda/checker/types/type.h @@ -260,7 +260,7 @@ public: virtual std::tuple ResolveConditionExpr() const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); }; virtual void Identical(TypeRelation *relation, Type *other); diff --git a/ets2panda/checker/types/typeRelation.h b/ets2panda/checker/types/typeRelation.h index 110ebac6ad..489132498b 100644 --- a/ets2panda/checker/types/typeRelation.h +++ b/ets2panda/checker/types/typeRelation.h @@ -82,7 +82,6 @@ struct enumbitops::IsAllowedType : std }; namespace ark::es2panda::checker { -using DiagnosticMessageElement = util::DiagnosticMessageElement; class RelationKey { public: diff --git a/ets2panda/compiler/base/lreference.cpp b/ets2panda/compiler/base/lreference.cpp index 88c4e1839e..48bab0c0d6 100644 --- a/ets2panda/compiler/base/lreference.cpp +++ b/ets2panda/compiler/base/lreference.cpp @@ -70,7 +70,7 @@ LReference::LReferenceBase LReference::CreateBase(CodeGen *cg, const ir::AstNode return CreateBase(cg, node->AsTSNonNullExpression()->Expr(), isDeclaration); } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } @@ -136,7 +136,7 @@ void JSLReference::GetValue() const break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } @@ -167,7 +167,7 @@ void JSLReference::SetValue() const break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } diff --git a/ets2panda/compiler/core/ETSCompiler.cpp b/ets2panda/compiler/core/ETSCompiler.cpp index e938cd25e5..d2b2570654 100644 --- a/ets2panda/compiler/core/ETSCompiler.cpp +++ b/ets2panda/compiler/core/ETSCompiler.cpp @@ -366,7 +366,7 @@ void ETSCompiler::Compile(const ir::ETSTypeReferencePart *node) const void ETSCompiler::Compile([[maybe_unused]] const ir::ETSWildcardType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile(const ir::ArrayExpression *expr) const @@ -455,7 +455,7 @@ void ETSCompiler::Compile(const ir::AwaitExpression *expr) const void ETSCompiler::Compile([[maybe_unused]] const ir::ImportExpression *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } static void CompileNullishCoalescing(compiler::ETSGen *etsg, ir::BinaryExpression const *const node) @@ -776,7 +776,7 @@ void ETSCompiler::Compile(const ir::CallExpression *expr) const auto const callee = expr->Callee(); checker::Signature *const signature = expr->Signature(); - ASSERT(!callee->TsType()->IsETSArrowType()); // should have been lowered + ES2PANDA_ASSERT(!callee->TsType()->IsETSArrowType()); // should have been lowered bool const isStatic = signature->HasSignatureFlag(checker::SignatureFlags::STATIC); @@ -797,12 +797,12 @@ void ETSCompiler::Compile(const ir::CallExpression *expr) const } EmitCall(expr, calleeReg, signature); } else if (callee->IsSuperExpression() || callee->IsThisExpression()) { - ASSERT(expr->IsETSConstructorCall()); + ES2PANDA_ASSERT(expr->IsETSConstructorCall()); callee->Compile(etsg); // ctor is not a value! etsg->StoreAccumulator(expr, calleeReg); EmitCall(expr, calleeReg, signature); } else { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } if (expr->HasBoxingUnboxingFlags(ir::BoxingUnboxingFlags::UNBOXING_FLAG | ir::BoxingUnboxingFlags::BOXING_FLAG)) { @@ -889,7 +889,7 @@ bool ETSCompiler::CompileComputed(compiler::ETSGen *etsg, const ir::MemberExpres } else if (objectType->IsETSArrayType()) { etsg->LoadArrayElement(expr, objReg); } else { - ASSERT(objectType->IsETSTupleType()); + ES2PANDA_ASSERT(objectType->IsETSTupleType()); etsg->LoadTupleElement(expr, objReg); } @@ -1023,7 +1023,7 @@ void ETSCompiler::Compile(const ir::ObjectExpression *expr) const } else if (key->IsIdentifier()) { pname = key->AsIdentifier()->Name(); } else { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } value->Compile(etsg); @@ -1641,7 +1641,7 @@ void ETSCompiler::CompileCastUnboxable(const ir::TSAsExpression *expr) const etsg->CastToDouble(expr); break; default: - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -1684,7 +1684,7 @@ void ETSCompiler::CompileCastPrimitives(const ir::TSAsExpression *expr) const break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } diff --git a/ets2panda/compiler/core/ETSCompilerUnrechable.cpp b/ets2panda/compiler/core/ETSCompilerUnrechable.cpp index 9f0c7cf28e..29ac5ceb21 100644 --- a/ets2panda/compiler/core/ETSCompilerUnrechable.cpp +++ b/ets2panda/compiler/core/ETSCompilerUnrechable.cpp @@ -19,493 +19,493 @@ namespace ark::es2panda::compiler { void ETSCompiler::Compile([[maybe_unused]] const ir::NamedType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::PrefixAssertionExpression *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::ClassDefinition *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::ClassStaticBlock *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::Decorator *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::MetaProperty *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::MethodDefinition *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::Property *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::ScriptFunction *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::SpreadElement *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSIndexSignature *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSMethodSignature *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSPropertySignature *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSSignatureDeclaration *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::ETSModule *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::ETSTuple *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::ETSImportDeclaration *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::ETSPackageDeclaration *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::ETSPrimitiveType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::ETSStructDeclaration *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::ETSNullType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::ETSUndefinedType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::ETSNeverType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::ETSStringLiteralType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::ETSUnionType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::ArrowFunctionExpression *expr) const { // Should have been handled by LambdaLowering - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::ChainExpression *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::ClassExpression *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::ETSReExportDeclaration *stmt) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::DirectEvalExpression *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::FunctionExpression *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::NewExpression *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::OmittedExpression *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::OpaqueTypeNode *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::BrokenTypeNode *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TaggedTemplateExpression *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::UpdateExpression *expr) const { // Should have been handled by OpAssignment lowering. - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::YieldExpression *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::RegExpLiteral *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::UndefinedLiteral *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::ExportAllDeclaration *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::ExportDefaultDeclaration *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::ExportNamedDeclaration *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::ExportSpecifier *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::ImportDeclaration *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::ImportDefaultSpecifier *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::ImportNamespaceSpecifier *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::ImportSpecifier *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::DebuggerStatement *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::ForInStatement *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::FunctionDeclaration *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::SwitchCaseStatement *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSAnyKeyword *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSBigintKeyword *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSBooleanKeyword *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSClassImplements *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSConditionalType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSConstructorType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSEnumMember *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSExternalModuleReference *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSFunctionType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSImportEqualsDeclaration *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSImportType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSIndexedAccessType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSInferType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSInterfaceBody *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSInterfaceHeritage *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSIntersectionType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSLiteralType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSMappedType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSModuleBlock *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSModuleDeclaration *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSNamedTupleMember *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSNeverKeyword *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSNullKeyword *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSNumberKeyword *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSObjectKeyword *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSParameterProperty *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSParenthesizedType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSQualifiedName *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSStringKeyword *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSThisType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSTupleType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSTypeAssertion *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSTypeLiteral *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSTypeOperator *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSTypeParameter *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSTypeParameterDeclaration *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSTypeParameterInstantiation *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSTypePredicate *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSTypeQuery *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSTypeReference *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSUndefinedKeyword *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSUnionType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSUnknownKeyword *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSVoidKeyword *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::DummyNode *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSEnumDeclaration *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } // namespace ark::es2panda::compiler diff --git a/ets2panda/compiler/core/ETSGen-inl.h b/ets2panda/compiler/core/ETSGen-inl.h index 808b8bf671..de548d52ed 100644 --- a/ets2panda/compiler/core/ETSGen-inl.h +++ b/ets2panda/compiler/core/ETSGen-inl.h @@ -65,7 +65,7 @@ void ETSGen::MoveImmediateToRegister(const ir::AstNode *node, VReg reg, const ch break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } diff --git a/ets2panda/compiler/core/ETSGen.cpp b/ets2panda/compiler/core/ETSGen.cpp index d678810b54..558de23457 100644 --- a/ets2panda/compiler/core/ETSGen.cpp +++ b/ets2panda/compiler/core/ETSGen.cpp @@ -327,7 +327,7 @@ void ETSGen::LoadVar(const ir::Identifier *node, varbinder::Variable const *cons break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } @@ -353,7 +353,7 @@ void ETSGen::StoreVar(const ir::Identifier *node, const varbinder::ConstScopeFin break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } @@ -448,7 +448,7 @@ void ETSGen::StorePropertyByName([[maybe_unused]] const ir::AstNode *node, [[may Ra().Emit(node, objReg, fullName); } #else - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); #endif // PANDA_WITH_ETS } @@ -468,7 +468,7 @@ void ETSGen::LoadPropertyByName([[maybe_unused]] const ir::AstNode *const node, } SetAccumulatorType(propType); #else - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); #endif // PANDA_WITH_ETS } @@ -609,7 +609,7 @@ void ETSGen::CallRangeFillUndefined(const ir::AstNode *const node, checker::Sign const VReg thisReg) { RegScope rs(this); - ASSERT(signature->MinArgCount() == 0); + ES2PANDA_ASSERT(signature->MinArgCount() == 0); auto undef = AllocReg(); LoadAccumulatorUndefined(node); @@ -775,7 +775,7 @@ void ETSGen::IsInstanceDynamic(const ir::BinaryExpression *const node, const VRe CallExact(node, Signatures::BUILTIN_JSRUNTIME_INSTANCE_OF_STATIC, srcReg, typeReg); } } else { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } SetAccumulatorType(Checker()->GlobalETSBooleanType()); @@ -839,7 +839,7 @@ void ETSGen::TestIsInstanceConstituent(const ir::AstNode *const node, std::tuple break; } default: - UNREACHABLE(); // other types must not appear here + ES2PANDA_UNREACHABLE(); // other types must not appear here } SetAccumulatorType(nullptr); } @@ -1081,7 +1081,7 @@ bool ETSGen::TryLoadConstantExpression(const ir::Expression *node) break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -1169,7 +1169,7 @@ void ETSGen::ApplyUnboxingConversion(const ir::AstNode *node) callUnbox(Signatures::BUILTIN_DOUBLE_UNBOXED, Checker()->GlobalDoubleType()); return; default: - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -1320,7 +1320,7 @@ void ETSGen::EmitBoxingConversion(ir::BoxingUnboxingFlags boxingFlag, const ir:: callBox(Signatures::BUILTIN_DOUBLE_VALUE_OF, Checker()->GlobalDoubleType()); return; default: - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -1396,7 +1396,7 @@ void ETSGen::CastToBoolean([[maybe_unused]] const ir::AstNode *node) break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -1444,7 +1444,7 @@ void ETSGen::CastToByte([[maybe_unused]] const ir::AstNode *node) break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -1497,7 +1497,7 @@ void ETSGen::CastToChar([[maybe_unused]] const ir::AstNode *node) break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -1547,7 +1547,7 @@ void ETSGen::CastToShort([[maybe_unused]] const ir::AstNode *node) break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -1590,7 +1590,7 @@ void ETSGen::CastToDouble(const ir::AstNode *node) break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -1632,7 +1632,7 @@ void ETSGen::CastToFloat(const ir::AstNode *node) break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -1675,7 +1675,7 @@ void ETSGen::CastToLong(const ir::AstNode *node) break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -1716,7 +1716,7 @@ void ETSGen::CastToInt(const ir::AstNode *node) break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -1808,7 +1808,7 @@ void ETSGen::CastDynamicToObject(const ir::AstNode *node, const checker::Type *t return; } - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSGen::CastToString(const ir::AstNode *const node) @@ -1860,7 +1860,7 @@ void ETSGen::CastToDynamic(const ir::AstNode *node, const checker::ETSDynamicTyp } [[fallthrough]]; case checker::TypeFlag::FUNCTION: - ASSERT(!GetAccumulatorType()->IsETSMethodType()); + ES2PANDA_ASSERT(!GetAccumulatorType()->IsETSMethodType()); [[fallthrough]]; case checker::TypeFlag::ETS_ARRAY: case checker::TypeFlag::ETS_TUPLE: @@ -1870,7 +1870,7 @@ void ETSGen::CastToDynamic(const ir::AstNode *node, const checker::ETSDynamicTyp SetAccumulatorType(type); return; default: - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } ES2PANDA_ASSERT(!methodName.empty()); @@ -1907,7 +1907,7 @@ void ETSGen::CastDynamicTo(const ir::AstNode *node, enum checker::TypeFlag typeF break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -1975,7 +1975,7 @@ void ETSGen::BinaryLogic(const ir::AstNode *node, lexer::TokenType op, VReg lhs) break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } ES2PANDA_ASSERT(node->IsAssignmentExpression() || node->IsBinaryExpression()); @@ -2102,7 +2102,7 @@ void ETSGen::Condition(const ir::AstNode *node, lexer::TokenType op, VReg lhs, L break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } @@ -2437,7 +2437,7 @@ void ETSGen::BinaryEqualityCondition(const ir::AstNode *node, VReg lhs, Label *i break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -2479,7 +2479,7 @@ void ETSGen::BinaryRelationCondition(const ir::AstNode *node, VReg lhs, Label *i break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -2537,7 +2537,7 @@ void ETSGen::BinaryBitwiseArithmetic(const ir::AstNode *node, VReg lhs) break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } @@ -2650,7 +2650,7 @@ void ETSGen::UpdateOperator(const ir::AstNode *node) break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } @@ -2733,7 +2733,7 @@ void ETSGen::Negate(const ir::AstNode *node) break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } @@ -2807,7 +2807,7 @@ void ETSGen::LoadAccumulatorNull([[maybe_unused]] const ir::AstNode *node) Sa().Emit(node); SetAccumulatorType(Checker()->GlobalETSNullType()); #else - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); #endif // PANDA_WITH_ETS } @@ -2833,7 +2833,7 @@ void ETSGen::Unary(const ir::AstNode *node, lexer::TokenType op) LogicalNot(node); break; default: - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -2867,7 +2867,7 @@ void ETSGen::UnaryMinus(const ir::AstNode *node) break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } @@ -2895,7 +2895,7 @@ void ETSGen::UnaryTilde(const ir::AstNode *node) break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } @@ -2912,7 +2912,7 @@ void ETSGen::Update(const ir::AstNode *node, lexer::TokenType op) break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } @@ -2929,7 +2929,7 @@ void ETSGen::UpdateBigInt(const ir::Expression *node, VReg arg, lexer::TokenType break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } @@ -3147,7 +3147,7 @@ void ETSGen::LoadArrayElement(const ir::AstNode *node, VReg objectReg) } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -3190,7 +3190,7 @@ void ETSGen::StoreArrayElement(const ir::AstNode *node, VReg objectReg, VReg ind } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -3240,7 +3240,7 @@ void ETSGen::LoadTupleElement(const ir::AstNode *node, VReg objectReg) } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -3286,7 +3286,7 @@ void ETSGen::StoreTupleElement(const ir::AstNode *node, VReg objectReg, VReg ind } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -3319,7 +3319,7 @@ void ETSGen::IncrementImmediateRegister(const ir::AstNode *node, VReg reg, const break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } @@ -3466,7 +3466,7 @@ void ETSGen::SetAccumulatorTargetType(const ir::AstNode *node, checker::TypeFlag break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } diff --git a/ets2panda/compiler/core/ETSGen.h b/ets2panda/compiler/core/ETSGen.h index b778962cfe..04c6858835 100644 --- a/ets2panda/compiler/core/ETSGen.h +++ b/ets2panda/compiler/core/ETSGen.h @@ -305,7 +305,7 @@ public: #ifdef PANDA_WITH_ETS Ra().Emit(node, reg); #else - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); #endif // PANDA_WITH_ETS } @@ -314,7 +314,7 @@ public: #ifdef PANDA_WITH_ETS Ra().Emit(node, reg); #else - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); #endif // PANDA_WITH_ETS } @@ -480,7 +480,7 @@ private: #ifdef PANDA_WITH_ETS Sa().Emit(node); #else - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); #endif // PANDA_WITH_ETS } @@ -495,7 +495,7 @@ private: Ra().Emit(node, lhs, rhs); } #else - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); #endif // PANDA_WITH_ETS } diff --git a/ets2panda/compiler/core/ETSemitter.cpp b/ets2panda/compiler/core/ETSemitter.cpp index fdd65ae915..0955afb391 100644 --- a/ets2panda/compiler/core/ETSemitter.cpp +++ b/ets2panda/compiler/core/ETSemitter.cpp @@ -313,7 +313,7 @@ static pandasm::ScalarValue CreateScalarValue(const checker::Type *type, checker type->AsETSObjectType()->AsETSStringType()->GetValue().Mutf8()); } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } @@ -564,7 +564,7 @@ void ETSEmitter::CreateEnumProp(const ir::ClassProperty *prop, pandasm::Field &f auto value = init->AsStringLiteral()->Str().Mutf8(); field.metadata->SetValue(pandasm::ScalarValue::Create(value)); } else { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -644,7 +644,7 @@ void ETSEmitter::ProcessArrayElement(const ir::Expression *elem, std::vectorIsETSArrayType()) { CreateLiteralArrayProp(prop, baseName, field); } else { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } record.fieldList.emplace_back(std::move(field)); } @@ -764,7 +764,7 @@ pandasm::AnnotationElement ETSEmitter::ProcessETSEnumType(std::string &baseName, auto intEnumValue = pandasm::ScalarValue::Create(enumValue); return pandasm::AnnotationElement {baseName, std::make_unique(intEnumValue)}; } - ASSERT(type->IsETSStringEnumType()); + ES2PANDA_ASSERT(type->IsETSStringEnumType()); auto enumValue = initValue->AsStringLiteral()->Str().Mutf8(); auto stringValue = pandasm::ScalarValue::Create(enumValue); return pandasm::AnnotationElement {baseName, std::make_unique(stringValue)}; @@ -804,7 +804,7 @@ pandasm::AnnotationElement ETSEmitter::GenCustomAnnotationElement(const ir::Clas propName, std::make_unique(CreateScalarValue(init->TsType(), typeKind))}; } default: - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } diff --git a/ets2panda/compiler/core/ETSfunction.cpp b/ets2panda/compiler/core/ETSfunction.cpp index f22cb82eed..4edd9d31b2 100644 --- a/ets2panda/compiler/core/ETSfunction.cpp +++ b/ets2panda/compiler/core/ETSfunction.cpp @@ -51,7 +51,7 @@ void ETSFunction::CallImplicitCtor(ETSGen *etsg) auto res = std::find_if(superType->ConstructSignatures().cbegin(), superType->ConstructSignatures().cend(), [](const checker::Signature *sig) { return sig->MinArgCount() == 0; }); if (res == superType->ConstructSignatures().cend()) { - ASSERT(superType->ConstructSignatures().empty()); + ES2PANDA_ASSERT(superType->ConstructSignatures().empty()); return; } auto sig = *res; diff --git a/ets2panda/compiler/core/JSCompiler.cpp b/ets2panda/compiler/core/JSCompiler.cpp index 42bb80d441..b7cb2f00d3 100644 --- a/ets2panda/compiler/core/JSCompiler.cpp +++ b/ets2panda/compiler/core/JSCompiler.cpp @@ -98,7 +98,7 @@ compiler::Literal PropertyMethodKind(const ir::MethodDefinition *propMethod, uti break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } return value; @@ -310,7 +310,7 @@ static void CompilePropertyKind(const ir::MethodDefinition *prop, compiler::VReg break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } @@ -964,7 +964,7 @@ void CompileRemainingPropertyKind(const ir::Property *prop, compiler::VReg objRe break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } diff --git a/ets2panda/compiler/core/JSCompilerUnreachable.cpp b/ets2panda/compiler/core/JSCompilerUnreachable.cpp index cfad289dd2..6fc674be5e 100644 --- a/ets2panda/compiler/core/JSCompilerUnreachable.cpp +++ b/ets2panda/compiler/core/JSCompilerUnreachable.cpp @@ -20,497 +20,497 @@ namespace ark::es2panda::compiler { // from as folder void JSCompiler::Compile([[maybe_unused]] const ir::NamedType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::PrefixAssertionExpression *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::ClassProperty *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::ClassStaticBlock *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::Decorator *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::MethodDefinition *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::Property *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::ScriptFunction *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::SpreadElement *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TemplateElement *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSIndexSignature *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSMethodSignature *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSPropertySignature *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSSignatureDeclaration *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } // from ets folder void JSCompiler::Compile([[maybe_unused]] const ir::ETSModule *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::ETSClassLiteral *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::ETSFunctionType *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::ETSTuple *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::ETSImportDeclaration *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::ETSReExportDeclaration *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::ETSLaunchExpression *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::ETSNewArrayInstanceExpression *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::ETSNewClassInstanceExpression *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::ETSNewMultiDimArrayInstanceExpression *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::ETSPackageDeclaration *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::ETSParameterExpression *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::ETSPrimitiveType *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::ETSStructDeclaration *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::ETSTypeReference *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::ETSTypeReferencePart *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::ETSNullType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::ETSUndefinedType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::ETSNeverType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::ETSStringLiteralType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::ETSUnionType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::ETSWildcardType *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::BlockExpression *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::OpaqueTypeNode *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::BrokenTypeNode *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::OmittedExpression *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::CharLiteral *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::UndefinedLiteral *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::ExportSpecifier *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::ImportDefaultSpecifier *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::ImportNamespaceSpecifier *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::ImportSpecifier *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } // Compile methods for STATEMENTS in alphabetical order void JSCompiler::Compile([[maybe_unused]] const ir::AssertStatement *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::SwitchCaseStatement *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } // from ts folder void JSCompiler::Compile([[maybe_unused]] const ir::TSAnyKeyword *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSArrayType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSAsExpression *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSBigintKeyword *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSBooleanKeyword *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSClassImplements *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSConditionalType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSConstructorType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSEnumDeclaration *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSEnumMember *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSExternalModuleReference *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSFunctionType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSImportEqualsDeclaration *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSImportType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSIndexedAccessType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSInferType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSInterfaceBody *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSInterfaceDeclaration *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSInterfaceHeritage *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSIntersectionType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSLiteralType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSMappedType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSModuleBlock *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSModuleDeclaration *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSNamedTupleMember *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSNeverKeyword *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSNonNullExpression *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSNullKeyword *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSNumberKeyword *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSObjectKeyword *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSParameterProperty *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSParenthesizedType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSQualifiedName *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSStringKeyword *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSThisType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSTupleType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSTypeAliasDeclaration *st) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSTypeAssertion *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSTypeLiteral *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSTypeOperator *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSTypeParameter *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSTypeParameterDeclaration *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSTypeParameterInstantiation *expr) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSTypePredicate *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSTypeQuery *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSTypeReference *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSUndefinedKeyword *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSUnionType *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSUnknownKeyword *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::TSVoidKeyword *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void JSCompiler::Compile([[maybe_unused]] const ir::DummyNode *node) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } // namespace ark::es2panda::compiler diff --git a/ets2panda/compiler/core/JSemitter.cpp b/ets2panda/compiler/core/JSemitter.cpp index d9914fdd4e..8c4925497d 100644 --- a/ets2panda/compiler/core/JSemitter.cpp +++ b/ets2panda/compiler/core/JSemitter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - 2024 Huawei Device Co., Ltd. + * 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 @@ -40,7 +40,7 @@ pandasm::Function *JSFunctionEmitter::GenFunctionSignature() return func; #else - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); #endif } @@ -79,7 +79,7 @@ void JSEmitter::GenAnnotation() GenESAnnotationRecord(); GenESModuleModeRecord(Context()->parserProgram->Kind() == parser::ScriptKind::MODULE); #else - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); #endif } diff --git a/ets2panda/compiler/core/codeGen.cpp b/ets2panda/compiler/core/codeGen.cpp index a3b320e9b7..fd01a1c9f2 100644 --- a/ets2panda/compiler/core/codeGen.cpp +++ b/ets2panda/compiler/core/codeGen.cpp @@ -297,7 +297,7 @@ void CodeGen::SetFirstStmt(const ir::Statement *stmt) noexcept void CodeGen::Unimplemented() { // Unimplemented code path - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } SimpleAllocator &CodeGen::Sa() noexcept diff --git a/ets2panda/compiler/core/compileJob.h b/ets2panda/compiler/core/compileJob.h index bf75a14f18..46e0e901dd 100644 --- a/ets2panda/compiler/core/compileJob.h +++ b/ets2panda/compiler/core/compileJob.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - 2024 Huawei Device Co., Ltd. + * 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 @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_COMPILE_JOB_H #define ES2PANDA_COMPILER_CORE_COMPILE_JOB_H -#include "macros.h" +#include "util/es2pandaMacros.h" #include "compiler/core/programElement.h" #include diff --git a/ets2panda/compiler/core/compileQueue.h b/ets2panda/compiler/core/compileQueue.h index 6e01f85c0f..7bc948033b 100644 --- a/ets2panda/compiler/core/compileQueue.h +++ b/ets2panda/compiler/core/compileQueue.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_COMPILE_QUEUE_H #define ES2PANDA_COMPILER_CORE_COMPILE_QUEUE_H -#include "macros.h" +#include "util/es2pandaMacros.h" #include "os/thread.h" #include "es2panda.h" #include "compiler/core/compileJob.h" diff --git a/ets2panda/compiler/core/compilerImpl.cpp b/ets2panda/compiler/core/compilerImpl.cpp index d09918f019..22eee1a0c7 100644 --- a/ets2panda/compiler/core/compilerImpl.cpp +++ b/ets2panda/compiler/core/compilerImpl.cpp @@ -301,7 +301,7 @@ pandasm::Program *CompilerImpl::Compile(const CompilationUnit &unit) this); } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); return nullptr; } } diff --git a/ets2panda/compiler/core/dynamicContext.cpp b/ets2panda/compiler/core/dynamicContext.cpp index 6216e4031f..2cb7dab7ba 100644 --- a/ets2panda/compiler/core/dynamicContext.cpp +++ b/ets2panda/compiler/core/dynamicContext.cpp @@ -282,7 +282,7 @@ void ETSTryContext::EmitFinalizerInsertion(ETSGen *etsg, compiler::LabelPair lab compiler::Label *target = etsg->ControlFlowChangeContinue(statement->AsContinueStatement()->Ident()); etsg->Branch(tryStmt_, target); } else { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } diff --git a/ets2panda/compiler/core/emitter.cpp b/ets2panda/compiler/core/emitter.cpp index dde7e2cba2..bf0978abe2 100644 --- a/ets2panda/compiler/core/emitter.cpp +++ b/ets2panda/compiler/core/emitter.cpp @@ -28,7 +28,7 @@ #include "parser/program/program.h" #include "checker/types/type.h" #include "generated/isa.h" -#include "macros.h" +#include "util/es2pandaMacros.h" #include "public/public.h" #include @@ -68,7 +68,7 @@ static LiteralPair TransformMethodLiterals(const compiler::Literal *literal) break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); break; } } @@ -165,7 +165,7 @@ static Format MatchFormat(const IRNode *node, const Formats &formats) } } - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); return *iter; } @@ -435,12 +435,12 @@ static void UpdateLiteralBufferId([[maybe_unused]] ark::pandasm::Ins *ins, [[may break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); break; } } #else - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); #endif } diff --git a/ets2panda/compiler/core/labelPair.h b/ets2panda/compiler/core/labelPair.h index 76fe1b4798..dc09dbdaa1 100644 --- a/ets2panda/compiler/core/labelPair.h +++ b/ets2panda/compiler/core/labelPair.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * 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 @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_LABEL_PAIR_H #define ES2PANDA_COMPILER_CORE_LABEL_PAIR_H -#include "macros.h" +#include "util/es2pandaMacros.h" #include "ir/irnode.h" namespace ark::es2panda::compiler { diff --git a/ets2panda/compiler/core/pandagen.cpp b/ets2panda/compiler/core/pandagen.cpp index 59d6fb8b1a..85ab16b545 100644 --- a/ets2panda/compiler/core/pandagen.cpp +++ b/ets2panda/compiler/core/pandagen.cpp @@ -49,33 +49,33 @@ public: template explicit EcmaDisabled(const ir::AstNode *node, [[maybe_unused]] Args &&...args) : IRNode(node) { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } Formats GetFormats() const override { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } size_t Registers([[maybe_unused]] std::array *regs) override { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } size_t Registers([[maybe_unused]] std::array *regs) const override { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } size_t OutRegisters([[maybe_unused]] std::array *regs) const override { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void Transform([[maybe_unused]] pandasm::Ins *ins, [[maybe_unused]] ProgramElement *programElement, [[maybe_unused]] uint32_t totalRegs) const override { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } }; @@ -411,7 +411,7 @@ void PandaGen::LoadConst(const ir::AstNode *node, Constant id) break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } @@ -674,7 +674,7 @@ void PandaGen::Condition(const ir::AstNode *node, lexer::TokenType op, VReg lhs, break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -714,7 +714,7 @@ void PandaGen::Unary(const ir::AstNode *node, lexer::TokenType op, VReg operand) break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } @@ -783,7 +783,7 @@ void PandaGen::Binary(const ir::AstNode *node, lexer::TokenType op, VReg lhs) case lexer::TokenType::PUNCTUATOR_LOGICAL_NULLISH_EQUAL: return Unimplemented(); default: - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } diff --git a/ets2panda/compiler/core/pandagen.h b/ets2panda/compiler/core/pandagen.h index 6cec50e0b2..ba4176d6d3 100644 --- a/ets2panda/compiler/core/pandagen.h +++ b/ets2panda/compiler/core/pandagen.h @@ -25,7 +25,7 @@ #include "compiler/core/regScope.h" #include "ir/irnode.h" #include "generated/tokenType.h" -#include "macros.h" +#include "util/es2pandaMacros.h" #include diff --git a/ets2panda/compiler/core/programElement.h b/ets2panda/compiler/core/programElement.h index 54f69868c5..59e31f6525 100644 --- a/ets2panda/compiler/core/programElement.h +++ b/ets2panda/compiler/core/programElement.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - 2023 Huawei Device Co., Ltd. + * 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 @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_PROGRAM_ELEMENT_H #define ES2PANDA_COMPILER_CORE_PROGRAM_ELEMENT_H -#include "macros.h" +#include "util/es2pandaMacros.h" #include "compiler/base/literals.h" namespace ark::pandasm { diff --git a/ets2panda/compiler/core/regAllocator.h b/ets2panda/compiler/core/regAllocator.h index febac89d37..2f48a9a674 100644 --- a/ets2panda/compiler/core/regAllocator.h +++ b/ets2panda/compiler/core/regAllocator.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - 2023 Huawei Device Co., Ltd. + * 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 @@ -18,7 +18,7 @@ #include "generated/isa.h" #include "compiler/core/regSpiller.h" -#include "macros.h" +#include "util/es2pandaMacros.h" namespace ark::es2panda::ir { class AstNode; diff --git a/ets2panda/compiler/core/regScope.h b/ets2panda/compiler/core/regScope.h index 55b102c6f1..40e5e48ec7 100644 --- a/ets2panda/compiler/core/regScope.h +++ b/ets2panda/compiler/core/regScope.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_REG_SCOPE_H #define ES2PANDA_COMPILER_CORE_REG_SCOPE_H -#include "macros.h" +#include "util/es2pandaMacros.h" #include "varbinder/scope.h" #include "vReg.h" diff --git a/ets2panda/compiler/core/targetTypeContext.h b/ets2panda/compiler/core/targetTypeContext.h index 3b3d2fe862..14466b33ff 100644 --- a/ets2panda/compiler/core/targetTypeContext.h +++ b/ets2panda/compiler/core/targetTypeContext.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - 2023 Huawei Device Co., Ltd. + * 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 @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_TARGET_TYPE_CONTEXT_H #define ES2PANDA_COMPILER_CORE_TARGET_TYPE_CONTEXT_H -#include "macros.h" +#include "util/es2pandaMacros.h" namespace ark::es2panda::checker { class Type; diff --git a/ets2panda/compiler/core/vReg.h b/ets2panda/compiler/core/vReg.h index 14bbc4af93..d8a8e76377 100644 --- a/ets2panda/compiler/core/vReg.h +++ b/ets2panda/compiler/core/vReg.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - 2023 Huawei Device Co., Ltd. + * 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 @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_VREG_H #define ES2PANDA_COMPILER_CORE_VREG_H -#include "macros.h" +#include "util/es2pandaMacros.h" #include diff --git a/ets2panda/compiler/debugger/debuginfoDumper.cpp b/ets2panda/compiler/debugger/debuginfoDumper.cpp index d48d65210c..f51e14e13e 100644 --- a/ets2panda/compiler/debugger/debuginfoDumper.cpp +++ b/ets2panda/compiler/debugger/debuginfoDumper.cpp @@ -15,7 +15,7 @@ #include "debuginfoDumper.h" -#include "macros.h" +#include "util/es2pandaMacros.h" #include #include diff --git a/ets2panda/compiler/debugger/debuginfoDumper.h b/ets2panda/compiler/debugger/debuginfoDumper.h index bc94f6844b..9ee90387c4 100644 --- a/ets2panda/compiler/debugger/debuginfoDumper.h +++ b/ets2panda/compiler/debugger/debuginfoDumper.h @@ -18,7 +18,7 @@ #include "assembly-ins.h" #include "assembly-program.h" -#include "macros.h" +#include "util/es2pandaMacros.h" namespace ark::es2panda::debuginfo { diff --git a/ets2panda/compiler/function/functionBuilder.h b/ets2panda/compiler/function/functionBuilder.h index 53051197b2..bd8f029ad9 100644 --- a/ets2panda/compiler/function/functionBuilder.h +++ b/ets2panda/compiler/function/functionBuilder.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - 2023 Huawei Device Co., Ltd. + * 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 @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_FUNCTION_FUNCTION_BUILDER_H #define ES2PANDA_COMPILER_FUNCTION_FUNCTION_BUILDER_H -#include "macros.h" +#include "util/es2pandaMacros.h" #include "ir/irnode.h" namespace ark::es2panda::ir { @@ -59,7 +59,7 @@ public: virtual void Yield([[maybe_unused]] const ir::AstNode *node) { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); }; protected: diff --git a/ets2panda/compiler/lowering/ets/ambientLowering.cpp b/ets2panda/compiler/lowering/ets/ambientLowering.cpp index b0ddba96f6..fe653a07f2 100644 --- a/ets2panda/compiler/lowering/ets/ambientLowering.cpp +++ b/ets2panda/compiler/lowering/ets/ambientLowering.cpp @@ -69,7 +69,7 @@ ir::MethodDefinition *CreateMethodFunctionDefinition(ir::DummyNode *node, public sourceCode = "$_set(" + std::string(indexName) + " : number, " + "value : " + std::string(returnType->Name()) + " ) : void"; } else { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } auto methodDefinition = parser->CreateFormattedClassMethodDefinition(sourceCode); diff --git a/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp b/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp index 512fec1e71..20251e50fe 100644 --- a/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp +++ b/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp @@ -96,14 +96,14 @@ static TargetType GetOperand(ir::Literal *const node) if (numNode->Number().IsDouble()) { return numNode->Number().GetDouble(); } - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } if (node->IsCharLiteral()) { return node->AsCharLiteral()->Char(); } - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } static TypeRank GetTypeRank(ir::Literal *const literal) @@ -124,7 +124,7 @@ static TypeRank GetTypeRank(ir::Literal *const literal) } return TypeRank::FLOAT; } - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } static bool TestLiteralIsNotZero(ir::Literal *literal) @@ -147,7 +147,7 @@ static bool TestLiteralIsNotZero(ir::Literal *literal) if (number.IsFloat()) { return number.GetFloat() != 0; } - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } ir::AstNode *ConstantExpressionLowering::FoldTernaryConstant(ir::ConditionalExpression *cond) @@ -201,7 +201,7 @@ bool ConstantExpressionLowering::PerformRelationOperator(InputType left, InputTy return left != right; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } @@ -233,7 +233,7 @@ bool ConstantExpressionLowering::HandleRelationOperator(ir::Literal *left, ir::L return PerformRelationOperator(GetOperand(left), GetOperand(right), opType); } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } @@ -254,7 +254,7 @@ bool ConstantExpressionLowering::HandleBitwiseLogicalOperator(ir::Literal *left, return (static_cast(leftValue) | static_cast(rightValue)) != 0U; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } @@ -276,7 +276,7 @@ ir::AstNode *ConstantExpressionLowering::HandleLogicalOperator(ir::BinaryExpress } else if (left->IsNullLiteral() || left->IsUndefinedLiteral()) { leftBoolValue = false; } else { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } switch (opType) { @@ -297,7 +297,7 @@ ir::AstNode *ConstantExpressionLowering::HandleLogicalOperator(ir::BinaryExpress break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -393,7 +393,7 @@ IntegerType ConstantExpressionLowering::PerformBitwiseArithmetic(IntegerType lef break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -419,7 +419,7 @@ lexer::Number ConstantExpressionLowering::HandleBitwiseOperator(TargetType leftN return lexer::Number(PerformBitwiseArithmetic(leftNum, rightNum, operationType)); } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } @@ -459,7 +459,7 @@ TargetType ConstantExpressionLowering::HandleArithmeticOperation(TargetType left } } default: - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -529,7 +529,7 @@ ir::AstNode *ConstantExpressionLowering::FoldBinaryNumericConstant(ir::BinaryExp return FoldBinaryNumericConstantHelper(expr, targetRank); } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } @@ -579,7 +579,7 @@ lexer::Number ConstantExpressionLowering::HandleBitwiseNegate(InputType value, T return lexer::Number(static_cast(~static_cast(value))); } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } @@ -605,7 +605,7 @@ ir::AstNode *ConstantExpressionLowering::FoldUnaryNumericConstantHelper(ir::Unar break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -635,7 +635,7 @@ ir::AstNode *ConstantExpressionLowering::FoldUnaryNumericConstant(ir::UnaryExpre return FoldUnaryNumericConstantHelper(unary, literal, rank); } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } @@ -654,7 +654,7 @@ ir::AstNode *ConstantExpressionLowering::FoldUnaryBooleanConstant(ir::UnaryExpre result = !value; } } else { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } auto resNode = util::NodeAllocator::Alloc(context_->allocator, result); diff --git a/ets2panda/compiler/lowering/ets/defaultParametersInConstructorLowering.cpp b/ets2panda/compiler/lowering/ets/defaultParametersInConstructorLowering.cpp index e1e390025c..adbfec0e62 100644 --- a/ets2panda/compiler/lowering/ets/defaultParametersInConstructorLowering.cpp +++ b/ets2panda/compiler/lowering/ets/defaultParametersInConstructorLowering.cpp @@ -217,7 +217,7 @@ static void ClearOptionalParameters(public_lib::Context *ctx, ir::ScriptFunction false, allocator); params[idx]->SetParent(function); } - ASSERT(!params[idx]->AsETSParameterExpression()->IsOptional()); + ES2PANDA_ASSERT(!params[idx]->AsETSParameterExpression()->IsOptional()); } } @@ -250,7 +250,7 @@ static void ProcessGlobalFunctionDefinition(ir::MethodDefinition *method, public auto param = params[i]->AsETSParameterExpression(); ir::Expression *init; if (param->Initializer() == nullptr) { - ASSERT(param->IsOptional()); + ES2PANDA_ASSERT(param->IsOptional()); init = allocator->New(); } else if (param->Initializer()->IsArrowFunctionExpression()) { init = param->Initializer(); diff --git a/ets2panda/compiler/lowering/ets/defaultParametersLowering.cpp b/ets2panda/compiler/lowering/ets/defaultParametersLowering.cpp index 39608cee0e..d87fc777fd 100644 --- a/ets2panda/compiler/lowering/ets/defaultParametersLowering.cpp +++ b/ets2panda/compiler/lowering/ets/defaultParametersLowering.cpp @@ -31,7 +31,7 @@ static ir::Statement *TransformInitializer(ArenaAllocator *allocator, parser::ET typeAnnotation->SetParent(param->Ident()); param->SetInitializer(nullptr); - ASSERT(param->IsOptional()); + ES2PANDA_ASSERT(param->IsOptional()); return parser->CreateFormattedStatement("let @@I1: @@T2 = (@@I3 !== undefined) ? @@I4 : (@@E5 as @@T6)", ident, typeAnnotation->Clone(allocator, nullptr), param->Ident()->Name(), @@ -45,14 +45,14 @@ static void TransformFunction(public_lib::Context *ctx, ir::ScriptFunction *func for (auto *param : params) { if (!param->IsETSParameterExpression()) { // #23134 - ASSERT(ctx->diagnosticEngine->IsAnyError()); + ES2PANDA_ASSERT(ctx->diagnosticEngine->IsAnyError()); continue; } if (param->AsETSParameterExpression()->Initializer() == nullptr) { continue; } if (param->AsETSParameterExpression()->TypeAnnotation() == nullptr) { // #23134 - ASSERT(ctx->diagnosticEngine->IsAnyError()); + ES2PANDA_ASSERT(ctx->diagnosticEngine->IsAnyError()); continue; } defaultParams.push_back(param->AsETSParameterExpression()); @@ -62,7 +62,7 @@ static void TransformFunction(public_lib::Context *ctx, ir::ScriptFunction *func return; } if (!function->HasBody()) { // #23134 - ASSERT(ctx->diagnosticEngine->IsAnyError()); + ES2PANDA_ASSERT(ctx->diagnosticEngine->IsAnyError()); return; } auto const body = function->Body()->AsBlockStatement(); @@ -103,7 +103,7 @@ bool DefaultParametersLowering::PostconditionForModule([[maybe_unused]] public_l } for (auto p : node->AsScriptFunction()->Params()) { if (!p->IsETSParameterExpression()) { // #23134 - ASSERT(ctx->diagnosticEngine->IsAnyError()); + ES2PANDA_ASSERT(ctx->diagnosticEngine->IsAnyError()); (void)ctx; continue; } diff --git a/ets2panda/compiler/lowering/ets/enumLowering.cpp b/ets2panda/compiler/lowering/ets/enumLowering.cpp index 82dfb3ed0b..98a79a1818 100644 --- a/ets2panda/compiler/lowering/ets/enumLowering.cpp +++ b/ets2panda/compiler/lowering/ets/enumLowering.cpp @@ -343,7 +343,7 @@ void EnumLoweringPhase::ProcessEnumClassDeclaration(ir::TSEnumDeclaration *const InitScopesPhaseETS::RunExternalNode(enumClassDecl, varbinder_); var = varbinder_->GetScope()->FindLocal(ident->Name(), varbinder::ResolveBindingOptions::DECLARATION); } else { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } if (var != nullptr) { // Although it enum was transformed to class, it should still be regarded as enum. diff --git a/ets2panda/compiler/lowering/ets/enumPostCheckLowering.cpp b/ets2panda/compiler/lowering/ets/enumPostCheckLowering.cpp index cfbcab4cfb..2e80b18777 100644 --- a/ets2panda/compiler/lowering/ets/enumPostCheckLowering.cpp +++ b/ets2panda/compiler/lowering/ets/enumPostCheckLowering.cpp @@ -40,7 +40,7 @@ static ir::ClassDeclaration *FindEnclosingClass(ir::AstNode *ast) return curr->AsClassDeclaration(); } } - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } static std::string TypeToString(checker::Type *type) @@ -82,7 +82,7 @@ static bool IsValidEnumCasting(checker::Type *type, EnumCastType castType) return true; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } @@ -282,7 +282,7 @@ void EnumPostCheckLoweringPhase::CreateStatementForUnionConstituentType(EnumCast break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } diff --git a/ets2panda/compiler/lowering/ets/lambdaLowering.cpp b/ets2panda/compiler/lowering/ets/lambdaLowering.cpp index 6fbddca278..3e2d877307 100644 --- a/ets2panda/compiler/lowering/ets/lambdaLowering.cpp +++ b/ets2panda/compiler/lowering/ets/lambdaLowering.cpp @@ -59,7 +59,7 @@ static std::pair FindEnclosingClas function = curr->AsScriptFunction(); } } - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } static bool CheckIfNeedThis(ir::ArrowFunctionExpression *lambda, checker::ETSChecker *checker) @@ -685,7 +685,7 @@ static void CreateLambdaClassInvokeMethod(public_lib::Context *ctx, LambdaInfo c auto *invokeMethod = util::NodeAllocator::ForceSetParent( allocator, ir::MethodDefinitionKind::METHOD, invokeIdClone, funcExpr, ir::ModifierFlags::NONE, allocator, false); - ASSERT(!invokeMethod->IsStatic()); + ES2PANDA_ASSERT(!invokeMethod->IsStatic()); lciInfo->classDefinition->Body().push_back(invokeMethod); invokeMethod->SetParent(lciInfo->classDefinition); @@ -730,10 +730,10 @@ static void CorrectTheTrueThisForExtensionLambda(public_lib::Context *ctx, ir::C ->AsFunctionExpression() ->Function(); if (!scriptFunc->Signature()->HasSignatureFlag(checker::SignatureFlags::EXTENSION_FUNCTION)) { - ASSERT(!scriptFunc->IsExtensionMethod()); + ES2PANDA_ASSERT(!scriptFunc->IsExtensionMethod()); continue; } - ASSERT(scriptFunc->IsExtensionMethod()); + ES2PANDA_ASSERT(scriptFunc->IsExtensionMethod()); auto *functionScope = scriptFunc->Scope(); auto *functionParamScope = scriptFunc->Scope()->ParamScope(); auto *theTrueThisVar = functionParamScope->Params()[0]; @@ -944,7 +944,7 @@ static ir::ArrowFunctionExpression *CreateWrappingLambda(public_lib::Context *ct { auto *allocator = ctx->allocator; auto *varBinder = ctx->checker->VarBinder()->AsETSBinder(); - ASSERT(funcRef->TsType()->IsETSArrowType()); + ES2PANDA_ASSERT(funcRef->TsType()->IsETSArrowType()); auto signature = funcRef->TsType()->AsETSFunctionType()->ArrowSignature(); auto *parent = funcRef->Parent(); @@ -1014,7 +1014,7 @@ static ir::AstNode *ConvertFunctionReference(public_lib::Context *ctx, ir::Expre info.callReceiver = funcRef->AsMemberExpression()->Object(); } - ASSERT(funcRef->TsType()->IsETSArrowType()); + ES2PANDA_ASSERT(funcRef->TsType()->IsETSArrowType()); auto *lambdaClass = CreateLambdaClass(ctx, funcRef->TsType()->AsETSFunctionType(), method, &info); auto *constructorCall = CreateConstructorCall(ctx, funcRef, lambdaClass, &info); return constructorCall; @@ -1059,7 +1059,7 @@ static ir::AstNode *InsertInvokeCall(public_lib::Context *ctx, ir::CallExpressio util::UString {checker::FunctionalInterfaceInvokeName(arity, hasRestParam), allocator}.View(); auto *prop = ifaceType->GetProperty(invokeMethodName, checker::PropertySearchFlags::SEARCH_INSTANCE_METHOD | checker::PropertySearchFlags::SEARCH_IN_INTERFACES); - ASSERT(prop != nullptr); + ES2PANDA_ASSERT(prop != nullptr); auto *invoke0Id = allocator->New(invokeMethodName, allocator); invoke0Id->SetTsType(prop->TsType()); invoke0Id->SetVariable(prop); diff --git a/ets2panda/compiler/lowering/ets/localClassLowering.cpp b/ets2panda/compiler/lowering/ets/localClassLowering.cpp index e72b4b4aad..5153b0be11 100644 --- a/ets2panda/compiler/lowering/ets/localClassLowering.cpp +++ b/ets2panda/compiler/lowering/ets/localClassLowering.cpp @@ -269,7 +269,7 @@ bool LocalClassConstructionPhase::PerformForModule(public_lib::Context *ctx, par auto *newExpr = ast->AsETSNewClassInstanceExpression(); checker::Type *calleeType = newExpr->GetTypeRef()->Check(checker); - ASSERT(calleeType->IsETSObjectType()); + ES2PANDA_ASSERT(calleeType->IsETSObjectType()); auto *calleeObj = calleeType->AsETSObjectType(); if (!calleeObj->GetDeclNode()->IsClassDefinition()) { return; diff --git a/ets2panda/compiler/lowering/ets/objectIterator.cpp b/ets2panda/compiler/lowering/ets/objectIterator.cpp index 531cbf3ef1..9ea6bcb123 100644 --- a/ets2panda/compiler/lowering/ets/objectIterator.cpp +++ b/ets2panda/compiler/lowering/ets/objectIterator.cpp @@ -114,7 +114,7 @@ ir::Statement *ObjectIteratorLowering::ProcessObjectIterator(parser::ETSParser * declared = false; loopVariableName = left->AsIdentifier()->Name().Mutf8(); } else { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } whileStatement += loopVariableName + " = @@I6.value!; "; diff --git a/ets2panda/compiler/lowering/ets/opAssignment.cpp b/ets2panda/compiler/lowering/ets/opAssignment.cpp index dd82fcd5df..ba8bbc3d6b 100644 --- a/ets2panda/compiler/lowering/ets/opAssignment.cpp +++ b/ets2panda/compiler/lowering/ets/opAssignment.cpp @@ -71,7 +71,7 @@ static lexer::TokenType CombinedOpToOp(const lexer::TokenType combinedOp) return conv.to; } } - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void AdjustBoxingUnboxingFlags(ir::Expression *loweringResult, const ir::Expression *oldExpr) @@ -85,7 +85,7 @@ void AdjustBoxingUnboxingFlags(ir::Expression *loweringResult, const ir::Express exprToProcess = statement->AsExpressionStatement()->GetExpression(); } } else { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } // NOTE: gogabr. make sure that the checker never puts both a boxing and an unboxing flag on the same node. @@ -245,7 +245,7 @@ static ir::Expression *ConstructOpAssignmentResult(public_lib::Context *ctx, ir: retVal = GenerateStringForLoweredAssignment(opEqual, left->AsMemberExpression(), allocator, parser, {right, exprType}); } else { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } return retVal; diff --git a/ets2panda/compiler/lowering/ets/optionalArgumentsLowering.cpp b/ets2panda/compiler/lowering/ets/optionalArgumentsLowering.cpp index dafda7c642..00d6d3f6a5 100644 --- a/ets2panda/compiler/lowering/ets/optionalArgumentsLowering.cpp +++ b/ets2panda/compiler/lowering/ets/optionalArgumentsLowering.cpp @@ -24,10 +24,10 @@ static void TransformArguments(public_lib::Context *ctx, ir::Expression *callLik ArenaVector &arguments) { if (signature->ArgCount() < arguments.size()) { - ASSERT(signature->HasRestParameter()); + ES2PANDA_ASSERT(signature->HasRestParameter()); return; } - ASSERT(signature->ArgCount() >= signature->MinArgCount()); + ES2PANDA_ASSERT(signature->ArgCount() >= signature->MinArgCount()); if (arguments.size() < signature->MinArgCount()) { // #22952: workaround for dynamic types auto callee = callLike->IsCallExpression() ? callLike->AsCallExpression()->Callee() : callLike->AsETSNewClassInstanceExpression()->GetTypeRef(); @@ -35,7 +35,7 @@ static void TransformArguments(public_lib::Context *ctx, ir::Expression *callLik return; } } - ASSERT(arguments.size() >= signature->MinArgCount()); + ES2PANDA_ASSERT(arguments.size() >= signature->MinArgCount()); auto const checker = ctx->checker->AsETSChecker(); auto const allocator = ctx->allocator; diff --git a/ets2panda/compiler/lowering/ets/optionalLowering.cpp b/ets2panda/compiler/lowering/ets/optionalLowering.cpp index dd6093db5f..f8049254ca 100644 --- a/ets2panda/compiler/lowering/ets/optionalLowering.cpp +++ b/ets2panda/compiler/lowering/ets/optionalLowering.cpp @@ -105,7 +105,7 @@ static ir::Expression *FindOptionalInChain(ir::Expression *expr) if (expr->IsTSNonNullExpression()) { return FindOptionalInChain(expr->AsTSNonNullExpression()->Expr()); } - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } static ir::AstNode *LowerChain(public_lib::Context *ctx, ir::ChainExpression *const chain) @@ -117,7 +117,7 @@ static ir::AstNode *LowerChain(public_lib::Context *ctx, ir::ChainExpression *co if (optional->IsCallExpression()) { return LowerExpression(ctx, optional->AsCallExpression(), chain); } - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } bool OptionalLowering::PerformForModule(public_lib::Context *ctx, parser::Program *program) diff --git a/ets2panda/compiler/lowering/ets/recordLowering.cpp b/ets2panda/compiler/lowering/ets/recordLowering.cpp index 8644401aac..3faa6a83d1 100644 --- a/ets2panda/compiler/lowering/ets/recordLowering.cpp +++ b/ets2panda/compiler/lowering/ets/recordLowering.cpp @@ -58,7 +58,7 @@ RecordLowering::KeyType RecordLowering::TypeToKey(checker::Type *type) const if (type->IsETSStringType()) { return type->AsETSStringType()->GetValue(); } - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); return {}; } @@ -107,7 +107,7 @@ void RecordLowering::CheckDuplicateKey(KeySetType &keySet, ir::ObjectExpression break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); break; } } @@ -161,7 +161,7 @@ ir::Expression *RecordLowering::UpdateObjectExpression(ir::ObjectExpression *exp return expr; } - ASSERT(expr->TsType() != nullptr); + ES2PANDA_ASSERT(expr->TsType() != nullptr); std::stringstream ss; expr->TsType()->ToAssemblerType(ss); if (!(ss.str() == "escompat.Record" || ss.str() == "escompat.Map")) { diff --git a/ets2panda/compiler/lowering/ets/spreadLowering.cpp b/ets2panda/compiler/lowering/ets/spreadLowering.cpp index c2aadf1f9a..51e521c13e 100644 --- a/ets2panda/compiler/lowering/ets/spreadLowering.cpp +++ b/ets2panda/compiler/lowering/ets/spreadLowering.cpp @@ -179,7 +179,7 @@ static std::vector CreateElementsAssignForTupleElements(public_ auto *const newArrayId = newArrayAndIndex[0]; auto *const newArrayIndexId = newArrayAndIndex[1]; - ASSERT(spId->TsType()->IsETSTupleType()); + ES2PANDA_ASSERT(spId->TsType()->IsETSTupleType()); const auto *const spreadType = spId->TsType()->AsETSTupleType(); std::vector tupleAssignmentStatements {}; diff --git a/ets2panda/compiler/lowering/ets/topLevelStmts/importExportDecls.cpp b/ets2panda/compiler/lowering/ets/topLevelStmts/importExportDecls.cpp index 144b540ec2..fef9cb106c 100644 --- a/ets2panda/compiler/lowering/ets/topLevelStmts/importExportDecls.cpp +++ b/ets2panda/compiler/lowering/ets/topLevelStmts/importExportDecls.cpp @@ -137,7 +137,7 @@ void ImportExportDecls::HandleSelectiveExportWithAlias(util::StringView original ir::AstNode *field = fieldItem->second; if (field->IsVariableDeclaration()) { variableDeclarator = field->AsVariableDeclaration()->GetDeclaratorByName(originalFieldName); - ASSERT(variableDeclarator != nullptr); + ES2PANDA_ASSERT(variableDeclarator != nullptr); } if (variableDeclarator != nullptr) { diff --git a/ets2panda/compiler/lowering/ets/unionLowering.cpp b/ets2panda/compiler/lowering/ets/unionLowering.cpp index 6df33d8f61..68bf807f02 100644 --- a/ets2panda/compiler/lowering/ets/unionLowering.cpp +++ b/ets2panda/compiler/lowering/ets/unionLowering.cpp @@ -115,8 +115,8 @@ static void HandleUnionPropertyAccess(checker::ETSChecker *checker, varbinder::V } [[maybe_unused]] auto const *const parent = expr->Parent(); - ASSERT(!(parent->IsCallExpression() && parent->AsCallExpression()->Callee() == expr && - !parent->AsCallExpression()->Signature()->HasFunction())); + ES2PANDA_ASSERT(!(parent->IsCallExpression() && parent->AsCallExpression()->Callee() == expr && + !parent->AsCallExpression()->Signature()->HasFunction())); expr->SetPropVar( CreateNamedAccessProperty(checker, vbind, expr->TsType(), expr->Property()->AsIdentifier()->Name())); ES2PANDA_ASSERT(expr->PropVar() != nullptr); diff --git a/ets2panda/compiler/lowering/phase.cpp b/ets2panda/compiler/lowering/phase.cpp index e64cef8377..b4a995a5e7 100644 --- a/ets2panda/compiler/lowering/phase.cpp +++ b/ets2panda/compiler/lowering/phase.cpp @@ -202,7 +202,7 @@ std::vector GetPhaseList(ScriptExtension ext) case ScriptExtension::JS: return GetJSPhaseList(); default: - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } diff --git a/ets2panda/compiler/lowering/scopesInit/scopesInitPhase.cpp b/ets2panda/compiler/lowering/scopesInit/scopesInitPhase.cpp index 95cf5790c4..643b6325cc 100644 --- a/ets2panda/compiler/lowering/scopesInit/scopesInitPhase.cpp +++ b/ets2panda/compiler/lowering/scopesInit/scopesInitPhase.cpp @@ -493,7 +493,7 @@ std::tuple ScopesInitPhase::AddOrGetVa case ir::VariableDeclaratorFlag::CONST: return VarBinder()->NewVarDecl(id->Start(), name); default: - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -625,7 +625,7 @@ void ScopeInitTyped::VisitTSEnumMember(ir::TSEnumMember *enumMember) } else if (key->IsStringLiteral()) { name = key->AsStringLiteral()->Str(); } else { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } if (auto *decl = AddOrGetDecl(VarBinder(), name, enumMember, key->Start(), name); decl != nullptr) { diff --git a/ets2panda/compiler/templates/signatures.h.erb b/ets2panda/compiler/templates/signatures.h.erb index 9344b17585..8f09ce2292 100644 --- a/ets2panda/compiler/templates/signatures.h.erb +++ b/ets2panda/compiler/templates/signatures.h.erb @@ -83,7 +83,7 @@ public: return <%= data.dynamic_class %>; } % end - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } static std::string_view CallClass(Language lang) @@ -94,7 +94,7 @@ public: return <%= data.call_class.name %>; } % end - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } static std::string_view InitCallClassBuiltin(Language lang) @@ -105,7 +105,7 @@ public: return <%= data.call_class.init_builtin %>; } % end - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } static std::string_view NewClass(Language lang) @@ -116,7 +116,7 @@ public: return <%= data.new_class.name %>; } % end - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } static std::string_view InitNewClassBuiltin(Language lang) @@ -127,7 +127,7 @@ public: return <%= data.new_class.init_builtin %>; } % end - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } static std::string_view LoadModuleBuiltin(Language lang) @@ -138,7 +138,7 @@ public: return <%= data.module_class.load_builtin %>; } % end - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } static std::optional LanguageFromType(std::string_view assemblerName) @@ -159,7 +159,7 @@ public: return <%= data.builtins.get_undefined %>; } % end - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } % def generate(attr, pref) @@ -181,7 +181,7 @@ public: % res += " return #{builtin};\n" % res += " }\n" % end -% res += " UNREACHABLE();\n" +% res += " ES2PANDA_UNREACHABLE();\n" % res += " }" % end % res diff --git a/ets2panda/declgen_ets2ts/declgenEts2Ts.cpp b/ets2panda/declgen_ets2ts/declgenEts2Ts.cpp index dee69ef4fc..a66d8f472e 100644 --- a/ets2panda/declgen_ets2ts/declgenEts2Ts.cpp +++ b/ets2panda/declgen_ets2ts/declgenEts2Ts.cpp @@ -177,7 +177,7 @@ void TSDeclGen::LogError(const diagnostic::DiagnosticKind &kind, const util::Dia void TSDeclGen::LogWarning(const diagnostic::DiagnosticKind &kind, const util::DiagnosticMessageParams ¶ms = {}, const lexer::SourcePosition &pos = lexer::SourcePosition()) { - ASSERT(kind.Type() == util::DiagnosticType::DECLGEN_ETS2TS_WARNING); + ES2PANDA_ASSERT(kind.Type() == util::DiagnosticType::DECLGEN_ETS2TS_WARNING); LogError(kind, params, pos); } @@ -1069,7 +1069,7 @@ void TSDeclGen::GenClassDeclaration(const ir::ClassDeclaration *classDecl) CloseClassBlock(true); } if (classNode_.hasNestedClass || state_.inNamespace) { - ASSERT(classNode_.indentLevel != static_cast(-1)); + ES2PANDA_ASSERT(classNode_.indentLevel != static_cast(-1)); CloseClassBlock(false); } } diff --git a/ets2panda/es2panda.h b/ets2panda/es2panda.h index 32cf5fa4d1..bd18a2294f 100644 --- a/ets2panda/es2panda.h +++ b/ets2panda/es2panda.h @@ -16,11 +16,11 @@ #ifndef ES2PANDA_PUBLIC_H #define ES2PANDA_PUBLIC_H -#include "macros.h" -#include "util/arktsconfig.h" +#include "util/es2pandaMacros.h" #include "util/plugin.h" #include "util/diagnostic.h" #include "generated/options.h" +#include "util/language.h" namespace ark::pandasm { struct Program; @@ -68,9 +68,8 @@ inline Language ToLanguage(ScriptExtension ext) case ScriptExtension::STS: return Language(Language::Id::ETS); default: - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } - UNREACHABLE(); } struct SourceFile { diff --git a/ets2panda/evaluate/helpers.cpp b/ets2panda/evaluate/helpers.cpp index 21a2f12c83..210e57abe7 100644 --- a/ets2panda/evaluate/helpers.cpp +++ b/ets2panda/evaluate/helpers.cpp @@ -66,7 +66,7 @@ ir::TypeNode *PrimitiveToTypeNode(panda_file::Type::TypeId typeId, checker::ETSC irType = ir::PrimitiveType::DOUBLE; break; default: - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } return checker->AllocNode(irType, checker->Allocator()); @@ -226,7 +226,7 @@ static std::optional ReferenceToName(std::string_view typeSignature return arrayType; } default: - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } return {}; } diff --git a/ets2panda/evaluate/helpers.h b/ets2panda/evaluate/helpers.h index 254eb09c36..dd4766d19c 100644 --- a/ets2panda/evaluate/helpers.h +++ b/ets2panda/evaluate/helpers.h @@ -107,7 +107,7 @@ static inline constexpr std::string_view DEBUGGER_API_CLASS_NAME = "DebuggerAPI" /* CC-OFFNXT(G.PRE.05) function gen */ \ return #TYPE_NAME_BASE "Object"; \ default: \ - UNREACHABLE(); \ + ES2PANDA_UNREACHABLE(); \ /* CC-OFFNXT(G.PRE.05) function gen */ \ return {}; \ } \ diff --git a/ets2panda/evaluate/scopedDebugInfoPlugin.cpp b/ets2panda/evaluate/scopedDebugInfoPlugin.cpp index 54cc7f8e9e..ca16da8b35 100644 --- a/ets2panda/evaluate/scopedDebugInfoPlugin.cpp +++ b/ets2panda/evaluate/scopedDebugInfoPlugin.cpp @@ -255,7 +255,7 @@ varbinder::Variable *ScopedDebugInfoPlugin::FindClass(ir::Identifier *ident) // NOTE: separate this into a method. auto importPath = pathResolver_.FindNamedImportAll(context_.sourceFilePath.Utf8(), identName.Utf8()); if (!importPath.empty()) { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); return nullptr; } diff --git a/ets2panda/ir/astDump.cpp b/ets2panda/ir/astDump.cpp index c9b3d53e21..4e1ea33c36 100644 --- a/ets2panda/ir/astDump.cpp +++ b/ets2panda/ir/astDump.cpp @@ -179,7 +179,7 @@ void AstDumper::SerializeConstant(Property::Constant constant) break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } diff --git a/ets2panda/ir/astNode.cpp b/ets2panda/ir/astNode.cpp index 0168fb5fb8..63015a8368 100644 --- a/ets2panda/ir/astNode.cpp +++ b/ets2panda/ir/astNode.cpp @@ -74,12 +74,12 @@ bool AstNode::IsScopeBearer() const noexcept varbinder::Scope *AstNode::Scope() const noexcept { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void AstNode::ClearScope() noexcept { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } ir::ClassElement *AstNode::AsClassElement() @@ -118,7 +118,7 @@ const ir::BlockStatement *AstNode::GetTopStatement() const AstNode *AstNode::Clone([[maybe_unused]] ArenaAllocator *const allocator, [[maybe_unused]] AstNode *const parent) { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void AstNode::TransformChildrenRecursively(const NodeTransformer &cb, std::string_view transformationName) diff --git a/ets2panda/ir/astNode.h b/ets2panda/ir/astNode.h index 30ef3dbf05..27dff275cb 100644 --- a/ets2panda/ir/astNode.h +++ b/ets2panda/ir/astNode.h @@ -16,12 +16,12 @@ #ifndef ES2PANDA_IR_AST_NODE_H #define ES2PANDA_IR_AST_NODE_H +#include "es2panda.h" #include "astNodeFlags.h" #include "astNodeMapping.h" #include "ir/visitor/AstVisitor.h" #include "lexer/token/sourceLocation.h" -#include "macros.h" -#include "util/diagnosticEngine.h" +#include "util/es2pandaMacros.h" namespace ark::es2panda::compiler { class PandaGen; @@ -88,7 +88,7 @@ inline std::string_view ToString(AstNodeType nodeType) AST_NODE_REINTERPRET_MAPPING(STRING_FROM_NODE_TYPE_REINTERPRET) default: LOG(FATAL, ES2PANDA) << "Invalid 'AstNodeType'"; - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -331,7 +331,7 @@ public: virtual void AddDecorators([[maybe_unused]] ArenaVector &&decorators) { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } virtual bool CanHaveDecorator([[maybe_unused]] bool inTs) const diff --git a/ets2panda/ir/base/metaProperty.cpp b/ets2panda/ir/base/metaProperty.cpp index be90b9bc48..fcb85de132 100644 --- a/ets2panda/ir/base/metaProperty.cpp +++ b/ets2panda/ir/base/metaProperty.cpp @@ -41,7 +41,7 @@ void MetaProperty::Dump(ir::AstDumper *dumper) const break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } diff --git a/ets2panda/ir/base/methodDefinition.cpp b/ets2panda/ir/base/methodDefinition.cpp index d9a507018c..7320f52a01 100644 --- a/ets2panda/ir/base/methodDefinition.cpp +++ b/ets2panda/ir/base/methodDefinition.cpp @@ -44,7 +44,7 @@ PrivateFieldKind MethodDefinition::ToPrivateFieldKind(bool const isStatic) const return isStatic ? PrivateFieldKind::STATIC_SET : PrivateFieldKind::SET; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } @@ -140,7 +140,7 @@ void MethodDefinition::Dump(ir::AstDumper *dumper) const break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } diff --git a/ets2panda/ir/base/property.cpp b/ets2panda/ir/base/property.cpp index bf7b5ca5c0..24deab39d0 100644 --- a/ets2panda/ir/base/property.cpp +++ b/ets2panda/ir/base/property.cpp @@ -156,7 +156,7 @@ void Property::Dump(ir::AstDumper *dumper) const break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } diff --git a/ets2panda/ir/ets/etsNeverType.cpp b/ets2panda/ir/ets/etsNeverType.cpp index cfb9d692c2..79284dd1f7 100644 --- a/ets2panda/ir/ets/etsNeverType.cpp +++ b/ets2panda/ir/ets/etsNeverType.cpp @@ -51,12 +51,12 @@ void ETSNeverType::Dump(ir::SrcDumper *dumper) const void ETSNeverType::Compile([[maybe_unused]] compiler::PandaGen *pg) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSNeverType::Check([[maybe_unused]] checker::TSChecker *checker) { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::VerifiedType ETSNeverType::Check([[maybe_unused]] checker::ETSChecker *checker) diff --git a/ets2panda/ir/ets/etsNullishTypes.cpp b/ets2panda/ir/ets/etsNullishTypes.cpp index 2416452565..e3e9e79836 100644 --- a/ets2panda/ir/ets/etsNullishTypes.cpp +++ b/ets2panda/ir/ets/etsNullishTypes.cpp @@ -51,12 +51,12 @@ void ETSUndefinedType::Dump(ir::SrcDumper *dumper) const void ETSUndefinedType::Compile([[maybe_unused]] compiler::PandaGen *pg) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSUndefinedType::Check([[maybe_unused]] checker::TSChecker *checker) { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::VerifiedType ETSUndefinedType::Check([[maybe_unused]] checker::ETSChecker *checker) @@ -122,12 +122,12 @@ void ETSNullType::Dump(ir::SrcDumper *dumper) const void ETSNullType::Compile([[maybe_unused]] compiler::PandaGen *pg) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSNullType::Check([[maybe_unused]] checker::TSChecker *checker) { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::VerifiedType ETSNullType::Check([[maybe_unused]] checker::ETSChecker *checker) diff --git a/ets2panda/ir/ets/etsParameterExpression.cpp b/ets2panda/ir/ets/etsParameterExpression.cpp index b1ad5810ab..6072a259e3 100644 --- a/ets2panda/ir/ets/etsParameterExpression.cpp +++ b/ets2panda/ir/ets/etsParameterExpression.cpp @@ -28,7 +28,7 @@ ETSParameterExpression::ETSParameterExpression(AnnotatedExpression *const identO { SetOptional(isOptional); - ASSERT(identOrSpread != nullptr); + ES2PANDA_ASSERT(identOrSpread != nullptr); identOrSpread->SetParent(this); SetRange(identOrSpread->Range()); if (identOrSpread->IsIdentifier()) { @@ -39,7 +39,7 @@ ETSParameterExpression::ETSParameterExpression(AnnotatedExpression *const identO ident_ = spread_->Argument()->AsIdentifier(); ident_->SetParent(spread_); } else { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } diff --git a/ets2panda/ir/ets/etsParameterExpression.h b/ets2panda/ir/ets/etsParameterExpression.h index d49b522416..0d7b9d4157 100644 --- a/ets2panda/ir/ets/etsParameterExpression.h +++ b/ets2panda/ir/ets/etsParameterExpression.h @@ -77,13 +77,13 @@ public: void SetOptional(bool value) noexcept { isOptional_ = value; - ASSERT(isOptional_ || initializer_ == nullptr); + ES2PANDA_ASSERT(isOptional_ || initializer_ == nullptr); } void SetInitializer(Expression *initExpr) noexcept { initializer_ = initExpr; - ASSERT(isOptional_ || initializer_ == nullptr); + ES2PANDA_ASSERT(isOptional_ || initializer_ == nullptr); } [[nodiscard]] bool IsRestParameter() const noexcept diff --git a/ets2panda/ir/ets/etsPrimitiveType.cpp b/ets2panda/ir/ets/etsPrimitiveType.cpp index dfa14e13a4..c18f743502 100644 --- a/ets2panda/ir/ets/etsPrimitiveType.cpp +++ b/ets2panda/ir/ets/etsPrimitiveType.cpp @@ -78,7 +78,7 @@ void ETSPrimitiveType::Dump(ir::SrcDumper *dumper) const dumper->Add("void"); break; default: - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -151,7 +151,7 @@ checker::Type *ETSPrimitiveType::GetType([[maybe_unused]] checker::ETSChecker *c return checker->InvalidateType(this); } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } diff --git a/ets2panda/ir/ets/etsStringLiteralType.cpp b/ets2panda/ir/ets/etsStringLiteralType.cpp index 221270198f..d6227f2673 100644 --- a/ets2panda/ir/ets/etsStringLiteralType.cpp +++ b/ets2panda/ir/ets/etsStringLiteralType.cpp @@ -52,12 +52,12 @@ void ETSStringLiteralType::Dump(ir::SrcDumper *dumper) const void ETSStringLiteralType::Compile([[maybe_unused]] compiler::PandaGen *pg) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *ETSStringLiteralType::Check([[maybe_unused]] checker::TSChecker *checker) { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::VerifiedType ETSStringLiteralType::Check([[maybe_unused]] checker::ETSChecker *checker) diff --git a/ets2panda/ir/ets/etsStructDeclaration.cpp b/ets2panda/ir/ets/etsStructDeclaration.cpp index ef6e503517..f583cd4c6a 100644 --- a/ets2panda/ir/ets/etsStructDeclaration.cpp +++ b/ets2panda/ir/ets/etsStructDeclaration.cpp @@ -36,7 +36,7 @@ void ETSStructDeclaration::Dump(ir::SrcDumper *dumper) const checker::Type *ETSStructDeclaration::Check([[maybe_unused]] checker::TSChecker *checker) { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::VerifiedType ETSStructDeclaration::Check([[maybe_unused]] checker::ETSChecker *checker) diff --git a/ets2panda/ir/expressions/arrayExpression.cpp b/ets2panda/ir/expressions/arrayExpression.cpp index 108ee7ad3f..23ad522af5 100644 --- a/ets2panda/ir/expressions/arrayExpression.cpp +++ b/ets2panda/ir/expressions/arrayExpression.cpp @@ -305,7 +305,7 @@ checker::Type *CheckElementPattern(Expression *it, checker::Type *elementType, c return elementType; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } diff --git a/ets2panda/ir/expressions/blockExpression.cpp b/ets2panda/ir/expressions/blockExpression.cpp index 5705568106..c38cb57710 100644 --- a/ets2panda/ir/expressions/blockExpression.cpp +++ b/ets2panda/ir/expressions/blockExpression.cpp @@ -83,7 +83,7 @@ void BlockExpression::Dump(ir::SrcDumper *dumper) const void BlockExpression::Compile([[maybe_unused]] compiler::PandaGen *pg) const { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void BlockExpression::Compile(compiler::ETSGen *etsg) const @@ -93,7 +93,7 @@ void BlockExpression::Compile(compiler::ETSGen *etsg) const checker::Type *BlockExpression::Check([[maybe_unused]] checker::TSChecker *checker) { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::VerifiedType BlockExpression::Check(checker::ETSChecker *checker) diff --git a/ets2panda/ir/expressions/literals/numberLiteral.cpp b/ets2panda/ir/expressions/literals/numberLiteral.cpp index 2b1ef78d78..7a2c2267dc 100644 --- a/ets2panda/ir/expressions/literals/numberLiteral.cpp +++ b/ets2panda/ir/expressions/literals/numberLiteral.cpp @@ -138,7 +138,7 @@ void GetBase(FpType d, int digits, int *decpt, Span buf) // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) auto ret = snprintf_s(buf.begin(), buf.size(), buf.size() - 1, "%.*e", digits - 1, d); if (ret == -1) { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } char *end = buf.begin() + ret; ES2PANDA_ASSERT(*end == 0); @@ -244,7 +244,7 @@ static Span FpToStringDecimalRadixMainCase(FpType number, bool negative, S // the remaining k−n digits of the decimal representation of s. auto fracStart = bufferStart + n; if (memmove_s(fracStart + 1, buffer.end() - (fracStart + 1), fracStart, k - n) != EOK) { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } *fracStart = '.'; bufferEnd++; @@ -256,7 +256,7 @@ static Span FpToStringDecimalRadixMainCase(FpType number, bool negative, S auto length = -n + 2U; auto fracStart = bufferStart + length; if (memmove_s(fracStart, buffer.end() - fracStart, bufferStart, k) != EOK) { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } std::fill_n(bufferStart, length, '0'); bufferStart[1] = '.'; @@ -280,7 +280,7 @@ static Span FpToStringDecimalRadixMainCase(FpType number, bool negative, S if (bufferEnd + result.size() <= buffer.end()) { bufferEnd = std::copy(result.begin(), result.end(), bufferEnd); } else { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } if (negative) { diff --git a/ets2panda/ir/expressions/literals/stringLiteral.h b/ets2panda/ir/expressions/literals/stringLiteral.h index 0c578843a4..c0168d5f04 100644 --- a/ets2panda/ir/expressions/literals/stringLiteral.h +++ b/ets2panda/ir/expressions/literals/stringLiteral.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * 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 @@ -17,7 +17,7 @@ #define ES2PANDA_IR_EXPRESSION_LITERAL_STRING_LITERAL_H #include "ir/expressions/literal.h" -#include "macros.h" +#include "util/es2pandaMacros.h" #include "util/ustring.h" namespace ark::es2panda::ir { diff --git a/ets2panda/ir/expressions/memberExpression.cpp b/ets2panda/ir/expressions/memberExpression.cpp index 957d3f38a0..05fb588e2b 100644 --- a/ets2panda/ir/expressions/memberExpression.cpp +++ b/ets2panda/ir/expressions/memberExpression.cpp @@ -183,7 +183,7 @@ std::pair MemberExpression::Resolve return {resolvedType, nullptr}; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } @@ -310,7 +310,7 @@ bool MemberExpression::CheckArrayIndexValue(checker::ETSChecker *checker) const } index = static_cast(value); } else { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } if (object_->IsArrayExpression() && object_->AsArrayExpression()->Elements().size() <= index) { diff --git a/ets2panda/ir/expressions/objectExpression.cpp b/ets2panda/ir/expressions/objectExpression.cpp index 66b04432ff..11e04243c2 100644 --- a/ets2panda/ir/expressions/objectExpression.cpp +++ b/ets2panda/ir/expressions/objectExpression.cpp @@ -265,7 +265,7 @@ ObjectExpression::CheckPatternIsShorthand(CheckPatternIsShorthandArgs *args) break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } return {args->isOptional, args->bindingVar, args->patternParamType, args->foundVar}; @@ -290,7 +290,7 @@ ObjectExpression::CheckPatternIsShorthand(CheckPatternIsShorthandArgs *args) break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } return {args->isOptional, args->bindingVar, args->patternParamType, args->foundVar}; diff --git a/ets2panda/ir/irnode.h b/ets2panda/ir/irnode.h index 34f6d0713f..bf462a5ef8 100644 --- a/ets2panda/ir/irnode.h +++ b/ets2panda/ir/irnode.h @@ -20,7 +20,7 @@ #include "compiler/core/vReg.h" #include "compiler/core/programElement.h" #include "lexer/token/sourceLocation.h" -#include "macros.h" +#include "util/es2pandaMacros.h" #include "util/ustring.h" #include "utils/span.h" diff --git a/ets2panda/ir/statements/doWhileStatement.cpp b/ets2panda/ir/statements/doWhileStatement.cpp index 189859d0ec..58e70f28f5 100644 --- a/ets2panda/ir/statements/doWhileStatement.cpp +++ b/ets2panda/ir/statements/doWhileStatement.cpp @@ -99,7 +99,7 @@ DoWhileStatement *DoWhileStatement::Clone(ArenaAllocator *const allocator, AstNo } clone->SetRange(Range()); - ASSERT(clone->Scope() == nullptr); + ES2PANDA_ASSERT(clone->Scope() == nullptr); return clone; } diff --git a/ets2panda/ir/statements/forInStatement.cpp b/ets2panda/ir/statements/forInStatement.cpp index 2e30ae157c..9436f75696 100644 --- a/ets2panda/ir/statements/forInStatement.cpp +++ b/ets2panda/ir/statements/forInStatement.cpp @@ -92,7 +92,7 @@ ForInStatement *ForInStatement::Clone(ArenaAllocator *const allocator, AstNode * } clone->SetRange(Range()); - ASSERT(clone->Scope() == nullptr); + ES2PANDA_ASSERT(clone->Scope() == nullptr); return clone; } } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/statements/forUpdateStatement.cpp b/ets2panda/ir/statements/forUpdateStatement.cpp index af02f0402e..912dd11f40 100644 --- a/ets2panda/ir/statements/forUpdateStatement.cpp +++ b/ets2panda/ir/statements/forUpdateStatement.cpp @@ -138,7 +138,7 @@ ForUpdateStatement *ForUpdateStatement::Clone(ArenaAllocator *const allocator, A } clone->SetRange(Range()); - ASSERT(clone->Scope() == nullptr); + ES2PANDA_ASSERT(clone->Scope() == nullptr); return clone; } } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/statements/loopStatement.cpp b/ets2panda/ir/statements/loopStatement.cpp index b65c3eed1e..1396aa3bec 100644 --- a/ets2panda/ir/statements/loopStatement.cpp +++ b/ets2panda/ir/statements/loopStatement.cpp @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * 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 @@ -21,7 +21,7 @@ namespace ark::es2panda::ir { checker::VerifiedType LoopStatement::Check([[maybe_unused]] checker::ETSChecker *checker) { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); return {this, nullptr}; } } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/statements/loopStatement.h b/ets2panda/ir/statements/loopStatement.h index ceffffa95b..d641ae4397 100644 --- a/ets2panda/ir/statements/loopStatement.h +++ b/ets2panda/ir/statements/loopStatement.h @@ -52,27 +52,27 @@ public: void TransformChildren([[maybe_unused]] const NodeTransformer &cb, [[maybe_unused]] std::string_view const transformationName) override { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void Iterate([[maybe_unused]] const NodeTraverser &cb) const override { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void Dump([[maybe_unused]] AstDumper *dumper) const override { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void Compile([[maybe_unused]] compiler::PandaGen *pg) const override { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } checker::Type *Check([[maybe_unused]] checker::TSChecker *checker) override { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); return nullptr; } diff --git a/ets2panda/ir/statements/variableDeclaration.cpp b/ets2panda/ir/statements/variableDeclaration.cpp index 208632efe1..8ac91f0960 100644 --- a/ets2panda/ir/statements/variableDeclaration.cpp +++ b/ets2panda/ir/statements/variableDeclaration.cpp @@ -78,7 +78,7 @@ void VariableDeclaration::Dump(ir::AstDumper *dumper) const break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -111,7 +111,7 @@ void VariableDeclaration::Dump(ir::SrcDumper *dumper) const dumper->Add("var "); break; default: - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } for (auto declarator : declarators_) { diff --git a/ets2panda/ir/statements/whileStatement.cpp b/ets2panda/ir/statements/whileStatement.cpp index 3ea5dbc46e..5bdc886393 100644 --- a/ets2panda/ir/statements/whileStatement.cpp +++ b/ets2panda/ir/statements/whileStatement.cpp @@ -98,7 +98,7 @@ WhileStatement *WhileStatement::Clone(ArenaAllocator *const allocator, AstNode * } clone->SetRange(Range()); - ASSERT(clone->Scope() == nullptr); + ES2PANDA_ASSERT(clone->Scope() == nullptr); return clone; } } // namespace ark::es2panda::ir diff --git a/ets2panda/ir/ts/tsInterfaceDeclaration.cpp b/ets2panda/ir/ts/tsInterfaceDeclaration.cpp index 0c6028f235..467ecd8201 100644 --- a/ets2panda/ir/ts/tsInterfaceDeclaration.cpp +++ b/ets2panda/ir/ts/tsInterfaceDeclaration.cpp @@ -15,7 +15,7 @@ #include "tsInterfaceDeclaration.h" -#include "macros.h" +#include "util/es2pandaMacros.h" #include "varbinder/declaration.h" #include "varbinder/variable.h" #include "checker/TSchecker.h" diff --git a/ets2panda/ir/visitor/AstVisitor.h b/ets2panda/ir/visitor/AstVisitor.h index 952c66836b..33964b1c72 100644 --- a/ets2panda/ir/visitor/AstVisitor.h +++ b/ets2panda/ir/visitor/AstVisitor.h @@ -17,7 +17,7 @@ #define ES2PANDA_COMPILER_CORE_AST_VISITOR_H #include -#include "macros.h" +#include "util/es2pandaMacros.h" #include namespace ark::es2panda::ir { diff --git a/ets2panda/ir/visitor/IterateAstVisitor.h b/ets2panda/ir/visitor/IterateAstVisitor.h index a8eacb2e94..5b18563459 100644 --- a/ets2panda/ir/visitor/IterateAstVisitor.h +++ b/ets2panda/ir/visitor/IterateAstVisitor.h @@ -105,7 +105,7 @@ public: void HandleNode(ir::AstNode * /*node*/) final { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } }; diff --git a/ets2panda/lexer/keywordString.h b/ets2panda/lexer/keywordString.h index 170893833a..b93d472d52 100644 --- a/ets2panda/lexer/keywordString.h +++ b/ets2panda/lexer/keywordString.h @@ -17,7 +17,7 @@ #define ES2PANDA_PARSER_CORE_KEYWORD_STRING_H #include "generated/tokenType.h" -#include "macros.h" +#include "util/es2pandaMacros.h" #include "util/ustring.h" namespace ark::es2panda::lexer { diff --git a/ets2panda/lexer/keywordsBase.h b/ets2panda/lexer/keywordsBase.h index 296acb4984..a72ffa3bbe 100644 --- a/ets2panda/lexer/keywordsBase.h +++ b/ets2panda/lexer/keywordsBase.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - 2023 Huawei Device Co., Ltd. + * 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 @@ -18,7 +18,7 @@ #include "lexer/keywordString.h" #include "lexer/keywordsUtil.h" -#include "macros.h" +#include "util/es2pandaMacros.h" namespace ark::es2panda::lexer { class Keywords { diff --git a/ets2panda/lexer/keywordsUtil.h b/ets2panda/lexer/keywordsUtil.h index fd61b9e3c8..9c1bc3bb42 100644 --- a/ets2panda/lexer/keywordsUtil.h +++ b/ets2panda/lexer/keywordsUtil.h @@ -20,7 +20,7 @@ #include "lexer/lexer.h" #include "lexer/token/letters.h" #include "generated/tokenType.h" -#include "macros.h" +#include "util/es2pandaMacros.h" #include "util/ustring.h" #include "utils/span.h" diff --git a/ets2panda/lexer/lexer.cpp b/ets2panda/lexer/lexer.cpp index 8bc813b66f..60efc1500e 100644 --- a/ets2panda/lexer/lexer.cpp +++ b/ets2panda/lexer/lexer.cpp @@ -523,7 +523,7 @@ LexerTemplateString Lexer::ScanTemplateString() Iterator().Forward(cpSize); } - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); return templateStr; } @@ -573,7 +573,7 @@ util::StringView Lexer::ScanMultilineString() Iterator().Forward(cpSize); } - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); return str.View(); } diff --git a/ets2panda/lexer/templates/token.inl.erb b/ets2panda/lexer/templates/token.inl.erb index df07d2d980..8c4262f2d4 100644 --- a/ets2panda/lexer/templates/token.inl.erb +++ b/ets2panda/lexer/templates/token.inl.erb @@ -35,7 +35,7 @@ const char *TokenToString(TokenType type) // NOLINT(readability-function-size) case TokenType::EOS: return "eos"; default: - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } diff --git a/ets2panda/lexer/token/sourceLocation.h b/ets2panda/lexer/token/sourceLocation.h index 20afa7dc63..a150a8cfb0 100644 --- a/ets2panda/lexer/token/sourceLocation.h +++ b/ets2panda/lexer/token/sourceLocation.h @@ -17,7 +17,6 @@ #define ES2PANDA_LEXER_TOKEN_SOURCE_LOCATION_H #include "macros.h" -#include "util/ustring.h" #include #include #include @@ -25,6 +24,11 @@ namespace ark::es2panda::parser { class Program; } // namespace ark::es2panda::parser + +namespace ark::es2panda::util { +class StringView; +} // namespace ark::es2panda::util + namespace ark::es2panda::lexer { class SourceLocation; diff --git a/ets2panda/lexer/token/token.h b/ets2panda/lexer/token/token.h index 52e8cc8194..2f9ef0b194 100644 --- a/ets2panda/lexer/token/token.h +++ b/ets2panda/lexer/token/token.h @@ -19,7 +19,7 @@ #include "lexer/token/sourceLocation.h" #include "generated/tokenType.h" #include "lexer/token/number.h" -#include "macros.h" +#include "util/es2pandaMacros.h" #include "util/enumbitops.h" #include "util/ustring.h" diff --git a/ets2panda/lsp/include/completions.h b/ets2panda/lsp/include/completions.h index 11dfc87449..df8c4480a1 100644 --- a/ets2panda/lsp/include/completions.h +++ b/ets2panda/lsp/include/completions.h @@ -23,6 +23,7 @@ #include #include #include "checker/checker.h" +#include "util/arktsconfig.h" namespace ark::es2panda::lsp { diff --git a/ets2panda/parser/ETSFormattedParser.cpp b/ets2panda/parser/ETSFormattedParser.cpp index 7c2f6c9962..cfefa287b7 100644 --- a/ets2panda/parser/ETSFormattedParser.cpp +++ b/ets2panda/parser/ETSFormattedParser.cpp @@ -58,7 +58,7 @@ ParserImpl::NodeFormatType ETSParser::GetFormatPlaceholderType() auto identNumber = std::atoi(identData + 1U); if (identNumber <= 0) { LogError(diagnostic::INVALID_NODE_NUMBER, {}, Lexer()->GetToken().Start()); - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } return {isArray, *identData, @@ -77,7 +77,7 @@ ir::Expression *ETSParser::ParseExpressionFormatPlaceholder() ParserImpl::NodeFormatType nodeFormat = GetFormatPlaceholderType(); if (std::get<0>(nodeFormat)) { LogError(diagnostic::INVALID_NODE_TYPE, {}, Lexer()->GetToken().Start()); - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } if (auto const placeholderType = std::get<1>(nodeFormat); placeholderType == TYPE_FORMAT_NODE) { @@ -86,7 +86,7 @@ ir::Expression *ETSParser::ParseExpressionFormatPlaceholder() return ParseIdentifierFormatPlaceholder(std::make_optional(std::move(nodeFormat))); } else if (placeholderType != EXPRESSION_FORMAT_NODE) { // NOLINT(readability-else-after-return) LogError(diagnostic::INVALID_NODE_TYPE, {}, Lexer()->GetToken().Start()); - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } auto const placeholderNumber = std::get<2>(nodeFormat); @@ -94,7 +94,7 @@ ir::Expression *ETSParser::ParseExpressionFormatPlaceholder() placeholderNumber < insertingNodes_.size() ? insertingNodes_[placeholderNumber] : nullptr; if (insertingNode == nullptr || !insertingNode->IsExpression()) { LogError(diagnostic::INVALID_INSERT_NODE, {}, Lexer()->GetToken().Start()); - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } auto *const insertExpression = insertingNode->AsExpression(); @@ -107,13 +107,13 @@ ir::TypeNode *ETSParser::ParseTypeFormatPlaceholder(std::optionalGetToken().Start()); - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } nodeFormat = GetFormatPlaceholderType(); if (std::get<0>(*nodeFormat) || std::get<1>(*nodeFormat) != TYPE_FORMAT_NODE) { LogError(diagnostic::INVALID_NODE_TYPE, {}, Lexer()->GetToken().Start()); - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -122,7 +122,7 @@ ir::TypeNode *ETSParser::ParseTypeFormatPlaceholder(std::optionalIsExpression() || !insertingNode->AsExpression()->IsTypeNode()) { LogError(diagnostic::INVALID_INSERT_NODE, {}, Lexer()->GetToken().Start()); - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } auto *const insertType = insertingNode->AsExpression()->AsTypeNode(); @@ -150,7 +150,7 @@ ir::Identifier *ETSParser::ParseIdentifierFormatPlaceholder(std::optionalIsExpression() || !insertingNode->AsExpression()->IsIdentifier()) { LogError(diagnostic::INVALID_INSERT_NODE, {}, Lexer()->GetToken().Start()); - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } auto *const insertIdentifier = insertingNode->AsExpression()->AsIdentifier(); @@ -162,13 +162,13 @@ ir::Statement *ETSParser::ParseStatementFormatPlaceholder() { if (insertingNodes_.empty()) { LogError(diagnostic::INSERT_NODE_ABSENT, {}, Lexer()->GetToken().Start()); - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } ParserImpl::NodeFormatType nodeFormat = GetFormatPlaceholderType(); if (std::get<0>(nodeFormat) || std::get<1>(nodeFormat) != STATEMENT_FORMAT_NODE) { LogError(diagnostic::INVALID_NODE_TYPE, {}, Lexer()->GetToken().Start()); - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } auto const placeholderNumber = std::get<2>(nodeFormat); @@ -176,7 +176,7 @@ ir::Statement *ETSParser::ParseStatementFormatPlaceholder() placeholderNumber < insertingNodes_.size() ? insertingNodes_[placeholderNumber] : nullptr; if (insertingNode == nullptr || !insertingNode->IsStatement()) { LogError(diagnostic::INVALID_INSERT_NODE, {}, Lexer()->GetToken().Start()); - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } Lexer()->NextToken(); @@ -188,20 +188,20 @@ ir::AstNode *ETSParser::ParseTypeParametersFormatPlaceholder() ParserImpl::NodeFormatType nodeFormat = GetFormatPlaceholderType(); if (std::get<0>(nodeFormat) || std::get<1>(nodeFormat) != EXPRESSION_FORMAT_NODE) { LogError(diagnostic::INVALID_NODE_TYPE, {}, Lexer()->GetToken().Start()); - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } auto const placeholderNumber = std::get<2>(nodeFormat); if (placeholderNumber >= insertingNodes_.size()) { LogError(diagnostic::INSERT_NODE_ABSENT, {}, Lexer()->GetToken().Start()); - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } auto *const insertingNode = insertingNodes_[placeholderNumber]; if (insertingNode != nullptr && !insertingNode->IsTSTypeParameterDeclaration() && !insertingNode->IsTSTypeParameterInstantiation()) { LogError(diagnostic::INVALID_INSERT_NODE, {}, Lexer()->GetToken().Start()); - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } Lexer()->NextToken(); @@ -212,13 +212,13 @@ ArenaVector &ETSParser::ParseAstNodesArrayFormatPlaceholder() { if (insertingNodes_.empty()) { LogError(diagnostic::INSERT_NODE_ABSENT, {}, Lexer()->GetToken().Start()); - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } ParserImpl::NodeFormatType nodeFormat = GetFormatPlaceholderType(); if (!std::get<0>(nodeFormat) || std::get<1>(nodeFormat) != GENERAL_FORMAT_NODE) { LogError(diagnostic::INVALID_NODE_TYPE, {}, Lexer()->GetToken().Start()); - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } auto const placeholderNumber = std::get<2>(nodeFormat); @@ -226,7 +226,7 @@ ArenaVector &ETSParser::ParseAstNodesArrayFormatPlaceholder() placeholderNumber < insertingNodes_.size() ? insertingNodes_[placeholderNumber] : nullptr; if (insertingNode == nullptr || !insertingNode->IsTSInterfaceBody()) { LogError(diagnostic::INVALID_INSERT_NODE, {}, Lexer()->GetToken().Start()); - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } Lexer()->NextToken(); @@ -237,13 +237,13 @@ ArenaVector &ETSParser::ParseStatementsArrayFormatPlaceholder() { if (insertingNodes_.empty()) { LogError(diagnostic::INSERT_NODE_ABSENT, {}, Lexer()->GetToken().Start()); - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } ParserImpl::NodeFormatType nodeFormat = GetFormatPlaceholderType(); if (!std::get<0>(nodeFormat) || std::get<1>(nodeFormat) != STATEMENT_FORMAT_NODE) { LogError(diagnostic::INVALID_NODE_TYPE, {}, Lexer()->GetToken().Start()); - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } auto const placeholderNumber = std::get<2>(nodeFormat); @@ -251,7 +251,7 @@ ArenaVector &ETSParser::ParseStatementsArrayFormatPlaceholder() placeholderNumber < insertingNodes_.size() ? insertingNodes_[placeholderNumber] : nullptr; if (insertingNode == nullptr || !insertingNode->IsBlockExpression()) { LogError(diagnostic::INVALID_INSERT_NODE, {}, Lexer()->GetToken().Start()); - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } Lexer()->NextToken(); @@ -262,13 +262,13 @@ ArenaVector &ETSParser::ParseExpressionsArrayFormatPlaceholder { if (insertingNodes_.empty()) { LogError(diagnostic::INSERT_NODE_ABSENT, {}, Lexer()->GetToken().Start()); - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } ParserImpl::NodeFormatType nodeFormat = GetFormatPlaceholderType(); if (!std::get<0>(nodeFormat) || std::get<1>(nodeFormat) != EXPRESSION_FORMAT_NODE) { LogError(diagnostic::INVALID_NODE_TYPE, {}, Lexer()->GetToken().Start()); - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } auto const placeholderNumber = std::get<2>(nodeFormat); @@ -276,7 +276,7 @@ ArenaVector &ETSParser::ParseExpressionsArrayFormatPlaceholder placeholderNumber < insertingNodes_.size() ? insertingNodes_[placeholderNumber] : nullptr; if (insertingNode == nullptr || !insertingNode->IsSequenceExpression()) { LogError(diagnostic::INVALID_INSERT_NODE, {}, Lexer()->GetToken().Start()); - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } Lexer()->NextToken(); @@ -363,7 +363,7 @@ ir::AstNode *ETSParser::CreateFormattedClassFieldDefinition(std::string_view sou auto *const property = CreateClassElement(sourceCode, DUMMY_ARRAY, ir::ClassDefinitionModifiers::NONE); if (!property->IsTSInterfaceBody() || property->AsTSInterfaceBody()->Body().empty()) { LogError(diagnostic::INVALID_CLASS_FIELD, {}, Lexer()->GetToken().Start()); - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } insertingNodes_.swap(insertingNodes); @@ -379,7 +379,7 @@ ir::AstNode *ETSParser::CreateFormattedClassMethodDefinition(std::string_view so auto *const property = CreateClassElement(sourceCode, DUMMY_ARRAY, ir::ClassDefinitionModifiers::NONE); if (!property->IsMethodDefinition()) { LogError(diagnostic::INVALID_CLASS_METHOD, {}, Lexer()->GetToken().Start()); - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } insertingNodes_.swap(insertingNodes); @@ -487,7 +487,7 @@ ir::MethodDefinition *ETSParser::CreateConstructorDefinition(ir::ModifierFlags m if ((modifiers & ir::ModifierFlags::ASYNC) != 0) { LogError(diagnostic::ASYNC_CONSTRUCTOR); - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } auto *memberName = AllocNode(Lexer()->GetToken().Ident(), Allocator()); diff --git a/ets2panda/parser/ETSparser.cpp b/ets2panda/parser/ETSparser.cpp index 92c23db4cc..a220fbbc42 100644 --- a/ets2panda/parser/ETSparser.cpp +++ b/ets2panda/parser/ETSparser.cpp @@ -17,7 +17,7 @@ #include "ETSNolintParser.h" #include -#include "macros.h" +#include "util/es2pandaMacros.h" #include "parser/parserFlags.h" #include "parser/parserStatusContext.h" #include "util/helpers.h" @@ -698,7 +698,7 @@ std::pair ETSParser::CheckDefaultParameters(const ir::ScriptF return std::make_pair(hasOptionalParameters, requiredParametersNumber); } -std::string ETSParser::PrimitiveTypeToName(ir::PrimitiveType type) +std::string ETSParser::PrimitiveTypeToName(ir::PrimitiveType type) const { switch (type) { case ir::PrimitiveType::BYTE: @@ -720,7 +720,7 @@ std::string ETSParser::PrimitiveTypeToName(ir::PrimitiveType type) case ir::PrimitiveType::VOID: return "void"; default: - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -793,7 +793,7 @@ std::string ETSParser::GetNameForTypeNode(const ir::TypeNode *typeAnnotation) co return "undefined"; } - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } void ETSParser::ValidateRestParameter(ir::Expression *param) diff --git a/ets2panda/parser/ETSparser.h b/ets2panda/parser/ETSparser.h index f44c94b6ca..f7b8179fd7 100644 --- a/ets2panda/parser/ETSparser.h +++ b/ets2panda/parser/ETSparser.h @@ -352,7 +352,7 @@ private: ir::TypeNode *ParseTsArrayType(ir::TypeNode *typeNode, TypeAnnotationParsingOptions *options); bool ParseTriplePeriod(bool spreadTypePresent); std::pair CheckDefaultParameters(const ir::ScriptFunction *function); - static std::string PrimitiveTypeToName(ir::PrimitiveType type); + std::string PrimitiveTypeToName(ir::PrimitiveType type) const; std::string GetNameForTypeNode(const ir::TypeNode *typeAnnotation) const; std::string GetNameForETSUnionType(const ir::TypeNode *typeAnnotation) const; ir::TSInterfaceDeclaration *ParseInterfaceBody(ir::Identifier *name, bool isStatic); diff --git a/ets2panda/parser/ETSparserClasses.cpp b/ets2panda/parser/ETSparserClasses.cpp index 4a2109f37d..5d20261b6c 100644 --- a/ets2panda/parser/ETSparserClasses.cpp +++ b/ets2panda/parser/ETSparserClasses.cpp @@ -16,7 +16,8 @@ #include "ETSparser.h" #include "ETSNolintParser.h" #include -#include "macros.h" +#include "generated/diagnostic.h" +#include "util/es2pandaMacros.h" #include "parser/parserFlags.h" #include "parser/parserStatusContext.h" #include "util/helpers.h" @@ -134,7 +135,7 @@ ir::ModifierFlags ETSParser::ParseClassModifiers() break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -235,7 +236,7 @@ std::tuple ETSParser::ParseClassMemberAccessModifiers() break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -283,7 +284,7 @@ ir::ModifierFlags ETSParser::ParseClassFieldModifiers(bool seenStatic) break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -352,7 +353,7 @@ ir::ModifierFlags ETSParser::ParseClassMethodModifierFlag() break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } diff --git a/ets2panda/parser/ETSparserEnums.cpp b/ets2panda/parser/ETSparserEnums.cpp index 43acc3081e..c64b36c8a7 100644 --- a/ets2panda/parser/ETSparserEnums.cpp +++ b/ets2panda/parser/ETSparserEnums.cpp @@ -17,7 +17,7 @@ #include "ETSNolintParser.h" #include -#include "macros.h" +#include "util/es2pandaMacros.h" #include "parser/parserFlags.h" #include "parser/parserStatusContext.h" #include "util/helpers.h" diff --git a/ets2panda/parser/ETSparserStatements.cpp b/ets2panda/parser/ETSparserStatements.cpp index 524bd9b2ac..cf654dad81 100644 --- a/ets2panda/parser/ETSparserStatements.cpp +++ b/ets2panda/parser/ETSparserStatements.cpp @@ -16,7 +16,7 @@ #include "ETSparser.h" #include "ETSNolintParser.h" -#include "macros.h" +#include "util/es2pandaMacros.h" #include "parser/parserFlags.h" #include "util/errorRecovery.h" #include "util/helpers.h" diff --git a/ets2panda/parser/ETSparserTypes.cpp b/ets2panda/parser/ETSparserTypes.cpp index a307c3b5cb..1f2e9998f2 100644 --- a/ets2panda/parser/ETSparserTypes.cpp +++ b/ets2panda/parser/ETSparserTypes.cpp @@ -17,7 +17,7 @@ #include "ETSNolintParser.h" #include -#include "macros.h" +#include "util/es2pandaMacros.h" #include "parser/parserFlags.h" #include "parser/parserStatusContext.h" #include "util/helpers.h" diff --git a/ets2panda/parser/TSparser.cpp b/ets2panda/parser/TSparser.cpp index c9b819c847..818391e128 100644 --- a/ets2panda/parser/TSparser.cpp +++ b/ets2panda/parser/TSparser.cpp @@ -16,7 +16,7 @@ #include "TSparser.h" #include "parser/parserStatusContext.h" -#include "macros.h" +#include "util/es2pandaMacros.h" #include "parserFlags.h" #include "util/helpers.h" #include "varbinder/privateBinding.h" diff --git a/ets2panda/parser/TypedParser.cpp b/ets2panda/parser/TypedParser.cpp index 79e3bed7db..ea12cfac28 100644 --- a/ets2panda/parser/TypedParser.cpp +++ b/ets2panda/parser/TypedParser.cpp @@ -490,7 +490,7 @@ static util::StringView GetTSPropertyName(ir::Expression *key) return key->AsStringLiteral()->Str(); } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } @@ -1107,7 +1107,7 @@ static std::pair ParseActualNextStatus(lex return {ir::ModifierFlags::READONLY, ir::ModifierFlags::ASYNC | ir::ModifierFlags::DECLARE | ir::ModifierFlags::ABSTRACT}; default: - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } diff --git a/ets2panda/parser/expressionParser.cpp b/ets2panda/parser/expressionParser.cpp index e76f2e6099..7c9343b387 100644 --- a/ets2panda/parser/expressionParser.cpp +++ b/ets2panda/parser/expressionParser.cpp @@ -69,7 +69,7 @@ #include "lexer/token/letters.h" #include "lexer/token/sourceLocation.h" #include "lexer/token/token.h" -#include "macros.h" +#include "util/es2pandaMacros.h" #include "util/errorRecovery.h" #include "util/options.h" #include "generated/diagnostic.h" @@ -1062,7 +1062,7 @@ ir::Expression *ParserImpl::ParsePunctuators(ExpressionParseFlags flags) return ParsePrefixAssertionExpression(); } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } @@ -1135,7 +1135,7 @@ static constexpr size_t GetOperatorPrecedenceArithmeticAndComparison(const lexer return PRECEDENCE; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } @@ -1242,7 +1242,7 @@ static inline ir::Expression *GetAmendedChildExpression(ir::Expression *const ex } else if (expression->IsTSAsExpression()) { amendedChild = expression->AsTSAsExpression()->Expr(); } else { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } return amendedChild; @@ -1257,7 +1257,7 @@ static inline void SetAmendedChildExpression(ir::Expression *const parent, ir::E parent->AsTSAsExpression()->SetExpr(amended); amended->SetParent(parent); } else { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } @@ -1410,7 +1410,7 @@ ir::CallExpression *ParserImpl::ParseCallExpression(ir::Expression *callee, bool callee = callExpr; } - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } ir::Expression *ParserImpl::ParseOptionalChain(ir::Expression *leftSideExpr) diff --git a/ets2panda/parser/expressionTSParser.cpp b/ets2panda/parser/expressionTSParser.cpp index ec1fb2ccf0..86f1232891 100644 --- a/ets2panda/parser/expressionTSParser.cpp +++ b/ets2panda/parser/expressionTSParser.cpp @@ -542,7 +542,7 @@ void TSParser::ParseOptionalFunctionParameter(ir::AnnotatedExpression *returnNod break; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } diff --git a/ets2panda/parser/parserImpl.cpp b/ets2panda/parser/parserImpl.cpp index 1ba97bae82..13842bd184 100644 --- a/ets2panda/parser/parserImpl.cpp +++ b/ets2panda/parser/parserImpl.cpp @@ -1155,21 +1155,21 @@ ArenaVector &ParserImpl::ParseStatementsArrayFormatPlaceholder( { // NOTE(schernykh): add info about LoC LOG(FATAL, ES2PANDA) << "Format placeholder from statements array is not supported"; - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } ArenaVector &ParserImpl::ParseAstNodesArrayFormatPlaceholder() { // NOTE(schernykh): add info about LoC LOG(FATAL, ES2PANDA) << "Format placeholder from AST nodes is not supported"; - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } ArenaVector &ParserImpl::ParseExpressionsArrayFormatPlaceholder() { // NOTE(schernykh): add info about LoC LOG(FATAL, ES2PANDA) << "Format placeholder from expressions array is not supported"; - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } util::StringView ParserImpl::ParseSymbolIteratorIdentifier() const noexcept diff --git a/ets2panda/parser/parserImpl.h b/ets2panda/parser/parserImpl.h index e074172a62..b5b04374ba 100644 --- a/ets2panda/parser/parserImpl.h +++ b/ets2panda/parser/parserImpl.h @@ -115,7 +115,7 @@ protected: void ValidateClassKey(ClassElementDescriptor *desc); bool ValidatePrivateIdentifier(); - static ir::VariableDeclaratorFlag GetFlag(VariableParsingFlags flags); + ir::VariableDeclaratorFlag GetFlag(VariableParsingFlags flags); void ValidateAccessor(ExpressionParseFlags flags, lexer::TokenFlags currentTokenFlags); void CheckPropertyKeyAsyncModifier(ParserStatus *methodStatus); diff --git a/ets2panda/parser/program/entityNameVisitor.h b/ets2panda/parser/program/entityNameVisitor.h index 225b823c6e..e8f64ffc46 100644 --- a/ets2panda/parser/program/entityNameVisitor.h +++ b/ets2panda/parser/program/entityNameVisitor.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2024 Huawei Device Co., Ltd. + * 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 @@ -17,7 +17,7 @@ #define ES2PANDA_PARSER_PROGRAM_ENTITY_NAME_VISITOR_H #include "libpandabase/mem/arena_allocator.h" -#include "macros.h" +#include "util/es2pandaMacros.h" #include "ir/visitor/IterateAstVisitor.h" #include "util/ustring.h" diff --git a/ets2panda/parser/program/program.h b/ets2panda/parser/program/program.h index 36523fb4aa..f63d1f4156 100644 --- a/ets2panda/parser/program/program.h +++ b/ets2panda/parser/program/program.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_PARSER_INCLUDE_PROGRAM_H #define ES2PANDA_PARSER_INCLUDE_PROGRAM_H -#include "macros.h" +#include "util/es2pandaMacros.h" #include "mem/pool_manager.h" #include "os/filesystem.h" #include "util/ustring.h" diff --git a/ets2panda/parser/statementParser.cpp b/ets2panda/parser/statementParser.cpp index 15583f140b..b0a687a823 100644 --- a/ets2panda/parser/statementParser.cpp +++ b/ets2panda/parser/statementParser.cpp @@ -203,7 +203,7 @@ ir::Statement *ParserImpl::ParseStatementBasedOnTokenType(StatementParsingFlags ir::Statement *ParserImpl::ParseAnnotationsInStatement([[maybe_unused]] StatementParsingFlags flags) { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } ir::Statement *ParserImpl::ParseVarStatement() @@ -443,7 +443,7 @@ void ParserImpl::ParseDirectivePrologue(ArenaVector *statements ir::Statement *ParserImpl::ParseAssertStatement() { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } bool ParserImpl::ValidateLabeledStatement([[maybe_unused]] lexer::TokenType type) @@ -1414,7 +1414,7 @@ ir::VariableDeclaratorFlag ParserImpl::GetFlag(VariableParsingFlags flags) case VariableParsingFlags::LET: return ir::VariableDeclaratorFlag::LET; default: - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } diff --git a/ets2panda/public/es2panda_lib.cpp b/ets2panda/public/es2panda_lib.cpp index 0934922474..c03b2eeac3 100644 --- a/ets2panda/public/es2panda_lib.cpp +++ b/ets2panda/public/es2panda_lib.cpp @@ -75,7 +75,7 @@ __attribute__((unused)) lexer::TokenType StrToToken(TokenTypeToStr const *table, return tp->token; } } - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } __attribute__((unused)) char const *TokenToStr(TokenTypeToStr const *table, lexer::TokenType token) @@ -86,7 +86,7 @@ __attribute__((unused)) char const *TokenToStr(TokenTypeToStr const *table, lexe return tp->str; } } - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } __attribute__((unused)) char *StringViewToCString(ArenaAllocator *allocator, util::StringView const sv) diff --git a/ets2panda/public/es2panda_lib_impl.inc.erb b/ets2panda/public/es2panda_lib_impl.inc.erb index 14da4443e9..a5e4c60dae 100644 --- a/ets2panda/public/es2panda_lib_impl.inc.erb +++ b/ets2panda/public/es2panda_lib_impl.inc.erb @@ -53,7 +53,7 @@ end %>::<%= name %>)0U; end %>::<%= name %>::<%= flag %>; % end default: - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } %end } @@ -93,7 +93,7 @@ end %>::<%= name %>::<%= flag %>: return Es2panda<%= name %>::<%= enum.name_to_upper_snake %>_<%= flag %>; % end default: - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } % end } diff --git a/ets2panda/scripts/assert_check.sh b/ets2panda/scripts/assert_check.sh new file mode 100755 index 0000000000..f681d6b7e5 --- /dev/null +++ b/ets2panda/scripts/assert_check.sh @@ -0,0 +1,43 @@ +#!/bin/bash +# 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. + +set -e + +target_dir=$1/"ets_frontend/ets2panda" +excluded_dirs=("lsp" "test" "driver" "bindings" "scripts") +excluded_file="$target_dir/util/es2pandaMacros.h" + +# Build exclude conditions for find +exclude_prune=() +for dir in "${excluded_dirs[@]}"; do + exclude_prune+=(-path "*/$dir" -o) +done +unset 'exclude_prune[${#exclude_prune[@]}-1]' # Remove last -o + +# Find and process files +found_entries=$(find "$target_dir" \ + -type d \( "${exclude_prune[@]}" \) -prune -o \ + -type f ! -path "$excluded_file" \ + -exec grep -HnwE 'ASSERT|UNREACHABLE' {} +) || true + +# Format output and exit +if [[ -n "$found_entries" ]]; then + echo "ERROR: Depricated macroses ASSERT or UNREACHABLE found." + echo "Please use ES2PANDA_ASSERT(_POS) or ES2PANDA_UNREACHABLE(_POS)." + echo "It's better to use *_POS version of macroses to specify position in source code." + echo "$found_entries" + exit 1 +else + exit 0 +fi \ No newline at end of file diff --git a/ets2panda/test/utils/scope_init_test.cpp b/ets2panda/test/utils/scope_init_test.cpp index 80aa4cdac7..496e71db64 100644 --- a/ets2panda/test/utils/scope_init_test.cpp +++ b/ets2panda/test/utils/scope_init_test.cpp @@ -1,5 +1,5 @@ /** - * Copyright (c) 2024 Huawei Device Co., Ltd. + * 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 @@ -14,6 +14,10 @@ */ #include "scope_init_test.h" +#include "ir/expression.h" +#include "ir/statements/blockStatement.h" +#include "ir/statements/variableDeclarator.h" +#include "ir/statements/variableDeclaration.h" namespace test::utils { diff --git a/ets2panda/util/bitset.h b/ets2panda/util/bitset.h index 0f99c6a604..92c0ad4cf4 100644 --- a/ets2panda/util/bitset.h +++ b/ets2panda/util/bitset.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * 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 @@ -16,7 +16,7 @@ #ifndef ES2PANDA_UTIL_INCLUDE_BITSET_H #define ES2PANDA_UTIL_INCLUDE_BITSET_H -#include "macros.h" +#include "util/es2pandaMacros.h" #include #include diff --git a/ets2panda/util/diagnostic.cpp b/ets2panda/util/diagnostic.cpp index 54bce79622..b232b43ab6 100644 --- a/ets2panda/util/diagnostic.cpp +++ b/ets2panda/util/diagnostic.cpp @@ -57,7 +57,7 @@ std::string Format(const DiagnosticMessageElement &elem) std::get(elem)->ToString(ss, nullptr, true); return ss.str(); } - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } std::string Format(const DiagnosticMessageParams &list) { @@ -162,12 +162,10 @@ const char *DiagnosticTypeToString(DiagnosticType type) return "Declgen ets2ts error"; case DiagnosticType::DECLGEN_ETS2TS_WARNING: return "Declgen ets2ts warning"; - case DiagnosticType::COMPILER_BUG: - return "Compiler bug"; case DiagnosticType::ARKTS_CONFIG_ERROR: return "ArkTS config error"; default: - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } diff --git a/ets2panda/util/diagnostic.h b/ets2panda/util/diagnostic.h index ea384128ab..9fb4d0227e 100644 --- a/ets2panda/util/diagnostic.h +++ b/ets2panda/util/diagnostic.h @@ -18,7 +18,7 @@ #include #include -#include "macros.h" +#include "util/es2pandaMacros.h" #include "util/ustring.h" #include "generated/tokenType.h" @@ -47,7 +47,6 @@ enum DiagnosticType { PLUGIN, DECLGEN_ETS2TS_ERROR, DECLGEN_ETS2TS_WARNING, - COMPILER_BUG, ARKTS_CONFIG_ERROR, COUNT, INVALID = COUNT diff --git a/ets2panda/util/diagnosticEngine.cpp b/ets2panda/util/diagnosticEngine.cpp index f8be0a540b..ed4235c3fe 100644 --- a/ets2panda/util/diagnosticEngine.cpp +++ b/ets2panda/util/diagnosticEngine.cpp @@ -20,13 +20,6 @@ #include -namespace ark::es2panda { -lexer::SourcePosition GetPositionForDiagnostic() -{ - return lexer::SourcePosition {}; -} -} // namespace ark::es2panda - namespace ark::es2panda::util { void CLIDiagnosticPrinter::Print(const DiagnosticBase &diagnostic) const @@ -78,11 +71,7 @@ void DiagnosticEngine::FlushDiagnostic() static void SigSegvHandler([[maybe_unused]] int sig) { - if (g_diagnosticEngine != nullptr) { - g_diagnosticEngine->FlushDiagnostic(); - } - std::cerr << "PLEASE submit a bug report to https://gitee.com/openharmony/arkcompiler_ets_frontend/issues" - << std::endl; + CompilerBugAction(lexer::SourcePosition {}); ark::PrintStack(ark::GetStacktrace(), std::cerr); std::abort(); // CC-OFF(G.STD.16-CPP) fatal error } @@ -104,13 +93,13 @@ bool DiagnosticEngine::IsAnyError() const noexcept const DiagnosticBase &DiagnosticEngine::GetAnyError() const { - ASSERT(IsAnyError()); + ES2PANDA_ASSERT(IsAnyError()); for (size_t i = DiagnosticType::BEGIN; i < DiagnosticType::COUNT; ++i) { if (IsError(static_cast(i)) && !diagnostics_[i].empty()) { return *diagnostics_[i].front(); } } - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } bool DiagnosticEngine::IsError(DiagnosticType type) const @@ -121,14 +110,13 @@ bool DiagnosticEngine::IsError(DiagnosticType type) const case DiagnosticType::SEMANTIC: case DiagnosticType::PLUGIN: case DiagnosticType::DECLGEN_ETS2TS_ERROR: - case DiagnosticType::COMPILER_BUG: case DiagnosticType::ARKTS_CONFIG_ERROR: return true; case DiagnosticType::WARNING: case DiagnosticType::DECLGEN_ETS2TS_WARNING: return wError_; default: - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } diff --git a/ets2panda/util/diagnosticEngine.h b/ets2panda/util/diagnosticEngine.h index 2319bcf396..1b89462d24 100644 --- a/ets2panda/util/diagnosticEngine.h +++ b/ets2panda/util/diagnosticEngine.h @@ -19,15 +19,11 @@ #include #include #include "es2panda.h" +#include "util/es2pandaMacros.h" #include "generated/diagnostic.h" -#include "macros.h" #include "util/diagnostic.h" #include "lexer/token/sourceLocation.h" -namespace ark::es2panda { -lexer::SourcePosition GetPositionForDiagnostic(); -} // namespace ark::es2panda - namespace ark::es2panda::util { class DiagnosticPrinter { @@ -103,11 +99,6 @@ public: { LogThrowableDiagnostic(DiagnosticType::WARNING, std::forward(args)...); } - template - void LogCompilerBug(T &&...args) - { - LogThrowableDiagnostic(DiagnosticType::COMPILER_BUG, std::forward(args)...); - } // NOTE(schernykh): should not be able from STS template @@ -168,31 +159,6 @@ private: bool wError_ {false}; }; -#ifndef NDEBUG -// CC-OFFNXT(G.PRE.06) solid logic -// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define ES2PANDA_ASSERT3(cond, position) \ - if (UNLIKELY(!(cond))) { \ - if (g_diagnosticEngine != nullptr) { \ - g_diagnosticEngine->LogCompilerBug(std::string_view {#cond}, position); \ - g_diagnosticEngine->FlushDiagnostic(); \ - } \ - ASSERT_FAIL(#cond); \ - } - -// CC-OFFNXT(G.PRE.06) solid logic -// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define ES2PANDA_ASSERT(cond) ES2PANDA_ASSERT3(cond, GetPositionForDiagnostic()) - -#else // NDEBUG -// CC-OFFNXT(G.PRE.06) solid logic -// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define ES2PANDA_ASSERT3(cond, position) static_cast(0) -// CC-OFFNXT(G.PRE.06) solid logic -// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define ES2PANDA_ASSERT(cond) static_cast(0) -#endif - } // namespace ark::es2panda::util #endif // ES2PANDA_UTIL_DIAGNOSTIC_ENGINE_H diff --git a/ets2panda/util/dtoa_helper.cpp b/ets2panda/util/dtoa_helper.cpp index 4c584ae5bb..05a259cf90 100644 --- a/ets2panda/util/dtoa_helper.cpp +++ b/ets2panda/util/dtoa_helper.cpp @@ -96,7 +96,7 @@ void DtoaHelper::GrisuRound(uint64_t delta, uint64_t rest, uint64_t tenKappa, ui constexpr auto MAX_DIGITS = 9; int DtoaHelper::CountDecimalDigit32(uint32_t n) { - ASSERT(n < POW10[MAX_DIGITS]); + ES2PANDA_ASSERT(n < POW10[MAX_DIGITS]); for (int i = 1; i < MAX_DIGITS; i++) { if (n < POW10[i]) { return i; @@ -146,17 +146,17 @@ uint32_t DtoaHelper::PopDigit(int kappa, uint32_t &p1) p1 = 0; break; default: - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } return d; } void DtoaHelper::DigitGen(const DiyFp &w, const DiyFp &mp, uint64_t delta) { - ASSERT(mp.e_ <= 0); + ES2PANDA_ASSERT(mp.e_ <= 0); const DiyFp one(uint64_t(1) << static_cast(-mp.e_), mp.e_); const DiyFp distance = mp - w; - ASSERT(one.e_ <= 0); + ES2PANDA_ASSERT(one.e_ <= 0); auto p1 = static_cast(mp.f_ >> static_cast(-one.e_)); uint64_t p2 = mp.f_ & (one.f_ - 1); int kappa = CountDecimalDigit32(p1); // kappa in [0, 9] @@ -214,7 +214,7 @@ void DtoaHelper::Dtoa(double value) { // Exceptional case such as NAN, 0.0, negative... are processed in DoubleToEcmaString // So use Dtoa should avoid Exceptional case. - ASSERT(value > 0); + ES2PANDA_ASSERT(value > 0); Grisu(value); point_ = length_ + k_; } diff --git a/ets2panda/util/dtoa_helper.h b/ets2panda/util/dtoa_helper.h index e588849ddf..2a5fbac26f 100644 --- a/ets2panda/util/dtoa_helper.h +++ b/ets2panda/util/dtoa_helper.h @@ -20,7 +20,7 @@ #include #include #include "globals.h" -#include "macros.h" +#include "util/es2pandaMacros.h" // Almost copy of ets_runtime/ecmascript/base/dtoa_helper.h @@ -167,7 +167,7 @@ private: DiyFp pl = DiyFp((f_ << 1U) + 1, e_ - 1).NormalizeBoundary(); DiyFp mi = (f_ == DOUBLE_HIDDEN_BIT) ? DiyFp((f_ << 2U) - 1, e_ - 2) : DiyFp((f_ << 1U) - 1, e_ - 1); // 2: parameter - ASSERT(mi.e_ >= pl.e_); + ES2PANDA_ASSERT(mi.e_ >= pl.e_); mi.f_ <<= static_cast(mi.e_ - pl.e_); mi.e_ = pl.e_; *plus = pl; diff --git a/ets2panda/util/errorRecovery.cpp b/ets2panda/util/errorRecovery.cpp index e392b4f357..a273b81217 100644 --- a/ets2panda/util/errorRecovery.cpp +++ b/ets2panda/util/errorRecovery.cpp @@ -1,5 +1,5 @@ /** - * Copyright (c) 2024 Huawei Device Co., Ltd. + * 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 @@ -26,7 +26,7 @@ ErrorRecursionGuard::~ErrorRecursionGuard() lexer_->NextToken(); } } catch (...) { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } diff --git a/ets2panda/util/es2pandaMacros.cpp b/ets2panda/util/es2pandaMacros.cpp new file mode 100644 index 0000000000..a24c73da57 --- /dev/null +++ b/ets2panda/util/es2pandaMacros.cpp @@ -0,0 +1,51 @@ +/** + * 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. + */ + +#include "util/es2pandaMacros.h" +#include "util/diagnosticEngine.h" +#include "util/options.h" +#include "parser/program/program.h" + +namespace ark::es2panda { +lexer::SourcePosition GetPositionForDiagnostic() +{ + return lexer::SourcePosition {}; +} + +void CompilerBugAction(const lexer::SourcePosition &position) +{ + if (g_diagnosticEngine != nullptr) { + g_diagnosticEngine->FlushDiagnostic(); + } + + std::cerr << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"; + std::cerr << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"; + std::cerr << std::endl; + + std::cerr << "es2panda unexpectedly terminated"; + auto program = position.Program(); + if (program != nullptr) { + auto loc = position.ToLocation(); + std::cerr << " during processing [" << util::BaseName(program->SourceFilePath().Utf8()); + std::cerr << ":" << loc.line << ":" << loc.col << "]"; + } + std::cerr << "." << std::endl; + + std::cerr << "PLEASE submit a bug report to "; + std::cerr << "https://gitee.com/openharmony/arkcompiler_ets_frontend/issues"; + std::cerr << " and include the crash backtrace, source code and associated run script. "; + std::cerr << std::endl; +} +} // namespace ark::es2panda diff --git a/ets2panda/util/es2pandaMacros.h b/ets2panda/util/es2pandaMacros.h new file mode 100644 index 0000000000..cc0990c7b5 --- /dev/null +++ b/ets2panda/util/es2pandaMacros.h @@ -0,0 +1,68 @@ +/** + * 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. + */ + +#ifndef ES2PANDA_UTIL_ES2PANDA_MACROS_H +#define ES2PANDA_UTIL_ES2PANDA_MACROS_H + +#include "macros.h" +#include "lexer/token/sourceLocation.h" +namespace ark::es2panda::parser { +class Program; +} // namespace ark::es2panda::parser + +namespace ark::es2panda { +lexer::SourcePosition GetPositionForDiagnostic(); +void CompilerBugAction(const lexer::SourcePosition &pos); +} // namespace ark::es2panda + +#ifndef NDEBUG +// CC-OFFNXT(G.PRE.06) solid logic +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) +#define ES2PANDA_ASSERT_POS(cond, position) \ + if (UNLIKELY(!(cond))) { \ + ark::es2panda::CompilerBugAction(position); \ + ASSERT_FAIL(#cond); \ + } + +// CC-OFFNXT(G.PRE.06) solid logic +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) +#define ES2PANDA_ASSERT(cond) ES2PANDA_ASSERT_POS(cond, GetPositionForDiagnostic()) + +// CC-OFFNXT(G.PRE.06) solid logic +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) +#define ES2PANDA_UNREACHABLE_POS(position) \ + ark::es2panda::CompilerBugAction(position); \ + UNREACHABLE() + +// CC-OFFNXT(G.PRE.06, G.PRE.09) solid logic +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) +#define ES2PANDA_UNREACHABLE() ES2PANDA_UNREACHABLE_POS(GetPositionForDiagnostic()) + +#else // NDEBUG +// CC-OFFNXT(G.PRE.06) solid logic +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) +#define ES2PANDA_ASSERT_POS(cond, position) static_cast(0) +// CC-OFFNXT(G.PRE.06) solid logic +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) +#define ES2PANDA_ASSERT(cond) static_cast(0) +// CC-OFFNXT(G.PRE.06) solid logic +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) +#define ES2PANDA_UNREACHABLE_POS(position) __builtin_unreachable() +// CC-OFFNXT(G.PRE.06) solid logic +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) +#define ES2PANDA_UNREACHABLE() __builtin_unreachable() +#endif + +#endif // ES2PANDA_UTIL_ES2PANDA_MACROS_H diff --git a/ets2panda/util/helpers.cpp b/ets2panda/util/helpers.cpp index e1524a56c7..b816c8c780 100644 --- a/ets2panda/util/helpers.cpp +++ b/ets2panda/util/helpers.cpp @@ -81,7 +81,7 @@ util::StringView Helpers::LiteralToPropName(const ir::Expression *lit) return "undefined"; } default: { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } } diff --git a/ets2panda/util/language.h b/ets2panda/util/language.h index be4761c081..b1fa99a1f4 100644 --- a/ets2panda/util/language.h +++ b/ets2panda/util/language.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * 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 @@ -22,7 +22,7 @@ #include #include -#include "libpandabase/macros.h" +#include "util/es2pandaMacros.h" namespace ark::es2panda { @@ -46,7 +46,7 @@ public: } } - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } static std::optional FromString(std::string_view str) @@ -73,7 +73,7 @@ public: } } - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } bool operator==(const Language &l) const diff --git a/ets2panda/util/plugin.h b/ets2panda/util/plugin.h index 67f3825ff3..a09113ac0b 100644 --- a/ets2panda/util/plugin.h +++ b/ets2panda/util/plugin.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * 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 @@ -15,7 +15,7 @@ #ifndef ES2PANDA_UTIL_PLUGINS_H #define ES2PANDA_UTIL_PLUGINS_H -#include "macros.h" +#include "util/es2pandaMacros.h" #include "os/library_loader.h" #include "public/es2panda_lib.h" #include "util/ustring.h" diff --git a/ets2panda/util/ustring.h b/ets2panda/util/ustring.h index 34df05dacb..3e98a8fb47 100644 --- a/ets2panda/util/ustring.h +++ b/ets2panda/util/ustring.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * 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 @@ -16,7 +16,7 @@ #ifndef ES2PANDA_UTIL_INCLUDE_USTRING_H #define ES2PANDA_UTIL_INCLUDE_USTRING_H -#include "macros.h" +#include "util/es2pandaMacros.h" #include "utils/arena_containers.h" #include diff --git a/ets2panda/varbinder/ETSBinder.cpp b/ets2panda/varbinder/ETSBinder.cpp index dc744b8472..fba408bfec 100644 --- a/ets2panda/varbinder/ETSBinder.cpp +++ b/ets2panda/varbinder/ETSBinder.cpp @@ -970,7 +970,7 @@ ArenaVector ETSBinder::GetExternalProgram(const util::StringV { if (sourceName == ERROR_LITERAL) { // avoid logging rediculus messages, there must be a syntax error - ASSERT(GetContext()->diagnosticEngine->IsAnyError()); + ES2PANDA_ASSERT(GetContext()->diagnosticEngine->IsAnyError()); return ArenaVector(Allocator()->Adapter()); } // NOTE: quick fix to make sure not to look for the global program among the external sources @@ -1025,7 +1025,7 @@ void ETSBinder::AddSpecifiersToTopBindings(ir::AstNode *const specifier, const i auto item1 = std::find_if(selectMap2->second.begin(), selectMap2->second.end(), predicateFunc1); if (item1 != selectMap2->second.end()) { auto item2 = globalBindings.find(item1->first); - ASSERT(item2 != globalBindings.end()); + ES2PANDA_ASSERT(item2 != globalBindings.end()); specifier->AsImportDefaultSpecifier()->Local()->SetVariable(item2->second); InsertForeignBinding(specifier, import, specifier->AsImportDefaultSpecifier()->Local()->Name(), item2->second); diff --git a/ets2panda/varbinder/declaration.h b/ets2panda/varbinder/declaration.h index 350e5eed54..4398773e35 100644 --- a/ets2panda/varbinder/declaration.h +++ b/ets2panda/varbinder/declaration.h @@ -17,7 +17,7 @@ #define ES2PANDA_COMPILER_SCOPES_DECLARATION_H #include "varbinder/variableFlags.h" -#include "macros.h" +#include "util/es2pandaMacros.h" #include "util/diagnosticEngine.h" #include "util/ustring.h" diff --git a/ets2panda/varbinder/recordTable.h b/ets2panda/varbinder/recordTable.h index a1e7221e9c..9fce896bc6 100644 --- a/ets2panda/varbinder/recordTable.h +++ b/ets2panda/varbinder/recordTable.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * 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 @@ -16,7 +16,7 @@ #ifndef ES2PANDA_VARBINDER_RECORDTABLE_H #define ES2PANDA_VARBINDER_RECORDTABLE_H -#include "macros.h" +#include "util/es2pandaMacros.h" #include "utils/arena_containers.h" #include "util/ustring.h" #include "util/enumbitops.h" diff --git a/ets2panda/varbinder/scope.cpp b/ets2panda/varbinder/scope.cpp index 2860377a0a..4957c2f066 100644 --- a/ets2panda/varbinder/scope.cpp +++ b/ets2panda/varbinder/scope.cpp @@ -457,7 +457,7 @@ Variable *FunctionParamScope::AddBinding([[maybe_unused]] ArenaAllocator *alloca [[maybe_unused]] Variable *currentVariable, [[maybe_unused]] Decl *newDecl, [[maybe_unused]] ScriptExtension extension) { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } Variable *AnnotationParamScope::AddBinding([[maybe_unused]] ArenaAllocator *allocator, @@ -579,7 +579,7 @@ Scope::InsertResult GlobalScope::TryInsertBinding(const util::StringView &name, void GlobalScope::MergeBindings([[maybe_unused]] const VariableMap &bindings) { - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } Scope::VariableMap::size_type GlobalScope::EraseBinding(const util::StringView &name) @@ -961,7 +961,7 @@ void ClassScope::SetBindingProps(Decl *newDecl, BindingProps *props, bool isStat break; default: - UNREACHABLE(); + ES2PANDA_UNREACHABLE(); } } -- Gitee