This commit was manufactured by cvs2svn to create branch 'mono-1-0'.
[mono.git] / mono / metadata / metadata-internals.h
1
2 #ifndef __MONO_METADATA_INTERNALS_H__
3 #define __MONO_METADATA_INTERNALS_H__
4
5 #include "mono/metadata/image.h"
6 #include "mono/utils/mono-hash.h"
7
8 struct _MonoAssembly {
9         int   ref_count;
10         char *basedir;
11         gboolean in_gac;
12         MonoAssemblyName aname;
13         GModule *aot_module;
14         MonoImage *image;
15         /* Load files here */
16         gboolean dynamic;
17 };
18
19 typedef struct {
20         const char* data;
21         guint32  size;
22 } MonoStreamHeader;
23
24 struct _MonoTableInfo {
25         guint32   rows, row_size;
26         const char *base;
27
28         /*
29          * Tables contain up to 9 columns and the possible sizes of the
30          * fields in the documentation are 1, 2 and 4 bytes.  So we
31          * can encode in 2 bits the size.
32          *
33          * A 32 bit value can encode the resulting size
34          *
35          * The top eight bits encode the number of columns in the table.
36          * we only need 4, but 8 is aligned no shift required. 
37          */
38         guint32   size_bitfield;
39 };
40
41 struct _MonoImage {
42         int   ref_count;
43         FILE *f;
44         /* if f is NULL the image was loaded from raw data */
45         char *raw_data;
46         guint32 raw_data_len;
47         gboolean raw_data_allocated;
48         char *name;
49         const char *assembly_name;
50         const char *module_name;
51         const char *version;
52         char *guid;
53         void *image_info;
54
55         char                *raw_metadata;
56                             
57         gboolean             idx_string_wide, idx_guid_wide, idx_blob_wide;
58                             
59         MonoStreamHeader     heap_strings;
60         MonoStreamHeader     heap_us;
61         MonoStreamHeader     heap_blob;
62         MonoStreamHeader     heap_guid;
63         MonoStreamHeader     heap_tables;
64                             
65         const char          *tables_base;
66
67         MonoTableInfo        tables [64];
68
69         /*
70          * references is initialized only by using the mono_assembly_open
71          * function, and not by using the lowlevel mono_image_open.
72          *
73          * It is NULL terminated.
74          */
75         MonoAssembly **references;
76
77         MonoImage **modules;
78
79         MonoImage **files;
80
81         /*
82          * The Assembly this image was loaded from.
83          */
84         MonoAssembly *assembly;
85
86         /*
87          * Indexed by method tokens and typedef tokens.
88          */
89         GHashTable *method_cache;
90         GHashTable *class_cache;
91         /*
92          * Indexed by fielddef and memberref tokens
93          */
94         GHashTable *field_cache;
95
96         /* indexed by typespec tokens. */
97         GHashTable *typespec_cache;
98         /* indexed by token */
99         GHashTable *memberref_signatures;
100
101         /*
102          * Indexed by MonoGenericInst.
103          */
104         GHashTable *generic_inst_cache;
105
106         /*
107          * Indexes namespaces to hash tables that map class name to typedef token.
108          */
109         GHashTable *name_cache;
110
111         /*
112          * Indexed by ((rank << 24) | (typedef & 0xffffff)), which limits us to a
113          * maximal rank of 255
114          */
115         GHashTable *array_cache;
116
117         /*
118          * indexed by MonoMethodSignature 
119          */
120         GHashTable *delegate_begin_invoke_cache;
121         GHashTable *delegate_end_invoke_cache;
122         GHashTable *delegate_invoke_cache;
123
124         /*
125          * indexed by MonoMethod pointers 
126          */
127         GHashTable *runtime_invoke_cache;
128         GHashTable *managed_wrapper_cache;
129         GHashTable *native_wrapper_cache;
130         GHashTable *remoting_invoke_cache;
131         GHashTable *synchronized_cache;
132
133         void *reflection_info;
134
135         /*
136          * user_info is a public field and is not touched by the
137          * metadata engine
138          */
139         void *user_info;
140
141         /* dll map entries */
142         GHashTable *dll_map;
143
144         /* Whenever this is a dynamically emitted module */
145         gboolean dynamic;
146 };
147
148 enum {
149         MONO_SECTION_TEXT,
150         MONO_SECTION_RSRC,
151         MONO_SECTION_RELOC,
152         MONO_SECTION_MAX
153 };
154
155 typedef struct {
156         GHashTable *hash;
157         char *data;
158         guint32 alloc_size; /* malloced bytes */
159         guint32 index;
160         guint32 offset; /* from start of metadata */
161 } MonoDynamicStream;
162
163 typedef struct {
164         guint32 alloc_rows;
165         guint32 rows;
166         guint32 row_size; /*  calculated later with column_sizes */
167         guint32 columns;
168         guint32 column_sizes [9]; 
169         guint32 *values; /* rows * columns */
170         guint32 next_idx;
171 } MonoDynamicTable;
172
173 struct _MonoDynamicAssembly {
174         MonoAssembly assembly;
175         gboolean run;
176         gboolean save;
177         char *strong_name;
178         guint32 strong_name_size;
179 };
180
181 struct _MonoDynamicImage {
182         MonoImage image;
183         guint32 meta_size;
184         guint32 text_rva;
185         guint32 metadata_rva;
186         guint32 image_base;
187         guint32 cli_header_offset;
188         guint32 iat_offset;
189         guint32 idt_offset;
190         guint32 ilt_offset;
191         guint32 imp_names_offset;
192         struct {
193                 guint32 rva;
194                 guint32 size;
195                 guint32 offset;
196                 guint32 attrs;
197         } sections [MONO_SECTION_MAX];
198         GHashTable *typespec;
199         GHashTable *typeref;
200         GHashTable *handleref;
201         MonoGHashTable *tokens;
202         MonoGHashTable *blob_cache;
203         GList *array_methods;
204         MonoGHashTable *token_fixups;
205         MonoGHashTable *method_to_table_idx;
206         MonoGHashTable *field_to_table_idx;
207         MonoGHashTable *method_aux_hash;
208         gboolean run;
209         gboolean save;
210         char *strong_name;
211         guint32 strong_name_size;
212         char *win32_res;
213         guint32 win32_res_size;
214         MonoDynamicStream pefile;
215         MonoDynamicStream sheap;
216         MonoDynamicStream code; /* used to store method headers and bytecode */
217         MonoDynamicStream resources; /* managed embedded resources */
218         MonoDynamicStream us;
219         MonoDynamicStream blob;
220         MonoDynamicStream tstream;
221         MonoDynamicStream guid;
222         MonoDynamicTable tables [64];
223 };
224
225
226 #endif /* __MONO_METADATA_INTERNALS_H__ */
227