Host module sketch

This commit is contained in:
Sergey Pepyakin
2017-12-11 16:28:05 +01:00
parent 31abb05009
commit 5920cd93d5
5 changed files with 190 additions and 39 deletions

View File

@ -4,6 +4,7 @@ use elements::Module;
use interpreter::Error;
use interpreter::module::{ExecutionParams};
use interpreter::store::{Store, ModuleId};
use interpreter::host::HostModuleBuilder;
/// Program instance. Program is a set of instantiated modules.
pub struct ProgramInstance {
@ -42,6 +43,10 @@ impl ProgramInstance {
Ok(module_id)
}
pub fn with_host_module<St: 'static>(&mut self, name: &str) -> HostModuleBuilder<St> {
HostModuleBuilder::new(&mut self.store)
}
/// Get one of the modules by name
pub fn module(&self, name: &str) -> Option<ModuleId> {
self.modules.get(name).cloned()