enabled warnings

This commit is contained in:
Svyatoslav Nikolsky
2017-04-27 14:44:03 +03:00
parent af2c6a3e08
commit c2aef456a5
7 changed files with 32 additions and 19 deletions

View File

@ -1,4 +1,4 @@
#![allow(dead_code, unused_variables, missing_docs)]
#![allow(missing_docs)]
#[derive(Debug, Clone, PartialEq)]
pub enum Error {
@ -50,3 +50,7 @@ mod variable;
#[cfg(test)]
mod tests;
pub use self::module::ModuleInstance;
pub use self::program::ProgramInstance;
pub use self::value::RuntimeValue;

View File

@ -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.
pub fn module(&self) -> &Module {
&self.module
@ -206,7 +211,7 @@ impl ModuleInstance {
}
/// 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
match self.imports.parse_table_index(table_index) {
ItemIndex::IndexSpace(_) => unreachable!("parse_function_index resolves IndexSpace option"),

View File

@ -27,13 +27,14 @@ impl ProgramInstance {
}
/// 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();
match modules.entry(name.into()) {
Entry::Occupied(_) => Err(Error::Program(format!("module {} already instantiated", name))),
Entry::Vacant(entry) => {
entry.insert(Arc::new(ModuleInstance::new(Arc::downgrade(&self.essence), module)?));
Ok(())
let module_instance = Arc::new(ModuleInstance::new(Arc::downgrade(&self.essence), module)?);
entry.insert(module_instance.clone());
Ok(module_instance)
},
}
}

View File

@ -82,7 +82,7 @@ impl Interpreter {
&Opcode::Return => Interpreter::run_return(context),
&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::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()))
}
fn run_nop(context: &mut FunctionContext) -> Result<InstructionOutcome, Error> {
fn run_nop(_context: &mut FunctionContext) -> Result<InstructionOutcome, Error> {
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)
}
fn run_end(context: &mut FunctionContext) -> Result<InstructionOutcome, Error> {
fn run_end(_context: &mut FunctionContext) -> Result<InstructionOutcome, Error> {
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))
}
@ -324,7 +324,7 @@ impl Interpreter {
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)
}
@ -781,9 +781,9 @@ impl Interpreter {
.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> {
Err(Error::NotImplemented)
Err(Error::NotImplemented) // TODO
}
fn run_wrap<T, U>(context: &mut FunctionContext) -> Result<InstructionOutcome, Error>

View File

@ -12,8 +12,6 @@ pub struct TableInstance {
variable_type: VariableType,
/// Table memory buffer.
buffer: RwLock<Vec<VariableInstance>>,
/// Maximum buffer size.
maximum_size: u32,
}
impl TableInstance {
@ -23,7 +21,6 @@ impl TableInstance {
buffer: RwLock::new(
vec![VariableInstance::new(true, variable_type, RuntimeValue::Null)?; table_type.limits().initial() as usize]
),
maximum_size: table_type.limits().maximum().unwrap_or(u32::MAX),
}))
}

View File

@ -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!()
}
pub fn from_little_endian_bytes<T>(buffer: &[u8]) -> T {
pub fn from_little_endian_bytes<T>(_buffer: &[u8]) -> T {
unimplemented!()
}

View File

@ -16,3 +16,9 @@ pub use elements::{
serialize,
serialize_to_file,
};
pub use interpreter::{
ProgramInstance,
ModuleInstance,
RuntimeValue,
};