JintThrowStatement.cs 824 B

123456789101112131415161718192021222324252627
  1. using Esprima.Ast;
  2. using Jint.Runtime.Interpreter.Expressions;
  3. namespace Jint.Runtime.Interpreter.Statements
  4. {
  5. /// <summary>
  6. /// http://www.ecma-international.org/ecma-262/5.1/#sec-12.13
  7. /// </summary>
  8. internal sealed class JintThrowStatement : JintStatement<ThrowStatement>
  9. {
  10. private JintExpression _argument = null!;
  11. public JintThrowStatement(ThrowStatement statement) : base(statement)
  12. {
  13. }
  14. protected override void Initialize(EvaluationContext context)
  15. {
  16. _argument = JintExpression.Build(_statement.Argument);
  17. }
  18. protected override Completion ExecuteInternal(EvaluationContext context)
  19. {
  20. return new Completion(CompletionType.Throw, _argument.GetValue(context), _argument._expression);
  21. }
  22. }
  23. }