Skip to content

Commit

Permalink
Fixed Promises with the [[Done]] flag in iterators.
Browse files Browse the repository at this point in the history
Also upgraded dependencies, updated the Test262 and fixed a couple of
small spec implementations.
  • Loading branch information
Razican committed Jun 17, 2022
1 parent d382202 commit 7e043f7
Show file tree
Hide file tree
Showing 18 changed files with 130 additions and 100 deletions.
84 changes: 46 additions & 38 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion boa_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ boa_engine = { path = "../boa_engine", features = ["deser", "console"], version
boa_interner = { path = "../boa_interner", version = "0.15.0" }
rustyline = "9.1.2"
rustyline-derive = "0.6.0"
clap = { version = "3.1.18", features = ["derive"] }
clap = { version = "3.2.5", features = ["derive"] }
serde_json = "1.0.81"
colored = "2.0.0"
regex = "1.5.6"
Expand Down
4 changes: 2 additions & 2 deletions boa_engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ rustc-hash = "1.1.0"
num-bigint = { version = "0.4.3", features = ["serde"] }
num-integer = "0.1.45"
bitflags = "1.3.2"
indexmap = "1.8.2"
indexmap = "1.9.0"
ryu-js = "0.2.2"
chrono = "0.4.19"
fast-float = "0.2.0"
Expand All @@ -56,7 +56,7 @@ icu_datetime = { version = "0.6.0", features = ["serde"], optional = true }
icu_plurals = { version = "0.6.0", features = ["serde"], optional = true }
icu_provider = { version = "0.6.0", optional = true }
icu_testdata = { version = "0.6.0", optional = true }
sys-locale = { version = "0.2.0", optional = true }
sys-locale = { version = "0.2.1", optional = true }

[dev-dependencies]
criterion = "0.3.5"
Expand Down
16 changes: 7 additions & 9 deletions boa_engine/src/builtins/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,12 +366,10 @@ impl Array {
// 7. If IsConstructor(C) is false, throw a TypeError exception.
if let Some(c) = c.as_constructor() {
// 8. Return ? Construct(C, « 𝔽(length) »).
Ok(
c.construct(&[JsValue::new(length)], &c.clone().into(), context)?
.as_object()
.expect("constructing an object should always return an object")
.clone(),
)
Ok(c.construct(&[JsValue::new(length)], Some(c), context)?
.as_object()
.expect("constructing an object should always return an object")
.clone())
} else {
context.throw_type_error("Symbol.species must be a constructor")
}
Expand Down Expand Up @@ -421,7 +419,7 @@ impl Array {
// i. Let A be ? ArrayCreate(0en).
let a = match this.as_constructor() {
Some(constructor) => constructor
.construct(&[], this, context)?
.construct(&[], None, context)?
.as_object()
.cloned()
.ok_or_else(|| {
Expand Down Expand Up @@ -500,7 +498,7 @@ impl Array {
// a. Let A be ? ArrayCreate(len).
let a = match this.as_constructor() {
Some(constructor) => constructor
.construct(&[len.into()], this, context)?
.construct(&[len.into()], None, context)?
.as_object()
.cloned()
.ok_or_else(|| {
Expand Down Expand Up @@ -582,7 +580,7 @@ impl Array {
// a. Let A be ? ArrayCreate(len).
let a = match this.as_constructor() {
Some(constructor) => constructor
.construct(&[len.into()], this, context)?
.construct(&[len.into()], None, context)?
.as_object()
.cloned()
.ok_or_else(|| {
Expand Down
2 changes: 1 addition & 1 deletion boa_engine/src/builtins/array_buffer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ impl ArrayBuffer {
let ctor = obj.species_constructor(StandardConstructors::array_buffer, context)?;

// 16. Let new be ? Construct(ctor, « 𝔽(newLen) »).
let new = ctor.construct(&[new_len.into()], &ctor.clone().into(), context)?;
let new = ctor.construct(&[new_len.into()], Some(&ctor), context)?;

// 17. Perform ? RequireInternalSlot(new, [[ArrayBufferData]]).
let new_obj = new.as_object().cloned().ok_or_else(|| {
Expand Down
9 changes: 9 additions & 0 deletions boa_engine/src/builtins/iterable/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,21 +277,30 @@ impl IteratorRecord {
}
}

/// Get the `[[Iterator]]` field of the `IteratorRecord`.
#[inline]
pub(crate) fn iterator(&self) -> &JsObject {
&self.iterator
}

/// Get the `[[NextMethod]]` field of the `IteratorRecord`.
#[inline]
pub(crate) fn next_method(&self) -> &JsValue {
&self.next_method
}

/// Get the `[[Done]]` field of the `IteratorRecord`.
#[inline]
pub(crate) fn done(&self) -> bool {
self.done
}

/// Sets the `[[Done]]` field of the `IteratorRecord`.
#[inline]
pub(crate) fn set_done(&mut self, done: bool) {
self.done = done;
}

/// `IteratorNext ( iteratorRecord [ , value ] )`
///
/// The abstract operation `IteratorNext` takes argument `iteratorRecord` (an `Iterator`
Expand Down
Loading

0 comments on commit 7e043f7

Please sign in to comment.