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

LibJS: Support o.f++ :^)

This patch teaches UpdateExpression how to use a Reference. Some other
changes were necessary to keep tests working:
A Reference can now also refer to a local or global variable. This is
not fully aligned with the spec since we don't have a Record concept.
This commit is contained in:
Andreas Kling 2020-04-28 14:44:48 +02:00
parent ee0bf55127
commit 24cce3674b
5 changed files with 101 additions and 12 deletions

View file

@ -51,6 +51,15 @@ public:
{
}
enum GlobalVariableTag { GlobalVariable };
Reference(GlobalVariableTag, const String& name, bool strict = false)
: m_base(js_null())
, m_name(name)
, m_strict(strict)
, m_global_variable(true)
{
}
Value base() const { return m_base; }
const PropertyName& name() const { return m_name; }
bool is_strict() const { return m_strict; }
@ -71,13 +80,22 @@ public:
return m_local_variable;
}
void assign(Interpreter&, Value);
bool is_global_variable() const
{
return m_global_variable;
}
void put(Interpreter&, Value);
Value get(Interpreter&);
private:
void throw_reference_error(Interpreter&);
Value m_base { js_undefined() };
PropertyName m_name;
bool m_strict { false };
bool m_local_variable { false };
bool m_global_variable { false };
};
const LogStream& operator<<(const LogStream&, const Value&);