Skip to content

Commit 091a21d

Browse files
committed
Merge branch 'master' into _update-deps/runtimeverification/k
2 parents 6dbf6ae + 212271b commit 091a21d

22 files changed

Lines changed: 2428 additions & 1026 deletions

File tree

.github/workflows/test-pr.yml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,19 @@ jobs:
1515
- name: 'Check out code'
1616
uses: actions/checkout@v3
1717
with:
18-
token: ${{ secrets.JENKINS_GITHUB_PAT }}
1918
# fetch-depth 0 means deep clone the repo
2019
fetch-depth: 0
2120
ref: ${{ github.event.pull_request.head.sha }}
22-
- name: 'Configure GitHub user'
23-
run: |
24-
git config user.name devops
25-
git config user.email devops@runtimeverification.com
26-
- name: 'Update version'
21+
- name: 'Check version was bumped'
2722
run: |
2823
og_version=$(git show origin/${GITHUB_BASE_REF}:package/version)
2924
./package/version.sh bump ${og_version}
3025
./package/version.sh sub
31-
new_version=$(cat package/version)
32-
git add --update && git commit --message "Set Version: ${new_version}" || true
33-
- name: 'Push updates'
34-
run: git push origin HEAD:${GITHUB_HEAD_REF}
26+
if ! git diff --quiet; then
27+
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."
28+
git diff
29+
exit 1
30+
fi
3531
3632
pykwasm-code-quality-checks:
3733
name: 'Code Quality Checks'

pykwasm/pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ description = ""
99
readme = "README.md"
1010
requires-python = "~=3.10"
1111
dependencies = [
12-
"kframework>=7.1.337",
13-
"py-wasm@git+https://github.com/runtimeverification/py-wasm.git@0.3.1"
12+
"kframework>=7.1.337"
1413
]
1514

1615
[[project.authors]]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .module import parse_module
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from __future__ import annotations
2+
3+
from typing import TYPE_CHECKING
4+
5+
from .integers import u32
6+
from .utils import WasmParseError, reset
7+
8+
if TYPE_CHECKING:
9+
from .utils import A, InputStream, Parser
10+
11+
12+
def sized(p: Parser[A], s: InputStream) -> A:
13+
size = u32(s)
14+
start_pos = s.tell()
15+
res = p(s)
16+
end_pos = s.tell()
17+
if end_pos - start_pos != size:
18+
raise WasmParseError('Size mismatch')
19+
return res
20+
21+
22+
def parse_n(p: Parser[A], n: int, s: InputStream) -> list[A]:
23+
results = []
24+
for _ in range(n):
25+
x = p(s)
26+
results.append(x)
27+
return results
28+
29+
30+
def list_of(p: Parser[A], s: InputStream) -> list[A]:
31+
n = u32(s)
32+
return parse_n(p, n, s)
33+
34+
35+
def either(ps: list[Parser[A]], s: InputStream) -> A:
36+
for p in ps:
37+
pos = s.tell()
38+
try:
39+
return p(s)
40+
except WasmParseError:
41+
reset(pos, s)
42+
continue
43+
raise WasmParseError('None of the alternatives succeeded')
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from __future__ import annotations
2+
3+
import struct
4+
from typing import TYPE_CHECKING
5+
6+
from .utils import read_bytes
7+
8+
if TYPE_CHECKING:
9+
from .utils import InputStream
10+
11+
12+
def f32(s: InputStream) -> float:
13+
bs = read_bytes(4, s)
14+
f = struct.unpack('<f', bs)[0]
15+
return f
16+
17+
18+
def f64(s: InputStream) -> float:
19+
bs = read_bytes(8, s)
20+
f = struct.unpack('<d', bs)[0]
21+
return f
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
from __future__ import annotations
2+
3+
from typing import TYPE_CHECKING
4+
5+
import pykwasm.kwasm_ast as wast
6+
7+
from .integers import u32
8+
from .utils import WasmParseError, read_byte
9+
10+
if TYPE_CHECKING:
11+
from pyk.kast.inner import KInner
12+
13+
from .utils import InputStream
14+
15+
16+
def typeidx(s: InputStream) -> int:
17+
return u32(s)
18+
19+
20+
def funcidx(s: InputStream) -> int:
21+
return u32(s)
22+
23+
24+
def tableidx(s: InputStream) -> int:
25+
return u32(s)
26+
27+
28+
# TODO multi-memory support is future work; the K semantics models a single memory,
29+
# so any reference to a memory other than 0 is rejected instead of mis-executing.
30+
def memidx(s: InputStream) -> int:
31+
x = u32(s)
32+
if x != 0:
33+
raise WasmParseError(f'Multi-memory is not supported. Expected memory index 0, got: {x}')
34+
return x
35+
36+
37+
def globalidx(s: InputStream) -> int:
38+
return u32(s)
39+
40+
41+
def tagidx(s: InputStream) -> int:
42+
return u32(s)
43+
44+
45+
def elemidx(s: InputStream) -> int:
46+
return u32(s)
47+
48+
49+
def dataidx(s: InputStream) -> int:
50+
return u32(s)
51+
52+
53+
def localidx(s: InputStream) -> int:
54+
return u32(s)
55+
56+
57+
def labelidx(s: InputStream) -> int:
58+
return u32(s)
59+
60+
61+
def externidx(s: InputStream) -> KInner:
62+
match read_byte(s):
63+
case 0x00:
64+
return wast.externidx_func(funcidx(s))
65+
case 0x01:
66+
return wast.externidx_table(tableidx(s))
67+
case 0x02:
68+
return wast.externidx_memory(memidx(s))
69+
case 0x03:
70+
return wast.externidx_global(globalidx(s))
71+
case 0x04:
72+
return wast.externidx_tag(tagidx(s))
73+
case x:
74+
raise WasmParseError(f'Invalid externidx descriptor: {x}')

0 commit comments

Comments
 (0)