!557 Modify the location of pa file,modify assert content and fix codecheck warnings

Merge pull request !557 from jiangkaiwen/fix_codecheck
This commit is contained in:
openharmony_ci 2023-11-10 10:15:46 +00:00 committed by Gitee
commit 48fcbc0b2a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
26 changed files with 198 additions and 122 deletions

View File

@ -54,8 +54,8 @@
<!--policyitem type="license" name="LGPL" path="abc/.*" desc="Dynamically linked by module X"/-->
<!--policyitem type="copyright" name="xxx" path="abc/.*" rule="may" group="defaultGroup" filefilter="copyrightPolicyFilter" desc="Developed by X Company"/-->
<policyitem type="compatibility" name="Apache" path=".*" desc=""/>
<policyitem type="license" name="*" path="disassembler/tests/sources/.*" rule="may" group="defaultGroup" filefilter="defaultPolicyFilter" desc=""/>
<policyitem type="copyright" name="*" path="disassembler/tests/sources/.*" rule="may" group="defaultGroup" filefilter="copyrightPolicyFilter" desc=""/>
<policyitem type="license" name="*" path="disassembler/tests/expected/.*" rule="may" group="defaultGroup" filefilter="defaultPolicyFilter" desc=""/>
<policyitem type="copyright" name="*" path="disassembler/tests/expected/.*" rule="may" group="defaultGroup" filefilter="copyrightPolicyFilter" desc=""/>
</policy>
</policylist>

View File

