Move Webassembly objects to Store and remove Context

Co-authored-by: ptitSeb <sebastien.chev@gmail.com>
Co-authored-by: Manos Pitsidianakis <manos@wasmer.io>
This commit is contained in:
Syrus Akbary
2022-07-08 15:33:29 -07:00
committed by Manos Pitsidianakis
parent b5ae6399ce
commit a419ccdf52
214 changed files with 5800 additions and 5759 deletions

View File

@@ -8,10 +8,10 @@ pub use self::global::Global;
pub use self::memory::{Memory, MemoryError};
pub use self::table::Table;
use crate::js::context::{AsContextMut, AsContextRef};
use crate::js::export::Export;
use crate::js::exports::{ExportError, Exportable};
use crate::js::store::StoreObject;
use crate::js::store::{AsStoreMut, AsStoreRef};
use crate::js::types::AsJs;
use crate::js::ExternType;
use std::fmt;
@@ -34,7 +34,7 @@ pub enum Extern {
impl Extern {
/// Return the underlying type of the inner `Extern`.
pub fn ty(&self, ctx: &impl AsContextRef) -> ExternType {
pub fn ty(&self, ctx: &impl AsStoreRef) -> ExternType {
match self {
Self::Function(ft) => ExternType::Function(ft.ty(ctx).clone()),
Self::Memory(ft) => ExternType::Memory(ft.ty(ctx)),
@@ -44,7 +44,7 @@ impl Extern {
}
/// Create an `Extern` from an `wasmer_compiler::Export`.
pub fn from_vm_export(ctx: &mut impl AsContextMut, export: Export) -> Self {
pub fn from_vm_export(ctx: &mut impl AsStoreMut, export: Export) -> Self {
match export {
Export::Function(f) => Self::Function(Function::from_vm_extern(ctx, f)),
Export::Memory(m) => Self::Memory(Memory::from_vm_extern(ctx, m)),
@@ -54,12 +54,12 @@ impl Extern {
}
/// Checks whether this `Extern` can be used with the given context.
pub fn is_from_context(&self, ctx: &impl AsContextRef) -> bool {
pub fn is_from_store(&self, ctx: &impl AsStoreRef) -> bool {
match self {
Self::Function(val) => val.is_from_context(ctx),
Self::Memory(val) => val.is_from_context(ctx),
Self::Global(val) => val.is_from_context(ctx),
Self::Table(val) => val.is_from_context(ctx),
Self::Function(val) => val.is_from_store(ctx),
Self::Memory(val) => val.is_from_store(ctx),
Self::Global(val) => val.is_from_store(ctx),
Self::Table(val) => val.is_from_store(ctx),
}
}
@@ -74,7 +74,7 @@ impl Extern {
}
impl AsJs for Extern {
fn as_jsvalue(&self, ctx: &impl AsContextRef) -> wasm_bindgen::JsValue {
fn as_jsvalue(&self, ctx: &impl AsStoreRef) -> wasm_bindgen::JsValue {
match self {
Self::Function(_) => self.to_export().as_jsvalue(ctx),
Self::Global(_) => self.to_export().as_jsvalue(ctx),