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:
Dan Gohman
2017-08-28 17:07:28 -07:00
parent ee9989c4b9
commit f905dc914b
3 changed files with 26 additions and 6 deletions

View File

@@ -10,6 +10,8 @@
//!
//! The main function of this module is [`translate_module`](fn.translate_module.html).
#![deny(missing_docs)]
extern crate wasmparser;
extern crate cton_frontend;
extern crate cretonne;

View File

@@ -12,22 +12,25 @@ use cton_frontend::ILBuilder;
use std::collections::HashMap;
use runtime::WasmRuntime;
/// Output of the [`translate_module`](fn.translate_module.html) function. Contains the translated
/// functions and when present the index of the function defined as `start` of the module.
/// Output of the [`translate_module`](fn.translate_module.html) function.
pub struct TranslationResult {
/// The translated functions.
pub functions: Vec<FunctionTranslation>,
/// When present, the index of the function defined as `start` of the module.
pub start_index: Option<FunctionIndex>,
}
/// A function in a WebAssembly module can be either imported, or defined inside it. If it is
/// 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.
/// A function in a WebAssembly module can be either imported, or defined inside it.
#[derive(Clone)]
pub enum FunctionTranslation {
/// A function defined inside the WebAssembly module.
Code {
/// The translation in Cretonne IL.
il: Function,
/// The mappings between Cretonne imports and indexes in the function index space.
imports: ImportMappings,
},
/// An imported function.
Import(),
}
@@ -42,6 +45,7 @@ pub struct ImportMappings {
}
impl ImportMappings {
/// Create a new empty `ImportMappings`.
pub fn new() -> ImportMappings {
ImportMappings {
functions: HashMap::new(),

View File

@@ -32,27 +32,39 @@ pub enum Import {
/// WebAssembly global.
#[derive(Debug,Clone,Copy)]
pub struct Global {
/// The type of the value stored in the global.
pub ty: cretonne::ir::Type,
/// A flag indicating whether the value may change at runtime.
pub mutability: bool,
/// The source of the initial value.
pub initializer: GlobalInit,
}
/// Globals are initialized via the four `const` operators or by referring to another import.
#[derive(Debug,Clone,Copy)]
pub enum GlobalInit {
/// An `i32.const`.
I32Const(i32),
/// An `i64.const`.
I64Const(i64),
/// An `f32.const`.
F32Const(u32),
/// An `f64.const`.
F64Const(u64),
Import(),
/// A `get_global` of another global.
GlobalRef(GlobalIndex),
///< The global is imported from, and thus initialized by, a different module.
Import(),
}
/// WebAssembly table.
#[derive(Debug,Clone,Copy)]
pub struct Table {
/// The type of data stored in elements of the table.
pub ty: TableElementType,
/// The minimum number of elements in the table.
pub size: usize,
/// The maximum number of elements in the table.
pub maximum: Option<usize>,
}
@@ -66,7 +78,9 @@ pub enum TableElementType {
/// WebAssembly linear memory.
#[derive(Debug,Clone,Copy)]
pub struct Memory {
/// The minimum number of pages in the memory.
pub pages_count: usize,
/// The maximum number of pages in the memory.
pub maximum: Option<usize>,
}