1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
//! Raw `StateMachineMethod` table representation for Portable PDB format
//!
//! This module provides the [`StateMachineMethodRaw`] struct that represents
//! the binary format of `StateMachineMethod` table entries as they appear in
//! the metadata tables stream. This is the low-level representation used during
//! the initial parsing phase, containing unresolved method indices.
use crate::;
use Arc;
/// Raw binary representation of a `StateMachineMethod` table entry
///
/// This structure matches the exact binary layout of `StateMachineMethod` table
/// entries in the metadata tables stream. Both fields contain unresolved indices
/// into the `MethodDef` table that must be resolved during conversion to the
/// owned [`StateMachineMethod`] variant.
///
/// # Binary Format
///
/// Each `StateMachineMethod` table entry consists of:
/// - **`MoveNextMethod`** (4 bytes): `MethodDef` table index of the compiler-generated `MoveNext` method
/// - **`KickoffMethod`** (4 bytes): `MethodDef` table index of the original user method
///
/// # State Machine Context
///
/// When compilers generate state machines for async/await or yield return patterns:
/// 1. The original method becomes the "kickoff" method that initializes the state machine
/// 2. A new `MoveNext` method contains the actual implementation logic
/// 3. This table provides the bidirectional mapping between these methods
///
/// # Constraints
///
/// - Table must be sorted by `MoveNextMethod` column
/// - No duplicate `MoveNextMethod` values allowed
/// - No duplicate `KickoffMethod` values allowed
/// - Both indices must reference valid `MethodDef` entries
///
/// # References
///
/// - [Portable PDB Format - StateMachineMethod Table](https://github.com/dotnet/corefx/blob/master/src/System.Reflection.Metadata/specs/PortablePdb-Metadata.md#statemachinemethod-table-0x36)