rename PassiveElemIndex to ElemIndex and same for PassiveDataIndex (#1188)

* rename PassiveElemIndex to ElemIndex and same for PassiveDataIndex (#1411)

* rename PassiveDataIndex to DataIndex

* rename PassiveElemIndex to ElemIndex

* Apply renamings to wasmtime as well

* Run rustfmt

Co-authored-by: csmoe <csmoe@msn.com>
This commit is contained in:
Alex Crichton
2020-03-02 08:55:25 -06:00
committed by GitHub
parent 2c5be49af0
commit 8597930eed
10 changed files with 37 additions and 42 deletions

View File

@@ -11,8 +11,8 @@ use crate::environ::{
use crate::func_translator::FuncTranslator;
use crate::state::ModuleTranslationState;
use crate::translation_utils::{
DefinedFuncIndex, FuncIndex, Global, GlobalIndex, Memory, MemoryIndex, PassiveDataIndex,
PassiveElemIndex, SignatureIndex, Table, TableIndex,
DataIndex, DefinedFuncIndex, ElemIndex, FuncIndex, Global, GlobalIndex, Memory, MemoryIndex,
SignatureIndex, Table, TableIndex,
};
use core::convert::TryFrom;
use cranelift_codegen::cursor::FuncCursor;
@@ -607,7 +607,7 @@ impl<'data> ModuleEnvironment<'data> for DummyEnvironment {
fn declare_passive_element(
&mut self,
_elem_index: PassiveElemIndex,
_elem_index: ElemIndex,
_segments: Box<[FuncIndex]>,
) -> WasmResult<()> {
Ok(())
@@ -615,7 +615,7 @@ impl<'data> ModuleEnvironment<'data> for DummyEnvironment {
fn declare_passive_data(
&mut self,
_elem_index: PassiveDataIndex,
_elem_index: DataIndex,
_segments: &'data [u8],
) -> WasmResult<()> {
Ok(())

View File

@@ -8,8 +8,8 @@
use crate::state::{FuncTranslationState, ModuleTranslationState};
use crate::translation_utils::{
FuncIndex, Global, GlobalIndex, Memory, MemoryIndex, PassiveDataIndex, PassiveElemIndex,
SignatureIndex, Table, TableIndex,
DataIndex, ElemIndex, FuncIndex, Global, GlobalIndex, Memory, MemoryIndex, SignatureIndex,
Table, TableIndex,
};
use core::convert::From;
use cranelift_codegen::cursor::FuncCursor;
@@ -606,7 +606,7 @@ pub trait ModuleEnvironment<'data>: TargetEnvironment {
/// Declare a passive element segment.
fn declare_passive_element(
&mut self,
index: PassiveElemIndex,
index: ElemIndex,
elements: Box<[FuncIndex]>,
) -> WasmResult<()>;
@@ -620,11 +620,7 @@ pub trait ModuleEnvironment<'data>: TargetEnvironment {
}
/// Declare a passive data segment.
fn declare_passive_data(
&mut self,
data_index: PassiveDataIndex,
data: &'data [u8],
) -> WasmResult<()>;
fn declare_passive_data(&mut self, data_index: DataIndex, data: &'data [u8]) -> WasmResult<()>;
/// Provides the contents of a function body.
///

View File

@@ -66,9 +66,9 @@ pub use crate::module_translator::translate_module;
pub use crate::state::func_state::FuncTranslationState;
pub use crate::state::module_state::ModuleTranslationState;
pub use crate::translation_utils::{
get_vmctx_value_label, DefinedFuncIndex, DefinedGlobalIndex, DefinedMemoryIndex,
DefinedTableIndex, FuncIndex, Global, GlobalIndex, GlobalInit, Memory, MemoryIndex,
PassiveDataIndex, PassiveElemIndex, SignatureIndex, Table, TableElementType, TableIndex,
get_vmctx_value_label, DataIndex, DefinedFuncIndex, DefinedGlobalIndex, DefinedMemoryIndex,
DefinedTableIndex, ElemIndex, FuncIndex, Global, GlobalIndex, GlobalInit, Memory, MemoryIndex,
SignatureIndex, Table, TableElementType, TableIndex,
};
/// Version number of this crate.

View File

@@ -10,9 +10,8 @@
use crate::environ::{ModuleEnvironment, WasmError, WasmResult};
use crate::state::ModuleTranslationState;
use crate::translation_utils::{
tabletype_to_type, type_to_type, FuncIndex, Global, GlobalIndex, GlobalInit, Memory,
MemoryIndex, PassiveDataIndex, PassiveElemIndex, SignatureIndex, Table, TableElementType,
TableIndex,
tabletype_to_type, type_to_type, DataIndex, ElemIndex, FuncIndex, Global, GlobalIndex,
GlobalInit, Memory, MemoryIndex, SignatureIndex, Table, TableElementType, TableIndex,
};
use crate::{wasm_unsupported, HashMap};
use core::convert::TryFrom;
@@ -345,7 +344,7 @@ pub fn parse_element_section<'data>(
)?
}
ElementKind::Passive => {
let index = PassiveElemIndex::from_u32(index as u32);
let index = ElemIndex::from_u32(index as u32);
environ.declare_passive_element(index, segments)?;
}
ElementKind::Declared => return Err(wasm_unsupported!("element kind declared")),
@@ -404,7 +403,7 @@ pub fn parse_data_section<'data>(
)?;
}
DataKind::Passive => {
let index = PassiveDataIndex::from_u32(index as u32);
let index = DataIndex::from_u32(index as u32);
environ.declare_passive_data(index, data)?;
}
}

View File

@@ -59,13 +59,13 @@ entity_impl!(SignatureIndex);
/// Index type of a passive data segment inside the WebAssembly module.
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)]
pub struct PassiveDataIndex(u32);
entity_impl!(PassiveDataIndex);
pub struct DataIndex(u32);
entity_impl!(DataIndex);
/// Index type of a passive element segment inside the WebAssembly module.
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)]
pub struct PassiveElemIndex(u32);
entity_impl!(PassiveElemIndex);
pub struct ElemIndex(u32);
entity_impl!(ElemIndex);
/// WebAssembly global.
#[derive(Debug, Clone, Copy, Hash)]