From 6e9d2eb8d2e7909a108ed9393280d660150f64a8 Mon Sep 17 00:00:00 2001 From: NikVolf Date: Tue, 9 Apr 2019 19:10:00 +0300 Subject: [PATCH] edition to 2018 --- Cargo.toml | 1 + src/common/stack.rs | 2 +- src/func.rs | 18 +++++++++--------- src/global.rs | 8 ++++---- src/host.rs | 6 +++--- src/imports.rs | 16 ++++++++-------- src/isa.rs | 2 +- src/lib.rs | 8 ++++---- src/memory.rs | 16 ++++++++-------- src/module.rs | 34 +++++++++++++++++----------------- src/runner.rs | 22 +++++++++++----------- src/table.rs | 10 +++++----- src/tests/host.rs | 6 +++--- src/tests/mod.rs | 2 +- src/tests/wasm.rs | 4 ++-- src/types.rs | 2 +- src/validation/context.rs | 4 ++-- src/validation/func.rs | 14 +++++++------- src/validation/mod.rs | 10 +++++----- src/validation/tests.rs | 6 +++--- src/validation/util.rs | 4 ++-- src/value.rs | 6 +++--- 22 files changed, 101 insertions(+), 100 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index bb06203..cc69a16 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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"] diff --git a/src/common/stack.rs b/src/common/stack.rs index 9e96a63..85afa62 100644 --- a/src/common/stack.rs +++ b/src/common/stack.rs @@ -1,5 +1,5 @@ #[allow(unused_imports)] -use alloc::prelude::*; +use crate::alloc::prelude::*; use core::fmt; #[cfg(feature = "std")] diff --git a/src/func.rs b/src/func.rs index bc650dd..feef452 100644 --- a/src/func.rs +++ b/src/func.rs @@ -1,15 +1,15 @@ #[allow(unused_imports)] -use alloc::prelude::*; -use alloc::rc::{Rc, Weak}; +use crate::alloc::prelude::*; +use crate::alloc::rc::{Rc, Weak}; use core::fmt; -use host::Externals; -use isa; -use module::ModuleInstance; +use crate::host::Externals; +use crate::isa; +use crate::module::ModuleInstance; use parity_wasm::elements::Local; -use runner::{check_function_args, Interpreter, InterpreterState}; -use types::ValueType; -use value::RuntimeValue; -use {Signature, Trap}; +use crate::runner::{check_function_args, Interpreter, InterpreterState}; +use crate::types::ValueType; +use crate::value::RuntimeValue; +use crate::{Signature, Trap}; /// Reference to a function (See [`FuncInstance`] for details). /// diff --git a/src/global.rs b/src/global.rs index cde0d63..6330615 100644 --- a/src/global.rs +++ b/src/global.rs @@ -1,9 +1,9 @@ -use alloc::rc::Rc; +use crate::alloc::rc::Rc; use core::cell::Cell; use parity_wasm::elements::ValueType as EValueType; -use types::ValueType; -use value::RuntimeValue; -use Error; +use crate::types::ValueType; +use crate::value::RuntimeValue; +use crate::Error; /// Reference to a global variable (See [`GlobalInstance`] for details). /// diff --git a/src/host.rs b/src/host.rs index 3700fc7..122492f 100644 --- a/src/host.rs +++ b/src/host.rs @@ -1,6 +1,6 @@ use core::any::TypeId; -use value::{FromRuntimeValue, RuntimeValue}; -use {Trap, TrapKind}; +use crate::value::{FromRuntimeValue, RuntimeValue}; +use crate::{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() { diff --git a/src/imports.rs b/src/imports.rs index 44866a7..4757ab7 100644 --- a/src/imports.rs +++ b/src/imports.rs @@ -1,18 +1,18 @@ #[allow(unused_imports)] -use alloc::prelude::*; +use crate::alloc::prelude::*; #[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. /// diff --git a/src/isa.rs b/src/isa.rs index 0325f4e..a73dc19 100644 --- a/src/isa.rs +++ b/src/isa.rs @@ -68,7 +68,7 @@ //! #[allow(unused_imports)] -use alloc::prelude::*; +use crate::alloc::prelude::*; /// Should we keep a value before "discarding" a stack frame? /// diff --git a/src/lib.rs b/src/lib.rs index e2fb2f7..6cbc3e0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -121,7 +121,7 @@ extern crate memory_units as memory_units_crate; extern crate parity_wasm; #[allow(unused_imports)] -use alloc::prelude::*; +use crate::alloc::prelude::*; use core::fmt; #[cfg(feature = "std")] use std::error; @@ -410,8 +410,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 +454,7 @@ impl Module { /// } /// ``` pub fn from_parity_wasm_module(module: parity_wasm::elements::Module) -> Result { - use validation::{validate_module, ValidatedModule}; + use crate::validation::{validate_module, ValidatedModule}; let ValidatedModule { code_map, module } = validate_module(module)?; Ok(Module { code_map, module }) diff --git a/src/memory.rs b/src/memory.rs index 62e51b6..73a47b9 100644 --- a/src/memory.rs +++ b/src/memory.rs @@ -1,15 +1,15 @@ #[allow(unused_imports)] -use alloc::prelude::*; -use alloc::rc::Rc; +use crate::alloc::prelude::*; +use crate::alloc::rc::Rc; 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 crate::memory_units::{Bytes, Pages, RoundUpTo}; use parity_wasm::elements::ResizableLimits; -use value::LittleEndianConvert; -use Error; +use crate::value::LittleEndianConvert; +use crate::Error; /// Size of a page of [linear memory][`MemoryInstance`] - 64KiB. /// @@ -578,9 +578,9 @@ pub fn validate_memory(initial: Pages, maximum: Option) -> Result<(), Str mod tests { use super::{MemoryInstance, MemoryRef, LINEAR_MEMORY_PAGE_SIZE}; - use memory_units::Pages; + use crate::memory_units::Pages; use std::rc::Rc; - use Error; + use crate::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()); } diff --git a/src/module.rs b/src/module.rs index 8222e42..d5afcc1 100644 --- a/src/module.rs +++ b/src/module.rs @@ -1,27 +1,27 @@ #[allow(unused_imports)] -use alloc::prelude::*; -use alloc::rc::Rc; +use crate::alloc::prelude::*; +use crate::alloc::rc::Rc; use core::cell::RefCell; use core::fmt; -use Trap; +use crate::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 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 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 parity_wasm::elements::{External, InitExpr, Instruction, Internal, ResizableLimits, Type}; -use table::TableRef; -use types::{GlobalDescriptor, MemoryDescriptor, TableDescriptor}; -use {Error, MemoryInstance, Module, RuntimeValue, Signature, TableInstance}; +use crate::table::TableRef; +use crate::types::{GlobalDescriptor, MemoryDescriptor, TableDescriptor}; +use crate::{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] diff --git a/src/runner.rs b/src/runner.rs index ed7bfc7..9800199 100644 --- a/src/runner.rs +++ b/src/runner.rs @@ -1,22 +1,22 @@ #[allow(unused_imports)] -use alloc::prelude::*; -use common::{DEFAULT_MEMORY_INDEX, DEFAULT_TABLE_INDEX}; +use crate::alloc::prelude::*; +use crate::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 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 parity_wasm::elements::Local; -use value::{ +use crate::value::{ ArithmeticOps, ExtendInto, Float, Integer, LittleEndianConvert, RuntimeValue, TransmuteInto, TryTruncateInto, WrapInto, }; -use {Signature, Trap, TrapKind, ValueType}; +use crate::{Signature, Trap, TrapKind, ValueType}; /// Maximum number of entries in value stack. pub const DEFAULT_VALUE_STACK_LIMIT: usize = (1024 * 1024) / ::core::mem::size_of::(); diff --git a/src/table.rs b/src/table.rs index 7d8d744..0005469 100644 --- a/src/table.rs +++ b/src/table.rs @@ -1,13 +1,13 @@ #[allow(unused_imports)] -use alloc::prelude::*; -use alloc::rc::Rc; +use crate::alloc::prelude::*; +use crate::alloc::rc::Rc; use core::cell::RefCell; use core::fmt; use core::u32; -use func::FuncRef; -use module::check_limits; +use crate::func::FuncRef; +use crate::module::check_limits; use parity_wasm::elements::ResizableLimits; -use Error; +use crate::Error; /// Reference to a table (See [`TableInstance`] for details). /// diff --git a/src/tests/host.rs b/src/tests/host.rs index 99b7416..f1317c4 100644 --- a/src/tests/host.rs +++ b/src/tests/host.rs @@ -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, diff --git a/src/tests/mod.rs b/src/tests/mod.rs index a60ce73..7515de8 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -1,5 +1,5 @@ use wabt; -use Module; +use crate::Module; mod host; mod wasm; diff --git a/src/tests/wasm.rs b/src/tests/wasm.rs index 07efa51..c484546 100644 --- a/src/tests/wasm.rs +++ b/src/tests/wasm.rs @@ -1,6 +1,6 @@ -use memory_units::Pages; +use crate::memory_units::Pages; use std::fs::File; -use { +use crate::{ Error, FuncRef, GlobalDescriptor, GlobalInstance, GlobalRef, ImportsBuilder, MemoryDescriptor, MemoryInstance, MemoryRef, Module, ModuleImportResolver, ModuleInstance, NopExternals, RuntimeValue, Signature, TableDescriptor, TableInstance, TableRef, diff --git a/src/types.rs b/src/types.rs index f0b5c84..62ea8c1 100644 --- a/src/types.rs +++ b/src/types.rs @@ -1,4 +1,4 @@ -use alloc::borrow::Cow; +use crate::alloc::borrow::Cow; use parity_wasm::elements::{ FunctionType, GlobalType, MemoryType, TableType, ValueType as EValueType, diff --git a/src/validation/context.rs b/src/validation/context.rs index 62ccf6f..f928f01 100644 --- a/src/validation/context.rs +++ b/src/validation/context.rs @@ -1,9 +1,9 @@ #[allow(unused_imports)] -use alloc::prelude::*; +use crate::alloc::prelude::*; use parity_wasm::elements::{ BlockType, FunctionType, GlobalType, MemoryType, TableType, ValueType, }; -use validation::Error; +use crate::validation::Error; #[derive(Default, Debug)] pub struct ModuleContext { diff --git a/src/validation/func.rs b/src/validation/func.rs index 78dfd5e..4150325 100644 --- a/src/validation/func.rs +++ b/src/validation/func.rs @@ -1,15 +1,15 @@ #[allow(unused_imports)] -use alloc::prelude::*; -use common::{DEFAULT_MEMORY_INDEX, DEFAULT_TABLE_INDEX}; +use crate::alloc::prelude::*; +use crate::common::{DEFAULT_MEMORY_INDEX, DEFAULT_TABLE_INDEX}; use core::u32; use parity_wasm::elements::{BlockType, Func, FuncBody, Instruction, TableElementType, ValueType}; -use validation::context::ModuleContext; +use crate::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; diff --git a/src/validation/mod.rs b/src/validation/mod.rs index 01b583a..f96f154 100644 --- a/src/validation/mod.rs +++ b/src/validation/mod.rs @@ -1,5 +1,5 @@ #[allow(unused_imports)] -use alloc::prelude::*; +use crate::alloc::prelude::*; 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, @@ -400,7 +400,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 = 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> { diff --git a/src/validation/tests.rs b/src/validation/tests.rs index 49cee36..3adcfda 100644 --- a/src/validation/tests.rs +++ b/src/validation/tests.rs @@ -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, Vec) { 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::>()[..] ) }; diff --git a/src/validation/util.rs b/src/validation/util.rs index 6a42de4..06f5b2a 100644 --- a/src/validation/util.rs +++ b/src/validation/util.rs @@ -1,7 +1,7 @@ #[allow(unused_imports)] -use alloc::prelude::*; +use crate::alloc::prelude::*; use parity_wasm::elements::{Local, ValueType}; -use validation::Error; +use crate::validation::Error; /// Locals are the concatenation of a slice of function parameters /// with function declared local variables. diff --git a/src/value.rs b/src/value.rs index 9891923..8ec900c 100644 --- a/src/value.rs +++ b/src/value.rs @@ -1,7 +1,7 @@ use core::{f32, i32, i64, u32, u64}; -use nan_preserving_float::{F32, F64}; -use types::ValueType; -use TrapKind; +use crate::nan_preserving_float::{F32, F64}; +use crate::types::ValueType; +use crate::TrapKind; /// Error for `LittleEndianConvert` #[derive(Debug)]