mirror of
https://github.com/fluencelabs/parity-wasm
synced 2025-05-17 01:31:29 +00:00
fixed InitExpr(Opcode::Global)
This commit is contained in:
parent
b57e6d5d98
commit
013ff25b97
@ -48,6 +48,7 @@ impl Deserialize for Opcodes {
|
||||
}
|
||||
|
||||
/// Initialization expression.
|
||||
#[derive(Debug)]
|
||||
pub struct InitExpr(Vec<Opcode>);
|
||||
|
||||
impl InitExpr {
|
||||
|
@ -28,11 +28,11 @@ impl ProgramInstance {
|
||||
|
||||
/// Instantiate module.
|
||||
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)?);
|
||||
let mut modules = self.essence.modules.write();
|
||||
match modules.entry(name.into()) {
|
||||
Entry::Occupied(_) => Err(Error::Program(format!("module {} already instantiated", name))),
|
||||
Entry::Vacant(entry) => {
|
||||
let module_instance = Arc::new(ModuleInstance::new(Arc::downgrade(&self.essence), module)?);
|
||||
entry.insert(module_instance.clone());
|
||||
Ok(module_instance)
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user