Move Signature into types module.
This commit is contained in:
parent
e9470373f7
commit
1bf3702440
29
src/lib.rs
29
src/lib.rs
|
@ -10,7 +10,6 @@ extern crate byteorder;
|
|||
|
||||
use std::fmt;
|
||||
use std::error;
|
||||
use parity_wasm::elements::{FunctionType, ValueType};
|
||||
|
||||
/// Internal interpreter error.
|
||||
#[derive(Debug)]
|
||||
|
@ -98,32 +97,7 @@ impl From<::common::stack::Error> for Error {
|
|||
}
|
||||
}
|
||||
|
||||
#[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 }
|
||||
}
|
||||
}
|
||||
use types::Signature;
|
||||
|
||||
mod validation;
|
||||
mod common;
|
||||
|
@ -136,6 +110,7 @@ mod host;
|
|||
mod imports;
|
||||
mod global;
|
||||
mod func;
|
||||
mod types;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
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 }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue