mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 18:38:10 +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:
parent
90ba0145f6
commit
be019f28ca
5 changed files with 91 additions and 4 deletions
|
@ -31,6 +31,7 @@
|
|||
#include <LibJS/Forward.h>
|
||||
#include <LibJS/Runtime/Cell.h>
|
||||
#include <LibJS/Runtime/PrimitiveString.h>
|
||||
#include <LibJS/Runtime/PropertyName.h>
|
||||
#include <LibJS/Runtime/Value.h>
|
||||
|
||||
namespace JS {
|
||||
|
@ -45,9 +46,11 @@ public:
|
|||
|
||||
Optional<Value> get_by_index(i32 property_index) const;
|
||||
Optional<Value> get(const FlyString& property_name) const;
|
||||
Optional<Value> get(PropertyName) const;
|
||||
|
||||
void put_by_index(i32 property_index, Value);
|
||||
void put(const FlyString& property_name, Value);
|
||||
void put(PropertyName, Value);
|
||||
|
||||
virtual Optional<Value> get_own_property(const Object& this_object, const FlyString& property_name) const;
|
||||
virtual bool put_own_property(Object& this_object, const FlyString& property_name, Value);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue