Consistently use u32 for program counter storage
This commit is contained in:
parent
f928cc8188
commit
bcc53cac90
|
@ -348,7 +348,7 @@ impl Instructions {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn iterate_from(&self, position: usize) -> InstructionIter {
|
||||
pub fn iterate_from(&self, position: u32) -> InstructionIter {
|
||||
InstructionIter{
|
||||
instructions: &self.vec,
|
||||
position,
|
||||
|
@ -358,12 +358,12 @@ impl Instructions {
|
|||
|
||||
pub struct InstructionIter<'a> {
|
||||
instructions: &'a [Instruction],
|
||||
position: usize,
|
||||
position: u32,
|
||||
}
|
||||
|
||||
impl<'a> InstructionIter<'a> {
|
||||
#[inline]
|
||||
pub fn position(&self) -> usize {
|
||||
pub fn position(&self) -> u32 {
|
||||
self.position
|
||||
}
|
||||
}
|
||||
|
@ -373,7 +373,7 @@ impl<'a> Iterator for InstructionIter<'a> {
|
|||
|
||||
#[inline]
|
||||
fn next(&mut self) -> Option<<Self as Iterator>::Item> {
|
||||
self.instructions.get(self.position).map(|instruction| {
|
||||
self.instructions.get(self.position as usize).map(|instruction| {
|
||||
self.position += 1;
|
||||
instruction
|
||||
})
|
||||
|
|
|
@ -241,7 +241,7 @@ impl Interpreter {
|
|||
function_context.position = iter.position();
|
||||
},
|
||||
InstructionOutcome::Branch(target) => {
|
||||
function_context.position = target.dst_pc as usize;
|
||||
function_context.position = target.dst_pc;
|
||||
iter = instructions.iterate_from(function_context.position);
|
||||
self.value_stack.drop_keep(target.drop_keep);
|
||||
},
|
||||
|
@ -1083,7 +1083,7 @@ struct FunctionContext {
|
|||
pub module: ModuleRef,
|
||||
pub memory: Option<MemoryRef>,
|
||||
/// Current instruction position.
|
||||
pub position: usize,
|
||||
pub position: u32,
|
||||
}
|
||||
|
||||
impl FunctionContext {
|
||||
|
|
Loading…
Reference in New Issue