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