2 #ifndef __MONO_METADATA_H__
3 #define __MONO_METADATA_H__
7 #include <mono/metadata/eltype.h>
24 META_TABLE_INTERFACEIMPL,
27 META_TABLE_CUSTOMATTRIBUTE,
28 META_TABLE_FIELDMARSHAL,
29 META_TABLE_DECLSECURITY,
30 META_TABLE_CLASSLAYOUT,
31 META_TABLE_FIELDLAYOUT,
32 META_TABLE_STANDALONESIG,
36 META_TABLE_PROPERTYMAP,
39 META_TABLE_METHODSEMANTICS,
40 META_TABLE_METHODIMPL,
48 META_TABLE_ASSEMBLYPROCESSOR,
49 META_TABLE_ASSEMBLYOS,
50 META_TABLE_ASSEMBLYREF,
51 META_TABLE_ASSEMBLYREFPROCESSOR,
52 META_TABLE_ASSEMBLYREFOS,
54 META_TABLE_EXPORTEDTYPE,
55 META_TABLE_MANIFESTRESOURCE,
56 META_TABLE_NESTEDCLASS,
58 #define META_TABLE_LAST META_TABLE_NESTEDCLASS
62 guint32 rows, row_size;
66 * Tables contain up to 9 rows and the possible sizes of the
67 * fields in the documentation are 1, 2 and 4 bytes. So we
68 * can encode in 2 bits the size.
70 * A 32 bit value can encode the resulting size
72 * The top eight bits encode the number of columns in the table.
73 * we only need 4, but 8 is aligned no shift required.
75 guint32 size_bitfield;
76 } metadata_tableinfo_t;
78 void mono_metadata_decode_row (metadata_tableinfo_t *t,
84 * This macro is used to extract the size of the table encoded in
85 * the size_bitfield of metadata_tableinfo_t.
87 #define meta_table_size(bitfield,table) ((((bitfield) >> ((table)*2)) & 0x3) + 1)
88 #define meta_table_count(bitfield) ((bitfield) >> 24)
93 gboolean idx_string_wide, idx_guid_wide, idx_blob_wide;
95 stream_header_t heap_strings;
96 stream_header_t heap_us;
97 stream_header_t heap_blob;
98 stream_header_t heap_guid;
99 stream_header_t heap_tables;
103 metadata_tableinfo_t tables [64];
107 * This enumeration is used to describe the data types in the metadata
118 /* Index into Blob heap */
121 /* Index into String heap */
127 /* Pointer into a table */
130 /* HasConstant:Parent pointer (Param, Field or Property) */
133 /* HasCustomAttribute index. Indexes any table except CustomAttribute */
136 /* CustomAttributeType encoded index */
139 /* HasDeclSecurity index: TypeDef Method or Assembly */
142 /* Implementation coded index: File, Export AssemblyRef */
145 /* HasFieldMarshal coded index: Field or Param table */
148 /* MemberForwardedIndex: Field or Method */
151 /* TypeDefOrRef coded index: typedef, typeref, typespec */
154 /* MemberRefParent coded index: typeref, moduleref, method, memberref, typesepc, typedef */
157 /* MethodDefOrRef coded index: Method or Member Ref table */
160 /* HasSemantic coded index: Event or Property */
163 /* ResolutionScope coded index: Module, ModuleRef, AssemblytRef, TypeRef */
172 const char *mono_meta_table_name (int table);
174 /* Internal functions */
175 void mono_metadata_compute_table_bases (metadata_t *meta);
177 MonoMetaTable *mono_metadata_get_table (MetaTableEnum table);
182 char *mono_metadata_locate (metadata_t *meta, int table, int idx);
183 char *mono_metadata_locate_token (metadata_t *meta, guint32 token);
185 const char *mono_metadata_string_heap (metadata_t *meta, guint32 index);
186 const char *mono_metadata_blob_heap (metadata_t *meta, guint32 index);
187 const char *mono_metadata_user_string (metadata_t *meta, guint32 index);
190 * Functions to extract information from the Blobs
192 const char *mono_metadata_decode_value (const char *ptr,
194 const char *mono_metadata_decode_blob_size (const char *xptr,
198 MONO_META_EXCEPTION_CLAUSE_NONE,
199 MONO_META_EXCEPTION_CLAUSE_FILTER,
200 MONO_META_EXCEPTION_CLAUSE_FINALLY,
201 MONO_META_EXCEPTION_CLAUSE_FAULT
202 } MonoMetaExceptionEnum;
211 } MonoCallConvention;
214 MonoMetaExceptionEnum kind;
217 } MonoMetaExceptionHandler;
219 typedef struct _MonoType MonoType;
220 typedef struct _MonoArray MonoArray;
221 typedef struct _MonoMethodSignature MonoMethodSignature;
231 MonoCustomMod modifiers[1]; /* this may grow */
244 guchar type; /* ElementTypeEnum */
245 guchar custom_mod; /* for PTR and SZARRAY: use data.mtype instead of data.type */
246 guchar byref; /* when included in a MonoRetType */
247 guchar constraint; /* valid when included in a local var signature */
249 guint32 token; /* for VALUETYPE and CLASS */
251 MonoModifiedType *mtype;
252 MonoArray *array; /* for ARRAY */
253 MonoMethodSignature *method;
258 /* maybe use a union here: saves 4 bytes */
259 MonoType *type; /* NULL for VOID */
260 short param_attrs; /* 22.1.11 */
263 MonoCustomMod modifiers[1]; /* this may grow */
266 /* MonoRetType is used also for params */
267 typedef MonoRetType MonoParam;
269 struct _MonoMethodSignature {
272 char call_convention;
283 guint32 local_var_sig_tok;
285 /* if local_var_sig_tok != 0, then the following apply: */
286 unsigned int init_locals : 1;
290 GList *exception_handler_list;
291 } MonoMetaMethodHeader;
293 guint32 mono_metadata_parse_typedef_or_ref (metadata_t *m,
296 int mono_metadata_parse_custom_mod (metadata_t *m,
300 MonoArray *mono_metadata_parse_array (metadata_t *m,
303 void mono_metadata_free_array (MonoArray *array);
304 MonoParam *mono_metadata_parse_param (metadata_t *m,
308 void mono_metadata_free_param (MonoParam *param);
309 MonoType *mono_metadata_parse_type (metadata_t *m,
312 void mono_metadata_free_type (MonoType *type);
314 MonoMethodSignature *mono_metadata_parse_method_signature (metadata_t *m,
318 void mono_metadata_free_method_signature (MonoMethodSignature *method);
320 MonoMetaMethodHeader *mono_metadata_parse_mh (metadata_t *m, const char *ptr);
321 void mono_metadata_free_mh (MonoMetaMethodHeader *mh);
324 * Makes a token based on a table and an index
326 #define mono_metadata_make_token(table,idx) (((table) << 24)| idx)
329 * Returns the table index that this token encodes.
331 #define mono_metadata_token_table(token) ((token) >> 24)
334 * Returns the index that a token refers to
336 #define mono_metadata_token_index(token) ((token & 0xffffff))
339 #define mono_metadata_token_code(token) ((token & 0xff000000))
342 * FIXME: put all of the table codes here
346 } MonoMetadataTableCodes;
348 #endif /* __MONO_METADATA_H__ */