1 #ifndef __METADATA_REFLECTION_H__
2 #define __METADATA_REFLECTION_H__
4 #include <mono/metadata/image.h>
5 #include <mono/metadata/metadata.h>
6 #include <mono/metadata/class.h>
7 #include <mono/metadata/object.h>
8 #include <mono/utils/mono-hash.h>
13 guint32 alloc_size; /* malloced bytes */
15 guint32 offset; /* from start of metadata */
21 guint32 row_size; /* calculated later with column_sizes */
23 guint32 column_sizes [9];
24 guint32 *values; /* rows * columns */
29 * The followinbg structure must match the C# implementation in our corlib.
32 struct _MonoReflectionMethod {
36 MonoReflectionType *reftype;
39 struct _MonoDelegate {
41 MonoObject *target_type;
43 MonoString *method_name;
45 gpointer delegate_trampoline;
46 MonoReflectionMethod *method_info;
49 typedef struct _MonoMulticastDelegate MonoMulticastDelegate;
50 struct _MonoMulticastDelegate {
51 MonoDelegate delegate;
52 MonoMulticastDelegate *prev;
58 MonoClassField *field;
60 MonoReflectionType *type;
62 } MonoReflectionField;
67 MonoProperty *property;
68 } MonoReflectionProperty;
74 } MonoReflectionEvent;
78 MonoReflectionType *ClassImpl;
79 MonoObject *DefaultValueImpl;
80 MonoObject *MemberImpl;
84 } MonoReflectionParameter;
88 MonoAssembly *assembly;
89 } MonoReflectionAssembly;
92 MonoReflectionType *utype;
98 MonoReflectionType *parent;
99 MonoReflectionType *ret;
106 MonoReflectionType *parent;
108 MonoReflectionMethod *get;
109 MonoReflectionMethod *set;
114 MonoReflectionType *parent;
116 MonoReflectionMethod *add_method;
117 MonoReflectionMethod *remove_method;
118 MonoReflectionMethod *raise_method;
124 MonoString *name_space;
125 MonoReflectionType *etype;
126 MonoReflectionType *nested_in;
127 MonoReflectionAssembly *assembly;
129 MonoBoolean isprimitive;
135 } MonoReflectionILTokenInfo;
144 MonoArray *ex_handlers;
145 gint32 num_token_fixups;
146 MonoArray *token_fixups;
147 } MonoReflectionILGen;
154 } MonoILExceptionInfo;
157 MonoReflectionType *extype;
161 gint32 filter_offset;
162 } MonoILExceptionBlock;
166 MonoReflectionType *type;
168 } MonoReflectionLocalBuilder;
177 MonoString *marshaltype;
178 MonoReflectionType *marshaltyperef;
179 } MonoReflectionMarshal;
186 MonoReflectionMarshal *marshal_info;
190 } MonoReflectionParamBuilder;
195 MonoReflectionILGen *ilgen;
196 MonoArray *parameters;
204 MonoBoolean init_locals;
205 MonoArray *param_modreq;
206 MonoArray *param_modopt;
207 MonoArray *permissions;
208 } MonoReflectionCtorBuilder;
213 MonoReflectionType *rtype;
214 MonoArray *parameters;
220 MonoReflectionILGen *ilgen;
224 MonoReflectionMethod *override_method;
226 MonoString *dllentry;
230 MonoBoolean init_locals;
231 MonoArray *generic_params;
232 MonoArray *return_modreq;
233 MonoArray *return_modopt;
234 MonoArray *param_modreq;
235 MonoArray *param_modopt;
236 MonoArray *permissions;
237 } MonoReflectionMethodBuilder;
242 MonoReflectionType *parent;
243 MonoReflectionType *ret;
244 MonoArray *parameters;
248 } MonoReflectionArrayMethod;
251 * Information which isn't in the MonoMethod structure is stored here for
256 MonoMarshalSpec **param_marshall;
257 } MonoReflectionMethodAux;
267 MonoAssembly assembly;
271 guint32 strong_name_size;
272 } MonoDynamicAssembly;
278 guint32 metadata_rva;
280 guint32 cli_header_offset;
284 guint32 imp_names_offset;
290 } sections [MONO_SECTION_MAX];
292 GHashTable *handleref;
293 MonoGHashTable *tokens;
294 MonoGHashTable *blob_cache;
295 GList *array_methods;
296 MonoGHashTable *token_fixups;
297 MonoGHashTable *method_to_table_idx;
298 MonoGHashTable *field_to_table_idx;
299 MonoGHashTable *method_aux_hash;
303 guint32 strong_name_size;
304 MonoDynamicStream pefile;
305 MonoDynamicStream sheap;
306 MonoDynamicStream code; /* used to store method headers and bytecode */
307 MonoDynamicStream resources; /* managed embedded resources */
308 MonoDynamicStream us;
309 MonoDynamicStream blob;
310 MonoDynamicStream tstream;
311 MonoDynamicStream guid;
312 MonoDynamicTable tables [64];
318 MonoString *filename;
321 } MonoReflectionResource;
326 } MonoReflectionPermissionSet;
329 MonoReflectionAssembly assembly;
330 MonoDynamicAssembly *dynamic_assembly;
331 MonoReflectionMethodBuilder *entry_point;
336 MonoArray *resources;
337 MonoArray *public_key;
343 MonoBoolean delay_sign;
345 MonoArray *loaded_modules;
346 } MonoReflectionAssemblyBuilder;
351 MonoReflectionType *type;
353 MonoObject *def_value;
356 MonoReflectionType *typeb;
359 MonoReflectionMarshal *marshal_info;
360 MonoClassField *handle;
363 } MonoReflectionFieldBuilder;
369 MonoReflectionType *type;
370 MonoArray *parameters;
372 MonoObject *def_value;
373 MonoReflectionMethodBuilder *set_method;
374 MonoReflectionMethodBuilder *get_method;
376 } MonoReflectionPropertyBuilder;
381 MonoReflectionAssembly *assembly;
384 MonoString *scopename;
385 MonoBoolean is_resource;
386 } MonoReflectionModule;
389 MonoReflectionModule module;
390 MonoDynamicImage *dynamic_image;
396 MonoReflectionAssemblyBuilder *assemblyb;
397 MonoArray *global_methods;
398 MonoArray *global_fields;
400 MonoArray *resources;
401 } MonoReflectionModuleBuilder;
404 MonoReflectionType type;
407 MonoReflectionType *parent;
408 MonoReflectionType *nesting_type;
409 MonoArray *interfaces;
413 MonoArray *properties;
421 MonoReflectionModuleBuilder *module;
424 MonoArray *generic_params;
425 } MonoReflectionTypeBuilder;
428 MonoReflectionType type;
433 MonoArray *constraints;
435 } MonoReflectionGenericParam;
437 typedef struct _MonoReflectionGenericInst MonoReflectionGenericInst;
438 struct _MonoReflectionGenericInst {
439 MonoReflectionType type;
441 MonoReflectionGenericInst *parent;
442 MonoReflectionType *generic_type;
443 MonoArray *interfaces;
450 MonoReflectionMethod rmethod;
451 MonoReflectionMethod *declaring;
452 MonoReflectionGenericInst *declaring_type;
453 MonoReflectionGenericInst *reflected_type;
454 MonoGenericInst *ginst;
455 } MonoReflectionInflatedMethod;
458 MonoReflectionField rfield;
459 MonoClassField *declaring;
460 MonoReflectionGenericInst *declaring_type;
461 MonoReflectionGenericInst *reflected_type;
462 } MonoReflectionInflatedField;
467 MonoString *codebase;
468 gint32 major, minor, build, revision;
469 /* FIXME: add missing stuff */
470 /* CultureInfo cultureinfo;
471 AssemblyNameFlags flags;
472 AssemblyHashAlgorithm hashalg;
473 StrongNameKeyPair keypair;
474 AssemblyVersionCompatibility versioncompat;*/
475 MonoObject *cultureInfo;
479 MonoArray *publicKey;
481 MonoObject *versioncompat;
482 } MonoReflectionAssemblyName;
487 MonoReflectionType *type;
488 MonoReflectionTypeBuilder *typeb;
490 MonoReflectionMethodBuilder *add_method;
491 MonoReflectionMethodBuilder *remove_method;
492 MonoReflectionMethodBuilder *raise_method;
493 MonoArray *other_methods;
496 } MonoReflectionEventBuilder;
500 MonoReflectionMethod *ctor;
502 } MonoReflectionCustomAttr;
508 MonoReflectionType *rtype;
509 MonoArray *parameters;
512 MonoReflectionModule *module;
513 MonoBoolean skip_visibility;
514 MonoBoolean init_locals;
515 MonoReflectionILGen *ilgen;
518 } MonoReflectionDynamicMethod;
520 typedef struct MonoTypeNameParse MonoTypeNameParse;
522 struct MonoTypeNameParse {
525 MonoAssemblyName assembly;
526 GList *modifiers; /* 0 -> byref, -1 -> pointer, > 0 -> array rank */
532 MonoReflectionModuleBuilder *module;
533 MonoArray *arguments;
535 MonoReflectionType *return_type;
537 guint32 unmanaged_call_conv;
538 } MonoReflectionSigHelper;
544 } MonoCustomAttrEntry;
549 MonoCustomAttrEntry attrs [MONO_ZERO_LEN_ARRAY];
550 } MonoCustomAttrInfo;
553 RESOURCE_LOCATION_EMBEDDED = 1,
554 RESOURCE_LOCATION_ANOTHER_ASSEMBLY = 2,
555 RESOURCE_LOCATION_IN_MANIFEST = 4
560 MonoReflectionAssembly *assembly;
561 MonoString *filename;
563 } MonoManifestResourceInfo;
565 int mono_reflection_parse_type (char *name, MonoTypeNameParse *info);
566 MonoType* mono_reflection_get_type (MonoImage* image, MonoTypeNameParse *info, gboolean ignorecase);
567 MonoType* mono_reflection_type_from_name (char *name, MonoImage *image);
569 void mono_image_create_pefile (MonoReflectionModuleBuilder *module);
570 void mono_image_basic_init (MonoReflectionAssemblyBuilder *assembly);
571 MonoReflectionModule * mono_image_load_module (MonoReflectionAssemblyBuilder *assembly, MonoString *file_name);
572 guint32 mono_image_insert_string (MonoReflectionModuleBuilder *module, MonoString *str);
573 guint32 mono_image_create_token (MonoDynamicImage *assembly, MonoObject *obj);
574 void mono_image_module_basic_init (MonoReflectionModuleBuilder *module);
576 MonoReflectionAssembly* mono_assembly_get_object (MonoDomain *domain, MonoAssembly *assembly);
577 MonoReflectionModule* mono_module_get_object (MonoDomain *domain, MonoImage *image);
578 MonoReflectionModule* mono_module_file_get_object (MonoDomain *domain, MonoImage *image, int table_index);
579 MonoReflectionType* mono_type_get_object (MonoDomain *domain, MonoType *type);
580 MonoReflectionMethod* mono_method_get_object (MonoDomain *domain, MonoMethod *method, MonoClass *refclass);
581 MonoReflectionField* mono_field_get_object (MonoDomain *domain, MonoClass *klass, MonoClassField *field);
582 MonoReflectionProperty* mono_property_get_object (MonoDomain *domain, MonoClass *klass, MonoProperty *property);
583 MonoReflectionEvent* mono_event_get_object (MonoDomain *domain, MonoClass *klass, MonoEvent *event);
584 /* note: this one is slightly different: we keep the whole array of params in the cache */
585 MonoArray* mono_param_get_objects (MonoDomain *domain, MonoMethod *method);
587 MonoArray* mono_reflection_get_custom_attrs (MonoObject *obj);
588 MonoArray* mono_reflection_get_custom_attrs_blob (MonoObject *ctor, MonoArray *ctorArgs, MonoArray *properties, MonoArray *porpValues, MonoArray *fields, MonoArray* fieldValues);
590 MonoArray* mono_custom_attrs_construct (MonoCustomAttrInfo *cinfo);
591 MonoCustomAttrInfo* mono_custom_attrs_from_index (MonoImage *image, guint32 idx);
592 MonoCustomAttrInfo* mono_custom_attrs_from_method (MonoMethod *method);
593 MonoCustomAttrInfo* mono_custom_attrs_from_class (MonoClass *klass);
594 MonoCustomAttrInfo* mono_custom_attrs_from_assembly (MonoAssembly *assembly);
595 MonoCustomAttrInfo* mono_custom_attrs_from_property (MonoClass *klass, MonoProperty *property);
596 MonoCustomAttrInfo* mono_custom_attrs_from_event (MonoClass *klass, MonoEvent *event);
597 MonoCustomAttrInfo* mono_custom_attrs_from_field (MonoClass *klass, MonoClassField *field);
598 MonoCustomAttrInfo* mono_custom_attrs_from_param (MonoMethod *method, guint32 param);
599 void mono_custom_attrs_free (MonoCustomAttrInfo *ainfo);
601 void mono_reflection_setup_internal_class (MonoReflectionTypeBuilder *tb);
603 void mono_reflection_create_internal_class (MonoReflectionTypeBuilder *tb);
605 void mono_reflection_setup_generic_class (MonoReflectionTypeBuilder *tb);
607 MonoReflectionType* mono_reflection_create_runtime_class (MonoReflectionTypeBuilder *tb);
609 void mono_reflection_create_dynamic_method (MonoReflectionDynamicMethod *m);
611 MonoReflectionGenericParam *mono_reflection_define_generic_parameter (MonoReflectionTypeBuilder *tb, MonoReflectionMethodBuilder *mb, MonoString *name, guint32 index);
612 void mono_reflection_initialize_generic_parameter (MonoReflectionGenericParam *gparam);
614 MonoReflectionGenericInst*
615 mono_reflection_bind_generic_parameters (MonoReflectionType *type, MonoArray *types);
616 MonoReflectionInflatedMethod*
617 mono_reflection_bind_generic_method_parameters (MonoReflectionMethod *method, MonoArray *types);
618 MonoReflectionInflatedMethod*
619 mono_reflection_inflate_method_or_ctor (MonoReflectionGenericInst *declaring_type, MonoReflectionGenericInst *reflected_type, MonoObject *obj);
620 MonoReflectionInflatedField*
621 mono_reflection_inflate_field (MonoReflectionGenericInst *declaring_type, MonoReflectionGenericInst *reflected_type, MonoObject *obj);
623 MonoArray *mono_reflection_sighelper_get_signature_local (MonoReflectionSigHelper *sig);
625 MonoArray *mono_reflection_sighelper_get_signature_field (MonoReflectionSigHelper *sig);
628 mono_reflection_lookup_dynamic_token (MonoImage *image, guint32 token);
631 mono_image_build_metadata (MonoReflectionModuleBuilder *module);
633 #endif /* __METADATA_REFLECTION_H__ */