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