mirror of
https://github.com/pezkuwichain/wasm-instrument.git
synced 2026-05-31 04:41:05 +00:00
Merge pull request #144 from paritytech/at-unify-packet
Merge pwasm-utils-cli into the main package
This commit is contained in:
@@ -3,3 +3,4 @@ target
|
|||||||
.cargo
|
.cargo
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.idea
|
.idea
|
||||||
|
.vscode
|
||||||
|
|||||||
+2
-3
@@ -4,6 +4,5 @@ rust:
|
|||||||
- stable
|
- stable
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- cargo build --all --release --verbose
|
- cargo test --all-features --verbose
|
||||||
- cargo test --all --verbose
|
- cargo build --no-default-features --verbose
|
||||||
- cargo build --no-default-features
|
|
||||||
|
|||||||
+48
-4
@@ -1,6 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "pwasm-utils"
|
name = "pwasm-utils"
|
||||||
version = "0.15.0"
|
version = "0.15.0"
|
||||||
|
edition = "2018"
|
||||||
authors = ["Nikolay Volf <nikvolf@gmail.com>", "Sergey Pepyakin <s.pepyakin@gmail.com>"]
|
authors = ["Nikolay Volf <nikvolf@gmail.com>", "Sergey Pepyakin <s.pepyakin@gmail.com>"]
|
||||||
license = "MIT/Apache-2.0"
|
license = "MIT/Apache-2.0"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
@@ -8,6 +9,41 @@ description = "Collection of command-line utilities and corresponding Rust api f
|
|||||||
keywords = ["wasm", "webassembly", "pwasm"]
|
keywords = ["wasm", "webassembly", "pwasm"]
|
||||||
repository = "https://github.com/paritytech/wasm-utils"
|
repository = "https://github.com/paritytech/wasm-utils"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "wasm-prune"
|
||||||
|
path = "cli/prune/main.rs"
|
||||||
|
required-features = ["cli"]
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "wasm-ext"
|
||||||
|
path = "cli/ext/main.rs"
|
||||||
|
required-features = ["cli"]
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "wasm-gas"
|
||||||
|
path = "cli/gas/main.rs"
|
||||||
|
required-features = ["cli"]
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "wasm-build"
|
||||||
|
path = "cli/build/main.rs"
|
||||||
|
required-features = ["cli"]
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "wasm-stack-height"
|
||||||
|
path = "cli/stack_height/main.rs"
|
||||||
|
required-features = ["cli"]
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "wasm-pack"
|
||||||
|
path = "cli/pack/main.rs"
|
||||||
|
required-features = ["cli"]
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "wasm-check"
|
||||||
|
path = "cli/check/main.rs"
|
||||||
|
required-features = ["cli"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# If you add the feature "bulk", make sure you fixed all expects that say
|
# If you add the feature "bulk", make sure you fixed all expects that say
|
||||||
# "parity-wasm is compiled without bulk-memory operations"
|
# "parity-wasm is compiled without bulk-memory operations"
|
||||||
@@ -15,6 +51,12 @@ parity-wasm = { version = "0.41.0", default-features = false }
|
|||||||
log = { version = "0.4", default-features = false }
|
log = { version = "0.4", default-features = false }
|
||||||
byteorder = { version = "1", default-features = false }
|
byteorder = { version = "1", default-features = false }
|
||||||
|
|
||||||
|
# Dependencies only used by the binaries
|
||||||
|
glob = { version = "0.2", optional = true }
|
||||||
|
clap = { version = "2.24", optional = true }
|
||||||
|
env_logger = { version = "0.5", optional = true }
|
||||||
|
lazy_static = { version = "1.0", optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tempdir = "0.3"
|
tempdir = "0.3"
|
||||||
wabt = "0.10"
|
wabt = "0.10"
|
||||||
@@ -26,8 +68,10 @@ binaryen = "0.8"
|
|||||||
[features]
|
[features]
|
||||||
default = ["std"]
|
default = ["std"]
|
||||||
std = ["parity-wasm/std", "log/std", "byteorder/std"]
|
std = ["parity-wasm/std", "log/std", "byteorder/std"]
|
||||||
|
cli = [
|
||||||
[workspace]
|
"std",
|
||||||
members = [
|
"glob",
|
||||||
"./cli",
|
"clap",
|
||||||
|
"env_logger",
|
||||||
|
"lazy_static",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,21 +1,29 @@
|
|||||||
# wasm-utils
|
# pwasm-utils
|
||||||
|
|
||||||
[](https://travis-ci.org/paritytech/wasm-utils)
|
[](https://travis-ci.org/paritytech/wasm-utils)
|
||||||
|
|
||||||
Collection of WASM utilities used in pwasm-ethereum and substrate contract development
|
A collection of WASM utilities used in pwasm-ethereum and substrate contract development.
|
||||||
|
|
||||||
## Build tools for cargo
|
This repository contains the package `pwasm-utils` which consists of a library crate
|
||||||
|
and a collection of cli binaries that make use of this library.
|
||||||
Easiest way to use is to install via `cargo install`:
|
|
||||||
|
|
||||||
|
## Installation of cli tools
|
||||||
```
|
```
|
||||||
cargo install pwasm-utils-cli --bin wasm-build
|
cargo install pwasm-utils --features cli
|
||||||
```
|
```
|
||||||
|
|
||||||
|
This will install the following binaries:
|
||||||
|
* wasm-build
|
||||||
|
* wasm-check
|
||||||
|
* wasm-ext
|
||||||
|
* wasm-gas
|
||||||
|
* wasm-pack
|
||||||
|
* wasm-prune
|
||||||
|
* wasm-stack-height
|
||||||
|
|
||||||
## Symbols pruning (wasm-prune)
|
## Symbols pruning (wasm-prune)
|
||||||
|
|
||||||
```
|
```
|
||||||
cargo install pwasm-utils-cli --bin wasm-prune
|
|
||||||
wasm-prune <input_wasm_binary.wasm> <output_wasm_binary.wasm>
|
wasm-prune <input_wasm_binary.wasm> <output_wasm_binary.wasm>
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -26,14 +34,9 @@ This will optimize WASM symbols tree to leave only those elements that are used
|
|||||||
For development puposes, raw WASM contract can be injected with gas counters (the same way as it done by pwasm-ethereum/substrate runtime when running contracts)
|
For development puposes, raw WASM contract can be injected with gas counters (the same way as it done by pwasm-ethereum/substrate runtime when running contracts)
|
||||||
|
|
||||||
```
|
```
|
||||||
cargo install pwasm-utils-cli --bin wasm-gas
|
|
||||||
wasm-gas <input_wasm_binary.wasm> <output_wasm_binary.wasm>
|
wasm-gas <input_wasm_binary.wasm> <output_wasm_binary.wasm>
|
||||||
```
|
```
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
All executables use corresponding api methods of the root crate and can be combined in other build tools.
|
|
||||||
|
|
||||||
# License
|
# License
|
||||||
|
|
||||||
`wasm-utils` is primarily distributed under the terms of both the MIT
|
`wasm-utils` is primarily distributed under the terms of both the MIT
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "pwasm-utils-cli"
|
|
||||||
version = "0.15.0"
|
|
||||||
authors = ["Nikolay Volf <nikvolf@gmail.com>", "Sergey Pepyakin <s.pepyakin@gmail.com>"]
|
|
||||||
license = "MIT/Apache-2.0"
|
|
||||||
readme = "README.md"
|
|
||||||
description = "Collection of command-line utilities and corresponding Rust api for producing pwasm-compatible executables"
|
|
||||||
keywords = ["wasm", "webassembly", "pwasm"]
|
|
||||||
repository = "https://github.com/paritytech/wasm-utils"
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
|
|
||||||
[[bin]]
|
|
||||||
name = "wasm-prune"
|
|
||||||
path = "prune/main.rs"
|
|
||||||
|
|
||||||
[[bin]]
|
|
||||||
name = "wasm-ext"
|
|
||||||
path = "ext/main.rs"
|
|
||||||
|
|
||||||
[[bin]]
|
|
||||||
name = "wasm-gas"
|
|
||||||
path = "gas/main.rs"
|
|
||||||
|
|
||||||
[[bin]]
|
|
||||||
name = "wasm-build"
|
|
||||||
path = "build/main.rs"
|
|
||||||
|
|
||||||
[[bin]]
|
|
||||||
name = "wasm-stack-height"
|
|
||||||
path = "stack_height/main.rs"
|
|
||||||
|
|
||||||
[[bin]]
|
|
||||||
name = "wasm-pack"
|
|
||||||
path = "pack/main.rs"
|
|
||||||
|
|
||||||
[[bin]]
|
|
||||||
name = "wasm-check"
|
|
||||||
path = "check/main.rs"
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
parity-wasm = "0.41.0"
|
|
||||||
pwasm-utils = { path = "..", version = "0.15" }
|
|
||||||
glob = "0.2"
|
|
||||||
clap = "2.24"
|
|
||||||
log = "0.4"
|
|
||||||
env_logger = "0.5"
|
|
||||||
lazy_static = "1.0"
|
|
||||||
|
|
||||||
[dev-dependencies]
|
|
||||||
tempdir = "0.3"
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
# pwasm-utils-cli
|
|
||||||
|
|
||||||
Collection of WASM utilities used in Parity and WASM contract devepment
|
|
||||||
|
|
||||||
## Install
|
|
||||||
|
|
||||||
Easiest way to use is to install via `cargo install`:
|
|
||||||
|
|
||||||
```
|
|
||||||
cargo install pwasm-utils-cli
|
|
||||||
```
|
|
||||||
+2
-2
@@ -5,7 +5,7 @@ extern crate clap;
|
|||||||
extern crate glob;
|
extern crate glob;
|
||||||
extern crate pwasm_utils as utils;
|
extern crate pwasm_utils as utils;
|
||||||
extern crate parity_wasm;
|
extern crate parity_wasm;
|
||||||
extern crate pwasm_utils_cli as logger;
|
use pwasm_utils::logger;
|
||||||
|
|
||||||
mod source;
|
mod source;
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ pub fn process_output(input: &source::SourceInput) -> Result<(), Error> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn do_main() -> Result<(), Error> {
|
fn do_main() -> Result<(), Error> {
|
||||||
logger::init_log();
|
logger::init();
|
||||||
|
|
||||||
let matches = App::new("wasm-build")
|
let matches = App::new("wasm-build")
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
extern crate parity_wasm;
|
extern crate parity_wasm;
|
||||||
extern crate pwasm_utils as utils;
|
extern crate pwasm_utils as utils;
|
||||||
extern crate pwasm_utils_cli as logger;
|
use pwasm_utils::logger;
|
||||||
extern crate clap;
|
extern crate clap;
|
||||||
|
|
||||||
use clap::{App, Arg};
|
use clap::{App, Arg};
|
||||||
@@ -40,7 +40,7 @@ const ALLOWED_IMPORTS: &[&str] = &[
|
|||||||
];
|
];
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
logger::init_log();
|
logger::init();
|
||||||
|
|
||||||
let matches = App::new("wasm-check")
|
let matches = App::new("wasm-check")
|
||||||
.arg(Arg::with_name("input")
|
.arg(Arg::with_name("input")
|
||||||
|
|||||||
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
extern crate parity_wasm;
|
extern crate parity_wasm;
|
||||||
extern crate pwasm_utils as utils;
|
extern crate pwasm_utils as utils;
|
||||||
extern crate pwasm_utils_cli as logger;
|
use pwasm_utils::logger;
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
||||||
logger::init_log();
|
logger::init();
|
||||||
|
|
||||||
let args = env::args().collect::<Vec<_>>();
|
let args = env::args().collect::<Vec<_>>();
|
||||||
if args.len() != 3 {
|
if args.len() != 3 {
|
||||||
|
|||||||
+2
-2
@@ -1,11 +1,11 @@
|
|||||||
extern crate parity_wasm;
|
extern crate parity_wasm;
|
||||||
extern crate pwasm_utils as utils;
|
extern crate pwasm_utils as utils;
|
||||||
extern crate pwasm_utils_cli as logger;
|
use pwasm_utils::logger;
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
logger::init_log();
|
logger::init();
|
||||||
|
|
||||||
let args = env::args().collect::<Vec<_>>();
|
let args = env::args().collect::<Vec<_>>();
|
||||||
if args.len() != 3 {
|
if args.len() != 3 {
|
||||||
|
|||||||
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
extern crate parity_wasm;
|
extern crate parity_wasm;
|
||||||
extern crate pwasm_utils as utils;
|
extern crate pwasm_utils as utils;
|
||||||
extern crate pwasm_utils_cli as logger;
|
use pwasm_utils::logger;
|
||||||
extern crate clap;
|
extern crate clap;
|
||||||
|
|
||||||
use clap::{App, Arg};
|
use clap::{App, Arg};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
logger::init_log();
|
logger::init();
|
||||||
|
|
||||||
let target_runtime = utils::TargetRuntime::pwasm();
|
let target_runtime = utils::TargetRuntime::pwasm();
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
extern crate parity_wasm;
|
extern crate parity_wasm;
|
||||||
extern crate pwasm_utils as utils;
|
extern crate pwasm_utils as utils;
|
||||||
extern crate pwasm_utils_cli as logger;
|
use pwasm_utils::logger;
|
||||||
extern crate clap;
|
extern crate clap;
|
||||||
|
|
||||||
use clap::{App, Arg};
|
use clap::{App, Arg};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
logger::init_log();
|
logger::init();
|
||||||
|
|
||||||
let target_runtime = utils::TargetRuntime::pwasm();
|
let target_runtime = utils::TargetRuntime::pwasm();
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
extern crate pwasm_utils as utils;
|
extern crate pwasm_utils as utils;
|
||||||
extern crate parity_wasm;
|
extern crate parity_wasm;
|
||||||
extern crate pwasm_utils_cli as logger;
|
use pwasm_utils::logger;
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use utils::stack_height;
|
use utils::stack_height;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
logger::init_log();
|
logger::init();
|
||||||
|
|
||||||
let args = env::args().collect::<Vec<_>>();
|
let args = env::args().collect::<Vec<_>>();
|
||||||
if args.len() != 3 {
|
if args.len() != 3 {
|
||||||
|
|||||||
+3
-4
@@ -1,4 +1,3 @@
|
|||||||
use std;
|
|
||||||
use super::{
|
use super::{
|
||||||
optimize,
|
optimize,
|
||||||
pack_instance,
|
pack_instance,
|
||||||
@@ -9,8 +8,8 @@ use super::{
|
|||||||
PackingError,
|
PackingError,
|
||||||
OptimizerError,
|
OptimizerError,
|
||||||
TargetRuntime,
|
TargetRuntime,
|
||||||
|
std::fmt,
|
||||||
};
|
};
|
||||||
use parity_wasm;
|
|
||||||
use parity_wasm::elements;
|
use parity_wasm::elements;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@@ -38,8 +37,8 @@ pub enum SourceTarget {
|
|||||||
Unknown,
|
Unknown,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Display for Error {
|
impl fmt::Display for Error {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
|
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
||||||
use self::Error::*;
|
use self::Error::*;
|
||||||
match self {
|
match self {
|
||||||
Encoding(err) => write!(f, "Encoding error ({})", err),
|
Encoding(err) => write!(f, "Encoding error ({})", err),
|
||||||
|
|||||||
+5
-4
@@ -1,11 +1,12 @@
|
|||||||
use std::string::String;
|
use crate::std::string::String;
|
||||||
use std::vec::Vec;
|
use crate::std::vec::Vec;
|
||||||
use std::borrow::ToOwned;
|
use crate::std::borrow::ToOwned;
|
||||||
|
|
||||||
use parity_wasm::{elements, builder};
|
use parity_wasm::{elements, builder};
|
||||||
use optimizer::{import_section, export_section};
|
|
||||||
use byteorder::{LittleEndian, ByteOrder};
|
use byteorder::{LittleEndian, ByteOrder};
|
||||||
|
|
||||||
|
use crate::optimizer::{import_section, export_section};
|
||||||
|
|
||||||
type Insertion = (usize, u32, u32, String);
|
type Insertion = (usize, u32, u32, String);
|
||||||
|
|
||||||
pub fn update_call_index(instructions: &mut elements::Instructions, original_imports: usize, inserts: &[Insertion]) {
|
pub fn update_call_index(instructions: &mut elements::Instructions, original_imports: usize, inserts: &[Insertion]) {
|
||||||
|
|||||||
+5
-5
@@ -7,12 +7,12 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod validation;
|
mod validation;
|
||||||
|
|
||||||
use std::cmp::min;
|
use crate::std::cmp::min;
|
||||||
use std::mem;
|
use crate::std::mem;
|
||||||
use std::vec::Vec;
|
use crate::std::vec::Vec;
|
||||||
|
|
||||||
use parity_wasm::{elements, builder};
|
use parity_wasm::{elements, builder};
|
||||||
use rules::Rules;
|
use crate::rules::Rules;
|
||||||
|
|
||||||
pub fn update_call_index(instructions: &mut elements::Instructions, inserted_index: u32) {
|
pub fn update_call_index(instructions: &mut elements::Instructions, inserted_index: u32) {
|
||||||
use parity_wasm::elements::Instruction::*;
|
use parity_wasm::elements::Instruction::*;
|
||||||
@@ -518,7 +518,7 @@ mod tests {
|
|||||||
use parity_wasm::{serialize, builder, elements};
|
use parity_wasm::{serialize, builder, elements};
|
||||||
use parity_wasm::elements::Instruction::*;
|
use parity_wasm::elements::Instruction::*;
|
||||||
use super::*;
|
use super::*;
|
||||||
use rules;
|
use crate::rules;
|
||||||
|
|
||||||
pub fn get_function_body(module: &elements::Module, index: usize)
|
pub fn get_function_body(module: &elements::Module, index: usize)
|
||||||
-> Option<&[elements::Instruction]>
|
-> Option<&[elements::Instruction]>
|
||||||
|
|||||||
@@ -9,11 +9,15 @@
|
|||||||
//! the worst case.
|
//! the worst case.
|
||||||
|
|
||||||
use super::MeteredBlock;
|
use super::MeteredBlock;
|
||||||
use rules::Set as RuleSet;
|
use crate::rules::Set as RuleSet;
|
||||||
use rules::Rules;
|
use crate::rules::Rules;
|
||||||
|
use crate::std::vec::Vec;
|
||||||
use parity_wasm::elements::{FuncBody, Instruction};
|
use parity_wasm::elements::{FuncBody, Instruction};
|
||||||
|
|
||||||
use std::collections::HashMap;
|
#[cfg(features = "std")]
|
||||||
|
use crate::std::collections::HashMap as Map;
|
||||||
|
#[cfg(not(features = "std"))]
|
||||||
|
use crate::std::collections::BTreeMap as Map;
|
||||||
|
|
||||||
/// An ID for a node in a ControlFlowGraph.
|
/// An ID for a node in a ControlFlowGraph.
|
||||||
type NodeId = usize;
|
type NodeId = usize;
|
||||||
@@ -288,7 +292,7 @@ fn validate_graph_gas_costs(graph: &ControlFlowGraph) -> bool {
|
|||||||
node_id: NodeId,
|
node_id: NodeId,
|
||||||
mut total_actual: u32,
|
mut total_actual: u32,
|
||||||
mut total_charged: u32,
|
mut total_charged: u32,
|
||||||
loop_costs: &mut HashMap<NodeId, (u32, u32)>,
|
loop_costs: &mut Map<NodeId, (u32, u32)>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let node = graph.get_node(node_id);
|
let node = graph.get_node(node_id);
|
||||||
|
|
||||||
@@ -325,7 +329,7 @@ fn validate_graph_gas_costs(graph: &ControlFlowGraph) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Recursively explore all paths through the execution graph starting from the entry node.
|
// Recursively explore all paths through the execution graph starting from the entry node.
|
||||||
visit(graph, 0, 0, 0, &mut HashMap::new())
|
visit(graph, 0, 0, 0, &mut Map::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Validate that the metered blocks are correct with respect to the function body by exhaustively
|
/// Validate that the metered blocks are correct with respect to the function body by exhaustively
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
use parity_wasm::elements;
|
use parity_wasm::elements;
|
||||||
use super::ref_list::{RefList, EntryRef};
|
use super::ref_list::{RefList, EntryRef};
|
||||||
use std::{
|
use crate::std::{
|
||||||
vec::Vec,
|
vec::Vec,
|
||||||
borrow::ToOwned,
|
borrow::ToOwned,
|
||||||
string::String,
|
string::String,
|
||||||
|
|||||||
+9
-1
@@ -25,6 +25,8 @@ mod ref_list;
|
|||||||
mod symbols;
|
mod symbols;
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
mod export_globals;
|
mod export_globals;
|
||||||
|
#[cfg(feature = "cli")]
|
||||||
|
pub mod logger;
|
||||||
|
|
||||||
pub mod stack_height;
|
pub mod stack_height;
|
||||||
|
|
||||||
@@ -81,7 +83,7 @@ impl TargetRuntime {
|
|||||||
|
|
||||||
#[cfg(not(feature = "std"))]
|
#[cfg(not(feature = "std"))]
|
||||||
mod std {
|
mod std {
|
||||||
pub use alloc::{borrow, boxed, string, vec};
|
pub use ::alloc::{borrow, boxed, string, vec};
|
||||||
pub use core::*;
|
pub use core::*;
|
||||||
|
|
||||||
pub mod rc {
|
pub mod rc {
|
||||||
@@ -92,3 +94,9 @@ mod std {
|
|||||||
pub use alloc::collections::{BTreeMap, BTreeSet};
|
pub use alloc::collections::{BTreeMap, BTreeSet};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[cfg(feature = "std")]
|
||||||
|
mod std {
|
||||||
|
pub use std::*;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
#[macro_use] extern crate log;
|
use crate::std::env;
|
||||||
#[macro_use] extern crate lazy_static;
|
|
||||||
extern crate env_logger;
|
|
||||||
|
|
||||||
use std::env;
|
|
||||||
use log::LevelFilter;
|
use log::LevelFilter;
|
||||||
use env_logger::Builder;
|
use env_logger::Builder;
|
||||||
|
use lazy_static::lazy_static;
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref LOG_DUMMY: bool = {
|
static ref LOG_DUMMY: bool = {
|
||||||
@@ -22,6 +19,6 @@ lazy_static! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Intialize log with default settings
|
/// Intialize log with default settings
|
||||||
pub fn init_log() {
|
pub fn init() {
|
||||||
let _ = *LOG_DUMMY;
|
let _ = *LOG_DUMMY;
|
||||||
}
|
}
|
||||||
+5
-5
@@ -1,13 +1,13 @@
|
|||||||
#[cfg(features = "std")]
|
#[cfg(features = "std")]
|
||||||
use std::collections::{HashSet as Set};
|
use crate::std::collections::{HashSet as Set};
|
||||||
#[cfg(not(features = "std"))]
|
#[cfg(not(features = "std"))]
|
||||||
use std::collections::{BTreeSet as Set};
|
use crate::std::collections::{BTreeSet as Set};
|
||||||
use std::vec::Vec;
|
use crate::std::vec::Vec;
|
||||||
use std::mem;
|
use crate::std::mem;
|
||||||
|
|
||||||
use parity_wasm::elements;
|
use parity_wasm::elements;
|
||||||
|
|
||||||
use symbols::{Symbol, expand_symbols, push_code_symbols, resolve_function};
|
use crate::symbols::{Symbol, expand_symbols, push_code_symbols, resolve_function};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
|
|||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
use std::fmt;
|
use crate::std::fmt;
|
||||||
use std::vec::Vec;
|
use crate::std::vec::Vec;
|
||||||
use std::borrow::ToOwned;
|
use crate::std::borrow::ToOwned;
|
||||||
|
|
||||||
use parity_wasm::elements::{
|
use parity_wasm::elements::{
|
||||||
self, Section, DataSection, Instruction, DataSegment, InitExpr, Internal, External,
|
self, Section, DataSection, Instruction, DataSegment, InitExpr, Internal, External,
|
||||||
|
|||||||
+8
-8
@@ -1,9 +1,9 @@
|
|||||||
#![warn(missing_docs)]
|
#![warn(missing_docs)]
|
||||||
|
|
||||||
use std::rc::Rc;
|
use crate::std::rc::Rc;
|
||||||
use std::cell::RefCell;
|
use crate::std::cell::RefCell;
|
||||||
use std::vec::Vec;
|
use crate::std::vec::Vec;
|
||||||
use std::slice;
|
use crate::std::slice;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
enum EntryOrigin {
|
enum EntryOrigin {
|
||||||
@@ -50,7 +50,7 @@ impl<T> Entry<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> ::std::ops::Deref for Entry<T> {
|
impl<T> crate::std::ops::Deref for Entry<T> {
|
||||||
type Target = T;
|
type Target = T;
|
||||||
|
|
||||||
fn deref(&self) -> &T {
|
fn deref(&self) -> &T {
|
||||||
@@ -58,7 +58,7 @@ impl<T> ::std::ops::Deref for Entry<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> ::std::ops::DerefMut for Entry<T> {
|
impl<T> crate::std::ops::DerefMut for Entry<T> {
|
||||||
fn deref_mut(&mut self) -> &mut T {
|
fn deref_mut(&mut self) -> &mut T {
|
||||||
&mut self.val
|
&mut self.val
|
||||||
}
|
}
|
||||||
@@ -82,14 +82,14 @@ impl<T> From<Entry<T>> for EntryRef<T> {
|
|||||||
|
|
||||||
impl<T> EntryRef<T> {
|
impl<T> EntryRef<T> {
|
||||||
/// Read the reference data.
|
/// Read the reference data.
|
||||||
pub fn read(&self) -> ::std::cell::Ref<Entry<T>> {
|
pub fn read(&self) -> crate::std::cell::Ref<Entry<T>> {
|
||||||
self.0.borrow()
|
self.0.borrow()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Try to modify internal content of the referenced object.
|
/// Try to modify internal content of the referenced object.
|
||||||
///
|
///
|
||||||
/// May panic if it is already borrowed.
|
/// May panic if it is already borrowed.
|
||||||
pub fn write(&self) -> ::std::cell::RefMut<Entry<T>> {
|
pub fn write(&self) -> crate::std::cell::RefMut<Entry<T>> {
|
||||||
self.0.borrow_mut()
|
self.0.borrow_mut()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-4
@@ -1,9 +1,10 @@
|
|||||||
#[cfg(features = "std")]
|
#[cfg(features = "std")]
|
||||||
use std::collections::{HashMap as Map};
|
use crate::std::collections::HashMap as Map;
|
||||||
#[cfg(not(features = "std"))]
|
#[cfg(not(features = "std"))]
|
||||||
use std::collections::{BTreeMap as Map};
|
use crate::std::collections::BTreeMap as Map;
|
||||||
|
|
||||||
use std::num::NonZeroU32;
|
use crate::std::num::NonZeroU32;
|
||||||
|
use crate::std::str::FromStr;
|
||||||
|
|
||||||
use parity_wasm::elements;
|
use parity_wasm::elements;
|
||||||
|
|
||||||
@@ -68,7 +69,7 @@ pub enum InstructionType {
|
|||||||
GrowMemory,
|
GrowMemory,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::std::str::FromStr for InstructionType {
|
impl FromStr for InstructionType {
|
||||||
type Err = UnknownInstruction;
|
type Err = UnknownInstruction;
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use std::vec::Vec;
|
use crate::std::vec::Vec;
|
||||||
|
|
||||||
use parity_wasm::elements::{self, BlockType, Type};
|
use parity_wasm::elements::{self, BlockType, Type};
|
||||||
use super::{resolve_func_type, Error};
|
use super::{resolve_func_type, Error};
|
||||||
|
|||||||
@@ -49,8 +49,8 @@
|
|||||||
//! between the frames.
|
//! between the frames.
|
||||||
//! - upon entry into the function entire stack frame is allocated.
|
//! - upon entry into the function entire stack frame is allocated.
|
||||||
|
|
||||||
use std::string::String;
|
use crate::std::string::String;
|
||||||
use std::vec::Vec;
|
use crate::std::vec::Vec;
|
||||||
|
|
||||||
use parity_wasm::elements::{self, Type};
|
use parity_wasm::elements::{self, Type};
|
||||||
use parity_wasm::builder;
|
use parity_wasm::builder;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#[cfg(features = "std")]
|
#[cfg(features = "std")]
|
||||||
use std::collections::{HashMap as Map};
|
use crate::std::collections::{HashMap as Map};
|
||||||
#[cfg(not(features = "std"))]
|
#[cfg(not(features = "std"))]
|
||||||
use std::collections::{BTreeMap as Map};
|
use crate::std::collections::{BTreeMap as Map};
|
||||||
use std::vec::Vec;
|
use crate::std::vec::Vec;
|
||||||
|
|
||||||
use parity_wasm::elements::{self, FunctionType, Internal};
|
use parity_wasm::elements::{self, FunctionType, Internal};
|
||||||
use parity_wasm::builder;
|
use parity_wasm::builder;
|
||||||
|
|||||||
+3
-3
@@ -1,8 +1,8 @@
|
|||||||
#[cfg(features = "std")]
|
#[cfg(features = "std")]
|
||||||
use std::collections::{HashSet as Set};
|
use crate::std::collections::{HashSet as Set};
|
||||||
#[cfg(not(features = "std"))]
|
#[cfg(not(features = "std"))]
|
||||||
use std::collections::{BTreeSet as Set};
|
use crate::std::collections::{BTreeSet as Set};
|
||||||
use std::vec::Vec;
|
use crate::std::vec::Vec;
|
||||||
|
|
||||||
use parity_wasm::elements;
|
use parity_wasm::elements;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user