Make globals non leaking

This commit is contained in:
Syrus
2020-05-04 13:10:22 -07:00
parent 0885cb5c95
commit c24c5c6946
6 changed files with 26 additions and 35 deletions

View File

@@ -113,15 +113,10 @@ impl Global {
Self::from_type(store, GlobalType::new(val.ty(), Mutability::Var), val).unwrap()
}
pub fn from_type(store: &Store, ty: GlobalType, val: Val) -> Result<Global, RuntimeError> {
fn from_type(store: &Store, ty: GlobalType, val: Val) -> Result<Global, RuntimeError> {
if !val.comes_from_same_store(store) {
return Err(RuntimeError::new("cross-`Store` globals are not supported"));
}
if val.ty() != ty.ty.clone() {
return Err(RuntimeError::new(
"value provided does not match the type of this global",
));
}
let mut definition = VMGlobalDefinition::new();
unsafe {
match val {