diff --git a/boa/src/builtins/error/reference.rs b/boa/src/builtins/error/reference.rs index 8943b0148d0..3144f7a47ea 100644 --- a/boa/src/builtins/error/reference.rs +++ b/boa/src/builtins/error/reference.rs @@ -32,7 +32,7 @@ impl BuiltIn for ReferenceError { let error_prototype = context.standard_objects().error_object().prototype(); let attribute = Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE; - let range_error_object = ConstructorBuilder::with_standard_object( + let reference_error_object = ConstructorBuilder::with_standard_object( context, Self::constructor, context.standard_objects().reference_error_object().clone(), @@ -44,7 +44,7 @@ impl BuiltIn for ReferenceError { .property("message", "", attribute) .build(); - (Self::NAME, range_error_object.into(), Self::attribute()) + (Self::NAME, reference_error_object.into(), Self::attribute()) } } diff --git a/boa/src/builtins/error/syntax.rs b/boa/src/builtins/error/syntax.rs index 7c60227c016..55dd5886609 100644 --- a/boa/src/builtins/error/syntax.rs +++ b/boa/src/builtins/error/syntax.rs @@ -35,7 +35,7 @@ impl BuiltIn for SyntaxError { let error_prototype = context.standard_objects().error_object().prototype(); let attribute = Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE; - let range_error_object = ConstructorBuilder::with_standard_object( + let syntax_error_object = ConstructorBuilder::with_standard_object( context, Self::constructor, context.standard_objects().syntax_error_object().clone(), @@ -47,7 +47,7 @@ impl BuiltIn for SyntaxError { .property("message", "", attribute) .build(); - (Self::NAME, range_error_object.into(), Self::attribute()) + (Self::NAME, syntax_error_object.into(), Self::attribute()) } } diff --git a/boa/src/builtins/error/type.rs b/boa/src/builtins/error/type.rs index 803dd3d1568..fc0ec4aa9f0 100644 --- a/boa/src/builtins/error/type.rs +++ b/boa/src/builtins/error/type.rs @@ -38,7 +38,7 @@ impl BuiltIn for TypeError { let error_prototype = context.standard_objects().error_object().prototype(); let attribute = Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE; - let range_error_object = ConstructorBuilder::with_standard_object( + let type_error_object = ConstructorBuilder::with_standard_object( context, Self::constructor, context.standard_objects().type_error_object().clone(), @@ -50,7 +50,7 @@ impl BuiltIn for TypeError { .property("message", "", attribute) .build(); - (Self::NAME, range_error_object.into(), Self::attribute()) + (Self::NAME, type_error_object.into(), Self::attribute()) } } diff --git a/boa/src/builtins/map/mod.rs b/boa/src/builtins/map/mod.rs index 9eeee6e0abb..cf925ba40f9 100644 --- a/boa/src/builtins/map/mod.rs +++ b/boa/src/builtins/map/mod.rs @@ -46,14 +46,11 @@ impl Map { /// Create a new map pub(crate) fn constructor(this: &Value, args: &[Value], ctx: &mut Context) -> Result { - // Make a new Object which will internally represent the Array (mapping - // between indices and values): this creates an Object with no prototype - // Set Prototype let prototype = ctx.global_object().get_field("Map").get_field(PROTOTYPE); this.as_object_mut() - .expect("this is array object") + .expect("this is map object") .set_prototype_instance(prototype); // This value is used by console.log and other routines to match Object type // to its Javascript Identifier (global constructor method name) diff --git a/boa/src/builtins/mod.rs b/boa/src/builtins/mod.rs index 3333b65d340..be392f2133e 100644 --- a/boa/src/builtins/mod.rs +++ b/boa/src/builtins/mod.rs @@ -57,7 +57,7 @@ pub(crate) trait BuiltIn { /// Initializes builtin objects and functions #[inline] pub fn init(context: &mut Context) { - let globals2 = [ + let globals = [ // Global properties. Undefined::init, Infinity::init, @@ -90,7 +90,7 @@ pub fn init(context: &mut Context) { unreachable!("global object should always be an object") }; - for init in &globals2 { + for init in &globals { let (name, value, attribute) = init(context); let property = Property::data_descriptor(value, attribute); global_object.borrow_mut().insert(name, property); diff --git a/boa/src/class.rs b/boa/src/class.rs index 190561cc10a..b4c15a2f1fb 100644 --- a/boa/src/class.rs +++ b/boa/src/class.rs @@ -130,10 +130,9 @@ impl<'context> ClassBuilder<'context> { /// It is added to `prototype`. pub fn method(&mut self, name: N, length: usize, function: NativeFunction) -> &mut Self where - N: Into, + N: AsRef, { - // TODO: \/ - self.builder.method(function, &name.into(), length); + self.builder.method(function, name.as_ref(), length); self } @@ -147,9 +146,9 @@ impl<'context> ClassBuilder<'context> { function: NativeFunction, ) -> &mut Self where - N: Into, + N: AsRef, { - self.builder.static_method(function, &name.into(), length); + self.builder.static_method(function, name.as_ref(), length); self } diff --git a/boa/src/context.rs b/boa/src/context.rs index d2f239be3f7..580b4d1bfc1 100644 --- a/boa/src/context.rs +++ b/boa/src/context.rs @@ -44,11 +44,17 @@ impl Default for StandardConstructor { } impl StandardConstructor { + /// Return the constructor object. + /// + /// This is the same as `Object`, `Array`, etc. #[inline] pub fn constructor(&self) -> GcObject { self.constructor.clone() } + /// Return the prototype of the constructor object. + /// + /// This is the same as `Object.prototype`, `Array.prototype`, etc #[inline] pub fn prototype(&self) -> GcObject { self.prototype.clone() @@ -150,7 +156,7 @@ impl StandardObjects { /// /// `Context`s constructed in a thread share the same runtime, therefore it /// is possible to share objects from one context to another context, but they -/// have to in the same thread. +/// have to be in the same thread. #[derive(Debug)] pub struct Context { /// realm holds both the global object and the environment