Improve error handling, and start refactoring Instance.

Introduce proper error handling in several places, and perform a first
pass at refactoring Instance to make it easier to use.
This commit is contained in:
Dan Gohman
2018-12-07 15:32:51 -05:00
parent fe562297a7
commit 7dcca6be5b
24 changed files with 949 additions and 565 deletions

View File

@@ -38,7 +38,7 @@ use cranelift_codegen::settings;
use cranelift_codegen::settings::Configurable;
use docopt::Docopt;
use std::path::Path;
use wasmtime_wast::wast_file;
use wasmtime_wast::WastContext;
static LOG_FILENAME_PREFIX: &str = "cranelift.dbg.";
@@ -94,9 +94,10 @@ fn main() {
}
let isa = isa_builder.finish(settings::Flags::new(flag_builder));
let mut wast_context = WastContext::new();
for filename in &args.arg_file {
let path = Path::new(&filename);
wast_file(path, &*isa)
.unwrap_or_else(|e| panic!("error reading file {}: {}", path.display(), e));
wast_context
.run_file(&*isa, Path::new(&filename))
.unwrap_or_else(|e| panic!("{}", e));
}
}