wasm/decode.py
def decode_module(module, decode_name_subsections=False):
    """Decodes raw WASM modules, yielding `ModuleFragment`s."""
    module_wnd = memoryview(module)

    # Read & yield module header.
    hdr = ModuleHeader()
    hdr_len, hdr_data, _ = hdr.from_raw(None, module_wnd)
    yield ModuleFragment(hdr, hdr_data)
    module_wnd = module_wnd[hdr_len:]

    # Read & yield sections.
    while module_wnd:
        sec = Section()
        sec_len, sec_data, _ = sec.from_raw(None, module_wnd)

        # If requested, decode name subsections when encountered.
        if (
            decode_name_subsections and
            sec_data.id == SEC_UNK and
            sec_data.name == SEC_NAME
        ):
            sec_wnd = sec_data.payload
            while sec_wnd:
                subsec = NameSubSection()
                subsec_len, subsec_data, _ = subsec.from_raw(None, sec_wnd)
                yield ModuleFragment(subsec, subsec_data)
                sec_wnd = sec_wnd[subsec_len:]
        else:
            yield ModuleFragment(sec, sec_data)

        module_wnd = module_wnd[sec_len:]
Decodes raw WASM modules, yielding `ModuleFragment`s.
Decodes raw WASM modules, yielding `ModuleFragment`s.
Decodes raw WASM modules yielding ` ModuleFragment ` s .
def decode_module(module, decode_name_subsections=False):
    module_wnd = memoryview(module)
    hdr = ModuleHeader()
    hdr_len, hdr_data, _ = hdr.from_raw(None, module_wnd)
    yield ModuleFragment(hdr, hdr_data)
    module_wnd = module_wnd[hdr_len:]
    while module_wnd:
        sec = Section()
        sec_len, sec_data, _ = sec.from_raw(None, module_wnd)
        if (
            decode_name_subsections and
            sec_data.id == SEC_UNK and
            sec_data.name == SEC_NAME
        ):
            sec_wnd = sec_data.payload
            while sec_wnd:
                subsec = NameSubSection()
                subsec_len, subsec_data, _ = subsec.from_raw(None, sec_wnd)
                yield ModuleFragment(subsec, subsec_data)
                sec_wnd = sec_wnd[subsec_len:]
        else:
            yield ModuleFragment(sec, sec_data)
        module_wnd = module_wnd[sec_len:]
def decode_module ( module , decode_name_subsections = False ) : module_wnd = memoryview ( module ) hdr = ModuleHeader ( ) hdr_len , hdr_data , _ = hdr . from_raw ( None , module_wnd ) yield ModuleFragment ( hdr , hdr_data ) module_wnd = module_wnd [ hdr_len : ] while module_wnd : sec = Section ( ) sec_len , sec_data , _ = sec . from_raw ( None , module_wnd ) if ( decode_name_subsections and sec_data . id == SEC_UNK and sec_data . name == SEC_NAME ) : sec_wnd = sec_data . payload while sec_wnd : subsec = NameSubSection ( ) subsec_len , subsec_data , _ = subsec . from_raw ( None , sec_wnd ) yield ModuleFragment ( subsec , subsec_data ) sec_wnd = sec_wnd [ subsec_len : ] else : yield ModuleFragment ( sec , sec_data ) module_wnd = module_wnd [ sec_len : ]
Decodes raw WASM modules, yielding `ModuleFragment`s.
Decodes raw WASM modules yielding ` ModuleFragment ` s .
"""Decodes raw WASM modules, yielding `ModuleFragment`s.""" # Read & yield module header. # Read & yield sections. # If requested, decode name subsections when encountered.
module
decode_name_subsections