You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.1 KiB

  1. using System;
  2. using System.Collections.Immutable;
  3. using System.Reflection.Metadata;
  4. using System.Reflection.Metadata.Ecma335;
  5. namespace ICSharpCode.Decompiler.DebugInfo
  6. {
  7. public readonly struct AsyncDebugInfo
  8. {
  9. public readonly int CatchHandlerOffset;
  10. public readonly ImmutableArray<Await> Awaits;
  11. public AsyncDebugInfo(int catchHandlerOffset, ImmutableArray<Await> awaits)
  12. {
  13. this.CatchHandlerOffset = catchHandlerOffset;
  14. this.Awaits = awaits;
  15. }
  16. public readonly struct Await
  17. {
  18. public readonly int YieldOffset;
  19. public readonly int ResumeOffset;
  20. public Await(int yieldOffset, int resumeOffset)
  21. {
  22. this.YieldOffset = yieldOffset;
  23. this.ResumeOffset = resumeOffset;
  24. }
  25. }
  26. public BlobBuilder BuildBlob(MethodDefinitionHandle moveNext)
  27. {
  28. BlobBuilder blob = new BlobBuilder();
  29. blob.WriteUInt32((uint)CatchHandlerOffset);
  30. foreach (var await in Awaits)
  31. {
  32. blob.WriteUInt32((uint)await.YieldOffset);
  33. blob.WriteUInt32((uint)await.ResumeOffset);
  34. blob.WriteCompressedInteger(MetadataTokens.GetRowNumber(moveNext));
  35. }
  36. return blob;
  37. }
  38. }
  39. }