2007-08-30 Dick Porter <dick@ximian.com>
[mono.git] / mono / metadata / class-internals.h
1 #ifndef __MONO_METADATA_CLASS_INTERBALS_H__
2 #define __MONO_METADATA_CLASS_INTERBALS_H__
3
4 #include <mono/metadata/class.h>
5 #include <mono/metadata/object.h>
6 #include <mono/io-layer/io-layer.h>
7 #include "mono/utils/mono-compiler.h"
8
9 #define MONO_CLASS_IS_ARRAY(c) ((c)->rank)
10
11 #define MONO_DEFAULT_SUPERTABLE_SIZE 6
12
13 extern gboolean mono_print_vtable;
14
15 typedef void     (*MonoStackWalkImpl) (MonoStackWalk func, gboolean do_il_offset, gpointer user_data);
16
17 typedef struct _MonoMethodNormal MonoMethodNormal;
18 typedef struct _MonoMethodWrapper MonoMethodWrapper;
19 typedef struct _MonoMethodInflated MonoMethodInflated;
20 typedef struct _MonoMethodPInvoke MonoMethodPInvoke;
21
22 typedef enum {
23 #define WRAPPER(e,n) MONO_WRAPPER_ ## e,
24 #include "wrapper-types.h"
25 #undef WRAPPER
26         MONO_WRAPPER_NUM
27 } MonoWrapperType;
28
29 typedef enum {
30         MONO_TYPE_NAME_FORMAT_IL,
31         MONO_TYPE_NAME_FORMAT_REFLECTION,
32         MONO_TYPE_NAME_FORMAT_FULL_NAME,
33         MONO_TYPE_NAME_FORMAT_ASSEMBLY_QUALIFIED
34 } MonoTypeNameFormat;
35
36 typedef enum {
37         MONO_REMOTING_TARGET_UNKNOWN,
38         MONO_REMOTING_TARGET_APPDOMAIN,
39         MONO_REMOTING_TARGET_COMINTEROP
40 } MonoRemotingTarget;
41
42 struct _MonoMethod {
43         guint16 flags;  /* method flags */
44         guint16 iflags; /* method implementation flags */
45         guint32 token;
46         MonoClass *klass;
47         MonoMethodSignature *signature;
48         MonoGenericContainer *generic_container;
49         /* name is useful mostly for debugging */
50         const char *name;
51         /* this is used by the inlining algorithm */
52         unsigned int inline_info:1;
53         unsigned int uses_this:1;
54         unsigned int wrapper_type:5;
55         unsigned int string_ctor:1;
56         unsigned int save_lmf:1;
57         unsigned int dynamic:1; /* created & destroyed during runtime */
58         unsigned int is_inflated:1; /* whether we're a MonoMethodInflated */
59         unsigned int skip_visibility:1; /* whenever to skip JIT visibility checks */
60         signed int slot : 20;
61 };
62
63 struct _MonoMethodNormal {
64         MonoMethod method;
65         MonoMethodHeader *header;
66 };
67
68 struct _MonoMethodWrapper {
69         MonoMethodNormal method;
70         void *method_data;
71 };
72
73 struct _MonoMethodPInvoke {
74         MonoMethod method;
75         gpointer addr;
76         /* add marshal info */
77         guint16 piflags;  /* pinvoke flags */
78         guint16 implmap_idx;  /* index into IMPLMAP */
79 };
80
81 typedef struct {
82         MonoType *generic_type;
83         gpointer reflection_info;
84 } MonoInflatedField;
85
86 /*
87  * MonoClassField is just a runtime representation of the metadata for
88  * field, it doesn't contain the data directly.  Static fields are
89  * stored in MonoVTable->data.  Instance fields are allocated in the
90  * objects after the object header.
91  */
92 struct _MonoClassField {
93         /* Type of the field */
94         MonoType        *type;
95
96         /* If this is an instantiated generic type, this is the
97          * "original" type, ie. the MONO_TYPE_VAR or MONO_TYPE_GENERICINST
98          * it was instantiated from.
99          */
100         MonoInflatedField  *generic_info;
101
102         /*
103          * Offset where this field is stored; if it is an instance
104          * field, it's the offset from the start of the object, if
105          * it's static, it's from the start of the memory chunk
106          * allocated for statics for the class.
107          */
108         int              offset;
109
110         const char      *name;
111
112         /*
113          * If the field is constant, pointer to the metadata constant
114          * value.
115          * If the field has an RVA flag, pointer to the data.
116          * Else, invalid.
117          */
118         const char      *data;
119
120         /* Type where the field was defined */
121         MonoClass       *parent;
122
123         /*
124          * If the field is constant, the type of the constant.
125          */
126         MonoTypeEnum     def_type;
127 };
128
129 /* a field is ignored if it's named "_Deleted" and it has the specialname and rtspecialname flags set */
130 #define mono_field_is_deleted(field) (((field)->type->attrs & (FIELD_ATTRIBUTE_SPECIAL_NAME | FIELD_ATTRIBUTE_RT_SPECIAL_NAME)) \
131                                       && (strcmp ((field)->name, "_Deleted") == 0))
132
133 typedef struct {
134         MonoClassField *field;
135         guint32 offset;
136         MonoMarshalSpec *mspec;
137 } MonoMarshalField;
138
139 typedef struct {
140         guint32 native_size;
141         guint32 num_fields;
142         MonoMethod *ptr_to_str;
143         MonoMethod *str_to_ptr;
144         MonoMarshalField fields [MONO_ZERO_LEN_ARRAY];
145 } MonoMarshalType;
146
147 struct _MonoProperty {
148         MonoClass *parent;
149         const char *name;
150         MonoMethod *get;
151         MonoMethod *set;
152         guint32 attrs;
153 };
154
155 struct _MonoEvent {
156         MonoClass *parent;
157         const char *name;
158         MonoMethod *add;
159         MonoMethod *remove;
160         MonoMethod *raise;
161         MonoMethod **other;
162         guint32 attrs;
163 };
164
165 /* type of exception being "on hold" for later processing (see exception_type) */
166 enum {
167         MONO_EXCEPTION_NONE = 0,
168         MONO_EXCEPTION_SECURITY_LINKDEMAND = 1,
169         MONO_EXCEPTION_SECURITY_INHERITANCEDEMAND = 2,
170         MONO_EXCEPTION_INVALID_PROGRAM = 3,
171         MONO_EXCEPTION_UNVERIFIABLE_IL = 4,
172         MONO_EXCEPTION_MISSING_METHOD = 5,
173         MONO_EXCEPTION_MISSING_FIELD = 6,
174         MONO_EXCEPTION_TYPE_LOAD = 7,
175         MONO_EXCEPTION_FILE_NOT_FOUND = 8,
176         MONO_EXCEPTION_METHOD_ACCESS = 9,
177         MONO_EXCEPTION_FIELD_ACCESS = 10,
178         /* add other exception type */
179 };
180
181 /* This struct collects the info needed for the runtime use of a class,
182  * like the vtables for a domain, the GC descriptor, etc.
183  */
184 typedef struct {
185         guint16 max_domain;
186         /* domain_vtables is indexed by the domain id and the size is max_domain + 1 */
187         MonoVTable *domain_vtables [MONO_ZERO_LEN_ARRAY];
188 } MonoClassRuntimeInfo;
189
190 struct _MonoClass {
191         MonoImage *image;
192
193         /* The underlying type of the enum */
194         MonoType *enum_basetype;
195         /* element class for arrays and enum */
196         MonoClass *element_class; 
197         /* used for subtype checks */
198         MonoClass *cast_class; 
199         /* array dimension */
200         guint8     rank;          
201
202         guint inited          : 1;
203         /* We use init_pending to detect cyclic calls to mono_class_init */
204         guint init_pending    : 1;
205
206         /* A class contains static and non static data. Static data can be
207          * of the same type as the class itselfs, but it does not influence
208          * the instance size of the class. To avoid cyclic calls to 
209          * mono_class_init (from mono_class_instance_size ()) we first 
210          * initialise all non static fields. After that we set size_inited 
211          * to 1, because we know the instance size now. After that we 
212          * initialise all static fields.
213          */
214         guint size_inited     : 1;
215         guint valuetype       : 1; /* derives from System.ValueType */
216         guint enumtype        : 1; /* derives from System.Enum */
217         guint blittable       : 1; /* class is blittable */
218         guint unicode         : 1; /* class uses unicode char when marshalled */
219         guint wastypebuilder  : 1; /* class was created at runtime from a TypeBuilder */
220         /* next byte */
221         guint min_align       : 4;
222         guint packing_size    : 4;
223         /* next byte */
224         guint ghcimpl         : 1; /* class has its own GetHashCode impl */ 
225         guint has_finalize    : 1; /* class has its own Finalize impl */ 
226         guint marshalbyref    : 1; /* class is a MarshalByRefObject */
227         guint contextbound    : 1; /* class is a ContextBoundObject */
228         guint delegate        : 1; /* class is a Delegate */
229         guint gc_descr_inited : 1; /* gc_descr is initialized */
230         guint has_cctor       : 1; /* class has a cctor */
231         guint has_references  : 1; /* it has GC-tracked references in the instance */
232         /* next byte */
233         guint has_static_refs : 1; /* it has static fields that are GC-tracked */
234         guint no_special_static_fields : 1; /* has no thread/context static fields */
235         /* directly or indirectly derives from ComImport attributed class.
236          * this means we need to create a proxy for instances of this class
237          * for COM Interop. set this flag on loading so all we need is a quick check
238          * during object creation rather than having to traverse supertypes
239          */
240         guint is_com_object : 1; 
241
242         guint8     exception_type;      /* MONO_EXCEPTION_* */
243         void*      exception_data;      /* Additional information about the exception */
244         guint32    declsec_flags;       /* declarative security attributes flags */
245
246         MonoClass  *parent;
247         MonoClass  *nested_in;
248         GList      *nested_classes;
249
250         guint32    type_token;
251         const char *name;
252         const char *name_space;
253         
254         /* for fast subtype checks */
255         MonoClass **supertypes;
256         guint16     idepth;
257
258         guint16     interface_count;
259         guint16     interface_id;        /* unique inderface id (for interfaces) */
260         guint16     max_interface_id;
261         
262         guint16     interface_offsets_count;
263         MonoClass **interfaces_packed;
264         guint16    *interface_offsets_packed;
265         guint8     *interface_bitmap;
266         
267         MonoClass **interfaces;
268
269         /*
270          * Computed object instance size, total.
271          */
272         int        instance_size;
273         int        vtable_size; /* number of slots */
274         union {
275                 int class_size; /* size of area for static fields */
276                 int element_size; /* for array types */
277         } sizes;
278
279         /*
280          * From the TypeDef table
281          */
282         guint32    flags;
283         struct {
284                 guint32 first, count;
285         } field, method, property, event;
286
287         /* loaded on demand */
288         MonoMarshalType *marshal_info;
289
290         /*
291          * Field information: Type and location from object base
292          */
293         MonoClassField *fields;
294
295         /* Initialized by a call to mono_class_setup_properties () */
296         MonoProperty *properties;
297
298         /* Initialized by a call to mono_class_setup_events () */
299         MonoEvent *events;
300
301         MonoMethod **methods;
302
303         /* used as the type of the this argument and when passing the arg by value */
304         MonoType this_arg;
305         MonoType byval_arg;
306
307         MonoGenericClass *generic_class;
308         MonoGenericContainer *generic_container;
309
310         void *reflection_info;
311
312         void *gc_descr;
313
314         MonoClassRuntimeInfo *runtime_info;
315
316         /* next element in the class_cache hash list (in MonoImage) */
317         MonoClass *next_class_cache;
318
319         /* Generic vtable. Initialized by a call to mono_class_setup_vtable () */
320         MonoMethod **vtable;    
321 };
322
323 #define MONO_CLASS_IMPLEMENTS_INTERFACE(k,uiid) (((uiid) <= (k)->max_interface_id) && ((k)->interface_bitmap [(uiid) >> 3] & (1 << ((uiid)&7))))
324 int mono_class_interface_offset (MonoClass *klass, MonoClass *itf);
325
326 /* the interface_offsets array is stored in memory before this struct */
327 struct MonoVTable {
328         MonoClass  *klass;
329          /*
330          * According to comments in gc_gcj.h, this should be the second word in
331          * the vtable.
332          */
333         void *gc_descr;         
334         MonoDomain *domain;  /* each object/vtable belongs to exactly one domain */
335         gpointer    data; /* to store static class data */
336         gpointer    type; /* System.Type type for klass */
337         guint8     *interface_bitmap;
338         guint16     max_interface_id;
339         guint8      rank;
340         guint remote          : 1; /* class is remotely activated */
341         guint initialized     : 1; /* cctor has been run */
342         guint init_failed     : 1; /* cctor execution failed */
343         guint32     imt_collisions_bitmap;
344         /* do not add any fields after vtable, the structure is dynamically extended */
345         gpointer    vtable [MONO_ZERO_LEN_ARRAY];       
346 };
347
348 #define MONO_VTABLE_IMPLEMENTS_INTERFACE(vt,uiid) (((uiid) <= (vt)->max_interface_id) && ((vt)->interface_bitmap [(uiid) >> 3] & (1 << ((uiid)&7))))
349
350 /*
351  * Generic instantiation data type encoding.
352  */
353
354 /*
355  * A particular generic instantiation:
356  *
357  * All instantiations are cached and we don't distinguish between class and method
358  * instantiations here.
359  */
360 struct _MonoGenericInst {
361         guint id;                       /* unique ID for debugging */
362         guint type_argc    : 22;        /* number of type arguments */
363         guint is_open      :  1;        /* if this is an open type */
364         MonoType **type_argv;
365 };
366
367 /*
368  * The generic context: an instantiation of a set of class and method generic parameters.
369  *
370  * NOTE: Never allocate this directly on the heap.  It have to be either allocated on the stack,
371  *       or embedded within other objects.  Don't store pointers to this, because it may be on the stack.
372  *       If you really have to, ensure you store a pointer to the embedding object along with it.
373  */
374 struct _MonoGenericContext {
375         /* The instantiation corresponding to the class generic parameters */
376         MonoGenericInst *class_inst;
377         /* The instantiation corresponding to the method generic parameters */
378         MonoGenericInst *method_inst;
379 };
380
381 /*
382  * Inflated generic method.
383  */
384 struct _MonoMethodInflated {
385         union {
386                 MonoMethod method;
387                 MonoMethodNormal normal;
388                 MonoMethodPInvoke pinvoke;
389         } method;
390         MonoMethod *declaring;          /* the generic method definition. */
391         MonoGenericContext context;     /* The current instantiation */
392         gpointer reflection_info;
393 };
394
395 /*
396  * A particular instantiation of a generic type.
397  */
398 struct _MonoGenericClass {
399         MonoClass *container_class;     /* the generic type definition */
400         MonoGenericContext context;     /* a context that contains the type instantiation doesn't contain any method instantiation */
401         guint is_dynamic  : 1;          /* We're a MonoDynamicGenericClass */
402         MonoClass *cached_class;        /* if present, the MonoClass corresponding to the instantiation.  */
403 };
404
405 /*
406  * This is used when instantiating a generic type definition which is
407  * a TypeBuilder.
408  */
409 struct _MonoDynamicGenericClass {
410         MonoGenericClass generic_class;
411         int count_methods;
412         MonoMethod **methods;
413         int count_ctors;
414         MonoMethod **ctors;
415         int count_fields;
416         MonoClassField *fields;
417         int count_properties;
418         MonoProperty *properties;
419         int count_events;
420         MonoEvent *events;
421         guint initialized;
422 };
423
424 /*
425  * The generic container.
426  *
427  * Stores the type parameters of a generic type definition or a generic method definition.
428  */
429 struct _MonoGenericContainer {
430         MonoGenericContext context;
431         /* If we're a generic method definition in a generic type definition,
432            the generic container of the containing class. */
433         MonoGenericContainer *parent;
434         /* the generic type definition or the generic method definition corresponding to this container */
435         union {
436                 MonoClass *klass;
437                 MonoMethod *method;
438         } owner;
439         int type_argc    : 31;
440         /* If true, we're a generic method, otherwise a generic type definition. */
441         /* Invariant: parent != NULL => is_method */
442         int is_method    : 1;
443         /* Our type parameters. */
444         MonoGenericParam *type_params;
445 };
446
447 /*
448  * A type parameter.
449  */
450 struct _MonoGenericParam {
451         MonoGenericContainer *owner;    /* Type or method this parameter was defined in. */
452         MonoClass *pklass;              /* The corresponding `MonoClass'. */
453         const char *name;
454         guint16 flags;
455         guint16 num;
456         MonoClass** constraints; /* NULL means end of list */
457 };
458
459 /*
460  * Class information which might be cached by the runtime in the AOT file for
461  * example. Caching this allows us to avoid computing a generic vtable
462  * (class->vtable) in most cases, saving time and avoiding creation of lots of
463  * MonoMethod structures.
464  */
465 typedef struct MonoCachedClassInfo {
466         guint32 vtable_size;
467         guint has_finalize : 1;
468         guint ghcimpl : 1;
469         guint has_cctor : 1;
470         guint has_nested_classes : 1;
471         guint blittable : 1;
472         guint has_references : 1;
473         guint has_static_refs : 1;
474         guint no_special_static_fields : 1;
475         guint32 cctor_token;
476         MonoImage *finalize_image;
477         guint32 finalize_token;
478         guint32 instance_size;
479         guint32 class_size;
480         guint32 packing_size;
481         guint32 min_align;
482 } MonoCachedClassInfo;
483
484 typedef struct {
485         const char *name;
486         gconstpointer func;
487         gconstpointer wrapper;
488         gconstpointer trampoline;
489         MonoMethodSignature *sig;
490 } MonoJitICallInfo;
491
492 typedef struct {
493         guint8 exception_type;
494         char *class_name; /* If kind == TYPE */
495         char *assembly_name; /* If kind == TYPE or ASSEMBLY */
496         MonoClass *klass; /* If kind != TYPE */
497         const char *member_name; /* If kind != TYPE */
498         gboolean ref_only; /* If kind == ASSEMBLY */
499 } MonoLoaderError;
500
501 #define mono_class_has_parent(klass,parent) (((klass)->idepth >= (parent)->idepth) && ((klass)->supertypes [(parent)->idepth - 1] == (parent)))
502
503 typedef struct {
504         gulong new_object_count;
505         gulong initialized_class_count;
506         gulong generic_vtable_count;
507         gulong used_class_count;
508         gulong method_count;
509         gulong class_vtable_size;
510         gulong class_static_data_size;
511         gulong generic_instance_count;
512         gulong generic_class_count;
513         gulong inflated_method_count;
514         gulong inflated_method_count_2;
515         gulong inflated_type_count;
516         gulong generics_metadata_size;
517         gulong dynamic_code_alloc_count;
518         gulong dynamic_code_bytes_count;
519         gulong dynamic_code_frees_count;
520         gulong imt_tables_size;
521         gulong imt_number_of_tables;
522         gulong imt_number_of_methods;
523         gulong imt_used_slots;
524         gulong imt_slots_with_collisions;
525         gulong imt_max_collisions_in_slot;
526         gulong imt_method_count_when_max_collisions;
527         gulong imt_thunks_size;
528         gulong jit_info_table_insert_count;
529         gulong jit_info_table_remove_count;
530         gulong jit_info_table_lookup_count;
531         gulong hazardous_pointer_count;
532         gboolean enabled;
533 } MonoStats;
534
535 /*
536  * The definition of the first field in SafeHandle,
537  * Keep in sync with SafeHandle.cs, this is only used
538  * to access the `handle' parameter.
539  */
540 typedef struct {
541         MonoObject  base;
542         void       *handle;
543 } MonoSafeHandle;
544
545 /*
546  * Keep in sync with HandleRef.cs
547  */
548 typedef struct {
549         MonoObject *wrapper;
550         void       *handle;
551 } MonoHandleRef;
552
553 extern MonoStats mono_stats MONO_INTERNAL;
554
555 typedef gpointer (*MonoTrampoline)       (MonoMethod *method);
556 typedef gpointer (*MonoRemotingTrampoline)       (MonoMethod *method, MonoRemotingTarget target);
557 typedef gpointer (*MonoDelegateTrampoline)       (MonoClass *klass);
558
559 typedef gpointer (*MonoLookupDynamicToken) (MonoImage *image, guint32 token, MonoClass **handle_class);
560
561 typedef gboolean (*MonoGetCachedClassInfo) (MonoClass *klass, MonoCachedClassInfo *res);
562
563 typedef gboolean (*MonoGetClassFromName) (MonoImage *image, const char *name_space, const char *name, MonoClass **res);
564
565 void
566 mono_classes_init (void) MONO_INTERNAL;
567
568 void
569 mono_classes_cleanup (void) MONO_INTERNAL;
570
571 void
572 mono_class_layout_fields   (MonoClass *klass) MONO_INTERNAL;
573
574 void
575 mono_class_setup_interface_offsets (MonoClass *klass) MONO_INTERNAL;
576
577 void
578 mono_class_setup_vtable_general (MonoClass *klass, MonoMethod **overrides, int onum) MONO_INTERNAL;
579
580 void
581 mono_class_setup_vtable (MonoClass *klass) MONO_INTERNAL;
582
583 void
584 mono_class_setup_methods (MonoClass *klass) MONO_INTERNAL;
585
586 void
587 mono_class_setup_mono_type (MonoClass *klass) MONO_INTERNAL;
588
589 void
590 mono_class_setup_parent    (MonoClass *klass, MonoClass *parent) MONO_INTERNAL;
591
592 void
593 mono_class_setup_supertypes (MonoClass *klass) MONO_INTERNAL;
594
595 GPtrArray*
596 mono_class_get_implemented_interfaces (MonoClass *klass) MONO_INTERNAL;
597
598 gboolean
599 mono_class_is_open_constructed_type (MonoType *t) MONO_INTERNAL;
600
601 gboolean
602 mono_class_get_overrides_full (MonoImage *image, guint32 type_token, MonoMethod ***overrides, gint32 *num_overrides,
603                                MonoGenericContext *generic_context) MONO_INTERNAL;
604
605 MonoMethod*
606 mono_class_get_cctor (MonoClass *klass) MONO_INTERNAL;
607
608 MonoMethod*
609 mono_class_get_finalizer (MonoClass *klass) MONO_INTERNAL;
610
611 gboolean
612 mono_class_needs_cctor_run (MonoClass *klass, MonoMethod *caller) MONO_INTERNAL;
613
614 gboolean
615 mono_class_has_special_static_fields (MonoClass *klass) MONO_INTERNAL;
616
617 void
618 mono_install_trampoline (MonoTrampoline func) MONO_INTERNAL;
619
620 void
621 mono_install_remoting_trampoline (MonoRemotingTrampoline func) MONO_INTERNAL;
622
623 void
624 mono_install_delegate_trampoline (MonoDelegateTrampoline func) MONO_INTERNAL;
625
626 gpointer
627 mono_lookup_dynamic_token (MonoImage *image, guint32 token) MONO_INTERNAL;
628
629 gpointer
630 mono_lookup_dynamic_token_class (MonoImage *image, guint32 token, MonoClass **handle_class) MONO_INTERNAL;
631
632 void
633 mono_install_lookup_dynamic_token (MonoLookupDynamicToken func) MONO_INTERNAL;
634
635 void
636 mono_install_get_cached_class_info (MonoGetCachedClassInfo func) MONO_INTERNAL;
637
638 void
639 mono_install_get_class_from_name (MonoGetClassFromName func) MONO_INTERNAL;
640
641 MonoGenericContext*
642 mono_class_get_context (MonoClass *class) MONO_INTERNAL;
643
644 MonoGenericContext*
645 mono_method_get_context (MonoMethod *method) MONO_INTERNAL;
646
647 MonoGenericContext*
648 mono_generic_class_get_context (MonoGenericClass *gclass) MONO_INTERNAL;
649
650 MonoClass*
651 mono_generic_class_get_class (MonoGenericClass *gclass) MONO_INTERNAL;
652
653 MonoMethod*
654 mono_class_inflate_generic_method_full (MonoMethod *method, MonoClass *klass_hint, MonoGenericContext *context);
655
656 MonoMethodInflated*
657 mono_method_inflated_lookup (MonoMethodInflated* method, gboolean cache) MONO_INTERNAL;
658
659 typedef struct {
660         MonoImage *corlib;
661         MonoClass *object_class;
662         MonoClass *byte_class;
663         MonoClass *void_class;
664         MonoClass *boolean_class;
665         MonoClass *sbyte_class;
666         MonoClass *int16_class;
667         MonoClass *uint16_class;
668         MonoClass *int32_class;
669         MonoClass *uint32_class;
670         MonoClass *int_class;
671         MonoClass *uint_class;
672         MonoClass *int64_class;
673         MonoClass *uint64_class;
674         MonoClass *single_class;
675         MonoClass *double_class;
676         MonoClass *char_class;
677         MonoClass *string_class;
678         MonoClass *enum_class;
679         MonoClass *array_class;
680         MonoClass *delegate_class;
681         MonoClass *multicastdelegate_class;
682         MonoClass *asyncresult_class;
683         MonoClass *waithandle_class;
684         MonoClass *typehandle_class;
685         MonoClass *fieldhandle_class;
686         MonoClass *methodhandle_class;
687         MonoClass *systemtype_class;
688         MonoClass *monotype_class;
689         MonoClass *exception_class;
690         MonoClass *threadabortexception_class;
691         MonoClass *thread_class;
692         MonoClass *transparent_proxy_class;
693         MonoClass *real_proxy_class;
694         MonoClass *mono_method_message_class;
695         MonoClass *appdomain_class;
696         MonoClass *field_info_class;
697         MonoClass *method_info_class;
698         MonoClass *stringbuilder_class;
699         MonoClass *math_class;
700         MonoClass *stack_frame_class;
701         MonoClass *stack_trace_class;
702         MonoClass *marshal_class;
703         MonoClass *iserializeable_class;
704         MonoClass *serializationinfo_class;
705         MonoClass *streamingcontext_class;
706         MonoClass *typed_reference_class;
707         MonoClass *argumenthandle_class;
708         MonoClass *marshalbyrefobject_class;
709         MonoClass *monitor_class;
710         MonoClass *iremotingtypeinfo_class;
711         MonoClass *runtimesecurityframe_class;
712         MonoClass *executioncontext_class;
713         MonoClass *internals_visible_class;
714         MonoClass *generic_ilist_class;
715         MonoClass *generic_nullable_class;
716         MonoClass *variant_class;
717         MonoClass *com_object_class;
718         MonoClass *com_interop_proxy_class;
719         MonoClass *iunknown_class;
720         MonoClass *idispatch_class;
721         MonoClass *safehandle_class;
722         MonoClass *handleref_class;
723         MonoClass *attribute_class;
724         MonoClass *customattribute_data_class;
725 } MonoDefaults;
726
727 extern MonoDefaults mono_defaults MONO_INTERNAL;
728
729 void
730 mono_loader_init           (void) MONO_INTERNAL;
731
732 void
733 mono_loader_cleanup        (void) MONO_INTERNAL;
734
735 void
736 mono_loader_lock           (void) MONO_INTERNAL;
737
738 void
739 mono_loader_unlock         (void) MONO_INTERNAL;
740
741 void
742 mono_loader_set_error_assembly_load (const char *assembly_name, gboolean ref_only) MONO_INTERNAL;
743
744 void
745 mono_loader_set_error_type_load (const char *class_name, const char *assembly_name) MONO_INTERNAL;
746
747 void
748 mono_loader_set_error_method_load (const char *class_name, const char *member_name) MONO_INTERNAL;
749
750 void
751 mono_loader_set_error_field_load (MonoClass *klass, const char *member_name) MONO_INTERNAL;
752
753 MonoException *
754 mono_loader_error_prepare_exception (MonoLoaderError *error) MONO_INTERNAL;
755
756 MonoLoaderError *
757 mono_loader_get_last_error (void) MONO_INTERNAL;
758
759 void
760 mono_loader_clear_error    (void) MONO_INTERNAL;
761
762 void
763 mono_reflection_init       (void) MONO_INTERNAL;
764
765 void
766 mono_icall_init            (void) MONO_INTERNAL;
767
768 void
769 mono_icall_cleanup         (void) MONO_INTERNAL;
770
771 gpointer
772 mono_method_get_wrapper_data (MonoMethod *method, guint32 id) MONO_INTERNAL;
773
774 void
775 mono_install_stack_walk (MonoStackWalkImpl func) MONO_INTERNAL;
776
777 gboolean
778 mono_metadata_has_generic_params (MonoImage *image, guint32 token) MONO_INTERNAL;
779
780 MonoGenericContainer *
781 mono_metadata_load_generic_params (MonoImage *image, guint32 token,
782                                    MonoGenericContainer *parent_container);
783
784 void
785 mono_metadata_load_generic_param_constraints (MonoImage *image, guint32 token,
786                                               MonoGenericContainer *container);
787
788 MonoMethodSignature*
789 mono_create_icall_signature (const char *sigstr) MONO_INTERNAL;
790
791 MonoJitICallInfo *
792 mono_register_jit_icall (gconstpointer func, const char *name, MonoMethodSignature *sig, gboolean is_save) MONO_INTERNAL;
793
794 void
795 mono_register_jit_icall_wrapper (MonoJitICallInfo *info, gconstpointer wrapper) MONO_INTERNAL;
796
797 MonoJitICallInfo *
798 mono_find_jit_icall_by_name (const char *name) MONO_INTERNAL;
799
800 MonoJitICallInfo *
801 mono_find_jit_icall_by_addr (gconstpointer addr) MONO_INTERNAL;
802
803 gboolean
804 mono_class_set_failure (MonoClass *klass, guint32 ex_type, void *ex_data) MONO_INTERNAL;
805
806 MonoException*
807 mono_class_get_exception_for_failure (MonoClass *klass) MONO_INTERNAL;
808
809 char*
810 mono_type_get_name_full (MonoType *type, MonoTypeNameFormat format) MONO_INTERNAL;
811
812 char*
813 mono_type_get_full_name (MonoClass *class) MONO_INTERNAL;
814
815 MonoArrayType *mono_dup_array_type (MonoArrayType *a) MONO_INTERNAL;
816 MonoMethodSignature *mono_metadata_signature_deep_dup (MonoMethodSignature *sig) MONO_INTERNAL;
817
818 void
819 mono_image_init_name_cache (MonoImage *image);
820
821 gboolean mono_class_is_nullable (MonoClass *klass) MONO_INTERNAL;
822 MonoClass *mono_class_get_nullable_param (MonoClass *klass) MONO_INTERNAL;
823
824 /* object debugging functions, for use inside gdb */
825 void mono_object_describe        (MonoObject *obj);
826 void mono_object_describe_fields (MonoObject *obj);
827 void mono_value_describe_fields  (MonoClass* klass, const char* addr);
828 void mono_class_describe_statics (MonoClass* klass);
829
830 /*Enum validation related functions*/
831 gboolean
832 mono_type_is_valid_enum_basetype (MonoType * type);
833
834 gboolean
835 mono_class_is_valid_enum (MonoClass *klass);
836
837 MonoType *
838 mono_type_get_full        (MonoImage *image, guint32 type_token, MonoGenericContext *context) MONO_INTERNAL;
839
840 #endif /* __MONO_METADATA_CLASS_INTERBALS_H__ */
841