Make FuncEnvironment independent from ModuleEnvironment (formerly WasmRuntime).
This renames WasmRuntime to ModuleEnvironment, and makes several changes to allow for more flexible compilation. ModuleEnvironment no longer derives from FuncEnvironment, and no longer has the `begin_translation` and `next_translation` functions, so that independent `FuncEnvironment` instances can operate within the same module. Also, this obviates the rest of TranslationResult, as it moves processing of function bodies into the environment. The DummyEnvironment implementation gives an example of decoding the function bodies as they are parsed, however other implementation strategies are now possible.
This commit is contained in:
@@ -2,7 +2,7 @@ extern crate cton_wasm;
|
||||
extern crate cretonne;
|
||||
extern crate tempdir;
|
||||
|
||||
use cton_wasm::{translate_module, DummyRuntime, WasmRuntime};
|
||||
use cton_wasm::{translate_module, DummyEnvironment};
|
||||
use std::path::PathBuf;
|
||||
use std::fs::File;
|
||||
use std::error::Error;
|
||||
@@ -92,12 +92,9 @@ fn handle_module(path: PathBuf, flags: &Flags) {
|
||||
}
|
||||
}
|
||||
};
|
||||
let mut dummy_runtime = DummyRuntime::with_flags(flags.clone());
|
||||
let translation = {
|
||||
let runtime: &mut WasmRuntime = &mut dummy_runtime;
|
||||
translate_module(&data, runtime).unwrap()
|
||||
};
|
||||
for func in &translation.functions {
|
||||
let mut dummy_environ = DummyEnvironment::with_flags(flags.clone());
|
||||
translate_module(&data, &mut dummy_environ).unwrap();
|
||||
for func in &dummy_environ.info.function_bodies {
|
||||
verifier::verify_function(func, flags)
|
||||
.map_err(|err| panic!(pretty_verifier_error(func, None, err)))
|
||||
.unwrap();
|
||||
|
||||
Reference in New Issue
Block a user