mirror of
https://github.com/fluencelabs/parity-wasm
synced 2025-04-25 23:32:15 +00:00
Merge pull request #142 from paritytech/doc-update
Fix missing docs warnings
This commit is contained in:
commit
657ee416c5
@ -255,8 +255,11 @@ impl<F> FuncBodyBuilder<F> where F: Invoke<elements::FuncBody> {
|
|||||||
|
|
||||||
/// Function definition (extended structure to specify function entirely, incl. signature, mainness and code)
|
/// Function definition (extended structure to specify function entirely, incl. signature, mainness and code)
|
||||||
pub struct FunctionDefinition {
|
pub struct FunctionDefinition {
|
||||||
|
/// Is this function is start function
|
||||||
pub is_main: bool,
|
pub is_main: bool,
|
||||||
|
/// Signature description
|
||||||
pub signature: Signature,
|
pub signature: Signature,
|
||||||
|
/// Body (code) of the function
|
||||||
pub code: elements::FuncBody,
|
pub code: elements::FuncBody,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ pub struct ExportBuilder<F=Identity> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ExportBuilder {
|
impl ExportBuilder {
|
||||||
|
/// New export builder
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
ExportBuilder::with_callback(Identity)
|
ExportBuilder::with_callback(Identity)
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ use super::invoke::{Invoke, Identity};
|
|||||||
use super::misc::ValueTypeBuilder;
|
use super::misc::ValueTypeBuilder;
|
||||||
use elements;
|
use elements;
|
||||||
|
|
||||||
|
/// Global builder
|
||||||
pub struct GlobalBuilder<F=Identity> {
|
pub struct GlobalBuilder<F=Identity> {
|
||||||
callback: F,
|
callback: F,
|
||||||
value_type: elements::ValueType,
|
value_type: elements::ValueType,
|
||||||
@ -10,12 +11,14 @@ pub struct GlobalBuilder<F=Identity> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl GlobalBuilder {
|
impl GlobalBuilder {
|
||||||
|
/// New global builder
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
GlobalBuilder::with_callback(Identity)
|
GlobalBuilder::with_callback(Identity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<F> GlobalBuilder<F> {
|
impl<F> GlobalBuilder<F> {
|
||||||
|
/// New global builder with callback (in chained context)
|
||||||
pub fn with_callback(callback: F) -> Self {
|
pub fn with_callback(callback: F) -> Self {
|
||||||
GlobalBuilder {
|
GlobalBuilder {
|
||||||
callback: callback,
|
callback: callback,
|
||||||
@ -25,31 +28,36 @@ impl<F> GlobalBuilder<F> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set/override resulting global type
|
||||||
pub fn with_type(mut self, value_type: elements::ValueType) -> Self {
|
pub fn with_type(mut self, value_type: elements::ValueType) -> Self {
|
||||||
self.value_type = value_type;
|
self.value_type = value_type;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set mutabilty to true
|
||||||
pub fn mutable(mut self) -> Self {
|
pub fn mutable(mut self) -> Self {
|
||||||
self.is_mutable = true;
|
self.is_mutable = true;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set initialization expression opcode for this global (`end` opcode will be added automatically)
|
||||||
pub fn init_expr(mut self, opcode: elements::Opcode) -> Self {
|
pub fn init_expr(mut self, opcode: elements::Opcode) -> Self {
|
||||||
self.init_expr = elements::InitExpr::new(vec![opcode, elements::Opcode::End]);
|
self.init_expr = elements::InitExpr::new(vec![opcode, elements::Opcode::End]);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Start value type builder
|
||||||
pub fn value_type(self) -> ValueTypeBuilder<Self> {
|
pub fn value_type(self) -> ValueTypeBuilder<Self> {
|
||||||
ValueTypeBuilder::with_callback(self)
|
ValueTypeBuilder::with_callback(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<F> GlobalBuilder<F> where F: Invoke<elements::GlobalEntry> {
|
impl<F> GlobalBuilder<F> where F: Invoke<elements::GlobalEntry> {
|
||||||
|
/// Finalize current builder spawning resulting struct
|
||||||
pub fn build(self) -> F::Result {
|
pub fn build(self) -> F::Result {
|
||||||
self.callback.invoke(
|
self.callback.invoke(
|
||||||
elements::GlobalEntry::new(
|
elements::GlobalEntry::new(
|
||||||
elements::GlobalType::new(self.value_type, self.is_mutable),
|
elements::GlobalType::new(self.value_type, self.is_mutable),
|
||||||
self.init_expr,
|
self.init_expr,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
use super::invoke::{Invoke, Identity};
|
use super::invoke::{Invoke, Identity};
|
||||||
use elements;
|
use elements;
|
||||||
|
|
||||||
|
/// Import builder
|
||||||
pub struct ImportBuilder<F=Identity> {
|
pub struct ImportBuilder<F=Identity> {
|
||||||
callback: F,
|
callback: F,
|
||||||
module: String,
|
module: String,
|
||||||
@ -9,13 +10,14 @@ pub struct ImportBuilder<F=Identity> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ImportBuilder {
|
impl ImportBuilder {
|
||||||
|
/// New import builder
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
ImportBuilder::with_callback(Identity)
|
ImportBuilder::with_callback(Identity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<F> ImportBuilder<F> {
|
impl<F> ImportBuilder<F> {
|
||||||
|
/// New import builder with callback (in chained context)
|
||||||
pub fn with_callback(callback: F) -> Self {
|
pub fn with_callback(callback: F) -> Self {
|
||||||
ImportBuilder {
|
ImportBuilder {
|
||||||
callback: callback,
|
callback: callback,
|
||||||
@ -25,31 +27,37 @@ impl<F> ImportBuilder<F> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set/override module name
|
||||||
pub fn module(mut self, name: &str) -> Self {
|
pub fn module(mut self, name: &str) -> Self {
|
||||||
self.module = name.to_owned();
|
self.module = name.to_owned();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set/override field name
|
||||||
pub fn field(mut self, name: &str) -> Self {
|
pub fn field(mut self, name: &str) -> Self {
|
||||||
self.field = name.to_owned();
|
self.field = name.to_owned();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set/override both module name and field name
|
||||||
pub fn path(self, module: &str, field: &str) -> Self {
|
pub fn path(self, module: &str, field: &str) -> Self {
|
||||||
self.module(module).field(field)
|
self.module(module).field(field)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set/override external mapping for this import
|
||||||
pub fn with_external(mut self, external: elements::External) -> Self {
|
pub fn with_external(mut self, external: elements::External) -> Self {
|
||||||
self.binding = external;
|
self.binding = external;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Start new external mapping builder
|
||||||
pub fn external(self) -> ImportExternalBuilder<Self> {
|
pub fn external(self) -> ImportExternalBuilder<Self> {
|
||||||
ImportExternalBuilder::with_callback(self)
|
ImportExternalBuilder::with_callback(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<F> ImportBuilder<F> where F: Invoke<elements::ImportEntry> {
|
impl<F> ImportBuilder<F> where F: Invoke<elements::ImportEntry> {
|
||||||
|
/// Finalize current builder spawning the resulting struct
|
||||||
pub fn build(self) -> F::Result {
|
pub fn build(self) -> F::Result {
|
||||||
self.callback.invoke(elements::ImportEntry::new(self.module, self.field, self.binding))
|
self.callback.invoke(elements::ImportEntry::new(self.module, self.field, self.binding))
|
||||||
}
|
}
|
||||||
@ -62,12 +70,14 @@ impl<F> Invoke<elements::External> for ImportBuilder<F> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Import to external mapping builder
|
||||||
pub struct ImportExternalBuilder<F=Identity> {
|
pub struct ImportExternalBuilder<F=Identity> {
|
||||||
callback: F,
|
callback: F,
|
||||||
binding: elements::External,
|
binding: elements::External,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<F> ImportExternalBuilder<F> where F: Invoke<elements::External> {
|
impl<F> ImportExternalBuilder<F> where F: Invoke<elements::External> {
|
||||||
|
/// New import to external mapping builder with callback (in chained context)
|
||||||
pub fn with_callback(callback: F) -> Self {
|
pub fn with_callback(callback: F) -> Self {
|
||||||
ImportExternalBuilder{
|
ImportExternalBuilder{
|
||||||
callback: callback,
|
callback: callback,
|
||||||
@ -75,21 +85,25 @@ impl<F> ImportExternalBuilder<F> where F: Invoke<elements::External> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Function mapping with type reference
|
||||||
pub fn func(mut self, index: u32) -> F::Result {
|
pub fn func(mut self, index: u32) -> F::Result {
|
||||||
self.binding = elements::External::Function(index);
|
self.binding = elements::External::Function(index);
|
||||||
self.callback.invoke(self.binding)
|
self.callback.invoke(self.binding)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Memory mapping with specified limits
|
||||||
pub fn memory(mut self, min: u32, max: Option<u32>) -> F::Result {
|
pub fn memory(mut self, min: u32, max: Option<u32>) -> F::Result {
|
||||||
self.binding = elements::External::Memory(elements::MemoryType::new(min, max));
|
self.binding = elements::External::Memory(elements::MemoryType::new(min, max));
|
||||||
self.callback.invoke(self.binding)
|
self.callback.invoke(self.binding)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Table mapping with specified limits
|
||||||
pub fn table(mut self, min: u32, max: Option<u32>) -> F::Result {
|
pub fn table(mut self, min: u32, max: Option<u32>) -> F::Result {
|
||||||
self.binding = elements::External::Table(elements::TableType::new(min, max));
|
self.binding = elements::External::Table(elements::TableType::new(min, max));
|
||||||
self.callback.invoke(self.binding)
|
self.callback.invoke(self.binding)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Global mapping with speciifed type and mutability
|
||||||
pub fn global(mut self, value_type: elements::ValueType, is_mut: bool) -> F::Result {
|
pub fn global(mut self, value_type: elements::ValueType, is_mut: bool) -> F::Result {
|
||||||
self.binding = elements::External::Global(elements::GlobalType::new(value_type, is_mut));
|
self.binding = elements::External::Global(elements::GlobalType::new(value_type, is_mut));
|
||||||
self.callback.invoke(self.binding)
|
self.callback.invoke(self.binding)
|
||||||
|
@ -1,31 +1,41 @@
|
|||||||
use elements;
|
use elements;
|
||||||
use super::invoke::{Invoke, Identity};
|
use super::invoke::{Invoke, Identity};
|
||||||
|
|
||||||
|
/// Memory definition struct
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct MemoryDefinition {
|
pub struct MemoryDefinition {
|
||||||
|
/// Minimum memory size
|
||||||
pub min: u32,
|
pub min: u32,
|
||||||
|
/// Maximum memory size
|
||||||
pub max: Option<u32>,
|
pub max: Option<u32>,
|
||||||
|
/// Memory data segments (static regions)
|
||||||
pub data: Vec<MemoryDataDefinition>,
|
pub data: Vec<MemoryDataDefinition>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Memory static region entry definition
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct MemoryDataDefinition {
|
pub struct MemoryDataDefinition {
|
||||||
|
/// Segment initialization expression for offset
|
||||||
pub offset: elements::InitExpr,
|
pub offset: elements::InitExpr,
|
||||||
|
/// Raw bytes of static region
|
||||||
pub values: Vec<u8>,
|
pub values: Vec<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Memory and static regions builder
|
||||||
pub struct MemoryBuilder<F=Identity> {
|
pub struct MemoryBuilder<F=Identity> {
|
||||||
callback: F,
|
callback: F,
|
||||||
memory: MemoryDefinition,
|
memory: MemoryDefinition,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MemoryBuilder {
|
impl MemoryBuilder {
|
||||||
|
/// New memory builder
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
MemoryBuilder::with_callback(Identity)
|
MemoryBuilder::with_callback(Identity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<F> MemoryBuilder<F> where F: Invoke<MemoryDefinition> {
|
impl<F> MemoryBuilder<F> where F: Invoke<MemoryDefinition> {
|
||||||
|
/// New memory builder with callback (in chained context)
|
||||||
pub fn with_callback(callback: F) -> Self {
|
pub fn with_callback(callback: F) -> Self {
|
||||||
MemoryBuilder {
|
MemoryBuilder {
|
||||||
callback: callback,
|
callback: callback,
|
||||||
@ -33,16 +43,19 @@ impl<F> MemoryBuilder<F> where F: Invoke<MemoryDefinition> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set/override minimum size
|
||||||
pub fn with_min(mut self, min: u32) -> Self {
|
pub fn with_min(mut self, min: u32) -> Self {
|
||||||
self.memory.min = min;
|
self.memory.min = min;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set/override maximum size
|
||||||
pub fn with_max(mut self, max: Option<u32>) -> Self {
|
pub fn with_max(mut self, max: Option<u32>) -> Self {
|
||||||
self.memory.max = max;
|
self.memory.max = max;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Push new static region with initialized offset expression and raw bytes
|
||||||
pub fn with_data(mut self, index: u32, values: Vec<u8>) -> Self {
|
pub fn with_data(mut self, index: u32, values: Vec<u8>) -> Self {
|
||||||
self.memory.data.push(MemoryDataDefinition {
|
self.memory.data.push(MemoryDataDefinition {
|
||||||
offset: elements::InitExpr::new(vec![
|
offset: elements::InitExpr::new(vec![
|
||||||
@ -54,6 +67,7 @@ impl<F> MemoryBuilder<F> where F: Invoke<MemoryDefinition> {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Finalize current builder, spawning resulting struct
|
||||||
pub fn build(self) -> F::Result {
|
pub fn build(self) -> F::Result {
|
||||||
self.callback.invoke(self.memory)
|
self.callback.invoke(self.memory)
|
||||||
}
|
}
|
||||||
|
@ -1,31 +1,41 @@
|
|||||||
use elements;
|
use elements;
|
||||||
use super::invoke::{Invoke, Identity};
|
use super::invoke::{Invoke, Identity};
|
||||||
|
|
||||||
|
/// Table definition
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct TableDefinition {
|
pub struct TableDefinition {
|
||||||
|
/// Minimum length
|
||||||
pub min: u32,
|
pub min: u32,
|
||||||
|
/// Maximum length, if any
|
||||||
pub max: Option<u32>,
|
pub max: Option<u32>,
|
||||||
|
/// Element segments, if any
|
||||||
pub elements: Vec<TableEntryDefinition>,
|
pub elements: Vec<TableEntryDefinition>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Table elements entry definition
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct TableEntryDefinition {
|
pub struct TableEntryDefinition {
|
||||||
|
/// Offset initialization expression
|
||||||
pub offset: elements::InitExpr,
|
pub offset: elements::InitExpr,
|
||||||
|
/// Values of initialization
|
||||||
pub values: Vec<u32>,
|
pub values: Vec<u32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Table builder
|
||||||
pub struct TableBuilder<F=Identity> {
|
pub struct TableBuilder<F=Identity> {
|
||||||
callback: F,
|
callback: F,
|
||||||
table: TableDefinition,
|
table: TableDefinition,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TableBuilder {
|
impl TableBuilder {
|
||||||
|
/// New table builder
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
TableBuilder::with_callback(Identity)
|
TableBuilder::with_callback(Identity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<F> TableBuilder<F> where F: Invoke<TableDefinition> {
|
impl<F> TableBuilder<F> where F: Invoke<TableDefinition> {
|
||||||
|
/// New table builder with callback in chained context
|
||||||
pub fn with_callback(callback: F) -> Self {
|
pub fn with_callback(callback: F) -> Self {
|
||||||
TableBuilder {
|
TableBuilder {
|
||||||
callback: callback,
|
callback: callback,
|
||||||
@ -33,16 +43,19 @@ impl<F> TableBuilder<F> where F: Invoke<TableDefinition> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set/override minimum length
|
||||||
pub fn with_min(mut self, min: u32) -> Self {
|
pub fn with_min(mut self, min: u32) -> Self {
|
||||||
self.table.min = min;
|
self.table.min = min;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set/override maximum length
|
||||||
pub fn with_max(mut self, max: Option<u32>) -> Self {
|
pub fn with_max(mut self, max: Option<u32>) -> Self {
|
||||||
self.table.max = max;
|
self.table.max = max;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Generate initialization expression and element values on specified index
|
||||||
pub fn with_element(mut self, index: u32, values: Vec<u32>) -> Self {
|
pub fn with_element(mut self, index: u32, values: Vec<u32>) -> Self {
|
||||||
self.table.elements.push(TableEntryDefinition {
|
self.table.elements.push(TableEntryDefinition {
|
||||||
offset: elements::InitExpr::new(vec![
|
offset: elements::InitExpr::new(vec![
|
||||||
@ -54,6 +67,7 @@ impl<F> TableBuilder<F> where F: Invoke<TableDefinition> {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Finalize current builder spawning resulting struct
|
||||||
pub fn build(self) -> F::Result {
|
pub fn build(self) -> F::Result {
|
||||||
self.callback.invoke(self.table)
|
self.callback.invoke(self.table)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user