Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace all u64/i64 for length, index or offsets into usize/isize #4083

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions cli/src/debug/limits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use boa_engine::{
js_string,
object::{FunctionObjectBuilder, ObjectInitializer},
property::Attribute,
Context, JsArgs, JsNativeError, JsObject, JsResult, JsValue, NativeFunction,
Context, JsArgs, JsObject, JsResult, JsValue, NativeFunction,
};

fn get_loop(_: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult<JsValue> {
Expand All @@ -12,7 +12,9 @@ fn get_loop(_: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult<JsVal

fn set_loop(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult<JsValue> {
let value = args.get_or_undefined(0).to_length(context)?;
context.runtime_limits_mut().set_loop_iteration_limit(value);
context
.runtime_limits_mut()
.set_loop_iteration_limit(value as u64);
Ok(JsValue::undefined())
}

Expand All @@ -23,11 +25,6 @@ fn get_stack(_: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult<JsVa

fn set_stack(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult<JsValue> {
let value = args.get_or_undefined(0).to_length(context)?;
let Ok(value) = value.try_into() else {
return Err(JsNativeError::range()
.with_message(format!("Argument {value} greater than usize::MAX"))
.into());
};
context.runtime_limits_mut().set_stack_size_limit(value);
Ok(JsValue::undefined())
}
Expand All @@ -39,11 +36,6 @@ fn get_recursion(_: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult<

fn set_recursion(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult<JsValue> {
let value = args.get_or_undefined(0).to_length(context)?;
let Ok(value) = value.try_into() else {
return Err(JsNativeError::range()
.with_message(format!("Argument {value} greater than usize::MAX"))
.into());
};
context.runtime_limits_mut().set_recursion_limit(value);
Ok(JsValue::undefined())
}
Expand Down
2 changes: 1 addition & 1 deletion core/engine/src/builtins/array/array_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use boa_profiler::Profiler;
#[derive(Debug, Clone, Finalize, Trace, JsData)]
pub(crate) struct ArrayIterator {
array: JsObject,
next_index: u64,
next_index: usize,
#[unsafe_ignore_trace]
kind: PropertyNameKind,
done: bool,
Expand Down
Loading
Loading