Skip to content

Commit

Permalink
small refactor multiversx#3
Browse files Browse the repository at this point in the history
  • Loading branch information
ovstinga authored and camilbancioiu committed Oct 4, 2022
1 parent b398962 commit 347b2d9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/runtime-core/src/backing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use crate::{
table::Table,
typed_func::{always_trap, Func},
types::{
ImportedFuncIndex, ImportedGlobalIndex, ImportedMemoryIndex, ImportedTableIndex,
Initializer, LocalFuncIndex, LocalGlobalIndex, LocalMemoryIndex, LocalOrImport,
LocalTableIndex, SigIndex, Value,
GlobalInit, ImportedFuncIndex, ImportedGlobalIndex, ImportedMemoryIndex,
ImportedTableIndex, Initializer, LocalFuncIndex, LocalGlobalIndex, LocalMemoryIndex,
LocalOrImport, LocalTableIndex, SigIndex, Value,
},
vm,
};
Expand Down Expand Up @@ -159,14 +159,16 @@ impl LocalBacking {
globals: &mut SliceMap<LocalGlobalIndex, Global>,
) -> RuntimeResult<()> {
for (index, global_init) in module_info.globals.iter() {
let value = match &global_init.init {
let GlobalInit { desc, init } = global_init;

let value = match init {
Initializer::Const(value) => value.clone(),
Initializer::GetGlobal(_index) => {
return Err(RuntimeError(Box::new("Initializer is not supported")))
}
};

if global_init.desc.mutable {
if desc.mutable {
match globals.get_mut(index) {
Some(global) => global.set(value),
None => return Err(RuntimeError(Box::new("Undefined global"))),
Expand Down

0 comments on commit 347b2d9

Please sign in to comment.