2017-04-04 16:06:58 +03:00
|
|
|
# parity-wasm
|
|
|
|
|
2017-10-24 15:11:50 +03:00
|
|
|
[](https://travis-ci.org/paritytech/parity-wasm)
|
2017-05-30 22:45:14 +04:00
|
|
|
[](https://crates.io/crates/parity-wasm)
|
2017-04-04 16:15:05 +03:00
|
|
|
|
2017-04-04 16:43:30 +03:00
|
|
|
[Documentation](https://nikvolf.github.io/parity-wasm/parity_wasm/)
|
|
|
|
|
2017-04-04 16:08:20 +03:00
|
|
|
## Rust WebAssembly format serializing/deserializing
|
2017-04-04 16:06:58 +03:00
|
|
|
|
2017-05-23 17:37:57 +04:00
|
|
|
along with experimental interpreter
|
|
|
|
|
2017-04-04 16:06:58 +03:00
|
|
|
```rust
|
|
|
|
|
|
|
|
extern crate parity_wasm;
|
|
|
|
|
2017-06-03 23:45:42 +02:00
|
|
|
let module = parity_wasm::deserialize_file("./res/cases/v1/hello.wasm");
|
2017-04-04 16:06:58 +03:00
|
|
|
assert_eq!(module.code_section().is_some());
|
2017-04-04 16:07:55 +03:00
|
|
|
|
|
|
|
let code_section = module.code_section().unwrap(); // Part of the module with functions code
|
|
|
|
|
|
|
|
println!("Function count in wasm file: {}", code_section.bodies().len());
|
2017-04-04 16:06:58 +03:00
|
|
|
```
|
2017-04-04 16:48:01 +03:00
|
|
|
|
2017-06-05 17:05:11 +04:00
|
|
|
## Wabt Test suite
|
|
|
|
|
2017-09-07 13:06:50 -07:00
|
|
|
Interpreter and decoder supports full wabt testsuite (https://github.com/WebAssembly/testsuite), To run testsuite:
|
2017-06-05 17:05:11 +04:00
|
|
|
|
2017-06-05 17:05:52 +04:00
|
|
|
- make sure you have all prerequisites to build `wabt` (since parity-wasm builds it internally using `cmake`, see https://github.com/WebAssembly/wabt)
|
2017-09-11 15:14:01 +03:00
|
|
|
- checkout with submodules (`git submodule update --init --recursive`)
|
2017-06-05 17:05:11 +04:00
|
|
|
- run `cargo test --release --manifest-path=spec/Cargo.toml`
|
|
|
|
|
2017-09-09 16:39:58 +03:00
|
|
|
Decoder can be fuzzed with `cargo-fuzz` using `wasm-opt` (https://github.com/WebAssembly/binaryen):
|
2017-09-07 13:06:50 -07:00
|
|
|
|
|
|
|
- make sure you have all prerequisites to build `binaryen` and `cargo-fuzz` (`cmake` and a C++11 toolchain)
|
|
|
|
- checkout with submodules (`git submodule update --init --recursive`)
|
|
|
|
- install `cargo fuzz` subcommand with `cargo install cargo-fuzz`
|
|
|
|
- set rustup to use a nightly toolchain, because `cargo fuzz` uses a rust compiler plugin: `rustup override set nightly`
|
|
|
|
- run `cargo fuzz run deserialize`
|
|
|
|
|
2017-04-04 16:48:01 +03:00
|
|
|
# License
|
|
|
|
|
|
|
|
`parity-wasm` is primarily distributed under the terms of both the MIT
|
|
|
|
license and the Apache License (Version 2.0), at your choice.
|
|
|
|
|
2017-05-23 17:37:57 +04:00
|
|
|
See LICENSE-APACHE, and LICENSE-MIT for details.
|