PropertyAttributes.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright (c) 2021, David Tuin <david.tuin@gmail.com>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include "PropertyAttributes.h"
  7. namespace JS {
  8. PropertyAttributes PropertyAttributes::overwrite(PropertyAttributes attr) const
  9. {
  10. PropertyAttributes combined = m_bits;
  11. if (attr.has_configurable()) {
  12. if (attr.is_configurable()) {
  13. combined.set_configurable();
  14. } else {
  15. combined.m_bits &= ~Attribute::Configurable;
  16. }
  17. combined.set_has_configurable();
  18. }
  19. if (attr.has_enumerable()) {
  20. if (attr.is_enumerable()) {
  21. combined.set_enumerable();
  22. } else {
  23. combined.m_bits &= ~Attribute::Enumerable;
  24. }
  25. combined.set_has_configurable();
  26. }
  27. if (attr.has_writable()) {
  28. if (attr.is_writable()) {
  29. combined.set_writable();
  30. } else {
  31. combined.m_bits &= ~Attribute::Writable;
  32. }
  33. combined.set_has_writable();
  34. }
  35. if (attr.has_getter()) {
  36. combined.set_has_getter();
  37. }
  38. if (attr.has_setter()) {
  39. combined.set_has_setter();
  40. }
  41. return combined;
  42. }
  43. }