Code review feedback.

* Move `Module::compile` to `Engine::precompile_module`.
* Remove `Module::deserialize` method.
* Make `Module::serialize` the same format as `Engine::precompile_module`.
* Make `Engine::precompile_module` return a `Vec<u8>`.
* Move the remaining serialization-related code to `serialization.rs`.
This commit is contained in:
Peter Huene
2021-03-31 23:46:30 -07:00
parent abf3bf29f9
commit d1313b1291
10 changed files with 136 additions and 146 deletions

View File

@@ -2,15 +2,14 @@
use crate::CommonOptions;
use anyhow::{bail, Context, Result};
use std::fs::{self, File};
use std::io::BufWriter;
use std::fs;
use std::path::PathBuf;
use structopt::{
clap::{AppSettings, ArgGroup},
StructOpt,
};
use target_lexicon::Triple;
use wasmtime::{Engine, Module};
use wasmtime::Engine;
lazy_static::lazy_static! {
static ref AFTER_HELP: String = {
@@ -100,8 +99,7 @@ impl CompileCommand {
output
});
let mut writer = BufWriter::new(File::create(&output)?);
Module::compile(&engine, &input, &mut writer)?;
fs::write(output, engine.precompile_module(&input)?)?;
Ok(())
}
@@ -112,7 +110,7 @@ mod test {
use super::*;
use std::io::Write;
use tempfile::NamedTempFile;
use wasmtime::{Instance, Store};
use wasmtime::{Instance, Module, Store};
#[test]
fn test_successful_compile() -> Result<()> {