Skip to content

Commit ea65615

Browse files
authored
Consistent method naming in tools/webassembly.py. NFC (#17253)
1 parent abeba41 commit ea65615

File tree

5 files changed

+85
-85
lines changed

5 files changed

+85
-85
lines changed

emsymbolizer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,9 @@ def symbolize_address_sourcemap(module, address, force_file):
165165
section = get_sourceMappingURL_section(module)
166166
assert section
167167
module.seek(section.offset)
168-
assert module.readString() == 'sourceMappingURL'
168+
assert module.read_string() == 'sourceMappingURL'
169169
# TODO: support stripping/replacing a prefix from the URL
170-
URL = module.readString()
170+
URL = module.read_string()
171171

172172
if shared.DEBUG:
173173
print(f'Source Mapping URL: {URL}')

tests/test_other.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8475,7 +8475,7 @@ def test_check_sourcemapurl(self):
84758475
self.run_process([EMCC, test_file('hello_123.c'), '-gsource-map', '-o', 'a.js', '--source-map-base', 'dir/'])
84768476
output = read_binary('a.wasm')
84778477
# has sourceMappingURL section content and points to 'dir/a.wasm.map' file
8478-
source_mapping_url_content = webassembly.toLEB(len('sourceMappingURL')) + b'sourceMappingURL' + webassembly.toLEB(len('dir/a.wasm.map')) + b'dir/a.wasm.map'
8478+
source_mapping_url_content = webassembly.to_leb(len('sourceMappingURL')) + b'sourceMappingURL' + webassembly.to_leb(len('dir/a.wasm.map')) + b'dir/a.wasm.map'
84798479
self.assertEqual(output.count(source_mapping_url_content), 1)
84808480
# make sure no DWARF debug info sections remain - they would just waste space
84818481
self.assertNotIn(b'.debug_', output)
@@ -8502,7 +8502,7 @@ def test_check_sourcemapurl_default(self, *args):
85028502
self.run_process([EMCC, test_file('hello_123.c'), '-gsource-map', '-o', 'a.js'] + list(args))
85038503
output = read_binary('a.wasm')
85048504
# has sourceMappingURL section content and points to 'a.wasm.map' file
8505-
source_mapping_url_content = webassembly.toLEB(len('sourceMappingURL')) + b'sourceMappingURL' + webassembly.toLEB(len('a.wasm.map')) + b'a.wasm.map'
8505+
source_mapping_url_content = webassembly.to_leb(len('sourceMappingURL')) + b'sourceMappingURL' + webassembly.to_leb(len('a.wasm.map')) + b'a.wasm.map'
85068506
self.assertIn(source_mapping_url_content, output)
85078507

85088508
def test_wasm_sourcemap(self):

tools/building.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,11 +1252,11 @@ def emit_debug_on_side(wasm_file):
12521252
# see https://yurydelendik.github.io/webassembly-dwarf/#external-DWARF
12531253
section_name = b'\x13external_debug_info' # section name, including prefixed size
12541254
filename_bytes = embedded_path.encode('utf-8')
1255-
contents = webassembly.toLEB(len(filename_bytes)) + filename_bytes
1255+
contents = webassembly.to_leb(len(filename_bytes)) + filename_bytes
12561256
section_size = len(section_name) + len(contents)
12571257
with open(wasm_file, 'ab') as f:
12581258
f.write(b'\0') # user section is code 0
1259-
f.write(webassembly.toLEB(section_size))
1259+
f.write(webassembly.to_leb(section_size))
12601260
f.write(section_name)
12611261
f.write(contents)
12621262

@@ -1353,7 +1353,7 @@ def is_wasm_dylib(filename):
13531353
section = next(module.sections())
13541354
if section.type == webassembly.SecType.CUSTOM:
13551355
module.seek(section.offset)
1356-
if module.readString() in ('dylink', 'dylink.0'):
1356+
if module.read_string() in ('dylink', 'dylink.0'):
13571357
return True
13581358
return False
13591359

tools/extract_metadata.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@
1010

1111
def is_wrapper_function(module, function):
1212
module.seek(function.offset)
13-
num_local_decls = module.readULEB()
13+
num_local_decls = module.read_uleb()
1414
while num_local_decls:
15-
local_count = module.readULEB() # noqa
15+
local_count = module.read_uleb() # noqa
1616
local_type = module.read_type() # noqa
1717
num_local_decls -= 1
1818
end = function.offset + function.size
1919
while module.tell() != end:
20-
opcode = module.readByte()
20+
opcode = module.read_byte()
2121
try:
2222
opcode = webassembly.OpCode(opcode)
2323
except ValueError as e:
2424
print(e)
2525
return False
2626
if opcode == webassembly.OpCode.CALL:
27-
callee = module.readULEB() # noqa
27+
callee = module.read_uleb() # noqa
2828
elif opcode == webassembly.OpCode.END:
2929
break
3030
else:
@@ -100,7 +100,7 @@ def get_asm_strings(module, globls, export_map, imported_globals):
100100

101101
asm_strings = {}
102102
str_start = seg_offset
103-
data = module.readAt(seg.offset, seg.size)
103+
data = module.read_at(seg.offset, seg.size)
104104
size = end_addr - start_addr
105105
end = seg_offset + size
106106
while str_start < end:
@@ -157,7 +157,7 @@ def update_metadata(filename, metadata):
157157

158158
def get_string_at(module, address):
159159
seg, offset = find_segment_with_address(module, address)
160-
data = module.readAt(seg.offset, seg.size)
160+
data = module.read_at(seg.offset, seg.size)
161161
str_end = data.find(b'\0', offset)
162162
return data_to_string(data[offset:str_end])
163163

0 commit comments

Comments
 (0)