DebugInformation.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System;
  2. using Esprima;
  3. using Esprima.Ast;
  4. using Jint.Native;
  5. namespace Jint.Runtime.Debugger
  6. {
  7. public sealed class DebugInformation : EventArgs
  8. {
  9. internal DebugInformation(Statement currentStatement, DebugCallStack callStack, long currentMemoryUsage)
  10. {
  11. CurrentStatement = currentStatement;
  12. CallStack = callStack;
  13. CurrentMemoryUsage = currentMemoryUsage;
  14. }
  15. /// <summary>
  16. /// The current call stack.
  17. /// </summary>
  18. /// <remarks>This will always include at least a call frame for the global environment.</remarks>
  19. public DebugCallStack CallStack { get; set; }
  20. /// <summary>
  21. /// The Statement that will be executed on next step.
  22. /// Note that this will be null when execution is at a return point.
  23. /// </summary>
  24. public Statement CurrentStatement { get; }
  25. /// <summary>
  26. /// The current source Location.
  27. /// For return points, this starts and ends at the end of the function body.
  28. /// </summary>
  29. public Location Location => CurrentCallFrame.Location;
  30. /// <summary>
  31. /// Not implemented. Will always return 0.
  32. /// </summary>
  33. public long CurrentMemoryUsage { get; }
  34. /// <summary>
  35. /// The currently executing call frame.
  36. /// </summary>
  37. public CallFrame CurrentCallFrame => CallStack[0];
  38. /// <summary>
  39. /// The scope chain of the currently executing call frame.
  40. /// </summary>
  41. public DebugScopes CurrentScopeChain => CurrentCallFrame.ScopeChain;
  42. /// <summary>
  43. /// The return value of the currently executing call frame.
  44. /// This is null if execution is not at a return point.
  45. /// </summary>
  46. public JsValue ReturnValue => CurrentCallFrame.ReturnValue;
  47. }
  48. }