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
//! `MemberRef` table implementation for external member references.
//!
//! This module provides complete support for the `MemberRef` metadata table, which defines
//! references to members (fields and methods) in external assemblies or modules. The `MemberRef`
//! table is essential for cross-assembly interoperability, late binding, and dynamic member
//! access in .NET applications.
//!
//! # Module Components
//! - [`MemberRefRaw`] - Raw table structure with unresolved coded indexes and heap references
//! - [`MemberRef`] - Owned variant with resolved references and parsed signatures
//! - [`MemberRefLoader`] - Internal loader for processing table entries (crate-private)
//! - [`MemberRefSignature`] - Union type for method and field signature representations
//! - Type aliases for collections: [`MemberRefMap`], [`MemberRefList`], [`MemberRefRc`]
//!
//! # Table Structure (ECMA-335 §22.25)
//! | Column | Type | Description |
//! |--------|------|-------------|
//! | Class | `MemberRefParent` coded index | Declaring type or module reference |
//! | Name | String heap index | Member name identifier |
//! | Signature | Blob heap index | Member signature (method or field) |
//!
//! # Member Reference Types
//! The `MemberRef` table supports references to different kinds of external members:
//! - **Field references**: External field access with type information and metadata
//! - **Method references**: External method calls with parameter and return type signatures
//! - **Constructor references**: Object creation with parameter specifications
//! - **Generic member references**: Generic methods and fields with type parameter resolution
//! - **Vararg method references**: Variable argument method calls with parameter lists
//!
//! # Parent Reference Types
//! The Class column uses `MemberRefParent` coded index encoding to specify the declaring context:
//! - **`TypeDef`**: Members declared in the current assembly's types
//! - **`TypeRef`**: Members declared in external assembly types
//! - **`ModuleRef`**: Global members declared in external modules
//! - **`MethodDef`**: Vararg method signatures referencing specific method definitions
//! - **`TypeSpec`**: Members of generic type instantiations
//!
//! # Signature Resolution
//! Member signatures in the blob heap are parsed according to their type:
//! - **Method signatures**: Include calling convention, parameter count, return type, and parameter types
//! - **Field signatures**: Include field type information and modifiers
//! - **Generic signatures**: Include type parameter specifications and constraints
//! - **Vararg signatures**: Include fixed and variable parameter specifications
//!
//! # ECMA-335 References
//! - ECMA-335, Partition II, §22.25: `MemberRef` table specification
//! - ECMA-335, Partition II, §23.2.6: `MemberRefParent` coded index encoding
//! - ECMA-335, Partition II, §23.2: Method and field signature specifications
use SkipMap;
use Arc;
use crate;
pub use *;
pub use *;
pub use *;
pub use *;
/// Concurrent map for storing `MemberRef` entries indexed by [`crate::metadata::token::Token`].
///
/// This thread-safe map enables efficient lookup of member references by their
/// associated tokens during metadata processing and member resolution operations.
pub type MemberRefMap = ;
/// Thread-safe list for storing collections of `MemberRef` entries.
///
/// Used for maintaining ordered sequences of member references during metadata
/// loading and for iteration over all members in an assembly.
pub type MemberRefList = ;
/// Reference-counted pointer to a [`MemberRef`] instance.
///
/// Enables efficient sharing of member reference data across multiple contexts
/// without duplication, supporting concurrent access patterns in member resolution.
pub type MemberRefRc = ;
/// Returns the name of the member reference for the given token, if it exists in the map.
///
/// This is a convenience function that performs a lookup in a [`MemberRefMap`] and extracts
/// the member name without requiring callers to deal with the `Entry` guard returned
/// by the underlying [`crossbeam_skiplist::SkipMap`].
///
/// # Arguments
///
/// * `map` - The member reference map to search in.
/// * `token` - The metadata token (table 0x0A) identifying the member reference.
///
/// # Returns
///
/// The member name as a `String` if a reference with the given token exists, `None` otherwise.
/// Member signature type union for `MemberRef` entries.
///
/// This enum represents the two possible signature types for member references:
/// method signatures (including constructors) and field signatures. The signature
/// type is determined by parsing the blob heap data according to the signature
/// calling convention and type encoding.
///
/// # Signature Determination
/// The signature type is determined by the first byte of the blob heap data:
/// - **Method signatures**: Have calling convention flags (0x00-0x0F, 0x20, 0x30)
/// - **Field signatures**: Have field signature marker (0x06)
/// - **Property signatures**: Have property signature marker (0x08, handled as field)
// ToDo: Verify if we handle this properly (Field vs Property)