1use gaia_types::{GaiaError, Result, SourceLocation};
2use std::collections::HashMap;
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
6pub struct ClrVersion {
7 pub major: u16,
8 pub minor: u16,
9 pub build: u16,
10 pub revision: u16,
11}
12
13impl Default for ClrVersion {
14 fn default() -> Self {
15 Self { major: 0, minor: 0, build: 0, revision: 0 }
16 }
17}
18
19#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
21pub struct ClrAccessFlags {
22 pub is_public: bool,
23 pub is_private: bool,
24 pub is_security_transparent: bool,
25 pub is_retargetable: bool,
26}
27
28impl Default for ClrAccessFlags {
29 fn default() -> Self {
30 Self { is_public: false, is_private: true, is_security_transparent: false, is_retargetable: false }
31 }
32}
33
34#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
36pub struct ClrMethodImplFlags {
37 pub is_managed: bool,
38 pub is_native: bool,
39 pub is_runtime: bool,
40 pub is_inline: bool,
41 pub is_no_inline: bool,
42 pub is_synchronized: bool,
43}
44
45impl Default for ClrMethodImplFlags {
46 fn default() -> Self {
47 Self {
48 is_managed: true,
49 is_native: false,
50 is_runtime: false,
51 is_inline: false,
52 is_no_inline: false,
53 is_synchronized: false,
54 }
55 }
56}
57
58#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
60pub enum ClrReferenceType {
61 Type,
62 Method,
63 Field,
64 Member,
65}
66
67#[derive(Debug, Clone, PartialEq, Eq, Hash)]
69pub enum ClrTypeReference {
70 Primitive(String),
71 Type(String, Option<String>), Array(Box<ClrTypeReference>),
73 Generic(Box<ClrTypeReference>, Vec<ClrTypeReference>),
74}
75
76#[derive(Debug, Clone, PartialEq, Eq, Hash)]
78pub struct ClrExternalAssembly {
79 pub name: String,
80 pub version: ClrVersion,
81 pub public_key_token: Option<Vec<u8>>,
82 pub culture: Option<String>,
83 pub hash_value: Option<Vec<u8>>,
84}
85
86#[derive(Debug, Clone, PartialEq, Eq, Hash)]
88pub struct ClrModule {
89 pub name: String,
90 pub mvid: [u8; 16], }
92
93#[derive(Debug, Clone, PartialEq, Eq)]
95pub struct ClrAttribute {
96 pub name: String,
97 pub constructor_args: Vec<ClrAttributeValue>,
98 pub named_args: HashMap<String, ClrAttributeValue>,
99}
100
101#[derive(Debug, Clone, PartialEq, Eq)]
103pub enum ClrAttributeValue {
104 String(String),
105 Int32(i32),
106 Boolean(bool),
107 Enum(String, i32),
108 Array(Vec<ClrAttributeValue>),
109}
110
111#[derive(Debug, Clone, PartialEq, Eq)]
113pub struct ClrField {
114 pub name: String,
115 pub field_type: ClrTypeReference,
116 pub access_flags: ClrAccessFlags,
117 pub attributes: Vec<ClrAttribute>,
118 pub initial_value: Option<Vec<u8>>,
119}
120
121#[derive(Debug, Clone, PartialEq, Eq)]
123pub struct ClrParameter {
124 pub name: String,
125 pub parameter_type: ClrTypeReference,
126 pub attributes: Vec<ClrAttribute>,
127}
128
129#[derive(Debug, Clone, PartialEq, Eq)]
131pub struct ClrLocalVariable {
132 pub index: u32,
133 pub variable_type: ClrTypeReference,
134 pub name: Option<String>,
135}
136
137#[derive(Debug, Clone, PartialEq, Eq)]
139pub struct ClrExceptionHandler {
140 pub handler_type: ClrExceptionHandlerType,
141 pub try_start: u32,
142 pub try_end: u32,
143 pub handler_start: u32,
144 pub handler_end: u32,
145 pub catch_type: Option<ClrTypeReference>,
146 pub filter_start: Option<u32>,
147}
148
149#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
151pub enum ClrExceptionHandlerType {
152 Catch,
153 Filter,
154 Finally,
155 Fault,
156}