EvalFunctionInstance.cs 907 B

12345678910111213141516171819202122232425262728293031
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Jint.Native.Object;
  6. using Jint.Parser;
  7. using Jint.Parser.Ast;
  8. using Jint.Runtime;
  9. using Jint.Runtime.Environments;
  10. namespace Jint.Native.Function
  11. {
  12. public class EvalFunctionInstance: FunctionInstance
  13. {
  14. private readonly Engine _engine;
  15. public EvalFunctionInstance(Engine engine, ObjectInstance prototype, Identifier[] parameters, LexicalEnvironment scope, bool strict) : base(engine, prototype, parameters, scope, strict)
  16. {
  17. _engine = engine;
  18. }
  19. public override object Call(object thisObject, object[] arguments)
  20. {
  21. var code = TypeConverter.ToString(arguments[0]);
  22. var parser = new JavascriptParser();
  23. var program = parser.Parse(code);
  24. return _engine.ExecuteStatement(program);
  25. }
  26. }
  27. }