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
154
155
156
157
158
159
160
161
162
163
//! Raw `EncMap` table implementation for .NET metadata.
//!
//! This module provides the [`EncMapRaw`] structure for representing rows in the `EncMap` table,
//! which manages token mapping during Edit-and-Continue debugging operations. Each row contains
//! a metadata token that represents the original token value before editing occurred.
//!
//! ## Table Structure
//! The `EncMap` table (`TableId` 0x1F) contains the following column:
//! - **Token** (4 bytes): Original metadata token value
//!
//! ## Token Mapping Process
//!
//! During Edit-and-Continue operations:
//! 1. Original tokens are preserved in the `EncMap` table
//! 2. New metadata is generated with updated token values
//! 3. The position in the `EncMap` table provides the mapping relationship
//! 4. Debuggers correlate original and new tokens using table position
//!
//! ## Usage Examples
//!
//! ```rust,ignore
//! # use dotscope::metadata::tables::encmap::EncMapRaw;
//! # use dotscope::metadata::token::Token;
//! # fn example(raw: EncMapRaw) -> dotscope::Result<()> {
//! // Access original token information
//! let original_token = raw.token;
//! println!("Original token: {:#010x}", original_token.value());
//!
//! // Extract table and row information
//! let table_id = original_token.table_id();
//! let row_id = original_token.row_id();
//! println!("Token maps table {} row {}", table_id as u8, row_id);
//! # Ok(())
//! # }
//! ```
//!
//! ## ECMA-335 Reference
//!
//! See ECMA-335, Partition II, Section 22.13 for the complete `EncMap` table specification.
use Arc;
use crate::;
/// Raw representation of a row in the `EncMap` metadata table.
///
/// The `EncMap` table manages token mapping during Edit-and-Continue debugging operations.
/// Each row contains an original metadata token that was present before code editing occurred.
/// The table position provides an implicit mapping to the corresponding updated token.
///
/// ## Fields Overview
/// - **rid**: Row identifier within the `EncMap` table
/// - **token**: Metadata token for this mapping entry
/// - **offset**: Byte offset within the `EncMap` table data
/// - **`original_token`**: The original metadata token before editing
///
/// ## Token Correlation
/// The `EncMap` table provides implicit mapping through table position:
/// - Row N in `EncMap` contains the original token
/// - The updated token is determined by the debugger's token allocation
/// - Position-based correlation enables efficient token mapping
///
/// ## ECMA-335 Compliance
/// This structure directly corresponds to the `EncMap` table format specified in
/// ECMA-335, Partition II, Section 22.13.
///
/// **Table ID**: `0x1F`