Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b09f65d
update `DataDefn` and `ExternDefn`, fix type annotations
bbyalcinkaya Apr 3, 2026
44d15be
add binary parser for numbers
bbyalcinkaya Apr 3, 2026
3bf2f6c
parse modules
bbyalcinkaya Apr 3, 2026
4446609
add integrations tests and compare legacy and new parser
bbyalcinkaya Apr 3, 2026
e8a8df4
format
bbyalcinkaya Apr 6, 2026
2168d39
pyupgrade
bbyalcinkaya Apr 6, 2026
71bf9cb
organize imports
bbyalcinkaya Apr 6, 2026
09cb5ae
fix `<exports>`: migrate to typed export indices
bbyalcinkaya Apr 7, 2026
b6e052f
migrate to the new parser
bbyalcinkaya Jun 24, 2026
ed10881
add `#instrWithPos` support
bbyalcinkaya Jun 24, 2026
1d08a6a
Set Version: 0.1.157
rv-auditor Jun 24, 2026
35a25c8
fix `elem_init` after instrWithPos
bbyalcinkaya Jun 25, 2026
b368c89
remove unused `BlockMetaData`
bbyalcinkaya Jun 25, 2026
a84ca20
fix `limits` address-type flag bytes for memory64
bbyalcinkaya Jul 10, 2026
cb06aa7
fix custom sections not being consumed
bbyalcinkaya Jul 10, 2026
2b6742b
add memory.copy and memory.fill opcode parsing
bbyalcinkaya Jul 10, 2026
cbde36f
fix binary parser to reject trailing data after module end
bbyalcinkaya Jul 10, 2026
335d7f1
remove unused iterate combinator from binary parser
bbyalcinkaya Jul 10, 2026
8fd4f38
raise WasmParseError instead of ValueError on func/code length mismatch
bbyalcinkaya Jul 10, 2026
0a2a2ba
fix peek_bytes to restore stream position on partial-EOF read
bbyalcinkaya Jul 10, 2026
efb4d5a
fix parsing of if instructions without an else branch
bbyalcinkaya Jul 13, 2026
c4359b3
reject non-zero memory indices instead of silently using memory 0
bbyalcinkaya Jul 13, 2026
6bc7cc8
improve comment clarity in binary parser unit tests
bbyalcinkaya Jul 13, 2026
d0823d3
scope the recursion limit to run_module and clean up dead code
bbyalcinkaya Jul 13, 2026
95095b6
reject unsupported 64-bit addressing and non-funcref table imports
bbyalcinkaya Jul 14, 2026
2fd32ff
improve parse error reporting and exception hygiene
bbyalcinkaya Jul 14, 2026
91a77c0
turn version-bump CI job into a check instead of auto-commit
bbyalcinkaya Jul 20, 2026
9a43a4e
update uv lock
bbyalcinkaya Jul 30, 2026
484abde
remove obsolete unit test file `test_wasm2kast.py`
bbyalcinkaya Jul 30, 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
16 changes: 6 additions & 10 deletions .github/workflows/test-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,19 @@ jobs:
- name: 'Check out code'
uses: actions/checkout@v3
with:
token: ${{ secrets.JENKINS_GITHUB_PAT }}
# fetch-depth 0 means deep clone the repo
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: 'Configure GitHub user'
run: |
git config user.name devops
git config user.email devops@runtimeverification.com
- name: 'Update version'
- name: 'Check version was bumped'
run: |
og_version=$(git show origin/${GITHUB_BASE_REF}:package/version)
./package/version.sh bump ${og_version}
./package/version.sh sub
new_version=$(cat package/version)
git add --update && git commit --message "Set Version: ${new_version}" || true
- name: 'Push updates'
run: git push origin HEAD:${GITHUB_HEAD_REF}
if ! git diff --quiet; then
echo "::error::Version was not bumped for this PR. Run './package/version.sh bump ${og_version} && ./package/version.sh sub' locally and commit the result."
git diff
exit 1
fi

pykwasm-code-quality-checks:
name: 'Code Quality Checks'
Expand Down
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
74 changes: 74 additions & 0 deletions pykwasm/src/pykwasm/binary/indices.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
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)


# TODO multi-memory support is future work; the K semantics models a single memory,
# so any reference to a memory other than 0 is rejected instead of mis-executing.
def memidx(s: InputStream) -> int:
x = u32(s)
if x != 0:
raise WasmParseError(f'Multi-memory is not supported. Expected memory index 0, got: {x}')
return x


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