From 8030e2adbb5b584d45721891148e5a6d46faa9c5 Mon Sep 17 00:00:00 2001 From: jedel1043 Date: Fri, 4 Mar 2022 08:01:56 -0600 Subject: [PATCH] Rename `standard_constructors` to `constructors` --- boa_engine/src/builtins/array/mod.rs | 8 ++--- boa_engine/src/builtins/array_buffer/mod.rs | 6 +--- boa_engine/src/builtins/bigint/mod.rs | 6 +--- boa_engine/src/builtins/boolean/mod.rs | 6 +--- boa_engine/src/builtins/dataview/mod.rs | 6 +--- boa_engine/src/builtins/error/eval.rs | 18 ++--------- boa_engine/src/builtins/error/mod.rs | 2 +- boa_engine/src/builtins/error/range.rs | 18 ++--------- boa_engine/src/builtins/error/reference.rs | 14 ++------ boa_engine/src/builtins/error/syntax.rs | 18 ++--------- boa_engine/src/builtins/error/type.rs | 24 +++----------- boa_engine/src/builtins/error/uri.rs | 18 ++--------- boa_engine/src/builtins/function/arguments.rs | 6 +--- boa_engine/src/builtins/function/mod.rs | 14 ++------ boa_engine/src/builtins/generator/mod.rs | 16 +++------- .../src/builtins/generator_function/mod.rs | 28 ++++------------ boa_engine/src/builtins/json/tests.rs | 4 +-- boa_engine/src/builtins/map/mod.rs | 2 +- boa_engine/src/builtins/number/mod.rs | 6 +--- boa_engine/src/builtins/object/mod.rs | 6 +--- boa_engine/src/builtins/proxy/mod.rs | 8 ++--- boa_engine/src/builtins/regexp/mod.rs | 20 ++---------- boa_engine/src/builtins/set/mod.rs | 2 +- boa_engine/src/builtins/string/mod.rs | 6 +--- boa_engine/src/builtins/symbol/mod.rs | 6 +--- boa_engine/src/builtins/typed_array/mod.rs | 16 ++++------ boa_engine/src/context/intrinsics.rs | 8 ++--- boa_engine/src/context/mod.rs | 19 +++++------ boa_engine/src/object/internal_methods/mod.rs | 2 +- boa_engine/src/object/mod.rs | 8 ++--- boa_engine/src/object/operations.rs | 8 ++--- boa_engine/src/value/mod.rs | 32 ++++--------------- boa_engine/src/vm/code_block.rs | 20 +++--------- 33 files changed, 89 insertions(+), 292 deletions(-) diff --git a/boa_engine/src/builtins/array/mod.rs b/boa_engine/src/builtins/array/mod.rs index 0e5eeeda137..58e2301b87e 100644 --- a/boa_engine/src/builtins/array/mod.rs +++ b/boa_engine/src/builtins/array/mod.rs @@ -55,7 +55,7 @@ impl BuiltIn for Array { ConstructorBuilder::with_standard_constructor( context, Self::constructor, - context.intrinsics().standard_constructors().array().clone(), + context.intrinsics().constructors().array().clone(), ) .name(Self::NAME) .length(Self::LENGTH) @@ -223,11 +223,7 @@ impl Array { // 5. Set A.[[DefineOwnProperty]] as specified in 10.4.2.1. let prototype = match prototype { Some(prototype) => prototype, - None => context - .intrinsics() - .standard_constructors() - .array() - .prototype(), + None => context.intrinsics().constructors().array().prototype(), }; let array = JsObject::from_proto_and_data(prototype, ObjectData::array()); diff --git a/boa_engine/src/builtins/array_buffer/mod.rs b/boa_engine/src/builtins/array_buffer/mod.rs index 89f9ec5e23d..d05e7b82400 100644 --- a/boa_engine/src/builtins/array_buffer/mod.rs +++ b/boa_engine/src/builtins/array_buffer/mod.rs @@ -45,11 +45,7 @@ impl BuiltIn for ArrayBuffer { ConstructorBuilder::with_standard_constructor( context, Self::constructor, - context - .intrinsics() - .standard_constructors() - .array_buffer() - .clone(), + context.intrinsics().constructors().array_buffer().clone(), ) .name(Self::NAME) .length(Self::LENGTH) diff --git a/boa_engine/src/builtins/bigint/mod.rs b/boa_engine/src/builtins/bigint/mod.rs index 3f034652e2c..b5bd14a4e50 100644 --- a/boa_engine/src/builtins/bigint/mod.rs +++ b/boa_engine/src/builtins/bigint/mod.rs @@ -42,11 +42,7 @@ impl BuiltIn for BigInt { ConstructorBuilder::with_standard_constructor( context, Self::constructor, - context - .intrinsics() - .standard_constructors() - .bigint_object() - .clone(), + context.intrinsics().constructors().bigint_object().clone(), ) .name(Self::NAME) .length(Self::LENGTH) diff --git a/boa_engine/src/builtins/boolean/mod.rs b/boa_engine/src/builtins/boolean/mod.rs index 12bf066ac4f..4377cbd8dab 100644 --- a/boa_engine/src/builtins/boolean/mod.rs +++ b/boa_engine/src/builtins/boolean/mod.rs @@ -37,11 +37,7 @@ impl BuiltIn for Boolean { ConstructorBuilder::with_standard_constructor( context, Self::constructor, - context - .intrinsics() - .standard_constructors() - .boolean() - .clone(), + context.intrinsics().constructors().boolean().clone(), ) .name(Self::NAME) .length(Self::LENGTH) diff --git a/boa_engine/src/builtins/dataview/mod.rs b/boa_engine/src/builtins/dataview/mod.rs index 70b6d55875c..0bb9b2497c7 100644 --- a/boa_engine/src/builtins/dataview/mod.rs +++ b/boa_engine/src/builtins/dataview/mod.rs @@ -41,11 +41,7 @@ impl BuiltIn for DataView { ConstructorBuilder::with_standard_constructor( context, Self::constructor, - context - .intrinsics() - .standard_constructors() - .data_view() - .clone(), + context.intrinsics().constructors().data_view().clone(), ) .name(Self::NAME) .length(Self::LENGTH) diff --git a/boa_engine/src/builtins/error/eval.rs b/boa_engine/src/builtins/error/eval.rs index d7c176afdb3..4cade0f1856 100644 --- a/boa_engine/src/builtins/error/eval.rs +++ b/boa_engine/src/builtins/error/eval.rs @@ -35,26 +35,14 @@ impl BuiltIn for EvalError { fn init(context: &mut Context) -> Option { let _timer = Profiler::global().start_event(Self::NAME, "init"); - let error_constructor = context - .intrinsics() - .standard_constructors() - .error() - .constructor(); - let error_prototype = context - .intrinsics() - .standard_constructors() - .error() - .prototype(); + let error_constructor = context.intrinsics().constructors().error().constructor(); + let error_prototype = context.intrinsics().constructors().error().prototype(); let attribute = Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE; ConstructorBuilder::with_standard_constructor( context, Self::constructor, - context - .intrinsics() - .standard_constructors() - .eval_error() - .clone(), + context.intrinsics().constructors().eval_error().clone(), ) .name(Self::NAME) .length(Self::LENGTH) diff --git a/boa_engine/src/builtins/error/mod.rs b/boa_engine/src/builtins/error/mod.rs index cf7ce018b19..f0fadcc7021 100644 --- a/boa_engine/src/builtins/error/mod.rs +++ b/boa_engine/src/builtins/error/mod.rs @@ -55,7 +55,7 @@ impl BuiltIn for Error { ConstructorBuilder::with_standard_constructor( context, Self::constructor, - context.intrinsics().standard_constructors().error().clone(), + context.intrinsics().constructors().error().clone(), ) .name(Self::NAME) .length(Self::LENGTH) diff --git a/boa_engine/src/builtins/error/range.rs b/boa_engine/src/builtins/error/range.rs index 8c9110937db..1fa1258b0a8 100644 --- a/boa_engine/src/builtins/error/range.rs +++ b/boa_engine/src/builtins/error/range.rs @@ -33,26 +33,14 @@ impl BuiltIn for RangeError { fn init(context: &mut Context) -> Option { let _timer = Profiler::global().start_event(Self::NAME, "init"); - let error_constructor = context - .intrinsics() - .standard_constructors() - .error() - .constructor(); - let error_prototype = context - .intrinsics() - .standard_constructors() - .error() - .prototype(); + let error_constructor = context.intrinsics().constructors().error().constructor(); + let error_prototype = context.intrinsics().constructors().error().prototype(); let attribute = Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE; ConstructorBuilder::with_standard_constructor( context, Self::constructor, - context - .intrinsics() - .standard_constructors() - .range_error() - .clone(), + context.intrinsics().constructors().range_error().clone(), ) .name(Self::NAME) .length(Self::LENGTH) diff --git a/boa_engine/src/builtins/error/reference.rs b/boa_engine/src/builtins/error/reference.rs index a346c555d27..e130678b955 100644 --- a/boa_engine/src/builtins/error/reference.rs +++ b/boa_engine/src/builtins/error/reference.rs @@ -32,16 +32,8 @@ impl BuiltIn for ReferenceError { fn init(context: &mut Context) -> Option { let _timer = Profiler::global().start_event(Self::NAME, "init"); - let error_constructor = context - .intrinsics() - .standard_constructors() - .error() - .constructor(); - let error_prototype = context - .intrinsics() - .standard_constructors() - .error() - .prototype(); + let error_constructor = context.intrinsics().constructors().error().constructor(); + let error_prototype = context.intrinsics().constructors().error().prototype(); let attribute = Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE; ConstructorBuilder::with_standard_constructor( @@ -49,7 +41,7 @@ impl BuiltIn for ReferenceError { Self::constructor, context .intrinsics() - .standard_constructors() + .constructors() .reference_error() .clone(), ) diff --git a/boa_engine/src/builtins/error/syntax.rs b/boa_engine/src/builtins/error/syntax.rs index e127d42be72..d0d2a33bcda 100644 --- a/boa_engine/src/builtins/error/syntax.rs +++ b/boa_engine/src/builtins/error/syntax.rs @@ -35,26 +35,14 @@ impl BuiltIn for SyntaxError { fn init(context: &mut Context) -> Option { let _timer = Profiler::global().start_event(Self::NAME, "init"); - let error_constructor = context - .intrinsics() - .standard_constructors() - .error() - .constructor(); - let error_prototype = context - .intrinsics() - .standard_constructors() - .error() - .prototype(); + let error_constructor = context.intrinsics().constructors().error().constructor(); + let error_prototype = context.intrinsics().constructors().error().prototype(); let attribute = Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE; ConstructorBuilder::with_standard_constructor( context, Self::constructor, - context - .intrinsics() - .standard_constructors() - .syntax_error() - .clone(), + context.intrinsics().constructors().syntax_error().clone(), ) .name(Self::NAME) .length(Self::LENGTH) diff --git a/boa_engine/src/builtins/error/type.rs b/boa_engine/src/builtins/error/type.rs index aaa30e931d5..0d1faad759c 100644 --- a/boa_engine/src/builtins/error/type.rs +++ b/boa_engine/src/builtins/error/type.rs @@ -39,26 +39,14 @@ impl BuiltIn for TypeError { fn init(context: &mut Context) -> Option { let _timer = Profiler::global().start_event(Self::NAME, "init"); - let error_constructor = context - .intrinsics() - .standard_constructors() - .error() - .constructor(); - let error_prototype = context - .intrinsics() - .standard_constructors() - .error() - .prototype(); + let error_constructor = context.intrinsics().constructors().error().constructor(); + let error_prototype = context.intrinsics().constructors().error().prototype(); let attribute = Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE; ConstructorBuilder::with_standard_constructor( context, Self::constructor, - context - .intrinsics() - .standard_constructors() - .type_error() - .clone(), + context.intrinsics().constructors().type_error().clone(), ) .name(Self::NAME) .length(Self::LENGTH) @@ -112,11 +100,7 @@ pub(crate) fn create_throw_type_error(context: &mut Context) -> JsObject { } let function = JsObject::from_proto_and_data( - context - .intrinsics() - .standard_constructors() - .function() - .prototype(), + context.intrinsics().constructors().function().prototype(), ObjectData::function(Function::Native { function: throw_type_error, constructor: false, diff --git a/boa_engine/src/builtins/error/uri.rs b/boa_engine/src/builtins/error/uri.rs index cb47dfe877f..f00866d2a7b 100644 --- a/boa_engine/src/builtins/error/uri.rs +++ b/boa_engine/src/builtins/error/uri.rs @@ -34,26 +34,14 @@ impl BuiltIn for UriError { fn init(context: &mut Context) -> Option { let _timer = Profiler::global().start_event(Self::NAME, "init"); - let error_constructor = context - .intrinsics() - .standard_constructors() - .error() - .constructor(); - let error_prototype = context - .intrinsics() - .standard_constructors() - .error() - .prototype(); + let error_constructor = context.intrinsics().constructors().error().constructor(); + let error_prototype = context.intrinsics().constructors().error().prototype(); let attribute = Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE; ConstructorBuilder::with_standard_constructor( context, Self::constructor, - context - .intrinsics() - .standard_constructors() - .uri_error() - .clone(), + context.intrinsics().constructors().uri_error().clone(), ) .name(Self::NAME) .length(Self::LENGTH) diff --git a/boa_engine/src/builtins/function/arguments.rs b/boa_engine/src/builtins/function/arguments.rs index 274a741436f..cc28c657a3c 100644 --- a/boa_engine/src/builtins/function/arguments.rs +++ b/boa_engine/src/builtins/function/arguments.rs @@ -224,11 +224,7 @@ impl Arguments { // 11. Set obj.[[ParameterMap]] to map. let obj = JsObject::from_proto_and_data( - context - .intrinsics() - .standard_constructors() - .object() - .prototype(), + context.intrinsics().constructors().object().prototype(), ObjectData::arguments(Self::Mapped(map)), ); diff --git a/boa_engine/src/builtins/function/mod.rs b/boa_engine/src/builtins/function/mod.rs index bec7baeeddc..cc4af912b79 100644 --- a/boa_engine/src/builtins/function/mod.rs +++ b/boa_engine/src/builtins/function/mod.rs @@ -236,7 +236,7 @@ pub(crate) fn make_builtin_fn( let function = JsObject::from_proto_and_data( interpreter .intrinsics() - .standard_constructors() + .constructors() .function() .prototype(), ObjectData::function(Function::Native { @@ -500,11 +500,7 @@ impl BuiltIn for BuiltInFunctionObject { fn init(context: &mut Context) -> Option { let _timer = Profiler::global().start_event("function", "init"); - let function_prototype = context - .intrinsics() - .standard_constructors() - .function() - .prototype(); + let function_prototype = context.intrinsics().constructors().function().prototype(); FunctionBuilder::native(context, Self::prototype) .name("") .length(0) @@ -522,11 +518,7 @@ impl BuiltIn for BuiltInFunctionObject { ConstructorBuilder::with_standard_constructor( context, Self::constructor, - context - .intrinsics() - .standard_constructors() - .function() - .clone(), + context.intrinsics().constructors().function().clone(), ) .name(Self::NAME) .length(Self::LENGTH) diff --git a/boa_engine/src/builtins/generator/mod.rs b/boa_engine/src/builtins/generator/mod.rs index f81796e17c5..358890dac77 100644 --- a/boa_engine/src/builtins/generator/mod.rs +++ b/boa_engine/src/builtins/generator/mod.rs @@ -68,18 +68,14 @@ impl BuiltIn for Generator { let generator_function_prototype = context .intrinsics() - .standard_constructors() + .constructors() .generator_function() .prototype(); ConstructorBuilder::with_standard_constructor( context, Self::constructor, - context - .intrinsics() - .standard_constructors() - .generator() - .clone(), + context.intrinsics().constructors().generator().clone(), ) .name(Self::NAME) .length(Self::LENGTH) @@ -96,7 +92,7 @@ impl BuiltIn for Generator { context .intrinsics() - .standard_constructors() + .constructors() .generator() .prototype .insert_property( @@ -121,11 +117,7 @@ impl Generator { _: &[JsValue], context: &mut Context, ) -> JsResult { - let prototype = context - .intrinsics() - .standard_constructors() - .generator() - .prototype(); + let prototype = context.intrinsics().constructors().generator().prototype(); let this = JsObject::from_proto_and_data( prototype, diff --git a/boa_engine/src/builtins/generator_function/mod.rs b/boa_engine/src/builtins/generator_function/mod.rs index 8c5f78f80d3..19d761c5f8d 100644 --- a/boa_engine/src/builtins/generator_function/mod.rs +++ b/boa_engine/src/builtins/generator_function/mod.rs @@ -33,21 +33,17 @@ impl BuiltIn for GeneratorFunction { let prototype = &context .intrinsics() - .standard_constructors() + .constructors() .generator_function() .prototype; let constructor = &context .intrinsics() - .standard_constructors() + .constructors() .generator_function() .constructor; constructor.set_prototype(Some( - context - .intrinsics() - .standard_constructors() - .function() - .constructor(), + context.intrinsics().constructors().function().constructor(), )); let property = PropertyDescriptor::builder() .value(1) @@ -65,7 +61,7 @@ impl BuiltIn for GeneratorFunction { .value( context .intrinsics() - .standard_constructors() + .constructors() .generator_function() .prototype(), ) @@ -79,17 +75,13 @@ impl BuiltIn for GeneratorFunction { }); prototype.set_prototype(Some( - context - .intrinsics() - .standard_constructors() - .function() - .prototype(), + context.intrinsics().constructors().function().prototype(), )); let property = PropertyDescriptor::builder() .value( context .intrinsics() - .standard_constructors() + .constructors() .generator_function() .constructor(), ) @@ -98,13 +90,7 @@ impl BuiltIn for GeneratorFunction { .configurable(true); prototype.borrow_mut().insert("constructor", property); let property = PropertyDescriptor::builder() - .value( - context - .intrinsics() - .standard_constructors() - .generator() - .prototype(), - ) + .value(context.intrinsics().constructors().generator().prototype()) .writable(false) .enumerable(false) .configurable(true); diff --git a/boa_engine/src/builtins/json/tests.rs b/boa_engine/src/builtins/json/tests.rs index 4807d72e4e8..b4779f516f4 100644 --- a/boa_engine/src/builtins/json/tests.rs +++ b/boa_engine/src/builtins/json/tests.rs @@ -423,13 +423,13 @@ fn json_parse_sets_prototypes() { .clone(); let global_object_prototype = context .intrinsics() - .standard_constructors() + .constructors() .object() .prototype() .into(); let global_array_prototype = context .intrinsics() - .standard_constructors() + .constructors() .array() .prototype() .into(); diff --git a/boa_engine/src/builtins/map/mod.rs b/boa_engine/src/builtins/map/mod.rs index c862c8ae4bf..673d7f9b386 100644 --- a/boa_engine/src/builtins/map/mod.rs +++ b/boa_engine/src/builtins/map/mod.rs @@ -63,7 +63,7 @@ impl BuiltIn for Map { ConstructorBuilder::with_standard_constructor( context, Self::constructor, - context.intrinsics().standard_constructors().map().clone(), + context.intrinsics().constructors().map().clone(), ) .name(Self::NAME) .length(Self::LENGTH) diff --git a/boa_engine/src/builtins/number/mod.rs b/boa_engine/src/builtins/number/mod.rs index ed484059ff7..9e9ed98d390 100644 --- a/boa_engine/src/builtins/number/mod.rs +++ b/boa_engine/src/builtins/number/mod.rs @@ -55,11 +55,7 @@ impl BuiltIn for Number { ConstructorBuilder::with_standard_constructor( context, Self::constructor, - context - .intrinsics() - .standard_constructors() - .number() - .clone(), + context.intrinsics().constructors().number().clone(), ) .name(Self::NAME) .length(Self::LENGTH) diff --git a/boa_engine/src/builtins/object/mod.rs b/boa_engine/src/builtins/object/mod.rs index f6ebb385c51..6bdb4b6a158 100644 --- a/boa_engine/src/builtins/object/mod.rs +++ b/boa_engine/src/builtins/object/mod.rs @@ -46,11 +46,7 @@ impl BuiltIn for Object { ConstructorBuilder::with_standard_constructor( context, Self::constructor, - context - .intrinsics() - .standard_constructors() - .object() - .clone(), + context.intrinsics().constructors().object().clone(), ) .name(Self::NAME) .length(Self::LENGTH) diff --git a/boa_engine/src/builtins/proxy/mod.rs b/boa_engine/src/builtins/proxy/mod.rs index 7b7ef462d43..5f580f74bfd 100644 --- a/boa_engine/src/builtins/proxy/mod.rs +++ b/boa_engine/src/builtins/proxy/mod.rs @@ -35,7 +35,7 @@ impl BuiltIn for Proxy { ConstructorBuilder::with_standard_constructor( context, Self::constructor, - context.intrinsics().standard_constructors().proxy().clone(), + context.intrinsics().constructors().proxy().clone(), ) .name(Self::NAME) .length(Self::LENGTH) @@ -111,11 +111,7 @@ impl Proxy { // 6. Set P.[[ProxyTarget]] to target. // 7. Set P.[[ProxyHandler]] to handler. let p = JsObject::from_proto_and_data( - context - .intrinsics() - .standard_constructors() - .object() - .prototype(), + context.intrinsics().constructors().object().prototype(), ObjectData::proxy( Self::new(target.clone(), handler.clone()), target.is_callable(), diff --git a/boa_engine/src/builtins/regexp/mod.rs b/boa_engine/src/builtins/regexp/mod.rs index 923faa41d23..b39d66a8a9b 100644 --- a/boa_engine/src/builtins/regexp/mod.rs +++ b/boa_engine/src/builtins/regexp/mod.rs @@ -98,11 +98,7 @@ impl BuiltIn for RegExp { ConstructorBuilder::with_standard_constructor( context, Self::constructor, - context - .intrinsics() - .standard_constructors() - .regexp() - .clone(), + context.intrinsics().constructors().regexp().clone(), ) .name(Self::NAME) .length(Self::LENGTH) @@ -349,11 +345,7 @@ impl RegExp { if JsObject::equals( object, - &context - .intrinsics() - .standard_constructors() - .regexp() - .prototype, + &context.intrinsics().constructors().regexp().prototype, ) { return Ok(JsValue::undefined()); } @@ -574,13 +566,7 @@ impl RegExp { // b. Otherwise, throw a TypeError exception. if JsValue::same_value( this, - &JsValue::new( - context - .intrinsics() - .standard_constructors() - .regexp() - .prototype(), - ), + &JsValue::new(context.intrinsics().constructors().regexp().prototype()), ) { Ok(JsValue::new("(?:)")) } else { diff --git a/boa_engine/src/builtins/set/mod.rs b/boa_engine/src/builtins/set/mod.rs index 85a69180811..1ff23fb706d 100644 --- a/boa_engine/src/builtins/set/mod.rs +++ b/boa_engine/src/builtins/set/mod.rs @@ -63,7 +63,7 @@ impl BuiltIn for Set { ConstructorBuilder::with_standard_constructor( context, Self::constructor, - context.intrinsics().standard_constructors().set().clone(), + context.intrinsics().constructors().set().clone(), ) .name(Self::NAME) .length(Self::LENGTH) diff --git a/boa_engine/src/builtins/string/mod.rs b/boa_engine/src/builtins/string/mod.rs index 6e57c052800..60bfdd8f9f5 100644 --- a/boa_engine/src/builtins/string/mod.rs +++ b/boa_engine/src/builtins/string/mod.rs @@ -110,11 +110,7 @@ impl BuiltIn for String { ConstructorBuilder::with_standard_constructor( context, Self::constructor, - context - .intrinsics() - .standard_constructors() - .string() - .clone(), + context.intrinsics().constructors().string().clone(), ) .name(Self::NAME) .length(Self::LENGTH) diff --git a/boa_engine/src/builtins/symbol/mod.rs b/boa_engine/src/builtins/symbol/mod.rs index 5466bbc574b..df98d652c1a 100644 --- a/boa_engine/src/builtins/symbol/mod.rs +++ b/boa_engine/src/builtins/symbol/mod.rs @@ -108,11 +108,7 @@ impl BuiltIn for Symbol { ConstructorBuilder::with_standard_constructor( context, Self::constructor, - context - .intrinsics() - .standard_constructors() - .symbol() - .clone(), + context.intrinsics().constructors().symbol().clone(), ) .name(Self::NAME) .length(Self::LENGTH) diff --git a/boa_engine/src/builtins/typed_array/mod.rs b/boa_engine/src/builtins/typed_array/mod.rs index 77925272618..d7ea9c48957 100644 --- a/boa_engine/src/builtins/typed_array/mod.rs +++ b/boa_engine/src/builtins/typed_array/mod.rs @@ -56,12 +56,12 @@ macro_rules! typed_array { let typed_array_constructor = context .intrinsics() - .standard_constructors() + .constructors() .typed_array() .constructor(); let typed_array_constructor_proto = context .intrinsics() - .standard_constructors() + .constructors() .typed_array() .prototype(); @@ -75,7 +75,7 @@ macro_rules! typed_array { Self::constructor, context .intrinsics() - .standard_constructors() + .constructors() .$global_object_name() .clone(), ) @@ -286,11 +286,7 @@ impl BuiltIn for TypedArray { ConstructorBuilder::with_standard_constructor( context, Self::constructor, - context - .intrinsics() - .standard_constructors() - .typed_array() - .clone(), + context.intrinsics().constructors().typed_array().clone(), ) .name(Self::NAME) .length(Self::LENGTH) @@ -2031,7 +2027,7 @@ impl TypedArray { // c. NOTE: %ArrayBuffer% is used to clone srcBuffer because is it known to not have any observable side-effects. let array_buffer_constructor = context .intrinsics() - .standard_constructors() + .constructors() .array_buffer() .constructor() .into(); @@ -2933,7 +2929,7 @@ impl TypedArray { let data = ArrayBuffer::allocate( &context .intrinsics() - .standard_constructors() + .constructors() .array_buffer() .constructor() .into(), diff --git a/boa_engine/src/context/intrinsics.rs b/boa_engine/src/context/intrinsics.rs index 129b16f60ab..e9e67929951 100644 --- a/boa_engine/src/context/intrinsics.rs +++ b/boa_engine/src/context/intrinsics.rs @@ -7,7 +7,7 @@ use crate::{ #[derive(Debug, Default)] pub struct Intrinsics { /// Cached standard constructors - pub(super) standard_constructors: StandardConstructors, + pub(super) constructors: StandardConstructors, /// Cached intrinsic objects pub(super) objects: IntrinsicObjects, } @@ -19,10 +19,10 @@ impl Intrinsics { &self.objects } - /// Return the core standard objects. + /// Return the cached standard constructors. #[inline] - pub fn standard_constructors(&self) -> &StandardConstructors { - &self.standard_constructors + pub fn constructors(&self) -> &StandardConstructors { + &self.constructors } } diff --git a/boa_engine/src/context/mod.rs b/boa_engine/src/context/mod.rs index 37bbf833bb1..6439e0df008 100644 --- a/boa_engine/src/context/mod.rs +++ b/boa_engine/src/context/mod.rs @@ -173,10 +173,7 @@ impl Context { #[inline] pub fn construct_object(&self) -> JsObject { JsObject::from_proto_and_data( - self.intrinsics() - .standard_constructors() - .object() - .prototype(), + self.intrinsics().constructors().object().prototype(), ObjectData::ordinary(), ) } @@ -228,7 +225,7 @@ impl Context { crate::builtins::error::Error::constructor( &self .intrinsics() - .standard_constructors() + .constructors() .error() .constructor() .into(), @@ -256,7 +253,7 @@ impl Context { crate::builtins::error::RangeError::constructor( &self .intrinsics() - .standard_constructors() + .constructors() .range_error() .constructor() .into(), @@ -284,7 +281,7 @@ impl Context { crate::builtins::error::TypeError::constructor( &self .intrinsics() - .standard_constructors() + .constructors() .type_error() .constructor() .into(), @@ -312,7 +309,7 @@ impl Context { crate::builtins::error::ReferenceError::constructor( &self .intrinsics() - .standard_constructors() + .constructors() .reference_error() .constructor() .into(), @@ -340,7 +337,7 @@ impl Context { crate::builtins::error::SyntaxError::constructor( &self .intrinsics() - .standard_constructors() + .constructors() .syntax_error() .constructor() .into(), @@ -367,7 +364,7 @@ impl Context { crate::builtins::error::EvalError::constructor( &self .intrinsics() - .standard_constructors() + .constructors() .eval_error() .constructor() .into(), @@ -385,7 +382,7 @@ impl Context { crate::builtins::error::UriError::constructor( &self .intrinsics() - .standard_constructors() + .constructors() .uri_error() .constructor() .into(), diff --git a/boa_engine/src/object/internal_methods/mod.rs b/boa_engine/src/object/internal_methods/mod.rs index c0b33c745d0..d628f6d1164 100644 --- a/boa_engine/src/object/internal_methods/mod.rs +++ b/boa_engine/src/object/internal_methods/mod.rs @@ -968,5 +968,5 @@ where // TODO: handle realms // a. Let realm be ? GetFunctionRealm(constructor). // b. Set proto to realm's intrinsic object named intrinsicDefaultProto. - Ok(default(context.intrinsics().standard_constructors()).prototype()) + Ok(default(context.intrinsics().constructors()).prototype()) } diff --git a/boa_engine/src/object/mod.rs b/boa_engine/src/object/mod.rs index 1b5ab6597ee..0a2a992a66a 100644 --- a/boa_engine/src/object/mod.rs +++ b/boa_engine/src/object/mod.rs @@ -1419,7 +1419,7 @@ impl<'context> FunctionBuilder<'context> { let function = JsObject::from_proto_and_data( self.context .intrinsics() - .standard_constructors() + .constructors() .function() .prototype(), ObjectData::function(self.function), @@ -1441,7 +1441,7 @@ impl<'context> FunctionBuilder<'context> { object.set_prototype( self.context .intrinsics() - .standard_constructors() + .constructors() .object() .prototype(), ); @@ -1881,7 +1881,7 @@ impl<'context> ConstructorBuilder<'context> { constructor.set_prototype( self.context .intrinsics() - .standard_constructors() + .constructors() .function() .prototype(), ); @@ -1916,7 +1916,7 @@ impl<'context> ConstructorBuilder<'context> { prototype.set_prototype( self.context .intrinsics() - .standard_constructors() + .constructors() .object() .prototype(), ); diff --git a/boa_engine/src/object/operations.rs b/boa_engine/src/object/operations.rs index ee742010ce6..91b22c31662 100644 --- a/boa_engine/src/object/operations.rs +++ b/boa_engine/src/object/operations.rs @@ -482,9 +482,7 @@ impl JsObject { // 3. If C is undefined, return defaultConstructor. if c.is_undefined() { - return Ok( - default_constructor(context.intrinsics().standard_constructors()).constructor(), - ); + return Ok(default_constructor(context.intrinsics().constructors()).constructor()); } // 4. If Type(C) is not Object, throw a TypeError exception. @@ -499,9 +497,7 @@ impl JsObject { // 6. If S is either undefined or null, return defaultConstructor. if s.is_null_or_undefined() { - return Ok( - default_constructor(context.intrinsics().standard_constructors()).constructor(), - ); + return Ok(default_constructor(context.intrinsics().constructors()).constructor()); } // 7. If IsConstructor(S) is true, return S. diff --git a/boa_engine/src/value/mod.rs b/boa_engine/src/value/mod.rs index a3120dfbeca..2fd12402887 100644 --- a/boa_engine/src/value/mod.rs +++ b/boa_engine/src/value/mod.rs @@ -465,44 +465,28 @@ impl JsValue { context.throw_type_error("cannot convert 'null' or 'undefined' to object") } JsValue::Boolean(boolean) => { - let prototype = context - .intrinsics() - .standard_constructors() - .boolean() - .prototype(); + let prototype = context.intrinsics().constructors().boolean().prototype(); Ok(JsObject::from_proto_and_data( prototype, ObjectData::boolean(*boolean), )) } JsValue::Integer(integer) => { - let prototype = context - .intrinsics() - .standard_constructors() - .number() - .prototype(); + let prototype = context.intrinsics().constructors().number().prototype(); Ok(JsObject::from_proto_and_data( prototype, ObjectData::number(f64::from(*integer)), )) } JsValue::Rational(rational) => { - let prototype = context - .intrinsics() - .standard_constructors() - .number() - .prototype(); + let prototype = context.intrinsics().constructors().number().prototype(); Ok(JsObject::from_proto_and_data( prototype, ObjectData::number(*rational), )) } JsValue::String(ref string) => { - let prototype = context - .intrinsics() - .standard_constructors() - .string() - .prototype(); + let prototype = context.intrinsics().constructors().string().prototype(); let object = JsObject::from_proto_and_data(prototype, ObjectData::string(string.clone())); @@ -518,11 +502,7 @@ impl JsValue { Ok(object) } JsValue::Symbol(ref symbol) => { - let prototype = context - .intrinsics() - .standard_constructors() - .symbol() - .prototype(); + let prototype = context.intrinsics().constructors().symbol().prototype(); Ok(JsObject::from_proto_and_data( prototype, ObjectData::symbol(symbol.clone()), @@ -531,7 +511,7 @@ impl JsValue { JsValue::BigInt(ref bigint) => { let prototype = context .intrinsics() - .standard_constructors() + .constructors() .bigint_object() .prototype(); Ok(JsObject::from_proto_and_data( diff --git a/boa_engine/src/vm/code_block.rs b/boa_engine/src/vm/code_block.rs index 0149fbf74be..8673e2de97a 100644 --- a/boa_engine/src/vm/code_block.rs +++ b/boa_engine/src/vm/code_block.rs @@ -403,11 +403,7 @@ impl ToInternedString for CodeBlock { pub(crate) fn create_function_object(code: Gc, context: &mut Context) -> JsObject { let _timer = Profiler::global().start_event("JsVmFunction::new", "vm"); - let function_prototype = context - .intrinsics() - .standard_constructors() - .function() - .prototype(); + let function_prototype = context.intrinsics().constructors().function().prototype(); let prototype = context.construct_object(); @@ -471,7 +467,7 @@ pub(crate) fn create_generator_function_object( ) -> JsObject { let function_prototype = context .intrinsics() - .standard_constructors() + .constructors() .generator_function() .prototype(); @@ -490,11 +486,7 @@ pub(crate) fn create_generator_function_object( .build(); let prototype = JsObject::from_proto_and_data( - context - .intrinsics() - .standard_constructors() - .generator() - .prototype(), + context.intrinsics().constructors().generator().prototype(), ObjectData::ordinary(), ); @@ -799,11 +791,7 @@ impl JsObject { { prototype.clone() } else { - context - .intrinsics() - .standard_constructors() - .generator() - .prototype() + context.intrinsics().constructors().generator().prototype() }; let generator = Self::from_proto_and_data(