From f50486f9adf7f771bb9744c80847a7c57d2ddde7 Mon Sep 17 00:00:00 2001 From: nekevss Date: Mon, 11 Sep 2023 19:01:03 -0400 Subject: [PATCH] Post rebase fixes and updates --- boa_engine/src/bigint.rs | 18 ------------------ .../src/builtins/temporal/calendar/mod.rs | 10 +++++----- boa_engine/src/builtins/temporal/mod.rs | 6 +++--- .../builtins/temporal/plain_date_time/mod.rs | 2 +- .../builtins/temporal/plain_month_day/mod.rs | 2 +- .../src/builtins/temporal/plain_time/mod.rs | 4 ++-- boa_engine/src/object/builtins/jspromise.rs | 4 ++-- 7 files changed, 14 insertions(+), 32 deletions(-) diff --git a/boa_engine/src/bigint.rs b/boa_engine/src/bigint.rs index accc98960ba..27f1e3af8c7 100644 --- a/boa_engine/src/bigint.rs +++ b/boa_engine/src/bigint.rs @@ -437,24 +437,6 @@ impl From for JsBigInt { } } -impl From for JsBigInt { - #[inline] - fn from(value: u128) -> Self { - Self { - inner: Rc::new(RawBigInt::from(value)), - } - } -} - -impl From for JsBigInt { - #[inline] - fn from(value: i128) -> Self { - Self { - inner: Rc::new(RawBigInt::from(value)), - } - } -} - /// The error indicates that the conversion from [`f64`] to [`JsBigInt`] failed. #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)] pub struct TryFromF64Error; diff --git a/boa_engine/src/builtins/temporal/calendar/mod.rs b/boa_engine/src/builtins/temporal/calendar/mod.rs index 019c73e248c..b2a4f454c7f 100644 --- a/boa_engine/src/builtins/temporal/calendar/mod.rs +++ b/boa_engine/src/builtins/temporal/calendar/mod.rs @@ -71,11 +71,11 @@ pub trait BuiltinCalendar { fn days_in_year(&self, args: &[JsValue], context: &mut Context<'_>) -> JsResult; /// Returns the months in a year for a given calendar. fn months_in_year(&self, args: &[JsValue], context: &mut Context<'_>) -> JsResult; - /// TODO: Docs + /// Returns whether a value is within a leap year according to the designated calendar. fn in_leap_year(&self, args: &[JsValue], context: &mut Context<'_>) -> JsResult; - /// TODO: Docs + /// Returns the fields of the implemented calendar fn fields(&self, args: &[JsValue], context: &mut Context<'_>) -> JsResult; - /// TODO: Docs + /// Merges provided fields. fn merge_fields(&self, args: &[JsValue], context: &mut Context<'_>) -> JsResult; } @@ -896,9 +896,9 @@ pub(crate) fn calendar_fields( )?; // 3. Let iteratorRecord be ? GetIterator(fieldsArray, sync). - let iterator_record = fields_array.get_iterator(context, Some(IteratorHint::Sync), None)?; + let mut iterator_record = fields_array.get_iterator(context, Some(IteratorHint::Sync), None)?; // 4. Return ? IteratorToListOfType(iteratorRecord, « String »). - super::iterator_to_list_of_types(&iterator_record, &[crate::value::Type::String], context) + super::iterator_to_list_of_types(&mut iterator_record, &[crate::value::Type::String], context) } /// 12.2.3 CalendarMergeFields ( calendar, fields, additionalFields ) diff --git a/boa_engine/src/builtins/temporal/mod.rs b/boa_engine/src/builtins/temporal/mod.rs index 99a88c44277..60704efc7b0 100644 --- a/boa_engine/src/builtins/temporal/mod.rs +++ b/boa_engine/src/builtins/temporal/mod.rs @@ -241,7 +241,7 @@ fn to_zero_padded_decimal_string(n: u64, min_length: usize) -> String { // TODO: 13.1 IteratorToListOfType pub(crate) fn iterator_to_list_of_types( - iterator: &IteratorRecord, + iterator: &mut IteratorRecord, element_types: &[Type], context: &mut Context<'_>, ) -> JsResult> { @@ -252,9 +252,9 @@ pub(crate) fn iterator_to_list_of_types( // 3. Repeat, while next is not false, // a. Set next to ? IteratorStep(iteratorRecord). // b. If next is not false, then - while let Some(next) = iterator.step(context)? { + while iterator.step(context)? { // i. Let nextValue be ? IteratorValue(next). - let next_value = next.value(context)?; + let next_value = iterator.value(context)?; // ii. If Type(nextValue) is not an element of elementTypes, then if element_types.contains(&next_value.get_type()) { // 1. Let completion be ThrowCompletion(a newly created TypeError object). diff --git a/boa_engine/src/builtins/temporal/plain_date_time/mod.rs b/boa_engine/src/builtins/temporal/plain_date_time/mod.rs index 189505d3b79..d5b638dfae4 100644 --- a/boa_engine/src/builtins/temporal/plain_date_time/mod.rs +++ b/boa_engine/src/builtins/temporal/plain_date_time/mod.rs @@ -53,7 +53,7 @@ impl BuiltInConstructor for PlainDateTime { args: &[JsValue], context: &mut Context<'_>, ) -> JsResult { - todo!() + Err(JsNativeError::range().with_message("Not yet implemented.").into()) } } diff --git a/boa_engine/src/builtins/temporal/plain_month_day/mod.rs b/boa_engine/src/builtins/temporal/plain_month_day/mod.rs index b5d8e440c2f..ec73ef48d6b 100644 --- a/boa_engine/src/builtins/temporal/plain_month_day/mod.rs +++ b/boa_engine/src/builtins/temporal/plain_month_day/mod.rs @@ -52,7 +52,7 @@ impl BuiltInConstructor for PlainMonthDay { args: &[JsValue], context: &mut Context<'_>, ) -> JsResult { - todo!() + Err(JsNativeError::range().with_message("Not yet implemented.").into()) } } diff --git a/boa_engine/src/builtins/temporal/plain_time/mod.rs b/boa_engine/src/builtins/temporal/plain_time/mod.rs index b7af0651091..781b98e22e8 100644 --- a/boa_engine/src/builtins/temporal/plain_time/mod.rs +++ b/boa_engine/src/builtins/temporal/plain_time/mod.rs @@ -4,7 +4,7 @@ use crate::{ context::intrinsics::{Intrinsics, StandardConstructor, StandardConstructors}, property::Attribute, realm::Realm, - Context, JsObject, JsResult, JsSymbol, JsValue, + Context, JsObject, JsResult, JsSymbol, JsValue, JsNativeError, }; use boa_profiler::Profiler; @@ -52,6 +52,6 @@ impl BuiltInConstructor for PlainTime { args: &[JsValue], context: &mut Context<'_>, ) -> JsResult { - todo!() + Err(JsNativeError::range().with_message("Not yet implemented.").into()) } } diff --git a/boa_engine/src/object/builtins/jspromise.rs b/boa_engine/src/object/builtins/jspromise.rs index edb7a865950..294651ca7db 100644 --- a/boa_engine/src/object/builtins/jspromise.rs +++ b/boa_engine/src/object/builtins/jspromise.rs @@ -966,7 +966,7 @@ impl JsPromise { let state = state.clone(); FunctionObjectBuilder::new( - context, + context.realm().clone(), NativeFunction::from_copy_closure_with_captures( move |_, args, state, _| { finish(state, Ok(args.get_or_undefined(0).clone())); @@ -982,7 +982,7 @@ impl JsPromise { let state = state.clone(); FunctionObjectBuilder::new( - context, + context.realm().clone(), NativeFunction::from_copy_closure_with_captures( move |_, args, state, _| { let err = JsError::from_opaque(args.get_or_undefined(0).clone());