mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:38:12 +00:00
LibJS: Simplify Cell::initialize()
Remove the Interpreter& argument and pass only GlobalObject&. We can find everything we need via the global object anyway.
This commit is contained in:
parent
299824de73
commit
aaf6014ae1
82 changed files with 161 additions and 160 deletions
|
@ -672,7 +672,7 @@ Value ClassExpression::execute(Interpreter& interpreter, GlobalObject& global_ob
|
||||||
return interpreter.throw_exception<TypeError>(ErrorType::ClassDoesNotExtendAConstructorOrNull, super_constructor.to_string_without_side_effects().characters());
|
return interpreter.throw_exception<TypeError>(ErrorType::ClassDoesNotExtendAConstructorOrNull, super_constructor.to_string_without_side_effects().characters());
|
||||||
|
|
||||||
class_constructor->set_constructor_kind(Function::ConstructorKind::Derived);
|
class_constructor->set_constructor_kind(Function::ConstructorKind::Derived);
|
||||||
Object* prototype = Object::create_empty(interpreter, interpreter.global_object());
|
Object* prototype = Object::create_empty(global_object);
|
||||||
|
|
||||||
Object* super_constructor_prototype = nullptr;
|
Object* super_constructor_prototype = nullptr;
|
||||||
if (!super_constructor.is_null()) {
|
if (!super_constructor.is_null()) {
|
||||||
|
@ -1461,7 +1461,7 @@ Value ObjectProperty::execute(Interpreter&, GlobalObject&) const
|
||||||
|
|
||||||
Value ObjectExpression::execute(Interpreter& interpreter, GlobalObject& global_object) const
|
Value ObjectExpression::execute(Interpreter& interpreter, GlobalObject& global_object) const
|
||||||
{
|
{
|
||||||
auto* object = Object::create_empty(interpreter, global_object);
|
auto* object = Object::create_empty(global_object);
|
||||||
for (auto& property : m_properties) {
|
for (auto& property : m_properties) {
|
||||||
auto key = property.key().execute(interpreter, global_object);
|
auto key = property.key().execute(interpreter, global_object);
|
||||||
if (interpreter.exception())
|
if (interpreter.exception())
|
||||||
|
|
|
@ -59,7 +59,7 @@ public:
|
||||||
auto* memory = allocate_cell(sizeof(T));
|
auto* memory = allocate_cell(sizeof(T));
|
||||||
new (memory) T(forward<Args>(args)...);
|
new (memory) T(forward<Args>(args)...);
|
||||||
auto* cell = static_cast<T*>(memory);
|
auto* cell = static_cast<T*>(memory);
|
||||||
cell->initialize(m_interpreter, global_object);
|
cell->initialize(global_object);
|
||||||
return cell;
|
return cell;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -274,7 +274,7 @@ Value Interpreter::construct(Function& function, Function& new_target, Optional<
|
||||||
|
|
||||||
Object* new_object = nullptr;
|
Object* new_object = nullptr;
|
||||||
if (function.constructor_kind() == Function::ConstructorKind::Base) {
|
if (function.constructor_kind() == Function::ConstructorKind::Base) {
|
||||||
new_object = Object::create_empty(*this, global_object);
|
new_object = Object::create_empty(global_object);
|
||||||
current_environment()->bind_this_value(new_object);
|
current_environment()->bind_this_value(new_object);
|
||||||
if (exception())
|
if (exception())
|
||||||
return {};
|
return {};
|
||||||
|
|
|
@ -45,9 +45,9 @@ ArrayConstructor::~ArrayConstructor()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArrayConstructor::initialize(Interpreter& interpreter, GlobalObject& global_object)
|
void ArrayConstructor::initialize(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
NativeFunction::initialize(interpreter, global_object);
|
NativeFunction::initialize(global_object);
|
||||||
|
|
||||||
define_property("prototype", global_object.array_prototype(), 0);
|
define_property("prototype", global_object.array_prototype(), 0);
|
||||||
define_property("length", Value(1), Attribute::Configurable);
|
define_property("length", Value(1), Attribute::Configurable);
|
||||||
|
|
|
@ -35,7 +35,7 @@ class ArrayConstructor final : public NativeFunction {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ArrayConstructor(GlobalObject&);
|
explicit ArrayConstructor(GlobalObject&);
|
||||||
virtual void initialize(Interpreter&, GlobalObject&) override;
|
virtual void initialize(GlobalObject&) override;
|
||||||
virtual ~ArrayConstructor() override;
|
virtual ~ArrayConstructor() override;
|
||||||
|
|
||||||
virtual Value call(Interpreter&) override;
|
virtual Value call(Interpreter&) override;
|
||||||
|
|
|
@ -38,12 +38,12 @@ ArrayIteratorPrototype::ArrayIteratorPrototype(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArrayIteratorPrototype::initialize(Interpreter& interpreter, GlobalObject& global_object)
|
void ArrayIteratorPrototype::initialize(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
Object::initialize(interpreter, global_object);
|
Object::initialize(global_object);
|
||||||
|
|
||||||
define_native_function("next", next, 0, Attribute::Configurable | Attribute::Writable);
|
define_native_function("next", next, 0, Attribute::Configurable | Attribute::Writable);
|
||||||
define_property(interpreter.well_known_symbol_to_string_tag(), js_string(interpreter, "Array Iterator"), Attribute::Configurable);
|
define_property(global_object.interpreter().well_known_symbol_to_string_tag(), js_string(global_object.heap(), "Array Iterator"), Attribute::Configurable);
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayIteratorPrototype::~ArrayIteratorPrototype()
|
ArrayIteratorPrototype::~ArrayIteratorPrototype()
|
||||||
|
@ -61,7 +61,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayIteratorPrototype::next)
|
||||||
auto& iterator = static_cast<ArrayIterator&>(this_object);
|
auto& iterator = static_cast<ArrayIterator&>(this_object);
|
||||||
auto target_array = iterator.array();
|
auto target_array = iterator.array();
|
||||||
if (target_array.is_undefined())
|
if (target_array.is_undefined())
|
||||||
return create_iterator_result_object(interpreter, global_object, js_undefined(), true);
|
return create_iterator_result_object(global_object, js_undefined(), true);
|
||||||
ASSERT(target_array.is_object());
|
ASSERT(target_array.is_object());
|
||||||
auto& array = target_array.as_object();
|
auto& array = target_array.as_object();
|
||||||
|
|
||||||
|
@ -72,23 +72,23 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayIteratorPrototype::next)
|
||||||
|
|
||||||
if (index >= length) {
|
if (index >= length) {
|
||||||
iterator.m_array = js_undefined();
|
iterator.m_array = js_undefined();
|
||||||
return create_iterator_result_object(interpreter, global_object, js_undefined(), true);
|
return create_iterator_result_object(global_object, js_undefined(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator.m_index++;
|
iterator.m_index++;
|
||||||
if (iteration_kind == Object::PropertyKind::Key)
|
if (iteration_kind == Object::PropertyKind::Key)
|
||||||
return create_iterator_result_object(interpreter, global_object, Value(static_cast<i32>(index)), false);
|
return create_iterator_result_object(global_object, Value(static_cast<i32>(index)), false);
|
||||||
|
|
||||||
auto value = array.get(index);
|
auto value = array.get(index);
|
||||||
if (interpreter.exception())
|
if (interpreter.exception())
|
||||||
return {};
|
return {};
|
||||||
if (iteration_kind == Object::PropertyKind::Value)
|
if (iteration_kind == Object::PropertyKind::Value)
|
||||||
return create_iterator_result_object(interpreter, global_object, value, false);
|
return create_iterator_result_object(global_object, value, false);
|
||||||
|
|
||||||
auto* entry_array = Array::create(global_object);
|
auto* entry_array = Array::create(global_object);
|
||||||
entry_array->define_property(0, Value(static_cast<i32>(index)));
|
entry_array->define_property(0, Value(static_cast<i32>(index)));
|
||||||
entry_array->define_property(1, value);
|
entry_array->define_property(1, value);
|
||||||
return create_iterator_result_object(interpreter, global_object, entry_array, false);
|
return create_iterator_result_object(global_object, entry_array, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ class ArrayIteratorPrototype final : public Object {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ArrayIteratorPrototype(GlobalObject&);
|
ArrayIteratorPrototype(GlobalObject&);
|
||||||
virtual void initialize(Interpreter&, GlobalObject&) override;
|
virtual void initialize(GlobalObject&) override;
|
||||||
virtual ~ArrayIteratorPrototype() override;
|
virtual ~ArrayIteratorPrototype() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -46,9 +46,9 @@ ArrayPrototype::ArrayPrototype(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArrayPrototype::initialize(Interpreter& interpreter, GlobalObject& global_object)
|
void ArrayPrototype::initialize(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
Object::initialize(interpreter, global_object);
|
Object::initialize(global_object);
|
||||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||||
|
|
||||||
define_native_function("filter", filter, 1, attr);
|
define_native_function("filter", filter, 1, attr);
|
||||||
|
@ -81,7 +81,7 @@ void ArrayPrototype::initialize(Interpreter& interpreter, GlobalObject& global_o
|
||||||
// Use define_property here instead of define_native_function so that
|
// Use define_property here instead of define_native_function so that
|
||||||
// Object.is(Array.prototype[Symbol.iterator], Array.prototype.values)
|
// Object.is(Array.prototype[Symbol.iterator], Array.prototype.values)
|
||||||
// evaluates to true
|
// evaluates to true
|
||||||
define_property(interpreter.well_known_symbol_iterator(), get("values"), attr);
|
define_property(global_object.interpreter().well_known_symbol_iterator(), get("values"), attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayPrototype::~ArrayPrototype()
|
ArrayPrototype::~ArrayPrototype()
|
||||||
|
|
|
@ -36,7 +36,7 @@ class ArrayPrototype final : public Object {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ArrayPrototype(GlobalObject&);
|
ArrayPrototype(GlobalObject&);
|
||||||
virtual void initialize(Interpreter&, GlobalObject&) override;
|
virtual void initialize(GlobalObject&) override;
|
||||||
virtual ~ArrayPrototype() override;
|
virtual ~ArrayPrototype() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -39,9 +39,9 @@ BigIntConstructor::BigIntConstructor(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void BigIntConstructor::initialize(Interpreter& interpreter, GlobalObject& global_object)
|
void BigIntConstructor::initialize(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
NativeFunction::initialize(interpreter, global_object);
|
NativeFunction::initialize(global_object);
|
||||||
define_property("prototype", global_object.bigint_prototype(), 0);
|
define_property("prototype", global_object.bigint_prototype(), 0);
|
||||||
define_property("length", Value(1), Attribute::Configurable);
|
define_property("length", Value(1), Attribute::Configurable);
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ class BigIntConstructor final : public NativeFunction {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit BigIntConstructor(GlobalObject&);
|
explicit BigIntConstructor(GlobalObject&);
|
||||||
virtual void initialize(Interpreter&, GlobalObject&) override;
|
virtual void initialize(GlobalObject&) override;
|
||||||
virtual ~BigIntConstructor() override;
|
virtual ~BigIntConstructor() override;
|
||||||
|
|
||||||
virtual Value call(Interpreter&) override;
|
virtual Value call(Interpreter&) override;
|
||||||
|
|
|
@ -37,15 +37,15 @@ BigIntPrototype::BigIntPrototype(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void BigIntPrototype::initialize(Interpreter& interpreter, GlobalObject& global_object)
|
void BigIntPrototype::initialize(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
Object::initialize(interpreter, global_object);
|
Object::initialize(global_object);
|
||||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||||
define_native_function("toString", to_string, 0, attr);
|
define_native_function("toString", to_string, 0, attr);
|
||||||
define_native_function("toLocaleString", to_locale_string, 0, attr);
|
define_native_function("toLocaleString", to_locale_string, 0, attr);
|
||||||
define_native_function("valueOf", value_of, 0, attr);
|
define_native_function("valueOf", value_of, 0, attr);
|
||||||
|
|
||||||
define_property(interpreter.well_known_symbol_to_string_tag(), js_string(interpreter, "BigInt"), Attribute::Configurable);
|
define_property(global_object.interpreter().well_known_symbol_to_string_tag(), js_string(global_object.heap(), "BigInt"), Attribute::Configurable);
|
||||||
}
|
}
|
||||||
|
|
||||||
BigIntPrototype::~BigIntPrototype()
|
BigIntPrototype::~BigIntPrototype()
|
||||||
|
|
|
@ -35,7 +35,7 @@ class BigIntPrototype final : public Object {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit BigIntPrototype(GlobalObject&);
|
explicit BigIntPrototype(GlobalObject&);
|
||||||
virtual void initialize(Interpreter&, GlobalObject&) override;
|
virtual void initialize(GlobalObject&) override;
|
||||||
virtual ~BigIntPrototype() override;
|
virtual ~BigIntPrototype() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -38,9 +38,9 @@ BooleanConstructor::BooleanConstructor(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void BooleanConstructor::initialize(Interpreter& interpreter, GlobalObject& global_object)
|
void BooleanConstructor::initialize(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
NativeFunction::initialize(interpreter, global_object);
|
NativeFunction::initialize(global_object);
|
||||||
define_property("prototype", Value(global_object.boolean_prototype()), 0);
|
define_property("prototype", Value(global_object.boolean_prototype()), 0);
|
||||||
define_property("length", Value(1), Attribute::Configurable);
|
define_property("length", Value(1), Attribute::Configurable);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ class BooleanConstructor final : public NativeFunction {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit BooleanConstructor(GlobalObject&);
|
explicit BooleanConstructor(GlobalObject&);
|
||||||
virtual void initialize(Interpreter&, GlobalObject&) override;
|
virtual void initialize(GlobalObject&) override;
|
||||||
virtual ~BooleanConstructor() override;
|
virtual ~BooleanConstructor() override;
|
||||||
|
|
||||||
virtual Value call(Interpreter&) override;
|
virtual Value call(Interpreter&) override;
|
||||||
|
|
|
@ -37,9 +37,9 @@ BooleanPrototype::BooleanPrototype(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void BooleanPrototype::initialize(Interpreter& interpreter, GlobalObject& global_object)
|
void BooleanPrototype::initialize(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
BooleanObject::initialize(interpreter, global_object);
|
BooleanObject::initialize(global_object);
|
||||||
define_native_function("toString", to_string, 0, Attribute::Writable | Attribute::Configurable);
|
define_native_function("toString", to_string, 0, Attribute::Writable | Attribute::Configurable);
|
||||||
define_native_function("valueOf", value_of, 0, Attribute::Writable | Attribute::Configurable);
|
define_native_function("valueOf", value_of, 0, Attribute::Writable | Attribute::Configurable);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ class BooleanPrototype final : public BooleanObject {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit BooleanPrototype(GlobalObject&);
|
explicit BooleanPrototype(GlobalObject&);
|
||||||
virtual void initialize(Interpreter&, GlobalObject&) override;
|
virtual void initialize(GlobalObject&) override;
|
||||||
virtual ~BooleanPrototype() override;
|
virtual ~BooleanPrototype() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -39,9 +39,9 @@ BoundFunction::BoundFunction(GlobalObject& global_object, Function& target_funct
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoundFunction::initialize(Interpreter& interpreter, GlobalObject& global_object)
|
void BoundFunction::initialize(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
Function::initialize(interpreter, global_object);
|
Function::initialize(global_object);
|
||||||
define_property("length", Value(m_length), Attribute::Configurable);
|
define_property("length", Value(m_length), Attribute::Configurable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ class BoundFunction final : public Function {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BoundFunction(GlobalObject&, Function& target_function, Value bound_this, Vector<Value> arguments, i32 length, Object* constructor_prototype);
|
BoundFunction(GlobalObject&, Function& target_function, Value bound_this, Vector<Value> arguments, i32 length, Object* constructor_prototype);
|
||||||
virtual void initialize(Interpreter&, GlobalObject&) override;
|
virtual void initialize(GlobalObject&) override;
|
||||||
virtual ~BoundFunction();
|
virtual ~BoundFunction();
|
||||||
|
|
||||||
virtual Value call(Interpreter& interpreter) override;
|
virtual Value call(Interpreter& interpreter) override;
|
||||||
|
|
|
@ -37,7 +37,7 @@ class Cell {
|
||||||
AK_MAKE_NONMOVABLE(Cell);
|
AK_MAKE_NONMOVABLE(Cell);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void initialize(Interpreter&, GlobalObject&) { }
|
virtual void initialize(GlobalObject&) { }
|
||||||
virtual ~Cell() { }
|
virtual ~Cell() { }
|
||||||
|
|
||||||
bool is_marked() const { return m_mark; }
|
bool is_marked() const { return m_mark; }
|
||||||
|
|
|
@ -40,9 +40,9 @@ ConsoleObject::ConsoleObject(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConsoleObject::initialize(Interpreter& interpreter, GlobalObject& global_object)
|
void ConsoleObject::initialize(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
Object::initialize(interpreter, global_object);
|
Object::initialize(global_object);
|
||||||
define_native_function("log", log);
|
define_native_function("log", log);
|
||||||
define_native_function("debug", debug);
|
define_native_function("debug", debug);
|
||||||
define_native_function("info", info);
|
define_native_function("info", info);
|
||||||
|
|
|
@ -35,7 +35,7 @@ class ConsoleObject final : public Object {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ConsoleObject(GlobalObject&);
|
explicit ConsoleObject(GlobalObject&);
|
||||||
virtual void initialize(Interpreter&, GlobalObject&) override;
|
virtual void initialize(GlobalObject&) override;
|
||||||
virtual ~ConsoleObject() override;
|
virtual ~ConsoleObject() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -39,9 +39,9 @@ DateConstructor::DateConstructor(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void DateConstructor::initialize(Interpreter& interpreter, GlobalObject& global_object)
|
void DateConstructor::initialize(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
NativeFunction::initialize(interpreter, global_object);
|
NativeFunction::initialize(global_object);
|
||||||
define_property("prototype", global_object.date_prototype(), 0);
|
define_property("prototype", global_object.date_prototype(), 0);
|
||||||
define_property("length", Value(7), Attribute::Configurable);
|
define_property("length", Value(7), Attribute::Configurable);
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ class DateConstructor final : public NativeFunction {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DateConstructor(GlobalObject&);
|
explicit DateConstructor(GlobalObject&);
|
||||||
virtual void initialize(Interpreter&, GlobalObject&) override;
|
virtual void initialize(GlobalObject&) override;
|
||||||
virtual ~DateConstructor() override;
|
virtual ~DateConstructor() override;
|
||||||
|
|
||||||
virtual Value call(Interpreter&) override;
|
virtual Value call(Interpreter&) override;
|
||||||
|
|
|
@ -53,9 +53,9 @@ DatePrototype::DatePrototype(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatePrototype::initialize(Interpreter& interpreter, GlobalObject& global_object)
|
void DatePrototype::initialize(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
Object::initialize(interpreter, global_object);
|
Object::initialize(global_object);
|
||||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||||
define_native_function("getDate", get_date, 0, attr);
|
define_native_function("getDate", get_date, 0, attr);
|
||||||
define_native_function("getDay", get_day, 0, attr);
|
define_native_function("getDay", get_day, 0, attr);
|
||||||
|
|
|
@ -34,7 +34,7 @@ class DatePrototype final : public Object {
|
||||||
JS_OBJECT(DatePrototype, Object);
|
JS_OBJECT(DatePrototype, Object);
|
||||||
public:
|
public:
|
||||||
explicit DatePrototype(GlobalObject&);
|
explicit DatePrototype(GlobalObject&);
|
||||||
virtual void initialize(Interpreter&, GlobalObject&) override;
|
virtual void initialize(GlobalObject&) override;
|
||||||
virtual ~DatePrototype() override;
|
virtual ~DatePrototype() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -36,9 +36,9 @@ ErrorConstructor::ErrorConstructor(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ErrorConstructor::initialize(Interpreter& interpreter, GlobalObject& global_object)
|
void ErrorConstructor::initialize(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
NativeFunction::initialize(interpreter, global_object);
|
NativeFunction::initialize(global_object);
|
||||||
define_property("prototype", global_object.error_prototype(), 0);
|
define_property("prototype", global_object.error_prototype(), 0);
|
||||||
define_property("length", Value(1), Attribute::Configurable);
|
define_property("length", Value(1), Attribute::Configurable);
|
||||||
}
|
}
|
||||||
|
@ -68,9 +68,9 @@ Value ErrorConstructor::construct(Interpreter& interpreter, Function&)
|
||||||
: NativeFunction(*global_object.function_prototype()) \
|
: NativeFunction(*global_object.function_prototype()) \
|
||||||
{ \
|
{ \
|
||||||
} \
|
} \
|
||||||
void ConstructorName::initialize(Interpreter& interpreter, GlobalObject& global_object) \
|
void ConstructorName::initialize(GlobalObject& global_object) \
|
||||||
{ \
|
{ \
|
||||||
NativeFunction::initialize(interpreter, global_object); \
|
NativeFunction::initialize(global_object); \
|
||||||
define_property("prototype", global_object.snake_name##_prototype(), 0); \
|
define_property("prototype", global_object.snake_name##_prototype(), 0); \
|
||||||
define_property("length", Value(1), Attribute::Configurable); \
|
define_property("length", Value(1), Attribute::Configurable); \
|
||||||
} \
|
} \
|
||||||
|
|
|
@ -36,7 +36,7 @@ class ErrorConstructor final : public NativeFunction {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ErrorConstructor(GlobalObject&);
|
explicit ErrorConstructor(GlobalObject&);
|
||||||
virtual void initialize(Interpreter&, GlobalObject&) override;
|
virtual void initialize(GlobalObject&) override;
|
||||||
virtual ~ErrorConstructor() override;
|
virtual ~ErrorConstructor() override;
|
||||||
|
|
||||||
virtual Value call(Interpreter&) override;
|
virtual Value call(Interpreter&) override;
|
||||||
|
@ -52,7 +52,7 @@ private:
|
||||||
\
|
\
|
||||||
public: \
|
public: \
|
||||||
explicit ConstructorName(GlobalObject&); \
|
explicit ConstructorName(GlobalObject&); \
|
||||||
virtual void initialize(Interpreter&, GlobalObject&) override; \
|
virtual void initialize(GlobalObject&) override; \
|
||||||
virtual ~ConstructorName() override; \
|
virtual ~ConstructorName() override; \
|
||||||
virtual Value call(Interpreter&) override; \
|
virtual Value call(Interpreter&) override; \
|
||||||
virtual Value construct(Interpreter&, Function& new_target) override; \
|
virtual Value construct(Interpreter&, Function& new_target) override; \
|
||||||
|
|
|
@ -40,9 +40,9 @@ ErrorPrototype::ErrorPrototype(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ErrorPrototype::initialize(Interpreter& interpreter, GlobalObject& global_object)
|
void ErrorPrototype::initialize(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
Object::initialize(interpreter, global_object);
|
Object::initialize(global_object);
|
||||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||||
define_native_property("name", name_getter, name_setter, attr);
|
define_native_property("name", name_getter, name_setter, attr);
|
||||||
define_native_property("message", message_getter, nullptr, attr);
|
define_native_property("message", message_getter, nullptr, attr);
|
||||||
|
|
|
@ -35,7 +35,7 @@ class ErrorPrototype final : public Object {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ErrorPrototype(GlobalObject&);
|
explicit ErrorPrototype(GlobalObject&);
|
||||||
virtual void initialize(Interpreter&, GlobalObject&) override;
|
virtual void initialize(GlobalObject&) override;
|
||||||
virtual ~ErrorPrototype() override;
|
virtual ~ErrorPrototype() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -53,7 +53,7 @@ private:
|
||||||
\
|
\
|
||||||
public: \
|
public: \
|
||||||
explicit PrototypeName(GlobalObject&); \
|
explicit PrototypeName(GlobalObject&); \
|
||||||
virtual void initialize(Interpreter&, GlobalObject&) override { } \
|
virtual void initialize(GlobalObject&) override { } \
|
||||||
virtual ~PrototypeName() override; \
|
virtual ~PrototypeName() override; \
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual ~Function();
|
virtual ~Function();
|
||||||
virtual void initialize(Interpreter&, GlobalObject&) override { }
|
virtual void initialize(GlobalObject&) override { }
|
||||||
|
|
||||||
virtual Value call(Interpreter&) = 0;
|
virtual Value call(Interpreter&) = 0;
|
||||||
virtual Value construct(Interpreter&, Function& new_target) = 0;
|
virtual Value construct(Interpreter&, Function& new_target) = 0;
|
||||||
|
|
|
@ -40,9 +40,9 @@ FunctionConstructor::FunctionConstructor(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void FunctionConstructor::initialize(Interpreter& interpreter, GlobalObject& global_object)
|
void FunctionConstructor::initialize(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
NativeFunction::initialize(interpreter, global_object);
|
NativeFunction::initialize(global_object);
|
||||||
define_property("prototype", global_object.function_prototype(), 0);
|
define_property("prototype", global_object.function_prototype(), 0);
|
||||||
define_property("length", Value(1), Attribute::Configurable);
|
define_property("length", Value(1), Attribute::Configurable);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ class FunctionConstructor final : public NativeFunction {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit FunctionConstructor(GlobalObject&);
|
explicit FunctionConstructor(GlobalObject&);
|
||||||
virtual void initialize(Interpreter&, GlobalObject&) override;
|
virtual void initialize(GlobalObject&) override;
|
||||||
virtual ~FunctionConstructor() override;
|
virtual ~FunctionConstructor() override;
|
||||||
|
|
||||||
virtual Value call(Interpreter&) override;
|
virtual Value call(Interpreter&) override;
|
||||||
|
|
|
@ -43,15 +43,15 @@ FunctionPrototype::FunctionPrototype(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void FunctionPrototype::initialize(Interpreter& interpreter, GlobalObject& global_object)
|
void FunctionPrototype::initialize(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
Object::initialize(interpreter, global_object);
|
Object::initialize(global_object);
|
||||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||||
define_native_function("apply", apply, 2, attr);
|
define_native_function("apply", apply, 2, attr);
|
||||||
define_native_function("bind", bind, 1, attr);
|
define_native_function("bind", bind, 1, attr);
|
||||||
define_native_function("call", call, 1, attr);
|
define_native_function("call", call, 1, attr);
|
||||||
define_native_function("toString", to_string, 0, attr);
|
define_native_function("toString", to_string, 0, attr);
|
||||||
define_native_function(interpreter.well_known_symbol_has_instance(), symbol_has_instance, 1, 0);
|
define_native_function(global_object.interpreter().well_known_symbol_has_instance(), symbol_has_instance, 1, 0);
|
||||||
define_property("length", Value(0), Attribute::Configurable);
|
define_property("length", Value(0), Attribute::Configurable);
|
||||||
define_property("name", js_string(heap(), ""), Attribute::Configurable);
|
define_property("name", js_string(heap(), ""), Attribute::Configurable);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ class FunctionPrototype final : public Object {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit FunctionPrototype(GlobalObject&);
|
explicit FunctionPrototype(GlobalObject&);
|
||||||
virtual void initialize(Interpreter&, GlobalObject&) override;
|
virtual void initialize(GlobalObject&) override;
|
||||||
virtual ~FunctionPrototype() override;
|
virtual ~FunctionPrototype() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -78,8 +78,8 @@ void GlobalObject::initialize()
|
||||||
m_object_prototype = heap().allocate_without_global_object<ObjectPrototype>(*this);
|
m_object_prototype = heap().allocate_without_global_object<ObjectPrototype>(*this);
|
||||||
m_function_prototype = heap().allocate_without_global_object<FunctionPrototype>(*this);
|
m_function_prototype = heap().allocate_without_global_object<FunctionPrototype>(*this);
|
||||||
|
|
||||||
static_cast<FunctionPrototype*>(m_function_prototype)->initialize(heap().interpreter(), *this);
|
static_cast<FunctionPrototype*>(m_function_prototype)->initialize(*this);
|
||||||
static_cast<ObjectPrototype*>(m_object_prototype)->initialize(heap().interpreter(), *this);
|
static_cast<ObjectPrototype*>(m_object_prototype)->initialize(*this);
|
||||||
|
|
||||||
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \
|
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \
|
||||||
if (!m_##snake_name##_prototype) \
|
if (!m_##snake_name##_prototype) \
|
||||||
|
|
|
@ -96,9 +96,9 @@ void iterator_close(Object& iterator)
|
||||||
TODO();
|
TODO();
|
||||||
}
|
}
|
||||||
|
|
||||||
Value create_iterator_result_object(Interpreter& interpreter, GlobalObject& global_object, Value value, bool done)
|
Value create_iterator_result_object(GlobalObject& global_object, Value value, bool done)
|
||||||
{
|
{
|
||||||
auto* object = Object::create_empty(interpreter, global_object);
|
auto* object = Object::create_empty(global_object);
|
||||||
object->define_property("value", value);
|
object->define_property("value", value);
|
||||||
object->define_property("done", Value(done));
|
object->define_property("done", Value(done));
|
||||||
return object;
|
return object;
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace JS {
|
||||||
|
|
||||||
Object* get_iterator(GlobalObject&, Value value, String hint = "sync", Value method = {});
|
Object* get_iterator(GlobalObject&, Value value, String hint = "sync", Value method = {});
|
||||||
bool is_iterator_complete(Object& iterator_result);
|
bool is_iterator_complete(Object& iterator_result);
|
||||||
Value create_iterator_result_object(Interpreter&, GlobalObject&, Value value, bool done);
|
Value create_iterator_result_object(GlobalObject&, Value value, bool done);
|
||||||
|
|
||||||
Object* iterator_next(Object& iterator, Value value = {});
|
Object* iterator_next(Object& iterator, Value value = {});
|
||||||
void iterator_close(Object& iterator);
|
void iterator_close(Object& iterator);
|
||||||
|
|
|
@ -34,10 +34,10 @@ IteratorPrototype::IteratorPrototype(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void IteratorPrototype::initialize(Interpreter& interpreter, GlobalObject& global_object)
|
void IteratorPrototype::initialize(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
Object::initialize(interpreter, global_object);
|
Object::initialize(global_object);
|
||||||
define_native_function(interpreter.well_known_symbol_iterator(), symbol_iterator, 0, Attribute::Writable | Attribute::Enumerable);
|
define_native_function(global_object.interpreter().well_known_symbol_iterator(), symbol_iterator, 0, Attribute::Writable | Attribute::Enumerable);
|
||||||
}
|
}
|
||||||
|
|
||||||
IteratorPrototype::~IteratorPrototype()
|
IteratorPrototype::~IteratorPrototype()
|
||||||
|
|
|
@ -35,7 +35,7 @@ class IteratorPrototype : public Object {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IteratorPrototype(GlobalObject&);
|
IteratorPrototype(GlobalObject&);
|
||||||
virtual void initialize(Interpreter&, GlobalObject&) override;
|
virtual void initialize(GlobalObject&) override;
|
||||||
virtual ~IteratorPrototype() override;
|
virtual ~IteratorPrototype() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -42,14 +42,14 @@ JSONObject::JSONObject(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void JSONObject::initialize(Interpreter& interpreter, GlobalObject& global_object)
|
void JSONObject::initialize(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
Object::initialize(interpreter, global_object);
|
Object::initialize(global_object);
|
||||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||||
define_native_function("stringify", stringify, 3, attr);
|
define_native_function("stringify", stringify, 3, attr);
|
||||||
define_native_function("parse", parse, 2, attr);
|
define_native_function("parse", parse, 2, attr);
|
||||||
|
|
||||||
define_property(interpreter.well_known_symbol_to_string_tag(), js_string(interpreter, "JSON"), Attribute::Configurable);
|
define_property(global_object.interpreter().well_known_symbol_to_string_tag(), js_string(global_object.heap(), "JSON"), Attribute::Configurable);
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONObject::~JSONObject()
|
JSONObject::~JSONObject()
|
||||||
|
@ -117,7 +117,7 @@ String JSONObject::stringify_impl(Interpreter& interpreter, GlobalObject& global
|
||||||
state.gap = String::empty();
|
state.gap = String::empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* wrapper = Object::create_empty(interpreter, global_object);
|
auto* wrapper = Object::create_empty(global_object);
|
||||||
wrapper->define_property(String::empty(), value);
|
wrapper->define_property(String::empty(), value);
|
||||||
if (interpreter.exception())
|
if (interpreter.exception())
|
||||||
return {};
|
return {};
|
||||||
|
@ -401,7 +401,7 @@ JS_DEFINE_NATIVE_FUNCTION(JSONObject::parse)
|
||||||
}
|
}
|
||||||
Value result = parse_json_value(interpreter, global_object, json.value());
|
Value result = parse_json_value(interpreter, global_object, json.value());
|
||||||
if (reviver.is_function()) {
|
if (reviver.is_function()) {
|
||||||
auto* holder_object = Object::create_empty(interpreter, global_object);
|
auto* holder_object = Object::create_empty(global_object);
|
||||||
holder_object->define_property(String::empty(), result);
|
holder_object->define_property(String::empty(), result);
|
||||||
if (interpreter.exception())
|
if (interpreter.exception())
|
||||||
return {};
|
return {};
|
||||||
|
@ -433,7 +433,7 @@ Value JSONObject::parse_json_value(Interpreter& interpreter, GlobalObject& globa
|
||||||
|
|
||||||
Object* JSONObject::parse_json_object(Interpreter& interpreter, GlobalObject& global_object, const JsonObject& json_object)
|
Object* JSONObject::parse_json_object(Interpreter& interpreter, GlobalObject& global_object, const JsonObject& json_object)
|
||||||
{
|
{
|
||||||
auto* object = Object::create_empty(interpreter, global_object);
|
auto* object = Object::create_empty(global_object);
|
||||||
json_object.for_each_member([&](auto& key, auto& value) {
|
json_object.for_each_member([&](auto& key, auto& value) {
|
||||||
object->define_property(key, parse_json_value(interpreter, global_object, value));
|
object->define_property(key, parse_json_value(interpreter, global_object, value));
|
||||||
});
|
});
|
||||||
|
|
|
@ -35,7 +35,7 @@ class JSONObject final : public Object {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit JSONObject(GlobalObject&);
|
explicit JSONObject(GlobalObject&);
|
||||||
virtual void initialize(Interpreter&, GlobalObject&) override;
|
virtual void initialize(GlobalObject&) override;
|
||||||
virtual ~JSONObject() override;
|
virtual ~JSONObject() override;
|
||||||
|
|
||||||
// The base implementation of stringify is exposed because it is used by
|
// The base implementation of stringify is exposed because it is used by
|
||||||
|
|
|
@ -39,9 +39,9 @@ MathObject::MathObject(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void MathObject::initialize(Interpreter& interpreter, GlobalObject& global_object)
|
void MathObject::initialize(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
Object::initialize(interpreter, global_object);
|
Object::initialize(global_object);
|
||||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||||
define_native_function("abs", abs, 1, attr);
|
define_native_function("abs", abs, 1, attr);
|
||||||
define_native_function("random", random, 0, attr);
|
define_native_function("random", random, 0, attr);
|
||||||
|
@ -75,7 +75,7 @@ void MathObject::initialize(Interpreter& interpreter, GlobalObject& global_objec
|
||||||
define_property("SQRT1_2", Value(M_SQRT1_2), 0);
|
define_property("SQRT1_2", Value(M_SQRT1_2), 0);
|
||||||
define_property("SQRT2", Value(M_SQRT2), 0);
|
define_property("SQRT2", Value(M_SQRT2), 0);
|
||||||
|
|
||||||
define_property(interpreter.well_known_symbol_to_string_tag(), js_string(interpreter, "Math"), Attribute::Configurable);
|
define_property(global_object.interpreter().well_known_symbol_to_string_tag(), js_string(global_object.heap(), "Math"), Attribute::Configurable);
|
||||||
}
|
}
|
||||||
|
|
||||||
MathObject::~MathObject()
|
MathObject::~MathObject()
|
||||||
|
|
|
@ -35,7 +35,7 @@ class MathObject final : public Object {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MathObject(GlobalObject&);
|
explicit MathObject(GlobalObject&);
|
||||||
virtual void initialize(Interpreter&, GlobalObject&) override;
|
virtual void initialize(GlobalObject&) override;
|
||||||
virtual ~MathObject() override;
|
virtual ~MathObject() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -38,7 +38,7 @@ public:
|
||||||
static NativeFunction* create(Interpreter&, GlobalObject&, const FlyString& name, AK::Function<Value(Interpreter&, GlobalObject&)>);
|
static NativeFunction* create(Interpreter&, GlobalObject&, const FlyString& name, AK::Function<Value(Interpreter&, GlobalObject&)>);
|
||||||
|
|
||||||
explicit NativeFunction(const FlyString& name, AK::Function<Value(Interpreter&, GlobalObject&)>, Object& prototype);
|
explicit NativeFunction(const FlyString& name, AK::Function<Value(Interpreter&, GlobalObject&)>, Object& prototype);
|
||||||
virtual void initialize(Interpreter&, GlobalObject&) override { }
|
virtual void initialize(GlobalObject&) override { }
|
||||||
virtual ~NativeFunction() override;
|
virtual ~NativeFunction() override;
|
||||||
|
|
||||||
virtual Value call(Interpreter&) override;
|
virtual Value call(Interpreter&) override;
|
||||||
|
|
|
@ -42,9 +42,9 @@ NumberConstructor::NumberConstructor(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void NumberConstructor::initialize(Interpreter& interpreter, GlobalObject& global_object)
|
void NumberConstructor::initialize(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
NativeFunction::initialize(interpreter, global_object);
|
NativeFunction::initialize(global_object);
|
||||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||||
define_native_function("isFinite", is_finite, 1, attr);
|
define_native_function("isFinite", is_finite, 1, attr);
|
||||||
define_native_function("isInteger", is_integer, 1, attr);
|
define_native_function("isInteger", is_integer, 1, attr);
|
||||||
|
|
|
@ -35,7 +35,7 @@ class NumberConstructor final : public NativeFunction {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit NumberConstructor(GlobalObject&);
|
explicit NumberConstructor(GlobalObject&);
|
||||||
virtual void initialize(Interpreter&, GlobalObject&) override;
|
virtual void initialize(GlobalObject&) override;
|
||||||
virtual ~NumberConstructor() override;
|
virtual ~NumberConstructor() override;
|
||||||
|
|
||||||
virtual Value call(Interpreter&) override;
|
virtual Value call(Interpreter&) override;
|
||||||
|
|
|
@ -46,9 +46,9 @@ NumberPrototype::NumberPrototype(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void NumberPrototype::initialize(Interpreter& interpreter, GlobalObject& object)
|
void NumberPrototype::initialize(GlobalObject& object)
|
||||||
{
|
{
|
||||||
Object::initialize(interpreter, object);
|
Object::initialize(object);
|
||||||
|
|
||||||
define_native_function("toString", to_string, 1, Attribute::Configurable | Attribute::Writable);
|
define_native_function("toString", to_string, 1, Attribute::Configurable | Attribute::Writable);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ class NumberPrototype final : public NumberObject {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit NumberPrototype(GlobalObject&);
|
explicit NumberPrototype(GlobalObject&);
|
||||||
virtual void initialize(Interpreter&, GlobalObject&) override;
|
virtual void initialize(GlobalObject&) override;
|
||||||
virtual ~NumberPrototype() override;
|
virtual ~NumberPrototype() override;
|
||||||
|
|
||||||
JS_DECLARE_NATIVE_FUNCTION(to_string);
|
JS_DECLARE_NATIVE_FUNCTION(to_string);
|
||||||
|
|
|
@ -82,7 +82,7 @@ PropertyDescriptor PropertyDescriptor::from_dictionary(Interpreter& interpreter,
|
||||||
return descriptor;
|
return descriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object* Object::create_empty(Interpreter&, GlobalObject& global_object)
|
Object* Object::create_empty(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
return global_object.heap().allocate<Object>(global_object, *global_object.object_prototype());
|
return global_object.heap().allocate<Object>(global_object, *global_object.object_prototype());
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ Object::Object(Object& prototype)
|
||||||
set_prototype(&prototype);
|
set_prototype(&prototype);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Object::initialize(Interpreter&, GlobalObject&)
|
void Object::initialize(GlobalObject&)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,7 +301,7 @@ Value Object::get_own_property_descriptor_object(const PropertyName& property_na
|
||||||
return js_undefined();
|
return js_undefined();
|
||||||
auto descriptor = descriptor_opt.value();
|
auto descriptor = descriptor_opt.value();
|
||||||
|
|
||||||
auto* descriptor_object = Object::create_empty(interpreter(), global_object());
|
auto* descriptor_object = Object::create_empty(global_object());
|
||||||
descriptor_object->define_property("enumerable", Value(descriptor.attributes.is_enumerable()));
|
descriptor_object->define_property("enumerable", Value(descriptor.attributes.is_enumerable()));
|
||||||
if (interpreter().exception())
|
if (interpreter().exception())
|
||||||
return {};
|
return {};
|
||||||
|
|
|
@ -60,10 +60,10 @@ struct PropertyDescriptor {
|
||||||
|
|
||||||
class Object : public Cell {
|
class Object : public Cell {
|
||||||
public:
|
public:
|
||||||
static Object* create_empty(Interpreter&, GlobalObject&);
|
static Object* create_empty(GlobalObject&);
|
||||||
|
|
||||||
explicit Object(Object& prototype);
|
explicit Object(Object& prototype);
|
||||||
virtual void initialize(Interpreter&, GlobalObject&) override;
|
virtual void initialize(GlobalObject&) override;
|
||||||
virtual ~Object();
|
virtual ~Object();
|
||||||
|
|
||||||
virtual bool inherits(const StringView& class_name) const { return class_name == this->class_name(); }
|
virtual bool inherits(const StringView& class_name) const { return class_name == this->class_name(); }
|
||||||
|
|
|
@ -40,9 +40,9 @@ ObjectConstructor::ObjectConstructor(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectConstructor::initialize(Interpreter& interpreter, GlobalObject& global_object)
|
void ObjectConstructor::initialize(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
NativeFunction::initialize(interpreter, global_object);
|
NativeFunction::initialize(global_object);
|
||||||
define_property("prototype", global_object.object_prototype(), 0);
|
define_property("prototype", global_object.object_prototype(), 0);
|
||||||
define_property("length", Value(1), Attribute::Configurable);
|
define_property("length", Value(1), Attribute::Configurable);
|
||||||
|
|
||||||
|
@ -64,9 +64,9 @@ ObjectConstructor::~ObjectConstructor()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ObjectConstructor::call(Interpreter& interpreter)
|
Value ObjectConstructor::call(Interpreter&)
|
||||||
{
|
{
|
||||||
return Object::create_empty(interpreter, global_object());
|
return Object::create_empty(global_object());
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ObjectConstructor::construct(Interpreter& interpreter, Function&)
|
Value ObjectConstructor::construct(Interpreter& interpreter, Function&)
|
||||||
|
|
|
@ -35,7 +35,7 @@ class ObjectConstructor final : public NativeFunction {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ObjectConstructor(GlobalObject&);
|
explicit ObjectConstructor(GlobalObject&);
|
||||||
virtual void initialize(Interpreter&, GlobalObject&) override;
|
virtual void initialize(GlobalObject&) override;
|
||||||
virtual ~ObjectConstructor() override;
|
virtual ~ObjectConstructor() override;
|
||||||
|
|
||||||
virtual Value call(Interpreter&) override;
|
virtual Value call(Interpreter&) override;
|
||||||
|
|
|
@ -39,9 +39,9 @@ ObjectPrototype::ObjectPrototype(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectPrototype::initialize(Interpreter& interpreter, GlobalObject& global_object)
|
void ObjectPrototype::initialize(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
Object::initialize(interpreter, global_object);
|
Object::initialize(global_object);
|
||||||
// This must be called after the constructor has returned, so that the below code
|
// This must be called after the constructor has returned, so that the below code
|
||||||
// can find the ObjectPrototype through normal paths.
|
// can find the ObjectPrototype through normal paths.
|
||||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||||
|
@ -80,7 +80,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectPrototype::to_string)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
String tag;
|
String tag;
|
||||||
auto to_string_tag = this_object->get(interpreter.well_known_symbol_to_string_tag());
|
auto to_string_tag = this_object->get(global_object.interpreter().well_known_symbol_to_string_tag());
|
||||||
|
|
||||||
if (to_string_tag.is_string()) {
|
if (to_string_tag.is_string()) {
|
||||||
tag = to_string_tag.as_string().string();
|
tag = to_string_tag.as_string().string();
|
||||||
|
|
|
@ -35,7 +35,7 @@ class ObjectPrototype final : public Object {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ObjectPrototype(GlobalObject&);
|
explicit ObjectPrototype(GlobalObject&);
|
||||||
virtual void initialize(Interpreter&, GlobalObject&) override;
|
virtual void initialize(GlobalObject&) override;
|
||||||
virtual ~ObjectPrototype() override;
|
virtual ~ObjectPrototype() override;
|
||||||
|
|
||||||
// public to serve as intrinsic function %Object.prototype.toString%
|
// public to serve as intrinsic function %Object.prototype.toString%
|
||||||
|
|
|
@ -38,9 +38,9 @@ ProxyConstructor::ProxyConstructor(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProxyConstructor::initialize(Interpreter& interpreter, GlobalObject& global_object)
|
void ProxyConstructor::initialize(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
NativeFunction::initialize(interpreter, global_object);
|
NativeFunction::initialize(global_object);
|
||||||
define_property("prototype", global_object.proxy_prototype(), 0);
|
define_property("prototype", global_object.proxy_prototype(), 0);
|
||||||
define_property("length", Value(2), Attribute::Configurable);
|
define_property("length", Value(2), Attribute::Configurable);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ class ProxyConstructor final : public NativeFunction {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ProxyConstructor(GlobalObject&);
|
explicit ProxyConstructor(GlobalObject&);
|
||||||
virtual void initialize(Interpreter&, GlobalObject&) override;
|
virtual void initialize(GlobalObject&) override;
|
||||||
virtual ~ProxyConstructor() override;
|
virtual ~ProxyConstructor() override;
|
||||||
|
|
||||||
virtual Value call(Interpreter&) override;
|
virtual Value call(Interpreter&) override;
|
||||||
|
|
|
@ -80,9 +80,9 @@ ReflectObject::ReflectObject(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReflectObject::initialize(Interpreter& interpreter, GlobalObject& global_object)
|
void ReflectObject::initialize(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
Object::initialize(interpreter, global_object);
|
Object::initialize(global_object);
|
||||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||||
define_native_function("apply", apply, 3, attr);
|
define_native_function("apply", apply, 3, attr);
|
||||||
define_native_function("construct", construct, 2, attr);
|
define_native_function("construct", construct, 2, attr);
|
||||||
|
|
|
@ -35,7 +35,7 @@ class ReflectObject final : public Object {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ReflectObject(GlobalObject&);
|
explicit ReflectObject(GlobalObject&);
|
||||||
virtual void initialize(Interpreter&, GlobalObject&) override;
|
virtual void initialize(GlobalObject&) override;
|
||||||
virtual ~ReflectObject() override;
|
virtual ~ReflectObject() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -37,9 +37,9 @@ RegExpConstructor::RegExpConstructor(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegExpConstructor::initialize(Interpreter& interpreter, GlobalObject& global_object)
|
void RegExpConstructor::initialize(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
NativeFunction::initialize(interpreter, global_object);
|
NativeFunction::initialize(global_object);
|
||||||
define_property("prototype", global_object.regexp_prototype(), 0);
|
define_property("prototype", global_object.regexp_prototype(), 0);
|
||||||
define_property("length", Value(2), Attribute::Configurable);
|
define_property("length", Value(2), Attribute::Configurable);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ class RegExpConstructor final : public NativeFunction {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit RegExpConstructor(GlobalObject&);
|
explicit RegExpConstructor(GlobalObject&);
|
||||||
virtual void initialize(Interpreter&, GlobalObject&) override;
|
virtual void initialize(GlobalObject&) override;
|
||||||
virtual ~RegExpConstructor() override;
|
virtual ~RegExpConstructor() override;
|
||||||
|
|
||||||
virtual Value call(Interpreter&) override;
|
virtual Value call(Interpreter&) override;
|
||||||
|
|
|
@ -63,11 +63,11 @@ ScriptFunction::ScriptFunction(GlobalObject& global_object, const FlyString& nam
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptFunction::initialize(Interpreter& interpreter, GlobalObject& global_object)
|
void ScriptFunction::initialize(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
Function::initialize(interpreter, global_object);
|
Function::initialize(global_object);
|
||||||
if (!m_is_arrow_function) {
|
if (!m_is_arrow_function) {
|
||||||
Object* prototype = Object::create_empty(interpreter, global_object);
|
Object* prototype = Object::create_empty(global_object);
|
||||||
prototype->define_property("constructor", this, Attribute::Writable | Attribute::Configurable);
|
prototype->define_property("constructor", this, Attribute::Writable | Attribute::Configurable);
|
||||||
define_property("prototype", prototype, 0);
|
define_property("prototype", prototype, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ public:
|
||||||
static ScriptFunction* create(GlobalObject&, const FlyString& name, const Statement& body, Vector<FunctionNode::Parameter> parameters, i32 m_function_length, LexicalEnvironment* parent_environment, bool is_arrow_function = false);
|
static ScriptFunction* create(GlobalObject&, const FlyString& name, const Statement& body, Vector<FunctionNode::Parameter> parameters, i32 m_function_length, LexicalEnvironment* parent_environment, bool is_arrow_function = false);
|
||||||
|
|
||||||
ScriptFunction(GlobalObject&, const FlyString& name, const Statement& body, Vector<FunctionNode::Parameter> parameters, i32 m_function_length, LexicalEnvironment* parent_environment, Object& prototype, bool is_arrow_function = false);
|
ScriptFunction(GlobalObject&, const FlyString& name, const Statement& body, Vector<FunctionNode::Parameter> parameters, i32 m_function_length, LexicalEnvironment* parent_environment, Object& prototype, bool is_arrow_function = false);
|
||||||
virtual void initialize(Interpreter&, GlobalObject&) override;
|
virtual void initialize(GlobalObject&) override;
|
||||||
virtual ~ScriptFunction();
|
virtual ~ScriptFunction();
|
||||||
|
|
||||||
const Statement& body() const { return m_body; }
|
const Statement& body() const { return m_body; }
|
||||||
|
|
|
@ -40,9 +40,9 @@ StringConstructor::StringConstructor(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void StringConstructor::initialize(Interpreter& interpreter, GlobalObject& global_object)
|
void StringConstructor::initialize(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
NativeFunction::initialize(interpreter, global_object);
|
NativeFunction::initialize(global_object);
|
||||||
define_property("prototype", global_object.string_prototype(), 0);
|
define_property("prototype", global_object.string_prototype(), 0);
|
||||||
define_property("length", Value(1), Attribute::Configurable);
|
define_property("length", Value(1), Attribute::Configurable);
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ class StringConstructor final : public NativeFunction {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit StringConstructor(GlobalObject&);
|
explicit StringConstructor(GlobalObject&);
|
||||||
virtual void initialize(Interpreter&, GlobalObject&) override;
|
virtual void initialize(GlobalObject&) override;
|
||||||
virtual ~StringConstructor() override;
|
virtual ~StringConstructor() override;
|
||||||
|
|
||||||
virtual Value call(Interpreter&) override;
|
virtual Value call(Interpreter&) override;
|
||||||
|
|
|
@ -38,12 +38,12 @@ StringIteratorPrototype::StringIteratorPrototype(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void StringIteratorPrototype::initialize(Interpreter& interpreter, GlobalObject& global_object)
|
void StringIteratorPrototype::initialize(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
Object::initialize(interpreter, global_object);
|
Object::initialize(global_object);
|
||||||
|
|
||||||
define_native_function("next", next, 0, Attribute::Configurable | Attribute::Writable);
|
define_native_function("next", next, 0, Attribute::Configurable | Attribute::Writable);
|
||||||
define_property(interpreter.well_known_symbol_to_string_tag(), js_string(interpreter, "String Iterator"), Attribute::Configurable);
|
define_property(global_object.interpreter().well_known_symbol_to_string_tag(), js_string(global_object.heap(), "String Iterator"), Attribute::Configurable);
|
||||||
}
|
}
|
||||||
|
|
||||||
StringIteratorPrototype::~StringIteratorPrototype()
|
StringIteratorPrototype::~StringIteratorPrototype()
|
||||||
|
@ -59,20 +59,20 @@ JS_DEFINE_NATIVE_FUNCTION(StringIteratorPrototype::next)
|
||||||
auto& this_object = this_value.as_object();
|
auto& this_object = this_value.as_object();
|
||||||
auto& iterator = static_cast<StringIterator&>(this_object);
|
auto& iterator = static_cast<StringIterator&>(this_object);
|
||||||
if (iterator.done())
|
if (iterator.done())
|
||||||
return create_iterator_result_object(interpreter, global_object, js_undefined(), true);
|
return create_iterator_result_object(global_object, js_undefined(), true);
|
||||||
|
|
||||||
auto& utf8_iterator = iterator.iterator();
|
auto& utf8_iterator = iterator.iterator();
|
||||||
|
|
||||||
if (utf8_iterator.done()) {
|
if (utf8_iterator.done()) {
|
||||||
iterator.m_done = true;
|
iterator.m_done = true;
|
||||||
return create_iterator_result_object(interpreter, global_object, js_undefined(), true);
|
return create_iterator_result_object(global_object, js_undefined(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
builder.append_codepoint(*utf8_iterator);
|
builder.append_codepoint(*utf8_iterator);
|
||||||
++utf8_iterator;
|
++utf8_iterator;
|
||||||
|
|
||||||
return create_iterator_result_object(interpreter, global_object, js_string(interpreter, builder.to_string()), false);
|
return create_iterator_result_object(global_object, js_string(interpreter, builder.to_string()), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ class StringIteratorPrototype final : public Object {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
StringIteratorPrototype(GlobalObject&);
|
StringIteratorPrototype(GlobalObject&);
|
||||||
virtual void initialize(Interpreter&, GlobalObject&) override;
|
virtual void initialize(GlobalObject&) override;
|
||||||
virtual ~StringIteratorPrototype() override;
|
virtual ~StringIteratorPrototype() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -65,9 +65,9 @@ StringPrototype::StringPrototype(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void StringPrototype::initialize(Interpreter& interpreter, GlobalObject& global_object)
|
void StringPrototype::initialize(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
StringObject::initialize(interpreter, global_object);
|
StringObject::initialize(global_object);
|
||||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||||
|
|
||||||
define_native_property("length", length_getter, nullptr, 0);
|
define_native_property("length", length_getter, nullptr, 0);
|
||||||
|
@ -89,7 +89,7 @@ void StringPrototype::initialize(Interpreter& interpreter, GlobalObject& global_
|
||||||
define_native_function("includes", includes, 1, attr);
|
define_native_function("includes", includes, 1, attr);
|
||||||
define_native_function("slice", slice, 2, attr);
|
define_native_function("slice", slice, 2, attr);
|
||||||
define_native_function("lastIndexOf", last_index_of, 1, attr);
|
define_native_function("lastIndexOf", last_index_of, 1, attr);
|
||||||
define_native_function(interpreter.well_known_symbol_iterator(), symbol_iterator, 0, attr);
|
define_native_function(global_object.interpreter().well_known_symbol_iterator(), symbol_iterator, 0, attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
StringPrototype::~StringPrototype()
|
StringPrototype::~StringPrototype()
|
||||||
|
|
|
@ -35,7 +35,7 @@ class StringPrototype final : public StringObject {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit StringPrototype(GlobalObject&);
|
explicit StringPrototype(GlobalObject&);
|
||||||
virtual void initialize(Interpreter&, GlobalObject&) override;
|
virtual void initialize(GlobalObject&) override;
|
||||||
virtual ~StringPrototype() override;
|
virtual ~StringPrototype() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -37,9 +37,9 @@ SymbolConstructor::SymbolConstructor(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void SymbolConstructor::initialize(Interpreter& interpreter, GlobalObject& global_object)
|
void SymbolConstructor::initialize(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
NativeFunction::initialize(interpreter, global_object);
|
NativeFunction::initialize(global_object);
|
||||||
define_property("prototype", global_object.symbol_prototype(), 0);
|
define_property("prototype", global_object.symbol_prototype(), 0);
|
||||||
define_property("length", Value(0), Attribute::Configurable);
|
define_property("length", Value(0), Attribute::Configurable);
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ void SymbolConstructor::initialize(Interpreter& interpreter, GlobalObject& globa
|
||||||
define_native_function("keyFor", key_for, 1, Attribute::Writable | Attribute::Configurable);
|
define_native_function("keyFor", key_for, 1, Attribute::Writable | Attribute::Configurable);
|
||||||
|
|
||||||
#define __JS_ENUMERATE(SymbolName, snake_name) \
|
#define __JS_ENUMERATE(SymbolName, snake_name) \
|
||||||
define_property(#SymbolName, interpreter.well_known_symbol_##snake_name(), 0);
|
define_property(#SymbolName, global_object.interpreter().well_known_symbol_##snake_name(), 0);
|
||||||
JS_ENUMERATE_WELL_KNOWN_SYMBOLS
|
JS_ENUMERATE_WELL_KNOWN_SYMBOLS
|
||||||
#undef __JS_ENUMERATE
|
#undef __JS_ENUMERATE
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ class SymbolConstructor final : public NativeFunction {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SymbolConstructor(GlobalObject&);
|
explicit SymbolConstructor(GlobalObject&);
|
||||||
virtual void initialize(Interpreter&, GlobalObject&) override;
|
virtual void initialize(GlobalObject&) override;
|
||||||
virtual ~SymbolConstructor() override;
|
virtual ~SymbolConstructor() override;
|
||||||
|
|
||||||
virtual Value call(Interpreter&) override;
|
virtual Value call(Interpreter&) override;
|
||||||
|
|
|
@ -44,14 +44,14 @@ SymbolPrototype::SymbolPrototype(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void SymbolPrototype::initialize(Interpreter& interpreter, GlobalObject& global_object)
|
void SymbolPrototype::initialize(GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
Object::initialize(interpreter, global_object);
|
Object::initialize(global_object);
|
||||||
define_native_property("description", description_getter, nullptr, Attribute::Configurable);
|
define_native_property("description", description_getter, nullptr, Attribute::Configurable);
|
||||||
define_native_function("toString", to_string, 0, Attribute::Writable | Attribute::Configurable);
|
define_native_function("toString", to_string, 0, Attribute::Writable | Attribute::Configurable);
|
||||||
define_native_function("valueOf", value_of, 0, Attribute::Writable | Attribute::Configurable);
|
define_native_function("valueOf", value_of, 0, Attribute::Writable | Attribute::Configurable);
|
||||||
|
|
||||||
define_property(interpreter.well_known_symbol_to_string_tag(), js_string(interpreter, "Symbol"), Attribute::Configurable);
|
define_property(global_object.interpreter().well_known_symbol_to_string_tag(), js_string(global_object.heap(), "Symbol"), Attribute::Configurable);
|
||||||
}
|
}
|
||||||
|
|
||||||
SymbolPrototype::~SymbolPrototype()
|
SymbolPrototype::~SymbolPrototype()
|
||||||
|
|
|
@ -35,7 +35,7 @@ class SymbolPrototype final : public Object {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SymbolPrototype(GlobalObject&);
|
explicit SymbolPrototype(GlobalObject&);
|
||||||
virtual void initialize(Interpreter&, GlobalObject&) override;
|
virtual void initialize(GlobalObject&) override;
|
||||||
virtual ~SymbolPrototype() override;
|
virtual ~SymbolPrototype() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -40,9 +40,9 @@ LocationObject::LocationObject(JS::GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocationObject::initialize(JS::Interpreter& interpreter, JS::GlobalObject& global_object)
|
void LocationObject::initialize(JS::GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
Object::initialize(interpreter, global_object);
|
Object::initialize(global_object);
|
||||||
u8 attr = JS::Attribute::Writable | JS::Attribute::Enumerable;
|
u8 attr = JS::Attribute::Writable | JS::Attribute::Enumerable;
|
||||||
define_native_property("href", href_getter, href_setter, attr);
|
define_native_property("href", href_getter, href_setter, attr);
|
||||||
define_native_property("host", host_getter, nullptr, attr);
|
define_native_property("host", host_getter, nullptr, attr);
|
||||||
|
|
|
@ -37,7 +37,7 @@ class LocationObject final : public JS::Object {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit LocationObject(JS::GlobalObject&);
|
explicit LocationObject(JS::GlobalObject&);
|
||||||
virtual void initialize(JS::Interpreter&, JS::GlobalObject&) override;
|
virtual void initialize(JS::GlobalObject&) override;
|
||||||
virtual ~LocationObject() override;
|
virtual ~LocationObject() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -39,18 +39,19 @@ NavigatorObject::NavigatorObject(JS::GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void NavigatorObject::initialize(JS::Interpreter& interpreter, JS::GlobalObject& global_object)
|
void NavigatorObject::initialize(JS::GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
|
auto& heap = this->heap();
|
||||||
auto* languages = JS::Array::create(global_object);
|
auto* languages = JS::Array::create(global_object);
|
||||||
languages->indexed_properties().append(js_string(heap(), "en-US"));
|
languages->indexed_properties().append(js_string(heap, "en-US"));
|
||||||
|
|
||||||
define_property("appCodeName", js_string(interpreter.heap(), "Mozilla"));
|
define_property("appCodeName", js_string(heap, "Mozilla"));
|
||||||
define_property("appName", js_string(interpreter.heap(), "Netscape"));
|
define_property("appName", js_string(heap, "Netscape"));
|
||||||
define_property("appVersion", js_string(interpreter.heap(), "4.0"));
|
define_property("appVersion", js_string(heap, "4.0"));
|
||||||
define_property("language", languages->get(0));
|
define_property("language", languages->get(0));
|
||||||
define_property("languages", languages);
|
define_property("languages", languages);
|
||||||
define_property("platform", js_string(interpreter.heap(), "SerenityOS"));
|
define_property("platform", js_string(heap, "SerenityOS"));
|
||||||
define_property("product", js_string(interpreter.heap(), "Gecko"));
|
define_property("product", js_string(heap, "Gecko"));
|
||||||
|
|
||||||
define_native_property("userAgent", user_agent_getter, nullptr);
|
define_native_property("userAgent", user_agent_getter, nullptr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ class NavigatorObject final : public JS::Object {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NavigatorObject(JS::GlobalObject&);
|
NavigatorObject(JS::GlobalObject&);
|
||||||
virtual void initialize(JS::Interpreter&, JS::GlobalObject&) override;
|
virtual void initialize(JS::GlobalObject&) override;
|
||||||
virtual ~NavigatorObject() override;
|
virtual ~NavigatorObject() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -40,9 +40,9 @@ XMLHttpRequestConstructor::XMLHttpRequestConstructor(JS::GlobalObject& global_ob
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void XMLHttpRequestConstructor::initialize(JS::Interpreter& interpreter, JS::GlobalObject& global_object)
|
void XMLHttpRequestConstructor::initialize(JS::GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
NativeFunction::initialize(interpreter, global_object);
|
NativeFunction::initialize(global_object);
|
||||||
define_property("length", JS::Value(1), JS::Attribute::Configurable);
|
define_property("length", JS::Value(1), JS::Attribute::Configurable);
|
||||||
|
|
||||||
define_property("UNSENT", JS::Value((i32)XMLHttpRequest::ReadyState::Unsent), JS::Attribute::Enumerable);
|
define_property("UNSENT", JS::Value((i32)XMLHttpRequest::ReadyState::Unsent), JS::Attribute::Enumerable);
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace Web::Bindings {
|
||||||
class XMLHttpRequestConstructor final : public JS::NativeFunction {
|
class XMLHttpRequestConstructor final : public JS::NativeFunction {
|
||||||
public:
|
public:
|
||||||
explicit XMLHttpRequestConstructor(JS::GlobalObject&);
|
explicit XMLHttpRequestConstructor(JS::GlobalObject&);
|
||||||
virtual void initialize(JS::Interpreter&, JS::GlobalObject&) override;
|
virtual void initialize(JS::GlobalObject&) override;
|
||||||
virtual ~XMLHttpRequestConstructor() override;
|
virtual ~XMLHttpRequestConstructor() override;
|
||||||
|
|
||||||
virtual JS::Value call(JS::Interpreter&) override;
|
virtual JS::Value call(JS::Interpreter&) override;
|
||||||
|
|
|
@ -39,9 +39,9 @@ XMLHttpRequestPrototype::XMLHttpRequestPrototype(JS::GlobalObject& global_object
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void XMLHttpRequestPrototype::initialize(JS::Interpreter& interpreter, JS::GlobalObject& global_object)
|
void XMLHttpRequestPrototype::initialize(JS::GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
Object::initialize(interpreter, global_object);
|
Object::initialize(global_object);
|
||||||
define_native_function("open", open, 2);
|
define_native_function("open", open, 2);
|
||||||
define_native_function("send", send, 0);
|
define_native_function("send", send, 0);
|
||||||
define_native_property("readyState", ready_state_getter, nullptr, JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
define_native_property("readyState", ready_state_getter, nullptr, JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||||
|
|
|
@ -35,7 +35,7 @@ class XMLHttpRequestPrototype final : public JS::Object {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit XMLHttpRequestPrototype(JS::GlobalObject&);
|
explicit XMLHttpRequestPrototype(JS::GlobalObject&);
|
||||||
virtual void initialize(JS::Interpreter&, JS::GlobalObject&) override;
|
virtual void initialize(JS::GlobalObject&) override;
|
||||||
virtual ~XMLHttpRequestPrototype() override;
|
virtual ~XMLHttpRequestPrototype() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -365,7 +365,7 @@ static void generate_header(const IDL::Interface& interface)
|
||||||
out() << " JS_OBJECT(" << wrapper_class << ", " << wrapper_base_class << ");";
|
out() << " JS_OBJECT(" << wrapper_class << ", " << wrapper_base_class << ");";
|
||||||
out() << "public:";
|
out() << "public:";
|
||||||
out() << " " << wrapper_class << "(JS::GlobalObject&, " << interface.name << "&);";
|
out() << " " << wrapper_class << "(JS::GlobalObject&, " << interface.name << "&);";
|
||||||
out() << " virtual void initialize(JS::Interpreter&, JS::GlobalObject&) override;";
|
out() << " virtual void initialize(JS::GlobalObject&) override;";
|
||||||
out() << " virtual ~" << wrapper_class << "() override;";
|
out() << " virtual ~" << wrapper_class << "() override;";
|
||||||
|
|
||||||
if (wrapper_base_class == "Wrapper") {
|
if (wrapper_base_class == "Wrapper") {
|
||||||
|
@ -444,10 +444,10 @@ void generate_implementation(const IDL::Interface& interface)
|
||||||
out() << "}";
|
out() << "}";
|
||||||
|
|
||||||
// Implementation: Wrapper initialize()
|
// Implementation: Wrapper initialize()
|
||||||
out() << "void " << wrapper_class << "::initialize(JS::Interpreter& interpreter, JS::GlobalObject& global_object)";
|
out() << "void " << wrapper_class << "::initialize(JS::GlobalObject& global_object)";
|
||||||
out() << "{";
|
out() << "{";
|
||||||
out() << " [[maybe_unused]] u8 default_attributes = JS::Attribute::Enumerable | JS::Attribute::Configurable;";
|
out() << " [[maybe_unused]] u8 default_attributes = JS::Attribute::Enumerable | JS::Attribute::Configurable;";
|
||||||
out() << " " << wrapper_base_class << "::initialize(interpreter, global_object);";
|
out() << " " << wrapper_base_class << "::initialize(global_object);";
|
||||||
|
|
||||||
for (auto& attribute : interface.attributes) {
|
for (auto& attribute : interface.attributes) {
|
||||||
out() << " define_native_property(\"" << attribute.name << "\", " << attribute.getter_callback_name << ", " << (attribute.readonly ? "nullptr" : attribute.setter_callback_name) << ", default_attributes);";
|
out() << " define_native_property(\"" << attribute.name << "\", " << attribute.getter_callback_name << ", " << (attribute.readonly ? "nullptr" : attribute.setter_callback_name) << ", default_attributes);";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue