From ef3a4c6306815dd368034bd670866ac3e7c8928b Mon Sep 17 00:00:00 2001 From: jedel1043 Date: Tue, 6 Jun 2023 12:57:42 -0600 Subject: [PATCH] Change `usize` to `u32` --- boa_engine/src/vm/call_frame/env_stack.rs | 6 +++--- boa_engine/src/vm/opcode/control_flow/throw.rs | 4 ++-- boa_engine/src/vm/opcode/iteration/loop_ops.rs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/boa_engine/src/vm/call_frame/env_stack.rs b/boa_engine/src/vm/call_frame/env_stack.rs index c440c6f4a35..95b1ed71318 100644 --- a/boa_engine/src/vm/call_frame/env_stack.rs +++ b/boa_engine/src/vm/call_frame/env_stack.rs @@ -14,7 +14,7 @@ pub(crate) enum EnvEntryKind { value: JsValue, /// The index of the currently active iterator. - iterator: Option, + iterator: Option, }, Try, Catch, @@ -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(), @@ -166,7 +166,7 @@ impl EnvStackEntry { } /// Returns the active iterator index if `EnvStackEntry` is an iterator loop. - pub(crate) const fn iterator(&self) -> Option { + pub(crate) const fn iterator(&self) -> Option { if let EnvEntryKind::Loop { iterator, .. } = self.kind { return iterator; } diff --git a/boa_engine/src/vm/opcode/control_flow/throw.rs b/boa_engine/src/vm/opcode/control_flow/throw.rs index 3d1952739fb..fd466104d2e 100644 --- a/boa_engine/src/vm/opcode/control_flow/throw.rs +++ b/boa_engine/src/vm/opcode/control_flow/throw.rs @@ -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)); @@ -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)); diff --git a/boa_engine/src/vm/opcode/iteration/loop_ops.rs b/boa_engine/src/vm/opcode/iteration/loop_ops.rs index 84c01a1150a..dee19bac825 100644 --- a/boa_engine/src/vm/opcode/iteration/loop_ops.rs +++ b/boa_engine/src/vm/opcode/iteration/loop_ops.rs @@ -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) }