mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:48:11 +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:
parent
5495f06af5
commit
bdffc9e7fb
9 changed files with 102 additions and 35 deletions
|
@ -64,8 +64,10 @@ Value ObjectConstructor::get_own_property_names(Interpreter& interpreter)
|
|||
if (interpreter.exception())
|
||||
return {};
|
||||
auto* result = interpreter.heap().allocate<Array>();
|
||||
for (size_t i = 0; i < object->elements().size(); ++i)
|
||||
result->push(js_string(interpreter, String::number(i)));
|
||||
for (size_t i = 0; i < object->elements().size(); ++i) {
|
||||
if (!object->elements()[i].is_empty())
|
||||
result->push(js_string(interpreter, String::number(i)));
|
||||
}
|
||||
|
||||
for (auto& it : object->shape().property_table())
|
||||
result->push(js_string(interpreter, it.key));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue