Merge pull request #942 from alexcrichton/parity-wasm-public

Update parity-wasm dependency
This commit is contained in:
Alex Crichton 2018-10-08 12:46:35 -07:00 committed by GitHub
commit 6a9ad2e5d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 9 additions and 38 deletions

View File

@ -13,7 +13,7 @@ Shared support for the wasm-bindgen-cli package, an internal dependency
[dependencies]
base64 = "0.9"
failure = "0.1.2"
parity-wasm = "0.32"
parity-wasm = "0.34"
serde = "1.0"
serde_json = "1.0"
tempfile = "3.0"

View File

@ -8,7 +8,6 @@ extern crate wasm_bindgen_gc;
extern crate failure;
extern crate wasm_bindgen_wasm_interpreter as wasm_interpreter;
use std::any::Any;
use std::collections::BTreeSet;
use std::env;
use std::fs;
@ -40,7 +39,6 @@ pub struct Bindgen {
enum Input {
Path(PathBuf),
Bytes(Vec<u8>, String),
Module(Module, String),
None,
}
@ -68,33 +66,10 @@ impl Bindgen {
}
/// Explicitly specify the already parsed input module.
///
/// Note that this API is a little wonky to avoid tying itself with a public
/// dependency on the `parity-wasm` crate, what we currently use to parse
/// wasm mdoules.
///
/// If the `module` argument is a `parity_wasm::Module` then it will be used
/// directly. Otherwise it will be passed to `into_bytes` to serialize the
/// module to a vector of bytes, and this will deserialize the module later.
///
/// Note that even if the argument passed in is a `parity_wasm::Module` it
/// doesn't mean that this won't invoke `into_bytes`, if the `parity_wasm`
/// crate versions are different we'll have to go through serialization.
pub fn input_module<T: Any>(
&mut self,
name: &str,
mut module: T,
into_bytes: impl FnOnce(T) -> Vec<u8>,
) -> &mut Bindgen {
pub fn input_module(&mut self, name: &str, module: Module) -> &mut Bindgen {
let name = name.to_string();
if let Some(module) = (&mut module as &mut Any).downcast_mut::<Module>() {
let blank = Module::new(Vec::new());
self.input = Input::Module(mem::replace(module, blank), name);
return self;
}
self.input = Input::Bytes(into_bytes(module), name);
self
self.input = Input::Module(module, name);
return self;
}
pub fn nodejs(&mut self, node: bool) -> &mut Bindgen {
@ -153,11 +128,6 @@ impl Bindgen {
let blank_module = Module::new(Vec::new());
(mem::replace(m, blank_module), &name[..])
}
Input::Bytes(ref b, ref name) => {
let module = parity_wasm::deserialize_buffer::<Module>(&b)
.context("failed to parse input file as wasm")?;
(module, &name[..])
}
Input::Path(ref path) => {
let contents = fs::read(&path)
.with_context(|_| format!("failed to read `{}`", path.display()))?;

View File

@ -18,7 +18,7 @@ docopt = "1.0"
env_logger = "0.5"
failure = "0.1.2"
log = "0.4"
parity-wasm = "0.32"
parity-wasm = "0.34"
rouille = { version = "2.1.0", default-features = false }
serde = "1.0"
serde_derive = "1.0"

View File

@ -126,7 +126,7 @@ fn rmain() -> Result<(), Error> {
let mut b = Bindgen::new();
b.debug(debug)
.nodejs(node)
.input_module(module, wasm, |w| parity_wasm::serialize(w).unwrap())
.input_module(module, wasm)
.keep_debug(false)
.generate(&tmpdir)
.context("executing `wasm-bindgen` over the wasm file")?;

View File

@ -11,6 +11,6 @@ Support for removing unused items from a wasm executable
"""
[dependencies]
parity-wasm = "0.32"
parity-wasm = "0.34"
log = "0.4"
rustc-demangle = "0.1.9"

View File

@ -354,6 +354,7 @@ impl<'a> LiveContext<'a> {
ValueType::I64 => {}
ValueType::F32 => {}
ValueType::F64 => {}
ValueType::V128 => {}
}
}

View File

@ -11,7 +11,7 @@ Micro-interpreter optimized for wasm-bindgen's use case
"""
[dependencies]
parity-wasm = "0.32"
parity-wasm = "0.34"
[dev-dependencies]
tempfile = "3"