Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b3bad54
update `DataDefn` and `ExternDefn`, fix type annotations
bbyalcinkaya Apr 3, 2026
1113603
add binary parser for numbers
bbyalcinkaya Apr 3, 2026
e3dc7c9
parse modules
bbyalcinkaya Apr 3, 2026
56e7be2
add integrations tests and compare legacy and new parser
bbyalcinkaya Apr 3, 2026
4249fc4
Set Version: 0.1.149
rv-auditor Apr 3, 2026
9c35707
Merge branch 'master' into binary-parser
bbyalcinkaya Apr 3, 2026
9992ca9
format
bbyalcinkaya Apr 6, 2026
be18063
pyupgrade
bbyalcinkaya Apr 6, 2026
cd83932
organize imports
bbyalcinkaya Apr 6, 2026
12a946f
fix `<exports>`: migrate to typed export indices
bbyalcinkaya Apr 7, 2026
5b2c11a
Merge branch 'master' into binary-parser
bbyalcinkaya May 21, 2026
d16b9cc
Set Version: 0.1.155
rv-auditor May 21, 2026
7225499
migrate to the new parser
bbyalcinkaya Jun 24, 2026
f804037
add `#instrWithPos` support
bbyalcinkaya Jun 24, 2026
71f4f15
Merge branch 'master' into binary-parser
bbyalcinkaya Jun 24, 2026
315c57c
Set Version: 0.1.157
rv-auditor Jun 24, 2026
c212cbc
fix `elem_init` after instrWithPos
bbyalcinkaya Jun 25, 2026
b902f46
remove unused `BlockMetaData`
bbyalcinkaya Jun 25, 2026
70ae762
fix `limits` address-type flag bytes for memory64
bbyalcinkaya Jul 10, 2026
cab1047
fix custom sections not being consumed
bbyalcinkaya Jul 10, 2026
f0d9131
add memory.copy and memory.fill opcode parsing
bbyalcinkaya Jul 10, 2026
afc6f6d
fix binary parser to reject trailing data after module end
bbyalcinkaya Jul 10, 2026
f9a4272
remove unused iterate combinator from binary parser
bbyalcinkaya Jul 10, 2026
979e0cf
raise WasmParseError instead of ValueError on func/code length mismatch
bbyalcinkaya Jul 10, 2026
57278aa
fix peek_bytes to restore stream position on partial-EOF read
bbyalcinkaya Jul 10, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.156
0.1.157
5 changes: 2 additions & 3 deletions pykwasm/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ build-backend = "hatchling.build"

[project]
name = "pykwasm"
version = "0.1.156"
version = "0.1.157"
description = ""
readme = "README.md"
requires-python = "~=3.10"
dependencies = [
"kframework>=7.1.329",
"py-wasm@git+https://github.com/runtimeverification/py-wasm.git@0.3.1"
"kframework>=7.1.329"
]

[[project.authors]]
Expand Down
1 change: 1 addition & 0 deletions pykwasm/src/pykwasm/binary/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .module import parse_module
43 changes: 43 additions & 0 deletions pykwasm/src/pykwasm/binary/combinators.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from __future__ import annotations

from typing import TYPE_CHECKING

from .integers import u32
from .utils import WasmParseError, reset

if TYPE_CHECKING:
from .utils import A, InputStream, Parser


def sized(p: Parser[A], s: InputStream) -> A:
size = u32(s)
start_pos = s.tell()
res = p(s)
end_pos = s.tell()
if end_pos - start_pos != size:
raise WasmParseError('Size mismatch')
return res


def parse_n(p: Parser[A], n: int, s: InputStream) -> list[A]:
results = []
for _ in range(n):
x = p(s)
results.append(x)
return results


def list_of(p: Parser[A], s: InputStream) -> list[A]:
n = u32(s)
return parse_n(p, n, s)


def either(ps: list[Parser[A]], s: InputStream) -> A:
for p in ps:
pos = s.tell()
try:
return p(s)
except WasmParseError:
reset(pos, s)
continue
raise WasmParseError('None of the alternatives succeeded')
21 changes: 21 additions & 0 deletions pykwasm/src/pykwasm/binary/floats.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from __future__ import annotations

import struct
from typing import TYPE_CHECKING

from .utils import read_bytes

if TYPE_CHECKING:
from .utils import InputStream


def f32(s: InputStream) -> float:
bs = read_bytes(4, s)
f = struct.unpack('<f', bs)[0]
return f


def f64(s: InputStream) -> float:
bs = read_bytes(8, s)
f = struct.unpack('<d', bs)[0]
return f
69 changes: 69 additions & 0 deletions pykwasm/src/pykwasm/binary/indices.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
from __future__ import annotations

from typing import TYPE_CHECKING

import pykwasm.kwasm_ast as wast

from .integers import u32
from .utils import WasmParseError, read_byte

if TYPE_CHECKING:
from pyk.kast.inner import KInner

from .utils import InputStream


def typeidx(s: InputStream) -> int:
return u32(s)


def funcidx(s: InputStream) -> int:
return u32(s)


def tableidx(s: InputStream) -> int:
return u32(s)


def memidx(s: InputStream) -> int:
return u32(s)


def globalidx(s: InputStream) -> int:
return u32(s)


def tagidx(s: InputStream) -> int:
return u32(s)


def elemidx(s: InputStream) -> int:
return u32(s)


def dataidx(s: InputStream) -> int:
return u32(s)


def localidx(s: InputStream) -> int:
return u32(s)


def labelidx(s: InputStream) -> int:
return u32(s)


def externidx(s: InputStream) -> KInner:
match read_byte(s):
case 0x00:
return wast.externidx_func(funcidx(s))
case 0x01:
return wast.externidx_table(tableidx(s))
case 0x02:
return wast.externidx_memory(memidx(s))
case 0x03:
return wast.externidx_global(globalidx(s))
case 0x04:
return wast.externidx_tag(tagidx(s))
case x:
raise WasmParseError(f'Invalid externidx descriptor: {x}')
Loading
Loading