Tidy up redundant conversions.
This commit is contained in:
@@ -346,10 +346,11 @@ impl VMOffsets {
|
||||
|
||||
/// Return the offset to `VMSharedSignatureId` index `index`.
|
||||
pub fn vmctx_vmshared_signature_id(&self, index: SignatureIndex) -> u32 {
|
||||
assert!(u32::from(index.as_u32()) < self.num_signature_ids);
|
||||
assert!(index.as_u32() < self.num_signature_ids);
|
||||
self.vmctx_signature_ids_begin()
|
||||
.checked_add(
|
||||
u32::from(index.as_u32())
|
||||
index
|
||||
.as_u32()
|
||||
.checked_mul(u32::from(self.size_of_vmshared_signature_index()))
|
||||
.unwrap(),
|
||||
)
|
||||
@@ -358,10 +359,11 @@ impl VMOffsets {
|
||||
|
||||
/// Return the offset to `VMFunctionImport` index `index`.
|
||||
pub fn vmctx_vmfunction_import(&self, index: FuncIndex) -> u32 {
|
||||
assert!(u32::from(index.as_u32()) < self.num_imported_functions);
|
||||
assert!(index.as_u32() < self.num_imported_functions);
|
||||
self.vmctx_imported_functions_begin()
|
||||
.checked_add(
|
||||
u32::from(index.as_u32())
|
||||
index
|
||||
.as_u32()
|
||||
.checked_mul(u32::from(self.size_of_vmfunction_import()))
|
||||
.unwrap(),
|
||||
)
|
||||
@@ -370,10 +372,11 @@ impl VMOffsets {
|
||||
|
||||
/// Return the offset to `VMTableImport` index `index`.
|
||||
pub fn vmctx_vmtable_import(&self, index: TableIndex) -> u32 {
|
||||
assert!(u32::from(index.as_u32()) < self.num_imported_tables);
|
||||
assert!(index.as_u32() < self.num_imported_tables);
|
||||
self.vmctx_imported_tables_begin()
|
||||
.checked_add(
|
||||
u32::from(index.as_u32())
|
||||
index
|
||||
.as_u32()
|
||||
.checked_mul(u32::from(self.size_of_vmtable_import()))
|
||||
.unwrap(),
|
||||
)
|
||||
@@ -382,10 +385,11 @@ impl VMOffsets {
|
||||
|
||||
/// Return the offset to `VMMemoryImport` index `index`.
|
||||
pub fn vmctx_vmmemory_import(&self, index: MemoryIndex) -> u32 {
|
||||
assert!(u32::from(index.as_u32()) < self.num_imported_memories);
|
||||
assert!(index.as_u32() < self.num_imported_memories);
|
||||
self.vmctx_imported_memories_begin()
|
||||
.checked_add(
|
||||
u32::from(index.as_u32())
|
||||
index
|
||||
.as_u32()
|
||||
.checked_mul(u32::from(self.size_of_vmmemory_import()))
|
||||
.unwrap(),
|
||||
)
|
||||
@@ -394,10 +398,11 @@ impl VMOffsets {
|
||||
|
||||
/// Return the offset to `VMGlobalImport` index `index`.
|
||||
pub fn vmctx_vmglobal_import(&self, index: GlobalIndex) -> u32 {
|
||||
assert!(u32::from(index.as_u32()) < self.num_imported_globals);
|
||||
assert!(index.as_u32() < self.num_imported_globals);
|
||||
self.vmctx_imported_globals_begin()
|
||||
.checked_add(
|
||||
u32::from(index.as_u32())
|
||||
index
|
||||
.as_u32()
|
||||
.checked_mul(u32::from(self.size_of_vmglobal_import()))
|
||||
.unwrap(),
|
||||
)
|
||||
@@ -406,10 +411,11 @@ impl VMOffsets {
|
||||
|
||||
/// Return the offset to `VMTableDefinition` index `index`.
|
||||
pub fn vmctx_vmtable_definition(&self, index: DefinedTableIndex) -> u32 {
|
||||
assert!(u32::from(index.as_u32()) < self.num_defined_tables);
|
||||
assert!(index.as_u32() < self.num_defined_tables);
|
||||
self.vmctx_tables_begin()
|
||||
.checked_add(
|
||||
u32::from(index.as_u32())
|
||||
index
|
||||
.as_u32()
|
||||
.checked_mul(u32::from(self.size_of_vmtable_definition()))
|
||||
.unwrap(),
|
||||
)
|
||||
@@ -418,10 +424,11 @@ impl VMOffsets {
|
||||
|
||||
/// Return the offset to `VMMemoryDefinition` index `index`.
|
||||
pub fn vmctx_vmmemory_definition(&self, index: DefinedMemoryIndex) -> u32 {
|
||||
assert!(u32::from(index.as_u32()) < self.num_defined_memories);
|
||||
assert!(index.as_u32() < self.num_defined_memories);
|
||||
self.vmctx_memories_begin()
|
||||
.checked_add(
|
||||
u32::from(index.as_u32())
|
||||
index
|
||||
.as_u32()
|
||||
.checked_mul(u32::from(self.size_of_vmmemory_definition()))
|
||||
.unwrap(),
|
||||
)
|
||||
@@ -430,10 +437,11 @@ impl VMOffsets {
|
||||
|
||||
/// Return the offset to the `VMGlobalDefinition` index `index`.
|
||||
pub fn vmctx_vmglobal_definition(&self, index: DefinedGlobalIndex) -> u32 {
|
||||
assert!(u32::from(index.as_u32()) < self.num_defined_globals);
|
||||
assert!(index.as_u32() < self.num_defined_globals);
|
||||
self.vmctx_globals_begin()
|
||||
.checked_add(
|
||||
u32::from(index.as_u32())
|
||||
index
|
||||
.as_u32()
|
||||
.checked_mul(u32::from(self.size_of_vmglobal_definition()))
|
||||
.unwrap(),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user