Skip to content

Commit

Permalink
Merge 8a7ac4e into 23bc476
Browse files Browse the repository at this point in the history
  • Loading branch information
tofpie authored Dec 31, 2020
2 parents 23bc476 + 8a7ac4e commit cef486e
Show file tree
Hide file tree
Showing 39 changed files with 449 additions and 348 deletions.
13 changes: 6 additions & 7 deletions boa/src/builtins/array/array_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl ArrayIterator {
array: Value,
kind: ArrayIterationKind,
) -> Result<Value> {
let array_iterator = Value::new_object(Some(context.global_object()));
let array_iterator = Value::new_object(context);
array_iterator.set_data(ObjectData::ArrayIterator(Self::new(array, kind)));
array_iterator
.as_object()
Expand All @@ -77,7 +77,7 @@ impl ArrayIterator {
}
let len = array_iterator
.array
.get_field("length")
.get_field("length", context)?
.as_number()
.ok_or_else(|| context.construct_type_error("Not an array"))?
as u32;
Expand All @@ -91,13 +91,13 @@ impl ArrayIterator {
Ok(create_iter_result_object(context, index.into(), false))
}
ArrayIterationKind::Value => {
let element_value = array_iterator.array.get_field(index);
let element_value = array_iterator.array.get_field(index, context)?;
Ok(create_iter_result_object(context, element_value, false))
}
ArrayIterationKind::KeyAndValue => {
let element_value = array_iterator.array.get_field(index);
let element_value = array_iterator.array.get_field(index, context)?;
let result = Array::constructor(
&Value::new_object(Some(context.global_object())),
&Value::new_object(context),
&[index.into(), element_value],
context,
)?;
Expand All @@ -119,11 +119,10 @@ impl ArrayIterator {
///
/// [spec]: https://tc39.es/ecma262/#sec-%arrayiteratorprototype%-object
pub(crate) fn create_prototype(context: &mut Context, iterator_prototype: Value) -> Value {
let global = context.global_object();
let _timer = BoaProfiler::global().start_event(Self::NAME, "init");

// Create prototype
let array_iterator = Value::new_object(Some(global));
let array_iterator = Value::new_object(context);
make_builtin_fn(Self::next, "next", &array_iterator, 0, context);
array_iterator
.as_object()
Expand Down
Loading

0 comments on commit cef486e

Please sign in to comment.