70 lines
1.4 KiB
Rust
Raw Normal View History

2017-04-27 15:49:14 +03:00
//! WebAssembly interpreter module.
2017-04-21 14:35:12 +03:00
2017-04-27 15:49:14 +03:00
/// Interpreter error.
2017-04-21 14:35:12 +03:00
#[derive(Debug, Clone, PartialEq)]
pub enum Error {
2017-04-27 15:49:14 +03:00
/// Program-level error.
2017-04-21 14:35:12 +03:00
Program(String),
2017-04-27 15:49:14 +03:00
/// Initialization error.
2017-04-21 14:35:12 +03:00
Initialization(String),
2017-04-27 15:49:14 +03:00
/// Function-level error.
2017-04-21 14:35:12 +03:00
Function(String),
2017-04-27 15:49:14 +03:00
/// Table-level error.
2017-04-21 14:35:12 +03:00
Table(String),
2017-04-27 15:49:14 +03:00
/// Memory-level error.
2017-04-21 14:35:12 +03:00
Memory(String),
2017-04-27 15:49:14 +03:00
/// Variable-level error.
2017-04-21 14:35:12 +03:00
Variable(String),
2017-04-27 15:49:14 +03:00
/// Global-level error.
2017-04-21 14:35:12 +03:00
Global(String),
2017-04-27 15:49:14 +03:00
/// Local-level error.
2017-04-21 14:35:12 +03:00
Local(String),
2017-04-27 15:49:14 +03:00
/// Stack-level error.
2017-04-26 12:37:27 +03:00
Stack(String),
2017-04-27 15:49:14 +03:00
/// Value-level error.
2017-04-21 14:35:12 +03:00
Value(String),
2017-04-27 15:49:14 +03:00
/// Interpreter (code) error.
2017-04-21 14:35:12 +03:00
Interpreter(String),
2017-05-04 12:01:21 +03:00
/// Env module error.
Env(String),
2017-04-27 15:49:14 +03:00
/// Trap.
2017-04-26 15:41:22 +03:00
Trap(String),
2017-04-21 14:35:12 +03:00
}
impl Into<String> for Error {
fn into(self) -> String {
match self {
Error::Program(s) => s,
Error::Initialization(s) => s,
Error::Function(s) => s,
Error::Table(s) => s,
Error::Memory(s) => s,
Error::Variable(s) => s,
Error::Global(s) => s,
Error::Local(s) => s,
2017-04-26 12:37:27 +03:00
Error::Stack(s) => s,
2017-04-21 14:35:12 +03:00
Error::Interpreter(s) => s,
Error::Value(s) => s,
2017-05-04 12:01:21 +03:00
Error::Env(s) => s,
2017-04-26 15:41:22 +03:00
Error::Trap(s) => format!("trap: {}", s),
2017-04-21 14:35:12 +03:00
}
}
}
2017-05-04 11:25:25 +03:00
mod env;
2017-04-21 14:35:12 +03:00
mod imports;
mod memory;
mod module;
mod program;
mod runner;
2017-04-26 12:37:27 +03:00
mod stack;
2017-04-21 14:35:12 +03:00
mod table;
mod value;
mod variable;
2017-04-27 14:22:02 +03:00
#[cfg(test)]
mod tests;
2017-04-27 14:44:03 +03:00
2017-05-04 11:25:25 +03:00
pub use self::module::{ModuleInstance, ModuleInstanceInterface};
2017-04-27 14:44:03 +03:00
pub use self::program::ProgramInstance;
pub use self::value::RuntimeValue;