diff --git a/ets2panda/BUILD.gn b/ets2panda/BUILD.gn index d416ad788af64d1feee0731594780347ab229064..fbb7b049945cd6cac782161bd0651f3c6b029de2 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 6b2b87fad94651d32f220c0d095fd79fc1c8d359..e07fe05d8b296702e4abe4acd0514b33399b028b 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 3dcc24ffd24ada9d2a7592c482250772fe4f1d84..cf14965ca2c8c0be8aecbd49c4ff26c6fdbb1bc3 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 e917c2ec5e85cc6f4cc33455f741d7e07d7a84d6..3c7fd517e87b6fd1da4ce43a74d3a33bc1c46349 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 a29d5ca198f33c266f558d497b0ce315ec8e45a4..f0c54c5924a652d64c423ffd410dab66ffa7ed0d 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 478b6bb799f0b9c0e623d9573a715512afb495dc..6b68293395d7c26972743678d3ee87806c0e0c18 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 1ab907e2da44af4ecc4dbb594b954bead4c402c5..125e291bfe04b6639c2efa5f80205e2fa23c6d87 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 af6dedfb03097909f27f9538e6aa83cd606cbadb..b4993e16668979ab001c1a45cc59332e9d1a993c 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 2ab3269279761de46dbf2b6786b845d1457f53ca..ac489d0448fd4bc5f50d3143bdf355c4dabc3540 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 9f7ccf3ed7df665a6792fedd179298094abe38c2..65c8e1027a9f483ac59e179c8d991bf92f349c9e 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 ffd92dfd061e0936c777e052b7d4246df7473d15..9e08b1e46e32a4fae19e8436d5f7be1a5c9d491e 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 b5ce9dce58aa64d5a7a0ed690530a1c23f14544e..f0e115a8ea158accde9e8d0b3fdfe56e73e71df8 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 b0f1361a5043949261f5ea2d16d34084763b6abc..73bdbf791dac700f807624552061fe4c6563def6 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 e3576d924aa4cf4a238f1e96c71fa30a7e5553d6..20003630a7a1209552b236310d0d78dce6e494fe 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 581160f71956d077c4f333df7fd905b753627df4..68d09f28c40deffd3bbd1f9b9e40759129f7c2a0 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 b7c25333a707eab9a04bef87e51d57ff456666a9..19f9e141382ff96c4fce4f6e28d068221d4b241e 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 657c99eb3af60f6a25a6500425245742d80af9b0..b0308a8ff0af26953151c248bc2e95e3eee1741e 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 ed2be72a2c9f461a6e88e410bd3d426512369cd4..55badd2535177575933f7e56f0ae34b120c8dffe 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 a5ef57e129a66ce185d7721b9d2f3313c0b97028..101e14ba1838523f1ffddab37cd2877f8305d2ae 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 3a0ddfbd7867fa8912a7f4cb6157585ede045755..408ddcb599c137bb4834be26ba2fb53dc45abfc3 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 8c10b9170cca63dc4869eee59bd115586f49deb3..e3b958cf6d07fb6c177e4f1c5d254c80e687d921 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 b6f17a29a40fdbd65ec227a9677e9b4cfce95519..e017996260d4ac5bef4ace78ee3fbeb12d03df02 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 4f2d4ce25a4e532420e410870913cb6b8121df37..e4419c3f8c3e31d2890a36cf00d8249525e94ec9 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 7585c5345048c0184832949427bc2bb2339a6760..1762795939461a9115a2af76b31d4aa29f4d85e6 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 8aff5f7d1991cdd6d19de82ddbd3058451144014..275c3459d37ffed73949da56676b6894e0d0699b 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 8a5c0303d134b48a2fa245a2d24e454e095cee34..191e54e33dbf5200535857e86027b978cd1ebcac 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 1f454eece969c4f568423b4038e6e3ef85204640..db327f239f12f2e6d47453581f3ba1c37bda284e 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 eb489bd61706a02d7e562718612967a55e628d68..d3a880af3776558633d49761fab59db0c7d2ba17 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 b112df060d4effc9c371a8742cc123eeeffe6361..e6fa4f3806db7b714a20035be823f3450bffd459 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 86d49369d0cd322d2fd9d8dceca5768ac49fad74..6e102e16751ae3c4b039af93f2d5a8278a34a2de 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 a97a942ac346db5fdec54cc416bf89dc96e6274c..9a84a669601e35045330020d501ed1e410dc295b 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 d4546021f80bae0b09c686a3bd148dfd649716ac..60b2c20e27f725cb6e7442bb613426d8a400ec07 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 b1772fbd4fb4ebb493c7f1953fa6ae95e3ddf031..ceed788dbbd9ab2d7a247c391e1540ecef1124e9 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 4598c7f04f048a9593b88a191c9fdd4746323d1e..d616adb638d7050392fdc10c54daeee046fa25fe 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 f14417c1f707e915c2b77cac1198803d748c7fcc..5a126fd4da5fc0bb841c53ed8b661012cd7a924b 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 94054af236f011f1e303874e477ced6a8a8b1b92..82f695644d9361bda793aa2bfb088480ff08df7e 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 686db7292782e724d577476b83e3f334682483a7..9cd7d90b86fa8627ef6cf66220b84e3cfd85956f 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 096deaa07781707eb699e401394313df46a9053f..eb6106ec4fdb3f9574a2312d16a50e12cdf82228 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 b3253037feb8b9acc843d082d82312d6eb1b4a5a..948ea1be837f3943863bc4ee3f645f011224461a 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 110ebac6ada0e4642d0f306cafb60d8e70399bbd..489132498b96b8cea31058d19fe3654da1c928ba 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 88c4e1839ec708a526c20a787ceddf5511075e6f..48bab0c0d66c81d5f0161ccf41a6e29cfaaa55ba 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 e938cd25e5b4a5d3bda2c76a41767af2561f71c9..d2b2570654d4a61274d582657bd18180fd60c9b1 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 9f0c7cf28ef7c5c8b9aef066540a4ce169ea3912..29ac5ceb21322215ccc9156a3fe8a6ec741ce216 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 808b8bf6719fb7339d046cac24a39ea7df0b2b1e..de548d52ede22fed2e87f790b77c79d1b212755d 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 d678810b54e1f86863fc6fe7c5d6c35e6979e794..558de23457778172f845f9ff022a969de9d9c465 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 b778962cfeca749cfd46d76039a65d78d6f7c1b5..04c6858835861257f39d6ea79dc0353f5b5ff10a 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 fdd65ae915f2e496f1ae347a44b2ab62d6a22de7..0955afb391b4131367d19de402ac600af0c3e3d0 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 f22cb82eedb1bb37ee019e16ad885068174a02b4..4edd9d31b25ace531738391744a03630fe79e6ea 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 42bb80d441f38d944c9fffc877dcd816ae9ca934..b7cb2f00d379e2ab4919d2b95f84cdef55f2b2b2 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 cfad289dd27985e673a41fb3cdcf7900c62f0382..6fc674be5ed24142712fc569596a62944ea71356 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 d9914fdd4e193910b027da7c4658fdc5c3541c12..8c4925497da89abff5d3320b527839018b437938 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 a3b320e9b7c62fed4dc76f07c00d2a8a4b04806c..fd01a1c9f22233b98eef8ca278a813014eea0587 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 bf75a14f180f35ca010e4e8749d0a4d9bfd8da76..46e0e901dd8b3853cdfb099b19e30e8a17be2e7b 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 6e01f85c0fa00401f8f5cc6c58d3428e38baac8e..7bc948033b789a599bd49c62855efe59c8e2e059 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 d09918f019827b1cd674c75e36004da0cd0a7804..22eee1a0c7c03b25ed1726df6c361100c451d131 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 6216e4031fd657fa7325105efad053739a283cde..2cb7dab7bab2555969ca818fe8822caa84bf98dd 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 dde7e2cba2cbb7150c2841be122cabd615243568..bf0978abe2ebac743662ac5cab6bf9ab61bbd1cb 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 76fe1b479829582ec1e31e0091bee04e56cbe716..dc09dbdaa12a0f87aa5286da8a07283c9e8a6f66 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 59d6fb8b1a18daa294ad25b9522cbeda25cb8ef5..85ab16b5455323a15f78a485dab62313595ce5a3 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 6cec50e0b24ad698381572fbc3c117cf4e27a1c2..ba4176d6d3495ab05547778d30f5735c4887f127 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 54f69868c565aa4e8bdd62ddcb0c34b94d5c40ba..59e31f6525b86c119ee225492b3c10aa52bee445 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 febac89d37e5db5a95ebf6ef3cb78b816579b167..2f48a9a674721672c9b08917471833c38ca41fa7 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 55b102c6f1e54984fb66d6f8dfc2cd7d2cc43c80..40e5e48ec788cfc5aa2243a9db02ca382bbda5ec 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 3b3d2fe862cdb76ea721f5107bc3a9b485260038..14466b33ff5912450ff15a6363ec41b5a864d5b4 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 14bbc4af933627341da5090c65422731fe92e988..d8a8e763778ba66256623d054950dbf48a769d8b 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 d48d65210cf8ac7286399a640c9dc53020a2dce8..f51e14e13eac4f0efb8b8f501ea09e881ce7fc65 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 bc94f6844b0f9518d7a0c827a3837e3164c101c4..9ee90387c4d10e979198cd5997dbd63e37fb7098 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 53051197b21edf780f6afa20732e7c73780a7284..bd8f029ad9d506ee36d0571b3c14515aefc22480 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 b0ddba96f6a860d279cada33f216bc05cc29d57d..fe653a07f201359a5073daac4392758903ad363b 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 512fec1e71b0ce7f94abb122b90a01f1b0633bc5..20251e50fe1bd012e653b80ab1239f6dd31b7af0 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 e1e390025c99890f37927c249eab9d63f76c3b1b..adbfec0e629fa4f6b865ae2ee97d31d2554e93ed 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 39608cee0e6aae6213389811f7470606d4abd0a3..d87fc777fd5283328aa9c22b3f21b944ac3cc7c2 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 82dfb3ed0b63df8c2458a88b8d0e52394c1bb7a3..98a79a181889dd5cad514a9816bc7bb300a305b1 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 cfbcab4cfb029c5dec9f2bfb3ada5a098ac9bdd5..2e80b18777222e922247eed8eddf6453952b85d1 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 6fbddca27810d33a4435847186cb7f0872377ddc..3e2d877307b68ac3e4eb383a123956c226164cb2 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 e72b4b4aad741250d8334708daf6f359f9a9deff..5153b0be11153d366b260cee6078f846923e0c3b 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 531cbf3ef1208eaba6ea1076f01b8425552131c6..9ea6bcb12381dcf887088a9be53553f3d5284b90 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 dd82fcd5df45b0707db80ad43ce7e7fcc69ec22b..ba8bbc3d6b74fa28c344e01c49d30bd85b3327b7 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 dafda7c642a07943899f47d7ce7474303edff7ca..00d6d3f6a58f6618ad200ab6a929082e726a699d 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 dd6093db5f6cfee3b97d5ca594d0aa1bda8575fb..f8049254cab2f4cfb5d39b3bd06c7567e94869b9 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 8644401aac900a11e811ae5600c57541db7886e4..3faa6a83d179e84d4b3bcc50e4de23ff3ecb50e2 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 c2aadf1f9a4589125f72f828674afecef70bd1ea..51e521c13efa6cd6371843165ef0d7438131af03 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 144b540ec286a154e3a4196b3c64b1805f65d875..fef9cb106c37b4a383e0262fa6ebb4294de6155b 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 6df33d8f616490e1e60d49d2decf129ec3d6ed46..68bf807f024ba6d3693250ce6b4c3ed82aefb63b 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 e64cef837703d3aa2780e5251637bcb3130992bf..b4a995a5e7c96eba120dde33aa2b69608a07e3a2 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 95cf5790c4e7c99aebc9f4b3f6100b999e1a5c45..643b6325cc0e83118afe60ed180ac94f2393724f 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 9344b17585831b02d8af3e5c572e4496920cee82..8f09ce229261f772a9c83296926e913006f1888e 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 dee69ef4fc1244a0ab57fdd021a90c6b5a71e024..a66d8f472e2f716b5ef2f6c1f4d94e58a6f33c74 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 32cf5fa4d10f291e8a5c40cef720290a8763569e..bd18a2294f5f581e4108cd4dcf10fec42d2262a2 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 21a2f12c8302ab981fa9bdb251d1a792a2b50495..210e57abe749f7ef195e04c110c61f6ae9a4a157 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 254eb09c365322f88f5607726b848cf4b8ff0d7e..dd4766d19c0d7b751bbaefa2e06dc22943ab0d34 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 54cc7f8e9ec261221aa2a2f456034c0495207075..ca16da8b35cd26c0d4de52cc35f4e4d2ac9e40d7 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 c9b3d53e21c84e7528f269ef08035dbedd51b5aa..4e1ea33c3661ea5773ce386cc43fe9752ad91495 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 0168fb5fb8d9eb4b986f1f9770caee62cb86df76..63015a8368d2346351677afc64370649f1084e48 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 30ef3dbf05a77bb4b4105ff668ccc188fd3a3fad..27dff275cb1148850f39bb1d80f65ef61dd26c24 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 be90b9bc489f89d73540a8174190c59905f89059..fcb85de1329aba2e26539357685305794696c3d4 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 d9a507018cd50a7c4f1de34e52ebae50a5b25e97..7320f52a010299c90f82d02c0d54a398fc149e0b 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 bf7b5ca5c0e282c5b74bef5fb7b0af6bfeecf1e0..24deab39d0e1c4e3e62e9051620e2a3bbd23259e 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 cfb9d692c2e63956b73b4f2881835bf2a03485bf..79284dd1f72e3bf37538f07f13547c9a08a41bbd 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 2416452565c3c9168923066ce22a61c3bff20e3e..e3e9e7983678fd1e341b4ef1e288950800243472 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 b1ad5810ab5485ef157b07cc41e807db24b5fb77..6072a259e350baa2758602de839e6d1db2aa3ec1 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 d49b522416876b98f971ef65af8abb43966f602e..0d7b9d4157819010f7b198affd06fb3c09062b81 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 dfa14e13a4f87709aec7420cea7f4e9ff7d9a8ee..c18f74350262d4994bce708bdd606cfcf57c1501 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 221270198f17c6c80fecc4ac59ce7cf13b176274..d6227f2673e079f710a6e1bb7661a3a91c444be0 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 ef6e503517a7b85861f6fc59aa07ee6e477831d2..f583cd4c6a84851838a88d987d0825baf3349f6b 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 108ee7ad3f30ee525c8754acdec65d3a3898eb94..23ad522af5798d2b78fd327e9b35f48b26897a37 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 5705568106eca8d4979dbe9c9a35fb5f75eaa1e1..c38cb577107be65d90d5b14663582df782b9d698 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 2b1ef78d78dd781625520be87cbc4a63b8dcb94f..7a2c2267dc72abe8fa480caac1cbbf7340f4a3f2 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 0c578843a4f59c36ea23b423d1507787e28693c8..c0168d5f04a7b2f4282f424d08dd71c58271325d 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 957d3f38a03adad4765419c923b4c7f51f34d4be..05fb588e2bb7b3bdedef47794f07f9d439389fe4 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 66b04432ff9ae5667e94455032534bc45b94f258..11e04243c25bdab66ac27e8e4816f23a61fa6b6f 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 34f6d0713f65df55979a17d3c48c68b9d0145917..bf462a5ef82f2054aa4a56e04806ad34187cf4a0 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 189859d0ec15c4436443bbfb555b9e2bf2467264..58e70f28f5e02b7c4451ebc2e36d8f0c09376e1c 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 2e30ae157cdaea0cfe5f0dbb9a0192eb8f169f5b..9436f75696f297a3a274ff248d40a1d1eaefdadc 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 af02f0402e071955a097b044980a755f50323d2f..912dd11f40e02c16def7bf72aa490607a2a316e2 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 b65c3eed1e58d1fbad11da42f835f9419a6e83b0..1396aa3bec52ebda32d2c9fb22fb1b7673634b10 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 ceffffa95b370d6ec08d93700a60670c4c9de233..d641ae4397bef3f240afecf80054796b25d7cb39 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 208632efe11589ed14b66e0f4e500e3d1a7ff04f..8ac91f09600b40c42b2fcb7302589562b7290a53 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 3ea5dbc46e7808b42d28e088d2e09531f8e8d023..5bdc886393ced88805b5fd6d7e863bba745f40a8 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 0c6028f2357433c9c04c59ca070345fb72e05dd7..467ecd8201793ed24fdfc8fdd7f742c75797709f 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 952c66836b96a334523acbd9c4581418b6906123..33964b1c72bccf54af18f1e13426b89d50102cc8 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 a8eacb2e948372c1eec8569c4d5c195798df5a62..5b185634598696b995e7e7fa49bbdf4912b5cd69 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 170893833af45f1938594f31f1534c9a34d1e3a3..b93d472d52357bea2c3e8d7494820c8ea9835f29 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 296acb498405b8fc89ef1f7cd58eb286d6daf7ca..a72ffa3bbee39ace85e342e3ebf0678dbaf24a39 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 fd61b9e3c83c41defead939f6808a915bafb542e..9c1bc3bb42f7237c7bf92bccf5855140626b1819 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 8bc813b66f6c6efe50a1a25971d2be2e0e29e1c4..60efc1500e09d08bb3811d8aa032919681abefb3 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 df07d2d9802c580d81a18a958720ddd92ebf04b0..8c4262f2d4dc51f6cfa94ad856c84484f4b9edcc 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 20afa7dc63aee5ac55aefb7418775160c4d9a6a1..a150a8cfb08cebc09bff2457f506559a42776780 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 52e8cc81943f0d41b940a41da942e9d8c372d996..2f9ef0b1942b92dac585794832b5d59d6f215978 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 11dfc8744901ce10f656c8db6631e4a7fe9a4faf..df8c4480a1dfb676e6c67d7506dcbe67ffa753eb 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 7c2f6c9962e3c020470310899c1d599914ce730c..cfefa287b75e442fbdbebf19731df0da96a14327 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 92c23db4cc9a95fc5df1d11e82549c8d615ac531..a220fbbc42f4468aa82ccf9aa6394f8f2b787ea6 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 f44c94b6cac6e521846ea9fb74ca199e0c24d7ce..f7b8179fd7bd1bbb72f16abfe3155b6ecc7114c5 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 4a2109f37dc738d41d7dbaf32d1ac2195bda03b9..5d20261b6cde5f169b2a1216a20702e97eb9aa2e 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 43acc3081e7afcafa813c3de5a695fba73a351c6..c64b36c8a7b3082092ce73c4fd890d9e2174b4fa 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 524bd9b2acb3530d24b219a6ac3b2e69aa589572..cf654dad81a9f614349a3a0fdb93e86215bfa683 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 a307c3b5cbcf3488c28e7061bc6e0743efe23d7a..1f2e9998f235de84d6fe294e103e3e80616c7ecc 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 c9b819c84775d97b652edf142eb38205f2e2a0cf..818391e1284e2ef088f612270ca4d6a81495ba90 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 79e3bed7dbdbe1c38212ae5ae4c90a3f00f49e2f..ea12cfac28d801d7c5df323cdf4577a52b1d518f 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 e76f2e6099fdacfc3f3235dddade3302719f3776..7c9343b387ee12f8985f814834aac8bd02523623 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 ec1fb2ccf0d8ba74913c39a585a4f95f94c5803a..86f1232891b4b65215fc1c02150c7d4c820c46f2 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 1ba97bae827e868f2baa15850716eb5d121156dc..13842bd184e7b02a6e4468e31347aacc8ea8c885 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 e074172a62ad1a24ed63ae548d7687d0ff274b71..b5b04374ba4741fe5e44bca7a30e6d30ecaaa79d 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 225b823c6e3b681a390fc20566ad2cf9b060fb09..e8f64ffc46900ce165d1f94ac2c7ace714da9649 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 36523fb4aa7afb57e58761a82abadbcf211d7bf0..f63d1f41566a01d1f05e6add1d921eabaec299bf 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 15583f140bff89894dcc42df571acc7d39f8d77f..b0a687a82303a0e7bc1adfa0ec197962fb5dae11 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 09349224741b1862bb06e8379facdb21b225f52e..c03b2eeac33c0b7a67565ad8455cf5226cc05999 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 14da4443e9b3c5c1f54baadb75d1b684e7abda28..a5e4c60dae8b555444c66aef3601c52b7eba40ae 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 0000000000000000000000000000000000000000..f681d6b7e57ecba83cc8a178203313bf7b0f8540 --- /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 80aa4cdac7a73b7940d2d9356f4f15e4012d7a66..496e71db6443665ed32dd796cbf80642bbf041ce 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 0f99c6a604b64d471e8ce9e7ccb28d96eee56655..92c0ad4cf4869252d8533f1b2fb40b2b1916f86f 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 54bce79622c1a2932d4b3d1754bda93385cb7645..b232b43ab67401bf113b30f49c78ef763a4d0208 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 ea384128ab110bf3feff4904d498366d45866e42..9fb4d0227e767510e4014eb806609f9089ea7cf6 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 f8be0a540b6923205353643a7aa3544d3def2682..ed4235c3fe0d528949eb797cec8e720537a44443 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 2319bcf396cd016cd5d4cc56113b9cad92f74ee4..1b89462d241d69ac48ccd129babd1411569e714b 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 4c584ae5bb2ffecf4af6d80d4f8bac69af610adf..05a259cf9013d3c16e634c6fcd9d70b29f4bf1cb 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 e588849ddf84b4226467d9072ade51dcc7bf3e5c..2a5fbac26f5adb60e8843f6664e53faebddd5815 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 e392b4f357e0a5df54cbc63f351f96e9685b9e27..a273b812179e76d17b918e1f36cd1dea0b648625 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 0000000000000000000000000000000000000000..a24c73da57da9b18b2555911874b56e76fa48f99 --- /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 0000000000000000000000000000000000000000..cc0990c7b5768973d1159ca7af31193b5bcfa31d --- /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 e1524a56c7162a0315c0218af1a0eba371ff598b..b816c8c780901bf58f7aec781ca8a4c8e2ba5cbe 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 be4761c081e4f6da57aa708894f10a0898eb8073..b1fa99a1f41f71d49e40be0f7a6db5e0223528e7 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 67f3825ff3fd5283a27bb4cb81b32133860fc052..a09113ac0bba9e43c372ef2d764fbf14889fe7ac 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 34df05dacba3b5a0632da50ecdef402303c1cb2b..3e98a8fb47001dad7616fcf6f6df22ee9b063db5 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 dc744b84720a163be0c3ac7975cfc71be486e82c..fba408bfec1a2eb88ccbc4b5469fb10756cf15cb 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 350e5eed54800f6af23ae03f0f2e8116df6e4ba2..4398773e35519d75d847c32ecd4755b5385d5e70 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 a1e7221e9c2a430e54344984d41957e3281293dc..9fce896bc6d7c915e0797824cb86c4b5614ba29d 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 2860377a0a7358d178ed7aff757e4af5d704b026..4957c2f066a776b348ca5d88e52321319ac12cca 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(); } }