ObjectInstance.Fast.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System.Runtime.CompilerServices;
  2. using Jint.Runtime.Descriptors;
  3. namespace Jint.Native.Object;
  4. /// <summary>
  5. /// Fast access helpers which violate JavaScript specification, but helpful when accessed
  6. /// against ObjectInstance and prototype chain is intact.
  7. /// </summary>
  8. public partial class ObjectInstance
  9. {
  10. /// <summary>
  11. /// Creates data property without checking prototype, property existence and overwrites any data already present.
  12. /// </summary>
  13. /// <remarks>
  14. /// Does not conform to JavaScript specification prototype etc. handling etc.
  15. /// </remarks>
  16. public void FastSetProperty(string name, PropertyDescriptor value)
  17. {
  18. SetProperty(name, value);
  19. }
  20. /// <summary>
  21. /// Creates data property without checking prototype, property existence and overwrites any data already present.
  22. /// </summary>
  23. /// <remarks>
  24. /// Does not conform to JavaScript specification prototype etc. handling etc.
  25. /// </remarks>
  26. public void FastSetProperty(JsValue property, PropertyDescriptor value)
  27. {
  28. SetProperty(property, value);
  29. }
  30. /// <summary>
  31. /// Creates data property (configurable, enumerable, writable) without checking prototype, property existence and overwrites any data already present.
  32. /// </summary>
  33. /// <remarks>
  34. /// Does not conform to JavaScript specification prototype etc. handling etc.
  35. /// </remarks>
  36. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  37. public void FastSetDataProperty(string name, JsValue value)
  38. {
  39. SetProperty(name, new PropertyDescriptor(value, PropertyFlag.ConfigurableEnumerableWritable));
  40. }
  41. }