Skip to content

Commit

Permalink
Rename standard_constructors to constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
jedel1043 committed Mar 4, 2022
1 parent 8e1aa3d commit 8030e2a
Show file tree
Hide file tree
Showing 33 changed files with 89 additions and 292 deletions.
8 changes: 2 additions & 6 deletions boa_engine/src/builtins/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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());

Expand Down
6 changes: 1 addition & 5 deletions boa_engine/src/builtins/array_buffer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 1 addition & 5 deletions boa_engine/src/builtins/bigint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 1 addition & 5 deletions boa_engine/src/builtins/boolean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 1 addition & 5 deletions boa_engine/src/builtins/dataview/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 3 additions & 15 deletions boa_engine/src/builtins/error/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,14 @@ impl BuiltIn for EvalError {
fn init(context: &mut Context) -> Option<JsValue> {
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)
Expand Down
2 changes: 1 addition & 1 deletion boa_engine/src/builtins/error/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 3 additions & 15 deletions boa_engine/src/builtins/error/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,14 @@ impl BuiltIn for RangeError {
fn init(context: &mut Context) -> Option<JsValue> {
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)
Expand Down
14 changes: 3 additions & 11 deletions boa_engine/src/builtins/error/reference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,16 @@ impl BuiltIn for ReferenceError {
fn init(context: &mut Context) -> Option<JsValue> {
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()
.constructors()
.reference_error()
.clone(),
)
Expand Down
18 changes: 3 additions & 15 deletions boa_engine/src/builtins/error/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,14 @@ impl BuiltIn for SyntaxError {
fn init(context: &mut Context) -> Option<JsValue> {
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)
Expand Down
24 changes: 4 additions & 20 deletions boa_engine/src/builtins/error/type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,14 @@ impl BuiltIn for TypeError {
fn init(context: &mut Context) -> Option<JsValue> {
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)
Expand Down Expand Up @@ -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,
Expand Down
18 changes: 3 additions & 15 deletions boa_engine/src/builtins/error/uri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,14 @@ impl BuiltIn for UriError {
fn init(context: &mut Context) -> Option<JsValue> {
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)
Expand Down
6 changes: 1 addition & 5 deletions boa_engine/src/builtins/function/arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
);

Expand Down
14 changes: 3 additions & 11 deletions boa_engine/src/builtins/function/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ pub(crate) fn make_builtin_fn<N>(
let function = JsObject::from_proto_and_data(
interpreter
.intrinsics()
.standard_constructors()
.constructors()
.function()
.prototype(),
ObjectData::function(Function::Native {
Expand Down Expand Up @@ -500,11 +500,7 @@ impl BuiltIn for BuiltInFunctionObject {
fn init(context: &mut Context) -> Option<JsValue> {
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)
Expand All @@ -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)
Expand Down
16 changes: 4 additions & 12 deletions boa_engine/src/builtins/generator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -96,7 +92,7 @@ impl BuiltIn for Generator {

context
.intrinsics()
.standard_constructors()
.constructors()
.generator()
.prototype
.insert_property(
Expand All @@ -121,11 +117,7 @@ impl Generator {
_: &[JsValue],
context: &mut Context,
) -> JsResult<JsValue> {
let prototype = context
.intrinsics()
.standard_constructors()
.generator()
.prototype();
let prototype = context.intrinsics().constructors().generator().prototype();

let this = JsObject::from_proto_and_data(
prototype,
Expand Down
Loading

0 comments on commit 8030e2a

Please sign in to comment.