mirror of
https://github.com/fluencelabs/parity-wasm
synced 2025-05-17 09:41:34 +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.
|
/// Initialization expression.
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct InitExpr(Vec<Opcode>);
|
pub struct InitExpr(Vec<Opcode>);
|
||||||
|
|
||||||
impl InitExpr {
|
impl InitExpr {
|
||||||
|
@ -28,11 +28,11 @@ impl ProgramInstance {
|
|||||||
|
|
||||||
/// Instantiate module.
|
/// Instantiate module.
|
||||||
pub fn add_module(&self, name: &str, module: Module) -> Result<Arc<ModuleInstance>, Error> {
|
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();
|
let mut modules = self.essence.modules.write();
|
||||||
match modules.entry(name.into()) {
|
match modules.entry(name.into()) {
|
||||||
Entry::Occupied(_) => Err(Error::Program(format!("module {} already instantiated", name))),
|
Entry::Occupied(_) => Err(Error::Program(format!("module {} already instantiated", name))),
|
||||||
Entry::Vacant(entry) => {
|
Entry::Vacant(entry) => {
|
||||||
let module_instance = Arc::new(ModuleInstance::new(Arc::downgrade(&self.essence), module)?);
|
|
||||||
entry.insert(module_instance.clone());
|
entry.insert(module_instance.clone());
|
||||||
Ok(module_instance)
|
Ok(module_instance)
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user