@ -402,13 +402,8 @@ std::string Disassembler::ModuleTagToString(panda_file::ModuleTag &tag) const
std::vector<std::string> Disassembler::GetModuleLiteralArray(panda_file::File::EntityId &module_id) const
{
std::vector<std::string> request_modules;
panda_file::ModuleDataAccessor mda(*file_, module_id);
const std::vector<uint32_t> &request_modules_offset = mda.getRequestModules();
for (size_t idx = 0; idx < request_modules_offset.size(); ++idx) {
request_modules.emplace_back(GetStringByOffset(request_modules_offset[idx]));
}
std::vector<std::string> module_literal_array;
mda.EnumerateModuleRecord([&](panda_file::ModuleTag tag, uint32_t export_name_offset,
uint32_t request_module_idx, uint32_t import_name_offset,
@ -424,12 +419,11 @@ std::vector<std::string> Disassembler::GetModuleLiteralArray(panda_file::File::E
if (IsValidOffset(import_name_offset)) {
ss << ", import_name: " << GetStringByOffset(import_name_offset);
}
if (request_module_idx < request_modules.size()) {
auto request_module = request_modules[request_module_idx];
ASSERT(IsValidOffset(request_module));
ss << ", module_request: " << request_module;
if (request_module_idx < request_modules_offset.size()) {
auto request_module_offset = request_modules_offset[request_module_idx];
ASSERT(IsValidOffset(request_module_offset));
ss << ", module_request: " << GetStringByOffset(request_module_offset);
}
module_literal_array.push_back(ss.str());
});
@ -1523,7 +1517,8 @@ void Disassembler::Serialize(const pandasm::Function &method, std::ostream &os,
os << "}\n\n";
}
void Disassembler::SerializeStrings(const panda_file::File::EntityId &offset, const std::string &name_value, std::ostream &os) const
void Disassembler::SerializeStrings(const panda_file::File::EntityId &offset, const std::string &name_value,
std::ostream &os) const
{
os << "[offset:0x" << std::hex <<offset<< ", name_value:" << name_value<< "]" <<std::endl;
}

View File

@ -128,7 +128,8 @@ private:
void Serialize(const pandasm::Record &record, std::ostream &os, bool print_information = false) const;
void SerializeFields(const pandasm::Record &record, std::ostream &os, bool print_information) const;
void Serialize(const pandasm::Function &method, std::ostream &os, bool print_information = false) const;
void SerializeStrings(const panda_file::File::EntityId &offset, const std::string &name_value, std::ostream &os) const;
void SerializeStrings(const panda_file::File::EntityId &offset, const std::string &name_value,
std::ostream &os) const;
void Serialize(const pandasm::Function::CatchBlock &catch_block, std::ostream &os) const;
void Serialize(const pandasm::ItemMetadata &meta, const AnnotationList &ann_list, std::ostream &os) const;
void SerializeLineNumberTable(const panda_file::LineNumberTable &line_number_table, std::ostream &os) const;

View File

@ -14,4 +14,4 @@
*/
import('./script-export.js')
import('./script-export.js');

View File

@ -14,4 +14,4 @@
*/
export var x = 1;
export let x = 1;

View File

@ -0,0 +1,132 @@
# source binary: module-multi-import.abc
.language ECMAScript
# ====================
# LITERALS
0 0x685 { 4 [ string:"fun", method:fun, method_affiliate:2, i32:1, ]}
3 0x375 { 4 [ string:"fun1", method:fun1, method_affiliate:2, i32:1, ]}
1 0x5ff { 11 [ ModuleTag: REGULAR_IMPORT, local_name: a, import_name: a, module_request: ./module-multi-export.js; ModuleTag: REGULAR_IMPORT, local_name: b1, import_name: b1, module_request: ./module-multi-export.js; ModuleTag: REGULAR_IMPORT, local_name: b2, import_name: b2, module_request: ./module-multi-export.js; ModuleTag: REGULAR_IMPORT, local_name: c, import_name: c, module_request: ./module-multi-export.js; ModuleTag: REGULAR_IMPORT, local_name: dd, import_name: default, module_request: ./module-multi-export.js; ModuleTag: REGULAR_IMPORT, local_name: ee, import_name: default, module_request: ./module-multi-export.js; ModuleTag: REGULAR_IMPORT, local_name: ff, import_name: f, module_request: ./module-multi-export.js; ModuleTag: REGULAR_IMPORT, local_name: g, import_name: g, module_request: ./module-multi-export.js; ModuleTag: REGULAR_IMPORT, local_name: hh, import_name: h, module_request: ./module-multi-export.js; ModuleTag: NAMESPACE_IMPORT, local_name: n, module_request: ./module-multi-export.js; ModuleTag: NAMESPACE_IMPORT, local_name: ns, module_request: ./module-multi-export.js; ]}
2 0x492 { 3 [ ModuleTag: LOCAL_EXPORT, local_name: a, export_name: a; ModuleTag: LOCAL_EXPORT, local_name: b, export_name: b; ModuleTag: LOCAL_EXPORT, local_name: c, export_name: c; ]}
4 0x2f9 { 12 [ ModuleTag: LOCAL_EXPORT, local_name: ClassB, export_name: ClassB, module_request: ./module-export-file.js; ModuleTag: LOCAL_EXPORT, local_name: FunctionC, export_name: FunctionC, module_request: ./module-export-file.js; ModuleTag: LOCAL_EXPORT, local_name: a, export_name: a, module_request: ./module-export-file.js; ModuleTag: LOCAL_EXPORT, local_name: b1, export_name: b1, module_request: ./module-export-file.js; ModuleTag: LOCAL_EXPORT, local_name: b2, export_name: b2, module_request: ./module-export-file.js; ModuleTag: LOCAL_EXPORT, local_name: d, export_name: dd, module_request: ./module-export-file.js; ModuleTag: LOCAL_EXPORT, local_name: e, export_name: ee, module_request: ./module-export-file.js; ModuleTag: LOCAL_EXPORT, local_name: f, export_name: f, module_request: ./module-export-file.js; ModuleTag: LOCAL_EXPORT, local_name: g, export_name: g, module_request: ./module-export-file.js; ModuleTag: LOCAL_EXPORT, local_name: h, export_name: h, module_request: ./module-export-file.js; ModuleTag: INDIRECT_EXPORT, export_name: c, import_name: c, module_request: ./module-export-file.js; ModuleTag: STAR_EXPORT, module_request: ./module-export-file.js; ]}
# ====================
# RECORDS
.record _ESConcurrentModuleRequestsAnnotation {
}
.record _ESSlotNumberAnnotation {
}
.record _ESTypeAnnotation <external>
.record module-export-file {
u8 pkgName@ = 0x0
u8 isCommonjs = 0x0
u32 moduleRecordIdx = 0x492
}
.record module-multi-export {
u8 pkgName@ = 0x0
u8 isCommonjs = 0x0
u32 moduleRecordIdx = 0x2f9
}
.record module-multi-import {
u8 pkgName@ = 0x0
u8 isCommonjs = 0x0
u32 moduleRecordIdx = 0x5ff
}
# ====================
# METHODS
.function any module-export-file.func_main_0(any a0, any a1, any a2) <static> {
ldai 0x1
stmodulevar 0x0
ldai 0x2
stmodulevar 0x1
ldai 0x3
stmodulevar 0x2
ldundefined
returnundefined
}
.function any module-multi-export.ClassB(any a0, any a1, any a2) <static> {
lda a2
return
}
.function any module-multi-export.FunctionC(any a0, any a1, any a2) <static> {
ldundefined
returnundefined
}
.function any module-multi-export.fun1(any a0, any a1, any a2, any a3, any a4) <static> {
lda a4
add2 0x0, a3
return
}
.function any module-multi-export.func_main_0(any a0, any a1, any a2) <static> {
definefunc 0x0, module-multi-export.FunctionC:(any,any,any), 0x0
stmodulevar 0x1
ldai 0x1
stmodulevar 0x2
ldai 0x2
stmodulevar 0x3
ldai 0x3
stmodulevar 0x4
ldai 0x5
stmodulevar 0x5
ldai 0x6
stmodulevar 0x6
ldai 0x7
stmodulevar 0x7
ldai 0x8
stmodulevar 0x8
ldai 0x9
stmodulevar 0x9
ldhole
sta v0
defineclasswithbuffer 0x1, module-multi-export.ClassB:(any,any,any), { 4 [ string:"fun1", method:fun1, method_affiliate:2, i32:1, ]}, 0x0, v0
sta v0
ldobjbyname 0x2, "prototype"
lda v0
stmodulevar 0x0
ldundefined
returnundefined
}
.function any module-multi-import.ClassA(any a0, any a1, any a2) <static> {
lda.str "test"
stobjbyname 0x0, "str", a2
lda a2
return
}
.function any module-multi-import.fun(any a0, any a1, any a2, any a3, any a4) <static> {
lda a4
add2 0x0, a3
return
}
.function any module-multi-import.func_main_0(any a0, any a1, any a2) <static> {
getmodulenamespace 0x0
getmodulenamespace 0x0
ldhole
sta v0
defineclasswithbuffer 0x0, module-multi-import.ClassA:(any,any,any), { 4 [ string:"fun", method:fun, method_affiliate:2, i32:1, ]}, 0x0, v0
ldobjbyname 0x1, "prototype"
ldundefined
returnundefined
}
# ====================
# STRING
[offset:0x120, name_value:prototype]
[offset:0x4e5, name_value:str]
[offset:0x4ea, name_value:test]

View File

@ -26,8 +26,6 @@
# METHODS
.function any func_main_0(any a0, any a1, any a2) <static> {
ldundefined
stmodulevar 0x0
ldai 0x1
stmodulevar 0x0
ldundefined

View File

@ -193,8 +193,7 @@ def gen_module_and_dynamicimport_abc(args, tc, tc_dir, out_dir):
# dependent output abc directory
if "/dynamic-import/" in dependency:
out_dependency_abc_dir = os.path.join(args.output_dir, 'disassember_tests',
'dynamic-import')
out_dependency_abc_dir = os.path.join(args.output_dir, 'disassember_tests', 'dynamic-import')
elif "/module/" in dependency:
out_dependency_abc_dir = os.path.join(args.output_dir, 'disassember_tests', 'module')
@ -207,15 +206,13 @@ def gen_module_and_dynamicimport_abc(args, tc, tc_dir, out_dir):
# dependent output-protobin for module, dependent output-abc for dynamic-import
out_dependency_proto_file = os.path.join(out_dependency_abc_dir, tc_name_pre,
dependency_name_pre + '.protoBin')
out_dependency_aparted_abc_file = os.path.join(out_dependency_abc_dir,
dependency_name_pre + '.abc')
dependency_name_pre + '.protoBin')
out_dependency_aparted_abc_file = os.path.join(out_dependency_abc_dir, dependency_name_pre + '.abc')
if "/dynamic-import/" in dependency:
cmd = [frontend_binary, dependency, '--output', out_dependency_aparted_abc_file]
elif "/module/" in dependency:
cmd = [frontend_binary, dependency, '--outputProto',
out_dependency_proto_file, '--merge-abc']
cmd = [frontend_binary, dependency, '--outputProto', out_dependency_proto_file, '--merge-abc']
if check_compile_mode(dependency):
cmd.append('--module')
@ -340,7 +337,7 @@ def cmp_pa_file(testcase, tc_dir, output_dir):
out_tc_pa_file = os.path.join(out_abc_dir, tc_name + '.pa')
is_out_tc_pa_file = os.path.exists(out_tc_pa_file)
target_pa_dir = os.path.join(tc_dir, 'sources')
target_pa_dir = os.path.join(tc_dir, 'expected')
target_pa_file = os.path.join(target_pa_dir, tc_name + '.pa')
is_target_pa_file = os.path.exists(target_pa_file)

View File

@ -14,4 +14,4 @@
*/
let a = 1
let a = 1;

View File

@ -18,6 +18,6 @@ flags: [module]
---*/
export let a = 1
export let b = 2
export let c = 3
export let a = 1;
export let b = 2;
export let c = 3;

View File

@ -18,6 +18,6 @@ flags: [module]
---*/
import { a } from './module-indirect-export.js'
import { b } from './module-start-export.js'
import { c } from './module-local-export.js'
import { a } from './module-indirect-export.js';
import { b } from './module-start-export.js';
import { c } from './module-local-export.js';

View File

@ -18,4 +18,4 @@ flags: [module]
---*/
export let c = 3
export let c = 3;

View File

@ -18,22 +18,30 @@ flags: [module]
---*/
export let a = 1
export let b = 2
export let c = 3
export let d = 5
export let e = 6
export let f = 7
export let g = 8
let a = 1;
let b1 = 2;
let b2 = 3;
let d = 5;
let e = 6;
let x = 4
export { x } from './module-multi-import.js'
export * from "./module-multi-import.js"
export { a, b, c }
export { d as dd, e as ee }
export { a };
export { b1, b2 };
export { c } from './module-export-file.js';
export * from './module-export-file.js';
export { d as dd, e as ee };
export let f = 7;
export let g = 8;
export let h = 9;
let i = 10;
let j = 11;
export class ClassB {
fun(d, e){ return d + e }
fun1(i, j) { return i + j; }
}
export function FunctionC() {
let h = 9
let l = 12;
}

View File

@ -18,16 +18,21 @@ flags: [module]
---*/
import { a } from './module-multi-export.s'
import { b, c } from './module-multi-export.s'
import './module-multi-export.s'
import * as ns from './module-multi-export.s'
import { foo as foo1 } from './module-multi-export.s'
import d from './module-multi-export.s'
import e, * as n from './module-multi-export.s'
import { f , g as num } from './module-multi-export.s'
import { a } from './module-multi-export.js';
import { b1, b2 } from './module-multi-export.js';
import { c } from './module-multi-export.js';
import dd from './module-multi-export.js';
import ee, * as n from './module-multi-export.js';
import * as ns from './module-multi-export.js';
import { f as ff } from './module-multi-export.js';
import { g , h as hh } from './module-multi-export.js';
import './module-multi-export.js';
class ClassA {
fun(a, b){ return a + b }
str = "test";
fun(a, b) { return a + b; }
str = 'test';
}

View File

@ -18,4 +18,4 @@ flags: [module]
---*/
import * as ns from './module-export-file.js'
import * as ns from './module-export-file.js';

View File

@ -18,4 +18,4 @@ flags: [module]
---*/
import { a } from './module-export-file.js'
import { a } from './module-export-file.js';

View File

@ -18,6 +18,6 @@ flags: [module]
---*/
let b = 2
let b = 2;
export * from './module-import-file.js'
export * from './module-import-file.js';

View File

@ -1,60 +0,0 @@
# source binary: module-multi-import.abc
.language ECMAScript
# ====================
# LITERALS
0 0x311 { 4 [ string:"fun", method:fun, method_affiliate:2, i32:1, ]}
1 0x295 { 10 [ ModuleTag: REGULAR_IMPORT, local_name: a, import_name: a, module_request: ./module-multi-export.s; ModuleTag: REGULAR_IMPORT, local_name: b, import_name: b, module_request: ./module-multi-export.s; ModuleTag: REGULAR_IMPORT, local_name: c, import_name: c, module_request: ./module-multi-export.s; ModuleTag: REGULAR_IMPORT, local_name: d, import_name: default, module_request: ./module-multi-export.s; ModuleTag: REGULAR_IMPORT, local_name: e, import_name: default, module_request: ./module-multi-export.s; ModuleTag: REGULAR_IMPORT, local_name: f, import_name: f, module_request: ./module-multi-export.s; ModuleTag: REGULAR_IMPORT, local_name: foo1, import_name: foo, module_request: ./module-multi-export.s; ModuleTag: REGULAR_IMPORT, local_name: num, import_name: g, module_request: ./module-multi-export.s; ModuleTag: NAMESPACE_IMPORT, local_name: ns, module_request: ./module-multi-export.s; ModuleTag: NAMESPACE_IMPORT, local_name: n, module_request: ./module-multi-export.s; ]}
# ====================
# RECORDS
.record _ESConcurrentModuleRequestsAnnotation {
}
.record _ESSlotNumberAnnotation {
}
.record _ESTypeAnnotation <external>
.record module-multi-import {
u8 pkgName@ = 0x0
u8 isCommonjs = 0x0
u32 moduleRecordIdx = 0x295
}
# ====================
# METHODS
.function any module-multi-import.ClassA(any a0, any a1, any a2) <static> {
lda.str "test"
stobjbyname 0x0, "str", a2
lda a2
return
}
.function any module-multi-import.fun(any a0, any a1, any a2, any a3, any a4) <static> {
lda a4
add2 0x0, a3
return
}
.function any module-multi-import.func_main_0(any a0, any a1, any a2) <static> {
getmodulenamespace 0x0
getmodulenamespace 0x0
ldhole
sta v0
defineclasswithbuffer 0x0, module-multi-import.ClassA:(any,any,any), { 4 [ string:"fun", method:fun, method_affiliate:2, i32:1, ]}, 0x0, v0
ldobjbyname 0x1, "prototype"
ldundefined
returnundefined
}
# ====================
# STRING
[offset:0xd9, name_value:prototype]
[offset:0xe4, name_value:str]
[offset:0xe9, name_value:test]