wasmi/src/types.rs

29 lines
602 B
Rust
Raw Normal View History

2018-01-18 12:54:31 +00:00
use parity_wasm::elements::{FunctionType, ValueType};
#[derive(Debug, Clone, PartialEq)]
pub struct Signature {
func_type: FunctionType,
}
impl Signature {
pub fn new(params: &[ValueType], return_type: Option<ValueType>) -> Signature {
Signature {
func_type: FunctionType::new(params.to_vec(), return_type),
}
}
pub fn params(&self) -> &[ValueType] {
self.func_type.params()
}
pub fn return_type(&self) -> Option<ValueType> {
self.func_type.return_type()
}
}
impl From<FunctionType> for Signature {
fn from(func_type: FunctionType) -> Signature {
Signature { func_type }
}
}