LibJS: Add define_direct_property and remove the define_property helper
This removes all usages of the non-standard define_property helper method and replaces all it's usages with the specification required alternative or with define_direct_property where appropriate.
This commit is contained in:
parent
e915155ca4
commit
a6b8291a9b
Notes:
sideshowbarker
2024-07-18 10:18:57 +09:00
Author: https://github.com/IdanHo Commit: https://github.com/SerenityOS/serenity/commit/a6b8291a9b3 Pull-request: https://github.com/SerenityOS/serenity/pull/8478 Reviewed-by: https://github.com/linusg
81 changed files with 246 additions and 275 deletions
|
@ -177,7 +177,7 @@ JS_DEFINE_NATIVE_FUNCTION(TestRunnerGlobalObject::fuzzilli)
|
|||
void TestRunnerGlobalObject::initialize_global_object()
|
||||
{
|
||||
Base::initialize_global_object();
|
||||
define_property("global", this, JS::Attribute::Enumerable);
|
||||
define_direct_property("global", this, JS::Attribute::Enumerable);
|
||||
define_native_function("fuzzilli", fuzzilli, 2);
|
||||
}
|
||||
|
||||
|
|
|
@ -896,10 +896,10 @@ Value ClassExpression::execute(Interpreter& interpreter, GlobalObject& global_ob
|
|||
}
|
||||
auto* prototype = Object::create(global_object, super_constructor_prototype);
|
||||
|
||||
prototype->define_property(vm.names.constructor, class_constructor, 0);
|
||||
prototype->define_direct_property(vm.names.constructor, class_constructor, 0);
|
||||
if (interpreter.exception())
|
||||
return {};
|
||||
class_constructor->define_property(vm.names.prototype, prototype, Attribute::Writable);
|
||||
class_constructor->define_direct_property(vm.names.prototype, prototype, Attribute::Writable);
|
||||
if (interpreter.exception())
|
||||
return {};
|
||||
class_constructor->internal_set_prototype_of(super_constructor.is_null() ? global_object.function_prototype() : &super_constructor.as_object());
|
||||
|
@ -1825,7 +1825,7 @@ Value ObjectExpression::execute(Interpreter& interpreter, GlobalObject& global_o
|
|||
|
||||
for (auto& it : obj_to_spread.shape().property_table_ordered()) {
|
||||
if (it.value.attributes.is_enumerable()) {
|
||||
object->define_property(it.key, obj_to_spread.get(it.key));
|
||||
object->define_direct_property(it.key, obj_to_spread.get(it.key), JS::default_attributes);
|
||||
if (interpreter.exception())
|
||||
return {};
|
||||
}
|
||||
|
@ -1834,7 +1834,7 @@ Value ObjectExpression::execute(Interpreter& interpreter, GlobalObject& global_o
|
|||
auto& str_to_spread = key.as_string().string();
|
||||
|
||||
for (size_t i = 0; i < str_to_spread.length(); i++) {
|
||||
object->define_property(i, js_string(interpreter.heap(), str_to_spread.substring(i, 1)));
|
||||
object->define_direct_property(i, js_string(interpreter.heap(), str_to_spread.substring(i, 1)), JS::default_attributes);
|
||||
if (interpreter.exception())
|
||||
return {};
|
||||
}
|
||||
|
@ -1861,14 +1861,14 @@ Value ObjectExpression::execute(Interpreter& interpreter, GlobalObject& global_o
|
|||
switch (property.type()) {
|
||||
case ObjectProperty::Type::Getter:
|
||||
VERIFY(value.is_function());
|
||||
object->define_accessor(PropertyName::from_value(global_object, key), &value.as_function(), nullptr, Attribute::Configurable | Attribute::Enumerable);
|
||||
object->define_direct_accessor(PropertyName::from_value(global_object, key), &value.as_function(), nullptr, Attribute::Configurable | Attribute::Enumerable);
|
||||
break;
|
||||
case ObjectProperty::Type::Setter:
|
||||
VERIFY(value.is_function());
|
||||
object->define_accessor(PropertyName::from_value(global_object, key), nullptr, &value.as_function(), Attribute::Configurable | Attribute::Enumerable);
|
||||
object->define_direct_accessor(PropertyName::from_value(global_object, key), nullptr, &value.as_function(), Attribute::Configurable | Attribute::Enumerable);
|
||||
break;
|
||||
case ObjectProperty::Type::KeyValue:
|
||||
object->define_property(PropertyName::from_value(global_object, key), value);
|
||||
object->define_direct_property(PropertyName::from_value(global_object, key), value, JS::default_attributes);
|
||||
break;
|
||||
case ObjectProperty::Type::Spread:
|
||||
default:
|
||||
|
@ -2110,7 +2110,7 @@ Value TaggedTemplateLiteral::execute(Interpreter& interpreter, GlobalObject& glo
|
|||
return {};
|
||||
raw_strings->indexed_properties().append(value);
|
||||
}
|
||||
strings->define_property(vm.names.raw, raw_strings, 0);
|
||||
strings->define_direct_property(vm.names.raw, raw_strings, 0);
|
||||
return vm.call(tag_function, js_undefined(), move(arguments));
|
||||
}
|
||||
|
||||
|
|
|
@ -203,7 +203,7 @@ void CopyObjectExcludingProperties::execute_impl(Bytecode::Interpreter& interpre
|
|||
auto property_value = from_object->get(property_name);
|
||||
if (interpreter.vm().exception())
|
||||
return;
|
||||
to_object->define_property(property_name, property_value);
|
||||
to_object->define_direct_property(property_name, property_value, JS::default_attributes);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,9 +25,9 @@ void AggregateErrorConstructor::initialize(GlobalObject& global_object)
|
|||
NativeFunction::initialize(global_object);
|
||||
|
||||
// 20.5.7.2.1 AggregateError.prototype, https://tc39.es/ecma262/#sec-aggregate-error.prototype
|
||||
define_property(vm.names.prototype, global_object.aggregate_error_prototype(), 0);
|
||||
define_direct_property(vm.names.prototype, global_object.aggregate_error_prototype(), 0);
|
||||
|
||||
define_property(vm.names.length, Value(2), Attribute::Configurable);
|
||||
define_direct_property(vm.names.length, Value(2), Attribute::Configurable);
|
||||
}
|
||||
|
||||
// 20.5.7.1.1 AggregateError ( errors, message ), https://tc39.es/ecma262/#sec-aggregate-error
|
||||
|
|
|
@ -20,8 +20,8 @@ void AggregateErrorPrototype::initialize(GlobalObject& global_object)
|
|||
auto& vm = this->vm();
|
||||
Object::initialize(global_object);
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_property(vm.names.name, js_string(vm, "AggregateError"), attr);
|
||||
define_property(vm.names.message, js_string(vm, ""), attr);
|
||||
define_direct_property(vm.names.name, js_string(vm, "AggregateError"), attr);
|
||||
define_direct_property(vm.names.message, js_string(vm, ""), attr);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,9 +24,9 @@ void ArrayBufferConstructor::initialize(GlobalObject& global_object)
|
|||
NativeFunction::initialize(global_object);
|
||||
|
||||
// 25.1.4.2 ArrayBuffer.prototype, https://tc39.es/ecma262/#sec-arraybuffer.prototype
|
||||
define_property(vm.names.prototype, global_object.array_buffer_prototype(), 0);
|
||||
define_direct_property(vm.names.prototype, global_object.array_buffer_prototype(), 0);
|
||||
|
||||
define_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(vm.names.isView, is_view, 1, attr);
|
||||
|
|
|
@ -28,7 +28,7 @@ void ArrayBufferPrototype::initialize(GlobalObject& global_object)
|
|||
define_native_accessor(vm.names.byteLength, byte_length_getter, {}, Attribute::Configurable);
|
||||
|
||||
// 25.1.5.4 ArrayBuffer.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-arraybuffer.prototype-@@tostringtag
|
||||
define_property(*vm.well_known_symbol_to_string_tag(), js_string(vm.heap(), vm.names.ArrayBuffer.as_string()), Attribute::Configurable);
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm.heap(), vm.names.ArrayBuffer.as_string()), Attribute::Configurable);
|
||||
}
|
||||
|
||||
ArrayBufferPrototype::~ArrayBufferPrototype()
|
||||
|
|
|
@ -31,9 +31,9 @@ void ArrayConstructor::initialize(GlobalObject& global_object)
|
|||
NativeFunction::initialize(global_object);
|
||||
|
||||
// 23.1.2.4 Array.prototype, https://tc39.es/ecma262/#sec-array.prototype
|
||||
define_property(vm.names.prototype, global_object.array_prototype(), 0);
|
||||
define_direct_property(vm.names.prototype, global_object.array_prototype(), 0);
|
||||
|
||||
define_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(vm.names.from, from, 1, attr);
|
||||
|
|
|
@ -28,7 +28,7 @@ void ArrayIteratorPrototype::initialize(GlobalObject& global_object)
|
|||
define_native_function(vm.names.next, next, 0, Attribute::Configurable | Attribute::Writable);
|
||||
|
||||
// 23.1.5.2.2 %ArrayIteratorPrototype% [ @@toStringTag ], https://tc39.es/ecma262/#sec-%arrayiteratorprototype%-@@tostringtag
|
||||
define_property(*vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), "Array Iterator"), Attribute::Configurable);
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), "Array Iterator"), Attribute::Configurable);
|
||||
}
|
||||
|
||||
ArrayIteratorPrototype::~ArrayIteratorPrototype()
|
||||
|
@ -87,10 +87,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayIteratorPrototype::next)
|
|||
if (iteration_kind == Object::PropertyKind::Value)
|
||||
return create_iterator_result_object(global_object, value, false);
|
||||
|
||||
auto* entry_array = Array::create(global_object, 0);
|
||||
entry_array->define_property(0, Value(static_cast<i32>(index)));
|
||||
entry_array->define_property(1, value);
|
||||
return create_iterator_result_object(global_object, entry_array, false);
|
||||
return create_iterator_result_object(global_object, Array::create_from(global_object, { Value(static_cast<i32>(index)), value }), false);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ void ArrayPrototype::initialize(GlobalObject& global_object)
|
|||
// Object.is(Array.prototype[Symbol.iterator], Array.prototype.values)
|
||||
// evaluates to true
|
||||
// 23.1.3.33 Array.prototype [ @@iterator ] ( ), https://tc39.es/ecma262/#sec-array.prototype-@@iterator
|
||||
define_property(*vm.well_known_symbol_iterator(), get(vm.names.values), attr);
|
||||
define_direct_property(*vm.well_known_symbol_iterator(), get(vm.names.values), attr);
|
||||
|
||||
// 23.1.3.34 Array.prototype [ @@unscopables ], https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
|
||||
auto* unscopable_list = Object::create(global_object, nullptr);
|
||||
|
@ -89,7 +89,7 @@ void ArrayPrototype::initialize(GlobalObject& global_object)
|
|||
unscopable_list->create_data_property_or_throw(vm.names.keys, Value(true));
|
||||
unscopable_list->create_data_property_or_throw(vm.names.values, Value(true));
|
||||
|
||||
define_property(*vm.well_known_symbol_unscopables(), unscopable_list, Attribute::Configurable);
|
||||
define_direct_property(*vm.well_known_symbol_unscopables(), unscopable_list, Attribute::Configurable);
|
||||
}
|
||||
|
||||
ArrayPrototype::~ArrayPrototype()
|
||||
|
@ -364,7 +364,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::push)
|
|||
return {};
|
||||
}
|
||||
for (size_t i = 0; i < argument_count; ++i) {
|
||||
this_object->define_property(length + i, vm.argument(i));
|
||||
this_object->set(length + i, vm.argument(i), true);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
}
|
||||
|
@ -403,7 +403,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::unshift)
|
|||
auto from_value = this_object->get(from);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
this_object->define_property(to, from_value);
|
||||
this_object->set(to, from_value, true);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
} else {
|
||||
|
@ -414,7 +414,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::unshift)
|
|||
}
|
||||
|
||||
for (size_t j = 0; j < arg_count; j++) {
|
||||
this_object->define_property(j, vm.argument(j));
|
||||
this_object->set(j, vm.argument(j), true);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
}
|
||||
|
@ -487,7 +487,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::shift)
|
|||
auto from_value = this_object->get(from);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
this_object->define_property(to, from_value);
|
||||
this_object->set(to, from_value, true);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
} else {
|
||||
|
@ -1095,14 +1095,14 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::reverse)
|
|||
}
|
||||
|
||||
if (lower_exists && upper_exists) {
|
||||
this_object->define_property(lower, upper_value);
|
||||
this_object->set(lower, upper_value, true);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
this_object->define_property(upper, lower_value);
|
||||
this_object->set(upper, lower_value, true);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
} else if (!lower_exists && upper_exists) {
|
||||
this_object->define_property(lower, upper_value);
|
||||
this_object->set(lower, upper_value, true);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
this_object->delete_property_or_throw(upper);
|
||||
|
@ -1112,7 +1112,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::reverse)
|
|||
this_object->delete_property_or_throw(lower);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
this_object->define_property(upper, lower_value);
|
||||
this_object->set(upper, lower_value, true);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
}
|
||||
|
@ -1688,7 +1688,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::splice)
|
|||
auto to = i + insert_count;
|
||||
|
||||
if (!from.is_empty()) {
|
||||
this_object->define_property(to, from);
|
||||
this_object->set(to, from, true);
|
||||
} else {
|
||||
this_object->delete_property_or_throw(to);
|
||||
}
|
||||
|
@ -1710,7 +1710,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::splice)
|
|||
auto to = i + insert_count - 1;
|
||||
|
||||
if (!from.is_empty()) {
|
||||
this_object->define_property(to, from);
|
||||
this_object->set(to, from, true);
|
||||
} else {
|
||||
this_object->delete_property_or_throw(to);
|
||||
}
|
||||
|
@ -1720,7 +1720,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::splice)
|
|||
}
|
||||
|
||||
for (size_t i = 0; i < insert_count; ++i) {
|
||||
this_object->define_property(actual_start + i, vm.argument(i + 2));
|
||||
this_object->set(actual_start + i, vm.argument(i + 2), true);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
}
|
||||
|
|
|
@ -25,9 +25,9 @@ void BigIntConstructor::initialize(GlobalObject& global_object)
|
|||
NativeFunction::initialize(global_object);
|
||||
|
||||
// 21.2.2.3 BigInt.prototype, https://tc39.es/ecma262/#sec-bigint.prototype
|
||||
define_property(vm.names.prototype, global_object.bigint_prototype(), 0);
|
||||
define_direct_property(vm.names.prototype, global_object.bigint_prototype(), 0);
|
||||
|
||||
define_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
|
||||
// TODO: Implement these functions below and uncomment this.
|
||||
// u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
|
|
|
@ -27,7 +27,7 @@ void BigIntPrototype::initialize(GlobalObject& global_object)
|
|||
define_native_function(vm.names.valueOf, value_of, 0, attr);
|
||||
|
||||
// 21.2.3.5 BigInt.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-bigint.prototype-@@tostringtag
|
||||
define_property(*vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), vm.names.BigInt.as_string()), Attribute::Configurable);
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), vm.names.BigInt.as_string()), Attribute::Configurable);
|
||||
}
|
||||
|
||||
BigIntPrototype::~BigIntPrototype()
|
||||
|
|
|
@ -22,9 +22,9 @@ void BooleanConstructor::initialize(GlobalObject& global_object)
|
|||
NativeFunction::initialize(global_object);
|
||||
|
||||
// 20.3.2.1 Boolean.prototype, https://tc39.es/ecma262/#sec-boolean.prototype
|
||||
define_property(vm.names.prototype, global_object.boolean_prototype(), 0);
|
||||
define_direct_property(vm.names.prototype, global_object.boolean_prototype(), 0);
|
||||
|
||||
define_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
}
|
||||
|
||||
BooleanConstructor::~BooleanConstructor()
|
||||
|
|
|
@ -22,7 +22,7 @@ void BoundFunction::initialize(GlobalObject& global_object)
|
|||
{
|
||||
auto& vm = this->vm();
|
||||
Base::initialize(global_object);
|
||||
define_property(vm.names.length, Value(m_length), Attribute::Configurable);
|
||||
define_direct_property(vm.names.length, Value(m_length), Attribute::Configurable);
|
||||
}
|
||||
|
||||
BoundFunction::~BoundFunction()
|
||||
|
|
|
@ -23,9 +23,9 @@ void DataViewConstructor::initialize(GlobalObject& global_object)
|
|||
NativeFunction::initialize(global_object);
|
||||
|
||||
// 25.3.3.1 DataView.prototype, https://tc39.es/ecma262/#sec-dataview.prototype
|
||||
define_property(vm.names.prototype, global_object.data_view_prototype(), 0);
|
||||
define_direct_property(vm.names.prototype, global_object.data_view_prototype(), 0);
|
||||
|
||||
define_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
}
|
||||
|
||||
DataViewConstructor::~DataViewConstructor()
|
||||
|
|
|
@ -45,7 +45,7 @@ void DataViewPrototype::initialize(GlobalObject& global_object)
|
|||
define_native_accessor(vm.names.byteOffset, byte_offset_getter, {}, Attribute::Configurable);
|
||||
|
||||
// 25.3.4.25 DataView.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-dataview.prototype-@@tostringtag
|
||||
define_property(*vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), vm.names.DataView.as_string()), Attribute::Configurable);
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), vm.names.DataView.as_string()), Attribute::Configurable);
|
||||
}
|
||||
|
||||
DataViewPrototype::~DataViewPrototype()
|
||||
|
|
|
@ -131,9 +131,9 @@ void DateConstructor::initialize(GlobalObject& global_object)
|
|||
NativeFunction::initialize(global_object);
|
||||
|
||||
// 21.4.3.3 Date.prototype, https://tc39.es/ecma262/#sec-date.prototype
|
||||
define_property(vm.names.prototype, global_object.date_prototype(), 0);
|
||||
define_direct_property(vm.names.prototype, global_object.date_prototype(), 0);
|
||||
|
||||
define_property(vm.names.length, Value(7), Attribute::Configurable);
|
||||
define_direct_property(vm.names.length, Value(7), Attribute::Configurable);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(vm.names.now, now, 0, attr);
|
||||
|
|
|
@ -93,7 +93,7 @@ void DatePrototype::initialize(GlobalObject& global_object)
|
|||
// B.2.4.3 Date.prototype.toGMTString ( ), https://tc39.es/ecma262/#sec-date.prototype.togmtstring
|
||||
// The function object that is the initial value of Date.prototype.toGMTString
|
||||
// is the same function object that is the initial value of Date.prototype.toUTCString.
|
||||
define_property(vm.names.toGMTString, get(vm.names.toUTCString), attr);
|
||||
define_direct_property(vm.names.toGMTString, get(vm.names.toUTCString), attr);
|
||||
}
|
||||
|
||||
DatePrototype::~DatePrototype()
|
||||
|
|
|
@ -20,7 +20,7 @@ Error* Error::create(GlobalObject& global_object, String const& message)
|
|||
auto& vm = global_object.vm();
|
||||
auto* error = Error::create(global_object);
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
error->define_property(vm.names.message, js_string(vm, message), attr);
|
||||
error->define_direct_property(vm.names.message, js_string(vm, message), attr);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ void Error::install_error_cause(Value options)
|
|||
auto& vm = global_object.vm(); \
|
||||
auto* error = ClassName::create(global_object); \
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable; \
|
||||
error->define_property(vm.names.message, js_string(vm, message), attr); \
|
||||
error->define_direct_property(vm.names.message, js_string(vm, message), attr); \
|
||||
return error; \
|
||||
} \
|
||||
\
|
||||
|
|
|
@ -22,9 +22,9 @@ void ErrorConstructor::initialize(GlobalObject& global_object)
|
|||
NativeFunction::initialize(global_object);
|
||||
|
||||
// 20.5.2.1 Error.prototype, https://tc39.es/ecma262/#sec-error.prototype
|
||||
define_property(vm.names.prototype, global_object.error_prototype(), 0);
|
||||
define_direct_property(vm.names.prototype, global_object.error_prototype(), 0);
|
||||
|
||||
define_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
}
|
||||
|
||||
// 20.5.1.1 Error ( message ), https://tc39.es/ecma262/#sec-error-message
|
||||
|
@ -70,9 +70,9 @@ Value ErrorConstructor::construct(FunctionObject& new_target)
|
|||
\
|
||||
/* 20.5.6.2.1 NativeError.prototype, \
|
||||
https://tc39.es/ecma262/#sec-nativeerror.prototype */ \
|
||||
define_property(vm.names.prototype, global_object.snake_name##_prototype(), 0); \
|
||||
define_direct_property(vm.names.prototype, global_object.snake_name##_prototype(), 0); \
|
||||
\
|
||||
define_property(vm.names.length, Value(1), Attribute::Configurable); \
|
||||
define_direct_property(vm.names.length, Value(1), Attribute::Configurable); \
|
||||
} \
|
||||
\
|
||||
ConstructorName::~ConstructorName() { } \
|
||||
|
|
|
@ -24,8 +24,8 @@ void ErrorPrototype::initialize(GlobalObject& global_object)
|
|||
auto& vm = this->vm();
|
||||
Object::initialize(global_object);
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_property(vm.names.name, js_string(vm, "Error"), attr);
|
||||
define_property(vm.names.message, js_string(vm, ""), attr);
|
||||
define_direct_property(vm.names.name, js_string(vm, "Error"), attr);
|
||||
define_direct_property(vm.names.message, js_string(vm, ""), attr);
|
||||
define_native_function(vm.names.toString, to_string, 0, attr);
|
||||
}
|
||||
|
||||
|
@ -77,8 +77,8 @@ JS_DEFINE_NATIVE_FUNCTION(ErrorPrototype::to_string)
|
|||
auto& vm = this->vm(); \
|
||||
Object::initialize(global_object); \
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable; \
|
||||
define_property(vm.names.name, js_string(vm, #ClassName), attr); \
|
||||
define_property(vm.names.message, js_string(vm, ""), attr); \
|
||||
define_direct_property(vm.names.name, js_string(vm, #ClassName), attr); \
|
||||
define_direct_property(vm.names.message, js_string(vm, ""), attr); \
|
||||
}
|
||||
|
||||
JS_ENUMERATE_NATIVE_ERRORS
|
||||
|
|
|
@ -23,9 +23,9 @@ void FinalizationRegistryConstructor::initialize(GlobalObject& global_object)
|
|||
NativeFunction::initialize(global_object);
|
||||
|
||||
// 26.2.2.1 FinalizationRegistry.prototype, https://tc39.es/ecma262/#sec-finalization-registry.prototype
|
||||
define_property(vm.names.prototype, global_object.finalization_registry_prototype(), 0);
|
||||
define_direct_property(vm.names.prototype, global_object.finalization_registry_prototype(), 0);
|
||||
|
||||
define_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
}
|
||||
|
||||
FinalizationRegistryConstructor::~FinalizationRegistryConstructor()
|
||||
|
|
|
@ -24,7 +24,7 @@ void FinalizationRegistryPrototype::initialize(GlobalObject& global_object)
|
|||
define_native_function(vm.names.unregister, unregister, 1, attr);
|
||||
|
||||
// 26.2.3.4 FinalizationRegistry.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-finalization-registry.prototype-@@tostringtag
|
||||
define_property(*vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), vm.names.FinalizationRegistry.as_string()), Attribute::Configurable);
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), vm.names.FinalizationRegistry.as_string()), Attribute::Configurable);
|
||||
}
|
||||
|
||||
FinalizationRegistryPrototype::~FinalizationRegistryPrototype()
|
||||
|
|
|
@ -26,9 +26,9 @@ void FunctionConstructor::initialize(GlobalObject& global_object)
|
|||
NativeFunction::initialize(global_object);
|
||||
|
||||
// 20.2.2.2 Function.prototype, https://tc39.es/ecma262/#sec-function.prototype
|
||||
define_property(vm.names.prototype, global_object.function_prototype(), 0);
|
||||
define_direct_property(vm.names.prototype, global_object.function_prototype(), 0);
|
||||
|
||||
define_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
}
|
||||
|
||||
FunctionConstructor::~FunctionConstructor()
|
||||
|
|
|
@ -35,8 +35,8 @@ void FunctionPrototype::initialize(GlobalObject& global_object)
|
|||
define_native_function(vm.names.call, call, 1, attr);
|
||||
define_native_function(vm.names.toString, to_string, 0, attr);
|
||||
define_native_function(*vm.well_known_symbol_has_instance(), symbol_has_instance, 1, 0);
|
||||
define_property(vm.names.length, Value(0), Attribute::Configurable);
|
||||
define_property(vm.names.name, js_string(heap(), ""), Attribute::Configurable);
|
||||
define_direct_property(vm.names.length, Value(0), Attribute::Configurable);
|
||||
define_direct_property(vm.names.name, js_string(heap(), ""), Attribute::Configurable);
|
||||
}
|
||||
|
||||
FunctionPrototype::~FunctionPrototype()
|
||||
|
|
|
@ -27,9 +27,9 @@ void GeneratorFunctionConstructor::initialize(GlobalObject& global_object)
|
|||
NativeFunction::initialize(global_object);
|
||||
|
||||
// 27.3.2.1 GeneratorFunction.length, https://tc39.es/ecma262/#sec-generatorfunction.length
|
||||
define_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
// 27.3.2.2 GeneratorFunction.prototype, https://tc39.es/ecma262/#sec-generatorfunction.length
|
||||
define_property(vm.names.prototype, global_object.generator_function_prototype(), 0);
|
||||
define_direct_property(vm.names.prototype, global_object.generator_function_prototype(), 0);
|
||||
}
|
||||
|
||||
GeneratorFunctionConstructor::~GeneratorFunctionConstructor()
|
||||
|
|
|
@ -21,9 +21,9 @@ void GeneratorFunctionPrototype::initialize(GlobalObject& global_object)
|
|||
Object::initialize(global_object);
|
||||
|
||||
// 27.3.3.2 %GeneratorFunction.prototype% prototype, https://tc39.es/ecma262/#sec-generatorfunction.prototype.prototype
|
||||
define_property(vm.names.prototype, global_object.generator_object_prototype(), Attribute::Configurable);
|
||||
define_direct_property(vm.names.prototype, global_object.generator_object_prototype(), Attribute::Configurable);
|
||||
// 27.3.3.3 %GeneratorFunction.prototype% [ @@toStringTag ], https://tc39.es/ecma262/#sec-generatorfunction.prototype-@@tostringtag
|
||||
define_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "GeneratorFunction"), Attribute::Configurable);
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "GeneratorFunction"), Attribute::Configurable);
|
||||
}
|
||||
|
||||
GeneratorFunctionPrototype::~GeneratorFunctionPrototype()
|
||||
|
|
|
@ -37,7 +37,7 @@ void GeneratorObjectPrototype::initialize(GlobalObject& global_object)
|
|||
define_native_function(vm.names.throw_, throw_, 1, attr);
|
||||
|
||||
// 27.5.1.5 Generator.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-generator.prototype-@@tostringtag
|
||||
define_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Generator"), Attribute::Configurable);
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Generator"), Attribute::Configurable);
|
||||
}
|
||||
|
||||
GeneratorObjectPrototype::~GeneratorObjectPrototype()
|
||||
|
|
|
@ -126,7 +126,7 @@ void GlobalObject::initialize_global_object()
|
|||
// %GeneratorFunction.prototype.prototype% must be initialized separately as it has no
|
||||
// companion constructor
|
||||
m_generator_object_prototype = heap().allocate<GeneratorObjectPrototype>(*this, *this);
|
||||
m_generator_object_prototype->define_property(vm.names.constructor, m_generator_function_constructor, Attribute::Configurable);
|
||||
m_generator_object_prototype->define_direct_property(vm.names.constructor, m_generator_function_constructor, Attribute::Configurable);
|
||||
|
||||
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
|
||||
if (!m_##snake_name##_prototype) \
|
||||
|
@ -148,13 +148,13 @@ void GlobalObject::initialize_global_object()
|
|||
vm.throw_exception<TypeError>(global_object, ErrorType::RestrictedFunctionPropertiesAccess);
|
||||
return Value();
|
||||
});
|
||||
m_throw_type_error_function->define_property_without_transition(vm.names.length, Value(0), 0, false);
|
||||
m_throw_type_error_function->define_property_without_transition(vm.names.name, js_string(vm, ""), 0, false);
|
||||
m_throw_type_error_function->define_direct_property(vm.names.length, Value(0), 0);
|
||||
m_throw_type_error_function->define_direct_property(vm.names.name, js_string(vm, ""), 0);
|
||||
m_throw_type_error_function->internal_prevent_extensions();
|
||||
|
||||
// 10.2.4 AddRestrictedFunctionProperties ( F, realm ), https://tc39.es/ecma262/#sec-addrestrictedfunctionproperties
|
||||
m_function_prototype->define_accessor(vm.names.caller, throw_type_error_function(), throw_type_error_function(), Attribute::Configurable);
|
||||
m_function_prototype->define_accessor(vm.names.arguments, throw_type_error_function(), throw_type_error_function(), Attribute::Configurable);
|
||||
m_function_prototype->define_direct_accessor(vm.names.caller, throw_type_error_function(), throw_type_error_function(), Attribute::Configurable);
|
||||
m_function_prototype->define_direct_accessor(vm.names.arguments, throw_type_error_function(), throw_type_error_function(), Attribute::Configurable);
|
||||
|
||||
define_native_function(vm.names.encodeURI, encode_uri, 1, attr);
|
||||
define_native_function(vm.names.decodeURI, decode_uri, 1, attr);
|
||||
|
@ -163,15 +163,15 @@ void GlobalObject::initialize_global_object()
|
|||
define_native_function(vm.names.escape, escape, 1, attr);
|
||||
define_native_function(vm.names.unescape, unescape, 1, attr);
|
||||
|
||||
define_property(vm.names.NaN, js_nan(), 0);
|
||||
define_property(vm.names.Infinity, js_infinity(), 0);
|
||||
define_property(vm.names.undefined, js_undefined(), 0);
|
||||
define_direct_property(vm.names.NaN, js_nan(), 0);
|
||||
define_direct_property(vm.names.Infinity, js_infinity(), 0);
|
||||
define_direct_property(vm.names.undefined, js_undefined(), 0);
|
||||
|
||||
define_property(vm.names.globalThis, this, attr);
|
||||
define_property(vm.names.console, heap().allocate<ConsoleObject>(*this, *this), attr);
|
||||
define_property(vm.names.Math, heap().allocate<MathObject>(*this, *this), attr);
|
||||
define_property(vm.names.JSON, heap().allocate<JSONObject>(*this, *this), attr);
|
||||
define_property(vm.names.Reflect, heap().allocate<ReflectObject>(*this, *this), attr);
|
||||
define_direct_property(vm.names.globalThis, this, attr);
|
||||
define_direct_property(vm.names.console, heap().allocate<ConsoleObject>(*this, *this), attr);
|
||||
define_direct_property(vm.names.Math, heap().allocate<MathObject>(*this, *this), attr);
|
||||
define_direct_property(vm.names.JSON, heap().allocate<JSONObject>(*this, *this), attr);
|
||||
define_direct_property(vm.names.Reflect, heap().allocate<ReflectObject>(*this, *this), attr);
|
||||
|
||||
// This must be initialized before allocating AggregateErrorConstructor, which uses ErrorConstructor as its prototype.
|
||||
initialize_constructor(vm.names.Error, m_error_constructor, m_error_prototype);
|
||||
|
@ -210,7 +210,7 @@ void GlobalObject::initialize_global_object()
|
|||
// The generator constructor cannot be initialized with add_constructor as it has no global binding
|
||||
m_generator_function_constructor = heap().allocate<GeneratorFunctionConstructor>(*this, *this);
|
||||
// 27.3.3.1 GeneratorFunction.prototype.constructor, https://tc39.es/ecma262/#sec-generatorfunction.prototype.constructor
|
||||
m_generator_function_prototype->define_property(vm.names.constructor, m_generator_function_constructor, Attribute::Configurable);
|
||||
m_generator_function_prototype->define_direct_property(vm.names.constructor, m_generator_function_constructor, Attribute::Configurable);
|
||||
}
|
||||
|
||||
GlobalObject::~GlobalObject()
|
||||
|
|
|
@ -109,11 +109,11 @@ inline void GlobalObject::initialize_constructor(PropertyName const& property_na
|
|||
{
|
||||
auto& vm = this->vm();
|
||||
constructor = heap().allocate<ConstructorType>(*this, *this);
|
||||
constructor->define_property(vm.names.name, js_string(heap(), property_name.as_string()), Attribute::Configurable);
|
||||
constructor->define_direct_property(vm.names.name, js_string(heap(), property_name.as_string()), Attribute::Configurable);
|
||||
if (vm.exception())
|
||||
return;
|
||||
if (prototype) {
|
||||
prototype->define_property(vm.names.constructor, constructor, Attribute::Writable | Attribute::Configurable);
|
||||
prototype->define_direct_property(vm.names.constructor, constructor, Attribute::Writable | Attribute::Configurable);
|
||||
if (vm.exception())
|
||||
return;
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ inline void GlobalObject::add_constructor(PropertyName const& property_name, Con
|
|||
// Some constructors are pre-initialized separately.
|
||||
if (!constructor)
|
||||
initialize_constructor(property_name, constructor, prototype);
|
||||
define_property(property_name, constructor, Attribute::Writable | Attribute::Configurable);
|
||||
define_direct_property(property_name, constructor, Attribute::Writable | Attribute::Configurable);
|
||||
}
|
||||
|
||||
inline GlobalObject* Shape::global_object() const
|
||||
|
|
|
@ -149,8 +149,8 @@ Value create_iterator_result_object(GlobalObject& global_object, Value value, bo
|
|||
{
|
||||
auto& vm = global_object.vm();
|
||||
auto* object = Object::create(global_object, global_object.object_prototype());
|
||||
object->define_property(vm.names.value, value);
|
||||
object->define_property(vm.names.done, Value(done));
|
||||
object->create_data_property_or_throw(vm.names.value, value);
|
||||
object->create_data_property_or_throw(vm.names.done, Value(done));
|
||||
return object;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ void JSONObject::initialize(GlobalObject& global_object)
|
|||
define_native_function(vm.names.parse, parse, 2, attr);
|
||||
|
||||
// 25.5.3 JSON [ @@toStringTag ], https://tc39.es/ecma262/#sec-json-@@tostringtag
|
||||
define_property(*vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), "JSON"), Attribute::Configurable);
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), "JSON"), Attribute::Configurable);
|
||||
}
|
||||
|
||||
JSONObject::~JSONObject()
|
||||
|
@ -460,7 +460,7 @@ Object* JSONObject::parse_json_object(GlobalObject& global_object, const JsonObj
|
|||
{
|
||||
auto* object = Object::create(global_object, global_object.object_prototype());
|
||||
json_object.for_each_member([&](auto& key, auto& value) {
|
||||
object->define_property(key, parse_json_value(global_object, value));
|
||||
object->define_direct_property(key, parse_json_value(global_object, value), JS::default_attributes);
|
||||
});
|
||||
return object;
|
||||
}
|
||||
|
@ -470,7 +470,7 @@ Array* JSONObject::parse_json_array(GlobalObject& global_object, const JsonArray
|
|||
auto* array = Array::create(global_object, 0);
|
||||
size_t index = 0;
|
||||
json_array.for_each([&](auto& value) {
|
||||
array->define_property(index++, parse_json_value(global_object, value));
|
||||
array->define_direct_property(index++, parse_json_value(global_object, value), JS::default_attributes);
|
||||
});
|
||||
return array;
|
||||
}
|
||||
|
|
|
@ -24,9 +24,9 @@ void MapConstructor::initialize(GlobalObject& global_object)
|
|||
NativeFunction::initialize(global_object);
|
||||
|
||||
// 24.1.2.1 Map.prototype, https://tc39.es/ecma262/#sec-map.prototype
|
||||
define_property(vm.names.prototype, global_object.map_prototype(), 0);
|
||||
define_direct_property(vm.names.prototype, global_object.map_prototype(), 0);
|
||||
|
||||
define_property(vm.names.length, Value(0), Attribute::Configurable);
|
||||
define_direct_property(vm.names.length, Value(0), Attribute::Configurable);
|
||||
|
||||
define_native_accessor(*vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ void MapIteratorPrototype::initialize(GlobalObject& global_object)
|
|||
Object::initialize(global_object);
|
||||
|
||||
define_native_function(vm.names.next, next, 0, Attribute::Configurable | Attribute::Writable);
|
||||
define_property(*vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), "Map Iterator"), Attribute::Configurable);
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), "Map Iterator"), Attribute::Configurable);
|
||||
}
|
||||
|
||||
MapIteratorPrototype::~MapIteratorPrototype()
|
||||
|
@ -59,10 +59,7 @@ JS_DEFINE_NATIVE_FUNCTION(MapIteratorPrototype::next)
|
|||
else if (iteration_kind == Object::PropertyKind::Value)
|
||||
return create_iterator_result_object(global_object, entry.value, false);
|
||||
|
||||
auto* entry_array = Array::create(global_object, 0);
|
||||
entry_array->define_property(0, entry.key);
|
||||
entry_array->define_property(1, entry.value);
|
||||
return create_iterator_result_object(global_object, entry_array, false);
|
||||
return create_iterator_result_object(global_object, Array::create_from(global_object, { entry.key, entry.value }), false);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,8 +33,8 @@ void MapPrototype::initialize(GlobalObject& global_object)
|
|||
|
||||
define_native_accessor(vm.names.size, size_getter, {}, Attribute::Configurable);
|
||||
|
||||
define_property(*vm.well_known_symbol_iterator(), Object::get(vm.names.entries), attr);
|
||||
define_property(*vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), vm.names.Map.as_string()), Attribute::Configurable);
|
||||
define_direct_property(*vm.well_known_symbol_iterator(), Object::get(vm.names.entries), attr);
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), vm.names.Map.as_string()), Attribute::Configurable);
|
||||
}
|
||||
|
||||
MapPrototype::~MapPrototype()
|
||||
|
|
|
@ -61,17 +61,17 @@ void MathObject::initialize(GlobalObject& global_object)
|
|||
define_native_function(vm.names.tanh, tanh, 1, attr);
|
||||
|
||||
// 21.3.1 Value Properties of the Math Object, https://tc39.es/ecma262/#sec-value-properties-of-the-math-object
|
||||
define_property(vm.names.E, Value(M_E), 0);
|
||||
define_property(vm.names.LN2, Value(M_LN2), 0);
|
||||
define_property(vm.names.LN10, Value(M_LN10), 0);
|
||||
define_property(vm.names.LOG2E, Value(::log2(M_E)), 0);
|
||||
define_property(vm.names.LOG10E, Value(::log10(M_E)), 0);
|
||||
define_property(vm.names.PI, Value(M_PI), 0);
|
||||
define_property(vm.names.SQRT1_2, Value(M_SQRT1_2), 0);
|
||||
define_property(vm.names.SQRT2, Value(M_SQRT2), 0);
|
||||
define_direct_property(vm.names.E, Value(M_E), 0);
|
||||
define_direct_property(vm.names.LN2, Value(M_LN2), 0);
|
||||
define_direct_property(vm.names.LN10, Value(M_LN10), 0);
|
||||
define_direct_property(vm.names.LOG2E, Value(::log2(M_E)), 0);
|
||||
define_direct_property(vm.names.LOG10E, Value(::log10(M_E)), 0);
|
||||
define_direct_property(vm.names.PI, Value(M_PI), 0);
|
||||
define_direct_property(vm.names.SQRT1_2, Value(M_SQRT1_2), 0);
|
||||
define_direct_property(vm.names.SQRT2, Value(M_SQRT2), 0);
|
||||
|
||||
// 21.3.1.9 Math [ @@toStringTag ], https://tc39.es/ecma262/#sec-math-@@tostringtag
|
||||
define_property(*vm.well_known_symbol_to_string_tag(), js_string(vm.heap(), vm.names.Math.as_string()), Attribute::Configurable);
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm.heap(), vm.names.Math.as_string()), Attribute::Configurable);
|
||||
}
|
||||
|
||||
MathObject::~MathObject()
|
||||
|
|
|
@ -34,25 +34,25 @@ void NumberConstructor::initialize(GlobalObject& global_object)
|
|||
NativeFunction::initialize(global_object);
|
||||
|
||||
// 21.1.2.15 Number.prototype, https://tc39.es/ecma262/#sec-number.prototype
|
||||
define_property(vm.names.prototype, global_object.number_prototype(), 0);
|
||||
define_direct_property(vm.names.prototype, global_object.number_prototype(), 0);
|
||||
|
||||
define_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(vm.names.isFinite, is_finite, 1, attr);
|
||||
define_native_function(vm.names.isInteger, is_integer, 1, attr);
|
||||
define_native_function(vm.names.isNaN, is_nan, 1, attr);
|
||||
define_native_function(vm.names.isSafeInteger, is_safe_integer, 1, attr);
|
||||
define_property(vm.names.parseInt, global_object.get(vm.names.parseInt), attr);
|
||||
define_property(vm.names.parseFloat, global_object.get(vm.names.parseFloat), attr);
|
||||
define_property(vm.names.EPSILON, Value(EPSILON_VALUE), 0);
|
||||
define_property(vm.names.MAX_VALUE, Value(NumericLimits<double>::max()), 0);
|
||||
define_property(vm.names.MIN_VALUE, Value(NumericLimits<double>::min()), 0);
|
||||
define_property(vm.names.MAX_SAFE_INTEGER, Value(MAX_SAFE_INTEGER_VALUE), 0);
|
||||
define_property(vm.names.MIN_SAFE_INTEGER, Value(MIN_SAFE_INTEGER_VALUE), 0);
|
||||
define_property(vm.names.NEGATIVE_INFINITY, js_negative_infinity(), 0);
|
||||
define_property(vm.names.POSITIVE_INFINITY, js_infinity(), 0);
|
||||
define_property(vm.names.NaN, js_nan(), 0);
|
||||
define_direct_property(vm.names.parseInt, global_object.get(vm.names.parseInt), attr);
|
||||
define_direct_property(vm.names.parseFloat, global_object.get(vm.names.parseFloat), attr);
|
||||
define_direct_property(vm.names.EPSILON, Value(EPSILON_VALUE), 0);
|
||||
define_direct_property(vm.names.MAX_VALUE, Value(NumericLimits<double>::max()), 0);
|
||||
define_direct_property(vm.names.MIN_VALUE, Value(NumericLimits<double>::min()), 0);
|
||||
define_direct_property(vm.names.MAX_SAFE_INTEGER, Value(MAX_SAFE_INTEGER_VALUE), 0);
|
||||
define_direct_property(vm.names.MIN_SAFE_INTEGER, Value(MIN_SAFE_INTEGER_VALUE), 0);
|
||||
define_direct_property(vm.names.NEGATIVE_INFINITY, js_negative_infinity(), 0);
|
||||
define_direct_property(vm.names.POSITIVE_INFINITY, js_infinity(), 0);
|
||||
define_direct_property(vm.names.NaN, js_nan(), 0);
|
||||
}
|
||||
|
||||
NumberConstructor::~NumberConstructor()
|
||||
|
|
|
@ -1032,7 +1032,7 @@ void Object::set_shape(Shape& new_shape)
|
|||
m_shape = &new_shape;
|
||||
}
|
||||
|
||||
bool Object::define_native_accessor(PropertyName const& property_name, Function<Value(VM&, GlobalObject&)> getter, Function<Value(VM&, GlobalObject&)> setter, PropertyAttributes attribute)
|
||||
void Object::define_native_accessor(PropertyName const& property_name, Function<Value(VM&, GlobalObject&)> getter, Function<Value(VM&, GlobalObject&)> setter, PropertyAttributes attribute)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
String formatted_property_name;
|
||||
|
@ -1047,34 +1047,20 @@ bool Object::define_native_accessor(PropertyName const& property_name, Function<
|
|||
if (getter) {
|
||||
auto name = String::formatted("get {}", formatted_property_name);
|
||||
getter_function = NativeFunction::create(global_object(), name, move(getter));
|
||||
getter_function->define_property_without_transition(vm.names.length, Value(0), Attribute::Configurable);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
getter_function->define_property_without_transition(vm.names.name, js_string(vm.heap(), name), Attribute::Configurable);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
getter_function->define_direct_property(vm.names.length, Value(0), Attribute::Configurable);
|
||||
getter_function->define_direct_property(vm.names.name, js_string(vm.heap(), name), Attribute::Configurable);
|
||||
}
|
||||
FunctionObject* setter_function = nullptr;
|
||||
if (setter) {
|
||||
auto name = String::formatted("set {}", formatted_property_name);
|
||||
setter_function = NativeFunction::create(global_object(), name, move(setter));
|
||||
setter_function->define_property_without_transition(vm.names.length, Value(1), Attribute::Configurable);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
setter_function->define_property_without_transition(vm.names.name, js_string(vm.heap(), name), Attribute::Configurable);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
setter_function->define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
setter_function->define_direct_property(vm.names.name, js_string(vm.heap(), name), Attribute::Configurable);
|
||||
}
|
||||
return define_accessor(property_name, getter_function, setter_function, attribute);
|
||||
return define_direct_accessor(property_name, getter_function, setter_function, attribute);
|
||||
}
|
||||
|
||||
bool Object::define_property_without_transition(PropertyName const& property_name, Value value, PropertyAttributes attributes, bool throw_exceptions)
|
||||
{
|
||||
TemporaryChange change(m_transitions_enabled, false);
|
||||
return define_property(property_name, value, attributes, throw_exceptions);
|
||||
}
|
||||
|
||||
bool Object::define_accessor(PropertyName const& property_name, FunctionObject* getter, FunctionObject* setter, PropertyAttributes attributes, bool throw_exceptions)
|
||||
void Object::define_direct_accessor(PropertyName const& property_name, FunctionObject* getter, FunctionObject* setter, PropertyAttributes attributes)
|
||||
{
|
||||
VERIFY(property_name.is_valid());
|
||||
|
||||
|
@ -1082,18 +1068,13 @@ bool Object::define_accessor(PropertyName const& property_name, FunctionObject*
|
|||
auto* accessor = existing_property.is_accessor() ? &existing_property.as_accessor() : nullptr;
|
||||
if (!accessor) {
|
||||
accessor = Accessor::create(vm(), getter, setter);
|
||||
bool definition_success = define_property(property_name, accessor, attributes, throw_exceptions);
|
||||
if (vm().exception())
|
||||
return {};
|
||||
if (!definition_success)
|
||||
return false;
|
||||
define_direct_property(property_name, accessor, attributes);
|
||||
} else {
|
||||
if (getter)
|
||||
accessor->set_getter(getter);
|
||||
if (setter)
|
||||
accessor->set_setter(setter);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void Object::ensure_shape_is_unique()
|
||||
|
@ -1117,7 +1098,7 @@ Value Object::get_without_side_effects(const PropertyName& property_name) const
|
|||
return {};
|
||||
}
|
||||
|
||||
bool Object::define_native_function(PropertyName const& property_name, Function<Value(VM&, GlobalObject&)> native_function, i32 length, PropertyAttributes attribute)
|
||||
void Object::define_native_function(PropertyName const& property_name, Function<Value(VM&, GlobalObject&)> native_function, i32 length, PropertyAttributes attribute)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
String function_name;
|
||||
|
@ -1127,18 +1108,14 @@ bool Object::define_native_function(PropertyName const& property_name, Function<
|
|||
function_name = String::formatted("[{}]", property_name.as_symbol()->description());
|
||||
}
|
||||
auto* function = NativeFunction::create(global_object(), function_name, move(native_function));
|
||||
function->define_property_without_transition(vm.names.length, Value(length), Attribute::Configurable);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
function->define_property_without_transition(vm.names.name, js_string(vm.heap(), function_name), Attribute::Configurable);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
return define_property(property_name, function, attribute);
|
||||
function->define_direct_property(vm.names.length, Value(length), Attribute::Configurable);
|
||||
function->define_direct_property(vm.names.name, js_string(vm.heap(), function_name), Attribute::Configurable);
|
||||
define_direct_property(property_name, function, attribute);
|
||||
}
|
||||
|
||||
bool Object::define_native_property(PropertyName const& property_name, Function<Value(VM&, GlobalObject&)> getter, Function<void(VM&, GlobalObject&, Value)> setter, PropertyAttributes attribute)
|
||||
void Object::define_native_property(PropertyName const& property_name, Function<Value(VM&, GlobalObject&)> getter, Function<void(VM&, GlobalObject&, Value)> setter, PropertyAttributes attribute)
|
||||
{
|
||||
return define_property(property_name, heap().allocate_without_global_object<NativeProperty>(move(getter), move(setter)), attribute);
|
||||
define_direct_property(property_name, heap().allocate_without_global_object<NativeProperty>(move(getter), move(setter)), attribute);
|
||||
}
|
||||
|
||||
// 20.1.2.3.1 ObjectDefineProperties ( O, Properties ), https://tc39.es/ecma262/#sec-objectdefineproperties
|
||||
|
|
|
@ -126,19 +126,14 @@ public:
|
|||
// - Helpers using old, non-standard names but wrapping the standard methods.
|
||||
// FIXME: Update all the code relying on these and remove them.
|
||||
bool put(PropertyName const& property_name, Value value, Value receiver = {}) { return internal_set(property_name, value, receiver.value_or(this)); }
|
||||
bool define_property(PropertyName const& property_name, Value value, PropertyAttributes attributes = default_attributes, bool = true)
|
||||
{
|
||||
return internal_define_own_property(property_name, { .value = value, .writable = attributes.is_writable(), .enumerable = attributes.is_enumerable(), .configurable = attributes.is_configurable() });
|
||||
};
|
||||
|
||||
Value get_without_side_effects(const PropertyName&) const;
|
||||
|
||||
bool define_property_without_transition(const PropertyName&, Value value, PropertyAttributes attributes = default_attributes, bool throw_exceptions = true);
|
||||
bool define_accessor(const PropertyName&, FunctionObject* getter, FunctionObject* setter, PropertyAttributes attributes = default_attributes, bool throw_exceptions = true);
|
||||
void define_direct_property(PropertyName const& property_name, Value value, PropertyAttributes attributes) { storage_set(property_name, { value, attributes }); };
|
||||
void define_direct_accessor(PropertyName const&, FunctionObject* getter, FunctionObject* setter, PropertyAttributes attributes);
|
||||
|
||||
bool define_native_function(PropertyName const&, Function<Value(VM&, GlobalObject&)>, i32 length = 0, PropertyAttributes attributes = default_attributes);
|
||||
bool define_native_property(PropertyName const&, Function<Value(VM&, GlobalObject&)> getter, Function<void(VM&, GlobalObject&, Value)> setter, PropertyAttributes attributes = default_attributes);
|
||||
bool define_native_accessor(PropertyName const&, Function<Value(VM&, GlobalObject&)> getter, Function<Value(VM&, GlobalObject&)> setter, PropertyAttributes attributes = default_attributes);
|
||||
void define_native_function(PropertyName const&, Function<Value(VM&, GlobalObject&)>, i32 length = 0, PropertyAttributes attributes = default_attributes);
|
||||
void define_native_property(PropertyName const&, Function<Value(VM&, GlobalObject&)> getter, Function<void(VM&, GlobalObject&, Value)> setter, PropertyAttributes attributes = default_attributes);
|
||||
void define_native_accessor(PropertyName const&, Function<Value(VM&, GlobalObject&)> getter, Function<Value(VM&, GlobalObject&)> setter, PropertyAttributes attributes = default_attributes);
|
||||
|
||||
virtual bool is_array() const { return false; }
|
||||
virtual bool is_function() const { return false; }
|
||||
|
|
|
@ -28,9 +28,9 @@ void ObjectConstructor::initialize(GlobalObject& global_object)
|
|||
NativeFunction::initialize(global_object);
|
||||
|
||||
// 20.1.2.19 Object.prototype, https://tc39.es/ecma262/#sec-object.prototype
|
||||
define_property(vm.names.prototype, global_object.object_prototype(), 0);
|
||||
define_direct_property(vm.names.prototype, global_object.object_prototype(), 0);
|
||||
|
||||
define_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(vm.names.defineProperty, define_property_, 3, attr);
|
||||
|
@ -263,7 +263,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::from_entries)
|
|||
auto property_key = key.to_property_key(global_object);
|
||||
if (vm.exception())
|
||||
return IterationDecision::Break;
|
||||
object->define_property(property_key, value);
|
||||
object->create_data_property_or_throw(property_key, value);
|
||||
if (vm.exception())
|
||||
return IterationDecision::Break;
|
||||
return IterationDecision::Continue;
|
||||
|
|
|
@ -78,14 +78,14 @@ void OrdinaryFunctionObject::initialize(GlobalObject& global_object)
|
|||
auto* prototype = vm.heap().allocate<Object>(global_object, *global_object.new_ordinary_function_prototype_object_shape());
|
||||
switch (m_kind) {
|
||||
case FunctionKind::Regular:
|
||||
prototype->define_property(vm.names.constructor, this, Attribute::Writable | Attribute::Configurable);
|
||||
prototype->define_property_or_throw(vm.names.constructor, { .value = this, .writable = true, .enumerable = false, .configurable = true });
|
||||
break;
|
||||
case FunctionKind::Generator:
|
||||
// prototype is "g1.prototype" in figure-2 (https://tc39.es/ecma262/img/figure-2.png)
|
||||
prototype->internal_set_prototype_of(global_object.generator_object_prototype());
|
||||
break;
|
||||
}
|
||||
define_property(vm.names.prototype, prototype, Attribute::Writable);
|
||||
define_direct_property(vm.names.prototype, prototype, Attribute::Writable);
|
||||
}
|
||||
define_property_or_throw(vm.names.length, { .value = Value(m_function_length), .writable = false, .enumerable = false, .configurable = true });
|
||||
define_property_or_throw(vm.names.name, { .value = js_string(vm, m_name.is_null() ? "" : m_name), .writable = false, .enumerable = false, .configurable = true });
|
||||
|
|
|
@ -26,9 +26,9 @@ void PromiseConstructor::initialize(GlobalObject& global_object)
|
|||
NativeFunction::initialize(global_object);
|
||||
|
||||
// 27.2.4.4 Promise.prototype, https://tc39.es/ecma262/#sec-promise.prototype
|
||||
define_property(vm.names.prototype, global_object.promise_prototype(), 0);
|
||||
define_direct_property(vm.names.prototype, global_object.promise_prototype(), 0);
|
||||
|
||||
define_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
// TODO: Implement these functions below and uncomment this.
|
||||
|
|
|
@ -32,7 +32,7 @@ void PromisePrototype::initialize(GlobalObject& global_object)
|
|||
define_native_function(vm.names.finally, finally, 1, attr);
|
||||
|
||||
// 27.2.5.5 Promise.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-promise.prototype-@@tostringtag
|
||||
define_property(*vm.well_known_symbol_to_string_tag(), js_string(vm.heap(), vm.names.Promise.as_string()), Attribute::Configurable);
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm.heap(), vm.names.Promise.as_string()), Attribute::Configurable);
|
||||
}
|
||||
|
||||
static Promise* promise_from(VM& vm, GlobalObject& global_object)
|
||||
|
@ -106,7 +106,7 @@ JS_DEFINE_NATIVE_FUNCTION(PromisePrototype::finally)
|
|||
});
|
||||
return promise->invoke(vm.names.then.as_string(), value_thunk);
|
||||
});
|
||||
then_finally_function->define_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
then_finally_function->define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
|
||||
// 27.2.5.3.2 Catch Finally Functions, https://tc39.es/ecma262/#sec-catchfinallyfunctions
|
||||
auto* catch_finally_function = NativeFunction::create(global_object, "", [constructor_handle = make_handle(constructor), on_finally_handle = make_handle(&on_finally.as_function())](auto& vm, auto& global_object) -> Value {
|
||||
|
@ -125,7 +125,7 @@ JS_DEFINE_NATIVE_FUNCTION(PromisePrototype::finally)
|
|||
});
|
||||
return promise->invoke(vm.names.then.as_string(), thrower);
|
||||
});
|
||||
catch_finally_function->define_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
catch_finally_function->define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
|
||||
then_finally = Value(then_finally_function);
|
||||
catch_finally = Value(catch_finally_function);
|
||||
|
|
|
@ -42,7 +42,7 @@ PromiseCapability new_promise_capability(GlobalObject& global_object, Value cons
|
|||
promise_capability_functions.reject = reject;
|
||||
return js_undefined();
|
||||
});
|
||||
executor->define_property(vm.names.length, Value(2), Attribute::Configurable);
|
||||
executor->define_direct_property(vm.names.length, Value(2), Attribute::Configurable);
|
||||
|
||||
MarkedValueList arguments(vm.heap());
|
||||
arguments.append(executor);
|
||||
|
|
|
@ -27,7 +27,7 @@ PromiseResolvingFunction::PromiseResolvingFunction(Promise& promise, AlreadyReso
|
|||
void PromiseResolvingFunction::initialize(GlobalObject& global_object)
|
||||
{
|
||||
Base::initialize(global_object);
|
||||
define_property(vm().names.length, Value(1), Attribute::Configurable);
|
||||
define_direct_property(vm().names.length, Value(1), Attribute::Configurable);
|
||||
}
|
||||
|
||||
Value PromiseResolvingFunction::call()
|
||||
|
|
|
@ -37,7 +37,7 @@ void ProxyConstructor::initialize(GlobalObject& global_object)
|
|||
{
|
||||
auto& vm = this->vm();
|
||||
NativeFunction::initialize(global_object);
|
||||
define_property(vm.names.length, Value(2), Attribute::Configurable);
|
||||
define_direct_property(vm.names.length, Value(2), Attribute::Configurable);
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(vm.names.revocable, revocable, 2, attr);
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ JS_DEFINE_NATIVE_FUNCTION(ProxyConstructor::revocable)
|
|||
proxy.revoke();
|
||||
return js_undefined();
|
||||
});
|
||||
revoker->define_property(vm.names.length, Value(0), Attribute::Configurable);
|
||||
revoker->define_direct_property(vm.names.length, Value(0), Attribute::Configurable);
|
||||
|
||||
auto* result = Object::create(global_object, global_object.object_prototype());
|
||||
result->create_data_property_or_throw(vm.names.proxy, proxy);
|
||||
|
|
|
@ -40,7 +40,7 @@ void ReflectObject::initialize(GlobalObject& global_object)
|
|||
define_native_function(vm.names.setPrototypeOf, set_prototype_of, 2, attr);
|
||||
|
||||
// 28.1.14 Reflect [ @@toStringTag ], https://tc39.es/ecma262/#sec-reflect-@@tostringtag
|
||||
Object::define_property(*vm.well_known_symbol_to_string_tag(), js_string(vm.heap(), vm.names.Reflect.as_string()), Attribute::Configurable);
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm.heap(), vm.names.Reflect.as_string()), Attribute::Configurable);
|
||||
}
|
||||
|
||||
ReflectObject::~ReflectObject()
|
||||
|
|
|
@ -22,9 +22,9 @@ void RegExpConstructor::initialize(GlobalObject& global_object)
|
|||
NativeFunction::initialize(global_object);
|
||||
|
||||
// 22.2.4.1 RegExp.prototype, https://tc39.es/ecma262/#sec-regexp.prototype
|
||||
define_property(vm.names.prototype, global_object.regexp_prototype(), 0);
|
||||
define_direct_property(vm.names.prototype, global_object.regexp_prototype(), 0);
|
||||
|
||||
define_property(vm.names.length, Value(2), Attribute::Configurable);
|
||||
define_direct_property(vm.names.length, Value(2), Attribute::Configurable);
|
||||
|
||||
define_native_accessor(*vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable);
|
||||
}
|
||||
|
|
|
@ -24,9 +24,9 @@ void SetConstructor::initialize(GlobalObject& global_object)
|
|||
NativeFunction::initialize(global_object);
|
||||
|
||||
// 24.2.2.1 Set.prototype, https://tc39.es/ecma262/#sec-set.prototype
|
||||
define_property(vm.names.prototype, global_object.set_prototype(), 0);
|
||||
define_direct_property(vm.names.prototype, global_object.set_prototype(), 0);
|
||||
|
||||
define_property(vm.names.length, Value(0), Attribute::Configurable);
|
||||
define_direct_property(vm.names.length, Value(0), Attribute::Configurable);
|
||||
|
||||
define_native_accessor(*vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ void SetIteratorPrototype::initialize(GlobalObject& global_object)
|
|||
define_native_function(vm.names.next, next, 0, Attribute::Configurable | Attribute::Writable);
|
||||
|
||||
// 24.2.5.2.2 %SetIteratorPrototype% [ @@toStringTag ], https://tc39.es/ecma262/#sec-%setiteratorprototype%-@@tostringtag
|
||||
define_property(*vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), "Set Iterator"), Attribute::Configurable);
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), "Set Iterator"), Attribute::Configurable);
|
||||
}
|
||||
|
||||
SetIteratorPrototype::~SetIteratorPrototype()
|
||||
|
@ -61,10 +61,7 @@ JS_DEFINE_NATIVE_FUNCTION(SetIteratorPrototype::next)
|
|||
if (iteration_kind == Object::PropertyKind::Value)
|
||||
return create_iterator_result_object(global_object, value, false);
|
||||
|
||||
auto* entry_array = Array::create(global_object, 0);
|
||||
entry_array->define_property(0, value);
|
||||
entry_array->define_property(1, value);
|
||||
return create_iterator_result_object(global_object, entry_array, false);
|
||||
return create_iterator_result_object(global_object, Array::create_from(global_object, { value, value }), false);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,13 +30,13 @@ void SetPrototype::initialize(GlobalObject& global_object)
|
|||
define_native_function(vm.names.values, values, 0, attr);
|
||||
define_native_accessor(vm.names.size, size_getter, {}, Attribute::Configurable);
|
||||
|
||||
define_property(vm.names.keys, get(vm.names.values), attr);
|
||||
define_direct_property(vm.names.keys, get(vm.names.values), attr);
|
||||
|
||||
// 24.2.3.11 Set.prototype [ @@iterator ] ( ), https://tc39.es/ecma262/#sec-set.prototype-@@iterator
|
||||
define_property(*vm.well_known_symbol_iterator(), get(vm.names.values), attr);
|
||||
define_direct_property(*vm.well_known_symbol_iterator(), get(vm.names.values), attr);
|
||||
|
||||
// 24.2.3.12 Set.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-set.prototype-@@tostringtag
|
||||
define_property(*vm.well_known_symbol_to_string_tag(), js_string(vm.heap(), vm.names.Set.as_string()), Attribute::Configurable);
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm.heap(), vm.names.Set.as_string()), Attribute::Configurable);
|
||||
}
|
||||
|
||||
SetPrototype::~SetPrototype()
|
||||
|
|
|
@ -26,9 +26,9 @@ void StringConstructor::initialize(GlobalObject& global_object)
|
|||
NativeFunction::initialize(global_object);
|
||||
|
||||
// 22.1.2.3 String.prototype, https://tc39.es/ecma262/#sec-string.prototype
|
||||
define_property(vm.names.prototype, global_object.string_prototype(), 0);
|
||||
define_direct_property(vm.names.prototype, global_object.string_prototype(), 0);
|
||||
|
||||
define_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(vm.names.raw, raw, 1, attr);
|
||||
|
|
|
@ -25,7 +25,7 @@ void StringIteratorPrototype::initialize(GlobalObject& global_object)
|
|||
define_native_function(vm.names.next, next, 0, Attribute::Configurable | Attribute::Writable);
|
||||
|
||||
// 22.1.5.1.2 %StringIteratorPrototype% [ @@toStringTag ], https://tc39.es/ecma262/#sec-%stringiteratorprototype%-@@tostringtag
|
||||
define_property(*vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), "String Iterator"), Attribute::Configurable);
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), "String Iterator"), Attribute::Configurable);
|
||||
}
|
||||
|
||||
StringIteratorPrototype::~StringIteratorPrototype()
|
||||
|
|
|
@ -33,7 +33,7 @@ void StringObject::initialize(GlobalObject& global_object)
|
|||
{
|
||||
auto& vm = this->vm();
|
||||
Object::initialize(global_object);
|
||||
define_property(vm.names.length, Value(m_string.string().length()), 0);
|
||||
define_direct_property(vm.names.length, Value(m_string.string().length()), 0);
|
||||
}
|
||||
|
||||
void StringObject::visit_edges(Cell::Visitor& visitor)
|
||||
|
|
|
@ -68,9 +68,9 @@ void StringPrototype::initialize(GlobalObject& global_object)
|
|||
define_native_function(vm.names.padEnd, pad_end, 1, attr);
|
||||
define_native_function(vm.names.trim, trim, 0, attr);
|
||||
define_native_function(vm.names.trimStart, trim_start, 0, attr);
|
||||
define_property(vm.names.trimLeft, get_without_side_effects(vm.names.trimStart), attr);
|
||||
define_direct_property(vm.names.trimLeft, get_without_side_effects(vm.names.trimStart), attr);
|
||||
define_native_function(vm.names.trimEnd, trim_end, 0, attr);
|
||||
define_property(vm.names.trimRight, get_without_side_effects(vm.names.trimEnd), attr);
|
||||
define_direct_property(vm.names.trimRight, get_without_side_effects(vm.names.trimEnd), attr);
|
||||
define_native_function(vm.names.concat, concat, 1, attr);
|
||||
define_native_function(vm.names.substr, substr, 2, attr);
|
||||
define_native_function(vm.names.substring, substring, 2, attr);
|
||||
|
|
|
@ -21,16 +21,16 @@ void SymbolConstructor::initialize(GlobalObject& global_object)
|
|||
NativeFunction::initialize(global_object);
|
||||
|
||||
// 20.4.2.9 Symbol.prototype, https://tc39.es/ecma262/#sec-symbol.prototype
|
||||
define_property(vm.names.prototype, global_object.symbol_prototype(), 0);
|
||||
define_direct_property(vm.names.prototype, global_object.symbol_prototype(), 0);
|
||||
|
||||
define_property(vm.names.length, Value(0), Attribute::Configurable);
|
||||
define_direct_property(vm.names.length, Value(0), Attribute::Configurable);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(vm.names.for_, for_, 1, attr);
|
||||
define_native_function(vm.names.keyFor, key_for, 1, attr);
|
||||
|
||||
#define __JS_ENUMERATE(SymbolName, snake_name) \
|
||||
define_property(vm.names.SymbolName, vm.well_known_symbol_##snake_name(), 0);
|
||||
define_direct_property(vm.names.SymbolName, vm.well_known_symbol_##snake_name(), 0);
|
||||
JS_ENUMERATE_WELL_KNOWN_SYMBOLS
|
||||
#undef __JS_ENUMERATE
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ void SymbolPrototype::initialize(GlobalObject& global_object)
|
|||
define_native_function(*vm.well_known_symbol_to_primitive(), symbol_to_primitive, 1, Attribute::Configurable);
|
||||
|
||||
// 20.4.3.6 Symbol.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-symbol.prototype-@@tostringtag
|
||||
define_property(*vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), "Symbol"), Attribute::Configurable);
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), "Symbol"), Attribute::Configurable);
|
||||
}
|
||||
|
||||
SymbolPrototype::~SymbolPrototype()
|
||||
|
|
|
@ -236,12 +236,17 @@ void TypedArrayBase::visit_edges(Visitor& visitor)
|
|||
PrototypeName::PrototypeName(GlobalObject& global_object) \
|
||||
: Object(*global_object.typed_array_prototype()) \
|
||||
{ \
|
||||
auto& vm = this->vm(); \
|
||||
define_property(vm.names.BYTES_PER_ELEMENT, Value((i32)sizeof(Type)), 0); \
|
||||
} \
|
||||
\
|
||||
PrototypeName::~PrototypeName() { } \
|
||||
\
|
||||
void PrototypeName::initialize(GlobalObject& global_object) \
|
||||
{ \
|
||||
auto& vm = this->vm(); \
|
||||
Object::initialize(global_object); \
|
||||
define_direct_property(vm.names.BYTES_PER_ELEMENT, Value((i32)sizeof(Type)), 0); \
|
||||
} \
|
||||
\
|
||||
ConstructorName::ConstructorName(GlobalObject& global_object) \
|
||||
: TypedArrayConstructor(vm().names.ClassName.as_string(), *global_object.typed_array_constructor()) \
|
||||
{ \
|
||||
|
@ -255,12 +260,12 @@ void TypedArrayBase::visit_edges(Visitor& visitor)
|
|||
NativeFunction::initialize(global_object); \
|
||||
\
|
||||
/* 23.2.6.2 TypedArray.prototype, https://tc39.es/ecma262/#sec-typedarray.prototype */ \
|
||||
define_property(vm.names.prototype, global_object.snake_name##_prototype(), 0); \
|
||||
define_direct_property(vm.names.prototype, global_object.snake_name##_prototype(), 0); \
|
||||
\
|
||||
define_property(vm.names.length, Value(3), Attribute::Configurable); \
|
||||
define_direct_property(vm.names.length, Value(3), Attribute::Configurable); \
|
||||
\
|
||||
/* 23.2.6.1 TypedArray.BYTES_PER_ELEMENT, https://tc39.es/ecma262/#sec-typedarray.bytes_per_element */ \
|
||||
define_property(vm.names.BYTES_PER_ELEMENT, Value((i32)sizeof(Type)), 0); \
|
||||
define_direct_property(vm.names.BYTES_PER_ELEMENT, Value((i32)sizeof(Type)), 0); \
|
||||
} \
|
||||
\
|
||||
/* 23.2.5.1 TypedArray ( ...args ), https://tc39.es/ecma262/#sec-typedarray */ \
|
||||
|
|
|
@ -471,6 +471,7 @@ private:
|
|||
\
|
||||
public: \
|
||||
PrototypeName(GlobalObject&); \
|
||||
virtual void initialize(GlobalObject&) override; \
|
||||
virtual ~PrototypeName() override; \
|
||||
}; \
|
||||
class ConstructorName final : public TypedArrayConstructor { \
|
||||
|
|
|
@ -27,9 +27,9 @@ void TypedArrayConstructor::initialize(GlobalObject& global_object)
|
|||
NativeFunction::initialize(global_object);
|
||||
|
||||
// 23.2.2.3 %TypedArray%.prototype, https://tc39.es/ecma262/#sec-%typedarray%.prototype
|
||||
define_property(vm.names.prototype, global_object.typed_array_prototype(), 0);
|
||||
define_direct_property(vm.names.prototype, global_object.typed_array_prototype(), 0);
|
||||
|
||||
define_property(vm.names.length, Value(0), Attribute::Configurable);
|
||||
define_direct_property(vm.names.length, Value(0), Attribute::Configurable);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(vm.names.from, from, 1, attr);
|
||||
|
|
|
@ -44,7 +44,7 @@ void TypedArrayPrototype::initialize(GlobalObject& object)
|
|||
define_native_accessor(*vm.well_known_symbol_to_string_tag(), to_string_tag_getter, nullptr, Attribute::Configurable);
|
||||
|
||||
// 23.2.3.29 %TypedArray%.prototype.toString ( ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.tostring
|
||||
define_property(vm.names.toString, global_object().array_prototype()->get_without_side_effects(vm.names.toString), attr);
|
||||
define_direct_property(vm.names.toString, global_object().array_prototype()->get_without_side_effects(vm.names.toString), attr);
|
||||
}
|
||||
|
||||
TypedArrayPrototype::~TypedArrayPrototype()
|
||||
|
|
|
@ -24,9 +24,9 @@ void WeakMapConstructor::initialize(GlobalObject& global_object)
|
|||
NativeFunction::initialize(global_object);
|
||||
|
||||
// 24.3.2.1 WeakMap.prototype, https://tc39.es/ecma262/#sec-weakmap.prototype
|
||||
define_property(vm.names.prototype, global_object.weak_map_prototype(), 0);
|
||||
define_direct_property(vm.names.prototype, global_object.weak_map_prototype(), 0);
|
||||
|
||||
define_property(vm.names.length, Value(0), Attribute::Configurable);
|
||||
define_direct_property(vm.names.length, Value(0), Attribute::Configurable);
|
||||
}
|
||||
|
||||
WeakMapConstructor::~WeakMapConstructor()
|
||||
|
|
|
@ -26,7 +26,7 @@ void WeakMapPrototype::initialize(GlobalObject& global_object)
|
|||
define_native_function(vm.names.set, set, 2, attr);
|
||||
|
||||
// 24.3.3.6 WeakMap.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-weakmap.prototype-@@tostringtag
|
||||
define_property(*vm.well_known_symbol_to_string_tag(), js_string(vm.heap(), vm.names.WeakMap.as_string()), Attribute::Configurable);
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm.heap(), vm.names.WeakMap.as_string()), Attribute::Configurable);
|
||||
}
|
||||
|
||||
WeakMapPrototype::~WeakMapPrototype()
|
||||
|
|
|
@ -23,9 +23,9 @@ void WeakRefConstructor::initialize(GlobalObject& global_object)
|
|||
NativeFunction::initialize(global_object);
|
||||
|
||||
// 26.1.2.1 WeakRef.prototype, https://tc39.es/ecma262/#sec-weak-ref.prototype
|
||||
define_property(vm.names.prototype, global_object.weak_ref_prototype(), 0);
|
||||
define_direct_property(vm.names.prototype, global_object.weak_ref_prototype(), 0);
|
||||
|
||||
define_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
}
|
||||
|
||||
WeakRefConstructor::~WeakRefConstructor()
|
||||
|
|
|
@ -20,7 +20,7 @@ void WeakRefPrototype::initialize(GlobalObject& global_object)
|
|||
|
||||
define_native_function(vm.names.deref, deref, 0, Attribute::Writable | Attribute::Configurable);
|
||||
|
||||
define_property(*vm.well_known_symbol_to_string_tag(), js_string(vm.heap(), vm.names.WeakRef.as_string()), Attribute::Configurable);
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm.heap(), vm.names.WeakRef.as_string()), Attribute::Configurable);
|
||||
}
|
||||
|
||||
WeakRefPrototype::~WeakRefPrototype()
|
||||
|
|
|
@ -24,9 +24,9 @@ void WeakSetConstructor::initialize(GlobalObject& global_object)
|
|||
NativeFunction::initialize(global_object);
|
||||
|
||||
// 24.4.2.1 WeakSet.prototype, https://tc39.es/ecma262/#sec-weakset.prototype
|
||||
define_property(vm.names.prototype, global_object.weak_set_prototype(), 0);
|
||||
define_direct_property(vm.names.prototype, global_object.weak_set_prototype(), 0);
|
||||
|
||||
define_property(vm.names.length, Value(0), Attribute::Configurable);
|
||||
define_direct_property(vm.names.length, Value(0), Attribute::Configurable);
|
||||
}
|
||||
|
||||
WeakSetConstructor::~WeakSetConstructor()
|
||||
|
|
|
@ -25,7 +25,7 @@ void WeakSetPrototype::initialize(GlobalObject& global_object)
|
|||
define_native_function(vm.names.has, has, 1, attr);
|
||||
|
||||
// 24.4.3.5 WeakSet.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-weakset.prototype-@@tostringtag
|
||||
define_property(*vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), vm.names.WeakSet.as_string()), Attribute::Configurable);
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), vm.names.WeakSet.as_string()), Attribute::Configurable);
|
||||
}
|
||||
|
||||
WeakSetPrototype::~WeakSetPrototype()
|
||||
|
|
|
@ -26,7 +26,7 @@ test("Issue #5884, GenericIndexedPropertyStorage::take_first() loses elements",
|
|||
const a = [];
|
||||
for (let i = 0; i < 300; i++) {
|
||||
// NOTE: We use defineProperty to prevent the array from using SimpleIndexedPropertyStorage
|
||||
Object.defineProperty(a, i, { value: i, configurable: true });
|
||||
Object.defineProperty(a, i, { value: i, configurable: true, writable: true });
|
||||
}
|
||||
expect(a.length).toBe(300);
|
||||
for (let i = 0; i < 300; i++) {
|
||||
|
|
|
@ -180,13 +180,13 @@ public:
|
|||
inline void TestRunnerGlobalObject::initialize_global_object()
|
||||
{
|
||||
Base::initialize_global_object();
|
||||
define_property("global", this, JS::Attribute::Enumerable);
|
||||
define_direct_property("global", this, JS::Attribute::Enumerable);
|
||||
for (auto& entry : s_exposed_global_functions) {
|
||||
define_native_function(
|
||||
entry.key, [fn = entry.value.function](auto& vm, auto& global_object) {
|
||||
return fn(vm, global_object);
|
||||
},
|
||||
entry.value.length);
|
||||
entry.value.length, JS::default_attributes);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,8 +25,8 @@ void ImageConstructor::initialize(JS::GlobalObject& global_object)
|
|||
auto& window = static_cast<WindowObject&>(global_object);
|
||||
NativeFunction::initialize(global_object);
|
||||
|
||||
define_property(vm.names.prototype, &window.ensure_web_prototype<HTMLImageElementPrototype>("HTMLImageElement"), 0);
|
||||
define_property(vm.names.length, JS::Value(0), JS::Attribute::Configurable);
|
||||
define_direct_property(vm.names.prototype, &window.ensure_web_prototype<HTMLImageElementPrototype>("HTMLImageElement"), 0);
|
||||
define_direct_property(vm.names.length, JS::Value(0), JS::Attribute::Configurable);
|
||||
}
|
||||
|
||||
ImageConstructor::~ImageConstructor()
|
||||
|
|
|
@ -24,13 +24,14 @@ void NavigatorObject::initialize(JS::GlobalObject& global_object)
|
|||
languages->indexed_properties().append(js_string(heap, "en-US"));
|
||||
|
||||
// FIXME: All of these should be in Navigator's prototype and be native accessors
|
||||
define_property("appCodeName", js_string(heap, "Mozilla"));
|
||||
define_property("appName", js_string(heap, "Netscape"));
|
||||
define_property("appVersion", js_string(heap, "4.0"));
|
||||
define_property("language", languages->get(0));
|
||||
define_property("languages", languages);
|
||||
define_property("platform", js_string(heap, "SerenityOS"));
|
||||
define_property("product", js_string(heap, "Gecko"));
|
||||
u8 attr = JS::Attribute::Configurable | JS::Attribute::Writable | JS::Attribute::Enumerable;
|
||||
define_direct_property("appCodeName", js_string(heap, "Mozilla"), attr);
|
||||
define_direct_property("appName", js_string(heap, "Netscape"), attr);
|
||||
define_direct_property("appVersion", js_string(heap, "4.0"), attr);
|
||||
define_direct_property("language", languages->get(0), attr);
|
||||
define_direct_property("languages", languages, attr);
|
||||
define_direct_property("platform", js_string(heap, "SerenityOS"), attr);
|
||||
define_direct_property("product", js_string(heap, "Gecko"), attr);
|
||||
|
||||
define_native_accessor("userAgent", user_agent_getter, {});
|
||||
}
|
||||
|
|
|
@ -47,9 +47,9 @@ void WindowObject::initialize_global_object()
|
|||
VERIFY(success);
|
||||
|
||||
// FIXME: These should be native accessors, not properties
|
||||
define_property("window", this, JS::Attribute::Enumerable);
|
||||
define_property("frames", this, JS::Attribute::Enumerable);
|
||||
define_property("self", this, JS::Attribute::Enumerable);
|
||||
define_direct_property("window", this, JS::Attribute::Enumerable);
|
||||
define_direct_property("frames", this, JS::Attribute::Enumerable);
|
||||
define_direct_property("self", this, JS::Attribute::Enumerable);
|
||||
define_native_accessor("top", top_getter, nullptr, JS::Attribute::Enumerable);
|
||||
define_native_accessor("parent", parent_getter, {}, JS::Attribute::Enumerable);
|
||||
define_native_accessor("document", document_getter, {}, JS::Attribute::Enumerable);
|
||||
|
@ -72,11 +72,11 @@ void WindowObject::initialize_global_object()
|
|||
// Legacy
|
||||
define_native_accessor("event", event_getter, {}, JS::Attribute::Enumerable);
|
||||
|
||||
define_property("navigator", heap().allocate<NavigatorObject>(*this, *this), JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
define_property("location", heap().allocate<LocationObject>(*this, *this), JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
define_direct_property("navigator", heap().allocate<NavigatorObject>(*this, *this), JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
define_direct_property("location", heap().allocate<LocationObject>(*this, *this), JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
|
||||
// WebAssembly "namespace"
|
||||
define_property("WebAssembly", heap().allocate<WebAssemblyObject>(*this, *this), JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
define_direct_property("WebAssembly", heap().allocate<WebAssemblyObject>(*this, *this), JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
|
||||
ADD_WINDOW_OBJECT_INTERFACES;
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public:
|
|||
return *it->value;
|
||||
auto* constructor = heap().allocate<T>(*this, *this);
|
||||
m_constructors.set(class_name, constructor);
|
||||
define_property(class_name, JS::Value(constructor), JS::Attribute::Writable | JS::Attribute::Configurable);
|
||||
define_direct_property(class_name, JS::Value(constructor), JS::Attribute::Writable | JS::Attribute::Configurable);
|
||||
return *constructor;
|
||||
}
|
||||
|
||||
|
|
|
@ -226,12 +226,12 @@
|
|||
#include <LibWeb/Bindings/XMLHttpRequestEventTargetPrototype.h>
|
||||
#include <LibWeb/Bindings/XMLHttpRequestPrototype.h>
|
||||
|
||||
#define ADD_WINDOW_OBJECT_CONSTRUCTOR_AND_PROTOTYPE(interface_name, constructor_name, prototype_name) \
|
||||
{ \
|
||||
auto& constructor = ensure_web_constructor<constructor_name>(#interface_name); \
|
||||
constructor.define_property(vm.names.name, js_string(vm, #interface_name), JS::Attribute::Configurable); \
|
||||
auto& prototype = ensure_web_prototype<prototype_name>(#interface_name); \
|
||||
prototype.define_property(vm.names.constructor, &constructor, JS::Attribute::Writable | JS::Attribute::Configurable); \
|
||||
#define ADD_WINDOW_OBJECT_CONSTRUCTOR_AND_PROTOTYPE(interface_name, constructor_name, prototype_name) \
|
||||
{ \
|
||||
auto& constructor = ensure_web_constructor<constructor_name>(#interface_name); \
|
||||
constructor.define_direct_property(vm.names.name, js_string(vm, #interface_name), JS::Attribute::Configurable); \
|
||||
auto& prototype = ensure_web_prototype<prototype_name>(#interface_name); \
|
||||
prototype.define_direct_property(vm.names.constructor, &constructor, JS::Attribute::Writable | JS::Attribute::Configurable); \
|
||||
}
|
||||
|
||||
#define ADD_WINDOW_OBJECT_INTERFACE(interface_name) \
|
||||
|
|
|
@ -1113,8 +1113,8 @@ void @constructor_class@::initialize(JS::GlobalObject& global_object)
|
|||
[[maybe_unused]] u8 default_attributes = JS::Attribute::Enumerable;
|
||||
|
||||
NativeFunction::initialize(global_object);
|
||||
define_property(vm.names.prototype, &window.ensure_web_prototype<@prototype_class@>("@name@"), 0);
|
||||
define_property(vm.names.length, JS::Value(@constructor.length@), JS::Attribute::Configurable);
|
||||
define_direct_property(vm.names.prototype, &window.ensure_web_prototype<@prototype_class@>("@name@"), 0);
|
||||
define_direct_property(vm.names.length, JS::Value(@constructor.length@), JS::Attribute::Configurable);
|
||||
|
||||
)~~~");
|
||||
|
||||
|
@ -1124,7 +1124,7 @@ void @constructor_class@::initialize(JS::GlobalObject& global_object)
|
|||
constant_generator.set("constant.value", constant.value);
|
||||
|
||||
constant_generator.append(R"~~~(
|
||||
define_property("@constant.name@", JS::Value((i32)@constant.value@), JS::Attribute::Enumerable);
|
||||
define_direct_property("@constant.name@", JS::Value((i32)@constant.value@), JS::Attribute::Enumerable);
|
||||
)~~~");
|
||||
}
|
||||
|
||||
|
@ -1336,7 +1336,7 @@ void @prototype_class@::initialize(JS::GlobalObject& global_object)
|
|||
constant_generator.set("constant.value", constant.value);
|
||||
|
||||
constant_generator.append(R"~~~(
|
||||
define_property("@constant.name@", JS::Value((i32)@constant.value@), JS::Attribute::Enumerable);
|
||||
define_direct_property("@constant.name@", JS::Value((i32)@constant.value@), JS::Attribute::Enumerable);
|
||||
)~~~");
|
||||
}
|
||||
|
||||
|
|
|
@ -59,8 +59,8 @@ void WebAssemblyInstanceConstructor::initialize(JS::GlobalObject& global_object)
|
|||
auto& window = static_cast<WindowObject&>(global_object);
|
||||
|
||||
NativeFunction::initialize(global_object);
|
||||
define_property(vm.names.prototype, &window.ensure_web_prototype<WebAssemblyInstancePrototype>("WebAssemblyInstancePrototype"));
|
||||
define_property(vm.names.length, JS::Value(1), JS::Attribute::Configurable);
|
||||
define_direct_property(vm.names.prototype, &window.ensure_web_prototype<WebAssemblyInstancePrototype>("WebAssemblyInstancePrototype"), 0);
|
||||
define_direct_property(vm.names.length, JS::Value(1), JS::Attribute::Configurable);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ void WebAssemblyInstanceObject::initialize(JS::GlobalObject& global_object)
|
|||
object = create_native_function(address, export_.name(), global_object);
|
||||
cache.function_instances.set(address, *object);
|
||||
}
|
||||
m_exports_object->define_property(export_.name(), *object);
|
||||
m_exports_object->define_direct_property(export_.name(), *object, JS::default_attributes);
|
||||
},
|
||||
[&](const Wasm::MemoryAddress& address) {
|
||||
auto object = cache.memory_instances.get(address);
|
||||
|
@ -47,7 +47,7 @@ void WebAssemblyInstanceObject::initialize(JS::GlobalObject& global_object)
|
|||
object = heap().allocate<Web::Bindings::WebAssemblyMemoryObject>(global_object, global_object, address);
|
||||
cache.memory_instances.set(address, *object);
|
||||
}
|
||||
m_exports_object->define_property(export_.name(), *object);
|
||||
m_exports_object->define_direct_property(export_.name(), *object, JS::default_attributes);
|
||||
},
|
||||
[&](const auto&) {
|
||||
// FIXME: Implement other exports!
|
||||
|
|
|
@ -72,8 +72,8 @@ void WebAssemblyMemoryConstructor::initialize(JS::GlobalObject& global_object)
|
|||
auto& window = static_cast<WindowObject&>(global_object);
|
||||
|
||||
NativeFunction::initialize(global_object);
|
||||
define_property(vm.names.prototype, &window.ensure_web_prototype<WebAssemblyMemoryPrototype>("WebAssemblyMemoryPrototype"));
|
||||
define_property(vm.names.length, JS::Value(1), JS::Attribute::Configurable);
|
||||
define_direct_property(vm.names.prototype, &window.ensure_web_prototype<WebAssemblyMemoryPrototype>("WebAssemblyMemoryPrototype"), 0);
|
||||
define_direct_property(vm.names.length, JS::Value(1), JS::Attribute::Configurable);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -54,8 +54,8 @@ void WebAssemblyModuleConstructor::initialize(JS::GlobalObject& global_object)
|
|||
auto& window = static_cast<WindowObject&>(global_object);
|
||||
|
||||
NativeFunction::initialize(global_object);
|
||||
define_property(vm.names.prototype, &window.ensure_web_prototype<WebAssemblyModulePrototype>("WebAssemblyModulePrototype"));
|
||||
define_property(vm.names.length, JS::Value(1), JS::Attribute::Configurable);
|
||||
define_direct_property(vm.names.prototype, &window.ensure_web_prototype<WebAssemblyModulePrototype>("WebAssemblyModulePrototype"), 0);
|
||||
define_direct_property(vm.names.length, JS::Value(1), JS::Attribute::Configurable);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,30 +31,31 @@ void WebAssemblyObject::initialize(JS::GlobalObject& global_object)
|
|||
{
|
||||
Object::initialize(global_object);
|
||||
|
||||
define_native_function("validate", validate, 1);
|
||||
define_native_function("compile", compile, 1);
|
||||
define_native_function("instantiate", instantiate, 1);
|
||||
u8 attr = JS::Attribute::Configurable | JS::Attribute::Writable | JS::Attribute::Enumerable;
|
||||
define_native_function("validate", validate, 1, attr);
|
||||
define_native_function("compile", compile, 1, attr);
|
||||
define_native_function("instantiate", instantiate, 1, attr);
|
||||
|
||||
auto& vm = global_object.vm();
|
||||
|
||||
auto& window = static_cast<WindowObject&>(global_object);
|
||||
auto& memory_constructor = window.ensure_web_constructor<WebAssemblyMemoryConstructor>("WebAssembly.Memory");
|
||||
memory_constructor.define_property(vm.names.name, js_string(vm, "WebAssembly.Memory"), JS::Attribute::Configurable);
|
||||
memory_constructor.define_direct_property(vm.names.name, js_string(vm, "WebAssembly.Memory"), JS::Attribute::Configurable);
|
||||
auto& memory_prototype = window.ensure_web_prototype<WebAssemblyMemoryPrototype>("WebAssemblyMemoryPrototype");
|
||||
memory_prototype.define_property(vm.names.constructor, &memory_constructor, JS::Attribute::Writable | JS::Attribute::Configurable);
|
||||
define_property("Memory", &memory_constructor);
|
||||
memory_prototype.define_direct_property(vm.names.constructor, &memory_constructor, JS::Attribute::Writable | JS::Attribute::Configurable);
|
||||
define_direct_property("Memory", &memory_constructor, JS::Attribute::Writable | JS::Attribute::Configurable);
|
||||
|
||||
auto& instance_constructor = window.ensure_web_constructor<WebAssemblyInstanceConstructor>("WebAssembly.Instance");
|
||||
instance_constructor.define_property(vm.names.name, js_string(vm, "WebAssembly.Instance"), JS::Attribute::Configurable);
|
||||
instance_constructor.define_direct_property(vm.names.name, js_string(vm, "WebAssembly.Instance"), JS::Attribute::Configurable);
|
||||
auto& instance_prototype = window.ensure_web_prototype<WebAssemblyInstancePrototype>("WebAssemblyInstancePrototype");
|
||||
instance_prototype.define_property(vm.names.constructor, &instance_constructor, JS::Attribute::Writable | JS::Attribute::Configurable);
|
||||
define_property("Instance", &instance_constructor);
|
||||
instance_prototype.define_direct_property(vm.names.constructor, &instance_constructor, JS::Attribute::Writable | JS::Attribute::Configurable);
|
||||
define_direct_property("Instance", &instance_constructor, JS::Attribute::Writable | JS::Attribute::Configurable);
|
||||
|
||||
auto& module_constructor = window.ensure_web_constructor<WebAssemblyModuleConstructor>("WebAssembly.Module");
|
||||
module_constructor.define_property(vm.names.name, js_string(vm, "WebAssembly.Module"), JS::Attribute::Configurable);
|
||||
module_constructor.define_direct_property(vm.names.name, js_string(vm, "WebAssembly.Module"), JS::Attribute::Configurable);
|
||||
auto& module_prototype = window.ensure_web_prototype<WebAssemblyModulePrototype>("WebAssemblyModulePrototype");
|
||||
module_prototype.define_property(vm.names.constructor, &module_constructor, JS::Attribute::Writable | JS::Attribute::Configurable);
|
||||
define_property("Module", &module_constructor);
|
||||
module_prototype.define_direct_property(vm.names.constructor, &module_constructor, JS::Attribute::Writable | JS::Attribute::Configurable);
|
||||
define_direct_property("Module", &module_constructor, JS::Attribute::Writable | JS::Attribute::Configurable);
|
||||
}
|
||||
|
||||
NonnullOwnPtrVector<WebAssemblyObject::CompiledWebAssemblyModule> WebAssemblyObject::s_compiled_modules;
|
||||
|
|
|
@ -653,7 +653,7 @@ static JS::Value load_file_impl(JS::VM& vm, JS::GlobalObject& global_object)
|
|||
void ReplObject::initialize_global_object()
|
||||
{
|
||||
Base::initialize_global_object();
|
||||
define_property("global", this, JS::Attribute::Enumerable);
|
||||
define_direct_property("global", this, JS::Attribute::Enumerable);
|
||||
define_native_function("exit", exit_interpreter);
|
||||
define_native_function("help", repl_help);
|
||||
define_native_function("load", load_file, 1);
|
||||
|
@ -700,7 +700,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReplObject::load_file)
|
|||
void ScriptObject::initialize_global_object()
|
||||
{
|
||||
Base::initialize_global_object();
|
||||
define_property("global", this, JS::Attribute::Enumerable);
|
||||
define_direct_property("global", this, JS::Attribute::Enumerable);
|
||||
define_native_function("load", load_file, 1);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue