def from_reader(cls, r: typing.BinaryIO): o = Import() o.module = bin_reader.read_bytes(r, 32).decode() o.name = bin_reader.read_bytes(r, 32).decode() o.kind = ord(r.read(1)) if o.kind == bin_format.extern_func: o.desc = bin_reader.read_count(r, 32) elif o.kind == bin_format.extern_table: o.desc = TableType.from_reader(r) elif o.kind == bin_format.extern_mem: o.desc = MemoryType.from_reader(r) elif o.kind == bin_format.extern_global: o.desc = GlobalType.from_reader(r) else: raise Exception('Malformed!') return o
def from_reader(cls, r: typing.BinaryIO): o = DataSegment() o.memidx = bin_reader.read_count(r, 32) o.expr = Expression.from_reader(r) o.init = bytearray(bin_reader.read_bytes(r, 32)) return o
def from_reader(cls, r: typing.BinaryIO): o = Export() o.name = bin_reader.read_bytes(r, 32).decode() o.kind = ord(r.read(1)) o.desc = bin_reader.read_count(r, 32) return o
def from_reader(cls, r: typing.BinaryIO): o = FunctionType() assert ord(r.read(1)) == 0x60 o.args = bin_reader.read_bytes(r) o.rets = bin_reader.read_bytes(r) return o