1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:37:45 +00:00

LibJS: Bring Reference records a bit closer to the ECMAScript spec

Our Reference class now has the same fields as the spec:

- Base (a non-nullish value, an environment record, or `unresolvable`)
- Referenced Name (the name of the binding)
- Strict (whether the reference originated in strict mode code)
- ThisValue (if non-empty, the reference represents a `super` keyword)

The main difference from before is that we now resolve the environment
record that a reference interacts with. Previously we simply resolved
to either "local variable" or "global variable".

The associated abstract operations are still largely non-conforming,
since we don't yet implement proper variable bindings. But this patch
should at least fix a handful of test262 cases. :^)

There's one minor regression: some TypeError message strings get
a little worse due to doing a RequireObjectCoercible earlier in the
evaluation of MemberExpression.
This commit is contained in:
Andreas Kling 2021-06-25 16:27:59 +02:00
parent 6e1932e8b2
commit bce7fdba81
6 changed files with 193 additions and 123 deletions

View file

@ -204,7 +204,7 @@ public:
void assign(const FlyString& target, Value, GlobalObject&, bool first_assignment = false, EnvironmentRecord* specific_scope = nullptr);
void assign(const NonnullRefPtr<BindingPattern>& target, Value, GlobalObject&, bool first_assignment = false, EnvironmentRecord* specific_scope = nullptr);
Reference resolve_binding(FlyString const&);
Reference resolve_binding(GlobalObject&, FlyString const&, EnvironmentRecord* = nullptr);
template<typename T, typename... Args>
void throw_exception(GlobalObject& global_object, Args&&... args)