Add special error types for compile, linking, and runtime errors. (#99)

* Add error types and convert most results to wasmer-runtime results

* Fix spectests

* Fix umbrella project to work with new error types
This commit is contained in:
Lachlan Sneff
2019-01-18 10:54:16 -08:00
committed by GitHub
parent 9c0d78ae46
commit 8a9f5fa61a
18 changed files with 394 additions and 179 deletions

View File

@ -5,6 +5,7 @@ use crate::{
use cranelift_codegen::{ir, isa};
use cranelift_wasm::{self, translate_module, FuncTranslator, ModuleEnvironment};
use wasmer_runtime::{
error::{CompileError, CompileResult},
module::{DataInitializer, ExportIndex, ImportName, TableInitializer},
structures::{Map, TypedIndex},
types::{
@ -32,8 +33,9 @@ impl<'module, 'isa> ModuleEnv<'module, 'isa> {
}
}
pub fn translate(mut self, wasm: &[u8]) -> Result<Map<LocalFuncIndex, ir::Function>, String> {
translate_module(wasm, &mut self).map_err(|e| e.to_string())?;
pub fn translate(mut self, wasm: &[u8]) -> CompileResult<Map<LocalFuncIndex, ir::Function>> {
translate_module(wasm, &mut self)
.map_err(|e| CompileError::InternalError { msg: e.to_string() })?;
Ok(self.func_bodies)
}
}