Enable missing_docs errors in the wasm crate.
This adds `#![deny(missing_docs)]` to the wasm crate, and adds documentation to several struct and enum fields, as needed.
This commit is contained in:
@@ -10,6 +10,8 @@
|
|||||||
//!
|
//!
|
||||||
//! The main function of this module is [`translate_module`](fn.translate_module.html).
|
//! The main function of this module is [`translate_module`](fn.translate_module.html).
|
||||||
|
|
||||||
|
#![deny(missing_docs)]
|
||||||
|
|
||||||
extern crate wasmparser;
|
extern crate wasmparser;
|
||||||
extern crate cton_frontend;
|
extern crate cton_frontend;
|
||||||
extern crate cretonne;
|
extern crate cretonne;
|
||||||
|
|||||||
@@ -12,22 +12,25 @@ use cton_frontend::ILBuilder;
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use runtime::WasmRuntime;
|
use runtime::WasmRuntime;
|
||||||
|
|
||||||
/// Output of the [`translate_module`](fn.translate_module.html) function. Contains the translated
|
/// Output of the [`translate_module`](fn.translate_module.html) function.
|
||||||
/// functions and when present the index of the function defined as `start` of the module.
|
|
||||||
pub struct TranslationResult {
|
pub struct TranslationResult {
|
||||||
|
/// The translated functions.
|
||||||
pub functions: Vec<FunctionTranslation>,
|
pub functions: Vec<FunctionTranslation>,
|
||||||
|
/// When present, the index of the function defined as `start` of the module.
|
||||||
pub start_index: Option<FunctionIndex>,
|
pub start_index: Option<FunctionIndex>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A function in a WebAssembly module can be either imported, or defined inside it. If it is
|
/// A function in a WebAssembly module can be either imported, or defined inside it.
|
||||||
/// defined inside it, then the translation in Cretonne IL is available as well as the mappings
|
|
||||||
/// between Cretonne imports and indexes in the function index space.
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub enum FunctionTranslation {
|
pub enum FunctionTranslation {
|
||||||
|
/// A function defined inside the WebAssembly module.
|
||||||
Code {
|
Code {
|
||||||
|
/// The translation in Cretonne IL.
|
||||||
il: Function,
|
il: Function,
|
||||||
|
/// The mappings between Cretonne imports and indexes in the function index space.
|
||||||
imports: ImportMappings,
|
imports: ImportMappings,
|
||||||
},
|
},
|
||||||
|
/// An imported function.
|
||||||
Import(),
|
Import(),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,6 +45,7 @@ pub struct ImportMappings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ImportMappings {
|
impl ImportMappings {
|
||||||
|
/// Create a new empty `ImportMappings`.
|
||||||
pub fn new() -> ImportMappings {
|
pub fn new() -> ImportMappings {
|
||||||
ImportMappings {
|
ImportMappings {
|
||||||
functions: HashMap::new(),
|
functions: HashMap::new(),
|
||||||
|
|||||||
@@ -32,27 +32,39 @@ pub enum Import {
|
|||||||
/// WebAssembly global.
|
/// WebAssembly global.
|
||||||
#[derive(Debug,Clone,Copy)]
|
#[derive(Debug,Clone,Copy)]
|
||||||
pub struct Global {
|
pub struct Global {
|
||||||
|
/// The type of the value stored in the global.
|
||||||
pub ty: cretonne::ir::Type,
|
pub ty: cretonne::ir::Type,
|
||||||
|
/// A flag indicating whether the value may change at runtime.
|
||||||
pub mutability: bool,
|
pub mutability: bool,
|
||||||
|
/// The source of the initial value.
|
||||||
pub initializer: GlobalInit,
|
pub initializer: GlobalInit,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Globals are initialized via the four `const` operators or by referring to another import.
|
/// Globals are initialized via the four `const` operators or by referring to another import.
|
||||||
#[derive(Debug,Clone,Copy)]
|
#[derive(Debug,Clone,Copy)]
|
||||||
pub enum GlobalInit {
|
pub enum GlobalInit {
|
||||||
|
/// An `i32.const`.
|
||||||
I32Const(i32),
|
I32Const(i32),
|
||||||
|
/// An `i64.const`.
|
||||||
I64Const(i64),
|
I64Const(i64),
|
||||||
|
/// An `f32.const`.
|
||||||
F32Const(u32),
|
F32Const(u32),
|
||||||
|
/// An `f64.const`.
|
||||||
F64Const(u64),
|
F64Const(u64),
|
||||||
Import(),
|
/// A `get_global` of another global.
|
||||||
GlobalRef(GlobalIndex),
|
GlobalRef(GlobalIndex),
|
||||||
|
///< The global is imported from, and thus initialized by, a different module.
|
||||||
|
Import(),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// WebAssembly table.
|
/// WebAssembly table.
|
||||||
#[derive(Debug,Clone,Copy)]
|
#[derive(Debug,Clone,Copy)]
|
||||||
pub struct Table {
|
pub struct Table {
|
||||||
|
/// The type of data stored in elements of the table.
|
||||||
pub ty: TableElementType,
|
pub ty: TableElementType,
|
||||||
|
/// The minimum number of elements in the table.
|
||||||
pub size: usize,
|
pub size: usize,
|
||||||
|
/// The maximum number of elements in the table.
|
||||||
pub maximum: Option<usize>,
|
pub maximum: Option<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,7 +78,9 @@ pub enum TableElementType {
|
|||||||
/// WebAssembly linear memory.
|
/// WebAssembly linear memory.
|
||||||
#[derive(Debug,Clone,Copy)]
|
#[derive(Debug,Clone,Copy)]
|
||||||
pub struct Memory {
|
pub struct Memory {
|
||||||
|
/// The minimum number of pages in the memory.
|
||||||
pub pages_count: usize,
|
pub pages_count: usize,
|
||||||
|
/// The maximum number of pages in the memory.
|
||||||
pub maximum: Option<usize>,
|
pub maximum: Option<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user