1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 12:35:08 +00:00

LibJS: Support array holes, encoded as empty JS::Value

This patch adds a new kind of JS::Value, the empty value.
It's what you get when you do JSValue() (or most commonly, {} in C++.)

An empty Value signifies the absence of a value, and should never be
visible to JavaScript itself. As of right now, it's used for array
holes and as a return value when an exception has been thrown and we
just want to unwind.

This patch is a bit of a mess as I had to fix a whole bunch of code
that was relying on JSValue() being undefined, etc.
This commit is contained in:
Andreas Kling 2020-04-06 20:24:45 +02:00
parent 5495f06af5
commit bdffc9e7fb
9 changed files with 102 additions and 35 deletions

View file

@ -69,7 +69,7 @@ Value Interpreter::run(const Statement& statement, ArgumentVector arguments, Sco
auto& block = static_cast<const ScopeNode&>(statement);
enter_scope(block, move(arguments), scope_type);
m_last_value = {};
m_last_value = js_undefined();
for (auto& node : block.children()) {
m_last_value = node.execute(*this);
if (m_unwind_until != ScopeType::None)