Skip to content

Commit

Permalink
Change usize to u32
Browse files Browse the repository at this point in the history
  • Loading branch information
jedel1043 committed Jun 6, 2023
1 parent 63f38e8 commit ef3a4c6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions boa_engine/src/vm/call_frame/env_stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub(crate) enum EnvEntryKind {
value: JsValue,

/// The index of the currently active iterator.
iterator: Option<usize>,
iterator: Option<u32>,
},
Try,
Catch,
Expand Down Expand Up @@ -76,7 +76,7 @@ impl EnvStackEntry {

/// Returns calling `EnvStackEntry` with `kind` field of `Loop`, loop iteration set to zero
/// and iterator index set to `iterator`.
pub(crate) fn with_iterator_loop_flag(mut self, iteration_count: u64, iterator: usize) -> Self {
pub(crate) fn with_iterator_loop_flag(mut self, iteration_count: u64, iterator: u32) -> Self {
self.kind = EnvEntryKind::Loop {
iteration_count,
value: JsValue::undefined(),
Expand Down Expand Up @@ -166,7 +166,7 @@ impl EnvStackEntry {
}

/// Returns the active iterator index if `EnvStackEntry` is an iterator loop.
pub(crate) const fn iterator(&self) -> Option<usize> {
pub(crate) const fn iterator(&self) -> Option<u32> {
if let EnvEntryKind::Loop { iterator, .. } = self.kind {
return iterator;
}
Expand Down
4 changes: 2 additions & 2 deletions boa_engine/src/vm/opcode/control_flow/throw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl Operation for Throw {
.vm
.frame_mut()
.iterators
.split_off(active_iterator + 1);
.split_off(active_iterator as usize + 1);
for iterator in inactive {
if !iterator.done() {
drop(iterator.close(Ok(JsValue::undefined()), context));
Expand Down Expand Up @@ -146,7 +146,7 @@ impl Operation for Throw {
.vm
.frame_mut()
.iterators
.split_off(active_iterator + 1);
.split_off(active_iterator as usize + 1);
for iterator in inactive {
if !iterator.done() {
drop(iterator.close(Ok(JsValue::undefined()), context));
Expand Down
2 changes: 1 addition & 1 deletion boa_engine/src/vm/opcode/iteration/loop_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl Operation for IteratorLoopStart {

// Create and push loop evironment entry.
let entry = EnvStackEntry::new(start, exit)
.with_iterator_loop_flag(1, context.vm.frame().iterators.len() - 1);
.with_iterator_loop_flag(1, (context.vm.frame().iterators.len() - 1) as u32);
context.vm.frame_mut().env_stack.push(entry);
Ok(CompletionType::Normal)
}
Expand Down

0 comments on commit ef3a4c6

Please sign in to comment.