diff options
author | Andreas Kling <kling@serenityos.org> | 2020-04-06 17:08:23 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-06 18:09:26 +0200 |
commit | be019f28caa5400db817ef00ac6bd727c7252d0f (patch) | |
tree | 701df2bd5f17d3f5dbe585204f3c871db7ec0000 /Libraries/LibJS/Runtime/Object.h | |
parent | 90ba0145f6baec96bee41d2d0aa63253a42f4101 (diff) | |
download | serenity-be019f28caa5400db817ef00ac6bd727c7252d0f.zip |
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. :^)
Diffstat (limited to 'Libraries/LibJS/Runtime/Object.h')
-rw-r--r-- | Libraries/LibJS/Runtime/Object.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Libraries/LibJS/Runtime/Object.h b/Libraries/LibJS/Runtime/Object.h index 529fdb92cc..8772e6b1e2 100644 --- a/Libraries/LibJS/Runtime/Object.h +++ b/Libraries/LibJS/Runtime/Object.h @@ -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); |