Compare commits

...

3 Commits

Author SHA1 Message Date
NikVolf e5bde5b0d7 update fmt 2019-04-09 20:19:48 +03:00
NikVolf a51413563e fix nightly and warnings 2019-04-09 19:24:45 +03:00
NikVolf 6e9d2eb8d2 edition to 2018 2019-04-09 19:10:00 +03:00
22 changed files with 107 additions and 107 deletions

View File

@ -9,6 +9,7 @@ documentation = "https://paritytech.github.io/wasmi/"
description = "WebAssembly interpreter"
keywords = ["wasm", "webassembly", "bytecode", "interpreter"]
exclude = [ "/res/*", "/tests/*", "/fuzz/*", "/benches/*" ]
edition = "2018"
[features]
default = ["std"]

View File

@ -1,5 +1,5 @@
#[allow(unused_imports)]
use alloc::prelude::*;
use crate::alloc::prelude::v1::*;
use core::fmt;
#[cfg(feature = "std")]

View File

@ -1,15 +1,15 @@
#[allow(unused_imports)]
use alloc::prelude::*;
use alloc::rc::{Rc, Weak};
use crate::alloc::prelude::v1::*;
use crate::alloc::rc::{Rc, Weak};
use crate::host::Externals;
use crate::isa;
use crate::module::ModuleInstance;
use crate::runner::{check_function_args, Interpreter, InterpreterState};
use crate::types::ValueType;
use crate::value::RuntimeValue;
use crate::{Signature, Trap};
use core::fmt;
use host::Externals;
use isa;
use module::ModuleInstance;
use parity_wasm::elements::Local;
use runner::{check_function_args, Interpreter, InterpreterState};
use types::ValueType;
use value::RuntimeValue;
use {Signature, Trap};
/// Reference to a function (See [`FuncInstance`] for details).
///

View File

@ -1,9 +1,9 @@
use alloc::rc::Rc;
use crate::alloc::rc::Rc;
use crate::types::ValueType;
use crate::value::RuntimeValue;
use crate::Error;
use core::cell::Cell;
use parity_wasm::elements::ValueType as EValueType;
use types::ValueType;
use value::RuntimeValue;
use Error;
/// Reference to a global variable (See [`GlobalInstance`] for details).
///

View File

