diff --git a/libabckit/src/ir_impl.cpp b/libabckit/src/ir_impl.cpp index 08e86cfc47..bf9315dbf7 100644 --- a/libabckit/src/ir_impl.cpp +++ b/libabckit/src/ir_impl.cpp @@ -923,7 +923,7 @@ AbckitGraphApi g_graphApiImpl = { extern "C" AbckitGraphApi const *AbckitGetGraphApiImpl(AbckitApiVersion version) { #ifdef ABCKIT_ENABLE_MOCK_IMPLEMENTATION - // return mock api + return AbckitGetMockGraphApiImpl(version); #endif switch (version) { case ABCKIT_VERSION_RELEASE_1_0_0: diff --git a/libabckit/src/isa_dynamic_impl.cpp b/libabckit/src/isa_dynamic_impl.cpp index 9948f6a0f0..0b8e05f152 100644 --- a/libabckit/src/isa_dynamic_impl.cpp +++ b/libabckit/src/isa_dynamic_impl.cpp @@ -237,7 +237,7 @@ AbckitIsaApiDynamic g_isaApiDynamicImpl = { extern "C" AbckitIsaApiDynamic const *AbckitGetIsaApiDynamicImpl(AbckitApiVersion version) { #ifdef ABCKIT_ENABLE_MOCK_IMPLEMENTATION - // return mock api + return AbckitGetMockIsaApiDynamicImpl(version); #endif switch (version) { case ABCKIT_VERSION_RELEASE_1_0_0: diff --git a/libabckit/src/isa_static_impl.cpp b/libabckit/src/isa_static_impl.cpp index 67bb9ee1c1..f85dc3cdd1 100644 --- a/libabckit/src/isa_static_impl.cpp +++ b/libabckit/src/isa_static_impl.cpp @@ -896,7 +896,7 @@ AbckitIsaApiStatic g_isaApiStaticImpl = { extern "C" AbckitIsaApiStatic const *AbckitGetIsaApiStaticImpl(AbckitApiVersion version) { #ifdef ABCKIT_ENABLE_MOCK_IMPLEMENTATION - // return mock api + return AbckitGetMockIsaApiStaticImpl(version); #endif switch (version) { case ABCKIT_VERSION_RELEASE_1_0_0: diff --git a/libabckit/src/metadata_arkts_inspect_impl.cpp b/libabckit/src/metadata_arkts_inspect_impl.cpp index 5b8bcfc5b7..267b022983 100644 --- a/libabckit/src/metadata_arkts_inspect_impl.cpp +++ b/libabckit/src/metadata_arkts_inspect_impl.cpp @@ -594,7 +594,7 @@ void ArkTSAnnotationInterfaceEnumerateFields(AbckitCoreAnnotationInterface *ai, extern "C" AbckitArktsInspectApi const *AbckitGetArktsInspectApiImpl(AbckitApiVersion version) { #ifdef ABCKIT_ENABLE_MOCK_IMPLEMENTATION - // return mock api + return AbckitGetMockArktsInspectApiImpl(version); #endif switch (version) { case ABCKIT_VERSION_RELEASE_1_0_0: diff --git a/libabckit/src/metadata_arkts_modify_impl.cpp b/libabckit/src/metadata_arkts_modify_impl.cpp index 007554d842..9d332ecc4c 100644 --- a/libabckit/src/metadata_arkts_modify_impl.cpp +++ b/libabckit/src/metadata_arkts_modify_impl.cpp @@ -442,7 +442,7 @@ AbckitArktsModifyApi g_arktsModifyApiImpl = { extern "C" AbckitArktsModifyApi const *AbckitGetArktsModifyApiImpl(AbckitApiVersion version) { #ifdef ABCKIT_ENABLE_MOCK_IMPLEMENTATION - // return mock api + return AbckitGetMockArktsModifyApiImpl(version); #endif switch (version) { case ABCKIT_VERSION_RELEASE_1_0_0: diff --git a/libabckit/src/metadata_inspect_impl.cpp b/libabckit/src/metadata_inspect_impl.cpp index c0e65163c0..82ab86cc61 100644 --- a/libabckit/src/metadata_inspect_impl.cpp +++ b/libabckit/src/metadata_inspect_impl.cpp @@ -1445,7 +1445,7 @@ AbckitInspectApi g_inspectApiImpl = { extern "C" AbckitInspectApi const *AbckitGetInspectApiImpl(AbckitApiVersion version) { #ifdef ABCKIT_ENABLE_MOCK_IMPLEMENTATION - // return mock api + return AbckitGetMockInspectApiImpl(version); #endif switch (version) { case ABCKIT_VERSION_RELEASE_1_0_0: diff --git a/libabckit/src/metadata_modify_impl.cpp b/libabckit/src/metadata_modify_impl.cpp index 54359ef9bc..915069aae1 100644 --- a/libabckit/src/metadata_modify_impl.cpp +++ b/libabckit/src/metadata_modify_impl.cpp @@ -471,7 +471,7 @@ AbckitModifyApi g_modifyApiImpl = { extern "C" AbckitModifyApi const *AbckitGetModifyApiImpl(AbckitApiVersion version) { #ifdef ABCKIT_ENABLE_MOCK_IMPLEMENTATION - // return mock api + return AbckitGetMockModifyApiImpl(version); #endif switch (version) { case ABCKIT_VERSION_RELEASE_1_0_0: diff --git a/libabckit/src/mock/abckit_mock.h b/libabckit/src/mock/abckit_mock.h index b91a8d8ac3..1be3a83e5e 100644 --- a/libabckit/src/mock/abckit_mock.h +++ b/libabckit/src/mock/abckit_mock.h @@ -20,10 +20,21 @@ #include #include "../../include/c/abckit.h" +#include "../../include/c/metadata_core.h" +#include "../../include/c/isa/isa_dynamic.h" +#include "../../src/include_v2/c/isa/isa_static.h" +#include "../../include/c/extensions/arkts/metadata_arkts.h" // CC-OFFNXT(G.NAM.01) false positive extern std::queue g_calledFuncs; AbckitApi const *AbckitGetMockApiImpl(AbckitApiVersion version); +AbckitInspectApi const *AbckitGetMockInspectApiImpl(AbckitApiVersion version); +AbckitModifyApi const *AbckitGetMockModifyApiImpl(AbckitApiVersion version); +AbckitIsaApiDynamic const *AbckitGetMockIsaApiDynamicImpl(AbckitApiVersion version); +AbckitIsaApiStatic const *AbckitGetMockIsaApiStaticImpl(AbckitApiVersion version); +AbckitArktsInspectApi const *AbckitGetMockArktsInspectApiImpl(AbckitApiVersion version); +AbckitArktsModifyApi const *AbckitGetMockArktsModifyApiImpl(AbckitApiVersion version); +AbckitGraphApi const *AbckitGetMockGraphApiImpl(AbckitApiVersion version); #endif diff --git a/libabckit/src/mock/mock_values.h b/libabckit/src/mock/mock_values.h index 47950a929a..14a7058907 100644 --- a/libabckit/src/mock/mock_values.h +++ b/libabckit/src/mock/mock_values.h @@ -29,58 +29,125 @@ // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define DEFAULT_U32 0x11111111 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) +#define DEFAULT_I32 0x11111112 +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define DEFAULT_U64 0x1111111122222222 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) +#define DEFAULT_I64 0x1111111122222223 +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define DEFAULT_SIZE_T 0x1111111133333333 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) -#define DEFAULT_FILE ((AbckitFile *)0xdeadffff) +#define DEFAULT_ENUM_ABCKIT_ISA_TYPE (enum AbckitInst()) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) -#define DEFAULT_GRAPH ((AbckitGraph *)0xdeadeeee) +#define DEFAULT_ENUM_ISA_TYPE AbckitIsaType::ABCKIT_ISA_TYPE_UNSUPPORTED // NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) -#define DEFAULT_VOID ((void *)0xdead0001) +#define DEFAULT_ENUM_ISA_DYNAMIC_CONDITION_TYPE \ + AbckitIsaApiDynamicConditionCode::ABCKIT_ISA_API_DYNAMIC_CONDITION_CODE_CC_NONE // NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) -#define DEFAULT_CB ((void *)0xdead0002) +#define DEFAULT_ENUM_ISA_API_DYNAMIC_OPCODE AbckitIsaApiDynamicOpcode::ABCKIT_ISA_API_DYNAMIC_OPCODE_INVALID // NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) -#define DEFAULT_CORE_MODULE ((AbckitCoreModule *)0xdead0003) +#define DEFAULT_ENUM_ISA_STATIC_CONDITION_CODE \ + AbckitIsaApiStaticConditionCode::ABCKIT_ISA_API_STATIC_CONDITION_CODE_CC_NONE // NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) -#define DEFAULT_TARGET ((AbckitTarget)0xdead0004) +#define DEFAULT_ENUM_TYPE_ID AbckitTypeId::ABCKIT_TYPE_ID_INVALID // NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) -#define DEFAULT_STRING ((AbckitString *)0xdead0005) +#define DEFAULT_ENUM_ISA_API_STATIC_OPCODE AbckitIsaApiStaticOpcode::ABCKIT_ISA_API_STATIC_OPCODE_INVALID // NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) -#define DEFAULT_CORE_NAMESPACE ((AbckitCoreNamespace *)0xdead0006) +#define DEFAULT_TYPE_ID AbckitTypeId::ABCKIT_TYPE_ID_INVALID // NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) -#define DEFAULT_CORE_IMPORT_DESCRIPTOR ((AbckitCoreImportDescriptor *)0xdead0006) +#define DEFAULT_TARGET AbckitTarget::ABCKIT_TARGET_UNKNOWN // NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) -#define DEFAULT_CORE_EXPORT_DESCRIPTOR ((AbckitCoreExportDescriptor *)0xdead0007) +#define DEFAULT_LITERAL_TAG AbckitLiteralTag::ABCKIT_LITERAL_TAG_INVALID // NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) -#define DEFAULT_CORE_CLASS ((AbckitCoreClass *)0xdead0008) +#define DEFAULT_FILE (reinterpret_cast(0xdeadffff)) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) -#define DEFAULT_CORE_ANNOTATION_INTERFACE ((AbckitCoreAnnotationInterface *)0xdead0009) +#define DEFAULT_GRAPH (reinterpret_cast(0xdeadeeee)) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) -#define DEFAULT_CORE_ANNOTATION_INTERFACE_FIELD ((AbckitCoreAnnotationInterfaceField *)0xdead0010) +#define DEFAULT_VOID (reinterpret_cast(0xdead0001)) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) -#define DEFAULT_VALUE ((AbckitValue *)0xdead0011) +#define DEFAULT_CB (reinterpret_cast(0xdead0002)) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) -#define DEFAULT_CORE_FUNCTION ((AbckitCoreFunction *)0xdead0012) +#define DEFAULT_CORE_MODULE (reinterpret_cast(0xdead0003)) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) -#define DEFAULT_CORE_ANNOTATION ((AbckitCoreAnnotation *)0xdead0013) +#define DEFAULT_STRING (reinterpret_cast(0xdead0005)) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) -#define DEFAULT_CORE_ANNOTATION_ELEMENT ((AbckitCoreAnnotationElement *)0xdead0014) +#define DEFAULT_CORE_NAMESPACE (reinterpret_cast(0xdead0006)) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) -#define DEFAULT_TYPE_ID ((AbckitTypeId)0xdead0015) +#define DEFAULT_CORE_IMPORT_DESCRIPTOR (reinterpret_cast(0xdead0006)) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) -#define DEFAULT_DOUBLE ((double)0xdead0016) +#define DEFAULT_CORE_EXPORT_DESCRIPTOR (reinterpret_cast(0xdead0007)) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) -#define DEFAULT_LITERAL_ARRAY ((AbckitLiteralArray *)0xdead0017) +#define DEFAULT_CORE_CLASS (reinterpret_cast(0xdead0008)) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) -#define DEFAULT_LITERAL ((AbckitLiteral *)0xdead0018) +#define DEFAULT_CORE_ANNOTATION_INTERFACE (reinterpret_cast(0xdead0009)) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) -#define DEFAULT_LITERAL_TAG ((AbckitLiteralTag)0xdead0019) +#define DEFAULT_CORE_ANNOTATION_INTERFACE_FIELD (reinterpret_cast(0xdead0010)) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) -#define DEFAULT_FLOAT ((float)0xdead0020) +#define DEFAULT_VALUE (reinterpret_cast(0xdead0011)) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) -#define DEFAULT_TYPE ((AbckitType *)0xdead0021) +#define DEFAULT_CORE_FUNCTION (reinterpret_cast(0xdead0012)) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) -#define DEFAULT_FILE_VERSION ((AbckitFileVersion)0xdead0022) +#define DEFAULT_CORE_ANNOTATION (reinterpret_cast(0xdead0013)) +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) +#define DEFAULT_CORE_ANNOTATION_ELEMENT (reinterpret_cast(0xdead0014)) +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) +#define DEFAULT_DOUBLE (static_cast(0xdead0016)) +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) +#define DEFAULT_LITERAL_ARRAY (reinterpret_cast(0xdead0017)) +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) +#define DEFAULT_LITERAL (reinterpret_cast(0xdead0018)) +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) +#define DEFAULT_FLOAT (static_cast(0xdead0020)) +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) +#define DEFAULT_TYPE (reinterpret_cast(0xdead0021)) +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) +#define DEFAULT_FILE_VERSION (reinterpret_cast(0xdead0022)) +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) +#define DEFAULT_BB (reinterpret_cast(0xdead0023)) +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) +#define DEFAULT_INST (reinterpret_cast(0xdead0024)) +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) +#define DEFAULT_ABCKIT_TYPE (reinterpret_cast(0xdead0026)) +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) +#define DEFAULT_MODULE (reinterpret_cast(0xdead00027)) +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) +#define DEFAULT_NAMESPACE (reinterpret_cast(0xdead00028)) +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) +#define DEFAULT_IMPORT_DESCRIPTOR (reinterpret_cast(0xdead00029)) +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) +#define DEFAULT_FUNCTION (reinterpret_cast(0xdead00030)) +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) +#define DEFAULT_EXPORT_DESCRIPTOR (reinterpret_cast(0xdead00030)) +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) +#define DEFAULT_CLASS (reinterpret_cast(0xdead0031)) +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) +#define DEFAULT_ANNOTATION (reinterpret_cast(0xdead0032)) +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) +#define DEFAULT_ANNOTATION_ELEMENT (reinterpret_cast(0xdead0033)) +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) +#define DEFAULT_ANNOTATION_INTERFACE (reinterpret_cast(0xdead00034)) +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) +#define DEFAULT_ANNOTATION_INTERFACE_FIELD (reinterpret_cast(0xdead0035)) +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) +#define DEFAULT_STRUCT_ARKTS_V1_EXTERNAL_MODULE_CREATE_PARAMS \ + (reinterpret_cast(0xdead0039)) +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) +#define DEFAULT_STRUCT_ARKTS_IMPORT_FROM_DYNAMIC_CREATE_PARAMS \ + (reinterpret_cast(0xdead0039)) +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) +#define DEFAULT_STRUCT_ARKTS_DYNAMIC_MODULE_EXPORT_CREATE_PARAMS \ + (reinterpret_cast(0xdead0039)) +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) +#define DEFAULT_STRUCT_ARKTS_ANNOTATION_INTERFACE_CREATE_PARAMS \ + (reinterpret_cast(0xdead0039)) +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) +#define DEFAULT_STRUCT_ARKTS_ANNOTATION_CREATE_PARAMS \ + (reinterpret_cast(0xdead0039)) +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) +#define DEFAULT_STRUCT_ARKTS_ANNOTATION_INTERFACE_FIELD_CREATE_PARAMS \ + (reinterpret_cast(0xdead0039)) +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage, cppcoreguidelines-pro-type-cstyle-cast) +#define DEFAULT_STRUCT_ARKTS_ANNOTATION_ELEMENT_CREATE_PARAMS \ + (reinterpret_cast(0xdead0039)) #endif // ABCKIT_MOCK_GLOBAL_VALUES diff --git a/libabckit/tests/BUILD.gn b/libabckit/tests/BUILD.gn index 462ce7afe0..b8553e46d8 100644 --- a/libabckit/tests/BUILD.gn +++ b/libabckit/tests/BUILD.gn @@ -409,7 +409,14 @@ libabckit_host_unittest_action("abckit_mock_gtests") { sources = [ # mock infrastructure "mock/abckit_api_mock.cpp", + "mock/arkts_inspect_api_impl_mock.cpp", + "mock/arkts_modify_api_impl_mock.cpp", "mock/check_mock.cpp", + "mock/graph_api_impl_mock.cpp", + "mock/isa_api_dynamic_impl_mock.cpp", + "mock/isa_api_static_impl_mock.cpp", + "mock/metadata_inspect_impl_mock.cpp", + "mock/metadata_modify_impl_mock.cpp", #mock tests "mock/tests/cpp_mock_file.cpp", diff --git a/libabckit/tests/mock/abckit_api_mock.cpp b/libabckit/tests/mock/abckit_api_mock.cpp index 2ae9a81f9a..21a2277291 100644 --- a/libabckit/tests/mock/abckit_api_mock.cpp +++ b/libabckit/tests/mock/abckit_api_mock.cpp @@ -16,7 +16,6 @@ #include "mock/abckit_mock.h" #include "mock/mock_values.h" -#include "include/c/metadata_core.h" #include "include/c/statuses.h" #include "include/c/abckit.h" @@ -26,32 +25,32 @@ namespace libabckit::mock { // NOLINTBEGIN(readability-identifier-naming) -inline AbckitStatus getLastError() +inline AbckitStatus GetLastError() { return ABCKIT_STATUS_NO_ERROR; } -inline AbckitFile *openAbc(const char *path) +inline AbckitFile *OpenAbc(const char *path) { g_calledFuncs.push(__func__); EXPECT_TRUE(strncmp(path, DEFAULT_PATH, sizeof(DEFAULT_PATH)) == 0); return DEFAULT_FILE; } -inline void writeAbc(AbckitFile *file, const char *path) +inline void WriteAbc(AbckitFile *file, const char *path) { g_calledFuncs.push(__func__); EXPECT_TRUE(strncmp(path, DEFAULT_PATH, sizeof(DEFAULT_PATH)) == 0); EXPECT_TRUE(file == DEFAULT_FILE); } -inline void closeFile(AbckitFile *file) +inline void CloseFile(AbckitFile *file) { g_calledFuncs.push(__func__); EXPECT_TRUE(file == DEFAULT_FILE); } -inline void destroyGraph(AbckitGraph *graph) +inline void DestroyGraph(AbckitGraph *graph) { g_calledFuncs.push(__func__); EXPECT_TRUE(graph == DEFAULT_GRAPH); @@ -65,23 +64,25 @@ static AbckitApi g_impl = { // ======================================== ABCKIT_VERSION_RELEASE_1_0_0, - getLastError, + GetLastError, // ======================================== // Inspection API entrypoints // ======================================== - openAbc, - writeAbc, - closeFile, + OpenAbc, + WriteAbc, + CloseFile, // ======================================== // IR API entrypoints // ======================================== - destroyGraph, + DestroyGraph, }; +// NOLINTEND(readability-identifier-naming) + } // namespace libabckit::mock AbckitApi const *AbckitGetMockApiImpl([[maybe_unused]] AbckitApiVersion version) diff --git a/libabckit/tests/mock/arkts_inspect_api_impl_mock.cpp b/libabckit/tests/mock/arkts_inspect_api_impl_mock.cpp new file mode 100644 index 0000000000..37f3d252b2 --- /dev/null +++ b/libabckit/tests/mock/arkts_inspect_api_impl_mock.cpp @@ -0,0 +1,305 @@ +/* + * Copyright (c) 2024 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 "../../src/mock/abckit_mock.h" +#include "../../src/mock/mock_values.h" + +#include "../include/c/extensions/arkts/metadata_arkts.h" +#include "../../include/c/metadata_core.h" + +#include +#include + +namespace libabckit::mock { + +// NOLINTBEGIN(readability-identifier-naming) + +inline AbckitCoreModule *ArktsModuleToCoreModule(AbckitArktsModule *m) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(m == DEFAULT_MODULE); + return DEFAULT_CORE_MODULE; +} + +inline AbckitArktsModule *CoreModuleToArktsModule(AbckitCoreModule *m) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(m == DEFAULT_CORE_MODULE); + return DEFAULT_MODULE; +} + +inline AbckitCoreNamespace *ArktsNamespaceToCoreNamespace(AbckitArktsNamespace *ns) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(ns == DEFAULT_NAMESPACE); + return DEFAULT_CORE_NAMESPACE; +} + +inline AbckitArktsNamespace *CoreNamespaceToArktsNamespace(AbckitCoreNamespace *ns) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(ns == DEFAULT_CORE_NAMESPACE); + return DEFAULT_NAMESPACE; +} + +inline AbckitArktsFunction *ArktsV1NamespaceGetConstructor(AbckitArktsNamespace *ns) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(ns == DEFAULT_NAMESPACE); + return DEFAULT_FUNCTION; +} + +inline AbckitCoreImportDescriptor *ArktsImportDescriptorToCoreImportDescriptor(AbckitArktsImportDescriptor *id) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(id == DEFAULT_IMPORT_DESCRIPTOR); + return DEFAULT_CORE_IMPORT_DESCRIPTOR; +} + +inline AbckitArktsImportDescriptor *CoreImportDescriptorToArktsImportDescriptor(AbckitCoreImportDescriptor *id) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(id == DEFAULT_CORE_IMPORT_DESCRIPTOR); + return DEFAULT_IMPORT_DESCRIPTOR; +} + +inline AbckitCoreExportDescriptor *ArktsExportDescriptorToCoreExportDescriptor(AbckitArktsExportDescriptor *ed) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(ed == DEFAULT_EXPORT_DESCRIPTOR); + return DEFAULT_CORE_EXPORT_DESCRIPTOR; +} + +inline AbckitArktsExportDescriptor *CoreExportDescriptorToArktsExportDescriptor(AbckitCoreExportDescriptor *ed) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(ed == DEFAULT_CORE_EXPORT_DESCRIPTOR); + return DEFAULT_EXPORT_DESCRIPTOR; +} + +inline AbckitCoreClass *ArktsClassToCoreClass(AbckitArktsClass *klass) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(klass == DEFAULT_CLASS); + return DEFAULT_CORE_CLASS; +} + +inline AbckitArktsClass *CoreClassToArktsClass(AbckitCoreClass *klass) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(klass == DEFAULT_CORE_CLASS); + return DEFAULT_CLASS; +} + +inline AbckitCoreFunction *ArktsFunctionToCoreFunction(AbckitArktsFunction *function) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(function == DEFAULT_FUNCTION); + return DEFAULT_CORE_FUNCTION; +} + +inline AbckitArktsFunction *CoreFunctionToArktsFunction(AbckitCoreFunction *function) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(function == DEFAULT_CORE_FUNCTION); + return DEFAULT_FUNCTION; +} + +inline bool FunctionIsNative(AbckitArktsFunction *function) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(function == DEFAULT_FUNCTION); + return DEFAULT_BOOL; +} + +inline AbckitCoreAnnotation *ArktsAnnotationToCoreAnnotation(AbckitArktsAnnotation *anno) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(anno == DEFAULT_ANNOTATION); + return DEFAULT_CORE_ANNOTATION; +} + +inline AbckitArktsAnnotation *CoreAnnotationToArktsAnnotation(AbckitCoreAnnotation *anno) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(anno == DEFAULT_CORE_ANNOTATION); + return DEFAULT_ANNOTATION; +} + +inline AbckitCoreAnnotationElement *ArktsAnnotationElementToCoreAnnotationElement( + AbckitArktsAnnotationElement *annoElem) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(annoElem == DEFAULT_ANNOTATION_ELEMENT); + return DEFAULT_CORE_ANNOTATION_ELEMENT; +} + +inline AbckitArktsAnnotationElement *CoreAnnotationElementToArktsAnnotationElement( + AbckitCoreAnnotationElement *annoElem) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(annoElem == DEFAULT_CORE_ANNOTATION_ELEMENT); + return DEFAULT_ANNOTATION_ELEMENT; +} + +inline AbckitCoreAnnotationInterface *ArktsAnnotationInterfaceToCoreAnnotationInterface( + AbckitArktsAnnotationInterface *annoInterface) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(annoInterface == DEFAULT_ANNOTATION_INTERFACE); + return DEFAULT_CORE_ANNOTATION_INTERFACE; +} + +inline AbckitArktsAnnotationInterface *CoreAnnotationInterfaceToArktsAnnotationInterface( + AbckitCoreAnnotationInterface *annoInterface) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(annoInterface == DEFAULT_CORE_ANNOTATION_INTERFACE); + return DEFAULT_ANNOTATION_INTERFACE; +} + +inline AbckitCoreAnnotationInterfaceField *ArktsAnnotationInterfaceFieldToCoreAnnotationInterfaceField( + AbckitArktsAnnotationInterfaceField *annoInterfaceField) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(annoInterfaceField == DEFAULT_ANNOTATION_INTERFACE_FIELD); + return DEFAULT_CORE_ANNOTATION_INTERFACE_FIELD; +} + +inline AbckitArktsAnnotationInterfaceField *CoreAnnotationInterfaceFieldToArktsAnnotationInterfaceField( + AbckitCoreAnnotationInterfaceField *annoInterfaceField) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(annoInterfaceField == DEFAULT_CORE_ANNOTATION_INTERFACE_FIELD); + return DEFAULT_ANNOTATION_INTERFACE_FIELD; +} + +AbckitArktsInspectApi g_arktsInspectApiImpl = { + // ======================================== + // File + // ======================================== + + // ======================================== + // Module + // ======================================== + + ArktsModuleToCoreModule, CoreModuleToArktsModule, + + /* ======================================== + * Namespace + * ======================================== */ + + ArktsNamespaceToCoreNamespace, CoreNamespaceToArktsNamespace, ArktsV1NamespaceGetConstructor, + + // ======================================== + // ImportDescriptor + // ======================================== + + ArktsImportDescriptorToCoreImportDescriptor, CoreImportDescriptorToArktsImportDescriptor, + + // ======================================== + // ExportDescriptor + // ======================================== + + ArktsExportDescriptorToCoreExportDescriptor, CoreExportDescriptorToArktsExportDescriptor, + + // ======================================== + // Class + // ======================================== + + ArktsClassToCoreClass, CoreClassToArktsClass, + + // ======================================== + // Function + // ======================================== + + ArktsFunctionToCoreFunction, CoreFunctionToArktsFunction, FunctionIsNative, + + // ======================================== + // Annotation + // ======================================== + + ArktsAnnotationToCoreAnnotation, CoreAnnotationToArktsAnnotation, + + // ======================================== + // AnnotationElement + // ======================================== + + ArktsAnnotationElementToCoreAnnotationElement, CoreAnnotationElementToArktsAnnotationElement, + + // ======================================== + // AnnotationInterface + // ======================================== + + ArktsAnnotationInterfaceToCoreAnnotationInterface, CoreAnnotationInterfaceToArktsAnnotationInterface, + + // ======================================== + // AnnotationInterfaceField + // ======================================== + + ArktsAnnotationInterfaceFieldToCoreAnnotationInterfaceField, + CoreAnnotationInterfaceFieldToArktsAnnotationInterfaceField, + + // ======================================== + // Type + // ======================================== + + // ======================================== + // Value + // ======================================== + + // ======================================== + // String + // ======================================== + + // ======================================== + // LiteralArray + // ======================================== + + // ======================================== + // Literal + // ======================================== +}; + +// NOLINTEND(readability-identifier-naming) + +} // namespace libabckit::mock + +AbckitArktsInspectApi const *AbckitGetMockArktsInspectApiImpl([[maybe_unused]] AbckitApiVersion version) +{ + return &libabckit::mock::g_arktsInspectApiImpl; +} diff --git a/libabckit/tests/mock/arkts_modify_api_impl_mock.cpp b/libabckit/tests/mock/arkts_modify_api_impl_mock.cpp new file mode 100644 index 0000000000..105aea882f --- /dev/null +++ b/libabckit/tests/mock/arkts_modify_api_impl_mock.cpp @@ -0,0 +1,228 @@ +/* + * Copyright (c) 2024 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 "../../src/mock/abckit_mock.h" +#include "../../src/mock/mock_values.h" + +#include "../../include/c/extensions/arkts/metadata_arkts.h" + +#include +#include + +namespace libabckit::mock { + +// NOLINTBEGIN(readability-identifier-naming) + +inline AbckitArktsModule *FileAddExternalModuleArktsV1(AbckitFile *file, + const struct AbckitArktsV1ExternalModuleCreateParams *params) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(file == DEFAULT_FILE); + EXPECT_TRUE(params == DEFAULT_STRUCT_ARKTS_V1_EXTERNAL_MODULE_CREATE_PARAMS); + return DEFAULT_MODULE; +} + +inline AbckitArktsImportDescriptor *ModuleAddImportFromArktsV1ToArktsV1( + AbckitArktsModule *importing, AbckitArktsModule *imported, + const struct AbckitArktsImportFromDynamicModuleCreateParams *params) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(importing == DEFAULT_MODULE); + EXPECT_TRUE(imported == DEFAULT_MODULE); + EXPECT_TRUE(params == DEFAULT_STRUCT_ARKTS_IMPORT_FROM_DYNAMIC_CREATE_PARAMS); + return DEFAULT_IMPORT_DESCRIPTOR; +} + +inline void ModuleRemoveImport(AbckitArktsModule *m, AbckitArktsImportDescriptor *id) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(m == DEFAULT_MODULE); + EXPECT_TRUE(id == DEFAULT_IMPORT_DESCRIPTOR); +} + +inline AbckitArktsExportDescriptor *ModuleAddExportFromArktsV1ToArktsV1( + AbckitArktsModule *exporting, AbckitArktsModule *exported, + const struct AbckitArktsDynamicModuleExportCreateParams *params) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(exporting == DEFAULT_MODULE); + EXPECT_TRUE(exported == DEFAULT_MODULE); + EXPECT_TRUE(params == DEFAULT_STRUCT_ARKTS_DYNAMIC_MODULE_EXPORT_CREATE_PARAMS); + return DEFAULT_EXPORT_DESCRIPTOR; +} + +inline void ModuleRemoveExport(AbckitArktsModule *m, AbckitArktsExportDescriptor *ed) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(m == DEFAULT_MODULE); + EXPECT_TRUE(ed == DEFAULT_EXPORT_DESCRIPTOR); +} + +inline AbckitArktsAnnotationInterface *ModuleAddAnnotationInterface( + AbckitArktsModule *m, const struct AbckitArktsAnnotationInterfaceCreateParams *params) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(m == DEFAULT_MODULE); + EXPECT_TRUE(params == DEFAULT_STRUCT_ARKTS_ANNOTATION_INTERFACE_CREATE_PARAMS); + return DEFAULT_ANNOTATION_INTERFACE; +} + +inline AbckitArktsAnnotation *ClassAddAnnotation(AbckitArktsClass *klass, + const struct AbckitArktsAnnotationCreateParams *params) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(klass == DEFAULT_CLASS); + EXPECT_TRUE(params == DEFAULT_STRUCT_ARKTS_ANNOTATION_CREATE_PARAMS); + return DEFAULT_ANNOTATION; +} + +inline void ClassRemoveAnnotation(AbckitArktsClass *klass, AbckitArktsAnnotation *anno) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(klass == DEFAULT_CLASS); + EXPECT_TRUE(anno == DEFAULT_ANNOTATION); +} + +inline AbckitArktsAnnotationInterfaceField *AnnotationInterfaceAddField( + AbckitArktsAnnotationInterface *ai, const struct AbckitArktsAnnotationInterfaceFieldCreateParams *params) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(ai == DEFAULT_ANNOTATION_INTERFACE); + EXPECT_TRUE(params == DEFAULT_STRUCT_ARKTS_ANNOTATION_INTERFACE_FIELD_CREATE_PARAMS); + return DEFAULT_ANNOTATION_INTERFACE_FIELD; +} + +inline void AnnotationInterfaceRemoveField(AbckitArktsAnnotationInterface *ai, + AbckitArktsAnnotationInterfaceField *field) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(ai == DEFAULT_ANNOTATION_INTERFACE); + EXPECT_TRUE(field == DEFAULT_ANNOTATION_INTERFACE_FIELD); +} + +inline AbckitArktsAnnotation *FunctionAddAnnotation(AbckitArktsFunction *function, + const struct AbckitArktsAnnotationCreateParams *params) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(function == DEFAULT_FUNCTION); + EXPECT_TRUE(params == DEFAULT_STRUCT_ARKTS_ANNOTATION_CREATE_PARAMS); + return DEFAULT_ANNOTATION; +} + +inline void FunctionRemoveAnnotation(AbckitArktsFunction *function, AbckitArktsAnnotation *anno) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(function == DEFAULT_FUNCTION); + EXPECT_TRUE(anno == DEFAULT_ANNOTATION); +} + +inline AbckitArktsAnnotationElement *AnnotationAddAnnotationElement( + AbckitArktsAnnotation *anno, struct AbckitArktsAnnotationElementCreateParams *params) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(anno == DEFAULT_ANNOTATION); + EXPECT_TRUE(params == DEFAULT_STRUCT_ARKTS_ANNOTATION_ELEMENT_CREATE_PARAMS); + return DEFAULT_ANNOTATION_ELEMENT; +} + +inline void AnnotationRemoveAnnotationElement(AbckitArktsAnnotation *anno, AbckitArktsAnnotationElement *elem) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(anno == DEFAULT_ANNOTATION); + EXPECT_TRUE(elem == DEFAULT_ANNOTATION_ELEMENT); +} + +AbckitArktsModifyApi g_arktsModifyApiImpl = { + + // ======================================== + // File + // ======================================== + + FileAddExternalModuleArktsV1, + + // ======================================== + // Module + // ======================================== + + ModuleAddImportFromArktsV1ToArktsV1, ModuleRemoveImport, ModuleAddExportFromArktsV1ToArktsV1, ModuleRemoveExport, + ModuleAddAnnotationInterface, + + // ======================================== + // Class + // ======================================== + + ClassAddAnnotation, ClassRemoveAnnotation, + + // ======================================== + // AnnotationInterface + // ======================================== + + AnnotationInterfaceAddField, AnnotationInterfaceRemoveField, + + // ======================================== + // Function + // ======================================== + + FunctionAddAnnotation, FunctionRemoveAnnotation, + + // ======================================== + // Annotation + // ======================================== + + AnnotationAddAnnotationElement, AnnotationRemoveAnnotationElement, + + // ======================================== + // Type + // ======================================== + + // ======================================== + // Value + // ======================================== + + // ======================================== + // String + // ======================================== + + // ======================================== + // LiteralArray + // ======================================== + + // ======================================== + // LiteralArray + // ======================================== +}; + +// NOLINTEND(readability-identifier-naming) + +} // namespace libabckit::mock + +AbckitArktsModifyApi const *AbckitGetMockArktsModifyApiImpl([[maybe_unused]] AbckitApiVersion version) +{ + return &libabckit::mock::g_arktsModifyApiImpl; +} diff --git a/libabckit/tests/mock/graph_api_impl_mock.cpp b/libabckit/tests/mock/graph_api_impl_mock.cpp new file mode 100644 index 0000000000..b559bf9c61 --- /dev/null +++ b/libabckit/tests/mock/graph_api_impl_mock.cpp @@ -0,0 +1,834 @@ +/* + * Copyright (c) 2024 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 "../../src/mock/abckit_mock.h" +#include "../../src/mock/mock_values.h" + +#include +#include + +namespace libabckit::mock { + +// NOLINTBEGIN(readability-identifier-naming) + +inline enum AbckitIsaType GgetIsa(AbckitGraph *graph) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + return DEFAULT_ENUM_ISA_TYPE; +} + +inline AbckitFile *GgetFile(AbckitGraph *graph) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + return DEFAULT_FILE; +} + +inline AbckitBasicBlock *GgetStartBasicBlock(AbckitGraph *graph) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + return DEFAULT_BB; +} + +inline AbckitBasicBlock *GgetEndBasicBlock(AbckitGraph *graph) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + return DEFAULT_BB; +} + +inline uint32_t GgetNumberOfBasicBlocks(AbckitGraph *graph) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + return DEFAULT_U32; +} + +inline void GvisitBlocksRpo(AbckitGraph *graph, void *data, void (*cb)(AbckitBasicBlock *basicBlock, void *data)) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + (void)data; + cb(DEFAULT_BB, data); +} + +inline AbckitBasicBlock *GgetBasicBlock(AbckitGraph *graph, uint32_t id) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(id == DEFAULT_U32); + return DEFAULT_BB; +} + +inline AbckitInst *GgetParameter(AbckitGraph *graph, uint32_t index) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(index == DEFAULT_U32); + return DEFAULT_INST; +} + +inline uint32_t GgetNumberOfParameters(AbckitGraph *graph) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + return DEFAULT_U32; +} + +inline void GinsertTryCatch(AbckitBasicBlock *tryFirstBB, AbckitBasicBlock *tryLastBB, AbckitBasicBlock *catchBeginBB, + AbckitBasicBlock *catchEndBB) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(tryFirstBB == DEFAULT_BB); + EXPECT_TRUE(tryLastBB == DEFAULT_BB); + EXPECT_TRUE(catchBeginBB == DEFAULT_BB); + EXPECT_TRUE(catchEndBB == DEFAULT_BB); +} + +inline void Gdump(AbckitGraph *graph, int32_t fd) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(fd == DEFAULT_I32); +} + +inline AbckitInst *GcreateConstantI32(AbckitGraph *graph, int32_t value) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(value == DEFAULT_I32); + return DEFAULT_INST; +} + +inline AbckitInst *GcreateConstantI64(AbckitGraph *graph, int64_t value) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(value == DEFAULT_I64); + return DEFAULT_INST; +} + +inline AbckitInst *GcreateConstantU64(AbckitGraph *graph, uint64_t value) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(value == DEFAULT_U64); + return DEFAULT_INST; +} + +inline AbckitInst *GcreateConstantF64(AbckitGraph *graph, double value) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(value == DEFAULT_DOUBLE); + return DEFAULT_INST; +} + +inline void GrunPassRemoveUnreachableBlocks(AbckitGraph *graph) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); +} + +inline AbckitBasicBlock *BBCreateEmpty(AbckitGraph *graph) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + return DEFAULT_BB; +} + +inline uint32_t BBGetId(AbckitBasicBlock *basicBlock) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(basicBlock == DEFAULT_BB); + return DEFAULT_U32; +} + +inline AbckitGraph *BBGetGraph(AbckitBasicBlock *basicBlock) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(basicBlock == DEFAULT_BB); + return DEFAULT_GRAPH; +} + +inline uint64_t BBGetPredBlockCount(AbckitBasicBlock *basicBlock) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(basicBlock == DEFAULT_BB); + return DEFAULT_I64; +} + +inline AbckitBasicBlock *BBGetPredBlock(AbckitBasicBlock *basicBlock, uint32_t index) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(basicBlock == DEFAULT_BB); + EXPECT_TRUE(index == DEFAULT_U32); + return DEFAULT_BB; +} + +inline void BBVisitPredBlocks(AbckitBasicBlock *basicBlock, void *data, + void (*cb)(AbckitBasicBlock *predBasicBlock, void *data)) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(basicBlock == DEFAULT_BB); + (void)data; + cb(DEFAULT_BB, data); +} + +inline uint64_t BBGetSuccBlockCount(AbckitBasicBlock *basicBlock) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(basicBlock == DEFAULT_BB); + return DEFAULT_I64; +} + +inline AbckitBasicBlock *BBGetSuccBlock(AbckitBasicBlock *basicBlock, uint32_t index) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(basicBlock == DEFAULT_BB); + EXPECT_TRUE(index == DEFAULT_U32); + return DEFAULT_BB; +} + +inline void BBInsertSuccBlock(AbckitBasicBlock *basicBlock, AbckitBasicBlock *succBlock, uint32_t index) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(basicBlock == DEFAULT_BB); + EXPECT_TRUE(succBlock == DEFAULT_BB); + EXPECT_TRUE(index == DEFAULT_U32); +} + +inline void BBAppendSuccBlock(AbckitBasicBlock *basicBlock, AbckitBasicBlock *succBlock) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(basicBlock == DEFAULT_BB); + EXPECT_TRUE(succBlock == DEFAULT_BB); +} + +inline void BBEraseSuccBlock(AbckitBasicBlock *basicBlock, uint32_t index) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(basicBlock == DEFAULT_BB); + EXPECT_TRUE(index == DEFAULT_U32); +} + +inline void BBVisitSuccBlocks(AbckitBasicBlock *basicBlock, void *data, + void (*cb)(AbckitBasicBlock *succBasicBlock, void *data)) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(basicBlock == DEFAULT_BB); + (void)data; + cb(DEFAULT_BB, data); +} + +inline AbckitBasicBlock *BBGetTrueBranch(AbckitBasicBlock *basicBlock) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(basicBlock == DEFAULT_BB); + return DEFAULT_BB; +} + +inline AbckitBasicBlock *BBGetFalseBranch(AbckitBasicBlock *basicBlock) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(basicBlock == DEFAULT_BB); + return DEFAULT_BB; +} + +inline AbckitBasicBlock *BBSplitBlockAfterInstruction(AbckitInst *inst, bool makeEdge) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + EXPECT_TRUE(makeEdge == DEFAULT_BOOL); + return DEFAULT_BB; +} + +inline void BBAddInstFront(AbckitBasicBlock *basicBlock, AbckitInst *inst) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(basicBlock == DEFAULT_BB); + EXPECT_TRUE(inst == DEFAULT_INST); +} + +inline void BBAddInstBack(AbckitBasicBlock *basicBlock, AbckitInst *inst) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(basicBlock == DEFAULT_BB); + EXPECT_TRUE(inst == DEFAULT_INST); +} + +inline void BBRemoveAllInsts(AbckitBasicBlock *basicBlock) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(basicBlock == DEFAULT_BB); +} + +inline AbckitInst *BBGetFirstInst(AbckitBasicBlock *basicBlock) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(basicBlock == DEFAULT_BB); + return DEFAULT_INST; +} + +inline AbckitInst *BBGetLastInst(AbckitBasicBlock *basicBlock) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(basicBlock == DEFAULT_BB); + return DEFAULT_INST; +} + +inline uint32_t BBGetNumberOfInstructions(AbckitBasicBlock *basicBlock) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(basicBlock == DEFAULT_BB); + return DEFAULT_U32; +} + +inline AbckitBasicBlock *BBGetImmediateDominator(AbckitBasicBlock *basicBlock) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(basicBlock == DEFAULT_BB); + return DEFAULT_BB; +} + +inline bool BBCheckDominance(AbckitBasicBlock *basicBlock, AbckitBasicBlock *dominator) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(basicBlock == DEFAULT_BB); + EXPECT_TRUE(dominator == DEFAULT_BB); + return DEFAULT_BOOL; +} + +inline void BBVisitDominatedBlocks(AbckitBasicBlock *basicBlock, void *data, + void (*cb)(AbckitBasicBlock *dominatedBasicBlock, void *data)) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(basicBlock == DEFAULT_BB); + (void)data; + cb(DEFAULT_BB, data); +} + +inline bool BBIsStart(AbckitBasicBlock *basicBlock) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(basicBlock == DEFAULT_BB); + return DEFAULT_BOOL; +} + +inline bool BBIsEnd(AbckitBasicBlock *basicBlock) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(basicBlock == DEFAULT_BB); + return DEFAULT_BOOL; +} + +inline bool BBIsLoopHead(AbckitBasicBlock *basicBlock) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(basicBlock == DEFAULT_BB); + return DEFAULT_BOOL; +} + +inline bool BBIsLoopPrehead(AbckitBasicBlock *basicBlock) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(basicBlock == DEFAULT_BB); + return DEFAULT_BOOL; +} + +inline bool BBIsTryBegin(AbckitBasicBlock *basicBlock) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(basicBlock == DEFAULT_BB); + return DEFAULT_BOOL; +} + +inline bool BBIsTry(AbckitBasicBlock *basicBlock) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(basicBlock == DEFAULT_BB); + return DEFAULT_BOOL; +} + +inline bool BBIsTryEnd(AbckitBasicBlock *basicBlock) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(basicBlock == DEFAULT_BB); + return DEFAULT_BOOL; +} + +inline bool BBIsCatchBegin(AbckitBasicBlock *basicBlock) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(basicBlock == DEFAULT_BB); + return DEFAULT_BOOL; +} + +inline bool BBIsCatch(AbckitBasicBlock *basicBlock) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(basicBlock == DEFAULT_BB); + return DEFAULT_BOOL; +} + +inline void BBDump(AbckitBasicBlock *basicBlock, int32_t fd) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(basicBlock == DEFAULT_BB); + EXPECT_TRUE(fd == DEFAULT_I32); +} + +inline AbckitInst *BBCreatePhi(AbckitBasicBlock *basicBlock, size_t argCount, ...) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(basicBlock == DEFAULT_BB); + EXPECT_TRUE(argCount == DEFAULT_SIZE_T); + return DEFAULT_INST; +} + +inline AbckitInst *BBCreateCatchPhi(AbckitBasicBlock *catchBegin, size_t argCount, ...) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(catchBegin == DEFAULT_BB); + EXPECT_TRUE(argCount == DEFAULT_SIZE_T); + return DEFAULT_INST; +} + +inline void Iremove(AbckitInst *inst) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); +} + +inline uint32_t IgetId(AbckitInst *inst) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + return DEFAULT_U32; +} + +inline AbckitInst *IgetNext(AbckitInst *inst) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IgetPrev(AbckitInst *inst) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + return DEFAULT_INST; +} + +inline void IinsertAfter(AbckitInst *newInst, AbckitInst *ref) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(newInst == DEFAULT_INST); + EXPECT_TRUE(ref == DEFAULT_INST); +} + +inline void IinsertBefore(AbckitInst *newInst, AbckitInst *ref) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(newInst == DEFAULT_INST); + EXPECT_TRUE(ref == DEFAULT_INST); +} + +inline AbckitType *IgetType(AbckitInst *inst) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + return DEFAULT_TYPE; +} + +inline AbckitBasicBlock *IgetBasicBlock(AbckitInst *inst) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + return DEFAULT_BB; +} + +inline bool IcheckDominance(AbckitInst *inst, AbckitInst *dominator) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + EXPECT_TRUE(dominator == DEFAULT_INST); + return DEFAULT_BOOL; +} + +inline bool IcheckIsCall(AbckitInst *inst) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + return DEFAULT_BOOL; +} + +inline uint32_t IgetUserCount(AbckitInst *inst) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + return DEFAULT_U32; +} + +inline void IvisitUsers(AbckitInst *inst, void *data, void (*cb)(AbckitInst *user, void *data)) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + (void)data; + cb(DEFAULT_INST, data); +} + +inline uint32_t IgetInputCount(AbckitInst *inst) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + return DEFAULT_U32; +} + +inline AbckitInst *IgetInput(AbckitInst *inst, uint32_t index) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + EXPECT_TRUE(index == DEFAULT_U32); + return DEFAULT_INST; +} + +inline void IvisitInputs(AbckitInst *inst, void *data, void (*cb)(AbckitInst *input, size_t inputIdx, void *data)) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + (void)data; + cb(DEFAULT_INST, DEFAULT_SIZE_T, data); +} + +inline void IsetInput(AbckitInst *inst, AbckitInst *input, uint32_t index) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + EXPECT_TRUE(input == DEFAULT_INST); + EXPECT_TRUE(index == DEFAULT_U32); +} + +inline void IsetInputs(AbckitInst *inst, size_t argCount, ...) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + EXPECT_TRUE(argCount == DEFAULT_SIZE_T); +} + +inline void IappendInput(AbckitInst *inst, AbckitInst *input) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + EXPECT_TRUE(input == DEFAULT_INST); +} + +inline void Idump(AbckitInst *inst, int32_t fd) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + EXPECT_TRUE(fd == DEFAULT_I32); +} + +inline AbckitCoreFunction *IgetFunction(AbckitInst *inst) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + return DEFAULT_CORE_FUNCTION; +} + +inline void IsetFunction(AbckitInst *inst, AbckitCoreFunction *function) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + EXPECT_TRUE(function == DEFAULT_CORE_FUNCTION); +} + +inline uint64_t IgetImmediate(AbckitInst *inst, size_t index) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + EXPECT_TRUE(index == DEFAULT_SIZE_T); + return DEFAULT_I64; +} + +inline void IsetImmediate(AbckitInst *inst, size_t index, uint64_t imm) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + EXPECT_TRUE(index == DEFAULT_SIZE_T); + EXPECT_TRUE(imm == DEFAULT_U64); +} + +inline uint64_t IgetImmediateCount(AbckitInst *inst) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + return DEFAULT_I64; +} + +inline AbckitLiteralArray *IgetLiteralArray(AbckitInst *inst) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + return DEFAULT_LITERAL_ARRAY; +} + +inline void IsetLiteralArray(AbckitInst *inst, AbckitLiteralArray *la) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + EXPECT_TRUE(la == DEFAULT_LITERAL_ARRAY); +} + +inline AbckitString *IgetString(AbckitInst *inst) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + return DEFAULT_STRING; +} + +inline void IsetString(AbckitInst *inst, AbckitString *s) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + EXPECT_TRUE(s == DEFAULT_STRING); +} + +inline int32_t IgetConstantValueI32(AbckitInst *inst) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + return DEFAULT_I32; +} + +inline int64_t IgetConstantValueI64(AbckitInst *inst) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + return DEFAULT_I64; +} + +inline uint64_t IgetConstantValueU64(AbckitInst *inst) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + return DEFAULT_I64; +} + +inline double IgetConstantValueF64(AbckitInst *inst) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + return DEFAULT_DOUBLE; +} + +AbckitGraphApi g_graphApiImpl = { + GgetIsa, + GgetFile, + + // ======================================== + // Api for Graph manipulation + // ======================================== + + GgetStartBasicBlock, + GgetEndBasicBlock, + GgetNumberOfBasicBlocks, + GvisitBlocksRpo, + GgetBasicBlock, + GgetParameter, + GgetNumberOfParameters, + GinsertTryCatch, + Gdump, + GcreateConstantI32, + GcreateConstantI64, + GcreateConstantU64, + GcreateConstantF64, + GrunPassRemoveUnreachableBlocks, + + // ======================================== + // Api for basic block manipulation + // ======================================== + + BBCreateEmpty, + BBGetId, + BBGetGraph, + BBGetPredBlockCount, + BBGetPredBlock, + BBVisitPredBlocks, + BBGetSuccBlockCount, + BBGetSuccBlock, + BBInsertSuccBlock, + BBAppendSuccBlock, + BBEraseSuccBlock, + BBVisitSuccBlocks, + BBGetTrueBranch, + BBGetFalseBranch, + BBSplitBlockAfterInstruction, + BBAddInstFront, + BBAddInstBack, + BBRemoveAllInsts, + BBGetFirstInst, + BBGetLastInst, + BBGetNumberOfInstructions, + BBGetImmediateDominator, + BBCheckDominance, + BBVisitDominatedBlocks, + BBIsStart, + BBIsEnd, + BBIsLoopHead, + BBIsLoopPrehead, + BBIsTryBegin, + BBIsTry, + BBIsTryEnd, + BBIsCatchBegin, + BBIsCatch, + BBDump, + BBCreatePhi, + BBCreateCatchPhi, + + // ======================================== + // Api for instruction manipulation + // ======================================== + + Iremove, + IgetId, + IgetNext, + IgetPrev, + IinsertAfter, + IinsertBefore, + IgetType, + IgetBasicBlock, + IcheckDominance, + IcheckIsCall, + IgetUserCount, + IvisitUsers, + IgetInputCount, + IgetInput, + IvisitInputs, + IsetInput, + IsetInputs, + IappendInput, + Idump, + IgetFunction, + IsetFunction, + IgetImmediate, + IsetImmediate, + IgetImmediateCount, + IgetLiteralArray, + IsetLiteralArray, + IgetString, + IsetString, + IgetConstantValueI32, + IgetConstantValueI64, + IgetConstantValueU64, + IgetConstantValueF64, +}; + +// NOLINTEND(readability-identifier-naming) + +} // namespace libabckit::mock + +AbckitGraphApi const *AbckitGetMockGraphApiImpl([[maybe_unused]] AbckitApiVersion version) +{ + return &libabckit::mock::g_graphApiImpl; +} \ No newline at end of file diff --git a/libabckit/tests/mock/isa_api_dynamic_impl_mock.cpp b/libabckit/tests/mock/isa_api_dynamic_impl_mock.cpp new file mode 100644 index 0000000000..c0c71d3244 --- /dev/null +++ b/libabckit/tests/mock/isa_api_dynamic_impl_mock.cpp @@ -0,0 +1,2109 @@ +/* + * Copyright (c) 2024 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 "../../src/mock/abckit_mock.h" +#include "../../src/mock/mock_values.h" + +#include "../include/c/isa/isa_dynamic.h" + +#include +#include + +namespace libabckit::mock { + +// NOLINTBEGIN(readability-identifier-naming) + +inline AbckitCoreModule *IgetModule(AbckitInst *inst) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + return DEFAULT_CORE_MODULE; +} + +inline void IsetModule(AbckitInst *inst, AbckitCoreModule *md) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + EXPECT_TRUE(md == DEFAULT_CORE_MODULE); +} + +inline enum AbckitIsaApiDynamicConditionCode IgetConditionCode(AbckitInst *inst) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + return DEFAULT_ENUM_ISA_DYNAMIC_CONDITION_TYPE; +} + +inline void IsetConditionCode(AbckitInst *inst, enum AbckitIsaApiDynamicConditionCode cc) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + EXPECT_TRUE(cc == DEFAULT_ENUM_ISA_DYNAMIC_CONDITION_TYPE); +} + +inline enum AbckitIsaApiDynamicOpcode IgetOpcode(AbckitInst *inst) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + return DEFAULT_ENUM_ISA_API_DYNAMIC_OPCODE; +} + +inline AbckitCoreImportDescriptor *IgetImportDescriptor(AbckitInst *inst) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + return DEFAULT_CORE_IMPORT_DESCRIPTOR; +} + +inline void IsetImportDescriptor(AbckitInst *inst, AbckitCoreImportDescriptor *id) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + EXPECT_TRUE(id == DEFAULT_CORE_IMPORT_DESCRIPTOR); +} + +inline AbckitCoreExportDescriptor *IgetExportDescriptor(AbckitInst *inst) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + return DEFAULT_CORE_EXPORT_DESCRIPTOR; +} + +inline void IsetExportDescriptor(AbckitInst *inst, AbckitCoreExportDescriptor *ed) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + EXPECT_TRUE(ed == DEFAULT_CORE_EXPORT_DESCRIPTOR); +} + +inline AbckitInst *IcreateLoadString(AbckitGraph *graph, AbckitString *str) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(str == DEFAULT_STRING); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateLdnan(AbckitGraph *graph) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateLdinfinity(AbckitGraph *graph) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateLdundefined(AbckitGraph *graph) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateLdnull(AbckitGraph *graph) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateLdsymbol(AbckitGraph *graph) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateLdglobal(AbckitGraph *graph) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateLdtrue(AbckitGraph *graph) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateLdfalse(AbckitGraph *graph) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateLdhole(AbckitGraph *graph) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateLdnewtarget(AbckitGraph *graph) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateLdthis(AbckitGraph *graph) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + return DEFAULT_INST; +} + +inline AbckitInst *IcreatePoplexenv(AbckitGraph *graph) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateGetunmappedargs(AbckitGraph *graph) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateAsyncfunctionenter(AbckitGraph *graph) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateLdfunction(AbckitGraph *graph) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateDebugger(AbckitGraph *graph) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateGetpropiterator(AbckitGraph *graph, AbckitInst *acc) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateGetiterator(AbckitGraph *graph, AbckitInst *acc) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateGetasynciterator(AbckitGraph *graph, AbckitInst *acc) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateLdprivateproperty(AbckitGraph *graph, AbckitInst *acc, uint64_t imm0, uint64_t imm1) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(imm0 == DEFAULT_U64); + EXPECT_TRUE(imm1 == DEFAULT_U64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateStprivateproperty(AbckitGraph *graph, AbckitInst *acc, uint64_t imm0, uint64_t imm1, + AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(imm0 == DEFAULT_U64); + EXPECT_TRUE(imm1 == DEFAULT_U64); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateTestin(AbckitGraph *graph, AbckitInst *acc, uint64_t imm0, uint64_t imm1) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(imm0 == DEFAULT_U64); + EXPECT_TRUE(imm1 == DEFAULT_U64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateDefinefieldbyname(AbckitGraph *graph, AbckitInst *acc, AbckitString *string, + AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(string == DEFAULT_STRING); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateDefinepropertybyname(AbckitGraph *graph, AbckitInst *acc, AbckitString *string, + AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(string == DEFAULT_STRING); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCreateemptyobject(AbckitGraph *graph) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCreateemptyarray(AbckitGraph *graph) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCreategeneratorobj(AbckitGraph *graph, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCreateiterresultobj(AbckitGraph *graph, AbckitInst *input0, AbckitInst *input1) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(input1 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCreateobjectwithexcludedkeys(AbckitGraph *graph, AbckitInst *input0, AbckitInst *input1, + uint64_t imm0, ...) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(input1 == DEFAULT_INST); + EXPECT_TRUE(imm0 == DEFAULT_U64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateWideCreateobjectwithexcludedkeys(AbckitGraph *graph, AbckitInst *input0, AbckitInst *input1, + uint64_t imm0, ...) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(input1 == DEFAULT_INST); + EXPECT_TRUE(imm0 == DEFAULT_I64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCreatearraywithbuffer(AbckitGraph *graph, AbckitLiteralArray *literalArray) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(literalArray == DEFAULT_LITERAL_ARRAY); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCreateobjectwithbuffer(AbckitGraph *graph, AbckitLiteralArray *literalArray) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(literalArray == DEFAULT_LITERAL_ARRAY); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateNewobjapply(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateNewobjrange(AbckitGraph *graph, size_t argCount, ...) +{ + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(argCount == DEFAULT_SIZE_T); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateWideNewobjrange(AbckitGraph *graph, size_t argCount, ...) +{ + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(argCount == DEFAULT_SIZE_T); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateNewlexenv(AbckitGraph *graph, uint64_t imm0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(imm0 == DEFAULT_I64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateWideNewlexenv(AbckitGraph *graph, uint64_t imm0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(imm0 == DEFAULT_U64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateNewlexenvwithname(AbckitGraph *graph, uint64_t imm0, AbckitLiteralArray *literalArray) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(imm0 == DEFAULT_U64); + EXPECT_TRUE(literalArray == DEFAULT_LITERAL_ARRAY); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateWideNewlexenvwithname(AbckitGraph *graph, uint64_t imm0, AbckitLiteralArray *literalArray) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(imm0 == DEFAULT_U64); + EXPECT_TRUE(literalArray == DEFAULT_LITERAL_ARRAY); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCreateasyncgeneratorobj(AbckitGraph *graph, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateAsyncgeneratorresolve(AbckitGraph *graph, AbckitInst *input0, AbckitInst *input1, + AbckitInst *input2) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(input1 == DEFAULT_INST); + EXPECT_TRUE(input2 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateAdd2(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateSub2(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateMul2(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateDiv2(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateMod2(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateEq(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateNoteq(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateLess(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateLesseq(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateGreater(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateGreatereq(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateShl2(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateShr2(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateAshr2(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateAnd2(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateOr2(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateXor2(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateExp(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateTypeof(AbckitGraph *graph, AbckitInst *acc) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateTonumber(AbckitGraph *graph, AbckitInst *acc) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateTonumeric(AbckitGraph *graph, AbckitInst *acc) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateNeg(AbckitGraph *graph, AbckitInst *acc) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateNot(AbckitGraph *graph, AbckitInst *acc) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateInc(AbckitGraph *graph, AbckitInst *acc) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateDec(AbckitGraph *graph, AbckitInst *acc) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateIstrue(AbckitGraph *graph, AbckitInst *acc) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateIsfalse(AbckitGraph *graph, AbckitInst *acc) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateIsin(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateInstanceof(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateStrictnoteq(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateStricteq(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCallruntimeNotifyconcurrentresult(AbckitGraph *graph, AbckitInst *acc) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCallruntimeDefinefieldbyvalue(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0, + AbckitInst *input1) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(input1 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCallruntimeDefinefieldbyindex(AbckitGraph *graph, AbckitInst *acc, uint64_t imm0, + AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(imm0 == DEFAULT_U64); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCallruntimeTopropertykey(AbckitGraph *graph, AbckitInst *acc) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCallruntimeCreateprivateproperty(AbckitGraph *graph, uint64_t imm0, + AbckitLiteralArray *literalArray) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(imm0 == DEFAULT_U64); + EXPECT_TRUE(literalArray == DEFAULT_LITERAL_ARRAY); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCallruntimeDefineprivateproperty(AbckitGraph *graph, AbckitInst *acc, uint64_t imm0, + uint64_t imm1, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(imm0 == DEFAULT_I64); + EXPECT_TRUE(imm1 == DEFAULT_I64); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCallruntimeCallinit(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCallruntimeDefinesendableclass(AbckitGraph *graph, AbckitCoreFunction *function, + AbckitLiteralArray *literalArray, uint64_t imm0, + AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(function == DEFAULT_CORE_FUNCTION); + EXPECT_TRUE(literalArray == DEFAULT_LITERAL_ARRAY); + EXPECT_TRUE(imm0 == DEFAULT_U64); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCallruntimeLdsendableclass(AbckitGraph *graph, uint64_t imm0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(imm0 == DEFAULT_U64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCallruntimeLdsendableexternalmodulevar(AbckitGraph *graph, uint64_t imm0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(imm0 == DEFAULT_I64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCallruntimeWideldsendableexternalmodulevar(AbckitGraph *graph, uint64_t imm0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(imm0 == DEFAULT_I64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCallruntimeNewsendableenv(AbckitGraph *graph, uint64_t imm0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(imm0 == DEFAULT_I64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCallruntimeWidenewsendableenv(AbckitGraph *graph, uint64_t imm0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(imm0 == DEFAULT_I64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCallruntimeStsendablevar(AbckitGraph *graph, AbckitInst *acc, uint64_t imm0, uint64_t imm1) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(imm0 == DEFAULT_I64); + EXPECT_TRUE(imm1 == DEFAULT_I64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCallruntimeWidestsendablevar(AbckitGraph *graph, AbckitInst *acc, uint64_t imm0, + uint64_t imm1) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(imm0 == DEFAULT_I64); + EXPECT_TRUE(imm1 == DEFAULT_I64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCallruntimeLdsendablevar(AbckitGraph *graph, uint64_t imm0, uint64_t imm1) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(imm0 == DEFAULT_I64); + EXPECT_TRUE(imm1 == DEFAULT_I64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCallruntimeWideldsendablevar(AbckitGraph *graph, uint64_t imm0, uint64_t imm1) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(imm0 == DEFAULT_I64); + EXPECT_TRUE(imm1 == DEFAULT_I64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCallruntimeIstrue(AbckitGraph *graph, AbckitInst *acc) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCallruntimeIsfalse(AbckitGraph *graph, AbckitInst *acc) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateThrow(AbckitGraph *graph, AbckitInst *acc) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateThrowNotexists(AbckitGraph *graph) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateThrowPatternnoncoercible(AbckitGraph *graph) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateThrowDeletesuperproperty(AbckitGraph *graph) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateThrowConstassignment(AbckitGraph *graph, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateThrowIfnotobject(AbckitGraph *graph, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateThrowUndefinedifhole(AbckitGraph *graph, AbckitInst *input0, AbckitInst *input1) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(input1 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateThrowIfsupernotcorrectcall(AbckitGraph *graph, AbckitInst *acc, uint64_t imm0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(imm0 == DEFAULT_U64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateThrowUndefinedifholewithname(AbckitGraph *graph, AbckitInst *acc, AbckitString *string) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(string == DEFAULT_STRING); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCallarg0(AbckitGraph *graph, AbckitInst *acc) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCallarg1(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCallargs2(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0, AbckitInst *input1) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(input1 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCallargs3(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0, AbckitInst *input1, + AbckitInst *input2) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(input1 == DEFAULT_INST); + EXPECT_TRUE(input2 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCallrange(AbckitGraph *graph, AbckitInst *acc, size_t argCount, ...) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(argCount == DEFAULT_SIZE_T); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateWideCallrange(AbckitGraph *graph, AbckitInst *acc, size_t argCount, ...) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(argCount == DEFAULT_SIZE_T); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateSupercallspread(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateApply(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0, AbckitInst *input1) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(input1 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCallthis0(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCallthis1(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0, AbckitInst *input1) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(input1 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCallthis2(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0, AbckitInst *input1, + AbckitInst *input2) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(input1 == DEFAULT_INST); + EXPECT_TRUE(input2 == DEFAULT_INST); + return DEFAULT_INST; +} + +// CC-OFFNXT(G.FUN.01) function args are necessary +inline AbckitInst *IcreateCallthis3(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0, AbckitInst *input1, + AbckitInst *input2, AbckitInst *input3) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(input1 == DEFAULT_INST); + EXPECT_TRUE(input2 == DEFAULT_INST); + EXPECT_TRUE(input3 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCallthisrange(AbckitGraph *graph, AbckitInst *acc, size_t argCount, ...) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(argCount == DEFAULT_SIZE_T); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateWideCallthisrange(AbckitGraph *graph, AbckitInst *acc, size_t argCount, ...) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(argCount == DEFAULT_SIZE_T); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateSupercallthisrange(AbckitGraph *graph, size_t argCount, ...) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(argCount == DEFAULT_SIZE_T); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateWideSupercallthisrange(AbckitGraph *graph, size_t argCount, ...) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(argCount == DEFAULT_SIZE_T); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateSupercallarrowrange(AbckitGraph *graph, AbckitInst *acc, size_t argCount, ...) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(argCount == DEFAULT_SIZE_T); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateWideSupercallarrowrange(AbckitGraph *graph, AbckitInst *acc, size_t argCount, ...) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(argCount == DEFAULT_SIZE_T); + return DEFAULT_INST; +} + +// CC-OFFNXT(G.FUN.01) function args are necessary +inline AbckitInst *IcreateDefinegettersetterbyvalue(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0, + AbckitInst *input1, AbckitInst *input2, AbckitInst *input3) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(input1 == DEFAULT_INST); + EXPECT_TRUE(input2 == DEFAULT_INST); + EXPECT_TRUE(input3 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateDefinefunc(AbckitGraph *graph, AbckitCoreFunction *function, uint64_t imm0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(function == DEFAULT_CORE_FUNCTION); + EXPECT_TRUE(imm0 == DEFAULT_U64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateDefinemethod(AbckitGraph *graph, AbckitInst *acc, AbckitCoreFunction *function, uint64_t imm0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(function == DEFAULT_CORE_FUNCTION); + EXPECT_TRUE(imm0 == DEFAULT_U64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateDefineclasswithbuffer(AbckitGraph *graph, AbckitCoreFunction *function, + AbckitLiteralArray *literalArray, uint64_t imm0, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(function == DEFAULT_CORE_FUNCTION); + EXPECT_TRUE(literalArray == DEFAULT_LITERAL_ARRAY); + EXPECT_TRUE(imm0 == DEFAULT_U64); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateResumegenerator(AbckitGraph *graph, AbckitInst *acc) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateGetresumemode(AbckitGraph *graph, AbckitInst *acc) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateGettemplateobject(AbckitGraph *graph, AbckitInst *acc) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateGetnextpropname(AbckitGraph *graph, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateDelobjprop(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateSuspendgenerator(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateAsyncfunctionawaituncaught(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCopydataproperties(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateStarrayspread(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0, AbckitInst *input1) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(input1 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateSetobjectwithproto(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateLdobjbyvalue(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateStobjbyvalue(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0, AbckitInst *input1) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(input1 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateStownbyvalue(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0, AbckitInst *input1) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(input1 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateLdsuperbyvalue(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateStsuperbyvalue(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0, AbckitInst *input1) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(input1 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateLdobjbyindex(AbckitGraph *graph, AbckitInst *acc, uint64_t imm0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(imm0 == DEFAULT_U64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateWideLdobjbyindex(AbckitGraph *graph, AbckitInst *acc, uint64_t imm0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(imm0 == DEFAULT_U64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateStobjbyindex(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0, uint64_t imm0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(imm0 == DEFAULT_U64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateWideStobjbyindex(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0, uint64_t imm0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(imm0 == DEFAULT_U64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateStownbyindex(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0, uint64_t imm0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(imm0 == DEFAULT_U64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateWideStownbyindex(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0, uint64_t imm0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(imm0 == DEFAULT_U64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateAsyncfunctionresolve(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateAsyncfunctionreject(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCopyrestargs(AbckitGraph *graph, uint64_t imm0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(imm0 == DEFAULT_U64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateWideCopyrestargs(AbckitGraph *graph, uint64_t imm0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(imm0 == DEFAULT_U64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateLdlexvar(AbckitGraph *graph, uint64_t imm0, uint64_t imm1) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(imm0 == DEFAULT_U64); + EXPECT_TRUE(imm1 == DEFAULT_U64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateWideLdlexvar(AbckitGraph *graph, uint64_t imm0, uint64_t imm1) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(imm0 == DEFAULT_U64); + EXPECT_TRUE(imm1 == DEFAULT_U64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateStlexvar(AbckitGraph *graph, AbckitInst *acc, uint64_t imm0, uint64_t imm1) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(imm0 == DEFAULT_U64); + EXPECT_TRUE(imm1 == DEFAULT_U64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateWideStlexvar(AbckitGraph *graph, AbckitInst *acc, uint64_t imm0, uint64_t imm1) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(imm0 == DEFAULT_U64); + EXPECT_TRUE(imm1 == DEFAULT_U64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateGetmodulenamespace(AbckitGraph *graph, AbckitCoreModule *md) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(md == DEFAULT_CORE_MODULE); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateWideGetmodulenamespace(AbckitGraph *graph, AbckitCoreModule *md) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(md == DEFAULT_CORE_MODULE); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateStmodulevar(AbckitGraph *graph, AbckitInst *acc, AbckitCoreExportDescriptor *ed) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(ed == DEFAULT_CORE_EXPORT_DESCRIPTOR); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateWideStmodulevar(AbckitGraph *graph, AbckitInst *acc, AbckitCoreExportDescriptor *ed) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(ed == DEFAULT_CORE_EXPORT_DESCRIPTOR); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateTryldglobalbyname(AbckitGraph *graph, AbckitString *string) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(string == DEFAULT_STRING); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateTrystglobalbyname(AbckitGraph *graph, AbckitInst *acc, AbckitString *string) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(string == DEFAULT_STRING); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateLdglobalvar(AbckitGraph *graph, AbckitString *string) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(string == DEFAULT_STRING); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateStglobalvar(AbckitGraph *graph, AbckitInst *acc, AbckitString *string) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(string == DEFAULT_STRING); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateLdobjbyname(AbckitGraph *graph, AbckitInst *acc, AbckitString *string) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(string == DEFAULT_STRING); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateStobjbyname(AbckitGraph *graph, AbckitInst *acc, AbckitString *string, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(string == DEFAULT_STRING); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateStownbyname(AbckitGraph *graph, AbckitInst *acc, AbckitString *string, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(string == DEFAULT_STRING); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateLdsuperbyname(AbckitGraph *graph, AbckitInst *acc, AbckitString *string) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(string == DEFAULT_STRING); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateStsuperbyname(AbckitGraph *graph, AbckitInst *acc, AbckitString *string, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(string == DEFAULT_STRING); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateLdlocalmodulevar(AbckitGraph *graph, AbckitCoreExportDescriptor *ed) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(ed == DEFAULT_CORE_EXPORT_DESCRIPTOR); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateWideLdlocalmodulevar(AbckitGraph *graph, AbckitCoreExportDescriptor *ed) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(ed == DEFAULT_CORE_EXPORT_DESCRIPTOR); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateLdexternalmodulevar(AbckitGraph *graph, AbckitCoreImportDescriptor *id) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(id == DEFAULT_CORE_IMPORT_DESCRIPTOR); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateWideLdexternalmodulevar(AbckitGraph *graph, AbckitCoreImportDescriptor *id) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(id == DEFAULT_CORE_IMPORT_DESCRIPTOR); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateStownbyvaluewithnameset(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0, + AbckitInst *input1) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(input1 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateStownbynamewithnameset(AbckitGraph *graph, AbckitInst *acc, AbckitString *string, + AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(string == DEFAULT_STRING); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateLdbigint(AbckitGraph *graph, AbckitString *string) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(string == DEFAULT_STRING); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateLdthisbyname(AbckitGraph *graph, AbckitString *string) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(string == DEFAULT_STRING); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateStthisbyname(AbckitGraph *graph, AbckitInst *acc, AbckitString *string) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(string == DEFAULT_STRING); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateLdthisbyvalue(AbckitGraph *graph, AbckitInst *acc) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateStthisbyvalue(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateWideLdpatchvar(AbckitGraph *graph, uint64_t imm0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(imm0 == DEFAULT_U64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateWideStpatchvar(AbckitGraph *graph, AbckitInst *acc, uint64_t imm0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(imm0 == DEFAULT_U64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateDynamicimport(AbckitGraph *graph, AbckitInst *acc) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateAsyncgeneratorreject(AbckitGraph *graph, AbckitInst *acc, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateSetgeneratorstate(AbckitGraph *graph, AbckitInst *acc, uint64_t imm0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + EXPECT_TRUE(imm0 == DEFAULT_U64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateReturn(AbckitGraph *graph, AbckitInst *acc) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateReturnundefined(AbckitGraph *graph) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateIf(AbckitGraph *graph, AbckitInst *input, enum AbckitIsaApiDynamicConditionCode cc) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(input == DEFAULT_INST); + EXPECT_TRUE(cc == DEFAULT_ENUM_ISA_DYNAMIC_CONDITION_TYPE); + return DEFAULT_INST; +} + +AbckitIsaApiDynamic g_isaApiDynamicImpl = { + IgetModule, + IsetModule, + IgetConditionCode, + IsetConditionCode, + IgetOpcode, + IgetImportDescriptor, + IsetImportDescriptor, + IgetExportDescriptor, + IsetExportDescriptor, + IcreateLoadString, + IcreateLdnan, + IcreateLdinfinity, + IcreateLdundefined, + IcreateLdnull, + IcreateLdsymbol, + IcreateLdglobal, + IcreateLdtrue, + IcreateLdfalse, + IcreateLdhole, + IcreateLdnewtarget, + IcreateLdthis, + IcreatePoplexenv, + IcreateGetunmappedargs, + IcreateAsyncfunctionenter, + IcreateLdfunction, + IcreateDebugger, + IcreateGetpropiterator, + IcreateGetiterator, + IcreateGetasynciterator, + IcreateLdprivateproperty, + IcreateStprivateproperty, + IcreateTestin, + IcreateDefinefieldbyname, + IcreateDefinepropertybyname, + IcreateCreateemptyobject, + IcreateCreateemptyarray, + IcreateCreategeneratorobj, + IcreateCreateiterresultobj, + IcreateCreateobjectwithexcludedkeys, + IcreateWideCreateobjectwithexcludedkeys, + IcreateCreatearraywithbuffer, + IcreateCreateobjectwithbuffer, + IcreateNewobjapply, + IcreateNewobjrange, + IcreateWideNewobjrange, + IcreateNewlexenv, + IcreateWideNewlexenv, + IcreateNewlexenvwithname, + IcreateWideNewlexenvwithname, + IcreateCreateasyncgeneratorobj, + IcreateAsyncgeneratorresolve, + IcreateAdd2, + IcreateSub2, + IcreateMul2, + IcreateDiv2, + IcreateMod2, + IcreateEq, + IcreateNoteq, + IcreateLess, + IcreateLesseq, + IcreateGreater, + IcreateGreatereq, + IcreateShl2, + IcreateShr2, + IcreateAshr2, + IcreateAnd2, + IcreateOr2, + IcreateXor2, + IcreateExp, + IcreateTypeof, + IcreateTonumber, + IcreateTonumeric, + IcreateNeg, + IcreateNot, + IcreateInc, + IcreateDec, + IcreateIstrue, + IcreateIsfalse, + IcreateIsin, + IcreateInstanceof, + IcreateStrictnoteq, + IcreateStricteq, + IcreateCallruntimeNotifyconcurrentresult, + IcreateCallruntimeDefinefieldbyvalue, + IcreateCallruntimeDefinefieldbyindex, + IcreateCallruntimeTopropertykey, + IcreateCallruntimeCreateprivateproperty, + IcreateCallruntimeDefineprivateproperty, + IcreateCallruntimeCallinit, + IcreateCallruntimeDefinesendableclass, + IcreateCallruntimeLdsendableclass, + IcreateCallruntimeLdsendableexternalmodulevar, + IcreateCallruntimeWideldsendableexternalmodulevar, + IcreateCallruntimeNewsendableenv, + IcreateCallruntimeWidenewsendableenv, + IcreateCallruntimeStsendablevar, + IcreateCallruntimeWidestsendablevar, + IcreateCallruntimeLdsendablevar, + IcreateCallruntimeWideldsendablevar, + IcreateCallruntimeIstrue, + IcreateCallruntimeIsfalse, + IcreateThrow, + IcreateThrowNotexists, + IcreateThrowPatternnoncoercible, + IcreateThrowDeletesuperproperty, + IcreateThrowConstassignment, + IcreateThrowIfnotobject, + IcreateThrowUndefinedifhole, + IcreateThrowIfsupernotcorrectcall, + IcreateThrowUndefinedifholewithname, + IcreateCallarg0, + IcreateCallarg1, + IcreateCallargs2, + IcreateCallargs3, + IcreateCallrange, + IcreateWideCallrange, + IcreateSupercallspread, + IcreateApply, + IcreateCallthis0, + IcreateCallthis1, + IcreateCallthis2, + IcreateCallthis3, + IcreateCallthisrange, + IcreateWideCallthisrange, + IcreateSupercallthisrange, + IcreateWideSupercallthisrange, + IcreateSupercallarrowrange, + IcreateWideSupercallarrowrange, + IcreateDefinegettersetterbyvalue, + IcreateDefinefunc, + IcreateDefinemethod, + IcreateDefineclasswithbuffer, + IcreateResumegenerator, + IcreateGetresumemode, + IcreateGettemplateobject, + IcreateGetnextpropname, + IcreateDelobjprop, + IcreateSuspendgenerator, + IcreateAsyncfunctionawaituncaught, + IcreateCopydataproperties, + IcreateStarrayspread, + IcreateSetobjectwithproto, + IcreateLdobjbyvalue, + IcreateStobjbyvalue, + IcreateStownbyvalue, + IcreateLdsuperbyvalue, + IcreateStsuperbyvalue, + IcreateLdobjbyindex, + IcreateWideLdobjbyindex, + IcreateStobjbyindex, + IcreateWideStobjbyindex, + IcreateStownbyindex, + IcreateWideStownbyindex, + IcreateAsyncfunctionresolve, + IcreateAsyncfunctionreject, + IcreateCopyrestargs, + IcreateWideCopyrestargs, + IcreateLdlexvar, + IcreateWideLdlexvar, + IcreateStlexvar, + IcreateWideStlexvar, + IcreateGetmodulenamespace, + IcreateWideGetmodulenamespace, + IcreateStmodulevar, + IcreateWideStmodulevar, + IcreateTryldglobalbyname, + IcreateTrystglobalbyname, + IcreateLdglobalvar, + IcreateStglobalvar, + IcreateLdobjbyname, + IcreateStobjbyname, + IcreateStownbyname, + IcreateLdsuperbyname, + IcreateStsuperbyname, + IcreateLdlocalmodulevar, + IcreateWideLdlocalmodulevar, + IcreateLdexternalmodulevar, + IcreateWideLdexternalmodulevar, + IcreateStownbyvaluewithnameset, + IcreateStownbynamewithnameset, + IcreateLdbigint, + IcreateLdthisbyname, + IcreateStthisbyname, + IcreateLdthisbyvalue, + IcreateStthisbyvalue, + IcreateWideLdpatchvar, + IcreateWideStpatchvar, + IcreateDynamicimport, + IcreateAsyncgeneratorreject, + IcreateSetgeneratorstate, + IcreateReturn, + IcreateReturnundefined, + IcreateIf, +}; + +// NOLINTEND(readability-identifier-naming) + +} // namespace libabckit::mock + +AbckitIsaApiDynamic const *AbckitGetMockIsaApiDynamicImpl([[maybe_unused]] AbckitApiVersion version) +{ + return &libabckit::mock::g_isaApiDynamicImpl; +} diff --git a/libabckit/tests/mock/isa_api_static_impl_mock.cpp b/libabckit/tests/mock/isa_api_static_impl_mock.cpp new file mode 100644 index 0000000000..6ea2f05876 --- /dev/null +++ b/libabckit/tests/mock/isa_api_static_impl_mock.cpp @@ -0,0 +1,617 @@ +/* + * Copyright (c) 2024 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 "../../src/mock/abckit_mock.h" +#include "../../src/mock/mock_values.h" + +#include "../../include/c/metadata_core.h" +#include "../../src/include_v2/c/isa/isa_static.h" + +#include +#include +#include + +namespace libabckit::mock { + +// NOLINTBEGIN(readability-identifier-naming) + +inline AbckitCoreClass *IgetClass(AbckitInst *inst) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + return DEFAULT_CORE_CLASS; +} + +inline void IsetClass(AbckitInst *inst, AbckitCoreClass *klass) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + EXPECT_TRUE(klass == DEFAULT_CORE_CLASS); +} + +inline enum AbckitIsaApiStaticConditionCode IgetConditionCode(AbckitInst *inst) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + return DEFAULT_ENUM_ISA_STATIC_CONDITION_CODE; +} + +inline void IsetConditionCode(AbckitInst *inst, enum AbckitIsaApiStaticConditionCode cc) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + EXPECT_TRUE(cc == DEFAULT_ENUM_ISA_STATIC_CONDITION_CODE); +} + +inline enum AbckitIsaApiStaticOpcode IgetOpcode(AbckitInst *inst) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + return DEFAULT_ENUM_ISA_API_STATIC_OPCODE; +} + +inline void IsetTargetType(AbckitInst *inst, AbckitTypeId t) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + EXPECT_TRUE(t == DEFAULT_TYPE_ID); +} + +inline enum AbckitTypeId IgetTargetType(AbckitInst *inst) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(inst == DEFAULT_INST); + return DEFAULT_ENUM_TYPE_ID; +} + +inline AbckitInst *IcreateCmp(AbckitGraph *graph, AbckitInst *input0, AbckitInst *input1) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(input1 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateLoadString(AbckitGraph *graph, AbckitString *str) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(str == DEFAULT_STRING); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateReturn(AbckitGraph *graph, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateIf(AbckitGraph *graph, AbckitInst *input0, AbckitInst *input1, + enum AbckitIsaApiStaticConditionCode cc) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(input1 == DEFAULT_INST); + EXPECT_TRUE(cc == DEFAULT_ENUM_ISA_STATIC_CONDITION_CODE); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateNeg(AbckitGraph *graph, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateNot(AbckitGraph *graph, AbckitInst *input0) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(input0 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateAdd(AbckitGraph *graph, AbckitInst *input0, AbckitInst *input1) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(input1 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateSub(AbckitGraph *graph, AbckitInst *input0, AbckitInst *input1) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(input1 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateMul(AbckitGraph *graph, AbckitInst *input0, AbckitInst *input1) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(input1 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateDiv(AbckitGraph *graph, AbckitInst *input0, AbckitInst *input1) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(input1 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateMod(AbckitGraph *graph, AbckitInst *input0, AbckitInst *input1) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(input1 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateShl(AbckitGraph *graph, AbckitInst *input0, AbckitInst *input1) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(input1 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateShr(AbckitGraph *graph, AbckitInst *input0, AbckitInst *input1) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(input1 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateAShr(AbckitGraph *graph, AbckitInst *input0, AbckitInst *input1) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(input1 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateAnd(AbckitGraph *graph, AbckitInst *input0, AbckitInst *input1) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(input1 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateOr(AbckitGraph *graph, AbckitInst *input0, AbckitInst *input1) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(input1 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateXor(AbckitGraph *graph, AbckitInst *input0, AbckitInst *input1) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(input1 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCast(AbckitGraph *graph, AbckitInst *input0, AbckitTypeId targetType) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(targetType == DEFAULT_TYPE_ID); + return DEFAULT_INST; +} + +inline AbckitInst *GcreateNullPtr(AbckitGraph *graph) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateNewArray(AbckitGraph *graph, AbckitCoreClass *inputClass, AbckitInst *inputSize) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(inputClass == DEFAULT_CORE_CLASS); + EXPECT_TRUE(inputSize == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateNewObject(AbckitGraph *graph, AbckitCoreClass *inputClass) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(inputClass == DEFAULT_CORE_CLASS); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateInitObject(AbckitGraph *graph, AbckitCoreFunction *function, size_t argCount, ...) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(function == DEFAULT_CORE_FUNCTION); + EXPECT_TRUE(argCount == DEFAULT_SIZE_T); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateLoadArray(AbckitGraph *graph, AbckitInst *arrayRef, AbckitInst *idx, + AbckitTypeId returnTypeId) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(arrayRef == DEFAULT_INST); + EXPECT_TRUE(idx == DEFAULT_INST); + EXPECT_TRUE(returnTypeId == DEFAULT_TYPE_ID); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateStoreArray(AbckitGraph *graph, AbckitInst *arrayRef, AbckitInst *idx, AbckitInst *value, + AbckitTypeId returnTypeId) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(arrayRef == DEFAULT_INST); + EXPECT_TRUE(idx == DEFAULT_INST); + EXPECT_TRUE(value == DEFAULT_INST); + EXPECT_TRUE(returnTypeId == DEFAULT_TYPE_ID); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateStoreArrayWide(AbckitGraph *graph, AbckitInst *arrayRef, AbckitInst *idx, AbckitInst *value, + AbckitTypeId returnTypeId) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(arrayRef == DEFAULT_INST); + EXPECT_TRUE(idx == DEFAULT_INST); + EXPECT_TRUE(value == DEFAULT_INST); + EXPECT_TRUE(returnTypeId == DEFAULT_TYPE_ID); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateLenArray(AbckitGraph *graph, AbckitInst *arr) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(arr == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateLoadConstArray(AbckitGraph *graph, AbckitLiteralArray *literalArray) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(literalArray == DEFAULT_LITERAL_ARRAY); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCheckCast(AbckitGraph *graph, AbckitInst *inputObj, AbckitType *targetType) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(inputObj == DEFAULT_INST); + EXPECT_TRUE(targetType == DEFAULT_TYPE); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateIsInstance(AbckitGraph *graph, AbckitInst *inputObj, AbckitType *targetType) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(inputObj == DEFAULT_INST); + EXPECT_TRUE(targetType == DEFAULT_TYPE); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateLoadUndefined(AbckitGraph *graph) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateReturnVoid(AbckitGraph *graph) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateEquals(AbckitGraph *graph, AbckitInst *input0, AbckitInst *input1) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(input1 == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCallStatic(AbckitGraph *graph, AbckitCoreFunction *function, size_t argCount, ...) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(function == DEFAULT_CORE_FUNCTION); + EXPECT_TRUE(argCount == DEFAULT_SIZE_T); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateCallVirtual(AbckitGraph *graph, AbckitInst *inputObj, AbckitCoreFunction *function, + size_t argCount, ...) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(inputObj == DEFAULT_INST); + EXPECT_TRUE(function == DEFAULT_CORE_FUNCTION); + EXPECT_TRUE(argCount == DEFAULT_SIZE_T); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateAddI(AbckitGraph *graph, AbckitInst *input0, uint64_t imm) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(imm == DEFAULT_U64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateSubI(AbckitGraph *graph, AbckitInst *input0, uint64_t imm) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(imm == DEFAULT_U64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateMulI(AbckitGraph *graph, AbckitInst *input0, uint64_t imm) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(imm == DEFAULT_U64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateDivI(AbckitGraph *graph, AbckitInst *input0, uint64_t imm) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(imm == DEFAULT_U64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateModI(AbckitGraph *graph, AbckitInst *input0, uint64_t imm) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(imm == DEFAULT_U64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateShlI(AbckitGraph *graph, AbckitInst *input0, uint64_t imm) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(imm == DEFAULT_U64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateShrI(AbckitGraph *graph, AbckitInst *input0, uint64_t imm) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(imm == DEFAULT_U64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateAShrI(AbckitGraph *graph, AbckitInst *input0, uint64_t imm) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(imm == DEFAULT_U64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateAndI(AbckitGraph *graph, AbckitInst *input0, uint64_t imm) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(imm == DEFAULT_U64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateOrI(AbckitGraph *graph, AbckitInst *input0, uint64_t imm) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(imm == DEFAULT_U64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateXorI(AbckitGraph *graph, AbckitInst *input0, uint64_t imm) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(input0 == DEFAULT_INST); + EXPECT_TRUE(imm == DEFAULT_U64); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateThrow(AbckitGraph *graph, AbckitInst *acc) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(acc == DEFAULT_INST); + return DEFAULT_INST; +} + +inline AbckitInst *IcreateIsUndefined(AbckitGraph *graph, AbckitInst *inputObj) +{ + g_calledFuncs.push(__func__); + + EXPECT_TRUE(graph == DEFAULT_GRAPH); + EXPECT_TRUE(inputObj == DEFAULT_INST); + return DEFAULT_INST; +} + +AbckitIsaApiStatic g_isaApiStaticImpl = { + IgetClass, + IsetClass, + IgetConditionCode, + IsetConditionCode, + IgetOpcode, + IsetTargetType, + IgetTargetType, + IcreateCmp, + IcreateLoadString, + IcreateReturn, + IcreateIf, + IcreateNeg, + IcreateNot, + IcreateAdd, + IcreateSub, + IcreateMul, + IcreateDiv, + IcreateMod, + IcreateShl, + IcreateShr, + IcreateAShr, + IcreateAnd, + IcreateOr, + IcreateXor, + IcreateCast, + GcreateNullPtr, + IcreateNewArray, + IcreateNewObject, + IcreateInitObject, + IcreateLoadArray, + IcreateStoreArray, + IcreateStoreArrayWide, + IcreateLenArray, + IcreateLoadConstArray, + IcreateCheckCast, + IcreateIsInstance, + IcreateLoadUndefined, + IcreateReturnVoid, + IcreateEquals, + IcreateCallStatic, + IcreateCallVirtual, + IcreateAddI, + IcreateSubI, + IcreateMulI, + IcreateDivI, + IcreateModI, + IcreateShlI, + IcreateShrI, + IcreateAShrI, + IcreateAndI, + IcreateOrI, + IcreateXorI, + IcreateThrow, + IcreateIsUndefined, +}; + +// NOLINTEND(readability-identifier-naming) + +} // namespace libabckit::mock + +AbckitIsaApiStatic const *AbckitGetMockIsaApiStaticImpl([[maybe_unused]] AbckitApiVersion version) +{ + return &libabckit::mock::g_isaApiStaticImpl; +} \ No newline at end of file diff --git a/libabckit/tests/mock/metadata_inspect_impl_mock.cpp b/libabckit/tests/mock/metadata_inspect_impl_mock.cpp new file mode 100644 index 0000000000..812911c0e7 --- /dev/null +++ b/libabckit/tests/mock/metadata_inspect_impl_mock.cpp @@ -0,0 +1,899 @@ +/** + * Copyright (c) 2024 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 ABCKIT_INSPECT_IMPL_MOCK +#define ABCKIT_INSPECT_IMPL_MOCK + +#include "../../src/mock/abckit_mock.h" +#include "../../src/mock/mock_values.h" + +#include "../../include/c/metadata_core.h" + +#include + +namespace libabckit::mock { + +// NOLINTBEGIN(readability-identifier-naming) + +// ======================================== +// File +// ======================================== + +inline AbckitFileVersion FileGetVersion(AbckitFile *file) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(file == DEFAULT_FILE); + return DEFAULT_FILE_VERSION; +} + +inline void FileEnumerateModules(AbckitFile *file, void *data, bool (*cb)(AbckitCoreModule *module, void *data)) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(file == DEFAULT_FILE); + cb(DEFAULT_CORE_MODULE, data); +} + +inline void FileEnumerateExternalModules(AbckitFile *file, void *data, bool (*cb)(AbckitCoreModule *module, void *data)) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(file == DEFAULT_FILE); + cb(DEFAULT_CORE_MODULE, data); +} + +// ======================================== +// Module +// ======================================== + +inline AbckitFile *ModuleGetFile(AbckitCoreModule *m) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(m == DEFAULT_CORE_MODULE); + return DEFAULT_FILE; +} + +inline AbckitTarget ModuleGetTarget(AbckitCoreModule *m) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(m == DEFAULT_CORE_MODULE); + return DEFAULT_TARGET; +} + +inline AbckitString *ModuleGetName(AbckitCoreModule *m) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(m == DEFAULT_CORE_MODULE); + return DEFAULT_STRING; +} + +inline bool ModuleIsExternal(AbckitCoreModule *m) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(m == DEFAULT_CORE_MODULE); + return true; +} + +inline void ModuleEnumerateImports(AbckitCoreModule *m, void *data, + bool (*cb)(AbckitCoreImportDescriptor *i, void *data)) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(m == DEFAULT_CORE_MODULE); + cb(DEFAULT_CORE_IMPORT_DESCRIPTOR, data); +} + +inline void ModuleEnumerateExports(AbckitCoreModule *m, void *data, + bool (*cb)(AbckitCoreExportDescriptor *e, void *data)) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(m == DEFAULT_CORE_MODULE); + cb(DEFAULT_CORE_EXPORT_DESCRIPTOR, data); +} + +inline void ModuleEnumerateNamespaces(AbckitCoreModule *m, void *data, bool (*cb)(AbckitCoreNamespace *n, void *data)) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(m == DEFAULT_CORE_MODULE); + cb(DEFAULT_CORE_NAMESPACE, data); +} + +inline void ModuleEnumerateClasses(AbckitCoreModule *m, void *data, bool (*cb)(AbckitCoreClass *klass, void *data)) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(m == DEFAULT_CORE_MODULE); + cb(DEFAULT_CORE_CLASS, data); +} + +inline void ModuleEnumerateTopLevelFunctions(AbckitCoreModule *m, void *data, + bool (*cb)(AbckitCoreFunction *function, void *data)) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(m == DEFAULT_CORE_MODULE); + cb(DEFAULT_CORE_FUNCTION, data); +} + +inline void ModuleEnumerateAnonymousFunctions(AbckitCoreModule *m, void *data, + bool (*cb)(AbckitCoreFunction *function, void *data)) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(m == DEFAULT_CORE_MODULE); + cb(DEFAULT_CORE_FUNCTION, data); +} + +inline void ModuleEnumerateAnnotationInterfaces(AbckitCoreModule *m, void *data, + bool (*cb)(AbckitCoreAnnotationInterface *ai, void *data)) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(m == DEFAULT_CORE_MODULE); + cb(DEFAULT_CORE_ANNOTATION_INTERFACE, data); +} + +// ======================================== +// Namespace +// ======================================== + +inline AbckitString *NamespaceGetName(AbckitCoreNamespace *n) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(n == DEFAULT_CORE_NAMESPACE); + return DEFAULT_STRING; +} + +inline AbckitCoreNamespace *NamespaceGetParentNamespace(AbckitCoreNamespace *n) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(n == DEFAULT_CORE_NAMESPACE); + return DEFAULT_CORE_NAMESPACE; +} + +inline void NamespaceEnumerateNamespaces(AbckitCoreNamespace *n, void *data, + bool (*cb)(AbckitCoreNamespace *klass, void *data)) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(n == DEFAULT_CORE_NAMESPACE); + cb(DEFAULT_CORE_NAMESPACE, data); +} + +inline void NamespaceEnumerateClasses(AbckitCoreNamespace *n, void *data, + bool (*cb)(AbckitCoreClass *klass, void *data)) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(n == DEFAULT_CORE_NAMESPACE); + cb(DEFAULT_CORE_CLASS, data); +} + +inline void NamespaceEnumerateTopLevelFunctions(AbckitCoreNamespace *n, void *data, + bool (*cb)(AbckitCoreFunction *func, void *data)) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(n == DEFAULT_CORE_NAMESPACE); + cb(DEFAULT_CORE_FUNCTION, data); +} + +// ======================================== +// ImportDescriptor +// ======================================== + +inline AbckitFile *ImportDescriptorGetFile(AbckitCoreImportDescriptor *i) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(i == DEFAULT_CORE_IMPORT_DESCRIPTOR); + return DEFAULT_FILE; +} + +inline AbckitCoreModule *ImportDescriptorGetImportedModule(AbckitCoreImportDescriptor *i) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(i == DEFAULT_CORE_IMPORT_DESCRIPTOR); + return DEFAULT_CORE_MODULE; +} + +inline AbckitCoreModule *ImportDescriptorGetImportingModule(AbckitCoreImportDescriptor *i) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(i == DEFAULT_CORE_IMPORT_DESCRIPTOR); + return DEFAULT_CORE_MODULE; +} + +inline AbckitString *ImportDescriptorGetName(AbckitCoreImportDescriptor *i) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(i == DEFAULT_CORE_IMPORT_DESCRIPTOR); + return DEFAULT_STRING; +} + +inline AbckitString *ImportDescriptorGetAlias(AbckitCoreImportDescriptor *i) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(i == DEFAULT_CORE_IMPORT_DESCRIPTOR); + return DEFAULT_STRING; +} + +// ======================================== +// ExportDescriptor +// ======================================== + +inline AbckitFile *ExportDescriptorGetFile(AbckitCoreExportDescriptor *i) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(i == DEFAULT_CORE_EXPORT_DESCRIPTOR); + return DEFAULT_FILE; +} + +inline AbckitCoreModule *ExportDescriptorGetExportingModule(AbckitCoreExportDescriptor *i) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(i == DEFAULT_CORE_EXPORT_DESCRIPTOR); + return DEFAULT_CORE_MODULE; +} + +inline AbckitCoreModule *ExportDescriptorGetExportedModule(AbckitCoreExportDescriptor *i) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(i == DEFAULT_CORE_EXPORT_DESCRIPTOR); + return DEFAULT_CORE_MODULE; +} + +inline AbckitString *ExportDescriptorGetName(AbckitCoreExportDescriptor *i) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(i == DEFAULT_CORE_EXPORT_DESCRIPTOR); + return DEFAULT_STRING; +} + +inline AbckitString *ExportDescriptorGetAlias(AbckitCoreExportDescriptor *i) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(i == DEFAULT_CORE_EXPORT_DESCRIPTOR); + return DEFAULT_STRING; +} + +// ======================================== +// Class +// ======================================== + +inline AbckitFile *ClassGetFile(AbckitCoreClass *klass) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(klass == DEFAULT_CORE_CLASS); + return DEFAULT_FILE; +} + +inline AbckitCoreModule *ClassGetModule(AbckitCoreClass *klass) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(klass == DEFAULT_CORE_CLASS); + return DEFAULT_CORE_MODULE; +} + +inline AbckitString *ClassGetName(AbckitCoreClass *klass) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(klass == DEFAULT_CORE_CLASS); + return DEFAULT_STRING; +} + +inline AbckitCoreFunction *ClassGetParentFunction(AbckitCoreClass *klass) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(klass == DEFAULT_CORE_CLASS); + return DEFAULT_CORE_FUNCTION; +} + +inline AbckitCoreNamespace *ClassGetParentNamespace(AbckitCoreClass *klass) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(klass == DEFAULT_CORE_CLASS); + return DEFAULT_CORE_NAMESPACE; +} + +inline void ClassEnumerateMethods(AbckitCoreClass *klass, void *data, + bool (*cb)(AbckitCoreFunction *function, void *data)) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(klass == DEFAULT_CORE_CLASS); + cb(DEFAULT_CORE_FUNCTION, data); +} + +inline void ClassEnumerateAnnotations(AbckitCoreClass *klass, void *data, + bool (*cb)(AbckitCoreAnnotation *anno, void *data)) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(klass == DEFAULT_CORE_CLASS); + cb(DEFAULT_CORE_ANNOTATION, data); +} + +// ======================================== +// AnnotationInterface +// ======================================== + +inline AbckitFile *AnnotationInterfaceGetFile(AbckitCoreAnnotationInterface *anno) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(anno == DEFAULT_CORE_ANNOTATION_INTERFACE); + return DEFAULT_FILE; +} + +inline AbckitCoreModule *AnnotationInterfaceGetModule(AbckitCoreAnnotationInterface *anno) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(anno == DEFAULT_CORE_ANNOTATION_INTERFACE); + return DEFAULT_CORE_MODULE; +} + +inline AbckitString *AnnotationInterfaceGetName(AbckitCoreAnnotationInterface *ai) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(ai == DEFAULT_CORE_ANNOTATION_INTERFACE); + return DEFAULT_STRING; +} + +inline void AnnotationInterfaceEnumerateFields(AbckitCoreAnnotationInterface *ai, void *data, + bool (*cb)(AbckitCoreAnnotationInterfaceField *fld, void *data)) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(ai == DEFAULT_CORE_ANNOTATION_INTERFACE); + cb(DEFAULT_CORE_ANNOTATION_INTERFACE_FIELD, data); +} + +// ======================================== +// AnnotationInterfaceField +// ======================================== + +inline AbckitFile *AnnotationInterfaceFieldGetFile(AbckitCoreAnnotationInterfaceField *fld) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(fld == DEFAULT_CORE_ANNOTATION_INTERFACE_FIELD); + return DEFAULT_FILE; +} + +inline AbckitCoreAnnotationInterface *AnnotationInterfaceFieldGetInterface(AbckitCoreAnnotationInterfaceField *fld) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(fld == DEFAULT_CORE_ANNOTATION_INTERFACE_FIELD); + return DEFAULT_CORE_ANNOTATION_INTERFACE; +} + +inline AbckitString *AnnotationInterfaceFieldGetName(AbckitCoreAnnotationInterfaceField *fld) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(fld == DEFAULT_CORE_ANNOTATION_INTERFACE_FIELD); + return DEFAULT_STRING; +} + +inline AbckitType *AnnotationInterfaceFieldGetType(AbckitCoreAnnotationInterfaceField *fld) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(fld == DEFAULT_CORE_ANNOTATION_INTERFACE_FIELD); + return DEFAULT_TYPE; +} + +inline AbckitValue *AnnotationInterfaceFieldGetDefaultValue(AbckitCoreAnnotationInterfaceField *fld) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(fld == DEFAULT_CORE_ANNOTATION_INTERFACE_FIELD); + return DEFAULT_VALUE; +} + +// ======================================== +// Function +// ======================================== + +inline AbckitFile *FunctionGetFile(AbckitCoreFunction *function) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(function == DEFAULT_CORE_FUNCTION); + return DEFAULT_FILE; +} + +inline AbckitCoreModule *FunctionGetModule(AbckitCoreFunction *function) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(function == DEFAULT_CORE_FUNCTION); + return DEFAULT_CORE_MODULE; +} + +inline AbckitString *FunctionGetName(AbckitCoreFunction *function) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(function == DEFAULT_CORE_FUNCTION); + return DEFAULT_STRING; +} + +inline AbckitCoreFunction *FunctionGetParentFunction(AbckitCoreFunction *function) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(function == DEFAULT_CORE_FUNCTION); + return DEFAULT_CORE_FUNCTION; +} + +inline AbckitCoreClass *FunctionGetParentClass(AbckitCoreFunction *function) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(function == DEFAULT_CORE_FUNCTION); + return DEFAULT_CORE_CLASS; +} + +inline AbckitCoreNamespace *FunctionGetParentNamespace(AbckitCoreFunction *function) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(function == DEFAULT_CORE_FUNCTION); + return DEFAULT_CORE_NAMESPACE; +} + +inline void FunctionEnumerateNestedFunctions(AbckitCoreFunction *function, void *data, + bool (*cb)(AbckitCoreFunction *nestedFunc, void *data)) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(function == DEFAULT_CORE_FUNCTION); + cb(DEFAULT_CORE_FUNCTION, data); +} + +inline void FunctionEnumerateNestedClasses(AbckitCoreFunction *function, void *data, + bool (*cb)(AbckitCoreClass *nestedClass, void *data)) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(function == DEFAULT_CORE_FUNCTION); + cb(DEFAULT_CORE_CLASS, data); +} + +inline void FunctionEnumerateAnnotations(AbckitCoreFunction *function, void *data, + bool (*cb)(AbckitCoreAnnotation *anno, void *data)) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(function == DEFAULT_CORE_FUNCTION); + cb(DEFAULT_CORE_ANNOTATION, data); +} + +inline AbckitGraph *CreateGraphFromFunction(AbckitCoreFunction *function) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(function == DEFAULT_CORE_FUNCTION); + return DEFAULT_GRAPH; +} + +inline bool FunctionIsStatic(AbckitCoreFunction *function) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(function == DEFAULT_CORE_FUNCTION); + return DEFAULT_BOOL; +} + +inline bool FunctionIsCtor(AbckitCoreFunction *function) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(function == DEFAULT_CORE_FUNCTION); + return DEFAULT_BOOL; +} + +inline bool FunctionIsAnonymous(AbckitCoreFunction *function) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(function == DEFAULT_CORE_FUNCTION); + return DEFAULT_BOOL; +} + +// ======================================== +// Annotation +// ======================================== + +inline AbckitFile *AnnotationGetFile(AbckitCoreAnnotation *anno) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(anno == DEFAULT_CORE_ANNOTATION); + return DEFAULT_FILE; +} +inline AbckitCoreAnnotationInterface *AnnotationGetInterface(AbckitCoreAnnotation *anno) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(anno == DEFAULT_CORE_ANNOTATION); + return DEFAULT_CORE_ANNOTATION_INTERFACE; +} + +inline void AnnotationEnumerateElements(AbckitCoreAnnotation *anno, void *data, + bool (*cb)(AbckitCoreAnnotationElement *ae, void *data)) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(anno == DEFAULT_CORE_ANNOTATION); + cb(DEFAULT_CORE_ANNOTATION_ELEMENT, data); +} + +// ======================================== +// AnnotationElement +// ======================================== + +inline AbckitFile *AnnotationElementGetFile(AbckitCoreAnnotationElement *ae) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(ae == DEFAULT_CORE_ANNOTATION_ELEMENT); + return DEFAULT_FILE; +} + +inline AbckitCoreAnnotation *AnnotationElementGetAnnotation(AbckitCoreAnnotationElement *ae) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(ae == DEFAULT_CORE_ANNOTATION_ELEMENT); + return DEFAULT_CORE_ANNOTATION; +} + +inline AbckitString *AnnotationElementGetName(AbckitCoreAnnotationElement *ae) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(ae == DEFAULT_CORE_ANNOTATION_ELEMENT); + return DEFAULT_STRING; +} + +inline AbckitValue *AnnotationElementGetValue(AbckitCoreAnnotationElement *ae) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(ae == DEFAULT_CORE_ANNOTATION_ELEMENT); + return DEFAULT_VALUE; +} + +// ======================================== +// Type +// ======================================== + +inline AbckitTypeId TypeGetTypeId(AbckitType *type) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(type == DEFAULT_TYPE); + return DEFAULT_TYPE_ID; +} + +inline AbckitCoreClass *TypeGetReferenceClass(AbckitType *type) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(type == DEFAULT_TYPE); + return DEFAULT_CORE_CLASS; +} + +// ======================================== +// Value +// ======================================== + +inline AbckitFile *ValueGetFile(AbckitValue *value) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(value == DEFAULT_VALUE); + return DEFAULT_FILE; +} + +inline AbckitType *ValueGetType(AbckitValue *value) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(value == DEFAULT_VALUE); + return DEFAULT_TYPE; +} + +inline bool ValueGetU1(AbckitValue *value) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(value == DEFAULT_VALUE); + return DEFAULT_BOOL; +} + +inline double ValueGetDouble(AbckitValue *value) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(value == DEFAULT_VALUE); + return DEFAULT_DOUBLE; +} + +inline AbckitString *ValueGetString(AbckitValue *value) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(value == DEFAULT_VALUE); + return DEFAULT_STRING; +} + +inline AbckitLiteralArray *ArrayValueGetLiteralArray(AbckitValue *value) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(value == DEFAULT_VALUE); + return DEFAULT_LITERAL_ARRAY; +} + +// ======================================== +// String +// ======================================== + +inline const char *AbckitStringToString(AbckitString *value) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(value == DEFAULT_STRING); + return DEFAULT_CONST_CHAR; +} + +// ======================================== +// LiteralArray +// ======================================== + +inline void LiteralArrayEnumerateElements(AbckitLiteralArray *litArr, void *data, + bool (*cb)(AbckitFile *file, AbckitLiteral *v, void *data)) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(litArr == DEFAULT_LITERAL_ARRAY); + cb(DEFAULT_FILE, DEFAULT_LITERAL, data); +} + +// ======================================== +// Literal +// ======================================== + +inline AbckitFile *LiteralGetFile(AbckitLiteral *lit) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(lit == DEFAULT_LITERAL); + return DEFAULT_FILE; +} + +inline AbckitLiteralTag LiteralGetTag(AbckitLiteral *lit) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(lit == DEFAULT_LITERAL); + return DEFAULT_LITERAL_TAG; +} + +inline bool LiteralGetBool(AbckitLiteral *lit) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(lit == DEFAULT_LITERAL); + return DEFAULT_BOOL; +} + +inline uint8_t LiteralGetU8(AbckitLiteral *lit) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(lit == DEFAULT_LITERAL); + return DEFAULT_U8; +} + +inline uint16_t LiteralGetU16(AbckitLiteral *lit) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(lit == DEFAULT_LITERAL); + return DEFAULT_U16; +} + +inline uint16_t LiteralGetMethodAffiliate(AbckitLiteral *lit) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(lit == DEFAULT_LITERAL); + return DEFAULT_U16; +} + +inline uint32_t LiteralGetU32(AbckitLiteral *lit) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(lit == DEFAULT_LITERAL); + return DEFAULT_U32; +} + +inline uint64_t LiteralGetU64(AbckitLiteral *lit) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(lit == DEFAULT_LITERAL); + return DEFAULT_U64; +} + +inline float LiteralGetFloat(AbckitLiteral *lit) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(lit == DEFAULT_LITERAL); + return DEFAULT_FLOAT; +} + +inline double LiteralGetDouble(AbckitLiteral *lit) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(lit == DEFAULT_LITERAL); + return DEFAULT_DOUBLE; +} + +inline AbckitLiteralArray *LiteralGetLiteralArray(AbckitLiteral *lit) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(lit == DEFAULT_LITERAL); + return DEFAULT_LITERAL_ARRAY; +} + +inline AbckitString *LiteralGetString(AbckitLiteral *lit) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(lit == DEFAULT_LITERAL); + return DEFAULT_STRING; +} + +inline AbckitString *LiteralGetMethod(AbckitLiteral *lit) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(lit == DEFAULT_LITERAL); + return DEFAULT_STRING; +} + +static AbckitInspectApi g_inspectApiImpl = { + // ======================================== + // File + // ======================================== + + FileGetVersion, + FileEnumerateModules, + FileEnumerateExternalModules, + + // ======================================== + // String + // ======================================== + + AbckitStringToString, + + // ======================================== + // Type + // ======================================== + + TypeGetTypeId, + TypeGetReferenceClass, + + // ======================================== + // Value + // ======================================== + + ValueGetFile, + ValueGetType, + ValueGetU1, + ValueGetDouble, + ValueGetString, + ArrayValueGetLiteralArray, + + // ======================================== + // Literal + // ======================================== + + LiteralGetFile, + LiteralGetTag, + LiteralGetBool, + LiteralGetU8, + LiteralGetU16, + LiteralGetMethodAffiliate, + LiteralGetU32, + LiteralGetU64, + LiteralGetFloat, + LiteralGetDouble, + LiteralGetLiteralArray, + LiteralGetString, + LiteralGetMethod, + + // ======================================== + // LiteralArray + // ======================================== + + LiteralArrayEnumerateElements, + + // ======================================== + // Module + // ======================================== + + ModuleGetFile, + ModuleGetTarget, + ModuleGetName, + ModuleIsExternal, + ModuleEnumerateImports, + ModuleEnumerateExports, + ModuleEnumerateNamespaces, + ModuleEnumerateClasses, + ModuleEnumerateTopLevelFunctions, + ModuleEnumerateAnonymousFunctions, + ModuleEnumerateAnnotationInterfaces, + + // ======================================== + // Namespace + // ======================================== + + NamespaceGetName, + NamespaceGetParentNamespace, + NamespaceEnumerateNamespaces, + NamespaceEnumerateClasses, + NamespaceEnumerateTopLevelFunctions, + + // ======================================== + // ImportDescriptor + // ======================================== + + ImportDescriptorGetFile, + ImportDescriptorGetImportingModule, + ImportDescriptorGetImportedModule, + ImportDescriptorGetName, + ImportDescriptorGetAlias, + + // ======================================== + // ExportDescriptor + // ======================================== + + ExportDescriptorGetFile, + ExportDescriptorGetExportingModule, + ExportDescriptorGetExportedModule, + ExportDescriptorGetName, + ExportDescriptorGetAlias, + + // ======================================== + // Class + // ======================================== + + ClassGetFile, + ClassGetModule, + ClassGetName, + ClassGetParentFunction, + ClassGetParentNamespace, + ClassEnumerateMethods, + ClassEnumerateAnnotations, + + // ======================================== + // Function + // ======================================== + + FunctionGetFile, + FunctionGetModule, + FunctionGetName, + FunctionGetParentFunction, + FunctionGetParentClass, + FunctionGetParentNamespace, + FunctionEnumerateNestedFunctions, + FunctionEnumerateNestedClasses, + FunctionEnumerateAnnotations, + CreateGraphFromFunction, + FunctionIsStatic, + FunctionIsCtor, + FunctionIsAnonymous, + + // ======================================== + // Annotation + // ======================================== + + AnnotationGetFile, + AnnotationGetInterface, + AnnotationEnumerateElements, + AnnotationElementGetFile, + AnnotationElementGetAnnotation, + AnnotationElementGetName, + AnnotationElementGetValue, + + // ======================================== + // AnnotationInterface + // ======================================== + + AnnotationInterfaceGetFile, + AnnotationInterfaceGetModule, + AnnotationInterfaceGetName, + AnnotationInterfaceEnumerateFields, + + // ======================================== + // AnnotationInterfaceField + // ======================================== + + AnnotationInterfaceFieldGetFile, + AnnotationInterfaceFieldGetInterface, + AnnotationInterfaceFieldGetName, + AnnotationInterfaceFieldGetType, + AnnotationInterfaceFieldGetDefaultValue, +}; + +// NOLINTEND(readability-identifier-naming) + +} // namespace libabckit::mock + +AbckitInspectApi const *AbckitGetMockInspectApiImpl([[maybe_unused]] AbckitApiVersion version) +{ + return &libabckit::mock::g_inspectApiImpl; +} + +#endif // ABCKIT_INSPECT_IMPL_MOCK diff --git a/libabckit/tests/mock/metadata_modify_impl_mock.cpp b/libabckit/tests/mock/metadata_modify_impl_mock.cpp new file mode 100644 index 0000000000..588b82dd92 --- /dev/null +++ b/libabckit/tests/mock/metadata_modify_impl_mock.cpp @@ -0,0 +1,326 @@ +/** + * Copyright (c) 2024 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 ABCKIT_MODIFY_IMPL_MOCK +#define ABCKIT_MODIFY_IMPL_MOCK + +/** + * Copyright (c) 2024 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 "../../src/mock/abckit_mock.h" +#include "../../src/mock/mock_values.h" + +#include "../../include/c/metadata_core.h" + +#include + +namespace libabckit::mock { + +// NOLINTBEGIN(readability-identifier-naming) + +// ======================================== +// File +// ======================================== + +// ======================================== +// Module +// ======================================== + +// ======================================== +// Class +// ======================================== + +// ======================================== +// AnnotationInterface +// ======================================== + +// ======================================== +// Function +// ======================================== + +inline void FunctionSetGraph(AbckitCoreFunction *function, AbckitGraph *graph) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(function == DEFAULT_CORE_FUNCTION); + EXPECT_TRUE(graph == DEFAULT_GRAPH); +} + +// ======================================== +// Annotation +// ======================================== + +// ======================================== +// Type +// ======================================== + +inline AbckitType *CreateType(AbckitFile *file, AbckitTypeId id) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(file == DEFAULT_FILE); + EXPECT_TRUE(id == DEFAULT_TYPE_ID); + return DEFAULT_TYPE; +} + +inline AbckitType *CreateReferenceType(AbckitFile *file, AbckitCoreClass *klass) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(file == DEFAULT_FILE); + EXPECT_TRUE(klass == DEFAULT_CORE_CLASS); + return DEFAULT_TYPE; +} + +// ======================================== +// Value +// ======================================== + +inline AbckitValue *CreateValueU1(AbckitFile *file, bool value) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(file == DEFAULT_FILE); + EXPECT_TRUE(value == DEFAULT_BOOL); + return DEFAULT_VALUE; +} + +inline AbckitValue *CreateValueDouble(AbckitFile *file, double value) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(file == DEFAULT_FILE); + EXPECT_TRUE(value == DEFAULT_DOUBLE); + return DEFAULT_VALUE; +} + +inline AbckitValue *CreateValueString(AbckitFile *file, const char *value) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(file == DEFAULT_FILE); + EXPECT_TRUE(strncmp(value, DEFAULT_CONST_CHAR, sizeof(DEFAULT_CONST_CHAR)) == 0); + return DEFAULT_VALUE; +} + +inline AbckitValue *CreateLiteralArrayValue(AbckitFile *file, AbckitValue **value, size_t size) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(file == DEFAULT_FILE); + EXPECT_TRUE(*value == DEFAULT_VALUE); + EXPECT_TRUE(size == DEFAULT_SIZE_T); + return DEFAULT_VALUE; +} + +// ======================================== +// String +// ======================================== + +inline AbckitString *CreateString(AbckitFile *file, const char *value) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(file == DEFAULT_FILE); + EXPECT_TRUE(strncmp(value, DEFAULT_CONST_CHAR, sizeof(DEFAULT_CONST_CHAR)) == 0); + return DEFAULT_STRING; +} + +// ======================================== +// LiteralArray +// ======================================== + +inline AbckitLiteralArray *CreateLiteralArray(AbckitFile *file, AbckitLiteral **value, size_t size) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(file == DEFAULT_FILE); + EXPECT_TRUE(*value == DEFAULT_LITERAL); + EXPECT_TRUE(size == DEFAULT_SIZE_T); + return DEFAULT_LITERAL_ARRAY; +} + +inline AbckitLiteral *CreateLiteralBool(AbckitFile *file, bool value) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(file == DEFAULT_FILE); + EXPECT_TRUE(value == DEFAULT_BOOL); + return DEFAULT_LITERAL; +} + +inline AbckitLiteral *CreateLiteralU8(AbckitFile *file, uint8_t value) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(file == DEFAULT_FILE); + EXPECT_TRUE(value == DEFAULT_U8); + return DEFAULT_LITERAL; +} + +inline AbckitLiteral *CreateLiteralU16(AbckitFile *file, uint16_t value) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(file == DEFAULT_FILE); + EXPECT_TRUE(value == DEFAULT_U16); + return DEFAULT_LITERAL; +} + +inline AbckitLiteral *CreateLiteralMethodAffiliate(AbckitFile *file, uint16_t value) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(file == DEFAULT_FILE); + EXPECT_TRUE(value == DEFAULT_U16); + return DEFAULT_LITERAL; +} +inline AbckitLiteral *CreateLiteralU32(AbckitFile *file, uint32_t value) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(file == DEFAULT_FILE); + EXPECT_TRUE(value == DEFAULT_U32); + return DEFAULT_LITERAL; +} + +inline AbckitLiteral *CreateLiteralU64(AbckitFile *file, uint64_t value) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(file == DEFAULT_FILE); + EXPECT_TRUE(value == DEFAULT_U64); + return DEFAULT_LITERAL; +} + +inline AbckitLiteral *CreateLiteralFloat(AbckitFile *file, float value) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(file == DEFAULT_FILE); + EXPECT_TRUE(value == DEFAULT_FLOAT); + return DEFAULT_LITERAL; +} + +inline AbckitLiteral *CreateLiteralDouble(AbckitFile *file, double value) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(file == DEFAULT_FILE); + EXPECT_TRUE(value == DEFAULT_DOUBLE); + return DEFAULT_LITERAL; +} + +inline AbckitLiteral *CreateLiteralLiteralArray(AbckitFile *file, AbckitLiteralArray *litarr) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(file == DEFAULT_FILE); + EXPECT_TRUE(litarr == DEFAULT_LITERAL_ARRAY); + return DEFAULT_LITERAL; +} + +inline AbckitLiteral *CreateLiteralString(AbckitFile *file, const char *value) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(file == DEFAULT_FILE); + EXPECT_TRUE(strncmp(value, DEFAULT_CONST_CHAR, sizeof(DEFAULT_CONST_CHAR)) == 0); + return DEFAULT_LITERAL; +} + +inline AbckitLiteral *CreateLiteralMethod(AbckitFile *file, AbckitCoreFunction *function) +{ + g_calledFuncs.push(__func__); + EXPECT_TRUE(file == DEFAULT_FILE); + EXPECT_TRUE(function == DEFAULT_CORE_FUNCTION); + return DEFAULT_LITERAL; +} + +// NOLINTEND(readability-identifier-naming) + +static AbckitModifyApi g_modifyApiImpl = { + + // ======================================== + // File + // ======================================== + + // ======================================== + // Module + // ======================================== + + // ======================================== + // Class + // ======================================== + + // ======================================== + // AnnotationInterface + // ======================================== + + // ======================================== + // Function + // ======================================== + + FunctionSetGraph, + + // ======================================== + // Annotation + // ======================================== + + // ======================================== + // Type + // ======================================== + + CreateType, + CreateReferenceType, + + // ======================================== + // Value + // ======================================== + + CreateValueU1, + CreateValueDouble, + CreateValueString, + CreateLiteralArrayValue, + + // ======================================== + // String + // ======================================== + + CreateString, + + // ======================================== + // LiteralArray + // ======================================== + + CreateLiteralArray, + + // ======================================== + // LiteralArray + // ======================================== + + CreateLiteralBool, + CreateLiteralU8, + CreateLiteralU16, + CreateLiteralMethodAffiliate, + CreateLiteralU32, + CreateLiteralU64, + CreateLiteralFloat, + CreateLiteralDouble, + CreateLiteralLiteralArray, + CreateLiteralString, + CreateLiteralMethod, +}; + +} // namespace libabckit::mock + +AbckitModifyApi const *AbckitGetMockModifyApiImpl([[maybe_unused]] AbckitApiVersion version) +{ + return &libabckit::mock::g_modifyApiImpl; +} + +#endif // ABCKIT_MODIFY_IMPL_MOCK diff --git a/libabckit/tests/mock/tests/cpp_mock_file.cpp b/libabckit/tests/mock/tests/cpp_mock_file.cpp index d4e55b86c2..a826682f20 100644 --- a/libabckit/tests/mock/tests/cpp_mock_file.cpp +++ b/libabckit/tests/mock/tests/cpp_mock_file.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "include/cpp/abckit_cpp.h" +#include "../../../include/cpp/abckit_cpp.h" #include "../check_mock.h" #include @@ -27,11 +27,33 @@ TEST_F(LibAbcKitCppMockTest, CppTestMockFile) { { abckit::File file("abckit.abc"); - ASSERT_TRUE(CheckMockedApi("openAbc")); + ASSERT_TRUE(CheckMockedApi("OpenAbc")); file.WriteAbc("abckit.abc"); - ASSERT_TRUE(CheckMockedApi("writeAbc")); + ASSERT_TRUE(CheckMockedApi("WriteAbc")); } - ASSERT_TRUE(CheckMockedApi("closeFile")); + ASSERT_TRUE(CheckMockedApi("CloseFile")); +} + +// Test: test-kind=internal, abc-kind=ArkTS1, category=internal +TEST_F(LibAbcKitCppMockTest, CppTestMockFileEnumerateModules) +{ + { + abckit::File file("abckit.abc"); + ASSERT_TRUE(CheckMockedApi("OpenAbc")); + + std::vector modules; + + file.EnumerateModules([&](const abckit::core::Module &md) -> bool { + modules.push_back(md); + return true; + }); + + ASSERT_TRUE(CheckMockedApi("FileEnumerateModules")); + + file.WriteAbc("abckit.abc"); + ASSERT_TRUE(CheckMockedApi("WriteAbc")); + } + ASSERT_TRUE(CheckMockedApi("CloseFile")); } } // namespace libabckit::test