mirror of
https://github.com/fluencelabs/parity-wasm
synced 2025-06-21 18:51:52 +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)]
|
||||
pub enum Error {
|
||||
/// Program-level error.
|
||||
Program(String),
|
||||
/// Initialization error.
|
||||
Initialization(String),
|
||||
/// Function-level error.
|
||||
Function(String),
|
||||
/// Table-level error.
|
||||
Table(String),
|
||||
/// Memory-level error.
|
||||
Memory(String),
|
||||
/// Variable-level error.
|
||||
Variable(String),
|
||||
/// Global-level error.
|
||||
Global(String),
|
||||
/// Local-level error.
|
||||
Local(String),
|
||||
/// Stack-level error.
|
||||
Stack(String),
|
||||
/// Value-level error.
|
||||
Value(String),
|
||||
/// Interpreter (code) error.
|
||||
Interpreter(String),
|
||||
/// Trap.
|
||||
Trap(String),
|
||||
/// Functionality not yet implemented.
|
||||
NotImplemented,
|
||||
}
|
||||
|
||||
|
@ -109,14 +109,17 @@ pub trait Float<T>: ArithmeticOps<T> {
|
||||
}
|
||||
|
||||
impl RuntimeValue {
|
||||
/// Creates new value by interpreting passed u32 as f32.
|
||||
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 {
|
||||
RuntimeValue::F64(unsafe { mem::transmute(val) })
|
||||
RuntimeValue::F64(val.transmute_into())
|
||||
}
|
||||
|
||||
/// Returns true if value is null.
|
||||
pub fn is_null(&self) -> bool {
|
||||
match *self {
|
||||
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> {
|
||||
match *self {
|
||||
RuntimeValue::AnyFunc(idx) => Some(idx),
|
||||
@ -131,6 +135,7 @@ impl RuntimeValue {
|
||||
}
|
||||
}
|
||||
|
||||
/// Get variable type for this value.
|
||||
pub fn variable_type(&self) -> Option<VariableType> {
|
||||
match *self {
|
||||
RuntimeValue::Null => None,
|
||||
@ -345,10 +350,12 @@ impl_transmute_into!(i8, u8);
|
||||
impl_transmute_into!(u8, i8);
|
||||
impl_transmute_into!(i32, u32);
|
||||
impl_transmute_into!(u32, i32);
|
||||
impl_transmute_into!(u32, f32);
|
||||
impl_transmute_into!(i32, f32);
|
||||
impl_transmute_into!(f32, i32);
|
||||
impl_transmute_into!(i64, u64);
|
||||
impl_transmute_into!(u64, i64);
|
||||
impl_transmute_into!(u64, f64);
|
||||
impl_transmute_into!(i64, f64);
|
||||
impl_transmute_into!(f64, i64);
|
||||
|
||||
|
Reference in New Issue
Block a user