mirror of
https://github.com/fluencelabs/parity-wasm
synced 2025-06-05 11:01:38 +00:00
Rename Initialization error to Instatiation
This commit is contained in:
parent
9dd7a5dfaf
commit
afb33d6f16
@ -42,8 +42,9 @@ pub enum Error {
|
|||||||
Program(String),
|
Program(String),
|
||||||
/// Validation error.
|
/// Validation error.
|
||||||
Validation(String),
|
Validation(String),
|
||||||
/// Initialization error.
|
/// Error while instantiating a module. Might occur when provided
|
||||||
Initialization(String),
|
/// with incorrect exports (i.e. linkage failure).
|
||||||
|
Instatiation(String),
|
||||||
/// Function-level error.
|
/// Function-level error.
|
||||||
Function(String),
|
Function(String),
|
||||||
/// Table-level error.
|
/// Table-level error.
|
||||||
@ -75,7 +76,7 @@ impl Into<String> for Error {
|
|||||||
match self {
|
match self {
|
||||||
Error::Program(s) => s,
|
Error::Program(s) => s,
|
||||||
Error::Validation(s) => s,
|
Error::Validation(s) => s,
|
||||||
Error::Initialization(s) => s,
|
Error::Instatiation(s) => s,
|
||||||
Error::Function(s) => s,
|
Error::Function(s) => s,
|
||||||
Error::Table(s) => s,
|
Error::Table(s) => s,
|
||||||
Error::Memory(s) => s,
|
Error::Memory(s) => s,
|
||||||
@ -97,7 +98,7 @@ impl ::std::fmt::Display for Error {
|
|||||||
match *self {
|
match *self {
|
||||||
Error::Program(ref s) => write!(f, "Program: {}", s),
|
Error::Program(ref s) => write!(f, "Program: {}", s),
|
||||||
Error::Validation(ref s) => write!(f, "Validation: {}", s),
|
Error::Validation(ref s) => write!(f, "Validation: {}", s),
|
||||||
Error::Initialization(ref s) => write!(f, "Initialization: {}", s),
|
Error::Instatiation(ref s) => write!(f, "Instatiation: {}", s),
|
||||||
Error::Function(ref s) => write!(f, "Function: {}", s),
|
Error::Function(ref s) => write!(f, "Function: {}", s),
|
||||||
Error::Table(ref s) => write!(f, "Table: {}", s),
|
Error::Table(ref s) => write!(f, "Table: {}", s),
|
||||||
Error::Memory(ref s) => write!(f, "Memory: {}", s),
|
Error::Memory(ref s) => write!(f, "Memory: {}", s),
|
||||||
|
@ -167,7 +167,7 @@ impl<St> ModuleInstance<St> {
|
|||||||
.map(|is| is.entries())
|
.map(|is| is.entries())
|
||||||
.unwrap_or(&[]);
|
.unwrap_or(&[]);
|
||||||
if imports.len() != extern_vals.len() {
|
if imports.len() != extern_vals.len() {
|
||||||
return Err(Error::Initialization(format!(
|
return Err(Error::Instatiation(format!(
|
||||||
"extern_vals length is not equal to import section entries"
|
"extern_vals length is not equal to import section entries"
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
@ -181,7 +181,7 @@ impl<St> ModuleInstance<St> {
|
|||||||
.expect("Due to validation function type should exists");
|
.expect("Due to validation function type should exists");
|
||||||
let actual_fn_type = func.func_type();
|
let actual_fn_type = func.func_type();
|
||||||
if expected_fn_type != actual_fn_type {
|
if expected_fn_type != actual_fn_type {
|
||||||
return Err(Error::Initialization(format!(
|
return Err(Error::Instatiation(format!(
|
||||||
"Expected function with type {:?}, but actual type is {:?} for entry {}",
|
"Expected function with type {:?}, but actual type is {:?} for entry {}",
|
||||||
expected_fn_type,
|
expected_fn_type,
|
||||||
actual_fn_type,
|
actual_fn_type,
|
||||||
@ -200,7 +200,7 @@ impl<St> ModuleInstance<St> {
|
|||||||
}
|
}
|
||||||
(&External::Global(ref gl), &ExternVal::Global(ref global)) => {
|
(&External::Global(ref gl), &ExternVal::Global(ref global)) => {
|
||||||
if gl.content_type() != global.value_type() {
|
if gl.content_type() != global.value_type() {
|
||||||
return Err(Error::Initialization(format!(
|
return Err(Error::Instatiation(format!(
|
||||||
"Expect global with {:?} type, but provided global with {:?} type",
|
"Expect global with {:?} type, but provided global with {:?} type",
|
||||||
gl.content_type(),
|
gl.content_type(),
|
||||||
global.value_type(),
|
global.value_type(),
|
||||||
@ -209,7 +209,7 @@ impl<St> ModuleInstance<St> {
|
|||||||
instance.push_global(Rc::clone(global))
|
instance.push_global(Rc::clone(global))
|
||||||
}
|
}
|
||||||
(expected_import, actual_extern_val) => {
|
(expected_import, actual_extern_val) => {
|
||||||
return Err(Error::Initialization(format!(
|
return Err(Error::Instatiation(format!(
|
||||||
"Expected {:?} type, but provided {:?} extern_val",
|
"Expected {:?} type, but provided {:?} extern_val",
|
||||||
expected_import,
|
expected_import,
|
||||||
actual_extern_val
|
actual_extern_val
|
||||||
@ -369,7 +369,7 @@ impl<St> ModuleInstance<St> {
|
|||||||
let module_name = import_entry.module();
|
let module_name = import_entry.module();
|
||||||
let field_name = import_entry.field();
|
let field_name = import_entry.field();
|
||||||
let resolver = imports.resolver(module_name).ok_or_else(|| {
|
let resolver = imports.resolver(module_name).ok_or_else(|| {
|
||||||
Error::Initialization(format!("Module {} not found", module_name))
|
Error::Instatiation(format!("Module {} not found", module_name))
|
||||||
})?;
|
})?;
|
||||||
let extern_val = match *import_entry.external() {
|
let extern_val = match *import_entry.external() {
|
||||||
External::Function(fn_ty_idx) => {
|
External::Function(fn_ty_idx) => {
|
||||||
@ -600,7 +600,7 @@ fn eval_init_expr<T>(init_expr: &InitExpr, module: &ModuleInstance<T>) -> Runtim
|
|||||||
|
|
||||||
fn match_limits(l1: &ResizableLimits, l2: &ResizableLimits) -> Result<(), Error> {
|
fn match_limits(l1: &ResizableLimits, l2: &ResizableLimits) -> Result<(), Error> {
|
||||||
if l1.initial() < l2.initial() {
|
if l1.initial() < l2.initial() {
|
||||||
return Err(Error::Initialization(format!(
|
return Err(Error::Instatiation(format!(
|
||||||
"trying to import with limits l1.initial={} and l2.initial={}",
|
"trying to import with limits l1.initial={} and l2.initial={}",
|
||||||
l1.initial(),
|
l1.initial(),
|
||||||
l2.initial()
|
l2.initial()
|
||||||
@ -611,7 +611,7 @@ fn match_limits(l1: &ResizableLimits, l2: &ResizableLimits) -> Result<(), Error>
|
|||||||
(_, None) => (),
|
(_, None) => (),
|
||||||
(Some(m1), Some(m2)) if m1 <= m2 => (),
|
(Some(m1), Some(m2)) if m1 <= m2 => (),
|
||||||
_ => {
|
_ => {
|
||||||
return Err(Error::Initialization(format!(
|
return Err(Error::Instatiation(format!(
|
||||||
"trying to import with limits l1.max={:?} and l2.max={:?}",
|
"trying to import with limits l1.max={:?} and l2.max={:?}",
|
||||||
l1.maximum(),
|
l1.maximum(),
|
||||||
l2.maximum()
|
l2.maximum()
|
||||||
|
@ -379,7 +379,7 @@ fn memory_import_limits_initial() {
|
|||||||
.build();
|
.build();
|
||||||
match program.add_module("client", client_module, &mut ()).map(|_| ()) {
|
match program.add_module("client", client_module, &mut ()).map(|_| ()) {
|
||||||
Ok(_) if !is_error => (),
|
Ok(_) if !is_error => (),
|
||||||
Err(Error::Initialization(_)) if is_error => (),
|
Err(Error::Instatiation(_)) if is_error => (),
|
||||||
x @ _ => panic!("unexpected result for test_case {:?}: {:?}", test_case, x),
|
x @ _ => panic!("unexpected result for test_case {:?}: {:?}", test_case, x),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -411,7 +411,7 @@ fn memory_import_limits_maximum() {
|
|||||||
|
|
||||||
program.add_module("core", core_module, &mut ()).unwrap();
|
program.add_module("core", core_module, &mut ()).unwrap();
|
||||||
match program.add_module("client", client_module, &mut ()).map(|_| ()) {
|
match program.add_module("client", client_module, &mut ()).map(|_| ()) {
|
||||||
Err(Error::Initialization(actual_err)) => match expected_err {
|
Err(Error::Instatiation(actual_err)) => match expected_err {
|
||||||
MaximumError::ValueMismatch
|
MaximumError::ValueMismatch
|
||||||
if actual_err == format!("trying to import with limits l1.max={:?} and l2.max={:?}", core_maximum, client_maximum) => (),
|
if actual_err == format!("trying to import with limits l1.max={:?} and l2.max={:?}", core_maximum, client_maximum) => (),
|
||||||
_ => panic!("unexpected validation error for test_case {:?}: {}", test_case, actual_err),
|
_ => panic!("unexpected validation error for test_case {:?}: {}", test_case, actual_err),
|
||||||
@ -445,7 +445,7 @@ fn table_import_limits_initial() {
|
|||||||
.build();
|
.build();
|
||||||
match program.add_module("client", client_module, &mut ()).map(|_| ()) {
|
match program.add_module("client", client_module, &mut ()).map(|_| ()) {
|
||||||
Ok(_) if !is_error => (),
|
Ok(_) if !is_error => (),
|
||||||
Err(Error::Initialization(ref actual_error))
|
Err(Error::Instatiation(ref actual_error))
|
||||||
if is_error && actual_error == &format!("trying to import with limits l1.initial=10 and l2.initial={}", import_initial) => (),
|
if is_error && actual_error == &format!("trying to import with limits l1.initial=10 and l2.initial={}", import_initial) => (),
|
||||||
x @ _ => panic!("unexpected result for test_case {:?}: {:?}", test_case, x),
|
x @ _ => panic!("unexpected result for test_case {:?}: {:?}", test_case, x),
|
||||||
}
|
}
|
||||||
@ -478,7 +478,7 @@ fn table_import_limits_maximum() {
|
|||||||
|
|
||||||
program.add_module("core", core_module, &mut ()).unwrap();
|
program.add_module("core", core_module, &mut ()).unwrap();
|
||||||
match program.add_module("client", client_module, &mut ()).map(|_| ()) {
|
match program.add_module("client", client_module, &mut ()).map(|_| ()) {
|
||||||
Err(Error::Initialization(actual_err)) => match expected_err {
|
Err(Error::Instatiation(actual_err)) => match expected_err {
|
||||||
MaximumError::ValueMismatch
|
MaximumError::ValueMismatch
|
||||||
if actual_err == format!("trying to import with limits l1.max={:?} and l2.max={:?}", core_maximum, client_maximum) => (),
|
if actual_err == format!("trying to import with limits l1.max={:?} and l2.max={:?}", core_maximum, client_maximum) => (),
|
||||||
_ => panic!("unexpected validation error for test_case {:?}: {}", test_case, actual_err),
|
_ => panic!("unexpected validation error for test_case {:?}: {}", test_case, actual_err),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user