MVP #1

Merged
jbwdevries merged 73 commits from idea_crc32 into master 2022-08-21 12:59:21 +00:00
2 changed files with 45 additions and 1 deletions
Showing only changes of commit 541b3a3b62 - Show all commits

View File

@ -1,8 +1,19 @@
WABT_DIR := /home/johan/Sources/github.com/WebAssembly/wabt
WAT2WASM := $(WABT_DIR)/bin/wat2wasm
WASM2C := $(WABT_DIR)/bin/wasm2c
%.wat: %.py py2wasm/*.py
python3.8 -m py2wasm $< $@
%.wasm: %.wat
wat2wasm $^ -o $@
$(WAT2WASM) $^ -o $@
%.c: %.wasm
$(WASM2C) $^ -o $@
# %.exe: %.c
# cc $^ -o $@ -I $(WABT_DIR)/wasm2c
server:
python3.8 -m http.server

View File

@ -0,0 +1,33 @@
import io
import pytest
from pywasm import binary
from pywasm import Runtime
from .helpers import wat2wasm
@pytest.mark.parametrize('size,offset,output', [
('32', 0, 0x3020100),
('32', 1, 0x4030201),
('64', 0, 0x706050403020100),
('64', 2, 0x908070605040302),
])
def test_i32_64_load(size, offset, output):
code_wat = f"""
(module
(memory 1)
(data (memory 0) (i32.const 0) "\\00\\01\\02\\03\\04\\05\\06\\07\\08\\09\\10")
(func (export "testEntry") (result i{size})
i32.const {offset}
i{size}.load
return ))
"""
code_wasm = wat2wasm(code_wat)
module = binary.Module.from_reader(io.BytesIO(code_wasm))
runtime = Runtime(module, {}, {})
out_put = runtime.exec('testEntry', [])
assert output == out_put