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