summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2021-06-07 19:31:32 +0300
committerLinus Groh <mail@linusgroh.de>2021-06-08 09:09:51 +0100
commitaefb7995f138b83d838788ecd1906860bbb4af20 (patch)
tree9805eeb2c0a7a386394931c17fb0ab057734b108 /Userland/Libraries
parent39c3aefe5de1763384c33cae5b931802a866cb0f (diff)
downloadserenity-aefb7995f138b83d838788ecd1906860bbb4af20.zip
LibJS: Add the Symbol.species getter to the appropriate built-ins
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp7
-rw-r--r--Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.h2
-rw-r--r--Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp7
-rw-r--r--Userland/Libraries/LibJS/Runtime/ArrayConstructor.h2
-rw-r--r--Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp7
-rw-r--r--Userland/Libraries/LibJS/Runtime/PromiseConstructor.h2
-rw-r--r--Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp7
-rw-r--r--Userland/Libraries/LibJS/Runtime/RegExpConstructor.h2
-rw-r--r--Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp7
-rw-r--r--Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.h2
10 files changed, 45 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp
index c2a916325b..46adf163ac 100644
--- a/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp
@@ -25,6 +25,8 @@ void ArrayBufferConstructor::initialize(GlobalObject& global_object)
define_property(vm.names.prototype, global_object.array_buffer_prototype(), 0);
define_property(vm.names.length, Value(1), Attribute::Configurable);
define_native_function(vm.names.isView, is_view, 1, attr);
+
+ define_native_property(vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable);
}
ArrayBufferConstructor::~ArrayBufferConstructor()
@@ -62,4 +64,9 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayBufferConstructor::is_view)
return Value(false);
}
+JS_DEFINE_NATIVE_GETTER(ArrayBufferConstructor::symbol_species_getter)
+{
+ return vm.this_value(global_object);
+}
+
}
diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.h b/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.h
index 0b30d80086..542f9cc057 100644
--- a/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.h
+++ b/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.h
@@ -25,6 +25,8 @@ private:
virtual bool has_constructor() const override { return true; }
JS_DECLARE_NATIVE_FUNCTION(is_view);
+
+ JS_DECLARE_NATIVE_GETTER(symbol_species_getter);
};
}
diff --git a/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp
index 672ea80cdd..da435651e6 100644
--- a/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp
@@ -37,6 +37,8 @@ void ArrayConstructor::initialize(GlobalObject& global_object)
define_native_function(vm.names.from, from, 1, attr);
define_native_function(vm.names.isArray, is_array, 1, attr);
define_native_function(vm.names.of, of, 0, attr);
+
+ define_native_property(vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable);
}
Value ArrayConstructor::call()
@@ -151,4 +153,9 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayConstructor::of)
return array;
}
+JS_DEFINE_NATIVE_GETTER(ArrayConstructor::symbol_species_getter)
+{
+ return vm.this_value(global_object);
+}
+
}
diff --git a/Userland/Libraries/LibJS/Runtime/ArrayConstructor.h b/Userland/Libraries/LibJS/Runtime/ArrayConstructor.h
index b835e67e92..d2785216f9 100644
--- a/Userland/Libraries/LibJS/Runtime/ArrayConstructor.h
+++ b/Userland/Libraries/LibJS/Runtime/ArrayConstructor.h
@@ -27,6 +27,8 @@ private:
JS_DECLARE_NATIVE_FUNCTION(from);
JS_DECLARE_NATIVE_FUNCTION(is_array);
JS_DECLARE_NATIVE_FUNCTION(of);
+
+ JS_DECLARE_NATIVE_GETTER(symbol_species_getter);
};
}
diff --git a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp
index 561988717e..492165ed21 100644
--- a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp
@@ -35,6 +35,8 @@ void PromiseConstructor::initialize(GlobalObject& global_object)
// define_native_function(vm.names.race, race, 1, attr);
define_native_function(vm.names.reject, reject, 1, attr);
define_native_function(vm.names.resolve, resolve, 1, attr);
+
+ define_native_property(vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable);
}
Value PromiseConstructor::call()
@@ -113,4 +115,9 @@ JS_DEFINE_NATIVE_FUNCTION(PromiseConstructor::resolve)
return promise_resolve(global_object, *constructor, value);
}
+JS_DEFINE_NATIVE_GETTER(PromiseConstructor::symbol_species_getter)
+{
+ return vm.this_value(global_object);
+}
+
}
diff --git a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.h b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.h
index 75a52d58e8..00334dc282 100644
--- a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.h
+++ b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.h
@@ -30,6 +30,8 @@ private:
JS_DECLARE_NATIVE_FUNCTION(race);
JS_DECLARE_NATIVE_FUNCTION(reject);
JS_DECLARE_NATIVE_FUNCTION(resolve);
+
+ JS_DECLARE_NATIVE_GETTER(symbol_species_getter);
};
}
diff --git a/Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp b/Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp
index d02fa2291f..0642b8fdbd 100644
--- a/Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp
@@ -22,6 +22,8 @@ void RegExpConstructor::initialize(GlobalObject& global_object)
NativeFunction::initialize(global_object);
define_property(vm.names.prototype, global_object.regexp_prototype(), 0);
define_property(vm.names.length, Value(2), Attribute::Configurable);
+
+ define_native_property(vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable);
}
RegExpConstructor::~RegExpConstructor()
@@ -51,4 +53,9 @@ Value RegExpConstructor::construct(Function&)
return RegExpObject::create(global_object(), pattern, flags);
}
+JS_DEFINE_NATIVE_GETTER(RegExpConstructor::symbol_species_getter)
+{
+ return vm.this_value(global_object);
+}
+
}
diff --git a/Userland/Libraries/LibJS/Runtime/RegExpConstructor.h b/Userland/Libraries/LibJS/Runtime/RegExpConstructor.h
index d62fd6dae0..d110021ccf 100644
--- a/Userland/Libraries/LibJS/Runtime/RegExpConstructor.h
+++ b/Userland/Libraries/LibJS/Runtime/RegExpConstructor.h
@@ -23,6 +23,8 @@ public:
private:
virtual bool has_constructor() const override { return true; }
+
+ JS_DECLARE_NATIVE_GETTER(symbol_species_getter);
};
}
diff --git a/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp b/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp
index fec2ce8733..f9e958b241 100644
--- a/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp
@@ -25,6 +25,8 @@ void TypedArrayConstructor::initialize(GlobalObject& global_object)
NativeFunction::initialize(global_object);
define_property(vm.names.prototype, global_object.typed_array_prototype(), 0);
define_property(vm.names.length, Value(0), Attribute::Configurable);
+
+ define_native_property(vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable);
}
TypedArrayConstructor::~TypedArrayConstructor()
@@ -42,4 +44,9 @@ Value TypedArrayConstructor::construct(Function&)
return {};
}
+JS_DEFINE_NATIVE_GETTER(TypedArrayConstructor::symbol_species_getter)
+{
+ return vm.this_value(global_object);
+}
+
}
diff --git a/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.h b/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.h
index 4be3880271..17d3efeab4 100644
--- a/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.h
+++ b/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.h
@@ -24,6 +24,8 @@ public:
private:
virtual bool has_constructor() const override { return true; }
+
+ JS_DECLARE_NATIVE_GETTER(symbol_species_getter);
};
}