JintThrowStatement.cs 805 B

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