instructions validator

This commit is contained in:
Svyatoslav Nikolsky
2017-06-07 14:48:02 +03:00
parent 9e73505541
commit f0ecdc5af2
11 changed files with 707 additions and 37 deletions

View File

@ -31,7 +31,7 @@ impl ProgramInstance {
})
}
/// Instantiate module.
/// Instantiate module with validation.
pub fn add_module(&self, name: &str, module: Module) -> Result<Arc<ModuleInstance>, Error> {
let module_instance = Arc::new(ModuleInstance::new(Arc::downgrade(&self.essence), module)?);
// replace existing module with the same name with new one
@ -39,6 +39,14 @@ impl ProgramInstance {
Ok(module_instance)
}
/// Instantiate module without validation.
pub fn add_module_without_validation(&self, name: &str, module: Module) -> Result<Arc<ModuleInstance>, Error> {
let module_instance = Arc::new(ModuleInstance::new_with_validation_flag(Arc::downgrade(&self.essence), module, false)?);
// replace existing module with the same name with new one
self.essence.modules.write().insert(name.into(), module_instance.clone());
Ok(module_instance)
}
/// Get one of the modules by name
pub fn module(&self, name: &str) -> Option<Arc<ModuleInstanceInterface>> {
self.essence.module(name)