Switch from wabt crate to wast (#434)
* Switch lightbeam from `wabt` to `wast` Switch from a C++-based `*.wat` parser to a Rust-based parser * Remove unneeded `wabt` dev-dependency from wasmtime-api * Rewrite `wasmtime-wast` crate with `wast-parser` This commit moves the `wasmtime-wast` crate off the `wabt` crate on to the `wast-parser` crate which is a Rust implementation of a `*.wast` and `*.wat` parser. The intention here is to continue to reduce the amount of C++ required to build wasmtime! * Use new `wat` and `wast` crate names
This commit is contained in:
committed by
Dan Gohman
parent
ebef2c6b57
commit
9947bc5209
@@ -5,32 +5,16 @@ use core::cell::RefCell;
|
||||
use cranelift_codegen::settings;
|
||||
use cranelift_codegen::settings::Configurable;
|
||||
use std::collections::HashMap;
|
||||
use std::fs::File;
|
||||
use std::io;
|
||||
use std::io::Read;
|
||||
use std::path::PathBuf;
|
||||
use wabt;
|
||||
use wasmtime_jit::{instantiate, CompilationStrategy, Compiler, NullResolver};
|
||||
|
||||
#[cfg(test)]
|
||||
const PATH_MODULE_RS2WASM_ADD_FUNC: &str = r"filetests/rs2wasm-add-func.wat";
|
||||
|
||||
#[cfg(test)]
|
||||
fn read_to_end(path: PathBuf) -> Result<Vec<u8>, io::Error> {
|
||||
let mut buf: Vec<u8> = Vec::new();
|
||||
let mut file = File::open(path)?;
|
||||
file.read_to_end(&mut buf)?;
|
||||
Ok(buf)
|
||||
}
|
||||
|
||||
/// Simple test reading a wasm-file and translating to binary representation.
|
||||
#[test]
|
||||
fn test_environ_translate() {
|
||||
let path = PathBuf::from(PATH_MODULE_RS2WASM_ADD_FUNC);
|
||||
let wat_data = read_to_end(path).unwrap();
|
||||
assert!(wat_data.len() > 0);
|
||||
|
||||
let data = wabt::wat2wasm(wat_data).expect("expecting valid wat-file");
|
||||
let data = wat::parse_file(path).expect("expecting valid wat-file");
|
||||
assert!(data.len() > 0);
|
||||
|
||||
let mut flag_builder = settings::builder();
|
||||
|
||||
Reference in New Issue
Block a user