Constructor.cs 590 B

1234567891011121314151617181920
  1. using Jint.Native.Function;
  2. using Jint.Native.Object;
  3. using Jint.Runtime;
  4. namespace Jint.Native;
  5. public abstract class Constructor : FunctionInstance, IConstructor
  6. {
  7. protected Constructor(Engine engine, Realm realm, JsString name) : base(engine, realm, name)
  8. {
  9. }
  10. protected internal override JsValue Call(JsValue thisObject, JsValue[] arguments)
  11. {
  12. ExceptionHelper.ThrowTypeError(_realm, $"Constructor {_nameDescriptor?.Value} requires 'new'");
  13. return null;
  14. }
  15. public abstract ObjectInstance Construct(JsValue[] arguments, JsValue newTarget);
  16. }