mirror of
https://github.com/fluencelabs/parity-wasm
synced 2025-06-21 18:51:52 +00:00
enabled warnings
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
#![allow(dead_code, unused_variables, missing_docs)]
|
#![allow(missing_docs)]
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
@ -50,3 +50,7 @@ mod variable;
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
|
pub use self::module::ModuleInstance;
|
||||||
|
pub use self::program::ProgramInstance;
|
||||||
|
pub use self::value::RuntimeValue;
|
@ -104,6 +104,11 @@ impl ModuleInstance {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Execute start function of the module.
|
||||||
|
pub fn execute_main(&self, _args: &[RuntimeValue]) -> Result<Option<RuntimeValue>, Error> {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
/// Get module description reference.
|
/// Get module description reference.
|
||||||
pub fn module(&self) -> &Module {
|
pub fn module(&self) -> &Module {
|
||||||
&self.module
|
&self.module
|
||||||
@ -206,7 +211,7 @@ impl ModuleInstance {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Call function with given index in the given table.
|
/// Call function with given index in the given table.
|
||||||
pub fn call_function_indirect(&self, outer: &mut FunctionContext, table_index: ItemIndex, type_index: u32, func_index: u32) -> Result<Option<RuntimeValue>, Error> {
|
pub fn call_function_indirect(&self, outer: &mut FunctionContext, table_index: ItemIndex, _type_index: u32, func_index: u32) -> Result<Option<RuntimeValue>, Error> {
|
||||||
// TODO: check signature
|
// TODO: check signature
|
||||||
match self.imports.parse_table_index(table_index) {
|
match self.imports.parse_table_index(table_index) {
|
||||||
ItemIndex::IndexSpace(_) => unreachable!("parse_function_index resolves IndexSpace option"),
|
ItemIndex::IndexSpace(_) => unreachable!("parse_function_index resolves IndexSpace option"),
|
||||||
|
@ -27,13 +27,14 @@ impl ProgramInstance {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Instantiate module.
|
/// Instantiate module.
|
||||||
pub fn add_module(&self, name: &str, module: Module) -> Result<(), Error> {
|
pub fn add_module(&self, name: &str, module: Module) -> Result<Arc<ModuleInstance>, Error> {
|
||||||
let mut modules = self.essence.modules.write();
|
let mut modules = self.essence.modules.write();
|
||||||
match modules.entry(name.into()) {
|
match modules.entry(name.into()) {
|
||||||
Entry::Occupied(_) => Err(Error::Program(format!("module {} already instantiated", name))),
|
Entry::Occupied(_) => Err(Error::Program(format!("module {} already instantiated", name))),
|
||||||
Entry::Vacant(entry) => {
|
Entry::Vacant(entry) => {
|
||||||
entry.insert(Arc::new(ModuleInstance::new(Arc::downgrade(&self.essence), module)?));
|
let module_instance = Arc::new(ModuleInstance::new(Arc::downgrade(&self.essence), module)?);
|
||||||
Ok(())
|
entry.insert(module_instance.clone());
|
||||||
|
Ok(module_instance)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ impl Interpreter {
|
|||||||
&Opcode::Return => Interpreter::run_return(context),
|
&Opcode::Return => Interpreter::run_return(context),
|
||||||
|
|
||||||
&Opcode::Call(index) => Interpreter::run_call(context, index),
|
&Opcode::Call(index) => Interpreter::run_call(context, index),
|
||||||
&Opcode::CallIndirect(index, reserved) => Interpreter::run_call_indirect(context, index),
|
&Opcode::CallIndirect(index, _reserved) => Interpreter::run_call_indirect(context, index),
|
||||||
|
|
||||||
&Opcode::Drop => Interpreter::run_drop(context),
|
&Opcode::Drop => Interpreter::run_drop(context),
|
||||||
&Opcode::Select => Interpreter::run_select(context),
|
&Opcode::Select => Interpreter::run_select(context),
|
||||||
@ -261,11 +261,11 @@ impl Interpreter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_unreachable(context: &mut FunctionContext) -> Result<InstructionOutcome, Error> {
|
fn run_unreachable(_context: &mut FunctionContext) -> Result<InstructionOutcome, Error> {
|
||||||
Err(Error::Trap("programmatic".into()))
|
Err(Error::Trap("programmatic".into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_nop(context: &mut FunctionContext) -> Result<InstructionOutcome, Error> {
|
fn run_nop(_context: &mut FunctionContext) -> Result<InstructionOutcome, Error> {
|
||||||
Ok(InstructionOutcome::RunNextInstruction)
|
Ok(InstructionOutcome::RunNextInstruction)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,15 +299,15 @@ impl Interpreter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_else(context: &mut FunctionContext) -> Result<InstructionOutcome, Error> {
|
fn run_else(_context: &mut FunctionContext) -> Result<InstructionOutcome, Error> {
|
||||||
Ok(InstructionOutcome::End)
|
Ok(InstructionOutcome::End)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_end(context: &mut FunctionContext) -> Result<InstructionOutcome, Error> {
|
fn run_end(_context: &mut FunctionContext) -> Result<InstructionOutcome, Error> {
|
||||||
Ok(InstructionOutcome::End)
|
Ok(InstructionOutcome::End)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_br(context: &mut FunctionContext, label_idx: u32) -> Result<InstructionOutcome, Error> {
|
fn run_br(_context: &mut FunctionContext, label_idx: u32) -> Result<InstructionOutcome, Error> {
|
||||||
Ok(InstructionOutcome::Branch(label_idx as usize))
|
Ok(InstructionOutcome::Branch(label_idx as usize))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -324,7 +324,7 @@ impl Interpreter {
|
|||||||
Ok(InstructionOutcome::Branch(table.get(index as usize).cloned().unwrap_or(default) as usize))
|
Ok(InstructionOutcome::Branch(table.get(index as usize).cloned().unwrap_or(default) as usize))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_return(context: &mut FunctionContext) -> Result<InstructionOutcome, Error> {
|
fn run_return(_context: &mut FunctionContext) -> Result<InstructionOutcome, Error> {
|
||||||
Ok(InstructionOutcome::Return)
|
Ok(InstructionOutcome::Return)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -781,9 +781,9 @@ impl Interpreter {
|
|||||||
.map(|_| InstructionOutcome::RunNextInstruction)
|
.map(|_| InstructionOutcome::RunNextInstruction)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_copysign<T>(context: &mut FunctionContext) -> Result<InstructionOutcome, Error>
|
fn run_copysign<T>(_context: &mut FunctionContext) -> Result<InstructionOutcome, Error>
|
||||||
where RuntimeValue: From<T> + TryInto<T, Error>, T: Float<T> {
|
where RuntimeValue: From<T> + TryInto<T, Error>, T: Float<T> {
|
||||||
Err(Error::NotImplemented)
|
Err(Error::NotImplemented) // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_wrap<T, U>(context: &mut FunctionContext) -> Result<InstructionOutcome, Error>
|
fn run_wrap<T, U>(context: &mut FunctionContext) -> Result<InstructionOutcome, Error>
|
||||||
|
@ -12,8 +12,6 @@ pub struct TableInstance {
|
|||||||
variable_type: VariableType,
|
variable_type: VariableType,
|
||||||
/// Table memory buffer.
|
/// Table memory buffer.
|
||||||
buffer: RwLock<Vec<VariableInstance>>,
|
buffer: RwLock<Vec<VariableInstance>>,
|
||||||
/// Maximum buffer size.
|
|
||||||
maximum_size: u32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TableInstance {
|
impl TableInstance {
|
||||||
@ -23,7 +21,6 @@ impl TableInstance {
|
|||||||
buffer: RwLock::new(
|
buffer: RwLock::new(
|
||||||
vec![VariableInstance::new(true, variable_type, RuntimeValue::Null)?; table_type.limits().initial() as usize]
|
vec![VariableInstance::new(true, variable_type, RuntimeValue::Null)?; table_type.limits().initial() as usize]
|
||||||
),
|
),
|
||||||
maximum_size: table_type.limits().maximum().unwrap_or(u32::MAX),
|
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
pub fn to_little_endian_bytes<T>(number: T) -> Vec<u8> {
|
pub fn to_little_endian_bytes<T>(_number: T) -> Vec<u8> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_little_endian_bytes<T>(buffer: &[u8]) -> T {
|
pub fn from_little_endian_bytes<T>(_buffer: &[u8]) -> T {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
@ -16,3 +16,9 @@ pub use elements::{
|
|||||||
serialize,
|
serialize,
|
||||||
serialize_to_file,
|
serialize_to_file,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub use interpreter::{
|
||||||
|
ProgramInstance,
|
||||||
|
ModuleInstance,
|
||||||
|
RuntimeValue,
|
||||||
|
};
|
||||||
|
Reference in New Issue
Block a user