Move Signature into types module.

This commit is contained in:
Sergey Pepyakin 2018-01-18 15:54:31 +03:00
parent e9470373f7
commit 1bf3702440
2 changed files with 30 additions and 27 deletions

View File

@ -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;

28
src/types.rs Normal file
View File

@ -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 }
}
}