@ -1,6 +1,6 @@
use crate::value::{FromRuntimeValue, RuntimeValue};
use crate::{Trap, TrapKind};
use core::any::TypeId;
use value::{FromRuntimeValue, RuntimeValue};
use {Trap, TrapKind};
/// Wrapper around slice of [`RuntimeValue`] for using it
/// as an argument list conveniently.
@ -241,7 +241,7 @@ impl Externals for NopExternals {
mod tests {
use super::{HostError, RuntimeArgs};
use value::RuntimeValue;
use crate::value::RuntimeValue;
#[test]
fn i32_runtime_args() {

View File

@ -1,18 +1,18 @@
#[allow(unused_imports)]
use alloc::prelude::*;
use crate::alloc::prelude::v1::*;
#[cfg(not(feature = "std"))]
use hashbrown::HashMap;
#[cfg(feature = "std")]
use std::collections::HashMap;
use func::FuncRef;
use global::GlobalRef;
use memory::MemoryRef;
use module::ModuleRef;
use table::TableRef;
use types::{GlobalDescriptor, MemoryDescriptor, TableDescriptor};
use {Error, Signature};
use crate::func::FuncRef;
use crate::global::GlobalRef;
use crate::memory::MemoryRef;
use crate::module::ModuleRef;
use crate::table::TableRef;
use crate::types::{GlobalDescriptor, MemoryDescriptor, TableDescriptor};
use crate::{Error, Signature};
/// Resolver of a module's dependencies.
///

View File

@ -68,7 +68,7 @@
//!
#[allow(unused_imports)]
use alloc::prelude::*;
use crate::alloc::prelude::v1::*;
/// Should we keep a value before "discarding" a stack frame?
///

View File

@ -98,6 +98,7 @@
#![cfg_attr(not(feature = "std"), no_std)]
//// alloc is required in no_std
#![cfg_attr(not(feature = "std"), feature(alloc))]
#![cfg_attr(not(feature = "std"), feature(alloc_prelude))]
#[cfg(not(feature = "std"))]
#[macro_use]
@ -121,7 +122,7 @@ extern crate memory_units as memory_units_crate;
extern crate parity_wasm;
#[allow(unused_imports)]
use alloc::prelude::*;
use crate::alloc::prelude::v1::*;
use core::fmt;
#[cfg(feature = "std")]
use std::error;
@ -410,8 +411,8 @@ pub use self::value::{Error as ValueError, FromRuntimeValue, LittleEndianConvert
/// WebAssembly-specific sizes and units.
pub mod memory_units {
pub use memory_units_crate::wasm32::*;
pub use memory_units_crate::{size_of, ByteSize, Bytes, RoundUpTo};
pub use crate::memory_units_crate::wasm32::*;
pub use crate::memory_units_crate::{size_of, ByteSize, Bytes, RoundUpTo};
}
/// Deserialized module prepared for instantiation.
@ -454,7 +455,7 @@ impl Module {
/// }
/// ```
pub fn from_parity_wasm_module(module: parity_wasm::elements::Module) -> Result<Module, Error> {
use validation::{validate_module, ValidatedModule};
use crate::validation::{validate_module, ValidatedModule};
let ValidatedModule { code_map, module } = validate_module(module)?;
Ok(Module { code_map, module })

View File

@ -1,15 +1,15 @@
#[allow(unused_imports)]
use alloc::prelude::*;
use alloc::rc::Rc;
use crate::alloc::prelude::v1::*;
use crate::alloc::rc::Rc;
use crate::memory_units::{Bytes, Pages, RoundUpTo};
use crate::value::LittleEndianConvert;
use crate::Error;
use core::cell::{Cell, RefCell};
use core::cmp;
use core::fmt;
use core::ops::Range;
use core::u32;
use memory_units::{Bytes, Pages, RoundUpTo};
use parity_wasm::elements::ResizableLimits;
use value::LittleEndianConvert;
use Error;
/// Size of a page of [linear memory][`MemoryInstance`] - 64KiB.
///
@ -578,9 +578,9 @@ pub fn validate_memory(initial: Pages, maximum: Option<Pages>) -> Result<(), Str
mod tests {
use super::{MemoryInstance, MemoryRef, LINEAR_MEMORY_PAGE_SIZE};
use memory_units::Pages;
use crate::memory_units::Pages;
use crate::Error;
use std::rc::Rc;
use Error;
#[test]
fn alloc() {
@ -623,7 +623,7 @@ mod tests {
#[test]
fn ensure_page_size() {
use memory_units::ByteSize;
use crate::memory_units::ByteSize;
assert_eq!(LINEAR_MEMORY_PAGE_SIZE, Pages::byte_size());
}

View File

@ -1,27 +1,27 @@
#[allow(unused_imports)]
use alloc::prelude::*;
use alloc::rc::Rc;
use crate::alloc::prelude::v1::*;
use crate::alloc::rc::Rc;
use crate::Trap;
use core::cell::RefCell;
use core::fmt;
use Trap;
#[cfg(not(feature = "std"))]
use hashbrown::HashMap;
#[cfg(feature = "std")]
use std::collections::HashMap;
use common::{DEFAULT_MEMORY_INDEX, DEFAULT_TABLE_INDEX};
use crate::common::{DEFAULT_MEMORY_INDEX, DEFAULT_TABLE_INDEX};
use crate::func::{FuncBody, FuncInstance, FuncRef};
use crate::global::{GlobalInstance, GlobalRef};
use crate::host::Externals;
use crate::imports::ImportResolver;
use crate::memory::MemoryRef;
use crate::memory_units::Pages;
use crate::table::TableRef;
use crate::types::{GlobalDescriptor, MemoryDescriptor, TableDescriptor};
use crate::{Error, MemoryInstance, Module, RuntimeValue, Signature, TableInstance};
use core::cell::Ref;
use func::{FuncBody, FuncInstance, FuncRef};
use global::{GlobalInstance, GlobalRef};
use host::Externals;
use imports::ImportResolver;
use memory::MemoryRef;
use memory_units::Pages;
use parity_wasm::elements::{External, InitExpr, Instruction, Internal, ResizableLimits, Type};
use table::TableRef;
use types::{GlobalDescriptor, MemoryDescriptor, TableDescriptor};
use {Error, MemoryInstance, Module, RuntimeValue, Signature, TableInstance};
/// Reference to a [`ModuleInstance`].
///
@ -785,10 +785,10 @@ pub fn check_limits(limits: &ResizableLimits) -> Result<(), Error> {
#[cfg(test)]
mod tests {
use super::{ExternVal, ModuleInstance};
use func::FuncInstance;
use imports::ImportsBuilder;
use tests::parse_wat;
use types::{Signature, ValueType};
use crate::func::FuncInstance;
use crate::imports::ImportsBuilder;
use crate::tests::parse_wat;
use crate::types::{Signature, ValueType};
#[should_panic]
#[test]

View File

@ -1,22 +1,22 @@
#[allow(unused_imports)]
use alloc::prelude::*;
use common::{DEFAULT_MEMORY_INDEX, DEFAULT_TABLE_INDEX};
use core::fmt;
use core::ops;
use core::{u32, usize};
use func::{FuncInstance, FuncInstanceInternal, FuncRef};
use host::Externals;
use isa;
use memory::MemoryRef;
use memory_units::Pages;
use module::ModuleRef;
use nan_preserving_float::{F32, F64};
use parity_wasm::elements::Local;
use value::{
use crate::alloc::prelude::v1::*;
use crate::common::{DEFAULT_MEMORY_INDEX, DEFAULT_TABLE_INDEX};
use crate::func::{FuncInstance, FuncInstanceInternal, FuncRef};
use crate::host::Externals;
use crate::isa;
use crate::memory::MemoryRef;
use crate::memory_units::Pages;
use crate::module::ModuleRef;
use crate::nan_preserving_float::{F32, F64};
use crate::value::{
ArithmeticOps, ExtendInto, Float, Integer, LittleEndianConvert, RuntimeValue, TransmuteInto,
TryTruncateInto, WrapInto,
};
use {Signature, Trap, TrapKind, ValueType};
use crate::{Signature, Trap, TrapKind, ValueType};
use core::fmt;
use core::ops;
use core::{u32, usize};
use parity_wasm::elements::Local;
/// Maximum number of entries in value stack.
pub const DEFAULT_VALUE_STACK_LIMIT: usize = (1024 * 1024) / ::core::mem::size_of::<RuntimeValue>();

View File

@ -1,13 +1,13 @@
#[allow(unused_imports)]
use alloc::prelude::*;
use alloc::rc::Rc;
use crate::alloc::prelude::v1::*;
use crate::alloc::rc::Rc;
use crate::func::FuncRef;
use crate::module::check_limits;
use crate::Error;
use core::cell::RefCell;
use core::fmt;
use core::u32;
use func::FuncRef;
use module::check_limits;
use parity_wasm::elements::ResizableLimits;
use Error;
/// Reference to a table (See [`TableInstance`] for details).
///

View File

@ -1,7 +1,7 @@
use super::parse_wat;
use memory_units::Pages;
use types::ValueType;
use {
use crate::memory_units::Pages;
use crate::types::ValueType;
use crate::{
Error, Externals, FuncInstance, FuncRef, HostError, ImportsBuilder, MemoryDescriptor,
MemoryInstance, MemoryRef, ModuleImportResolver, ModuleInstance, ModuleRef, ResumableError,
RuntimeArgs, RuntimeValue, Signature, TableDescriptor, TableInstance, TableRef, Trap, TrapKind,

View File

@ -1,5 +1,5 @@
use crate::Module;
use wabt;
use Module;
mod host;
mod wasm;

View File

@ -1,10 +1,10 @@
use memory_units::Pages;
use std::fs::File;
use {
use crate::memory_units::Pages;
use crate::{
Error, FuncRef, GlobalDescriptor, GlobalInstance, GlobalRef, ImportsBuilder, MemoryDescriptor,
MemoryInstance, MemoryRef, Module, ModuleImportResolver, ModuleInstance, NopExternals,
RuntimeValue, Signature, TableDescriptor, TableInstance, TableRef,
};
use std::fs::File;
struct Env {
table_base: GlobalRef,

View File

@ -1,4 +1,4 @@
use alloc::borrow::Cow;
use crate::alloc::borrow::Cow;
use parity_wasm::elements::{
FunctionType, GlobalType, MemoryType, TableType, ValueType as EValueType,

View File

@ -1,9 +1,9 @@
#[allow(unused_imports)]
use alloc::prelude::*;
use crate::alloc::prelude::v1::*;
use crate::validation::Error;
use parity_wasm::elements::{
BlockType, FunctionType, GlobalType, MemoryType, TableType, ValueType,
};
use validation::Error;
#[derive(Default, Debug)]
pub struct ModuleContext {

View File

@ -1,15 +1,15 @@
#[allow(unused_imports)]
use alloc::prelude::*;
use common::{DEFAULT_MEMORY_INDEX, DEFAULT_TABLE_INDEX};
use crate::alloc::prelude::v1::*;
use crate::common::{DEFAULT_MEMORY_INDEX, DEFAULT_TABLE_INDEX};
use crate::validation::context::ModuleContext;
use core::u32;
use parity_wasm::elements::{BlockType, Func, FuncBody, Instruction, TableElementType, ValueType};
use validation::context::ModuleContext;
use validation::util::Locals;
use validation::Error;
use crate::validation::util::Locals;
use crate::validation::Error;
use common::stack::StackWithLimit;
use isa;
use crate::common::stack::StackWithLimit;
use crate::isa;
/// Maximum number of entries in value stack per function.
const DEFAULT_VALUE_STACK_LIMIT: usize = 16384;

View File

@ -1,5 +1,5 @@
#[allow(unused_imports)]
use alloc::prelude::*;
use crate::alloc::prelude::v1::*;
use core::fmt;
#[cfg(feature = "std")]
use std::error;
@ -11,9 +11,9 @@ use std::collections::HashSet;
use self::context::ModuleContextBuilder;
use self::func::FunctionReader;
use common::stack;
use isa;
use memory_units::Pages;
use crate::common::stack;
use crate::isa;
use crate::memory_units::Pages;
use parity_wasm::elements::{
BlockType, External, GlobalEntry, GlobalType, InitExpr, Instruction, Internal, MemoryType,
Module, ResizableLimits, TableType, Type, ValueType,
@ -150,8 +150,6 @@ pub fn deny_floating_point(module: &Module) -> Result<(), Error> {
}
if let (Some(sec), Some(types)) = (module.function_section(), module.type_section()) {
use parity_wasm::elements::{Type, ValueType};
let types = types.types();
for sig in sec.entries() {
@ -400,7 +398,7 @@ fn validate_limits(limits: &ResizableLimits) -> Result<(), Error> {
fn validate_memory_type(memory_type: &MemoryType) -> Result<(), Error> {
let initial: Pages = Pages(memory_type.limits().initial() as usize);
let maximum: Option<Pages> = memory_type.limits().maximum().map(|m| Pages(m as usize));
::memory::validate_memory(initial, maximum).map_err(Error)
crate::memory::validate_memory(initial, maximum).map_err(Error)
}
fn validate_table_type(table_type: &TableType) -> Result<(), Error> {

View File

@ -1,5 +1,5 @@
use super::{validate_module, ValidatedModule};
use isa;
use crate::isa;
use parity_wasm::builder::module;
use parity_wasm::elements::{
deserialize_buffer, BlockType, External, GlobalEntry, GlobalType, ImportEntry, InitExpr,
@ -299,10 +299,10 @@ fn compile(module: &ValidatedModule) -> (Vec<isa::Instruction>, Vec<u32>) {
macro_rules! targets {
($($target:expr),*) => {
::isa::BrTargets::from_internal(
crate::isa::BrTargets::from_internal(
&[$($target,)*]
.iter()
.map(|&target| ::isa::InstructionInternal::BrTableTarget(target))
.map(|&target| crate::isa::InstructionInternal::BrTableTarget(target))
.collect::<Vec<_>>()[..]
)
};

View File

@ -1,7 +1,7 @@
#[allow(unused_imports)]
use alloc::prelude::*;
use crate::alloc::prelude::v1::*;
use crate::validation::Error;
use parity_wasm::elements::{Local, ValueType};
use validation::Error;
/// Locals are the concatenation of a slice of function parameters
/// with function declared local variables.

View File

@ -1,7 +1,7 @@
use crate::nan_preserving_float::{F32, F64};
use crate::types::ValueType;
use crate::TrapKind;
use core::{f32, i32, i64, u32, u64};
use nan_preserving_float::{F32, F64};
use types::ValueType;
use TrapKind;
/// Error for `LittleEndianConvert`
#[derive(Debug)]