JintThrowStatement.cs 730 B

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