Skip to content
This repository has been archived by the owner on May 4, 2024. It is now read-only.

[session] Expose type_to_type_tag #728

Merged
merged 2 commits into from
Dec 8, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions language/move-vm/runtime/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,13 @@ impl<'r, 'l, S: MoveResolver> Session<'r, 'l, S> {
.get_fully_annotated_type_layout(type_tag, &self.data_cache)
}

pub fn get_type_tag(&self, ty: &Type) -> VMResult<TypeTag> {
self.runtime
.loader()
.type_to_type_tag(ty)
.map_err(|e| e.finish(Location::Undefined))
}

/// Fetch a struct type from cache, if the index is in bounds
/// Helpful when paired with load_type, or any other API that returns 'Type'
pub fn get_struct_type(&self, index: CachedStructIndex) -> Option<Arc<StructType>> {
Expand Down