2017-05-03 11:06:26 +03:00
|
|
|
mod basics;
|
2017-12-12 15:34:59 +01:00
|
|
|
mod wabt;
|
2017-12-12 15:40:54 +01:00
|
|
|
mod wasm;
|
2017-11-28 17:48:50 +03:00
|
|
|
|
|
|
|
mod utils {
|
|
|
|
use elements::{Internal, ExportEntry, InitExpr, Opcode, ValueType, GlobalType, GlobalEntry};
|
|
|
|
use interpreter::ProgramInstance;
|
|
|
|
use builder::module;
|
|
|
|
|
|
|
|
pub fn program_with_default_env() -> ProgramInstance {
|
2017-12-12 15:18:35 +01:00
|
|
|
let mut program = ProgramInstance::new();
|
2017-11-28 17:48:50 +03:00
|
|
|
let env_module = module()
|
|
|
|
.memory()
|
|
|
|
.with_min(256) // 256 pages. 256 * 64K = 16MB
|
|
|
|
.build()
|
|
|
|
.with_export(ExportEntry::new("memory".into(), Internal::Memory(0)))
|
|
|
|
.table()
|
|
|
|
.with_min(64)
|
|
|
|
.build()
|
|
|
|
.with_export(ExportEntry::new("table".into(), Internal::Table(0)))
|
2017-12-01 20:27:33 +03:00
|
|
|
.with_global(GlobalEntry::new(GlobalType::new(ValueType::I32, false), InitExpr::new(vec![Opcode::I32Const(0), Opcode::End])))
|
2017-11-28 17:48:50 +03:00
|
|
|
.with_export(ExportEntry::new("tableBase".into(), Internal::Global(0)))
|
2017-12-01 20:27:33 +03:00
|
|
|
.with_global(GlobalEntry::new(GlobalType::new(ValueType::I32, false), InitExpr::new(vec![Opcode::I32Const(0), Opcode::End])))
|
2017-11-28 17:48:50 +03:00
|
|
|
.with_export(ExportEntry::new("memoryBase".into(), Internal::Global(1)))
|
|
|
|
.build();
|
2017-12-12 15:18:35 +01:00
|
|
|
program.add_module("env", env_module, &mut ()).unwrap();
|
2017-11-28 17:48:50 +03:00
|
|
|
program
|
|
|
|
}
|
|
|
|
}
|