EnvironmentRecord.cs 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using Jint.Native;
  2. using Jint.Native.Object;
  3. namespace Jint.Runtime.Environments
  4. {
  5. /// <summary>
  6. /// Base implementation of an Environment Record
  7. /// http://www.ecma-international.org/ecma-262/5.1/#sec-10.2.1
  8. /// </summary>
  9. public abstract class EnvironmentRecord : ObjectInstance
  10. {
  11. protected EnvironmentRecord(Engine engine) : base(engine)
  12. {
  13. }
  14. /// <summary>
  15. /// Determines if an environment record has a binding for an identifier.
  16. /// </summary>
  17. /// <param name="name">The identifier of the binding</param>
  18. /// <returns><c>true</c> if it does and <c>false</c> if it does not.</returns>
  19. public abstract bool HasBinding(string name);
  20. /// <summary>
  21. /// Creates a new mutable binding in an environment record.
  22. /// </summary>
  23. /// <param name="name">The identifier of the binding.</param>
  24. /// <param name="canBeDeleted"><c>true</c> if the binding may be subsequently deleted.</param>
  25. public abstract void CreateMutableBinding(string name, bool canBeDeleted = false);
  26. /// <summary>
  27. /// Sets the value of an already existing mutable binding in an environment record.
  28. /// </summary>
  29. /// <param name="name">The identifier of the binding</param>
  30. /// <param name="value">The value of the binding.</param>
  31. /// <param name="strict">The identify strict mode references.</param>
  32. public abstract void SetMutableBinding(string name, JsValue value, bool strict);
  33. /// <summary>
  34. /// Returns the value of an already existing binding from an environment record.
  35. /// </summary>
  36. /// <param name="name">The identifier of the binding</param>
  37. /// <param name="strict">The identify strict mode references.</param>
  38. /// <return>The value of an already existing binding from an environment record.</return>
  39. public abstract JsValue GetBindingValue(string name, bool strict);
  40. /// <summary>
  41. /// Delete a binding from an environment record. The String value N is the text of the bound name If a binding for N exists, remove the binding and return true. If the binding exists but cannot be removed return false. If the binding does not exist return true.
  42. /// </summary>
  43. /// <param name="name">The identifier of the binding</param>
  44. /// <returns><true>true</true> if the deletion is successfull.</returns>
  45. public abstract bool DeleteBinding(string name);
  46. /// <summary>
  47. /// Returns the value to use as the <c>this</c> value on calls to function objects that are obtained as binding values from this environment record.
  48. /// </summary>
  49. /// <returns>The value to use as <c>this</c>.</returns>
  50. public abstract JsValue ImplicitThisValue();
  51. /// <summary>
  52. /// Returns an array of all the defined binding names
  53. /// </summary>
  54. /// <returns>The array of all defined bindings</returns>
  55. public abstract string[] GetAllBindingNames();
  56. }
  57. }