mirror of
https://github.com/fluencelabs/parity-wasm
synced 2025-06-18 09:21:49 +00:00
Fix type in Instantiation
This commit is contained in:
@ -46,7 +46,7 @@ pub enum Error {
|
|||||||
Validation(String),
|
Validation(String),
|
||||||
/// Error while instantiating a module. Might occur when provided
|
/// Error while instantiating a module. Might occur when provided
|
||||||
/// with incorrect exports (i.e. linkage failure).
|
/// with incorrect exports (i.e. linkage failure).
|
||||||
Instatiation(String),
|
Instantiation(String),
|
||||||
/// Function-level error.
|
/// Function-level error.
|
||||||
Function(String),
|
Function(String),
|
||||||
/// Table-level error.
|
/// Table-level error.
|
||||||
@ -78,7 +78,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::Instatiation(s) => s,
|
Error::Instantiation(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,
|
||||||
@ -100,7 +100,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::Instatiation(ref s) => write!(f, "Instatiation: {}", s),
|
Error::Instantiation(ref s) => write!(f, "Instantiation: {}", 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),
|
||||||
|
@ -170,7 +170,7 @@ impl<St> ModuleInstance<St> {
|
|||||||
&[],
|
&[],
|
||||||
);
|
);
|
||||||
if imports.len() != extern_vals.len() {
|
if imports.len() != extern_vals.len() {
|
||||||
return Err(Error::Instatiation(format!(
|
return Err(Error::Instantiation(format!(
|
||||||
"extern_vals length is not equal to import section entries"
|
"extern_vals length is not equal to import section entries"
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
@ -185,7 +185,7 @@ impl<St> ModuleInstance<St> {
|
|||||||
);
|
);
|
||||||
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::Instatiation(format!(
|
return Err(Error::Instantiation(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,
|
||||||
@ -204,7 +204,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::Instatiation(format!(
|
return Err(Error::Instantiation(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(),
|
||||||
@ -213,7 +213,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::Instatiation(format!(
|
return Err(Error::Instantiation(format!(
|
||||||
"Expected {:?} type, but provided {:?} extern_val",
|
"Expected {:?} type, but provided {:?} extern_val",
|
||||||
expected_import,
|
expected_import,
|
||||||
actual_extern_val
|
actual_extern_val
|
||||||
@ -365,7 +365,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::Instatiation(format!("Module {} not found", module_name))
|
Error::Instantiation(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) => {
|
||||||
@ -596,7 +596,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::Instatiation(format!(
|
return Err(Error::Instantiation(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()
|
||||||
@ -607,7 +607,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::Instatiation(format!(
|
return Err(Error::Instantiation(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()
|
||||||
|
@ -375,7 +375,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::Instatiation(_)) if is_error => (),
|
Err(Error::Instantiation(_)) if is_error => (),
|
||||||
x @ _ => panic!("unexpected result for test_case {:?}: {:?}", test_case, x),
|
x @ _ => panic!("unexpected result for test_case {:?}: {:?}", test_case, x),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -407,7 +407,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::Instatiation(actual_err)) => match expected_err {
|
Err(Error::Instantiation(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),
|
||||||
@ -441,7 +441,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::Instatiation(ref actual_error))
|
Err(Error::Instantiation(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),
|
||||||
}
|
}
|
||||||
@ -474,7 +474,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::Instatiation(actual_err)) => match expected_err {
|
Err(Error::Instantiation(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),
|
||||||
|
Reference in New Issue
Block a user