diff --git a/language/move-vm/runtime/src/loader.rs b/language/move-vm/runtime/src/loader.rs index 3b43e2d1d7..2e786ea837 100644 --- a/language/move-vm/runtime/src/loader.rs +++ b/language/move-vm/runtime/src/loader.rs @@ -935,7 +935,7 @@ impl Loader { pub(crate) fn load_type( &self, type_tag: &TypeTag, - data_store: &impl DataStore, + data_store: &(impl DataStore + ?Sized), ) -> VMResult { Ok(match type_tag { TypeTag::Bool => Type::Bool, @@ -977,7 +977,7 @@ impl Loader { pub(crate) fn load_module( &self, id: &ModuleId, - data_store: &impl DataStore, + data_store: &(impl DataStore + ?Sized), ) -> VMResult> { self.load_module_internal(id, &BTreeMap::new(), &BTreeSet::new(), data_store) } @@ -989,7 +989,7 @@ impl Loader { id: &ModuleId, bundle_verified: &BTreeMap, bundle_unverified: &BTreeSet, - data_store: &impl DataStore, + data_store: &(impl DataStore + ?Sized), ) -> VMResult> { // if the module is already in the code cache, load the cached version if let Some(cached) = self.module_cache.read().module_at(id) { @@ -1021,7 +1021,7 @@ impl Loader { fn load_and_verify_module( &self, id: &ModuleId, - data_store: &impl DataStore, + data_store: &(impl DataStore + ?Sized), allow_loading_failure: bool, ) -> VMResult { // bytes fetching, allow loading to fail if the flag is set @@ -1072,7 +1072,7 @@ impl Loader { &self, id: &ModuleId, bundle_verified: &BTreeMap, - data_store: &impl DataStore, + data_store: &(impl DataStore + ?Sized), visited: &mut BTreeSet, friends_discovered: &mut BTreeSet, allow_module_loading_failure: bool, @@ -1114,7 +1114,7 @@ impl Loader { &self, module: &CompiledModule, bundle_verified: &BTreeMap, - data_store: &impl DataStore, + data_store: &(impl DataStore + ?Sized), visited: &mut BTreeSet, friends_discovered: &mut BTreeSet, allow_dependency_loading_failure: bool, @@ -1183,7 +1183,7 @@ impl Loader { id: &ModuleId, bundle_verified: &BTreeMap, bundle_unverified: &BTreeSet, - data_store: &impl DataStore, + data_store: &(impl DataStore + ?Sized), allow_module_loading_failure: bool, dependencies_depth: usize, ) -> VMResult> { @@ -1220,7 +1220,7 @@ impl Loader { friends_discovered: BTreeSet, bundle_verified: &BTreeMap, bundle_unverified: &BTreeSet, - data_store: &impl DataStore, + data_store: &(impl DataStore + ?Sized), allow_friend_loading_failure: bool, dependencies_depth: usize, ) -> VMResult<()> { @@ -2829,7 +2829,7 @@ impl Loader { pub(crate) fn get_type_layout( &self, type_tag: &TypeTag, - move_storage: &impl DataStore, + move_storage: &(impl DataStore + ?Sized), ) -> VMResult { let ty = self.load_type(type_tag, move_storage)?; self.type_to_type_layout(&ty) @@ -2839,7 +2839,7 @@ impl Loader { pub(crate) fn get_fully_annotated_type_layout( &self, type_tag: &TypeTag, - move_storage: &impl DataStore, + move_storage: &(impl DataStore + ?Sized), ) -> VMResult { let ty = self.load_type(type_tag, move_storage)?; self.type_to_fully_annotated_layout(&ty) diff --git a/language/move-vm/runtime/src/native_functions.rs b/language/move-vm/runtime/src/native_functions.rs index 42f7c41437..90e535b299 100644 --- a/language/move-vm/runtime/src/native_functions.rs +++ b/language/move-vm/runtime/src/native_functions.rs @@ -5,7 +5,7 @@ use crate::{ interpreter::Interpreter, loader::Resolver, native_extensions::NativeContextExtensions, }; -use move_binary_format::errors::{ExecutionState, PartialVMError, PartialVMResult}; +use move_binary_format::errors::{ExecutionState, PartialVMError, PartialVMResult, VMResult}; use move_core_types::{ account_address::AccountAddress, gas_algebra::InternalGas, @@ -140,6 +140,22 @@ impl<'a, 'b> NativeContext<'a, 'b> { self.data_store.events() } + pub fn load_type(&self, type_tag: &TypeTag) -> VMResult { + self.resolver.loader().load_type(type_tag, self.data_store) + } + + pub fn get_type_layout(&self, type_tag: &TypeTag) -> VMResult { + self.resolver + .loader() + .get_type_layout(type_tag, self.data_store) + } + + pub fn get_fully_annotated_type_layout(&self, type_tag: &TypeTag) -> VMResult { + self.resolver + .loader() + .get_fully_annotated_type_layout(type_tag, self.data_store) + } + pub fn type_to_type_tag(&self, ty: &Type) -> PartialVMResult { self.resolver.loader().type_to_type_tag(ty) } diff --git a/language/move-vm/runtime/src/session.rs b/language/move-vm/runtime/src/session.rs index 7addfdb51b..cbaa2d34ed 100644 --- a/language/move-vm/runtime/src/session.rs +++ b/language/move-vm/runtime/src/session.rs @@ -331,7 +331,12 @@ impl<'r, 'l, S: MoveResolver> Session<'r, 'l, S> { } /// Gets the underlying native extensions. - pub fn get_native_extensions(&mut self) -> &mut NativeContextExtensions<'r> { + pub fn get_native_extensions(&self) -> &NativeContextExtensions<'r> { + &self.native_extensions + } + + /// Gets the underlying native extensions as mut. + pub fn get_native_extensions_mut(&mut self) -> &mut NativeContextExtensions<'r> { &mut self.native_extensions } }