Get rid of elements stuff in GlobalInstance API

This commit is contained in:
Sergey Pepyakin 2018-01-10 15:29:20 +03:00
parent 721b24442a
commit dbab8f5673
2 changed files with 7 additions and 4 deletions

View File

@ -1,6 +1,6 @@
use std::rc::Rc; use std::rc::Rc;
use std::cell::Cell; use std::cell::Cell;
use elements::{ValueType, GlobalType}; use elements::ValueType;
use interpreter::value::RuntimeValue; use interpreter::value::RuntimeValue;
use interpreter::Error; use interpreter::Error;
@ -22,8 +22,8 @@ pub struct GlobalInstance {
impl GlobalInstance { impl GlobalInstance {
pub fn alloc(global_type: &GlobalType, val: RuntimeValue) -> GlobalRef { pub fn alloc(val: RuntimeValue, mutable: bool) -> GlobalRef {
let global = GlobalInstance::new(val, global_type.is_mutable()); let global = GlobalInstance::new(val, mutable);
GlobalRef(Rc::new(global)) GlobalRef(Rc::new(global))
} }

View File

@ -259,7 +259,10 @@ impl ModuleInstance {
) )
{ {
let init_val = eval_init_expr(global_entry.init_expr(), &*instance); let init_val = eval_init_expr(global_entry.init_expr(), &*instance);
let global = GlobalInstance::alloc(global_entry.global_type(), init_val); let global = GlobalInstance::alloc(
init_val,
global_entry.global_type().is_mutable(),
);
instance.push_global(global); instance.push_global(global);
} }