2019-01-09 06:06:24 +00:00
|
|
|
#[cfg(test)]
|
|
|
|
#[macro_use]
|
|
|
|
extern crate field_offset;
|
|
|
|
|
2019-01-08 17:09:47 +00:00
|
|
|
#[macro_use]
|
2019-01-21 22:43:04 +00:00
|
|
|
mod macros;
|
2019-01-13 03:02:19 +00:00
|
|
|
#[doc(hidden)]
|
2019-01-12 22:53:17 +00:00
|
|
|
pub mod backend;
|
2019-01-08 17:09:47 +00:00
|
|
|
mod backing;
|
2019-01-18 18:54:16 +00:00
|
|
|
pub mod error;
|
2019-01-12 22:53:17 +00:00
|
|
|
pub mod export;
|
|
|
|
pub mod import;
|
2019-01-11 16:10:21 +00:00
|
|
|
pub mod instance;
|
2019-01-12 22:53:17 +00:00
|
|
|
pub mod memory;
|
|
|
|
pub mod module;
|
2019-01-11 03:59:57 +00:00
|
|
|
mod sig_registry;
|
2019-01-16 18:26:10 +00:00
|
|
|
pub mod structures;
|
2019-01-21 19:51:41 +00:00
|
|
|
mod sys;
|
2019-01-09 06:06:24 +00:00
|
|
|
pub mod table;
|
2019-01-08 17:09:47 +00:00
|
|
|
pub mod types;
|
|
|
|
pub mod vm;
|
2019-01-13 03:02:19 +00:00
|
|
|
#[doc(hidden)]
|
2019-01-08 17:09:47 +00:00
|
|
|
pub mod vmcalls;
|
|
|
|
|
2019-01-18 18:54:16 +00:00
|
|
|
use self::error::CompileResult;
|
2019-01-18 19:15:13 +00:00
|
|
|
pub use self::error::Result;
|
2019-01-12 22:52:14 +00:00
|
|
|
pub use self::instance::Instance;
|
2019-01-13 03:02:19 +00:00
|
|
|
#[doc(inline)]
|
|
|
|
pub use self::module::Module;
|
|
|
|
use std::rc::Rc;
|
2019-01-08 17:09:47 +00:00
|
|
|
|
2019-01-21 22:43:04 +00:00
|
|
|
pub mod prelude {
|
|
|
|
pub use crate::export_func;
|
|
|
|
pub use crate::import::{ImportObject, Namespace};
|
|
|
|
pub use crate::types::{
|
|
|
|
FuncIndex, GlobalIndex, ImportedFuncIndex, ImportedGlobalIndex, ImportedMemoryIndex,
|
|
|
|
ImportedTableIndex, LocalFuncIndex, LocalGlobalIndex, LocalMemoryIndex, LocalTableIndex,
|
|
|
|
MemoryIndex, TableIndex, Type, Value,
|
|
|
|
};
|
|
|
|
pub use crate::vm;
|
|
|
|
}
|
|
|
|
|
2019-01-08 17:09:47 +00:00
|
|
|
/// Compile a webassembly module using the provided compiler.
|
2019-01-18 18:54:16 +00:00
|
|
|
pub fn compile(wasm: &[u8], compiler: &dyn backend::Compiler) -> CompileResult<module::Module> {
|
2019-01-18 20:13:01 +00:00
|
|
|
let token = backend::Token::generate();
|
2019-01-13 03:02:19 +00:00
|
|
|
compiler
|
2019-01-18 20:13:01 +00:00
|
|
|
.compile(wasm, token)
|
2019-01-13 03:02:19 +00:00
|
|
|
.map(|inner| module::Module::new(Rc::new(inner)))
|
2019-01-09 02:57:28 +00:00
|
|
|
}
|