mirror of
https://github.com/fluencelabs/parity-wasm
synced 2025-06-22 03:02:08 +00:00
added missing docs
This commit is contained in:
@ -1,19 +1,33 @@
|
|||||||
#![allow(missing_docs)]
|
//! WebAssembly interpreter module.
|
||||||
|
|
||||||
|
/// Interpreter error.
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
|
/// Program-level error.
|
||||||
Program(String),
|
Program(String),
|
||||||
|
/// Initialization error.
|
||||||
Initialization(String),
|
Initialization(String),
|
||||||
|
/// Function-level error.
|
||||||
Function(String),
|
Function(String),
|
||||||
|
/// Table-level error.
|
||||||
Table(String),
|
Table(String),
|
||||||
|
/// Memory-level error.
|
||||||
Memory(String),
|
Memory(String),
|
||||||
|
/// Variable-level error.
|
||||||
Variable(String),
|
Variable(String),
|
||||||
|
/// Global-level error.
|
||||||
Global(String),
|
Global(String),
|
||||||
|
/// Local-level error.
|
||||||
Local(String),
|
Local(String),
|
||||||
|
/// Stack-level error.
|
||||||
Stack(String),
|
Stack(String),
|
||||||
|
/// Value-level error.
|
||||||
Value(String),
|
Value(String),
|
||||||
|
/// Interpreter (code) error.
|
||||||
Interpreter(String),
|
Interpreter(String),
|
||||||
|
/// Trap.
|
||||||
Trap(String),
|
Trap(String),
|
||||||
|
/// Functionality not yet implemented.
|
||||||
NotImplemented,
|
NotImplemented,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,14 +109,17 @@ pub trait Float<T>: ArithmeticOps<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl RuntimeValue {
|
impl RuntimeValue {
|
||||||
|
/// Creates new value by interpreting passed u32 as f32.
|
||||||
pub fn decode_f32(val: u32) -> Self {
|
pub fn decode_f32(val: u32) -> Self {
|
||||||
RuntimeValue::F32(unsafe { mem::transmute(val) })
|
RuntimeValue::F32(val.transmute_into())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Creates new value by interpreting passed u64 as f64.
|
||||||
pub fn decode_f64(val: u64) -> Self {
|
pub fn decode_f64(val: u64) -> Self {
|
||||||
RuntimeValue::F64(unsafe { mem::transmute(val) })
|
RuntimeValue::F64(val.transmute_into())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns true if value is null.
|
||||||
pub fn is_null(&self) -> bool {
|
pub fn is_null(&self) -> bool {
|
||||||
match *self {
|
match *self {
|
||||||
RuntimeValue::Null => true,
|
RuntimeValue::Null => true,
|
||||||
@ -124,6 +127,7 @@ impl RuntimeValue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Gets function index, if type of value is AnyFunc.
|
||||||
pub fn as_any_func_index(&self) -> Option<u32> {
|
pub fn as_any_func_index(&self) -> Option<u32> {
|
||||||
match *self {
|
match *self {
|
||||||
RuntimeValue::AnyFunc(idx) => Some(idx),
|
RuntimeValue::AnyFunc(idx) => Some(idx),
|
||||||
@ -131,6 +135,7 @@ impl RuntimeValue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get variable type for this value.
|
||||||
pub fn variable_type(&self) -> Option<VariableType> {
|
pub fn variable_type(&self) -> Option<VariableType> {
|
||||||
match *self {
|
match *self {
|
||||||
RuntimeValue::Null => None,
|
RuntimeValue::Null => None,
|
||||||
@ -345,10 +350,12 @@ impl_transmute_into!(i8, u8);
|
|||||||
impl_transmute_into!(u8, i8);
|
impl_transmute_into!(u8, i8);
|
||||||
impl_transmute_into!(i32, u32);
|
impl_transmute_into!(i32, u32);
|
||||||
impl_transmute_into!(u32, i32);
|
impl_transmute_into!(u32, i32);
|
||||||
|
impl_transmute_into!(u32, f32);
|
||||||
impl_transmute_into!(i32, f32);
|
impl_transmute_into!(i32, f32);
|
||||||
impl_transmute_into!(f32, i32);
|
impl_transmute_into!(f32, i32);
|
||||||
impl_transmute_into!(i64, u64);
|
impl_transmute_into!(i64, u64);
|
||||||
impl_transmute_into!(u64, i64);
|
impl_transmute_into!(u64, i64);
|
||||||
|
impl_transmute_into!(u64, f64);
|
||||||
impl_transmute_into!(i64, f64);
|
impl_transmute_into!(i64, f64);
|
||||||
impl_transmute_into!(f64, i64);
|
impl_transmute_into!(f64, i64);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user