1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 19:38:12 +00:00

LibJS: Make put_own_property_by_index closer to spec

Most of the code is taken from put_own_property however the attributes
  need to be handled slightly differently it seems
This commit is contained in:
davidot 2021-06-21 16:55:00 +02:00 committed by Linus Groh
parent a770c26d54
commit 733e8472fa
4 changed files with 117 additions and 14 deletions

View file

@ -0,0 +1,51 @@
/*
* Copyright (c) 2021, David Tuin <david.tuin@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "PropertyAttributes.h"
namespace JS {
PropertyAttributes PropertyAttributes::overwrite(PropertyAttributes attr) const
{
PropertyAttributes combined = m_bits;
if (attr.has_configurable()) {
if (attr.is_configurable()) {
combined.set_configurable();
} else {
combined.m_bits &= ~Attribute::Configurable;
}
combined.set_has_configurable();
}
if (attr.has_enumerable()) {
if (attr.is_enumerable()) {
combined.set_enumerable();
} else {
combined.m_bits &= ~Attribute::Enumerable;
}
combined.set_has_configurable();
}
if (attr.has_writable()) {
if (attr.is_writable()) {
combined.set_writable();
} else {
combined.m_bits &= ~Attribute::Writable;
}
combined.set_has_writable();
}
if (attr.has_getter()) {
combined.set_has_getter();
}
if (attr.has_setter()) {
combined.set_has_setter();
}
return combined;
}
}