GetterFunction.cs 659 B

123456789101112131415161718192021222324
  1. using Jint.Native;
  2. using Jint.Native.Function;
  3. namespace Jint.Runtime.Interop;
  4. /// <summary>
  5. /// Represents a FunctionInstance wrapping a CLR getter.
  6. /// </summary>
  7. internal sealed class GetterFunction : Function
  8. {
  9. private static readonly JsString _name = new JsString("get");
  10. private readonly Func<JsValue, JsValue> _getter;
  11. public GetterFunction(Engine engine, Func<JsValue, JsValue> getter)
  12. : base(engine, engine.Realm, _name, FunctionThisMode.Global)
  13. {
  14. _getter = getter;
  15. }
  16. protected internal override JsValue Call(JsValue thisObject, JsCallArguments arguments)
  17. {
  18. return _getter(thisObject);
  19. }
  20. }