2021-06-22 17:16:08 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
|
LibJS: Rewrite most of Object for spec compliance :^)
This is a huge patch, I know. In hindsight this perhaps could've been
done slightly more incremental, but I started and then fixed everything
until it worked, and here we are. I tried splitting of some completely
unrelated changes into separate commits, however. Anyway.
This is a rewrite of most of Object, and by extension large parts of
Array, Proxy, Reflect, String, TypedArray, and some other things.
What we already had worked fine for about 90% of things, but getting the
last 10% right proved to be increasingly difficult with the current code
that sort of grew organically and is only very loosely based on the
spec - this became especially obvious when we started fixing a large
number of test262 failures.
Key changes include:
- 1:1 matching function names and parameters of all object-related
functions, to avoid ambiguity. Previously we had things like put(),
which the spec doesn't have - as a result it wasn't always clear which
need to be used.
- Better separation between object abstract operations and internal
methods - the former are always the same, the latter can be overridden
(and are therefore virtual). The internal methods (i.e. [[Foo]] in the
spec) are now prefixed with 'internal_' for clarity - again, it was
previously not always clear which AO a certain method represents,
get() could've been both Get and [[Get]] (I don't know which one it
was closer to right now).
Note that some of the old names have been kept until all code relying
on them is updated, but they are now simple wrappers around the
closest matching standard abstract operation.
- Simplifications of the storage layer: functions that write values to
storage are now prefixed with 'storage_' to make their purpose clear,
and as they are not part of the spec they should not contain any steps
specified by it. Much functionality is now covered by the layers above
it and was removed (e.g. handling of accessors, attribute checks).
- PropertyAttributes has been greatly simplified, and is being replaced
by PropertyDescriptor - a concept similar to the current
implementation, but more aligned with the actual spec. See the commit
message of the previous commit where it was introduced for details.
- As a bonus, and since I had to look at the spec a whole lot anyway, I
introduced more inline comments with the exact steps from the spec -
this makes it super easy to verify correctness.
- East-const all the things.
As a result of all of this, things are much more correct but a bit
slower now. Retaining speed wasn't a consideration at all, I have done
no profiling of the new code - there might be low hanging fruits, which
we can then harvest separately.
Special thanks to Idan for helping me with this by tracking down bugs,
updating everything outside of LibJS to work with these changes (LibWeb,
Spreadsheet, HackStudio), as well as providing countless patches to fix
regressions I introduced - there still are very few (we got it down to
5), but we also get many new passing test262 tests in return. :^)
Co-authored-by: Idan Horowitz <idan.horowitz@gmail.com>
2021-07-04 18:14:16 +01:00
|
|
|
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
|
2021-06-22 17:16:08 +02:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <LibJS/AST.h>
|
2021-10-09 16:52:34 +01:00
|
|
|
#include <LibJS/Runtime/Completion.h>
|
2021-07-01 12:24:46 +02:00
|
|
|
#include <LibJS/Runtime/DeclarativeEnvironment.h>
|
|
|
|
#include <LibJS/Runtime/GlobalEnvironment.h>
|
2021-06-22 17:16:08 +02:00
|
|
|
#include <LibJS/Runtime/GlobalObject.h>
|
2021-07-01 12:24:46 +02:00
|
|
|
#include <LibJS/Runtime/ObjectEnvironment.h>
|
2021-06-22 17:16:08 +02:00
|
|
|
|
|
|
|
namespace JS {
|
|
|
|
|
2021-09-11 19:58:27 +01:00
|
|
|
// 9.1.2.5 NewGlobalEnvironment ( G, thisValue ), https://tc39.es/ecma262/#sec-newglobalenvironment
|
|
|
|
GlobalEnvironment::GlobalEnvironment(GlobalObject& global_object, Object& this_value)
|
2021-07-01 12:24:46 +02:00
|
|
|
: Environment(nullptr)
|
2021-09-11 19:58:27 +01:00
|
|
|
, m_global_this_value(&this_value)
|
2021-06-22 17:16:08 +02:00
|
|
|
{
|
2021-07-01 12:24:46 +02:00
|
|
|
m_object_record = global_object.heap().allocate<ObjectEnvironment>(global_object, global_object, ObjectEnvironment::IsWithEnvironment::No, nullptr);
|
|
|
|
m_declarative_record = global_object.heap().allocate<DeclarativeEnvironment>(global_object);
|
2021-06-22 17:16:08 +02:00
|
|
|
}
|
|
|
|
|
2021-07-01 12:24:46 +02:00
|
|
|
void GlobalEnvironment::visit_edges(Cell::Visitor& visitor)
|
2021-06-22 17:16:08 +02:00
|
|
|
{
|
|
|
|
Base::visit_edges(visitor);
|
|
|
|
visitor.visit(m_object_record);
|
2021-09-11 19:58:27 +01:00
|
|
|
visitor.visit(m_global_this_value);
|
2021-06-22 17:16:08 +02:00
|
|
|
visitor.visit(m_declarative_record);
|
|
|
|
}
|
|
|
|
|
2021-10-09 16:52:34 +01:00
|
|
|
// 9.1.1.4.11 GetThisBinding ( ), https://tc39.es/ecma262/#sec-global-environment-records-getthisbinding
|
|
|
|
ThrowCompletionOr<Value> GlobalEnvironment::get_this_binding(GlobalObject&) const
|
2021-06-22 17:16:08 +02:00
|
|
|
{
|
2021-10-09 16:52:34 +01:00
|
|
|
// 1. Return envRec.[[GlobalThisValue]].
|
2021-10-20 19:17:45 +01:00
|
|
|
return m_global_this_value;
|
2021-06-22 17:16:08 +02:00
|
|
|
}
|
|
|
|
|
2021-06-23 12:26:37 +02:00
|
|
|
// 9.1.1.4.1 HasBinding ( N ), https://tc39.es/ecma262/#sec-global-environment-records-hasbinding-n
|
2021-10-09 17:07:32 +01:00
|
|
|
ThrowCompletionOr<bool> GlobalEnvironment::has_binding(FlyString const& name, Optional<size_t>*) const
|
2021-06-23 12:26:37 +02:00
|
|
|
{
|
2021-10-09 17:07:32 +01:00
|
|
|
// 1. Let DclRec be envRec.[[DeclarativeRecord]].
|
|
|
|
// 2. If DclRec.HasBinding(N) is true, return true.
|
|
|
|
if (MUST(m_declarative_record->has_binding(name)))
|
2021-06-23 12:26:37 +02:00
|
|
|
return true;
|
2021-10-09 17:07:32 +01:00
|
|
|
|
|
|
|
// 3. Let ObjRec be envRec.[[ObjectRecord]].
|
|
|
|
// 4. Return ? ObjRec.HasBinding(N).
|
2021-06-23 12:26:37 +02:00
|
|
|
return m_object_record->has_binding(name);
|
|
|
|
}
|
|
|
|
|
2021-06-23 13:25:57 +02:00
|
|
|
// 9.1.1.4.2 CreateMutableBinding ( N, D ), https://tc39.es/ecma262/#sec-global-environment-records-createmutablebinding-n-d
|
2021-10-09 18:53:25 +01:00
|
|
|
ThrowCompletionOr<void> GlobalEnvironment::create_mutable_binding(GlobalObject& global_object, FlyString const& name, bool can_be_deleted)
|
2021-06-23 12:26:37 +02:00
|
|
|
{
|
2021-10-09 18:53:25 +01:00
|
|
|
// 1. Let DclRec be envRec.[[DeclarativeRecord]].
|
|
|
|
// 2. If DclRec.HasBinding(N) is true, throw a TypeError exception.
|
|
|
|
if (MUST(m_declarative_record->has_binding(name)))
|
2021-10-20 17:55:39 +01:00
|
|
|
return vm().throw_completion<TypeError>(global_object, ErrorType::GlobalEnvironmentAlreadyHasBinding, name);
|
2021-10-09 18:53:25 +01:00
|
|
|
|
|
|
|
// 3. Return DclRec.CreateMutableBinding(N, D).
|
|
|
|
return m_declarative_record->create_mutable_binding(global_object, name, can_be_deleted);
|
2021-06-23 12:26:37 +02:00
|
|
|
}
|
|
|
|
|
2021-06-23 13:25:57 +02:00
|
|
|
// 9.1.1.4.3 CreateImmutableBinding ( N, S ), https://tc39.es/ecma262/#sec-global-environment-records-createimmutablebinding-n-s
|
2021-10-09 19:00:06 +01:00
|
|
|
ThrowCompletionOr<void> GlobalEnvironment::create_immutable_binding(GlobalObject& global_object, FlyString const& name, bool strict)
|
2021-06-23 12:26:37 +02:00
|
|
|
{
|
2021-10-09 19:00:06 +01:00
|
|
|
// 1. Let DclRec be envRec.[[DeclarativeRecord]].
|
|
|
|
// 2. If DclRec.HasBinding(N) is true, throw a TypeError exception.
|
|
|
|
if (MUST(m_declarative_record->has_binding(name)))
|
2021-10-20 17:55:39 +01:00
|
|
|
return vm().throw_completion<TypeError>(global_object, ErrorType::GlobalEnvironmentAlreadyHasBinding, name);
|
2021-10-09 19:00:06 +01:00
|
|
|
|
|
|
|
// 3. Return DclRec.CreateImmutableBinding(N, S).
|
|
|
|
return m_declarative_record->create_immutable_binding(global_object, name, strict);
|
2021-06-23 12:26:37 +02:00
|
|
|
}
|
|
|
|
|
2021-06-23 13:25:57 +02:00
|
|
|
// 9.1.1.4.4 InitializeBinding ( N, V ), https://tc39.es/ecma262/#sec-global-environment-records-initializebinding-n-v
|
2021-10-09 19:16:24 +01:00
|
|
|
ThrowCompletionOr<void> GlobalEnvironment::initialize_binding(GlobalObject& global_object, FlyString const& name, Value value)
|
2021-06-23 12:26:37 +02:00
|
|
|
{
|
2021-10-09 19:16:24 +01:00
|
|
|
// 1. Let DclRec be envRec.[[DeclarativeRecord]].
|
|
|
|
// 2. If DclRec.HasBinding(N) is true, then
|
2021-10-09 17:07:32 +01:00
|
|
|
if (MUST(m_declarative_record->has_binding(name))) {
|
2021-10-09 19:16:24 +01:00
|
|
|
// a. Return DclRec.InitializeBinding(N, V).
|
|
|
|
return m_declarative_record->initialize_binding(global_object, name, value);
|
2021-06-23 12:26:37 +02:00
|
|
|
}
|
2021-10-09 19:16:24 +01:00
|
|
|
|
|
|
|
// 3. Assert: If the binding exists, it must be in the object Environment Record.
|
|
|
|
// 4. Let ObjRec be envRec.[[ObjectRecord]].
|
|
|
|
// 5. Return ? ObjRec.InitializeBinding(N, V).
|
|
|
|
return m_object_record->initialize_binding(global_object, name, value);
|
2021-06-23 12:26:37 +02:00
|
|
|
}
|
|
|
|
|
2021-06-23 13:25:57 +02:00
|
|
|
// 9.1.1.4.5 SetMutableBinding ( N, V, S ), https://tc39.es/ecma262/#sec-global-environment-records-setmutablebinding-n-v-s
|
2021-10-09 19:34:54 +01:00
|
|
|
ThrowCompletionOr<void> GlobalEnvironment::set_mutable_binding(GlobalObject& global_object, FlyString const& name, Value value, bool strict)
|
2021-06-23 12:26:37 +02:00
|
|
|
{
|
2021-10-09 19:34:54 +01:00
|
|
|
// 1. Let DclRec be envRec.[[DeclarativeRecord]].
|
|
|
|
// 2. If DclRec.HasBinding(N) is true, then
|
2021-10-09 17:07:32 +01:00
|
|
|
if (MUST(m_declarative_record->has_binding(name))) {
|
2021-10-09 19:34:54 +01:00
|
|
|
// a. Return DclRec.SetMutableBinding(N, V, S).
|
|
|
|
return m_declarative_record->set_mutable_binding(global_object, name, value, strict);
|
2021-06-23 12:26:37 +02:00
|
|
|
}
|
|
|
|
|
2021-10-09 19:34:54 +01:00
|
|
|
// 3. Let ObjRec be envRec.[[ObjectRecord]].
|
|
|
|
// 4. Return ? ObjRec.SetMutableBinding(N, V, S).
|
|
|
|
return m_object_record->set_mutable_binding(global_object, name, value, strict);
|
2021-06-23 12:26:37 +02:00
|
|
|
}
|
|
|
|
|
2021-06-23 13:25:57 +02:00
|
|
|
// 9.1.1.4.6 GetBindingValue ( N, S ), https://tc39.es/ecma262/#sec-global-environment-records-getbindingvalue-n-s
|
2021-10-09 19:43:19 +01:00
|
|
|
ThrowCompletionOr<Value> GlobalEnvironment::get_binding_value(GlobalObject& global_object, FlyString const& name, bool strict)
|
2021-06-23 12:26:37 +02:00
|
|
|
{
|
2021-10-09 19:43:19 +01:00
|
|
|
// 1. Let DclRec be envRec.[[DeclarativeRecord]].
|
|
|
|
// 2. If DclRec.HasBinding(N) is true, then
|
|
|
|
if (MUST(m_declarative_record->has_binding(name))) {
|
|
|
|
// a. Return DclRec.GetBindingValue(N, S).
|
2021-06-23 12:26:37 +02:00
|
|
|
return m_declarative_record->get_binding_value(global_object, name, strict);
|
2021-10-09 19:43:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// 3. Let ObjRec be envRec.[[ObjectRecord]].
|
|
|
|
// 4. Return ? ObjRec.GetBindingValue(N, S).
|
2021-06-23 12:26:37 +02:00
|
|
|
return m_object_record->get_binding_value(global_object, name, strict);
|
|
|
|
}
|
|
|
|
|
2021-06-23 13:25:57 +02:00
|
|
|
// 9.1.1.4.7 DeleteBinding ( N ), https://tc39.es/ecma262/#sec-global-environment-records-deletebinding-n
|
2021-10-09 19:49:08 +01:00
|
|
|
ThrowCompletionOr<bool> GlobalEnvironment::delete_binding(GlobalObject& global_object, FlyString const& name)
|
2021-06-23 12:26:37 +02:00
|
|
|
{
|
2021-10-09 19:49:08 +01:00
|
|
|
// 1. Let DclRec be envRec.[[DeclarativeRecord]].
|
|
|
|
// 2. If DclRec.HasBinding(N) is true, then
|
|
|
|
if (MUST(m_declarative_record->has_binding(name))) {
|
|
|
|
// a. Return DclRec.DeleteBinding(N).
|
2021-06-23 12:26:37 +02:00
|
|
|
return m_declarative_record->delete_binding(global_object, name);
|
2021-10-09 19:49:08 +01:00
|
|
|
}
|
2021-06-23 12:26:37 +02:00
|
|
|
|
2021-10-09 19:49:08 +01:00
|
|
|
// 3. Let ObjRec be envRec.[[ObjectRecord]].
|
|
|
|
// 4. Let globalObject be ObjRec.[[BindingObject]].
|
|
|
|
|
|
|
|
// 5. Let existingProp be ? HasOwnProperty(globalObject, N).
|
|
|
|
bool existing_prop = TRY(m_object_record->binding_object().has_own_property(name));
|
|
|
|
|
|
|
|
// 6. If existingProp is true, then
|
2021-06-23 12:26:37 +02:00
|
|
|
if (existing_prop) {
|
2021-10-09 19:49:08 +01:00
|
|
|
// a. Let status be ? ObjRec.DeleteBinding(N).
|
|
|
|
bool status = TRY(m_object_record->delete_binding(global_object, name));
|
|
|
|
|
|
|
|
// b. If status is true, then
|
2021-06-23 12:26:37 +02:00
|
|
|
if (status) {
|
2021-10-09 19:49:08 +01:00
|
|
|
// i. Let varNames be envRec.[[VarNames]].
|
|
|
|
// ii. If N is an element of varNames, remove that element from the varNames.
|
2021-06-23 12:26:37 +02:00
|
|
|
m_var_names.remove_all_matching([&](auto& entry) { return entry == name; });
|
|
|
|
}
|
2021-10-09 19:49:08 +01:00
|
|
|
|
|
|
|
// c. Return status.
|
2021-06-23 12:26:37 +02:00
|
|
|
return status;
|
|
|
|
}
|
2021-10-09 19:49:08 +01:00
|
|
|
|
|
|
|
// 7. Return true.
|
2021-06-23 12:26:37 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-06-23 13:25:57 +02:00
|
|
|
// 9.1.1.4.12 HasVarDeclaration ( N ), https://tc39.es/ecma262/#sec-hasvardeclaration
|
2021-07-01 12:24:46 +02:00
|
|
|
bool GlobalEnvironment::has_var_declaration(FlyString const& name) const
|
2021-06-23 12:26:37 +02:00
|
|
|
{
|
2021-12-29 15:48:11 +01:00
|
|
|
// 1. Let varDeclaredNames be envRec.[[VarNames]].
|
|
|
|
// 2. If varDeclaredNames contains N, return true.
|
|
|
|
// 3. Return false.
|
2021-06-23 12:26:37 +02:00
|
|
|
return m_var_names.contains_slow(name);
|
|
|
|
}
|
|
|
|
|
2021-06-23 13:25:57 +02:00
|
|
|
// 9.1.1.4.13 HasLexicalDeclaration ( N ), https://tc39.es/ecma262/#sec-haslexicaldeclaration
|
2021-07-01 12:24:46 +02:00
|
|
|
bool GlobalEnvironment::has_lexical_declaration(FlyString const& name) const
|
2021-06-23 12:26:37 +02:00
|
|
|
{
|
2021-12-29 15:48:11 +01:00
|
|
|
// 1. Let DclRec be envRec.[[DeclarativeRecord]].
|
|
|
|
// 2. Return DclRec.HasBinding(N).
|
2021-10-09 17:07:32 +01:00
|
|
|
return MUST(m_declarative_record->has_binding(name));
|
2021-06-23 12:26:37 +02:00
|
|
|
}
|
|
|
|
|
2021-06-23 13:25:57 +02:00
|
|
|
// 9.1.1.4.14 HasRestrictedGlobalProperty ( N ), https://tc39.es/ecma262/#sec-hasrestrictedglobalproperty
|
2021-12-29 15:50:50 +01:00
|
|
|
ThrowCompletionOr<bool> GlobalEnvironment::has_restricted_global_property(FlyString const& name) const
|
2021-06-23 12:26:37 +02:00
|
|
|
{
|
2021-12-29 15:48:11 +01:00
|
|
|
// 1. Let ObjRec be envRec.[[ObjectRecord]].
|
|
|
|
// 2. Let globalObject be ObjRec.[[BindingObject]].
|
LibJS: Rewrite most of Object for spec compliance :^)
This is a huge patch, I know. In hindsight this perhaps could've been
done slightly more incremental, but I started and then fixed everything
until it worked, and here we are. I tried splitting of some completely
unrelated changes into separate commits, however. Anyway.
This is a rewrite of most of Object, and by extension large parts of
Array, Proxy, Reflect, String, TypedArray, and some other things.
What we already had worked fine for about 90% of things, but getting the
last 10% right proved to be increasingly difficult with the current code
that sort of grew organically and is only very loosely based on the
spec - this became especially obvious when we started fixing a large
number of test262 failures.
Key changes include:
- 1:1 matching function names and parameters of all object-related
functions, to avoid ambiguity. Previously we had things like put(),
which the spec doesn't have - as a result it wasn't always clear which
need to be used.
- Better separation between object abstract operations and internal
methods - the former are always the same, the latter can be overridden
(and are therefore virtual). The internal methods (i.e. [[Foo]] in the
spec) are now prefixed with 'internal_' for clarity - again, it was
previously not always clear which AO a certain method represents,
get() could've been both Get and [[Get]] (I don't know which one it
was closer to right now).
Note that some of the old names have been kept until all code relying
on them is updated, but they are now simple wrappers around the
closest matching standard abstract operation.
- Simplifications of the storage layer: functions that write values to
storage are now prefixed with 'storage_' to make their purpose clear,
and as they are not part of the spec they should not contain any steps
specified by it. Much functionality is now covered by the layers above
it and was removed (e.g. handling of accessors, attribute checks).
- PropertyAttributes has been greatly simplified, and is being replaced
by PropertyDescriptor - a concept similar to the current
implementation, but more aligned with the actual spec. See the commit
message of the previous commit where it was introduced for details.
- As a bonus, and since I had to look at the spec a whole lot anyway, I
introduced more inline comments with the exact steps from the spec -
this makes it super easy to verify correctness.
- East-const all the things.
As a result of all of this, things are much more correct but a bit
slower now. Retaining speed wasn't a consideration at all, I have done
no profiling of the new code - there might be low hanging fruits, which
we can then harvest separately.
Special thanks to Idan for helping me with this by tracking down bugs,
updating everything outside of LibJS to work with these changes (LibWeb,
Spreadsheet, HackStudio), as well as providing countless patches to fix
regressions I introduced - there still are very few (we got it down to
5), but we also get many new passing test262 tests in return. :^)
Co-authored-by: Idan Horowitz <idan.horowitz@gmail.com>
2021-07-04 18:14:16 +01:00
|
|
|
auto& global_object = m_object_record->binding_object();
|
2021-12-29 15:48:11 +01:00
|
|
|
|
|
|
|
// 3. Let existingProp be ? globalObject.[[GetOwnProperty]](N).
|
2021-12-29 15:50:50 +01:00
|
|
|
auto existing_prop = TRY(global_object.internal_get_own_property(name));
|
2021-12-29 15:48:11 +01:00
|
|
|
|
|
|
|
// 4. If existingProp is undefined, return false.
|
LibJS: Rewrite most of Object for spec compliance :^)
This is a huge patch, I know. In hindsight this perhaps could've been
done slightly more incremental, but I started and then fixed everything
until it worked, and here we are. I tried splitting of some completely
unrelated changes into separate commits, however. Anyway.
This is a rewrite of most of Object, and by extension large parts of
Array, Proxy, Reflect, String, TypedArray, and some other things.
What we already had worked fine for about 90% of things, but getting the
last 10% right proved to be increasingly difficult with the current code
that sort of grew organically and is only very loosely based on the
spec - this became especially obvious when we started fixing a large
number of test262 failures.
Key changes include:
- 1:1 matching function names and parameters of all object-related
functions, to avoid ambiguity. Previously we had things like put(),
which the spec doesn't have - as a result it wasn't always clear which
need to be used.
- Better separation between object abstract operations and internal
methods - the former are always the same, the latter can be overridden
(and are therefore virtual). The internal methods (i.e. [[Foo]] in the
spec) are now prefixed with 'internal_' for clarity - again, it was
previously not always clear which AO a certain method represents,
get() could've been both Get and [[Get]] (I don't know which one it
was closer to right now).
Note that some of the old names have been kept until all code relying
on them is updated, but they are now simple wrappers around the
closest matching standard abstract operation.
- Simplifications of the storage layer: functions that write values to
storage are now prefixed with 'storage_' to make their purpose clear,
and as they are not part of the spec they should not contain any steps
specified by it. Much functionality is now covered by the layers above
it and was removed (e.g. handling of accessors, attribute checks).
- PropertyAttributes has been greatly simplified, and is being replaced
by PropertyDescriptor - a concept similar to the current
implementation, but more aligned with the actual spec. See the commit
message of the previous commit where it was introduced for details.
- As a bonus, and since I had to look at the spec a whole lot anyway, I
introduced more inline comments with the exact steps from the spec -
this makes it super easy to verify correctness.
- East-const all the things.
As a result of all of this, things are much more correct but a bit
slower now. Retaining speed wasn't a consideration at all, I have done
no profiling of the new code - there might be low hanging fruits, which
we can then harvest separately.
Special thanks to Idan for helping me with this by tracking down bugs,
updating everything outside of LibJS to work with these changes (LibWeb,
Spreadsheet, HackStudio), as well as providing countless patches to fix
regressions I introduced - there still are very few (we got it down to
5), but we also get many new passing test262 tests in return. :^)
Co-authored-by: Idan Horowitz <idan.horowitz@gmail.com>
2021-07-04 18:14:16 +01:00
|
|
|
if (!existing_prop.has_value())
|
2021-06-23 12:26:37 +02:00
|
|
|
return false;
|
2021-12-29 15:48:11 +01:00
|
|
|
|
|
|
|
// 5. If existingProp.[[Configurable]] is true, return false.
|
LibJS: Rewrite most of Object for spec compliance :^)
This is a huge patch, I know. In hindsight this perhaps could've been
done slightly more incremental, but I started and then fixed everything
until it worked, and here we are. I tried splitting of some completely
unrelated changes into separate commits, however. Anyway.
This is a rewrite of most of Object, and by extension large parts of
Array, Proxy, Reflect, String, TypedArray, and some other things.
What we already had worked fine for about 90% of things, but getting the
last 10% right proved to be increasingly difficult with the current code
that sort of grew organically and is only very loosely based on the
spec - this became especially obvious when we started fixing a large
number of test262 failures.
Key changes include:
- 1:1 matching function names and parameters of all object-related
functions, to avoid ambiguity. Previously we had things like put(),
which the spec doesn't have - as a result it wasn't always clear which
need to be used.
- Better separation between object abstract operations and internal
methods - the former are always the same, the latter can be overridden
(and are therefore virtual). The internal methods (i.e. [[Foo]] in the
spec) are now prefixed with 'internal_' for clarity - again, it was
previously not always clear which AO a certain method represents,
get() could've been both Get and [[Get]] (I don't know which one it
was closer to right now).
Note that some of the old names have been kept until all code relying
on them is updated, but they are now simple wrappers around the
closest matching standard abstract operation.
- Simplifications of the storage layer: functions that write values to
storage are now prefixed with 'storage_' to make their purpose clear,
and as they are not part of the spec they should not contain any steps
specified by it. Much functionality is now covered by the layers above
it and was removed (e.g. handling of accessors, attribute checks).
- PropertyAttributes has been greatly simplified, and is being replaced
by PropertyDescriptor - a concept similar to the current
implementation, but more aligned with the actual spec. See the commit
message of the previous commit where it was introduced for details.
- As a bonus, and since I had to look at the spec a whole lot anyway, I
introduced more inline comments with the exact steps from the spec -
this makes it super easy to verify correctness.
- East-const all the things.
As a result of all of this, things are much more correct but a bit
slower now. Retaining speed wasn't a consideration at all, I have done
no profiling of the new code - there might be low hanging fruits, which
we can then harvest separately.
Special thanks to Idan for helping me with this by tracking down bugs,
updating everything outside of LibJS to work with these changes (LibWeb,
Spreadsheet, HackStudio), as well as providing countless patches to fix
regressions I introduced - there still are very few (we got it down to
5), but we also get many new passing test262 tests in return. :^)
Co-authored-by: Idan Horowitz <idan.horowitz@gmail.com>
2021-07-04 18:14:16 +01:00
|
|
|
if (*existing_prop->configurable)
|
2021-06-23 12:26:37 +02:00
|
|
|
return false;
|
2021-12-29 15:48:11 +01:00
|
|
|
|
|
|
|
// 6. Return true.
|
2021-06-23 12:26:37 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-06-23 13:25:57 +02:00
|
|
|
// 9.1.1.4.15 CanDeclareGlobalVar ( N ), https://tc39.es/ecma262/#sec-candeclareglobalvar
|
2021-07-01 12:24:46 +02:00
|
|
|
bool GlobalEnvironment::can_declare_global_var(FlyString const& name) const
|
2021-06-23 12:26:37 +02:00
|
|
|
{
|
2021-12-29 15:48:11 +01:00
|
|
|
// 1. Let ObjRec be envRec.[[ObjectRecord]].
|
|
|
|
// 2. Let globalObject be ObjRec.[[BindingObject]].
|
LibJS: Rewrite most of Object for spec compliance :^)
This is a huge patch, I know. In hindsight this perhaps could've been
done slightly more incremental, but I started and then fixed everything
until it worked, and here we are. I tried splitting of some completely
unrelated changes into separate commits, however. Anyway.
This is a rewrite of most of Object, and by extension large parts of
Array, Proxy, Reflect, String, TypedArray, and some other things.
What we already had worked fine for about 90% of things, but getting the
last 10% right proved to be increasingly difficult with the current code
that sort of grew organically and is only very loosely based on the
spec - this became especially obvious when we started fixing a large
number of test262 failures.
Key changes include:
- 1:1 matching function names and parameters of all object-related
functions, to avoid ambiguity. Previously we had things like put(),
which the spec doesn't have - as a result it wasn't always clear which
need to be used.
- Better separation between object abstract operations and internal
methods - the former are always the same, the latter can be overridden
(and are therefore virtual). The internal methods (i.e. [[Foo]] in the
spec) are now prefixed with 'internal_' for clarity - again, it was
previously not always clear which AO a certain method represents,
get() could've been both Get and [[Get]] (I don't know which one it
was closer to right now).
Note that some of the old names have been kept until all code relying
on them is updated, but they are now simple wrappers around the
closest matching standard abstract operation.
- Simplifications of the storage layer: functions that write values to
storage are now prefixed with 'storage_' to make their purpose clear,
and as they are not part of the spec they should not contain any steps
specified by it. Much functionality is now covered by the layers above
it and was removed (e.g. handling of accessors, attribute checks).
- PropertyAttributes has been greatly simplified, and is being replaced
by PropertyDescriptor - a concept similar to the current
implementation, but more aligned with the actual spec. See the commit
message of the previous commit where it was introduced for details.
- As a bonus, and since I had to look at the spec a whole lot anyway, I
introduced more inline comments with the exact steps from the spec -
this makes it super easy to verify correctness.
- East-const all the things.
As a result of all of this, things are much more correct but a bit
slower now. Retaining speed wasn't a consideration at all, I have done
no profiling of the new code - there might be low hanging fruits, which
we can then harvest separately.
Special thanks to Idan for helping me with this by tracking down bugs,
updating everything outside of LibJS to work with these changes (LibWeb,
Spreadsheet, HackStudio), as well as providing countless patches to fix
regressions I introduced - there still are very few (we got it down to
5), but we also get many new passing test262 tests in return. :^)
Co-authored-by: Idan Horowitz <idan.horowitz@gmail.com>
2021-07-04 18:14:16 +01:00
|
|
|
auto& global_object = m_object_record->binding_object();
|
2021-12-29 15:48:11 +01:00
|
|
|
|
|
|
|
// 3. Let hasProperty be ? HasOwnProperty(globalObject, N).
|
2021-10-03 02:17:33 +01:00
|
|
|
bool has_property = TRY_OR_DISCARD(global_object.has_own_property(name));
|
2021-12-29 15:48:11 +01:00
|
|
|
|
|
|
|
// 4. If hasProperty is true, return true.
|
2021-06-23 12:26:37 +02:00
|
|
|
if (has_property)
|
|
|
|
return true;
|
2021-12-29 15:48:11 +01:00
|
|
|
|
|
|
|
// 5. Return ? IsExtensible(globalObject).
|
2021-10-02 15:27:37 +01:00
|
|
|
return TRY_OR_DISCARD(global_object.is_extensible());
|
2021-06-23 12:26:37 +02:00
|
|
|
}
|
|
|
|
|
2021-06-23 13:25:57 +02:00
|
|
|
// 9.1.1.4.16 CanDeclareGlobalFunction ( N ), https://tc39.es/ecma262/#sec-candeclareglobalfunction
|
2021-07-01 12:24:46 +02:00
|
|
|
bool GlobalEnvironment::can_declare_global_function(FlyString const& name) const
|
2021-06-23 12:26:37 +02:00
|
|
|
{
|
2021-12-29 15:48:11 +01:00
|
|
|
// 1. Let ObjRec be envRec.[[ObjectRecord]].
|
|
|
|
// 2. Let globalObject be ObjRec.[[BindingObject]].
|
LibJS: Rewrite most of Object for spec compliance :^)
This is a huge patch, I know. In hindsight this perhaps could've been
done slightly more incremental, but I started and then fixed everything
until it worked, and here we are. I tried splitting of some completely
unrelated changes into separate commits, however. Anyway.
This is a rewrite of most of Object, and by extension large parts of
Array, Proxy, Reflect, String, TypedArray, and some other things.
What we already had worked fine for about 90% of things, but getting the
last 10% right proved to be increasingly difficult with the current code
that sort of grew organically and is only very loosely based on the
spec - this became especially obvious when we started fixing a large
number of test262 failures.
Key changes include:
- 1:1 matching function names and parameters of all object-related
functions, to avoid ambiguity. Previously we had things like put(),
which the spec doesn't have - as a result it wasn't always clear which
need to be used.
- Better separation between object abstract operations and internal
methods - the former are always the same, the latter can be overridden
(and are therefore virtual). The internal methods (i.e. [[Foo]] in the
spec) are now prefixed with 'internal_' for clarity - again, it was
previously not always clear which AO a certain method represents,
get() could've been both Get and [[Get]] (I don't know which one it
was closer to right now).
Note that some of the old names have been kept until all code relying
on them is updated, but they are now simple wrappers around the
closest matching standard abstract operation.
- Simplifications of the storage layer: functions that write values to
storage are now prefixed with 'storage_' to make their purpose clear,
and as they are not part of the spec they should not contain any steps
specified by it. Much functionality is now covered by the layers above
it and was removed (e.g. handling of accessors, attribute checks).
- PropertyAttributes has been greatly simplified, and is being replaced
by PropertyDescriptor - a concept similar to the current
implementation, but more aligned with the actual spec. See the commit
message of the previous commit where it was introduced for details.
- As a bonus, and since I had to look at the spec a whole lot anyway, I
introduced more inline comments with the exact steps from the spec -
this makes it super easy to verify correctness.
- East-const all the things.
As a result of all of this, things are much more correct but a bit
slower now. Retaining speed wasn't a consideration at all, I have done
no profiling of the new code - there might be low hanging fruits, which
we can then harvest separately.
Special thanks to Idan for helping me with this by tracking down bugs,
updating everything outside of LibJS to work with these changes (LibWeb,
Spreadsheet, HackStudio), as well as providing countless patches to fix
regressions I introduced - there still are very few (we got it down to
5), but we also get many new passing test262 tests in return. :^)
Co-authored-by: Idan Horowitz <idan.horowitz@gmail.com>
2021-07-04 18:14:16 +01:00
|
|
|
auto& global_object = m_object_record->binding_object();
|
2021-12-29 15:48:11 +01:00
|
|
|
|
|
|
|
// 3. Let existingProp be ? globalObject.[[GetOwnProperty]](N).
|
2021-09-29 17:53:57 +01:00
|
|
|
auto existing_prop = TRY_OR_DISCARD(global_object.internal_get_own_property(name));
|
2021-12-29 15:48:11 +01:00
|
|
|
|
|
|
|
// 4. If existingProp is undefined, return ? IsExtensible(globalObject).
|
LibJS: Rewrite most of Object for spec compliance :^)
This is a huge patch, I know. In hindsight this perhaps could've been
done slightly more incremental, but I started and then fixed everything
until it worked, and here we are. I tried splitting of some completely
unrelated changes into separate commits, however. Anyway.
This is a rewrite of most of Object, and by extension large parts of
Array, Proxy, Reflect, String, TypedArray, and some other things.
What we already had worked fine for about 90% of things, but getting the
last 10% right proved to be increasingly difficult with the current code
that sort of grew organically and is only very loosely based on the
spec - this became especially obvious when we started fixing a large
number of test262 failures.
Key changes include:
- 1:1 matching function names and parameters of all object-related
functions, to avoid ambiguity. Previously we had things like put(),
which the spec doesn't have - as a result it wasn't always clear which
need to be used.
- Better separation between object abstract operations and internal
methods - the former are always the same, the latter can be overridden
(and are therefore virtual). The internal methods (i.e. [[Foo]] in the
spec) are now prefixed with 'internal_' for clarity - again, it was
previously not always clear which AO a certain method represents,
get() could've been both Get and [[Get]] (I don't know which one it
was closer to right now).
Note that some of the old names have been kept until all code relying
on them is updated, but they are now simple wrappers around the
closest matching standard abstract operation.
- Simplifications of the storage layer: functions that write values to
storage are now prefixed with 'storage_' to make their purpose clear,
and as they are not part of the spec they should not contain any steps
specified by it. Much functionality is now covered by the layers above
it and was removed (e.g. handling of accessors, attribute checks).
- PropertyAttributes has been greatly simplified, and is being replaced
by PropertyDescriptor - a concept similar to the current
implementation, but more aligned with the actual spec. See the commit
message of the previous commit where it was introduced for details.
- As a bonus, and since I had to look at the spec a whole lot anyway, I
introduced more inline comments with the exact steps from the spec -
this makes it super easy to verify correctness.
- East-const all the things.
As a result of all of this, things are much more correct but a bit
slower now. Retaining speed wasn't a consideration at all, I have done
no profiling of the new code - there might be low hanging fruits, which
we can then harvest separately.
Special thanks to Idan for helping me with this by tracking down bugs,
updating everything outside of LibJS to work with these changes (LibWeb,
Spreadsheet, HackStudio), as well as providing countless patches to fix
regressions I introduced - there still are very few (we got it down to
5), but we also get many new passing test262 tests in return. :^)
Co-authored-by: Idan Horowitz <idan.horowitz@gmail.com>
2021-07-04 18:14:16 +01:00
|
|
|
if (!existing_prop.has_value())
|
2021-10-02 15:27:37 +01:00
|
|
|
return TRY_OR_DISCARD(global_object.is_extensible());
|
2021-12-29 15:48:11 +01:00
|
|
|
|
|
|
|
// 5. If existingProp.[[Configurable]] is true, return true.
|
LibJS: Rewrite most of Object for spec compliance :^)
This is a huge patch, I know. In hindsight this perhaps could've been
done slightly more incremental, but I started and then fixed everything
until it worked, and here we are. I tried splitting of some completely
unrelated changes into separate commits, however. Anyway.
This is a rewrite of most of Object, and by extension large parts of
Array, Proxy, Reflect, String, TypedArray, and some other things.
What we already had worked fine for about 90% of things, but getting the
last 10% right proved to be increasingly difficult with the current code
that sort of grew organically and is only very loosely based on the
spec - this became especially obvious when we started fixing a large
number of test262 failures.
Key changes include:
- 1:1 matching function names and parameters of all object-related
functions, to avoid ambiguity. Previously we had things like put(),
which the spec doesn't have - as a result it wasn't always clear which
need to be used.
- Better separation between object abstract operations and internal
methods - the former are always the same, the latter can be overridden
(and are therefore virtual). The internal methods (i.e. [[Foo]] in the
spec) are now prefixed with 'internal_' for clarity - again, it was
previously not always clear which AO a certain method represents,
get() could've been both Get and [[Get]] (I don't know which one it
was closer to right now).
Note that some of the old names have been kept until all code relying
on them is updated, but they are now simple wrappers around the
closest matching standard abstract operation.
- Simplifications of the storage layer: functions that write values to
storage are now prefixed with 'storage_' to make their purpose clear,
and as they are not part of the spec they should not contain any steps
specified by it. Much functionality is now covered by the layers above
it and was removed (e.g. handling of accessors, attribute checks).
- PropertyAttributes has been greatly simplified, and is being replaced
by PropertyDescriptor - a concept similar to the current
implementation, but more aligned with the actual spec. See the commit
message of the previous commit where it was introduced for details.
- As a bonus, and since I had to look at the spec a whole lot anyway, I
introduced more inline comments with the exact steps from the spec -
this makes it super easy to verify correctness.
- East-const all the things.
As a result of all of this, things are much more correct but a bit
slower now. Retaining speed wasn't a consideration at all, I have done
no profiling of the new code - there might be low hanging fruits, which
we can then harvest separately.
Special thanks to Idan for helping me with this by tracking down bugs,
updating everything outside of LibJS to work with these changes (LibWeb,
Spreadsheet, HackStudio), as well as providing countless patches to fix
regressions I introduced - there still are very few (we got it down to
5), but we also get many new passing test262 tests in return. :^)
Co-authored-by: Idan Horowitz <idan.horowitz@gmail.com>
2021-07-04 18:14:16 +01:00
|
|
|
if (*existing_prop->configurable)
|
2021-06-23 12:26:37 +02:00
|
|
|
return true;
|
2021-12-29 15:48:11 +01:00
|
|
|
|
|
|
|
// 6. If IsDataDescriptor(existingProp) is true and existingProp has attribute values { [[Writable]]: true, [[Enumerable]]: true }, return true.
|
LibJS: Rewrite most of Object for spec compliance :^)
This is a huge patch, I know. In hindsight this perhaps could've been
done slightly more incremental, but I started and then fixed everything
until it worked, and here we are. I tried splitting of some completely
unrelated changes into separate commits, however. Anyway.
This is a rewrite of most of Object, and by extension large parts of
Array, Proxy, Reflect, String, TypedArray, and some other things.
What we already had worked fine for about 90% of things, but getting the
last 10% right proved to be increasingly difficult with the current code
that sort of grew organically and is only very loosely based on the
spec - this became especially obvious when we started fixing a large
number of test262 failures.
Key changes include:
- 1:1 matching function names and parameters of all object-related
functions, to avoid ambiguity. Previously we had things like put(),
which the spec doesn't have - as a result it wasn't always clear which
need to be used.
- Better separation between object abstract operations and internal
methods - the former are always the same, the latter can be overridden
(and are therefore virtual). The internal methods (i.e. [[Foo]] in the
spec) are now prefixed with 'internal_' for clarity - again, it was
previously not always clear which AO a certain method represents,
get() could've been both Get and [[Get]] (I don't know which one it
was closer to right now).
Note that some of the old names have been kept until all code relying
on them is updated, but they are now simple wrappers around the
closest matching standard abstract operation.
- Simplifications of the storage layer: functions that write values to
storage are now prefixed with 'storage_' to make their purpose clear,
and as they are not part of the spec they should not contain any steps
specified by it. Much functionality is now covered by the layers above
it and was removed (e.g. handling of accessors, attribute checks).
- PropertyAttributes has been greatly simplified, and is being replaced
by PropertyDescriptor - a concept similar to the current
implementation, but more aligned with the actual spec. See the commit
message of the previous commit where it was introduced for details.
- As a bonus, and since I had to look at the spec a whole lot anyway, I
introduced more inline comments with the exact steps from the spec -
this makes it super easy to verify correctness.
- East-const all the things.
As a result of all of this, things are much more correct but a bit
slower now. Retaining speed wasn't a consideration at all, I have done
no profiling of the new code - there might be low hanging fruits, which
we can then harvest separately.
Special thanks to Idan for helping me with this by tracking down bugs,
updating everything outside of LibJS to work with these changes (LibWeb,
Spreadsheet, HackStudio), as well as providing countless patches to fix
regressions I introduced - there still are very few (we got it down to
5), but we also get many new passing test262 tests in return. :^)
Co-authored-by: Idan Horowitz <idan.horowitz@gmail.com>
2021-07-04 18:14:16 +01:00
|
|
|
if (existing_prop->is_data_descriptor() && *existing_prop->writable && *existing_prop->enumerable)
|
2021-06-23 12:26:37 +02:00
|
|
|
return true;
|
2021-12-29 15:48:11 +01:00
|
|
|
|
|
|
|
// 7. Return false.
|
2021-06-23 12:26:37 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-06-23 13:25:57 +02:00
|
|
|
// 9.1.1.4.17 CreateGlobalVarBinding ( N, D ), https://tc39.es/ecma262/#sec-createglobalvarbinding
|
2021-07-01 12:24:46 +02:00
|
|
|
void GlobalEnvironment::create_global_var_binding(FlyString const& name, bool can_be_deleted)
|
2021-06-23 12:26:37 +02:00
|
|
|
{
|
2021-12-29 15:48:11 +01:00
|
|
|
// 1. Let ObjRec be envRec.[[ObjectRecord]].
|
|
|
|
// 2. Let globalObject be ObjRec.[[BindingObject]].
|
LibJS: Rewrite most of Object for spec compliance :^)
This is a huge patch, I know. In hindsight this perhaps could've been
done slightly more incremental, but I started and then fixed everything
until it worked, and here we are. I tried splitting of some completely
unrelated changes into separate commits, however. Anyway.
This is a rewrite of most of Object, and by extension large parts of
Array, Proxy, Reflect, String, TypedArray, and some other things.
What we already had worked fine for about 90% of things, but getting the
last 10% right proved to be increasingly difficult with the current code
that sort of grew organically and is only very loosely based on the
spec - this became especially obvious when we started fixing a large
number of test262 failures.
Key changes include:
- 1:1 matching function names and parameters of all object-related
functions, to avoid ambiguity. Previously we had things like put(),
which the spec doesn't have - as a result it wasn't always clear which
need to be used.
- Better separation between object abstract operations and internal
methods - the former are always the same, the latter can be overridden
(and are therefore virtual). The internal methods (i.e. [[Foo]] in the
spec) are now prefixed with 'internal_' for clarity - again, it was
previously not always clear which AO a certain method represents,
get() could've been both Get and [[Get]] (I don't know which one it
was closer to right now).
Note that some of the old names have been kept until all code relying
on them is updated, but they are now simple wrappers around the
closest matching standard abstract operation.
- Simplifications of the storage layer: functions that write values to
storage are now prefixed with 'storage_' to make their purpose clear,
and as they are not part of the spec they should not contain any steps
specified by it. Much functionality is now covered by the layers above
it and was removed (e.g. handling of accessors, attribute checks).
- PropertyAttributes has been greatly simplified, and is being replaced
by PropertyDescriptor - a concept similar to the current
implementation, but more aligned with the actual spec. See the commit
message of the previous commit where it was introduced for details.
- As a bonus, and since I had to look at the spec a whole lot anyway, I
introduced more inline comments with the exact steps from the spec -
this makes it super easy to verify correctness.
- East-const all the things.
As a result of all of this, things are much more correct but a bit
slower now. Retaining speed wasn't a consideration at all, I have done
no profiling of the new code - there might be low hanging fruits, which
we can then harvest separately.
Special thanks to Idan for helping me with this by tracking down bugs,
updating everything outside of LibJS to work with these changes (LibWeb,
Spreadsheet, HackStudio), as well as providing countless patches to fix
regressions I introduced - there still are very few (we got it down to
5), but we also get many new passing test262 tests in return. :^)
Co-authored-by: Idan Horowitz <idan.horowitz@gmail.com>
2021-07-04 18:14:16 +01:00
|
|
|
auto& global_object = m_object_record->binding_object();
|
2021-12-29 15:48:11 +01:00
|
|
|
|
|
|
|
// 3. Let hasProperty be ? HasOwnProperty(globalObject, N).
|
2021-10-03 02:17:33 +01:00
|
|
|
auto has_property_or_error = global_object.has_own_property(name);
|
|
|
|
if (has_property_or_error.is_error())
|
LibJS: Rewrite most of Object for spec compliance :^)
This is a huge patch, I know. In hindsight this perhaps could've been
done slightly more incremental, but I started and then fixed everything
until it worked, and here we are. I tried splitting of some completely
unrelated changes into separate commits, however. Anyway.
This is a rewrite of most of Object, and by extension large parts of
Array, Proxy, Reflect, String, TypedArray, and some other things.
What we already had worked fine for about 90% of things, but getting the
last 10% right proved to be increasingly difficult with the current code
that sort of grew organically and is only very loosely based on the
spec - this became especially obvious when we started fixing a large
number of test262 failures.
Key changes include:
- 1:1 matching function names and parameters of all object-related
functions, to avoid ambiguity. Previously we had things like put(),
which the spec doesn't have - as a result it wasn't always clear which
need to be used.
- Better separation between object abstract operations and internal
methods - the former are always the same, the latter can be overridden
(and are therefore virtual). The internal methods (i.e. [[Foo]] in the
spec) are now prefixed with 'internal_' for clarity - again, it was
previously not always clear which AO a certain method represents,
get() could've been both Get and [[Get]] (I don't know which one it
was closer to right now).
Note that some of the old names have been kept until all code relying
on them is updated, but they are now simple wrappers around the
closest matching standard abstract operation.
- Simplifications of the storage layer: functions that write values to
storage are now prefixed with 'storage_' to make their purpose clear,
and as they are not part of the spec they should not contain any steps
specified by it. Much functionality is now covered by the layers above
it and was removed (e.g. handling of accessors, attribute checks).
- PropertyAttributes has been greatly simplified, and is being replaced
by PropertyDescriptor - a concept similar to the current
implementation, but more aligned with the actual spec. See the commit
message of the previous commit where it was introduced for details.
- As a bonus, and since I had to look at the spec a whole lot anyway, I
introduced more inline comments with the exact steps from the spec -
this makes it super easy to verify correctness.
- East-const all the things.
As a result of all of this, things are much more correct but a bit
slower now. Retaining speed wasn't a consideration at all, I have done
no profiling of the new code - there might be low hanging fruits, which
we can then harvest separately.
Special thanks to Idan for helping me with this by tracking down bugs,
updating everything outside of LibJS to work with these changes (LibWeb,
Spreadsheet, HackStudio), as well as providing countless patches to fix
regressions I introduced - there still are very few (we got it down to
5), but we also get many new passing test262 tests in return. :^)
Co-authored-by: Idan Horowitz <idan.horowitz@gmail.com>
2021-07-04 18:14:16 +01:00
|
|
|
return;
|
2021-10-03 02:17:33 +01:00
|
|
|
auto has_property = has_property_or_error.release_value();
|
2021-12-29 15:48:11 +01:00
|
|
|
|
|
|
|
// 4. Let extensible be ? IsExtensible(globalObject).
|
2021-10-02 15:27:37 +01:00
|
|
|
auto extensible_or_error = global_object.is_extensible();
|
|
|
|
if (extensible_or_error.is_error())
|
LibJS: Rewrite most of Object for spec compliance :^)
This is a huge patch, I know. In hindsight this perhaps could've been
done slightly more incremental, but I started and then fixed everything
until it worked, and here we are. I tried splitting of some completely
unrelated changes into separate commits, however. Anyway.
This is a rewrite of most of Object, and by extension large parts of
Array, Proxy, Reflect, String, TypedArray, and some other things.
What we already had worked fine for about 90% of things, but getting the
last 10% right proved to be increasingly difficult with the current code
that sort of grew organically and is only very loosely based on the
spec - this became especially obvious when we started fixing a large
number of test262 failures.
Key changes include:
- 1:1 matching function names and parameters of all object-related
functions, to avoid ambiguity. Previously we had things like put(),
which the spec doesn't have - as a result it wasn't always clear which
need to be used.
- Better separation between object abstract operations and internal
methods - the former are always the same, the latter can be overridden
(and are therefore virtual). The internal methods (i.e. [[Foo]] in the
spec) are now prefixed with 'internal_' for clarity - again, it was
previously not always clear which AO a certain method represents,
get() could've been both Get and [[Get]] (I don't know which one it
was closer to right now).
Note that some of the old names have been kept until all code relying
on them is updated, but they are now simple wrappers around the
closest matching standard abstract operation.
- Simplifications of the storage layer: functions that write values to
storage are now prefixed with 'storage_' to make their purpose clear,
and as they are not part of the spec they should not contain any steps
specified by it. Much functionality is now covered by the layers above
it and was removed (e.g. handling of accessors, attribute checks).
- PropertyAttributes has been greatly simplified, and is being replaced
by PropertyDescriptor - a concept similar to the current
implementation, but more aligned with the actual spec. See the commit
message of the previous commit where it was introduced for details.
- As a bonus, and since I had to look at the spec a whole lot anyway, I
introduced more inline comments with the exact steps from the spec -
this makes it super easy to verify correctness.
- East-const all the things.
As a result of all of this, things are much more correct but a bit
slower now. Retaining speed wasn't a consideration at all, I have done
no profiling of the new code - there might be low hanging fruits, which
we can then harvest separately.
Special thanks to Idan for helping me with this by tracking down bugs,
updating everything outside of LibJS to work with these changes (LibWeb,
Spreadsheet, HackStudio), as well as providing countless patches to fix
regressions I introduced - there still are very few (we got it down to
5), but we also get many new passing test262 tests in return. :^)
Co-authored-by: Idan Horowitz <idan.horowitz@gmail.com>
2021-07-04 18:14:16 +01:00
|
|
|
return;
|
2021-10-02 15:27:37 +01:00
|
|
|
auto extensible = extensible_or_error.release_value();
|
2021-12-29 15:48:11 +01:00
|
|
|
|
|
|
|
// 5. If hasProperty is false and extensible is true, then
|
2021-06-23 12:26:37 +02:00
|
|
|
if (!has_property && extensible) {
|
2021-12-29 15:48:11 +01:00
|
|
|
// a. Perform ? ObjRec.CreateMutableBinding(N, D).
|
2021-10-09 18:53:25 +01:00
|
|
|
auto result = m_object_record->create_mutable_binding(m_object_record->global_object(), name, can_be_deleted);
|
|
|
|
if (result.is_error())
|
LibJS: Rewrite most of Object for spec compliance :^)
This is a huge patch, I know. In hindsight this perhaps could've been
done slightly more incremental, but I started and then fixed everything
until it worked, and here we are. I tried splitting of some completely
unrelated changes into separate commits, however. Anyway.
This is a rewrite of most of Object, and by extension large parts of
Array, Proxy, Reflect, String, TypedArray, and some other things.
What we already had worked fine for about 90% of things, but getting the
last 10% right proved to be increasingly difficult with the current code
that sort of grew organically and is only very loosely based on the
spec - this became especially obvious when we started fixing a large
number of test262 failures.
Key changes include:
- 1:1 matching function names and parameters of all object-related
functions, to avoid ambiguity. Previously we had things like put(),
which the spec doesn't have - as a result it wasn't always clear which
need to be used.
- Better separation between object abstract operations and internal
methods - the former are always the same, the latter can be overridden
(and are therefore virtual). The internal methods (i.e. [[Foo]] in the
spec) are now prefixed with 'internal_' for clarity - again, it was
previously not always clear which AO a certain method represents,
get() could've been both Get and [[Get]] (I don't know which one it
was closer to right now).
Note that some of the old names have been kept until all code relying
on them is updated, but they are now simple wrappers around the
closest matching standard abstract operation.
- Simplifications of the storage layer: functions that write values to
storage are now prefixed with 'storage_' to make their purpose clear,
and as they are not part of the spec they should not contain any steps
specified by it. Much functionality is now covered by the layers above
it and was removed (e.g. handling of accessors, attribute checks).
- PropertyAttributes has been greatly simplified, and is being replaced
by PropertyDescriptor - a concept similar to the current
implementation, but more aligned with the actual spec. See the commit
message of the previous commit where it was introduced for details.
- As a bonus, and since I had to look at the spec a whole lot anyway, I
introduced more inline comments with the exact steps from the spec -
this makes it super easy to verify correctness.
- East-const all the things.
As a result of all of this, things are much more correct but a bit
slower now. Retaining speed wasn't a consideration at all, I have done
no profiling of the new code - there might be low hanging fruits, which
we can then harvest separately.
Special thanks to Idan for helping me with this by tracking down bugs,
updating everything outside of LibJS to work with these changes (LibWeb,
Spreadsheet, HackStudio), as well as providing countless patches to fix
regressions I introduced - there still are very few (we got it down to
5), but we also get many new passing test262 tests in return. :^)
Co-authored-by: Idan Horowitz <idan.horowitz@gmail.com>
2021-07-04 18:14:16 +01:00
|
|
|
return;
|
2021-12-29 15:48:11 +01:00
|
|
|
|
|
|
|
// b. Perform ? ObjRec.InitializeBinding(N, undefined).
|
2021-10-09 19:16:24 +01:00
|
|
|
result = m_object_record->initialize_binding(m_object_record->global_object(), name, js_undefined());
|
|
|
|
if (result.is_error())
|
LibJS: Rewrite most of Object for spec compliance :^)
This is a huge patch, I know. In hindsight this perhaps could've been
done slightly more incremental, but I started and then fixed everything
until it worked, and here we are. I tried splitting of some completely
unrelated changes into separate commits, however. Anyway.
This is a rewrite of most of Object, and by extension large parts of
Array, Proxy, Reflect, String, TypedArray, and some other things.
What we already had worked fine for about 90% of things, but getting the
last 10% right proved to be increasingly difficult with the current code
that sort of grew organically and is only very loosely based on the
spec - this became especially obvious when we started fixing a large
number of test262 failures.
Key changes include:
- 1:1 matching function names and parameters of all object-related
functions, to avoid ambiguity. Previously we had things like put(),
which the spec doesn't have - as a result it wasn't always clear which
need to be used.
- Better separation between object abstract operations and internal
methods - the former are always the same, the latter can be overridden
(and are therefore virtual). The internal methods (i.e. [[Foo]] in the
spec) are now prefixed with 'internal_' for clarity - again, it was
previously not always clear which AO a certain method represents,
get() could've been both Get and [[Get]] (I don't know which one it
was closer to right now).
Note that some of the old names have been kept until all code relying
on them is updated, but they are now simple wrappers around the
closest matching standard abstract operation.
- Simplifications of the storage layer: functions that write values to
storage are now prefixed with 'storage_' to make their purpose clear,
and as they are not part of the spec they should not contain any steps
specified by it. Much functionality is now covered by the layers above
it and was removed (e.g. handling of accessors, attribute checks).
- PropertyAttributes has been greatly simplified, and is being replaced
by PropertyDescriptor - a concept similar to the current
implementation, but more aligned with the actual spec. See the commit
message of the previous commit where it was introduced for details.
- As a bonus, and since I had to look at the spec a whole lot anyway, I
introduced more inline comments with the exact steps from the spec -
this makes it super easy to verify correctness.
- East-const all the things.
As a result of all of this, things are much more correct but a bit
slower now. Retaining speed wasn't a consideration at all, I have done
no profiling of the new code - there might be low hanging fruits, which
we can then harvest separately.
Special thanks to Idan for helping me with this by tracking down bugs,
updating everything outside of LibJS to work with these changes (LibWeb,
Spreadsheet, HackStudio), as well as providing countless patches to fix
regressions I introduced - there still are very few (we got it down to
5), but we also get many new passing test262 tests in return. :^)
Co-authored-by: Idan Horowitz <idan.horowitz@gmail.com>
2021-07-04 18:14:16 +01:00
|
|
|
return;
|
2021-06-23 12:26:37 +02:00
|
|
|
}
|
2021-12-29 15:48:11 +01:00
|
|
|
|
|
|
|
// 6. Let varDeclaredNames be envRec.[[VarNames]].
|
|
|
|
// 7. If varDeclaredNames does not contain N, then
|
|
|
|
if (!m_var_names.contains_slow(name)) {
|
|
|
|
// a. Append N to varDeclaredNames.
|
2021-06-23 12:26:37 +02:00
|
|
|
m_var_names.append(name);
|
2021-12-29 15:48:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// 8. Return NormalCompletion(empty).
|
2021-06-23 12:26:37 +02:00
|
|
|
}
|
|
|
|
|
2021-06-23 13:25:57 +02:00
|
|
|
// 9.1.1.4.18 CreateGlobalFunctionBinding ( N, V, D ), https://tc39.es/ecma262/#sec-createglobalfunctionbinding
|
2021-07-01 12:24:46 +02:00
|
|
|
void GlobalEnvironment::create_global_function_binding(FlyString const& name, Value value, bool can_be_deleted)
|
2021-06-23 12:26:37 +02:00
|
|
|
{
|
2021-12-29 15:48:11 +01:00
|
|
|
// 1. Let ObjRec be envRec.[[ObjectRecord]].
|
|
|
|
// 2. Let globalObject be ObjRec.[[BindingObject]].
|
LibJS: Rewrite most of Object for spec compliance :^)
This is a huge patch, I know. In hindsight this perhaps could've been
done slightly more incremental, but I started and then fixed everything
until it worked, and here we are. I tried splitting of some completely
unrelated changes into separate commits, however. Anyway.
This is a rewrite of most of Object, and by extension large parts of
Array, Proxy, Reflect, String, TypedArray, and some other things.
What we already had worked fine for about 90% of things, but getting the
last 10% right proved to be increasingly difficult with the current code
that sort of grew organically and is only very loosely based on the
spec - this became especially obvious when we started fixing a large
number of test262 failures.
Key changes include:
- 1:1 matching function names and parameters of all object-related
functions, to avoid ambiguity. Previously we had things like put(),
which the spec doesn't have - as a result it wasn't always clear which
need to be used.
- Better separation between object abstract operations and internal
methods - the former are always the same, the latter can be overridden
(and are therefore virtual). The internal methods (i.e. [[Foo]] in the
spec) are now prefixed with 'internal_' for clarity - again, it was
previously not always clear which AO a certain method represents,
get() could've been both Get and [[Get]] (I don't know which one it
was closer to right now).
Note that some of the old names have been kept until all code relying
on them is updated, but they are now simple wrappers around the
closest matching standard abstract operation.
- Simplifications of the storage layer: functions that write values to
storage are now prefixed with 'storage_' to make their purpose clear,
and as they are not part of the spec they should not contain any steps
specified by it. Much functionality is now covered by the layers above
it and was removed (e.g. handling of accessors, attribute checks).
- PropertyAttributes has been greatly simplified, and is being replaced
by PropertyDescriptor - a concept similar to the current
implementation, but more aligned with the actual spec. See the commit
message of the previous commit where it was introduced for details.
- As a bonus, and since I had to look at the spec a whole lot anyway, I
introduced more inline comments with the exact steps from the spec -
this makes it super easy to verify correctness.
- East-const all the things.
As a result of all of this, things are much more correct but a bit
slower now. Retaining speed wasn't a consideration at all, I have done
no profiling of the new code - there might be low hanging fruits, which
we can then harvest separately.
Special thanks to Idan for helping me with this by tracking down bugs,
updating everything outside of LibJS to work with these changes (LibWeb,
Spreadsheet, HackStudio), as well as providing countless patches to fix
regressions I introduced - there still are very few (we got it down to
5), but we also get many new passing test262 tests in return. :^)
Co-authored-by: Idan Horowitz <idan.horowitz@gmail.com>
2021-07-04 18:14:16 +01:00
|
|
|
auto& global_object = m_object_record->binding_object();
|
2021-12-29 15:48:11 +01:00
|
|
|
|
|
|
|
// 3. Let existingProp be ? globalObject.[[GetOwnProperty]](N).
|
2021-09-29 17:53:57 +01:00
|
|
|
auto existing_prop_or_error = global_object.internal_get_own_property(name);
|
|
|
|
if (existing_prop_or_error.is_error())
|
LibJS: Rewrite most of Object for spec compliance :^)
This is a huge patch, I know. In hindsight this perhaps could've been
done slightly more incremental, but I started and then fixed everything
until it worked, and here we are. I tried splitting of some completely
unrelated changes into separate commits, however. Anyway.
This is a rewrite of most of Object, and by extension large parts of
Array, Proxy, Reflect, String, TypedArray, and some other things.
What we already had worked fine for about 90% of things, but getting the
last 10% right proved to be increasingly difficult with the current code
that sort of grew organically and is only very loosely based on the
spec - this became especially obvious when we started fixing a large
number of test262 failures.
Key changes include:
- 1:1 matching function names and parameters of all object-related
functions, to avoid ambiguity. Previously we had things like put(),
which the spec doesn't have - as a result it wasn't always clear which
need to be used.
- Better separation between object abstract operations and internal
methods - the former are always the same, the latter can be overridden
(and are therefore virtual). The internal methods (i.e. [[Foo]] in the
spec) are now prefixed with 'internal_' for clarity - again, it was
previously not always clear which AO a certain method represents,
get() could've been both Get and [[Get]] (I don't know which one it
was closer to right now).
Note that some of the old names have been kept until all code relying
on them is updated, but they are now simple wrappers around the
closest matching standard abstract operation.
- Simplifications of the storage layer: functions that write values to
storage are now prefixed with 'storage_' to make their purpose clear,
and as they are not part of the spec they should not contain any steps
specified by it. Much functionality is now covered by the layers above
it and was removed (e.g. handling of accessors, attribute checks).
- PropertyAttributes has been greatly simplified, and is being replaced
by PropertyDescriptor - a concept similar to the current
implementation, but more aligned with the actual spec. See the commit
message of the previous commit where it was introduced for details.
- As a bonus, and since I had to look at the spec a whole lot anyway, I
introduced more inline comments with the exact steps from the spec -
this makes it super easy to verify correctness.
- East-const all the things.
As a result of all of this, things are much more correct but a bit
slower now. Retaining speed wasn't a consideration at all, I have done
no profiling of the new code - there might be low hanging fruits, which
we can then harvest separately.
Special thanks to Idan for helping me with this by tracking down bugs,
updating everything outside of LibJS to work with these changes (LibWeb,
Spreadsheet, HackStudio), as well as providing countless patches to fix
regressions I introduced - there still are very few (we got it down to
5), but we also get many new passing test262 tests in return. :^)
Co-authored-by: Idan Horowitz <idan.horowitz@gmail.com>
2021-07-04 18:14:16 +01:00
|
|
|
return;
|
2021-09-29 17:53:57 +01:00
|
|
|
auto existing_prop = existing_prop_or_error.release_value();
|
2021-12-29 15:48:11 +01:00
|
|
|
|
2021-06-23 12:26:37 +02:00
|
|
|
PropertyDescriptor desc;
|
2021-12-29 15:48:11 +01:00
|
|
|
|
|
|
|
// 4. If existingProp is undefined or existingProp.[[Configurable]] is true, then
|
|
|
|
if (!existing_prop.has_value() || *existing_prop->configurable) {
|
|
|
|
// a. Let desc be the PropertyDescriptor { [[Value]]: V, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: D }.
|
LibJS: Rewrite most of Object for spec compliance :^)
This is a huge patch, I know. In hindsight this perhaps could've been
done slightly more incremental, but I started and then fixed everything
until it worked, and here we are. I tried splitting of some completely
unrelated changes into separate commits, however. Anyway.
This is a rewrite of most of Object, and by extension large parts of
Array, Proxy, Reflect, String, TypedArray, and some other things.
What we already had worked fine for about 90% of things, but getting the
last 10% right proved to be increasingly difficult with the current code
that sort of grew organically and is only very loosely based on the
spec - this became especially obvious when we started fixing a large
number of test262 failures.
Key changes include:
- 1:1 matching function names and parameters of all object-related
functions, to avoid ambiguity. Previously we had things like put(),
which the spec doesn't have - as a result it wasn't always clear which
need to be used.
- Better separation between object abstract operations and internal
methods - the former are always the same, the latter can be overridden
(and are therefore virtual). The internal methods (i.e. [[Foo]] in the
spec) are now prefixed with 'internal_' for clarity - again, it was
previously not always clear which AO a certain method represents,
get() could've been both Get and [[Get]] (I don't know which one it
was closer to right now).
Note that some of the old names have been kept until all code relying
on them is updated, but they are now simple wrappers around the
closest matching standard abstract operation.
- Simplifications of the storage layer: functions that write values to
storage are now prefixed with 'storage_' to make their purpose clear,
and as they are not part of the spec they should not contain any steps
specified by it. Much functionality is now covered by the layers above
it and was removed (e.g. handling of accessors, attribute checks).
- PropertyAttributes has been greatly simplified, and is being replaced
by PropertyDescriptor - a concept similar to the current
implementation, but more aligned with the actual spec. See the commit
message of the previous commit where it was introduced for details.
- As a bonus, and since I had to look at the spec a whole lot anyway, I
introduced more inline comments with the exact steps from the spec -
this makes it super easy to verify correctness.
- East-const all the things.
As a result of all of this, things are much more correct but a bit
slower now. Retaining speed wasn't a consideration at all, I have done
no profiling of the new code - there might be low hanging fruits, which
we can then harvest separately.
Special thanks to Idan for helping me with this by tracking down bugs,
updating everything outside of LibJS to work with these changes (LibWeb,
Spreadsheet, HackStudio), as well as providing countless patches to fix
regressions I introduced - there still are very few (we got it down to
5), but we also get many new passing test262 tests in return. :^)
Co-authored-by: Idan Horowitz <idan.horowitz@gmail.com>
2021-07-04 18:14:16 +01:00
|
|
|
desc = { .value = value, .writable = true, .enumerable = true, .configurable = can_be_deleted };
|
2021-12-29 15:48:11 +01:00
|
|
|
}
|
|
|
|
// 5. Else,
|
|
|
|
else {
|
|
|
|
// a. Let desc be the PropertyDescriptor { [[Value]]: V }.
|
LibJS: Rewrite most of Object for spec compliance :^)
This is a huge patch, I know. In hindsight this perhaps could've been
done slightly more incremental, but I started and then fixed everything
until it worked, and here we are. I tried splitting of some completely
unrelated changes into separate commits, however. Anyway.
This is a rewrite of most of Object, and by extension large parts of
Array, Proxy, Reflect, String, TypedArray, and some other things.
What we already had worked fine for about 90% of things, but getting the
last 10% right proved to be increasingly difficult with the current code
that sort of grew organically and is only very loosely based on the
spec - this became especially obvious when we started fixing a large
number of test262 failures.
Key changes include:
- 1:1 matching function names and parameters of all object-related
functions, to avoid ambiguity. Previously we had things like put(),
which the spec doesn't have - as a result it wasn't always clear which
need to be used.
- Better separation between object abstract operations and internal
methods - the former are always the same, the latter can be overridden
(and are therefore virtual). The internal methods (i.e. [[Foo]] in the
spec) are now prefixed with 'internal_' for clarity - again, it was
previously not always clear which AO a certain method represents,
get() could've been both Get and [[Get]] (I don't know which one it
was closer to right now).
Note that some of the old names have been kept until all code relying
on them is updated, but they are now simple wrappers around the
closest matching standard abstract operation.
- Simplifications of the storage layer: functions that write values to
storage are now prefixed with 'storage_' to make their purpose clear,
and as they are not part of the spec they should not contain any steps
specified by it. Much functionality is now covered by the layers above
it and was removed (e.g. handling of accessors, attribute checks).
- PropertyAttributes has been greatly simplified, and is being replaced
by PropertyDescriptor - a concept similar to the current
implementation, but more aligned with the actual spec. See the commit
message of the previous commit where it was introduced for details.
- As a bonus, and since I had to look at the spec a whole lot anyway, I
introduced more inline comments with the exact steps from the spec -
this makes it super easy to verify correctness.
- East-const all the things.
As a result of all of this, things are much more correct but a bit
slower now. Retaining speed wasn't a consideration at all, I have done
no profiling of the new code - there might be low hanging fruits, which
we can then harvest separately.
Special thanks to Idan for helping me with this by tracking down bugs,
updating everything outside of LibJS to work with these changes (LibWeb,
Spreadsheet, HackStudio), as well as providing countless patches to fix
regressions I introduced - there still are very few (we got it down to
5), but we also get many new passing test262 tests in return. :^)
Co-authored-by: Idan Horowitz <idan.horowitz@gmail.com>
2021-07-04 18:14:16 +01:00
|
|
|
desc = { .value = value };
|
2021-12-29 15:48:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// 6. Perform ? DefinePropertyOrThrow(globalObject, N, desc).
|
2021-10-03 01:35:36 +01:00
|
|
|
auto result_or_error = global_object.define_property_or_throw(name, desc);
|
|
|
|
if (result_or_error.is_error())
|
LibJS: Rewrite most of Object for spec compliance :^)
This is a huge patch, I know. In hindsight this perhaps could've been
done slightly more incremental, but I started and then fixed everything
until it worked, and here we are. I tried splitting of some completely
unrelated changes into separate commits, however. Anyway.
This is a rewrite of most of Object, and by extension large parts of
Array, Proxy, Reflect, String, TypedArray, and some other things.
What we already had worked fine for about 90% of things, but getting the
last 10% right proved to be increasingly difficult with the current code
that sort of grew organically and is only very loosely based on the
spec - this became especially obvious when we started fixing a large
number of test262 failures.
Key changes include:
- 1:1 matching function names and parameters of all object-related
functions, to avoid ambiguity. Previously we had things like put(),
which the spec doesn't have - as a result it wasn't always clear which
need to be used.
- Better separation between object abstract operations and internal
methods - the former are always the same, the latter can be overridden
(and are therefore virtual). The internal methods (i.e. [[Foo]] in the
spec) are now prefixed with 'internal_' for clarity - again, it was
previously not always clear which AO a certain method represents,
get() could've been both Get and [[Get]] (I don't know which one it
was closer to right now).
Note that some of the old names have been kept until all code relying
on them is updated, but they are now simple wrappers around the
closest matching standard abstract operation.
- Simplifications of the storage layer: functions that write values to
storage are now prefixed with 'storage_' to make their purpose clear,
and as they are not part of the spec they should not contain any steps
specified by it. Much functionality is now covered by the layers above
it and was removed (e.g. handling of accessors, attribute checks).
- PropertyAttributes has been greatly simplified, and is being replaced
by PropertyDescriptor - a concept similar to the current
implementation, but more aligned with the actual spec. See the commit
message of the previous commit where it was introduced for details.
- As a bonus, and since I had to look at the spec a whole lot anyway, I
introduced more inline comments with the exact steps from the spec -
this makes it super easy to verify correctness.
- East-const all the things.
As a result of all of this, things are much more correct but a bit
slower now. Retaining speed wasn't a consideration at all, I have done
no profiling of the new code - there might be low hanging fruits, which
we can then harvest separately.
Special thanks to Idan for helping me with this by tracking down bugs,
updating everything outside of LibJS to work with these changes (LibWeb,
Spreadsheet, HackStudio), as well as providing countless patches to fix
regressions I introduced - there still are very few (we got it down to
5), but we also get many new passing test262 tests in return. :^)
Co-authored-by: Idan Horowitz <idan.horowitz@gmail.com>
2021-07-04 18:14:16 +01:00
|
|
|
return;
|
2021-12-29 15:48:11 +01:00
|
|
|
|
|
|
|
// 7. Perform ? Set(globalObject, N, V, false).
|
2021-10-03 01:35:36 +01:00
|
|
|
result_or_error = global_object.set(name, value, Object::ShouldThrowExceptions::Yes);
|
2021-10-03 00:32:43 +01:00
|
|
|
if (result_or_error.is_error())
|
2021-06-23 12:26:37 +02:00
|
|
|
return;
|
2021-12-29 15:48:11 +01:00
|
|
|
|
|
|
|
// 8. Let varDeclaredNames be envRec.[[VarNames]].
|
|
|
|
// 9. If varDeclaredNames does not contain N, then
|
|
|
|
if (!m_var_names.contains_slow(name)) {
|
|
|
|
// a. Append N to varDeclaredNames.
|
2021-06-23 12:26:37 +02:00
|
|
|
m_var_names.append(name);
|
2021-12-29 15:48:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// 10. Return NormalCompletion(empty).
|
2021-06-23 12:26:37 +02:00
|
|
|
}
|
|
|
|
|
2021-06-22 17:16:08 +02:00
|
|
|
}
|