JintArrowFunctionExpression.cs 883 B

123456789101112131415161718192021222324252627282930
  1. using Esprima.Ast;
  2. using Jint.Native.Function;
  3. namespace Jint.Runtime.Interpreter.Expressions
  4. {
  5. internal sealed class JintArrowFunctionExpression : JintExpression
  6. {
  7. private readonly JintFunctionDefinition _function;
  8. public JintArrowFunctionExpression(Engine engine, IFunction function)
  9. : base(engine, ArrowParameterPlaceHolder.Empty)
  10. {
  11. _function = new JintFunctionDefinition(engine, function);
  12. }
  13. protected override object EvaluateInternal()
  14. {
  15. var scope = _engine.ExecutionContext.LexicalEnvironment;
  16. var closure = new ScriptFunctionInstance(
  17. _engine,
  18. _function,
  19. scope,
  20. FunctionThisMode.Lexical,
  21. proto: _engine.Function.PrototypeObject);
  22. return closure;
  23. }
  24. }
  25. }