Minor cleanup

- Removed unused stubs
- Removed wabt dependency since wasmtime can compile
  wat2wasm as well.
- Removed wasm2c references, it was never tested.
This commit is contained in:
Johan B.W. de Vries 2025-04-05 16:02:55 +02:00
parent 5c537f712e
commit 96f52a274c
8 changed files with 13 additions and 105 deletions

View File

@ -1,7 +1,4 @@
WABT_DIR := /home/johan/sources/github.com/WebAssembly/wabt WAT2WASM := venv/bin/python wat2wasm.py
WAT2WASM := $(WABT_DIR)/bin/wat2wasm
WASM2C := $(WABT_DIR)/bin/wasm2c
%.wat: %.py $(shell find phasm -name '*.py') venv/.done %.wat: %.py $(shell find phasm -name '*.py') venv/.done
venv/bin/python -m phasm $< $@ venv/bin/python -m phasm $< $@
@ -15,12 +12,6 @@ WASM2C := $(WABT_DIR)/bin/wasm2c
%.wasm: %.wat %.wasm: %.wat
$(WAT2WASM) $^ -o $@ $(WAT2WASM) $^ -o $@
%.c: %.wasm
$(WASM2C) $^ -o $@
# %.exe: %.c
# cc $^ -o $@ -I $(WABT_DIR)/wasm2c
examples: venv/.done $(subst .py,.wasm,$(wildcard examples/*.py)) $(subst .py,.wat.html,$(wildcard examples/*.py)) $(subst .py,.py.html,$(wildcard examples/*.py)) examples: venv/.done $(subst .py,.wasm,$(wildcard examples/*.py)) $(subst .py,.wat.html,$(wildcard examples/*.py)) $(subst .py,.py.html,$(wildcard examples/*.py))
venv/bin/python3 -m http.server --directory examples venv/bin/python3 -m http.server --directory examples
@ -31,7 +22,7 @@ lint: venv/.done
venv/bin/ruff check phasm tests venv/bin/ruff check phasm tests
typecheck: venv/.done typecheck: venv/.done
venv/bin/mypy --strict phasm tests/integration/helpers.py tests/integration/runners.py venv/bin/mypy --strict phasm wat2wasm.py tests/integration/helpers.py tests/integration/runners.py
venv/.done: requirements.txt venv/.done: requirements.txt
python3.12 -m venv venv python3.12 -m venv venv

View File

@ -1,14 +0,0 @@
from typing import Any, Dict, List, Optional, Union
from . import binary
from . import option
from . import execution
class Runtime:
store: execution.Store
def __init__(self, module: binary.Module, imps: Optional[Dict[str, Any]] = None, opts: Optional[option.Option] = None):
...
def exec(self, name: str, args: List[Union[int, float]]) -> Any:
...

View File

@ -1,6 +0,0 @@
from typing import BinaryIO
class Module:
@classmethod
def from_reader(cls, reader: BinaryIO) -> 'Module':
...

View File

@ -1,10 +0,0 @@
from typing import List
class Result:
...
class MemoryInstance:
data: bytearray
class Store:
memory_list: List[MemoryInstance]

View File

@ -1,2 +0,0 @@
class Option:
...

View File

@ -1,23 +0,0 @@
from typing import Any, Callable
class Module:
...
class Runtime:
...
def load(self, wasm_bin: Module) -> None:
...
def get_memory(self, memid: int) -> memoryview:
...
def find_function(self, name: str) -> Callable[[Any], Any]:
...
class Environment:
def new_runtime(self, mem_size: int) -> Runtime:
...
def parse_module(self, wasm_bin: bytes) -> Module:
...

View File

@ -1,39 +0,0 @@
from typing import Any, Dict, Callable, Union
def wat2wasm(inp: str) -> bytes:
...
class Store:
...
class Function:
def __init__(self, store: Store, func: Callable[[Any], Any]) -> None:
...
class Module:
def __init__(self, store: Store, wasm: bytes) -> None:
...
class Uint8Array:
def __getitem__(self, index: Union[int, slice]) -> int:
...
def __setitem__(self, idx: int, value: int) -> None:
...
class Memory:
def uint8_view(self, offset: int = 0) -> Uint8Array:
...
class Exports:
...
class ImportObject:
def register(self, region: str, values: Dict[str, Function]) -> None:
...
class Instance:
exports: Exports
def __init__(self, module: Module, imports: ImportObject) -> None:
...

11
wat2wasm.py Normal file
View File

@ -0,0 +1,11 @@
import sys
from wasmtime import wat2wasm
def main(_prog: str, inp: str, _dash_o: str, out: str) -> None:
with open(inp, 'rb') as inp_obj:
with open(out, 'wb') as out_obj:
out_obj.write(wat2wasm(inp_obj.read()))
if __name__ == '__main__':
main(*sys.argv)