Skip to content

Commit

Permalink
Merge 868301a into a5bc7dd
Browse files Browse the repository at this point in the history
  • Loading branch information
RageKnify authored Feb 6, 2021
2 parents a5bc7dd + 868301a commit c12c36a
Show file tree
Hide file tree
Showing 11 changed files with 946 additions and 15 deletions.
8 changes: 8 additions & 0 deletions boa/src/builtins/iterable/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::{
builtins::ArrayIterator,
builtins::ForInIterator,
builtins::MapIterator,
builtins::SetIterator,
object::{GcObject, ObjectInitializer},
property::{Attribute, DataDescriptor},
BoaProfiler, Context, Result, Value,
Expand All @@ -12,6 +13,7 @@ use crate::{
pub struct IteratorPrototypes {
iterator_prototype: GcObject,
array_iterator: GcObject,
set_iterator: GcObject,
string_iterator: GcObject,
map_iterator: GcObject,
for_in_iterator: GcObject,
Expand All @@ -25,6 +27,7 @@ impl IteratorPrototypes {
context,
iterator_prototype.clone().into(),
),
set_iterator: SetIterator::create_prototype(context, iterator_prototype.clone().into()),
string_iterator: StringIterator::create_prototype(
context,
iterator_prototype.clone().into(),
Expand All @@ -48,6 +51,11 @@ impl IteratorPrototypes {
self.iterator_prototype.clone()
}

#[inline]
pub fn set_iterator(&self) -> GcObject {
self.set_iterator.clone()
}

#[inline]
pub fn string_iterator(&self) -> GcObject {
self.string_iterator.clone()
Expand Down
5 changes: 2 additions & 3 deletions boa/src/builtins/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,14 @@ impl BuiltIn for Map {
.method(Self::has, "has", 1)
.method(Self::for_each, "forEach", 1)
.method(Self::values, "values", 0)
.callable(false)
.build();

(Self::NAME, map_object.into(), Self::attribute())
}
}

impl Map {
pub(crate) const LENGTH: usize = 1;
pub(crate) const LENGTH: usize = 0;

/// Create a new map
pub(crate) fn constructor(
Expand All @@ -75,7 +74,7 @@ impl Map {
context: &mut Context,
) -> Result<Value> {
if new_target.is_undefined() {
return context.throw_type_error("Map requires new");
return context.throw_type_error("Constructor Map requires 'new'");
}
let map_prototype = context
.global_object()
Expand Down
2 changes: 1 addition & 1 deletion boa/src/builtins/map/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,6 @@ fn not_a_function() {
";
assert_eq!(
forward(&mut context, init),
"\"TypeError: function object is not callable\""
"\"TypeError: Constructor Map requires 'new'\""
);
}
4 changes: 4 additions & 0 deletions boa/src/builtins/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub mod nan;
pub mod number;
pub mod object;
pub mod regexp;
pub mod set;
pub mod string;
pub mod symbol;
pub mod undefined;
Expand All @@ -40,6 +41,8 @@ pub(crate) use self::{
object::for_in_iterator::ForInIterator,
object::Object as BuiltInObjectObject,
regexp::RegExp,
set::set_iterator::SetIterator,
set::Set,
string::String,
symbol::Symbol,
undefined::Undefined,
Expand Down Expand Up @@ -76,6 +79,7 @@ pub fn init(context: &mut Context) {
Date::init,
Map::init,
Number::init,
Set::init,
String::init,
RegExp::init,
Symbol::init,
Expand Down
Loading

0 comments on commit c12c36a

Please sign in to comment.