mirror of
https://github.com/fluencelabs/parity-wasm
synced 2025-06-21 02:31:51 +00:00
Clone impl for a module
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "parity-wasm"
|
name = "parity-wasm"
|
||||||
version = "0.14.6"
|
version = "0.14.7"
|
||||||
authors = ["Nikolay Volf <nikvolf@gmail.com>", "Svyatoslav Nikolsky <svyatonik@yandex.ru>"]
|
authors = ["Nikolay Volf <nikvolf@gmail.com>", "Svyatoslav Nikolsky <svyatonik@yandex.ru>"]
|
||||||
license = "MIT/Apache-2.0"
|
license = "MIT/Apache-2.0"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
@ -48,7 +48,7 @@ impl Serialize for Internal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Export entry.
|
/// Export entry.
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct ExportEntry {
|
pub struct ExportEntry {
|
||||||
field_str: String,
|
field_str: String,
|
||||||
internal: Internal,
|
internal: Internal,
|
||||||
|
@ -5,6 +5,7 @@ use super::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Function signature (type reference)
|
/// Function signature (type reference)
|
||||||
|
#[derive(Clone)]
|
||||||
pub struct Func(u32);
|
pub struct Func(u32);
|
||||||
|
|
||||||
impl Func {
|
impl Func {
|
||||||
@ -23,7 +24,7 @@ impl Func {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Local definition inside the function body.
|
/// Local definition inside the function body.
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Local {
|
pub struct Local {
|
||||||
count: u32,
|
count: u32,
|
||||||
value_type: ValueType,
|
value_type: ValueType,
|
||||||
@ -63,7 +64,7 @@ impl Serialize for Local {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Function body definition.
|
/// Function body definition.
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct FuncBody {
|
pub struct FuncBody {
|
||||||
locals: Vec<Local>,
|
locals: Vec<Local>,
|
||||||
opcodes: Opcodes,
|
opcodes: Opcodes,
|
||||||
|
@ -2,6 +2,7 @@ use std::io;
|
|||||||
use super::{Deserialize, Serialize, Error, GlobalType, InitExpr};
|
use super::{Deserialize, Serialize, Error, GlobalType, InitExpr};
|
||||||
|
|
||||||
/// Global entry in the module.
|
/// Global entry in the module.
|
||||||
|
#[derive(Clone)]
|
||||||
pub struct GlobalEntry {
|
pub struct GlobalEntry {
|
||||||
global_type: GlobalType,
|
global_type: GlobalType,
|
||||||
init_expr: InitExpr,
|
init_expr: InitExpr,
|
||||||
|
@ -5,7 +5,7 @@ use super::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Global definition struct
|
/// Global definition struct
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct GlobalType {
|
pub struct GlobalType {
|
||||||
content_type: ValueType,
|
content_type: ValueType,
|
||||||
is_mutable: bool,
|
is_mutable: bool,
|
||||||
@ -51,7 +51,7 @@ impl Serialize for GlobalType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Table entry
|
/// Table entry
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct TableType {
|
pub struct TableType {
|
||||||
elem_type: TableElementType,
|
elem_type: TableElementType,
|
||||||
limits: ResizableLimits,
|
limits: ResizableLimits,
|
||||||
@ -150,7 +150,7 @@ impl Serialize for ResizableLimits {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Memory entry.
|
/// Memory entry.
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct MemoryType(ResizableLimits);
|
pub struct MemoryType(ResizableLimits);
|
||||||
|
|
||||||
impl MemoryType {
|
impl MemoryType {
|
||||||
@ -181,7 +181,7 @@ impl Serialize for MemoryType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// External to local binding.
|
/// External to local binding.
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum External {
|
pub enum External {
|
||||||
/// Binds to function with index.
|
/// Binds to function with index.
|
||||||
Function(u32),
|
Function(u32),
|
||||||
@ -238,7 +238,7 @@ impl Serialize for External {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Import entry.
|
/// Import entry.
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct ImportEntry {
|
pub struct ImportEntry {
|
||||||
module_str: String,
|
module_str: String,
|
||||||
field_str: String,
|
field_str: String,
|
||||||
|
@ -10,6 +10,7 @@ use super::section::{
|
|||||||
const WASM_MAGIC_NUMBER: [u8; 4] = [0x00, 0x61, 0x73, 0x6d];
|
const WASM_MAGIC_NUMBER: [u8; 4] = [0x00, 0x61, 0x73, 0x6d];
|
||||||
|
|
||||||
/// WebAssembly module
|
/// WebAssembly module
|
||||||
|
#[derive(Clone)]
|
||||||
pub struct Module {
|
pub struct Module {
|
||||||
magic: u32,
|
magic: u32,
|
||||||
version: u32,
|
version: u32,
|
||||||
|
@ -7,7 +7,7 @@ use super::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Collection of opcodes (usually inside a block section).
|
/// Collection of opcodes (usually inside a block section).
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
pub struct Opcodes(Vec<Opcode>);
|
pub struct Opcodes(Vec<Opcode>);
|
||||||
|
|
||||||
impl Opcodes {
|
impl Opcodes {
|
||||||
@ -54,7 +54,7 @@ impl Deserialize for Opcodes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Initialization expression.
|
/// Initialization expression.
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct InitExpr(Vec<Opcode>);
|
pub struct InitExpr(Vec<Opcode>);
|
||||||
|
|
||||||
impl InitExpr {
|
impl InitExpr {
|
||||||
|
@ -23,6 +23,7 @@ use super::{
|
|||||||
use super::types::Type;
|
use super::types::Type;
|
||||||
|
|
||||||
/// Section in the WebAssembly module.
|
/// Section in the WebAssembly module.
|
||||||
|
#[derive(Clone)]
|
||||||
pub enum Section {
|
pub enum Section {
|
||||||
/// Section is unparsed.
|
/// Section is unparsed.
|
||||||
Unparsed {
|
Unparsed {
|
||||||
@ -179,6 +180,7 @@ impl Serialize for Section {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Custom section
|
/// Custom section
|
||||||
|
#[derive(Clone)]
|
||||||
pub struct CustomSection {
|
pub struct CustomSection {
|
||||||
name: String,
|
name: String,
|
||||||
payload: Vec<u8>,
|
payload: Vec<u8>,
|
||||||
@ -238,7 +240,7 @@ impl Serialize for CustomSection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Section with type declarations
|
/// Section with type declarations
|
||||||
#[derive(Default)]
|
#[derive(Default, Clone)]
|
||||||
pub struct TypeSection(Vec<Type>);
|
pub struct TypeSection(Vec<Type>);
|
||||||
|
|
||||||
impl TypeSection {
|
impl TypeSection {
|
||||||
@ -286,7 +288,7 @@ impl Serialize for TypeSection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Section of the imports definition.
|
/// Section of the imports definition.
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default, Clone)]
|
||||||
pub struct ImportSection(Vec<ImportEntry>);
|
pub struct ImportSection(Vec<ImportEntry>);
|
||||||
|
|
||||||
impl ImportSection {
|
impl ImportSection {
|
||||||
@ -334,7 +336,7 @@ impl Serialize for ImportSection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Section with function signatures definition.
|
/// Section with function signatures definition.
|
||||||
#[derive(Default)]
|
#[derive(Default, Clone)]
|
||||||
pub struct FunctionSection(Vec<Func>);
|
pub struct FunctionSection(Vec<Func>);
|
||||||
|
|
||||||
impl FunctionSection {
|
impl FunctionSection {
|
||||||
@ -386,7 +388,7 @@ impl Serialize for FunctionSection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Section with table definition (currently only one is allowed).
|
/// Section with table definition (currently only one is allowed).
|
||||||
#[derive(Default)]
|
#[derive(Default, Clone)]
|
||||||
pub struct TableSection(Vec<TableType>);
|
pub struct TableSection(Vec<TableType>);
|
||||||
|
|
||||||
impl TableSection {
|
impl TableSection {
|
||||||
@ -434,7 +436,7 @@ impl Serialize for TableSection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Section with table definition (currently only one entry is allowed).
|
/// Section with table definition (currently only one entry is allowed).
|
||||||
#[derive(Default)]
|
#[derive(Default, Clone)]
|
||||||
pub struct MemorySection(Vec<MemoryType>);
|
pub struct MemorySection(Vec<MemoryType>);
|
||||||
|
|
||||||
impl MemorySection {
|
impl MemorySection {
|
||||||
@ -482,7 +484,7 @@ impl Serialize for MemorySection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Globals definition section.
|
/// Globals definition section.
|
||||||
#[derive(Default)]
|
#[derive(Default, Clone)]
|
||||||
pub struct GlobalSection(Vec<GlobalEntry>);
|
pub struct GlobalSection(Vec<GlobalEntry>);
|
||||||
|
|
||||||
impl GlobalSection {
|
impl GlobalSection {
|
||||||
@ -530,7 +532,7 @@ impl Serialize for GlobalSection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// List of exports definition.
|
/// List of exports definition.
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default, Clone)]
|
||||||
pub struct ExportSection(Vec<ExportEntry>);
|
pub struct ExportSection(Vec<ExportEntry>);
|
||||||
|
|
||||||
impl ExportSection {
|
impl ExportSection {
|
||||||
@ -578,7 +580,7 @@ impl Serialize for ExportSection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Section with function bodies of the module.
|
/// Section with function bodies of the module.
|
||||||
#[derive(Default)]
|
#[derive(Default, Clone)]
|
||||||
pub struct CodeSection(Vec<FuncBody>);
|
pub struct CodeSection(Vec<FuncBody>);
|
||||||
|
|
||||||
impl CodeSection {
|
impl CodeSection {
|
||||||
@ -626,7 +628,7 @@ impl Serialize for CodeSection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Element entries section.
|
/// Element entries section.
|
||||||
#[derive(Default)]
|
#[derive(Default, Clone)]
|
||||||
pub struct ElementSection(Vec<ElementSegment>);
|
pub struct ElementSection(Vec<ElementSegment>);
|
||||||
|
|
||||||
impl ElementSection {
|
impl ElementSection {
|
||||||
@ -674,7 +676,7 @@ impl Serialize for ElementSection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Data entries definitions.
|
/// Data entries definitions.
|
||||||
#[derive(Default)]
|
#[derive(Default, Clone)]
|
||||||
pub struct DataSection(Vec<DataSegment>);
|
pub struct DataSection(Vec<DataSegment>);
|
||||||
|
|
||||||
impl DataSection {
|
impl DataSection {
|
||||||
|
@ -2,7 +2,7 @@ use std::io;
|
|||||||
use super::{Deserialize, Serialize, Error, VarUint32, CountedList, InitExpr, CountedListWriter};
|
use super::{Deserialize, Serialize, Error, VarUint32, CountedList, InitExpr, CountedListWriter};
|
||||||
|
|
||||||
/// Entry in the element section.
|
/// Entry in the element section.
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct ElementSegment {
|
pub struct ElementSegment {
|
||||||
index: u32,
|
index: u32,
|
||||||
offset: InitExpr,
|
offset: InitExpr,
|
||||||
@ -68,6 +68,7 @@ impl Serialize for ElementSegment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Data segment definition.
|
/// Data segment definition.
|
||||||
|
#[derive(Clone)]
|
||||||
pub struct DataSegment {
|
pub struct DataSegment {
|
||||||
index: u32,
|
index: u32,
|
||||||
offset: InitExpr,
|
offset: InitExpr,
|
||||||
|
@ -5,7 +5,7 @@ use super::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Type definition in types section. Currently can be only of the function type.
|
/// Type definition in types section. Currently can be only of the function type.
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
pub enum Type {
|
pub enum Type {
|
||||||
/// Function type.
|
/// Function type.
|
||||||
Function(FunctionType),
|
Function(FunctionType),
|
||||||
|
Reference in New Issue
Block a user