h
This commit is contained in:
parent
fc887db31c
commit
282c86eff2
|
@ -14,6 +14,7 @@ impl HostFunctions {
|
||||||
fn check_signature(&self, index: usize, signature: &Signature) -> bool {
|
fn check_signature(&self, index: usize, signature: &Signature) -> bool {
|
||||||
let (params, ret_ty): (&[ValueType], Option<ValueType>) = match index.into() {
|
let (params, ret_ty): (&[ValueType], Option<ValueType>) = match index.into() {
|
||||||
SysCall::KILL => (&[ValueType::I32, ValueType::I32], Some(ValueType::I32)),
|
SysCall::KILL => (&[ValueType::I32, ValueType::I32], Some(ValueType::I32)),
|
||||||
|
SysCall::EMPTY => (&[], None),
|
||||||
_ => return false,
|
_ => return false,
|
||||||
};
|
};
|
||||||
signature.params() == params && signature.return_type() == ret_ty
|
signature.params() == params && signature.return_type() == ret_ty
|
||||||
|
@ -33,6 +34,7 @@ impl Externals for HostFunctions {
|
||||||
|
|
||||||
Ok(Some(RuntimeValue::I32(result as i32)))
|
Ok(Some(RuntimeValue::I32(result as i32)))
|
||||||
}
|
}
|
||||||
|
SysCall::EMPTY => Ok(None),
|
||||||
// SysCall::CONSOLE_RESET => {}
|
// SysCall::CONSOLE_RESET => {}
|
||||||
// SysCall::CONSOLE_IN => {}
|
// SysCall::CONSOLE_IN => {}
|
||||||
// SysCall::CONSOLE_OUT => {}
|
// SysCall::CONSOLE_OUT => {}
|
||||||
|
@ -46,6 +48,7 @@ impl ModuleImportResolver for HostFunctions {
|
||||||
fn resolve_func(&self, field_name: &str, signature: &Signature) -> Result<FuncRef, Error> {
|
fn resolve_func(&self, field_name: &str, signature: &Signature) -> Result<FuncRef, Error> {
|
||||||
let index = match field_name {
|
let index = match field_name {
|
||||||
"add" => SysCall::KILL as usize,
|
"add" => SysCall::KILL as usize,
|
||||||
|
"empty" => SysCall::EMPTY as usize,
|
||||||
_ => {
|
_ => {
|
||||||
return Err(Error::Instantiation(format!(
|
return Err(Error::Instantiation(format!(
|
||||||
"Export {} not found",
|
"Export {} not found",
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
(module
|
(module
|
||||||
(import "host" "add" (func $add (param i32 i32)(result i32)))
|
(import "host" "add" (func $add (param i32 i32)(result i32)))
|
||||||
|
(; (import "host" "empty" (func $empty)) ;)
|
||||||
(func (export "main") (result i32)
|
(func (export "main") (result i32)
|
||||||
|
(; (call $empty) ;)
|
||||||
(call $add (i32.const 123) (i32.const 456))
|
(call $add (i32.const 123) (i32.const 456))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
Reference in a new issue