Completion.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System.Runtime.CompilerServices;
  2. using Esprima;
  3. using Jint.Native;
  4. namespace Jint.Runtime
  5. {
  6. public enum CompletionType
  7. {
  8. Normal,
  9. Break,
  10. Continue,
  11. Return,
  12. Throw
  13. }
  14. /// <summary>
  15. /// http://www.ecma-international.org/ecma-262/5.1/#sec-8.9
  16. /// </summary>
  17. public readonly struct Completion
  18. {
  19. public Completion(CompletionType type, JsValue value, string identifier, Location location)
  20. {
  21. Type = type;
  22. Value = value;
  23. Identifier = identifier;
  24. Location = location;
  25. }
  26. public readonly CompletionType Type;
  27. public readonly JsValue Value;
  28. public readonly string Identifier;
  29. public readonly Location Location;
  30. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  31. public JsValue GetValueOrDefault()
  32. {
  33. return Value ?? Undefined.Instance;
  34. }
  35. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  36. public bool IsAbrupt()
  37. {
  38. return Type != CompletionType.Normal;
  39. }
  40. }
  41. }