mirror of
https://gitee.com/openharmony/arkcompiler_runtime_core
synced 2024-11-23 06:40:32 +00:00
Update version for Function name with scopes
Signed-off-by: shixiaowei4 <shixiaowei4@huawei.com> Change-Id: I5ff43c21ff8b3df02871f1a137338d33b94ee857
This commit is contained in:
parent
1e2050c695
commit
81e6c6b804
@ -19,9 +19,10 @@
|
||||
|
||||
namespace panda::abc2program {
|
||||
|
||||
std::set<std::string> Abc2ProgramTestUtils::helloworld_expected_program_strings_ = {"", ".HelloWorld", ".Lit",
|
||||
".foo", ".goo", ".hoo",
|
||||
".instance_initializer",
|
||||
std::set<std::string> Abc2ProgramTestUtils::helloworld_expected_program_strings_ = {"", ".#~@0=#HelloWorld",
|
||||
".#~@1=#Lit", ".#*#hoo",
|
||||
".#*#foo", ".#*#goo",
|
||||
".#~@0>#instance_initializer",
|
||||
"HelloWorld", "varA", "error",
|
||||
"inner catch",
|
||||
"masg", "max", "min", "msg",
|
||||
@ -30,11 +31,12 @@ std::set<std::string> Abc2ProgramTestUtils::helloworld_expected_program_strings_
|
||||
"string", "toString", "x"};
|
||||
std::vector<std::string> Abc2ProgramTestUtils::helloworld_expected_record_names_ = {"_ESModuleRecord",
|
||||
"_ESSlotNumberAnnotation",
|
||||
"_ESScopeNamesRecord",
|
||||
"_GLOBAL"};
|
||||
std::vector<std::string> Abc2ProgramTestUtils::helloworld_expected_literal_array_keys_ = {"_ESModuleRecord_2247",
|
||||
"_GLOBAL_2327",
|
||||
"_GLOBAL_2336",
|
||||
"_GLOBAL_2345"};
|
||||
std::vector<std::string> Abc2ProgramTestUtils::helloworld_expected_literal_array_keys_ = {"_ESModuleRecord_2412",
|
||||
"_GLOBAL_2492",
|
||||
"_GLOBAL_2501",
|
||||
"_GLOBAL_2510"};
|
||||
|
||||
std::set<size_t> Abc2ProgramTestUtils::helloworld_expected_literals_sizes_ = {2, 8, 21};
|
||||
|
||||
|
@ -27,10 +27,10 @@ using namespace testing::ext;
|
||||
namespace panda::abc2program {
|
||||
const std::string HELLO_WORLD_ABC_TEST_FILE_NAME = GRAPH_TEST_ABC_DIR "HelloWorld.abc";
|
||||
constexpr uint32_t NUM_OF_CODE_TEST_UT_FOO_METHOD_INS = 77;
|
||||
constexpr std::string_view FUNC_NAME_HELLO_WORLD = ".HelloWorld";
|
||||
constexpr std::string_view FUNC_NAME_FOO = ".foo";
|
||||
constexpr std::string_view FUNC_NAME_GOO = ".goo";
|
||||
constexpr std::string_view FUNC_NAME_HOO = ".hoo";
|
||||
constexpr std::string_view FUNC_NAME_HELLO_WORLD = ".#~@0=#HelloWorld";
|
||||
constexpr std::string_view FUNC_NAME_FOO = ".#*#foo";
|
||||
constexpr std::string_view FUNC_NAME_GOO = ".#*#goo";
|
||||
constexpr std::string_view FUNC_NAME_HOO = ".#*#hoo";
|
||||
constexpr std::string_view FUNC_NAME_MAIN = ".func_main_0";
|
||||
constexpr uint8_t INS_SIZE_OF_FUNCTION_HOO = 7;
|
||||
constexpr uint8_t IMMS_SIZE_OF_OPCODE_FLDAI = 1;
|
||||
@ -180,15 +180,15 @@ HWTEST_F(Abc2ProgramHelloWorldTest, abc2program_hello_world_test_record_table, T
|
||||
HWTEST_F(Abc2ProgramHelloWorldTest, abc2program_hello_world_test_fields, TestSize.Level1)
|
||||
{
|
||||
for (const auto &it : prog_->record_table) {
|
||||
if (it.first == "_ESModuleRecord") {
|
||||
if (it.first == "_ESModuleRecord" || it.first == "_ESScopeNamesRecord") {
|
||||
const pandasm::Record &record = it.second;
|
||||
const std::vector<pandasm::Field> &field_list = record.field_list;
|
||||
EXPECT_TRUE(field_list.size() == 1);
|
||||
EXPECT_EQ(field_list.size(), 1);
|
||||
const pandasm::Field &field = field_list[0];
|
||||
EXPECT_TRUE(field.type.GetPandasmName() == "u32");
|
||||
EXPECT_TRUE(field.name.find("HelloWorld.js") != std::string::npos);
|
||||
EXPECT_EQ(field.type.GetPandasmName(), "u32");
|
||||
EXPECT_NE(field.name.find("HelloWorld.js"), std::string::npos);
|
||||
} else {
|
||||
EXPECT_TRUE(it.second.field_list.size() == 0);
|
||||
EXPECT_EQ(it.second.field_list.size(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,10 @@ public:
|
||||
graph->RunPass<panda::compiler::IrBuilder>();
|
||||
|
||||
auto method_name = std::string(utf::Mutf8AsCString(pfile->GetStringData(mda.GetNameId()).data));
|
||||
|
||||
auto pos = method_name.find_last_of("#");
|
||||
if (pos != std::string::npos) {
|
||||
method_name = method_name.substr(pos + 1);
|
||||
}
|
||||
cb(graph, method_name);
|
||||
}
|
||||
});
|
||||
|
@ -81,7 +81,10 @@ public:
|
||||
graph->RunPass<panda::compiler::IrBuilder>();
|
||||
|
||||
auto method_name = std::string(utf::Mutf8AsCString(pfile->GetStringData(mda.GetNameId()).data));
|
||||
|
||||
auto pos = method_name.find_last_of("#");
|
||||
if (pos != std::string::npos) {
|
||||
method_name = method_name.substr(pos + 1);
|
||||
}
|
||||
cb(graph, method_name);
|
||||
});
|
||||
}
|
||||
|
@ -102,9 +102,12 @@ public:
|
||||
false, nullptr, true, true);
|
||||
graph->RunPass<panda::compiler::IrBuilder>();
|
||||
|
||||
auto methodName = std::string(utf::Mutf8AsCString(pfile->GetStringData(mda.GetNameId()).data));
|
||||
|
||||
cb(graph, methodName);
|
||||
auto method_name = std::string(utf::Mutf8AsCString(pfile->GetStringData(mda.GetNameId()).data));
|
||||
auto pos = method_name.find_last_of("#");
|
||||
if (pos != std::string::npos) {
|
||||
method_name = method_name.substr(pos + 1);
|
||||
}
|
||||
cb(graph, method_name);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -489,7 +489,7 @@ void Disassembler::GetFields(pandasm::Record *record, const panda_file::File::En
|
||||
uint32_t field_type = field_accessor.GetType();
|
||||
field.type = FieldTypeToPandasmType(field_type);
|
||||
|
||||
GetMetaData(&field, field_accessor.GetFieldId());
|
||||
GetMetaData(&field, field_accessor.GetFieldId(), record->name == ark::SCOPE_NAME_RECORD);
|
||||
|
||||
record->field_list.push_back(std::move(field));
|
||||
});
|
||||
@ -887,7 +887,9 @@ void Disassembler::GetMetaData(pandasm::Record *record, const panda_file::File::
|
||||
}
|
||||
}
|
||||
|
||||
void Disassembler::GetMetaData(pandasm::Field *field, const panda_file::File::EntityId &field_id)
|
||||
void Disassembler::GetMetaData(pandasm::Field *field,
|
||||
const panda_file::File::EntityId &field_id,
|
||||
bool is_scope_names_record)
|
||||
{
|
||||
LOG(DEBUG, DISASSEMBLER) << "[getting metadata]\nfield id: " << field_id << " (0x" << std::hex << field_id << ")";
|
||||
|
||||
@ -909,8 +911,8 @@ void Disassembler::GetMetaData(pandasm::Field *field, const panda_file::File::En
|
||||
|
||||
if (field->type.GetId() == panda_file::Type::TypeId::U32) {
|
||||
const auto offset = field_accessor.GetValue<uint32_t>().value();
|
||||
static const std::string TYPE_SUMMARY_FIELD_NAME = "typeSummaryOffset";
|
||||
if (field->name != TYPE_SUMMARY_FIELD_NAME) {
|
||||
bool is_scope_name_field = is_scope_names_record || field->name == ark::SCOPE_NAMES;
|
||||
if (field->name != ark::TYPE_SUMMARY_FIELD_NAME && !is_scope_name_field) {
|
||||
LOG(DEBUG, DISASSEMBLER) << "Module literalarray " << field->name << " at offset 0x" << std::hex << offset
|
||||
<< " is excluded";
|
||||
module_literals_.insert(offset);
|
||||
|
@ -113,7 +113,7 @@ private:
|
||||
|
||||
void GetMetaData(pandasm::Record *record, const panda_file::File::EntityId &record_id) const;
|
||||
void GetMetaData(pandasm::Function *method, const panda_file::File::EntityId &method_id) const;
|
||||
void GetMetaData(pandasm::Field *field, const panda_file::File::EntityId &field_id);
|
||||
void GetMetaData(pandasm::Field *field, const panda_file::File::EntityId &field_id, bool is_scope_names_record);
|
||||
|
||||
void GetLanguageSpecificMetadata();
|
||||
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
*/
|
||||
HWTEST_F(DisassemblerAnnotationTest, disassembler_annotation_test_001, TestSize.Level1)
|
||||
{
|
||||
static const std::string METHOD_NAME = "module-requests-annotation-import.funcD";
|
||||
static const std::string METHOD_NAME = "module-requests-annotation-import.#*#funcD";
|
||||
static const std::string ANNOTATION_NAME = "L_ESConcurrentModuleRequestsAnnotation";
|
||||
panda::disasm::Disassembler disasm {};
|
||||
disasm.Disassemble(MODULE_REQUEST_FILE_NAME, false, false);
|
||||
@ -69,7 +69,7 @@ HWTEST_F(DisassemblerAnnotationTest, disassembler_annotation_test_001, TestSize.
|
||||
*/
|
||||
HWTEST_F(DisassemblerAnnotationTest, disassembler_annotation_test_002, TestSize.Level1)
|
||||
{
|
||||
static const std::string METHOD_NAME = "funcA";
|
||||
static const std::string METHOD_NAME = "#*#funcA";
|
||||
static const std::string ANNOTATION_NAME = "L_ESSlotNumberAnnotation";
|
||||
panda::disasm::Disassembler disasm {};
|
||||
disasm.Disassemble(SLOT_NUMBER_FILE_NAME, false, false);
|
||||
|
@ -43,16 +43,10 @@ HWTEST_F(DisasmTest, disassembler_column_number_test_001, TestSize.Level1)
|
||||
// The known column number in the abc file
|
||||
std::vector<size_t> expectedColumnNumber = {10, 14, 6, -1, 1, 8, 4, 8, 4, -1};
|
||||
std::vector<size_t> columnNumber = disasm.GetColumnNumber();
|
||||
EXPECT_TRUE(expectedColumnNumber.size() == columnNumber.size());
|
||||
bool res = true;
|
||||
|
||||
ASSERT_EQ(expectedColumnNumber.size(), columnNumber.size());
|
||||
for (size_t i = 0; i < expectedColumnNumber.size(); ++i) {
|
||||
if (expectedColumnNumber[i] != columnNumber[i]) {
|
||||
res = false;
|
||||
break;
|
||||
}
|
||||
EXPECT_EQ(expectedColumnNumber[i], columnNumber[i]);
|
||||
}
|
||||
EXPECT_TRUE(res);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -70,15 +64,10 @@ HWTEST_F(DisasmTest, disassembler_column_number_test_002, TestSize.Level1)
|
||||
// The known column number in the abc file
|
||||
std::vector<size_t> expectedColumnNumber = {10, 6, 10, 6, 10, 6, -1, 1};
|
||||
std::vector<size_t> columnNumber = disasm.GetColumnNumber();
|
||||
EXPECT_TRUE(expectedColumnNumber.size() == columnNumber.size());
|
||||
bool res = true;
|
||||
ASSERT_EQ(expectedColumnNumber.size(), columnNumber.size());
|
||||
for (size_t i = 0; i < expectedColumnNumber.size(); ++i) {
|
||||
if (expectedColumnNumber[i] != columnNumber[i]) {
|
||||
res = false;
|
||||
break;
|
||||
}
|
||||
EXPECT_EQ(expectedColumnNumber[i], columnNumber[i]);
|
||||
}
|
||||
EXPECT_TRUE(res);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -96,15 +85,10 @@ HWTEST_F(DisasmTest, disassembler_column_number_test_003, TestSize.Level1)
|
||||
// The known column number in the abc file
|
||||
std::vector<size_t> expectedColumnNumber = {4, 16, 4, 15, 4, -1, 3, 14, 6, 14, 6, -1};
|
||||
std::vector<size_t> columnNumber = disasm.GetColumnNumber();
|
||||
EXPECT_TRUE(expectedColumnNumber.size() == columnNumber.size());
|
||||
bool res = true;
|
||||
ASSERT_EQ(expectedColumnNumber.size(), columnNumber.size());
|
||||
for (size_t i = 0; i < expectedColumnNumber.size(); ++i) {
|
||||
if (expectedColumnNumber[i] != columnNumber[i]) {
|
||||
res = false;
|
||||
break;
|
||||
}
|
||||
EXPECT_EQ(expectedColumnNumber[i], columnNumber[i]);
|
||||
}
|
||||
EXPECT_TRUE(res);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -121,15 +105,10 @@ HWTEST_F(DisasmTest, disassembler_column_number_test_004, TestSize.Level1)
|
||||
disasm.CollectInfo();
|
||||
std::vector<size_t> expectedColumnNumber = {10, 14, 6, 10, 6, 10, 14, 6, 9, 1, 1, 4, -1, 3, 8, 4, 8, 4, -1};
|
||||
std::vector<size_t> columnNumber = disasm.GetColumnNumber();
|
||||
EXPECT_TRUE(expectedColumnNumber.size() == columnNumber.size());
|
||||
bool res = true;
|
||||
ASSERT_EQ(expectedColumnNumber.size(), columnNumber.size());
|
||||
for (size_t i = 0; i < expectedColumnNumber.size(); ++i) {
|
||||
if (expectedColumnNumber[i] != columnNumber[i]) {
|
||||
res = false;
|
||||
break;
|
||||
}
|
||||
EXPECT_EQ(expectedColumnNumber[i], columnNumber[i]);
|
||||
}
|
||||
EXPECT_TRUE(res);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -145,18 +124,13 @@ HWTEST_F(DisasmTest, disassembler_column_number_test_005, TestSize.Level1)
|
||||
disasm.Disassemble(file_name, false, false);
|
||||
disasm.CollectInfo();
|
||||
// The known column number in the abc file
|
||||
std::vector<size_t> expectedColumnNumber = {4, 16, 4, 15, 4, -1, 3, 10, 6, 10, 6, 10, 14, 6, 10,
|
||||
14, 6, 9, 1, 2, -1, 1, 14, 6, 14, 6, 8, 4, -1};
|
||||
std::vector<size_t> expectedColumnNumber = {10, 6, 10, 6, 10, 14, 6, 10, 14, 6, 9, 1, 2, -1, 1,
|
||||
4, 16, 4, 15, 4, -1, 3, 14, 6, 14, 6, 8, 4, -1};
|
||||
std::vector<size_t> columnNumber = disasm.GetColumnNumber();
|
||||
EXPECT_TRUE(expectedColumnNumber.size() == columnNumber.size());
|
||||
bool res = true;
|
||||
ASSERT_EQ(expectedColumnNumber.size(), columnNumber.size());
|
||||
for (size_t i = 0; i < expectedColumnNumber.size(); ++i) {
|
||||
if (expectedColumnNumber[i] != columnNumber[i]) {
|
||||
res = false;
|
||||
break;
|
||||
}
|
||||
EXPECT_EQ(expectedColumnNumber[i], columnNumber[i]);
|
||||
}
|
||||
EXPECT_TRUE(res);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -172,19 +146,14 @@ HWTEST_F(DisasmTest, disassembler_column_number_test_006, TestSize.Level1)
|
||||
disasm.Disassemble(file_name, false, false);
|
||||
disasm.CollectInfo();
|
||||
// The known column number in the abc file
|
||||
std::vector<size_t> expectedColumnNumber = {15, 8, 16, 15, 8, -1, 3, 13, 6, 21, 37, 21, 15, 8, 10,
|
||||
4, 1, 4, -1, 1, 6, 1, 13, 6, 10, 26, 10, 4, -1, 1, 6, 1,
|
||||
14, 6, 14, 6, -1, 13, 6, 10, 4, 1, 4, -1, 1, 0, 13, 6, 12,
|
||||
11, 4, -1, 1};
|
||||
std::vector<size_t> expectedColumnNumber = {13, 6, 21, 37, 21, 15, 8, 10, 4, 1, 4, -1, 1, 6, 1,
|
||||
13, 6, 10, 26, 10, 4, -1, 1, 6, 1, 13, 6, 10, 4, 1, 4, -1,
|
||||
1, 0, 13, 6, 12, 11, 4, -1, 1, 15, 8, 16, 15, 8, -1, 3,
|
||||
14, 6, 14, 6, -1};
|
||||
std::vector<size_t> columnNumber = disasm.GetColumnNumber();
|
||||
EXPECT_TRUE(expectedColumnNumber.size() == columnNumber.size());
|
||||
bool res = true;
|
||||
ASSERT_EQ(expectedColumnNumber.size(), columnNumber.size());
|
||||
for (size_t i = 0; i < expectedColumnNumber.size(); ++i) {
|
||||
if (expectedColumnNumber[i] != columnNumber[i]) {
|
||||
res = false;
|
||||
break;
|
||||
}
|
||||
EXPECT_EQ(expectedColumnNumber[i], columnNumber[i]);
|
||||
}
|
||||
EXPECT_TRUE(res);
|
||||
}
|
||||
}
|
||||
|
@ -32,11 +32,11 @@ class DisassemblerGetFileNameTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase(void)
|
||||
{
|
||||
if (std::filesystem::exists(FILE_NAME)) {
|
||||
std::filesystem::remove(FILE_NAME);
|
||||
}
|
||||
std::filesystem::path src_file_name{ SOURCE_FILE_PATH };
|
||||
std::filesystem::path file_name{ FILE_NAME };
|
||||
std::filesystem::path src_file_name{ SOURCE_FILE_PATH };
|
||||
if (std::filesystem::exists(file_name)) {
|
||||
std::filesystem::remove(file_name);
|
||||
}
|
||||
std::filesystem::copy(src_file_name, file_name);
|
||||
};
|
||||
|
||||
|
@ -43,15 +43,10 @@ HWTEST_F(DisasmTest, disassembler_line_number_test_001, TestSize.Level1)
|
||||
// The known line number in the abc file
|
||||
std::vector<size_t> expectedLineNumber = {-1, 15, -1, 15, -1};
|
||||
std::vector<size_t> lineNumber = disasm.GetLineNumber();
|
||||
EXPECT_TRUE(expectedLineNumber.size() == lineNumber.size());
|
||||
bool res = true;
|
||||
ASSERT_EQ(expectedLineNumber.size(), lineNumber.size());
|
||||
for (size_t i = 0; i < lineNumber.size(); ++i) {
|
||||
if (expectedLineNumber[i] != lineNumber[i]) {
|
||||
res = false;
|
||||
break;
|
||||
}
|
||||
EXPECT_EQ(expectedLineNumber[i], lineNumber[i]);
|
||||
}
|
||||
EXPECT_TRUE(res);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -67,18 +62,13 @@ HWTEST_F(DisasmTest, disassembler_line_number_test_002, TestSize.Level1)
|
||||
disasm.Disassemble(file_name, false, false);
|
||||
disasm.CollectInfo();
|
||||
// The known line number in the abc file
|
||||
std::vector<size_t> expectedLineNumber = {-1, 17, 18, 19, -1, 21, -1, 15,
|
||||
-1, -1, 25, 26, 27, -1, 29};
|
||||
std::vector<size_t> expectedLineNumber = {-1, 25, 26, 27, -1, 29, -1, 17,
|
||||
18, 19, -1, 21, -1, 15, -1};
|
||||
std::vector<size_t> lineNumber = disasm.GetLineNumber();
|
||||
EXPECT_TRUE(expectedLineNumber.size() == lineNumber.size());
|
||||
bool res = true;
|
||||
ASSERT_EQ(expectedLineNumber.size(), lineNumber.size());
|
||||
for (size_t i = 0; i < lineNumber.size(); ++i) {
|
||||
if (expectedLineNumber[i] != lineNumber[i]) {
|
||||
res = false;
|
||||
break;
|
||||
}
|
||||
EXPECT_EQ(expectedLineNumber[i], lineNumber[i]);
|
||||
}
|
||||
EXPECT_TRUE(res);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -96,15 +86,10 @@ HWTEST_F(DisasmTest, disassembler_line_number_test_003, TestSize.Level1)
|
||||
// The known line number in the abc file
|
||||
std::vector<size_t> expectedLineNumber = {-1, 16, -1, 17, 15, 17, -1};
|
||||
std::vector<size_t> lineNumber = disasm.GetLineNumber();
|
||||
EXPECT_TRUE(expectedLineNumber.size() == lineNumber.size());
|
||||
bool res = true;
|
||||
ASSERT_EQ(expectedLineNumber.size(), lineNumber.size());
|
||||
for (size_t i = 0; i < lineNumber.size(); ++i) {
|
||||
if (expectedLineNumber[i] != lineNumber[i]) {
|
||||
res = false;
|
||||
break;
|
||||
}
|
||||
EXPECT_EQ(expectedLineNumber[i], lineNumber[i]);
|
||||
}
|
||||
EXPECT_TRUE(res);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -120,17 +105,12 @@ HWTEST_F(DisasmTest, disassembler_line_number_test_004, TestSize.Level1)
|
||||
disasm.Disassemble(file_name, false, false);
|
||||
disasm.CollectInfo();
|
||||
// The known line number in the abc file
|
||||
std::vector<size_t> expectedLineNumber = {-1, -1, 16, 17, 18, 20, 18, -1, 20, 15};
|
||||
std::vector<size_t> expectedLineNumber = {-1, 16, 17, 18, 20, 18, -1, 20, 15, -1};
|
||||
std::vector<size_t> lineNumber = disasm.GetLineNumber();
|
||||
EXPECT_TRUE(expectedLineNumber.size() == lineNumber.size());
|
||||
bool res = true;
|
||||
ASSERT_EQ(expectedLineNumber.size(), lineNumber.size());
|
||||
for (size_t i = 0; i < lineNumber.size(); ++i) {
|
||||
if (expectedLineNumber[i] != lineNumber[i]) {
|
||||
res = false;
|
||||
break;
|
||||
}
|
||||
EXPECT_EQ(expectedLineNumber[i], lineNumber[i]);
|
||||
}
|
||||
EXPECT_TRUE(res);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -148,15 +128,10 @@ HWTEST_F(DisasmTest, disassembler_line_number_test_005, TestSize.Level1)
|
||||
// The known line number in the abc file
|
||||
std::vector<size_t> expectedLineNumber = {-1, 16, 17, 18, 19, 21, 19, -1, 21, 15, 21, -1};
|
||||
std::vector<size_t> lineNumber = disasm.GetLineNumber();
|
||||
EXPECT_TRUE(expectedLineNumber.size() == lineNumber.size());
|
||||
bool res = true;
|
||||
ASSERT_EQ(expectedLineNumber.size(), lineNumber.size());
|
||||
for (size_t i = 0; i < lineNumber.size(); ++i) {
|
||||
if (expectedLineNumber[i] != lineNumber[i]) {
|
||||
res = false;
|
||||
break;
|
||||
}
|
||||
EXPECT_EQ(expectedLineNumber[i], lineNumber[i]);
|
||||
}
|
||||
EXPECT_TRUE(res);
|
||||
}
|
||||
|
||||
}
|
@ -107,10 +107,10 @@ chapters:
|
||||
|
||||
# File format and ISA versioning
|
||||
min_version: 0.0.0.2
|
||||
version: 12.0.3.0
|
||||
version: 12.0.4.0
|
||||
|
||||
# 0 is default value, alaways reflects to the newest version
|
||||
api_version_map: [[0, 12.0.3.0], [9, 9.0.0.0], [10, 9.0.0.0], [11, 11.0.2.0], [12, 12.0.3.0]]
|
||||
api_version_map: [[0, 12.0.4.0], [9, 9.0.0.0], [10, 9.0.0.0], [11, 11.0.2.0], [12, 12.0.4.0]]
|
||||
|
||||
# When delete bytecode or having any incompatible modification on bytecode,
|
||||
# please add the incompatible version in this list for prompting error message.
|
||||
|
@ -48,10 +48,27 @@ const std::vector<const Function *> &Class::GetMemberFunctionList() const
|
||||
return member_func_list_;
|
||||
}
|
||||
|
||||
static std::string GetFuncNameWithoutPrefix(const std::string &func_name)
|
||||
{
|
||||
auto name = std::string(func_name);
|
||||
auto pos1 = name.find_first_of("#");
|
||||
auto pos2 = name.find_last_of("#");
|
||||
if (pos1 == pos2) {
|
||||
ASSERT(pos1 == std::string::npos);
|
||||
return name;
|
||||
}
|
||||
ASSERT(pos1 != std::string::npos);
|
||||
ASSERT(pos2 != std::string::npos);
|
||||
auto record_name = name.substr(0, pos1);
|
||||
auto fun_name = name.substr(pos2 + 1);
|
||||
return record_name + fun_name;
|
||||
}
|
||||
|
||||
const Function *Class::GetMemberFunctionByName(std::string_view func_name) const
|
||||
{
|
||||
auto func_name_without_prefix = GetFuncNameWithoutPrefix(std::string(func_name));
|
||||
for (auto func : member_func_list_) {
|
||||
if (func->GetFunctionName() == func_name) {
|
||||
if (GetFuncNameWithoutPrefix(func->GetFunctionName()) == func_name_without_prefix) {
|
||||
return func;
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public:
|
||||
void TearDown() {};
|
||||
};
|
||||
|
||||
HWTEST(DefectScanAuxMergeTest, AcrossAbcTest, testing::ext::TestSize.Level0)
|
||||
HWTEST(DefectScanAuxMergeTest, AcrossAbcTest_0, testing::ext::TestSize.Level0)
|
||||
{
|
||||
std::string name = DEFECT_SCAN_AUX_TEST_MERGE_ABC_DIR "across_abc_test.abc";
|
||||
auto abc_file = panda::defect_scan_aux::AbcFile::Open(name);
|
||||
@ -50,12 +50,13 @@ HWTEST(DefectScanAuxMergeTest, AcrossAbcTest, testing::ext::TestSize.Level0)
|
||||
auto all_func_size = abc_file->GetDefinedFunctionCount();
|
||||
EXPECT_EQ(all_func_size, 18U);
|
||||
|
||||
auto class_userinput = abc_file->GetClassByName("Luser_input;UserInput");
|
||||
ASSERT(class_userinput != nullptr);
|
||||
auto class_userinput = abc_file->GetClassByName("Luser_input;#~@0=#UserInput");
|
||||
ASSERT_NE(class_userinput, nullptr);
|
||||
auto class_userinput_member_func_size = class_userinput->GetMemberFunctionCount();
|
||||
EXPECT_EQ(class_userinput_member_func_size, 3U);
|
||||
[[maybe_unused]] auto func_setText = class_userinput->GetMemberFunctionByName("Luser_input;setText");
|
||||
ASSERT(func_setText->GetClass() == class_userinput);
|
||||
[[maybe_unused]] auto func_setText = class_userinput->GetMemberFunctionByName("Luser_input;#~@0>#setText");
|
||||
ASSERT_NE(func_setText, nullptr);
|
||||
EXPECT_EQ(func_setText->GetClass(), class_userinput);
|
||||
|
||||
auto userinput_func_main_0 = abc_file->GetFunctionByName("Luser_input;func_main_0");
|
||||
auto &graph = userinput_func_main_0->GetGraph();
|
||||
@ -65,24 +66,34 @@ HWTEST(DefectScanAuxMergeTest, AcrossAbcTest, testing::ext::TestSize.Level0)
|
||||
std::string inter_name0 = abc_file->GetLocalNameByExportName("DBInterface", "Ldatabase;");
|
||||
EXPECT_EQ(inter_name0, "DatabaseInterface");
|
||||
auto ex_class = abc_file->GetExportClassByExportName("DBInterface", "Ldatabase;");
|
||||
EXPECT_EQ(ex_class->GetClassName(), "Ldatabase;DatabaseInterface");
|
||||
EXPECT_EQ(ex_class->GetClassName(), "Ldatabase;#~@1=#DatabaseInterface");
|
||||
|
||||
std::string inter_name1 = abc_file->GetLocalNameByExportName("getblankInstanceInterface", "Ldatabase;");
|
||||
EXPECT_EQ(inter_name1, "getblankInstance1");
|
||||
auto ex_func1 = abc_file->GetExportFunctionByExportName("getblankInstanceInterface", "Ldatabase;");
|
||||
EXPECT_EQ(ex_func1->GetFunctionName(), "Ldatabase;getblankInstance1");
|
||||
EXPECT_EQ(ex_func1->GetFunctionName(), "Ldatabase;#*#getblankInstance1");
|
||||
|
||||
auto ex_func2 = abc_file->GetExportFunctionByExportName("default", "Ldatabase;");
|
||||
EXPECT_EQ(ex_func2->GetFunctionName(), "Ldatabase;getblankInstance2");
|
||||
EXPECT_EQ(ex_func2->GetFunctionName(), "Ldatabase;#*#getblankInstance2");
|
||||
}
|
||||
|
||||
auto child_class = abc_file->GetClassByName("Ldatabase;DatabaseInterface");
|
||||
EXPECT_EQ(child_class->GetParentClassName(), "Ldatabase;Database");
|
||||
ASSERT_TRUE(child_class->GetMemberFunctionByName("Ldatabase;getText") == child_class->GetMemberFunctionByIndex(1));
|
||||
HWTEST(DefectScanAuxMergeTest, AcrossAbcTest_1, testing::ext::TestSize.Level0)
|
||||
{
|
||||
std::string name = DEFECT_SCAN_AUX_TEST_MERGE_ABC_DIR "across_abc_test.abc";
|
||||
auto abc_file = panda::defect_scan_aux::AbcFile::Open(name);
|
||||
ASSERT(abc_file != nullptr);
|
||||
|
||||
auto child_class = abc_file->GetClassByName("Ldatabase;#~@1=#DatabaseInterface");
|
||||
ASSERT_NE(child_class, nullptr);
|
||||
EXPECT_EQ(child_class->GetParentClassName(), "Ldatabase;#~@0=#Database");
|
||||
EXPECT_EQ(child_class->GetMemberFunctionByName("Ldatabase;#~@1>#getText"),
|
||||
child_class->GetMemberFunctionByIndex(1));
|
||||
auto database_func_main_0 = abc_file->GetFunctionByName("Ldatabase;func_main_0");
|
||||
ASSERT_NE(database_func_main_0, nullptr);
|
||||
auto callee_info = database_func_main_0->GetCalleeInfoByIndex(0);
|
||||
ASSERT_TRUE(callee_info->IsCalleeDefinite());
|
||||
EXPECT_EQ(callee_info->GetClass(), abc_file->GetClassByName("Ldatabase;Database"));
|
||||
EXPECT_EQ(callee_info->GetCallee(), abc_file->GetFunctionByName("Ldatabase;addData"));
|
||||
ASSERT_NE(callee_info, nullptr);
|
||||
EXPECT_TRUE(callee_info->IsCalleeDefinite());
|
||||
EXPECT_EQ(callee_info->GetClass(), abc_file->GetClassByName("Ldatabase;#~@0=#Database"));
|
||||
EXPECT_EQ(callee_info->GetCallee(), abc_file->GetFunctionByName("Ldatabase;#~@0>#addData"));
|
||||
}
|
||||
} // namespace panda::defect_scan_aux::test
|
||||
|
@ -31,9 +31,15 @@ public:
|
||||
|
||||
static const Function *CheckFunction(std::unique_ptr<const AbcFile> &abc_file, std::string_view func_name)
|
||||
{
|
||||
ASSERT(abc_file != nullptr);
|
||||
if (abc_file == nullptr) {
|
||||
EXPECT_NE(abc_file, nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
auto func0 = abc_file->GetFunctionByName(func_name);
|
||||
ASSERT(func0 != nullptr);
|
||||
if (func0 == nullptr) {
|
||||
EXPECT_NE(func0, nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
EXPECT_EQ(func0->GetFunctionName(), func_name);
|
||||
return func0;
|
||||
}
|
||||
@ -41,12 +47,15 @@ static const Function *CheckFunction(std::unique_ptr<const AbcFile> &abc_file, s
|
||||
static bool ContainDefinedFunction(std::unique_ptr<const AbcFile> &abc_file,
|
||||
const Function *par_func, std::string_view func_name)
|
||||
{
|
||||
ASSERT(abc_file != nullptr);
|
||||
if (abc_file == nullptr) {
|
||||
EXPECT_NE(abc_file, nullptr);
|
||||
return false;
|
||||
}
|
||||
size_t df_cnt0 = par_func->GetDefinedFunctionCount();
|
||||
for (size_t i = 0; i < df_cnt0; ++i) {
|
||||
auto df = par_func->GetDefinedFunctionByIndex(i);
|
||||
if (df->GetFunctionName() == func_name) {
|
||||
ASSERT(df->GetParentFunction() == par_func);
|
||||
EXPECT_EQ(df->GetParentFunction(), par_func);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -56,16 +65,18 @@ static bool ContainDefinedFunction(std::unique_ptr<const AbcFile> &abc_file,
|
||||
static bool ContainMemberFunction(std::unique_ptr<const AbcFile> &abc_file,
|
||||
const Class *class0, std::string_view func_name)
|
||||
{
|
||||
ASSERT(abc_file != nullptr);
|
||||
if (abc_file == nullptr) {
|
||||
EXPECT_NE(abc_file, nullptr);
|
||||
return false;
|
||||
}
|
||||
size_t mf_func_count = class0->GetMemberFunctionCount();
|
||||
for (size_t i = 0; i < mf_func_count; ++i) {
|
||||
auto mf = class0->GetMemberFunctionByIndex(i);
|
||||
if (mf->GetFunctionName() == func_name) {
|
||||
ASSERT(class0->GetMemberFunctionByName(func_name) == mf);
|
||||
EXPECT_EQ(class0->GetMemberFunctionByName(func_name), mf);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
auto par_class = class0->GetParentClass();
|
||||
if (par_class != nullptr) {
|
||||
return ContainMemberFunction(abc_file, par_class, func_name);
|
||||
@ -75,16 +86,26 @@ static bool ContainMemberFunction(std::unique_ptr<const AbcFile> &abc_file,
|
||||
|
||||
static const Class *CheckClass(std::unique_ptr<const AbcFile> &abc_file, std::string_view class_name)
|
||||
{
|
||||
ASSERT(abc_file != nullptr);
|
||||
if (abc_file == nullptr) {
|
||||
EXPECT_NE(abc_file, nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
auto *class0 = abc_file->GetClassByName(class_name);
|
||||
ASSERT(class0 != nullptr);
|
||||
if (class0 == nullptr) {
|
||||
EXPECT_NE(class0, nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
EXPECT_EQ(class0->GetClassName(), class_name);
|
||||
[[maybe_unused]] size_t mf_func_count = class0->GetMemberFunctionCount();
|
||||
ASSERT(mf_func_count >= 1);
|
||||
[[maybe_unused]] auto mf_func0 = class0->GetMemberFunctionByIndex(0);
|
||||
ASSERT(abc_file->GetFunctionByName(class_name) == mf_func0);
|
||||
ASSERT(class0->GetMemberFunctionByName(class_name) == mf_func0);
|
||||
ASSERT(mf_func0->GetClass() == class0);
|
||||
if (mf_func0 == nullptr) {
|
||||
EXPECT_NE(mf_func0, nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
EXPECT_EQ(abc_file->GetFunctionByName(class_name), mf_func0);
|
||||
EXPECT_EQ(class0->GetMemberFunctionByName(class_name), mf_func0);
|
||||
EXPECT_EQ(mf_func0->GetClass(), class0);
|
||||
CheckFunction(abc_file, class_name);
|
||||
return class0;
|
||||
}
|
||||
@ -106,90 +127,89 @@ size_t def_func_cnt = abc_file->GetDefinedFunctionCount();
|
||||
ASSERT_TRUE(f0->GetParentFunction() == nullptr);
|
||||
size_t dc_cnt0 = f0->GetDefinedClassCount();
|
||||
EXPECT_EQ(dc_cnt0, 2U);
|
||||
EXPECT_EQ(f0->GetDefinedClassByIndex(0)->GetClassName(), "Bar");
|
||||
EXPECT_EQ(f0->GetDefinedClassByIndex(1)->GetClassName(), "ExampleClass1");
|
||||
EXPECT_EQ(f0->GetDefinedClassByIndex(0)->GetClassName(), "#~@1=#Bar");
|
||||
EXPECT_EQ(f0->GetDefinedClassByIndex(1)->GetClassName(), "#~@4=#ExampleClass1");
|
||||
size_t df_cnt0 = f0->GetDefinedFunctionCount();
|
||||
EXPECT_EQ(df_cnt0, 12U);
|
||||
ASSERT_TRUE(ContainDefinedFunction(abc_file, f0, "func1"));
|
||||
ASSERT_TRUE(ContainDefinedFunction(abc_file, f0, "func2"));
|
||||
ASSERT_FALSE(ContainDefinedFunction(abc_file, f0, "func3"));
|
||||
ASSERT_TRUE(ContainDefinedFunction(abc_file, f0, "func6"));
|
||||
ASSERT_TRUE(ContainDefinedFunction(abc_file, f0, "getName"));
|
||||
ASSERT_TRUE(ContainDefinedFunction(abc_file, f0, "setName"));
|
||||
ASSERT_TRUE(ContainDefinedFunction(abc_file, f0, "func9"));
|
||||
ASSERT_TRUE(ContainDefinedFunction(abc_file, f0, "func10"));
|
||||
ASSERT_TRUE(ContainDefinedFunction(abc_file, f0, "func17"));
|
||||
ASSERT_TRUE(ContainDefinedFunction(abc_file, f0, "#*#func1"));
|
||||
ASSERT_TRUE(ContainDefinedFunction(abc_file, f0, "#*#func2"));
|
||||
ASSERT_FALSE(ContainDefinedFunction(abc_file, f0, "func1"));
|
||||
ASSERT_TRUE(ContainDefinedFunction(abc_file, f0, "#~@1>#func6"));
|
||||
ASSERT_TRUE(ContainDefinedFunction(abc_file, f0, "#~@1>#getName"));
|
||||
ASSERT_TRUE(ContainDefinedFunction(abc_file, f0, "#~@1>#setName"));
|
||||
ASSERT_TRUE(ContainDefinedFunction(abc_file, f0, "#~@1>#func9"));
|
||||
ASSERT_TRUE(ContainDefinedFunction(abc_file, f0, "#*#func10"));
|
||||
ASSERT_TRUE(ContainDefinedFunction(abc_file, f0, "#~@4>#func17"));
|
||||
// func2
|
||||
auto f1 = CheckFunction(abc_file, "func2");
|
||||
auto f1 = CheckFunction(abc_file, "#*#func2");
|
||||
ASSERT_NE(f1, nullptr);
|
||||
EXPECT_EQ(f1->GetArgCount(), 5U);
|
||||
size_t df_cnt1 = f1->GetDefinedFunctionCount();
|
||||
EXPECT_EQ(df_cnt1, 2U);
|
||||
ASSERT_TRUE(ContainDefinedFunction(abc_file, f1, "func4"));
|
||||
ASSERT_TRUE(ContainDefinedFunction(abc_file, f1, "#*@0*#func4"));
|
||||
// func10
|
||||
auto f2 = CheckFunction(abc_file, "func10");
|
||||
auto f2 = CheckFunction(abc_file, "#*#func10");
|
||||
EXPECT_EQ(f2->GetArgCount(), 3U);
|
||||
size_t dc_cnt2 = f2->GetDefinedClassCount();
|
||||
EXPECT_EQ(dc_cnt2, 2U);
|
||||
EXPECT_EQ(f2->GetDefinedClassByIndex(0)->GetClassName(),
|
||||
"#11247673030038003130#Bar");
|
||||
EXPECT_EQ(f2->GetDefinedClassByIndex(1)->GetClassName(), "Bar2");
|
||||
"#*@2~@1=#Bar");
|
||||
EXPECT_EQ(f2->GetDefinedClassByIndex(1)->GetClassName(), "#*@2~@3=#Bar2");
|
||||
size_t df_cnt2 = f2->GetDefinedFunctionCount();
|
||||
EXPECT_EQ(df_cnt2, 7U);
|
||||
ASSERT_TRUE(ContainDefinedFunction(abc_file, f2, "baseFoo1"));
|
||||
ASSERT_TRUE(ContainDefinedFunction(abc_file, f2, "func12"));
|
||||
ASSERT_TRUE(ContainDefinedFunction(abc_file, f2, "a"));
|
||||
ASSERT_TRUE(ContainDefinedFunction(abc_file, f2, "symbol"));
|
||||
ASSERT_TRUE(ContainDefinedFunction(abc_file, f2, "func15"));
|
||||
|
||||
EXPECT_TRUE(ContainDefinedFunction(abc_file, f2, "#*@2~@1>#baseFoo1"));
|
||||
EXPECT_TRUE(ContainDefinedFunction(abc_file, f2, "#*@2~@3>#func12"));
|
||||
EXPECT_TRUE(ContainDefinedFunction(abc_file, f2, "#*@2~@3>#a"));
|
||||
EXPECT_TRUE(ContainDefinedFunction(abc_file, f2, "#*@2~@3>#symbol"));
|
||||
EXPECT_TRUE(ContainDefinedFunction(abc_file, f2, "#*@2~@3>#func15"));
|
||||
// check each defined class
|
||||
// #1#Bar
|
||||
auto class0 = CheckClass(abc_file, "Bar");
|
||||
auto class0 = CheckClass(abc_file, "#~@1=#Bar");
|
||||
ASSERT_TRUE(class0->GetParentClass() == nullptr);
|
||||
ASSERT_TRUE(class0->GetDefiningFunction() == f0);
|
||||
size_t mf_count0 = class0->GetMemberFunctionCount();
|
||||
EXPECT_EQ(mf_count0, 5U);
|
||||
ASSERT_TRUE(ContainMemberFunction(abc_file, class0, "func6"));
|
||||
ASSERT_TRUE(ContainMemberFunction(abc_file, class0, "getName"));
|
||||
ASSERT_TRUE(ContainMemberFunction(abc_file, class0, "setName"));
|
||||
ASSERT_TRUE(ContainMemberFunction(abc_file, class0, "func9"));
|
||||
EXPECT_TRUE(ContainMemberFunction(abc_file, class0, "#~@1>#func6"));
|
||||
EXPECT_TRUE(ContainMemberFunction(abc_file, class0, "#~@1>#getName"));
|
||||
EXPECT_TRUE(ContainMemberFunction(abc_file, class0, "#~@1>#setName"));
|
||||
EXPECT_TRUE(ContainMemberFunction(abc_file, class0, "#~@1>#func9"));
|
||||
// #3#Bar2
|
||||
auto class1 = CheckClass(abc_file, "Bar2");
|
||||
auto class1 = CheckClass(abc_file, "#*@2~@3=#Bar2");
|
||||
ASSERT_TRUE(class1->GetParentClass() != nullptr);
|
||||
ASSERT_TRUE(class1->GetDefiningFunction() == abc_file->GetFunctionByName("func10"));
|
||||
ASSERT_TRUE(class1->GetDefiningFunction() == abc_file->GetFunctionByName("#*#func10"));
|
||||
size_t mf_count1 = class1->GetMemberFunctionCount();
|
||||
EXPECT_EQ(mf_count1, 5U);
|
||||
ASSERT_TRUE(ContainMemberFunction(abc_file, class1, "baseFoo1"));
|
||||
ASSERT_TRUE(ContainMemberFunction(abc_file, class1, "func12"));
|
||||
ASSERT_TRUE(ContainMemberFunction(abc_file, class1, "func15"));
|
||||
EXPECT_TRUE(ContainMemberFunction(abc_file, class1, "#*@2~@1>#baseFoo1"));
|
||||
EXPECT_TRUE(ContainMemberFunction(abc_file, class1, "#*@2~@3>#func12"));
|
||||
EXPECT_TRUE(ContainMemberFunction(abc_file, class1, "#*@2~@3>#func15"));
|
||||
// #8#ExampleClass2
|
||||
auto class2 = CheckClass(abc_file, "ExampleClass2");
|
||||
ASSERT_TRUE(class2->GetParentClass() ==
|
||||
abc_file->GetClassByName("#2505994642537462424#ExampleClass1"));
|
||||
ASSERT_FALSE(ContainMemberFunction(abc_file, class2, "func17"));
|
||||
ASSERT_TRUE(ContainMemberFunction(abc_file, class2, "func19"));
|
||||
auto class2 = CheckClass(abc_file, "#*@5*@7~@6=#ExampleClass2");
|
||||
EXPECT_EQ(class2->GetParentClassName(), "#*@5~@4=#ExampleClass1");
|
||||
EXPECT_FALSE(ContainMemberFunction(abc_file, class2, "#~@4=#func17"));
|
||||
EXPECT_TRUE(ContainMemberFunction(abc_file, class2, "#*@5~@4>#func19"));
|
||||
// #9#ExtendService
|
||||
auto class3 = CheckClass(abc_file, "ExtendService");
|
||||
auto class3 = CheckClass(abc_file, "#*@9~@8=#ExtendService");
|
||||
ASSERT_TRUE(class3->GetParentClass() == nullptr);
|
||||
EXPECT_EQ(class3->GetParentClassName(), "BaseService");
|
||||
EXPECT_EQ(class3->GetParClassExternalModuleName(), "../base/service");
|
||||
ASSERT_TRUE(class3->GetParClassGlobalVarName().empty());
|
||||
EXPECT_TRUE(class3->GetParClassGlobalVarName().empty());
|
||||
// #10#ExtendPhoneService
|
||||
auto class4 = CheckClass(abc_file, "ExtendPhoneService");
|
||||
auto class4 = CheckClass(abc_file, "#*@9~@a=#ExtendPhoneService");
|
||||
ASSERT_TRUE(class4->GetParentClass() == nullptr);
|
||||
EXPECT_EQ(class4->GetParentClassName(), "PhoneService");
|
||||
EXPECT_EQ(class4->GetParClassExternalModuleName(), "../mod1");
|
||||
ASSERT_TRUE(class4->GetParClassGlobalVarName().empty());
|
||||
EXPECT_TRUE(class4->GetParClassGlobalVarName().empty());
|
||||
// #11#ExtendDataSource
|
||||
auto class5 = CheckClass(abc_file, "ExtendDataSource");
|
||||
auto class5 = CheckClass(abc_file, "#*@9~@b=#ExtendDataSource");
|
||||
ASSERT_TRUE(class5->GetParentClass() == nullptr);
|
||||
EXPECT_EQ(class5->GetParentClassName(), "BasicDataSource");
|
||||
ASSERT_TRUE(class5->GetParClassExternalModuleName().empty());
|
||||
EXPECT_TRUE(class5->GetParClassExternalModuleName().empty());
|
||||
EXPECT_EQ(class5->GetParClassGlobalVarName(), "globalvar");
|
||||
// #12#ExtendDataItem
|
||||
auto class6 = CheckClass(abc_file, "ExtendDataItem");
|
||||
auto class6 = CheckClass(abc_file, "#*@9~@c=#ExtendDataItem");
|
||||
ASSERT_TRUE(class6->GetParentClass() == nullptr);
|
||||
EXPECT_EQ(class6->GetParentClassName(), "DataItem");
|
||||
ASSERT_TRUE(class6->GetParClassExternalModuleName().empty());
|
||||
EXPECT_TRUE(class6->GetParClassExternalModuleName().empty());
|
||||
EXPECT_EQ(class6->GetParClassGlobalVarName(), "globalvar2.Data");
|
||||
}
|
||||
|
||||
@ -197,33 +217,41 @@ HWTEST(DefectScanAuxTest, DebugInfoTest, testing::ext::TestSize.Level0)
|
||||
{
|
||||
std::string test_name = DEFECT_SCAN_AUX_TEST_ABC_DIR "debug_info_test.abc";
|
||||
auto abc_file = panda::defect_scan_aux::AbcFile::Open(test_name);
|
||||
ASSERT(abc_file != nullptr);
|
||||
ASSERT_NE(abc_file, nullptr);
|
||||
|
||||
// check debug info, whether the line number obtained from call inst is correct
|
||||
auto f0 = abc_file->GetFunctionByName("foo");
|
||||
auto f0 = abc_file->GetFunctionByName("#*#foo");
|
||||
ASSERT_NE(f0, nullptr);
|
||||
EXPECT_EQ(f0->GetCalleeInfoCount(), 3U);
|
||||
auto ci0_0 = f0->GetCalleeInfoByIndex(0);
|
||||
ASSERT_NE(ci0_0, nullptr);
|
||||
// callarg0
|
||||
EXPECT_EQ(abc_file->GetLineNumberByInst(f0, ci0_0->GetCallInst()), 34);
|
||||
auto ci0_1 = f0->GetCalleeInfoByIndex(1);
|
||||
ASSERT_NE(ci0_1, nullptr);
|
||||
// callspread
|
||||
EXPECT_EQ(abc_file->GetLineNumberByInst(f0, ci0_1->GetCallInst()), 38);
|
||||
auto ci0_2 = f0->GetCalleeInfoByIndex(2);
|
||||
ASSERT_NE(ci0_2, nullptr);
|
||||
// callirange
|
||||
EXPECT_EQ(abc_file->GetLineNumberByInst(f0, ci0_2->GetCallInst()), 40);
|
||||
// ctor of Data
|
||||
auto f1 = abc_file->GetFunctionByName("Data");
|
||||
auto f1 = abc_file->GetFunctionByName("#*@2~@1=#Data");
|
||||
ASSERT_NE(f1, nullptr);
|
||||
EXPECT_EQ(f1->GetCalleeInfoCount(), 1U);
|
||||
auto ci1_0 = f1->GetCalleeInfoByIndex(0);
|
||||
// supercall
|
||||
EXPECT_EQ(abc_file->GetLineNumberByInst(f1, ci1_0->GetCallInst()), 60);
|
||||
// bar
|
||||
auto f2 = abc_file->GetFunctionByName("bar");
|
||||
auto f2 = abc_file->GetFunctionByName("#*#bar");
|
||||
ASSERT_NE(f2, nullptr);
|
||||
EXPECT_EQ(f2->GetCalleeInfoCount(), 2U);
|
||||
auto ci2_0 = f2->GetCalleeInfoByIndex(0);
|
||||
ASSERT_NE(ci2_0, nullptr);
|
||||
// callithisrange
|
||||
EXPECT_EQ(abc_file->GetLineNumberByInst(f2, ci2_0->GetCallInst()), 70);
|
||||
auto ci2_1 = f2->GetCalleeInfoByIndex(1);
|
||||
ASSERT_NE(ci2_1, nullptr);
|
||||
// callithisrange
|
||||
EXPECT_EQ(abc_file->GetLineNumberByInst(f2, ci2_1->GetCallInst()), 75);
|
||||
}
|
||||
@ -232,7 +260,7 @@ HWTEST(DefectScanAuxTest, CalleeInfoTest, testing::ext::TestSize.Level0)
|
||||
{
|
||||
std::string test_name = DEFECT_SCAN_AUX_TEST_ABC_DIR "callee_info_test.abc";
|
||||
auto abc_file = panda::defect_scan_aux::AbcFile::Open(test_name);
|
||||
ASSERT(abc_file != nullptr);
|
||||
ASSERT_NE(abc_file, nullptr);
|
||||
size_t def_func_cnt = abc_file->GetDefinedFunctionCount();
|
||||
EXPECT_EQ(def_func_cnt, 19U);
|
||||
size_t def_class_cnt = abc_file->GetDefinedClassCount();
|
||||
@ -240,16 +268,19 @@ HWTEST(DefectScanAuxTest, CalleeInfoTest, testing::ext::TestSize.Level0)
|
||||
|
||||
// check callee info of each func
|
||||
// foo
|
||||
auto f0 = abc_file->GetFunctionByName("foo");
|
||||
auto f0 = abc_file->GetFunctionByName("#*#foo");
|
||||
ASSERT_NE(abc_file, nullptr);
|
||||
size_t ci_cnt0 = f0->GetCalleeInfoCount();
|
||||
EXPECT_EQ(ci_cnt0, 6U);
|
||||
auto ci0_0 = f0->GetCalleeInfoByIndex(0);
|
||||
ASSERT_NE(abc_file, nullptr);
|
||||
ASSERT_TRUE(f0->GetCalleeInfoByCallInst(ci0_0->GetCallInst()) == ci0_0);
|
||||
ASSERT_TRUE(ci0_0->IsCalleeDefinite());
|
||||
EXPECT_EQ(ci0_0->GetCalleeArgCount(), 1);
|
||||
ASSERT_TRUE(ci0_0->GetCaller() == f0);
|
||||
ASSERT_TRUE(ci0_0->GetCallee() == abc_file->GetFunctionByName("func2"));
|
||||
ASSERT_TRUE(ci0_0->GetCallee() == abc_file->GetFunctionByName("#*@0*#func2"));
|
||||
auto ci0_1 = f0->GetCalleeInfoByIndex(1);
|
||||
ASSERT_NE(ci0_1, nullptr);
|
||||
EXPECT_EQ(f0->GetCalleeInfoByCallInst(ci0_1->GetCallInst()), ci0_1);
|
||||
ASSERT_FALSE(ci0_1->IsCalleeDefinite());
|
||||
EXPECT_EQ(ci0_1->GetCalleeArgCount(), 1);
|
||||
@ -257,102 +288,124 @@ HWTEST(DefectScanAuxTest, CalleeInfoTest, testing::ext::TestSize.Level0)
|
||||
EXPECT_EQ(ci0_1->GetFunctionName(), "log");
|
||||
EXPECT_EQ(ci0_1->GetGlobalVarName(), "console");
|
||||
auto ci0_2 = f0->GetCalleeInfoByIndex(2);
|
||||
ASSERT_NE(ci0_2, nullptr);
|
||||
ASSERT_FALSE(ci0_2->IsCalleeDefinite());
|
||||
EXPECT_EQ(ci0_2->GetCalleeArgCount(), 1);
|
||||
ASSERT_TRUE(ci0_2->GetCallee() == nullptr);
|
||||
EXPECT_EQ(ci0_2->GetFunctionName(), "logd");
|
||||
EXPECT_EQ(ci0_2->GetGlobalVarName(), "globalvar.hilog");
|
||||
auto ci0_3 = f0->GetCalleeInfoByIndex(3);
|
||||
ASSERT_NE(ci0_3, nullptr);
|
||||
ASSERT_TRUE(ci0_3->IsCalleeDefinite());
|
||||
ASSERT_TRUE(ci0_3->GetCallee() == abc_file->GetFunctionByName("func2"));
|
||||
ASSERT_TRUE(ci0_3->GetCallee() == abc_file->GetFunctionByName("#*@0*#func2"));
|
||||
auto ci0_4 = f0->GetCalleeInfoByIndex(4);
|
||||
ASSERT_NE(ci0_4, nullptr);
|
||||
ASSERT_TRUE(ci0_4->IsCalleeDefinite());
|
||||
EXPECT_EQ(ci0_4->GetCalleeArgCount(), 2);
|
||||
ASSERT_TRUE(ci0_4->GetCallee() == abc_file->GetFunctionByName("func1"));
|
||||
ASSERT_TRUE(ci0_4->GetCallee() == abc_file->GetFunctionByName("#*#func1"));
|
||||
auto ci0_5 = f0->GetCalleeInfoByIndex(5);
|
||||
ASSERT_NE(ci0_5, nullptr);
|
||||
ASSERT_FALSE(ci0_5->IsCalleeDefinite());
|
||||
EXPECT_EQ(ci0_5->GetFunctionName(), "bar");
|
||||
// foo1
|
||||
auto f1 = abc_file->GetFunctionByName("foo1");
|
||||
auto f1 = abc_file->GetFunctionByName("#*#foo1");
|
||||
ASSERT_NE(f1, nullptr);
|
||||
size_t ci_cnt1 = f1->GetCalleeInfoCount();
|
||||
EXPECT_EQ(ci_cnt1, 3U);
|
||||
auto ci1_0 = f1->GetCalleeInfoByIndex(0);
|
||||
ASSERT_NE(ci1_0, nullptr);
|
||||
ASSERT_TRUE(ci1_0->IsCalleeDefinite());
|
||||
ASSERT_TRUE(ci1_0->GetCallee() == abc_file->GetFunctionByName("fn"));
|
||||
ASSERT_TRUE(ci1_0->GetCallee() == abc_file->GetFunctionByName("#*@1*#fn"));
|
||||
auto ci1_1 = f1->GetCalleeInfoByIndex(1);
|
||||
ASSERT_NE(ci1_1, nullptr);
|
||||
ASSERT_TRUE(ci1_1->IsCalleeDefinite());
|
||||
ASSERT_TRUE(ci1_1->GetCallee() == abc_file->GetFunctionByName("fn"));
|
||||
ASSERT_TRUE(ci1_1->GetCallee() == abc_file->GetFunctionByName("#*@1*#fn"));
|
||||
auto ci1_2 = f1->GetCalleeInfoByIndex(2);
|
||||
ASSERT_NE(ci1_2, nullptr);
|
||||
ASSERT_FALSE(ci1_2->IsCalleeDefinite());
|
||||
EXPECT_EQ(ci1_2->GetFunctionName(), "bind");
|
||||
// #2#ColorPoint
|
||||
auto f2 = abc_file->GetFunctionByName("ColorPoint");
|
||||
auto f2 = abc_file->GetFunctionByName("#*@4~@3=#ColorPoint");
|
||||
ASSERT_NE(f2, nullptr);
|
||||
size_t ci_cnt2 = f2->GetCalleeInfoCount();
|
||||
EXPECT_EQ(ci_cnt2, 1U);
|
||||
auto ci2_0 = f2->GetCalleeInfoByIndex(0);
|
||||
ASSERT_NE(ci2_0, nullptr);
|
||||
ASSERT_TRUE(ci2_0->IsCalleeDefinite());
|
||||
ASSERT_TRUE(ci2_0->GetClass() == abc_file->GetClassByName("Point"));
|
||||
ASSERT_TRUE(ci2_0->GetCallee() == abc_file->GetFunctionByName("Point"));
|
||||
ASSERT_TRUE(ci2_0->GetClass() == abc_file->GetClassByName("#~@2=#Point"));
|
||||
ASSERT_TRUE(ci2_0->GetCallee() == abc_file->GetFunctionByName("#~@2=#Point"));
|
||||
// func6
|
||||
auto f3 = abc_file->GetFunctionByName("func6");
|
||||
auto f3 = abc_file->GetFunctionByName("#*#func6");
|
||||
ASSERT_NE(f3, nullptr);
|
||||
size_t ci_cnt3 = f3->GetCalleeInfoCount();
|
||||
EXPECT_EQ(ci_cnt3, 1U);
|
||||
auto ci3_0 = f3->GetCalleeInfoByIndex(0);
|
||||
ASSERT_FALSE(ci3_0->IsCalleeDefinite());
|
||||
EXPECT_FALSE(ci3_0->IsCalleeDefinite());
|
||||
EXPECT_EQ(ci3_0->GetFunctionName(), "bar");
|
||||
EXPECT_EQ(ci3_0->GetExternalModuleName(), "./mod2");
|
||||
// func7
|
||||
auto f4 = abc_file->GetFunctionByName("func7");
|
||||
auto f4 = abc_file->GetFunctionByName("#*@5*#func7");
|
||||
ASSERT_NE(f4, nullptr);
|
||||
size_t ci_cnt4 = f4->GetCalleeInfoCount();
|
||||
EXPECT_EQ(ci_cnt4, 2U);
|
||||
auto ci4_0 = f4->GetCalleeInfoByIndex(0);
|
||||
ASSERT_NE(ci4_0, nullptr);
|
||||
ASSERT_FALSE(ci4_0->IsCalleeDefinite());
|
||||
EXPECT_EQ(ci4_0->GetCalleeArgCount(), 2);
|
||||
EXPECT_EQ(ci4_0->GetFunctionName(), "sum");
|
||||
EXPECT_EQ(ci4_0->GetExternalModuleName(), "../../mod1");
|
||||
auto ci4_1 = f4->GetCalleeInfoByIndex(1);
|
||||
ASSERT_FALSE(ci4_1->IsCalleeDefinite());
|
||||
ASSERT_NE(ci4_1, nullptr);
|
||||
EXPECT_FALSE(ci4_1->IsCalleeDefinite());
|
||||
EXPECT_EQ(ci4_1->GetCalleeArgCount(), 2);
|
||||
EXPECT_EQ(ci4_1->GetFunctionName(), "sub");
|
||||
EXPECT_EQ(ci4_1->GetExternalModuleName(), "../../mod1");
|
||||
// callMemberFunc1
|
||||
auto f5 = abc_file->GetFunctionByName("callMemberFunc1");
|
||||
auto f5 = abc_file->GetFunctionByName("#*@6*#callMemberFunc1");
|
||||
ASSERT_NE(f5, nullptr);
|
||||
size_t ci_cnt5 = f5->GetCalleeInfoCount();
|
||||
EXPECT_EQ(ci_cnt5, 2U);
|
||||
auto ci5_0 = f5->GetCalleeInfoByIndex(0);
|
||||
ASSERT_TRUE(ci5_0->IsCalleeDefinite());
|
||||
ASSERT_TRUE(ci5_0->GetClass() != nullptr);
|
||||
EXPECT_EQ(ci5_0->GetClass(), abc_file->GetClassByName("Point"));
|
||||
ASSERT_TRUE(ci5_0->GetCallee() != nullptr);
|
||||
EXPECT_EQ(ci5_0->GetCallee(), abc_file->GetFunctionByName("getCoordinateX"));
|
||||
ASSERT_NE(ci5_0, nullptr);
|
||||
EXPECT_TRUE(ci5_0->IsCalleeDefinite());
|
||||
EXPECT_TRUE(ci5_0->GetClass() != nullptr);
|
||||
EXPECT_EQ(ci5_0->GetClass(), abc_file->GetClassByName("#~@2=#Point"));
|
||||
EXPECT_TRUE(ci5_0->GetCallee() != nullptr);
|
||||
EXPECT_EQ(ci5_0->GetCallee(), abc_file->GetFunctionByName("#~@2>#getCoordinateX"));
|
||||
auto ci5_1 = f5->GetCalleeInfoByIndex(1);
|
||||
ASSERT_TRUE(ci5_1->IsCalleeDefinite());
|
||||
ASSERT_TRUE(ci5_1->GetClass() != nullptr);
|
||||
EXPECT_EQ(ci5_1->GetClass(), abc_file->GetClassByName("Point"));
|
||||
ASSERT_TRUE(ci5_1->GetCallee() != nullptr);
|
||||
EXPECT_EQ(ci5_1->GetCallee(), abc_file->GetFunctionByName("setCoordinateX"));
|
||||
ASSERT_NE(ci5_1, nullptr);
|
||||
EXPECT_TRUE(ci5_1->IsCalleeDefinite());
|
||||
EXPECT_TRUE(ci5_1->GetClass() != nullptr);
|
||||
EXPECT_EQ(ci5_1->GetClass(), abc_file->GetClassByName("#~@2=#Point"));
|
||||
EXPECT_TRUE(ci5_1->GetCallee() != nullptr);
|
||||
EXPECT_EQ(ci5_1->GetCallee(), abc_file->GetFunctionByName("#~@2>#setCoordinateX"));
|
||||
// callMemberFunc2
|
||||
auto f6 = abc_file->GetFunctionByName("callMemberFunc2");
|
||||
auto f6 = abc_file->GetFunctionByName("#*@6*@7*#callMemberFunc2");
|
||||
ASSERT_NE(f6, nullptr);
|
||||
size_t ci_cnt6 = f6->GetCalleeInfoCount();
|
||||
EXPECT_EQ(ci_cnt6, 2U);
|
||||
auto ci6_0 = f6->GetCalleeInfoByIndex(0);
|
||||
ASSERT_TRUE(ci6_0->IsCalleeDefinite());
|
||||
ASSERT_TRUE(ci6_0->GetClass() != nullptr);
|
||||
EXPECT_EQ(ci6_0->GetClass(), abc_file->GetClassByName("Point"));
|
||||
ASSERT_TRUE(ci6_0->GetCallee() != nullptr);
|
||||
EXPECT_EQ(ci6_0->GetCallee(), abc_file->GetFunctionByName("plus"));
|
||||
ASSERT_NE(ci6_0, nullptr);
|
||||
EXPECT_TRUE(ci6_0->IsCalleeDefinite());
|
||||
EXPECT_TRUE(ci6_0->GetClass() != nullptr);
|
||||
EXPECT_EQ(ci6_0->GetClass(), abc_file->GetClassByName("#~@2=#Point"));
|
||||
EXPECT_TRUE(ci6_0->GetCallee() != nullptr);
|
||||
EXPECT_EQ(ci6_0->GetCallee(), abc_file->GetFunctionByName("#~@2>#plus"));
|
||||
auto ci6_1 = f6->GetCalleeInfoByIndex(1);
|
||||
ASSERT_FALSE(ci6_1->IsCalleeDefinite());
|
||||
ASSERT_NE(ci6_1, nullptr);
|
||||
EXPECT_FALSE(ci6_1->IsCalleeDefinite());
|
||||
EXPECT_EQ(ci6_1->GetFunctionName(), "sub");
|
||||
EXPECT_EQ(ci6_1->GetExternalModuleName(), "");
|
||||
EXPECT_EQ(ci6_1->GetGlobalVarName(), "");
|
||||
// callExClassMemberFunc1
|
||||
auto f7 = abc_file->GetFunctionByName("callExClassMemberFunc1");
|
||||
auto f7 = abc_file->GetFunctionByName("#*@8*#callExClassMemberFunc1");
|
||||
ASSERT_NE(f7, nullptr);
|
||||
size_t ci_cnt7 = f7->GetCalleeInfoCount();
|
||||
EXPECT_EQ(ci_cnt7, 1U);
|
||||
auto ci7_0 = f7->GetCalleeInfoByIndex(0);
|
||||
ASSERT_FALSE(ci7_0->IsCalleeDefinite());
|
||||
ASSERT_TRUE(ci7_0->GetClass() == nullptr);
|
||||
ASSERT_NE(ci7_0, nullptr);
|
||||
EXPECT_FALSE(ci7_0->IsCalleeDefinite());
|
||||
EXPECT_TRUE(ci7_0->GetClass() == nullptr);
|
||||
EXPECT_EQ(ci7_0->GetFunctionName(), "makePhoneCall");
|
||||
EXPECT_EQ(ci7_0->GetExternalModuleName(), "../../mod1");
|
||||
EXPECT_EQ(ci7_0->GetGlobalVarName(), "");
|
||||
@ -362,9 +415,9 @@ HWTEST(DefectScanAuxTest, GraphTest, testing::ext::TestSize.Level0)
|
||||
{
|
||||
std::string test_name = DEFECT_SCAN_AUX_TEST_ABC_DIR "graph_test.abc";
|
||||
auto abc_file = panda::defect_scan_aux::AbcFile::Open(test_name);
|
||||
ASSERT(abc_file != nullptr);
|
||||
auto f0 = CheckFunction(abc_file, "foo");
|
||||
|
||||
ASSERT_NE(abc_file, nullptr);
|
||||
auto f0 = CheckFunction(abc_file, "#*#foo");
|
||||
ASSERT_NE(f0, nullptr);
|
||||
// check api of graph
|
||||
auto &graph = f0->GetGraph();
|
||||
auto bb_list = graph.GetBasicBlockList();
|
||||
@ -479,6 +532,15 @@ HWTEST(DefectScanAuxTest, GraphTest, testing::ext::TestSize.Level0)
|
||||
|
||||
HWTEST(DefectScanAuxTest, ModuleInfoTest, testing::ext::TestSize.Level0)
|
||||
{
|
||||
const std::string USER_INPUT = "#~@1=#UserInput";
|
||||
const std::string UI_INPUT = "UInput";
|
||||
const std::string GET_TEXT = "#~@1>#getText";
|
||||
const std::string INNER_USER_INPUT = "#~@0=#InnerUserInput";
|
||||
const std::string GET_TEXT_BASE = "#~@0>#getTextBase";
|
||||
const std::string FUNC1 = "#*#func1";
|
||||
const std::string FUNC2 = "#*#func2";
|
||||
const std::string FUNC3 = "#*#func3";
|
||||
|
||||
std::string test_name = DEFECT_SCAN_AUX_TEST_ABC_DIR "module_info_test.abc";
|
||||
auto abc_file = panda::defect_scan_aux::AbcFile::Open(test_name);
|
||||
ASSERT(abc_file != nullptr);
|
||||
@ -488,47 +550,47 @@ HWTEST(DefectScanAuxTest, ModuleInfoTest, testing::ext::TestSize.Level0)
|
||||
EXPECT_EQ(def_class_cnt, 2U);
|
||||
|
||||
// check exported class
|
||||
std::string inter_name0 = abc_file->GetLocalNameByExportName("UInput");
|
||||
std::string inter_name0 = abc_file->GetLocalNameByExportName(UI_INPUT);
|
||||
EXPECT_EQ(inter_name0, "UserInput");
|
||||
auto ex_class = abc_file->GetExportClassByExportName("UInput");
|
||||
EXPECT_EQ(ex_class->GetClassName(), "UserInput");
|
||||
CheckClass(abc_file, "UserInput");
|
||||
auto ex_class = abc_file->GetExportClassByExportName(UI_INPUT);
|
||||
EXPECT_EQ(ex_class->GetClassName(), USER_INPUT);
|
||||
CheckClass(abc_file, USER_INPUT);
|
||||
size_t mf_func_count0 = ex_class->GetMemberFunctionCount();
|
||||
EXPECT_EQ(mf_func_count0, 2U);
|
||||
auto mf_func0_1 = ex_class->GetMemberFunctionByIndex(1);
|
||||
EXPECT_EQ(mf_func0_1->GetFunctionName(), "getText");
|
||||
EXPECT_EQ(mf_func0_1->GetFunctionName(), GET_TEXT);
|
||||
ASSERT_TRUE(mf_func0_1->GetClass() == ex_class);
|
||||
CheckFunction(abc_file, "getText");
|
||||
CheckFunction(abc_file, GET_TEXT);
|
||||
auto par_class = ex_class->GetParentClass();
|
||||
ASSERT_TRUE(par_class != nullptr);
|
||||
EXPECT_EQ(par_class->GetClassName(), "InnerUserInput");
|
||||
CheckClass(abc_file, "InnerUserInput");
|
||||
EXPECT_EQ(par_class->GetClassName(), INNER_USER_INPUT);
|
||||
CheckClass(abc_file, INNER_USER_INPUT);
|
||||
size_t mf_func_count1 = par_class->GetMemberFunctionCount();
|
||||
EXPECT_EQ(mf_func_count1, 2U);
|
||||
auto mf_func1_1 = par_class->GetMemberFunctionByIndex(1);
|
||||
EXPECT_EQ(mf_func1_1->GetFunctionName(), "getTextBase");
|
||||
EXPECT_EQ(mf_func1_1->GetFunctionName(), GET_TEXT_BASE);
|
||||
ASSERT_TRUE(mf_func1_1->GetClass() == par_class);
|
||||
CheckFunction(abc_file, "getTextBase");
|
||||
CheckFunction(abc_file, GET_TEXT_BASE);
|
||||
|
||||
// check exported func
|
||||
// func3
|
||||
std::string inter_name1 = abc_file->GetLocalNameByExportName("exFunc3");
|
||||
EXPECT_EQ(inter_name1, "func3");
|
||||
auto ex_func1 = abc_file->GetExportFunctionByExportName("exFunc3");
|
||||
EXPECT_EQ(ex_func1->GetFunctionName(), "func3");
|
||||
CheckFunction(abc_file, "func3");
|
||||
EXPECT_EQ(ex_func1->GetFunctionName(), FUNC3);
|
||||
CheckFunction(abc_file, FUNC3);
|
||||
// func1
|
||||
std::string inter_name2 = abc_file->GetLocalNameByExportName("default");
|
||||
EXPECT_EQ(inter_name2, "func1");
|
||||
auto ex_func2 = abc_file->GetExportFunctionByExportName("default");
|
||||
EXPECT_EQ(ex_func2->GetFunctionName(), "func1");
|
||||
CheckFunction(abc_file, inter_name2);
|
||||
EXPECT_EQ(ex_func2->GetFunctionName(), FUNC1);
|
||||
CheckFunction(abc_file, FUNC1);
|
||||
// func2
|
||||
std::string inter_name3 = abc_file->GetLocalNameByExportName("func2");
|
||||
EXPECT_EQ(inter_name3, "func2");
|
||||
auto ex_func3 = abc_file->GetExportFunctionByExportName("func2");
|
||||
EXPECT_EQ(ex_func3->GetFunctionName(), "func2");
|
||||
CheckFunction(abc_file, inter_name3);
|
||||
EXPECT_EQ(ex_func3->GetFunctionName(), FUNC2);
|
||||
CheckFunction(abc_file, FUNC2);
|
||||
|
||||
// GetModuleNameByLocalName
|
||||
std::string mod_name0 = abc_file->GetModuleNameByLocalName("var1");
|
||||
|
@ -21,6 +21,9 @@ namespace ark {
|
||||
static constexpr size_t INSTRUCTION_FORMAT_WIDTH = 20;
|
||||
static constexpr size_t INSTRUCTION_VALUE_WIDTH = 2;
|
||||
static constexpr size_t INSTRUCTION_OFFSET_WIDTH = 4;
|
||||
static constexpr std::string_view SCOPE_NAME_RECORD = "_ESScopeNamesRecord";
|
||||
static constexpr std::string_view TYPE_SUMMARY_FIELD_NAME = "typeSummaryOffset";
|
||||
static constexpr std::string_view SCOPE_NAMES = "scopeNames";
|
||||
} // namespace ark
|
||||
|
||||
#endif // CONST_VALUE_H
|
||||
|
Loading…
Reference in New Issue
Block a user