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

LibJS: Add a PropertyName class that represents a string or a number

Now that we have two separate storages for Object properties depending
on what kind of index they have, it's nice to have an abstraction that
still allows us to say "here's a property name".

We use PropertyName to always choose the optimal storage path directly
while interpreting the AST. :^)
This commit is contained in:
Andreas Kling 2020-04-06 17:08:23 +02:00
parent 90ba0145f6
commit be019f28ca
5 changed files with 91 additions and 4 deletions

View file

@ -33,6 +33,7 @@
#include <AK/String.h>
#include <AK/Vector.h>
#include <LibJS/Forward.h>
#include <LibJS/Runtime/PropertyName.h>
#include <LibJS/Runtime/Value.h>
namespace JS {
@ -672,7 +673,7 @@ public:
const Expression& object() const { return *m_object; }
const Expression& property() const { return *m_property; }
FlyString computed_property_name(Interpreter&) const;
PropertyName computed_property_name(Interpreter&) const;
private:
virtual bool is_member_expression() const override { return true; }