2008-01-09 Rodrigo Kumpera <rkumpera@novell.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         MONO_EXCEPTION_GENERIC_SHARING_FAILED = 11,
179         MONO_EXCEPTION_BAD_IMAGE = 12
180         /* add other exception type */
181 };
182
183 /* This struct collects the info needed for the runtime use of a class,
184  * like the vtables for a domain, the GC descriptor, etc.
185  */
186 typedef struct {
187         guint16 max_domain;
188         /* domain_vtables is indexed by the domain id and the size is max_domain + 1 */
189         MonoVTable *domain_vtables [MONO_ZERO_LEN_ARRAY];
190 } MonoClassRuntimeInfo;
191
192 struct _MonoClass {
193         /* element class for arrays and enum */
194         MonoClass *element_class; 
195         /* used for subtype checks */
196         MonoClass *cast_class; 
197
198         /* for fast subtype checks */
199         MonoClass **supertypes;
200         guint16     idepth;
201
202         /* array dimension */
203         guint8     rank;          
204
205         int        instance_size; /* object instance size */
206
207         guint inited          : 1;
208         /* We use init_pending to detect cyclic calls to mono_class_init */
209         guint init_pending    : 1;
210
211         /* A class contains static and non static data. Static data can be
212          * of the same type as the class itselfs, but it does not influence
213          * the instance size of the class. To avoid cyclic calls to 
214          * mono_class_init (from mono_class_instance_size ()) we first 
215          * initialise all non static fields. After that we set size_inited 
216          * to 1, because we know the instance size now. After that we 
217          * initialise all static fields.
218          */
219         guint size_inited     : 1;
220         guint valuetype       : 1; /* derives from System.ValueType */
221         guint enumtype        : 1; /* derives from System.Enum */
222         guint blittable       : 1; /* class is blittable */
223         guint unicode         : 1; /* class uses unicode char when marshalled */
224         guint wastypebuilder  : 1; /* class was created at runtime from a TypeBuilder */
225         /* next byte */
226         guint min_align       : 4;
227         guint packing_size    : 4;
228         /* next byte */
229         guint ghcimpl         : 1; /* class has its own GetHashCode impl */ 
230         guint has_finalize    : 1; /* class has its own Finalize impl */ 
231         guint marshalbyref    : 1; /* class is a MarshalByRefObject */
232         guint contextbound    : 1; /* class is a ContextBoundObject */
233         guint delegate        : 1; /* class is a Delegate */
234         guint gc_descr_inited : 1; /* gc_descr is initialized */
235         guint has_cctor       : 1; /* class has a cctor */
236         guint has_references  : 1; /* it has GC-tracked references in the instance */
237         /* next byte */
238         guint has_static_refs : 1; /* it has static fields that are GC-tracked */
239         guint no_special_static_fields : 1; /* has no thread/context static fields */
240         /* directly or indirectly derives from ComImport attributed class.
241          * this means we need to create a proxy for instances of this class
242          * for COM Interop. set this flag on loading so all we need is a quick check
243          * during object creation rather than having to traverse supertypes
244          */
245         guint is_com_object : 1; 
246
247         guint8     exception_type;      /* MONO_EXCEPTION_* */
248         void*      exception_data;      /* Additional information about the exception */
249
250         MonoClass  *parent;
251         MonoClass  *nested_in;
252         GList      *nested_classes;
253
254         MonoImage *image;
255         const char *name;
256         const char *name_space;
257
258         /* The underlying type of the enum */
259         MonoType *enum_basetype;
260
261         guint32    declsec_flags;       /* declarative security attributes flags */
262         guint32    type_token;
263         int        vtable_size; /* number of slots */
264
265         guint16     interface_count;
266         guint16     interface_id;        /* unique inderface id (for interfaces) */
267         guint16     max_interface_id;
268         
269         guint16     interface_offsets_count;
270         MonoClass **interfaces_packed;
271         guint16    *interface_offsets_packed;
272         guint8     *interface_bitmap;
273         
274         MonoClass **interfaces;
275
276         union {
277                 int class_size; /* size of area for static fields */
278                 int element_size; /* for array types */
279         } sizes;
280
281         /*
282          * From the TypeDef table
283          */
284         guint32    flags;
285         struct {
286                 guint32 first, count;
287         } field, method, property, event;
288
289         /* loaded on demand */
290         MonoMarshalType *marshal_info;
291
292         /*
293          * Field information: Type and location from object base
294          */
295         MonoClassField *fields;
296
297         /* Initialized by a call to mono_class_setup_properties () */
298         MonoProperty *properties;
299
300         /* Initialized by a call to mono_class_setup_events () */
301         MonoEvent *events;
302
303         MonoMethod **methods;
304
305         /* used as the type of the this argument and when passing the arg by value */
306         MonoType this_arg;
307         MonoType byval_arg;
308
309         MonoGenericClass *generic_class;
310         MonoGenericContainer *generic_container;
311
312         void *reflection_info;
313
314         void *gc_descr;
315
316         MonoClassRuntimeInfo *runtime_info;
317
318         /* next element in the class_cache hash list (in MonoImage) */
319         MonoClass *next_class_cache;
320
321         /* Generic vtable. Initialized by a call to mono_class_setup_vtable () */
322         MonoMethod **vtable;    
323 };
324
325 #define MONO_CLASS_IMPLEMENTS_INTERFACE(k,uiid) (((uiid) <= (k)->max_interface_id) && ((k)->interface_bitmap [(uiid) >> 3] & (1 << ((uiid)&7))))
326 int mono_class_interface_offset (MonoClass *klass, MonoClass *itf);
327
328 typedef struct {
329         gpointer static_data;
330         MonoClass *klass;
331         MonoVTable *vtable;
332 } MonoRuntimeGenericSuperInfo;
333
334 typedef struct {
335         gpointer static_data;
336         MonoClass *klass;
337         MonoVTable *vtable;
338 } MonoRuntimeGenericArgInfo;
339
340 typedef struct {
341         MonoDomain *domain;
342         MonoRuntimeGenericArgInfo arg_infos [MONO_ZERO_LEN_ARRAY];
343 } MonoRuntimeGenericContext;
344
345 /* the interface_offsets array is stored in memory before this struct */
346 struct MonoVTable {
347         MonoClass  *klass;
348          /*
349          * According to comments in gc_gcj.h, this should be the second word in
350          * the vtable.
351          */
352         void *gc_descr;         
353         MonoDomain *domain;  /* each object/vtable belongs to exactly one domain */
354         gpointer    data; /* to store static class data */
355         gpointer    type; /* System.Type type for klass */
356         guint8     *interface_bitmap;
357         guint16     max_interface_id;
358         guint8      rank;
359         guint remote          : 1; /* class is remotely activated */
360         guint initialized     : 1; /* cctor has been run */
361         guint init_failed     : 1; /* cctor execution failed */
362         guint32     imt_collisions_bitmap;
363         MonoRuntimeGenericContext *runtime_generic_context;
364         /* do not add any fields after vtable, the structure is dynamically extended */
365         gpointer    vtable [MONO_ZERO_LEN_ARRAY];       
366 };
367
368 #define MONO_VTABLE_IMPLEMENTS_INTERFACE(vt,uiid) (((uiid) <= (vt)->max_interface_id) && ((vt)->interface_bitmap [(uiid) >> 3] & (1 << ((uiid)&7))))
369
370 /*
371  * Generic instantiation data type encoding.
372  */
373
374 /*
375  * A particular generic instantiation:
376  *
377  * All instantiations are cached and we don't distinguish between class and method
378  * instantiations here.
379  */
380 struct _MonoGenericInst {
381         guint id;                       /* unique ID for debugging */
382         guint type_argc    : 22;        /* number of type arguments */
383         guint is_open      :  1;        /* if this is an open type */
384         MonoType **type_argv;
385 };
386
387 /*
388  * The generic context: an instantiation of a set of class and method generic parameters.
389  *
390  * NOTE: Never allocate this directly on the heap.  It have to be either allocated on the stack,
391  *       or embedded within other objects.  Don't store pointers to this, because it may be on the stack.
392  *       If you really have to, ensure you store a pointer to the embedding object along with it.
393  */
394 struct _MonoGenericContext {
395         /* The instantiation corresponding to the class generic parameters */
396         MonoGenericInst *class_inst;
397         /* The instantiation corresponding to the method generic parameters */
398         MonoGenericInst *method_inst;
399 };
400
401 /*
402  * Inflated generic method.
403  */
404 struct _MonoMethodInflated {
405         union {
406                 MonoMethod method;
407                 MonoMethodNormal normal;
408                 MonoMethodPInvoke pinvoke;
409         } method;
410         MonoMethod *declaring;          /* the generic method definition. */
411         MonoGenericContext context;     /* The current instantiation */
412         gpointer reflection_info;
413 };
414
415 /*
416  * A particular instantiation of a generic type.
417  */
418 struct _MonoGenericClass {
419         MonoClass *container_class;     /* the generic type definition */
420         MonoGenericContext context;     /* a context that contains the type instantiation doesn't contain any method instantiation */
421         guint is_dynamic  : 1;          /* We're a MonoDynamicGenericClass */
422         guint is_tb_open  : 1;          /* This is the fully open instantiation for a type_builder. Quite ugly, but it's temporary.*/
423         MonoClass *cached_class;        /* if present, the MonoClass corresponding to the instantiation.  */
424 };
425
426 /*
427  * This is used when instantiating a generic type definition which is
428  * a TypeBuilder.
429  */
430 struct _MonoDynamicGenericClass {
431         MonoGenericClass generic_class;
432         int count_methods;
433         MonoMethod **methods;
434         int count_ctors;
435         MonoMethod **ctors;
436         int count_fields;
437         MonoClassField *fields;
438         int count_properties;
439         MonoProperty *properties;
440         int count_events;
441         MonoEvent *events;
442         guint initialized;
443 };
444
445 /*
446  * The generic container.
447  *
448  * Stores the type parameters of a generic type definition or a generic method definition.
449  */
450 struct _MonoGenericContainer {
451         MonoGenericContext context;
452         /* If we're a generic method definition in a generic type definition,
453            the generic container of the containing class. */
454         MonoGenericContainer *parent;
455         /* the generic type definition or the generic method definition corresponding to this container */
456         union {
457                 MonoClass *klass;
458                 MonoMethod *method;
459         } owner;
460         int type_argc    : 31;
461         /* If true, we're a generic method, otherwise a generic type definition. */
462         /* Invariant: parent != NULL => is_method */
463         int is_method    : 1;
464         /* Our type parameters. */
465         MonoGenericParam *type_params;
466 };
467
468 /*
469  * A type parameter.
470  */
471 struct _MonoGenericParam {
472         MonoGenericContainer *owner;    /* Type or method this parameter was defined in. */
473         MonoClass *pklass;              /* The corresponding `MonoClass'. */
474         const char *name;
475         guint16 flags;
476         guint16 num;
477         MonoClass** constraints; /* NULL means end of list */
478 };
479
480 /*
481  * Class information which might be cached by the runtime in the AOT file for
482  * example. Caching this allows us to avoid computing a generic vtable
483  * (class->vtable) in most cases, saving time and avoiding creation of lots of
484  * MonoMethod structures.
485  */
486 typedef struct MonoCachedClassInfo {
487         guint32 vtable_size;
488         guint has_finalize : 1;
489         guint ghcimpl : 1;
490         guint has_cctor : 1;
491         guint has_nested_classes : 1;
492         guint blittable : 1;
493         guint has_references : 1;
494         guint has_static_refs : 1;
495         guint no_special_static_fields : 1;
496         guint32 cctor_token;
497         MonoImage *finalize_image;
498         guint32 finalize_token;
499         guint32 instance_size;
500         guint32 class_size;
501         guint32 packing_size;
502         guint32 min_align;
503 } MonoCachedClassInfo;
504
505 typedef struct {
506         const char *name;
507         gconstpointer func;
508         gconstpointer wrapper;
509         gconstpointer trampoline;
510         MonoMethodSignature *sig;
511 } MonoJitICallInfo;
512
513 typedef struct {
514         guint8 exception_type;
515         char *class_name; /* If kind == TYPE */
516         char *assembly_name; /* If kind == TYPE or ASSEMBLY */
517         MonoClass *klass; /* If kind != TYPE */
518         const char *member_name; /* If kind != TYPE */
519         gboolean ref_only; /* If kind == ASSEMBLY */
520         char *msg; /* If kind == BAD_IMAGE */
521 } MonoLoaderError;
522
523 #define mono_class_has_parent(klass,parent) (((klass)->idepth >= (parent)->idepth) && ((klass)->supertypes [(parent)->idepth - 1] == (parent)))
524
525 typedef struct {
526         gulong new_object_count;
527         gulong initialized_class_count;
528         gulong generic_vtable_count;
529         gulong used_class_count;
530         gulong method_count;
531         gulong class_vtable_size;
532         gulong class_static_data_size;
533         gulong generic_instance_count;
534         gulong generic_class_count;
535         gulong inflated_method_count;
536         gulong inflated_method_count_2;
537         gulong inflated_type_count;
538         gulong generics_metadata_size;
539         gulong dynamic_code_alloc_count;
540         gulong dynamic_code_bytes_count;
541         gulong dynamic_code_frees_count;
542         gulong delegate_creations;
543         gulong imt_tables_size;
544         gulong imt_number_of_tables;
545         gulong imt_number_of_methods;
546         gulong imt_used_slots;
547         gulong imt_slots_with_collisions;
548         gulong imt_max_collisions_in_slot;
549         gulong imt_method_count_when_max_collisions;
550         gulong imt_thunks_size;
551         gulong jit_info_table_insert_count;
552         gulong jit_info_table_remove_count;
553         gulong jit_info_table_lookup_count;
554         gulong hazardous_pointer_count;
555         gulong generics_sharable_methods;
556         gulong generics_unsharable_methods;
557         gulong generics_shared_methods;
558         gulong minor_gc_count;
559         gulong major_gc_count;
560         gulong minor_gc_time_usecs;
561         gulong major_gc_time_usecs;
562         gboolean enabled;
563 } MonoStats;
564
565 /*
566  * The definition of the first field in SafeHandle,
567  * Keep in sync with SafeHandle.cs, this is only used
568  * to access the `handle' parameter.
569  */
570 typedef struct {
571         MonoObject  base;
572         void       *handle;
573 } MonoSafeHandle;
574
575 /*
576  * Keep in sync with HandleRef.cs
577  */
578 typedef struct {
579         MonoObject *wrapper;
580         void       *handle;
581 } MonoHandleRef;
582
583 enum {
584         MONO_GENERIC_SHARING_NONE,
585         MONO_GENERIC_SHARING_CORLIB,
586         MONO_GENERIC_SHARING_ALL
587 };
588
589 extern MonoStats mono_stats MONO_INTERNAL;
590
591 typedef gpointer (*MonoTrampoline)       (MonoMethod *method);
592 typedef gpointer (*MonoJumpTrampoline)       (MonoDomain *domain, MonoMethod *method, gboolean add_sync_wrapper);
593 typedef gpointer (*MonoRemotingTrampoline)       (MonoMethod *method, MonoRemotingTarget target);
594 typedef gpointer (*MonoDelegateTrampoline)       (MonoClass *klass);
595
596 typedef gpointer (*MonoLookupDynamicToken) (MonoImage *image, guint32 token, gboolean valid_token, MonoClass **handle_class, MonoGenericContext *context);
597
598 typedef gboolean (*MonoGetCachedClassInfo) (MonoClass *klass, MonoCachedClassInfo *res);
599
600 typedef gboolean (*MonoGetClassFromName) (MonoImage *image, const char *name_space, const char *name, MonoClass **res);
601
602 void
603 mono_classes_init (void) MONO_INTERNAL;
604
605 void
606 mono_classes_cleanup (void) MONO_INTERNAL;
607
608 void
609 mono_class_layout_fields   (MonoClass *klass) MONO_INTERNAL;
610
611 void
612 mono_class_setup_interface_offsets (MonoClass *klass) MONO_INTERNAL;
613
614 void
615 mono_class_setup_vtable_general (MonoClass *klass, MonoMethod **overrides, int onum) MONO_INTERNAL;
616
617 void
618 mono_class_setup_vtable (MonoClass *klass) MONO_INTERNAL;
619
620 void
621 mono_class_setup_methods (MonoClass *klass) MONO_INTERNAL;
622
623 void
624 mono_class_setup_mono_type (MonoClass *klass) MONO_INTERNAL;
625
626 void
627 mono_class_setup_parent    (MonoClass *klass, MonoClass *parent) MONO_INTERNAL;
628
629 void
630 mono_class_setup_supertypes (MonoClass *klass) MONO_INTERNAL;
631
632 GPtrArray*
633 mono_class_get_implemented_interfaces (MonoClass *klass) MONO_INTERNAL;
634
635 gboolean
636 mono_class_is_open_constructed_type (MonoType *t) MONO_INTERNAL;
637
638 gboolean
639 mono_class_get_overrides_full (MonoImage *image, guint32 type_token, MonoMethod ***overrides, gint32 *num_overrides,
640                                MonoGenericContext *generic_context) MONO_INTERNAL;
641
642 MonoMethod*
643 mono_class_get_cctor (MonoClass *klass) MONO_INTERNAL;
644
645 MonoMethod*
646 mono_class_get_finalizer (MonoClass *klass) MONO_INTERNAL;
647
648 gboolean
649 mono_class_needs_cctor_run (MonoClass *klass, MonoMethod *caller) MONO_INTERNAL;
650
651 gboolean
652 mono_class_has_special_static_fields (MonoClass *klass) MONO_INTERNAL;
653
654 const char*
655 mono_class_get_field_default_value (MonoClassField *field, MonoTypeEnum *def_type) MONO_INTERNAL;
656
657 void
658 mono_install_trampoline (MonoTrampoline func) MONO_INTERNAL;
659
660 void
661 mono_install_jump_trampoline (MonoJumpTrampoline func) MONO_INTERNAL;
662
663 void
664 mono_install_remoting_trampoline (MonoRemotingTrampoline func) MONO_INTERNAL;
665
666 void
667 mono_install_delegate_trampoline (MonoDelegateTrampoline func) MONO_INTERNAL;
668
669 gpointer
670 mono_lookup_dynamic_token (MonoImage *image, guint32 token, MonoGenericContext *context) MONO_INTERNAL;
671
672 gpointer
673 mono_lookup_dynamic_token_class (MonoImage *image, guint32 token, gboolean check_token, MonoClass **handle_class, MonoGenericContext *context) MONO_INTERNAL;
674
675 void
676 mono_install_lookup_dynamic_token (MonoLookupDynamicToken func) MONO_INTERNAL;
677
678 gpointer
679 mono_runtime_create_jump_trampoline (MonoDomain *domain, MonoMethod *method, gboolean add_sync_wrapper) MONO_INTERNAL;
680
681 gpointer
682 mono_runtime_create_delegate_trampoline (MonoClass *klass) MONO_INTERNAL;
683
684 void
685 mono_install_get_cached_class_info (MonoGetCachedClassInfo func) MONO_INTERNAL;
686
687 void
688 mono_install_get_class_from_name (MonoGetClassFromName func) MONO_INTERNAL;
689
690 MonoGenericContext*
691 mono_class_get_context (MonoClass *class) MONO_INTERNAL;
692
693 MonoGenericContext*
694 mono_method_get_context (MonoMethod *method) MONO_INTERNAL;
695
696 MonoGenericContext*
697 mono_generic_class_get_context (MonoGenericClass *gclass) MONO_INTERNAL;
698
699 MonoClass*
700 mono_generic_class_get_class (MonoGenericClass *gclass) MONO_INTERNAL;
701
702 MonoMethod*
703 mono_class_inflate_generic_method_full (MonoMethod *method, MonoClass *klass_hint, MonoGenericContext *context);
704
705 MonoMethodInflated*
706 mono_method_inflated_lookup (MonoMethodInflated* method, gboolean cache) MONO_INTERNAL;
707
708 MonoMethodSignature *
709 mono_metadata_get_inflated_signature (MonoMethodSignature *sig, MonoGenericContext *context);
710
711 void
712 mono_metadata_free_inflated_signature (MonoMethodSignature *sig);
713
714 typedef struct {
715         MonoImage *corlib;
716         MonoClass *object_class;
717         MonoClass *byte_class;
718         MonoClass *void_class;
719         MonoClass *boolean_class;
720         MonoClass *sbyte_class;
721         MonoClass *int16_class;
722         MonoClass *uint16_class;
723         MonoClass *int32_class;
724         MonoClass *uint32_class;
725         MonoClass *int_class;
726         MonoClass *uint_class;
727         MonoClass *int64_class;
728         MonoClass *uint64_class;
729         MonoClass *single_class;
730         MonoClass *double_class;
731         MonoClass *char_class;
732         MonoClass *string_class;
733         MonoClass *enum_class;
734         MonoClass *array_class;
735         MonoClass *delegate_class;
736         MonoClass *multicastdelegate_class;
737         MonoClass *asyncresult_class;
738         MonoClass *waithandle_class;
739         MonoClass *typehandle_class;
740         MonoClass *fieldhandle_class;
741         MonoClass *methodhandle_class;
742         MonoClass *systemtype_class;
743         MonoClass *monotype_class;
744         MonoClass *exception_class;
745         MonoClass *threadabortexception_class;
746         MonoClass *thread_class;
747         MonoClass *transparent_proxy_class;
748         MonoClass *real_proxy_class;
749         MonoClass *mono_method_message_class;
750         MonoClass *appdomain_class;
751         MonoClass *field_info_class;
752         MonoClass *method_info_class;
753         MonoClass *stringbuilder_class;
754         MonoClass *math_class;
755         MonoClass *stack_frame_class;
756         MonoClass *stack_trace_class;
757         MonoClass *marshal_class;
758         MonoClass *iserializeable_class;
759         MonoClass *serializationinfo_class;
760         MonoClass *streamingcontext_class;
761         MonoClass *typed_reference_class;
762         MonoClass *argumenthandle_class;
763         MonoClass *marshalbyrefobject_class;
764         MonoClass *monitor_class;
765         MonoClass *iremotingtypeinfo_class;
766         MonoClass *runtimesecurityframe_class;
767         MonoClass *executioncontext_class;
768         MonoClass *internals_visible_class;
769         MonoClass *generic_ilist_class;
770         MonoClass *generic_nullable_class;
771         MonoClass *variant_class;
772         MonoClass *com_object_class;
773         MonoClass *com_interop_proxy_class;
774         MonoClass *iunknown_class;
775         MonoClass *idispatch_class;
776         MonoClass *safehandle_class;
777         MonoClass *handleref_class;
778         MonoClass *attribute_class;
779         MonoClass *customattribute_data_class;
780 } MonoDefaults;
781
782 extern MonoDefaults mono_defaults MONO_INTERNAL;
783
784 void
785 mono_loader_init           (void) MONO_INTERNAL;
786
787 void
788 mono_loader_cleanup        (void) MONO_INTERNAL;
789
790 void
791 mono_loader_lock           (void) MONO_INTERNAL;
792
793 void
794 mono_loader_unlock         (void) MONO_INTERNAL;
795
796 void
797 mono_loader_set_error_assembly_load (const char *assembly_name, gboolean ref_only) MONO_INTERNAL;
798
799 void
800 mono_loader_set_error_type_load (const char *class_name, const char *assembly_name) MONO_INTERNAL;
801
802 void
803 mono_loader_set_error_method_load (const char *class_name, const char *member_name) MONO_INTERNAL;
804
805 void
806 mono_loader_set_error_field_load (MonoClass *klass, const char *member_name) MONO_INTERNAL;
807 void
808 mono_loader_set_error_bad_image (char *msg) MONO_INTERNAL;
809
810 MonoException *
811 mono_loader_error_prepare_exception (MonoLoaderError *error) MONO_INTERNAL;
812
813 MonoLoaderError *
814 mono_loader_get_last_error (void) MONO_INTERNAL;
815
816 void
817 mono_loader_clear_error    (void) MONO_INTERNAL;
818
819 void
820 mono_reflection_init       (void) MONO_INTERNAL;
821
822 void
823 mono_icall_init            (void) MONO_INTERNAL;
824
825 void
826 mono_icall_cleanup         (void) MONO_INTERNAL;
827
828 gpointer
829 mono_method_get_wrapper_data (MonoMethod *method, guint32 id) MONO_INTERNAL;
830
831 void
832 mono_install_stack_walk (MonoStackWalkImpl func) MONO_INTERNAL;
833
834 gboolean
835 mono_metadata_has_generic_params (MonoImage *image, guint32 token) MONO_INTERNAL;
836
837 MonoGenericContainer *
838 mono_metadata_load_generic_params (MonoImage *image, guint32 token,
839                                    MonoGenericContainer *parent_container);
840
841 void
842 mono_metadata_load_generic_param_constraints (MonoImage *image, guint32 token,
843                                               MonoGenericContainer *container);
844
845 MonoMethodSignature*
846 mono_create_icall_signature (const char *sigstr) MONO_INTERNAL;
847
848 MonoJitICallInfo *
849 mono_register_jit_icall (gconstpointer func, const char *name, MonoMethodSignature *sig, gboolean is_save) MONO_INTERNAL;
850
851 void
852 mono_register_jit_icall_wrapper (MonoJitICallInfo *info, gconstpointer wrapper) MONO_INTERNAL;
853
854 MonoJitICallInfo *
855 mono_find_jit_icall_by_name (const char *name) MONO_INTERNAL;
856
857 MonoJitICallInfo *
858 mono_find_jit_icall_by_addr (gconstpointer addr) MONO_INTERNAL;
859
860 gboolean
861 mono_class_set_failure (MonoClass *klass, guint32 ex_type, void *ex_data) MONO_INTERNAL;
862
863 MonoException*
864 mono_class_get_exception_for_failure (MonoClass *klass) MONO_INTERNAL;
865
866 char*
867 mono_type_get_name_full (MonoType *type, MonoTypeNameFormat format) MONO_INTERNAL;
868
869 char*
870 mono_type_get_full_name (MonoClass *class) MONO_INTERNAL;
871
872 MonoArrayType *mono_dup_array_type (MonoArrayType *a) MONO_INTERNAL;
873 MonoMethodSignature *mono_metadata_signature_deep_dup (MonoMethodSignature *sig) MONO_INTERNAL;
874
875 void
876 mono_image_init_name_cache (MonoImage *image);
877
878 gboolean mono_class_is_nullable (MonoClass *klass) MONO_INTERNAL;
879 MonoClass *mono_class_get_nullable_param (MonoClass *klass) MONO_INTERNAL;
880
881 /* object debugging functions, for use inside gdb */
882 void mono_object_describe        (MonoObject *obj);
883 void mono_object_describe_fields (MonoObject *obj);
884 void mono_value_describe_fields  (MonoClass* klass, const char* addr);
885 void mono_class_describe_statics (MonoClass* klass);
886
887 /*Enum validation related functions*/
888 gboolean
889 mono_type_is_valid_enum_basetype (MonoType * type);
890
891 gboolean
892 mono_class_is_valid_enum (MonoClass *klass);
893
894 MonoType *
895 mono_type_get_full        (MonoImage *image, guint32 type_token, MonoGenericContext *context) MONO_INTERNAL;
896
897 gboolean
898 mono_generic_class_is_generic_type_definition (MonoGenericClass *gklass) MONO_INTERNAL;
899
900 MonoType*
901 mono_type_get_basic_type_from_generic (MonoType *type) MONO_INTERNAL;
902
903 gboolean
904 mono_class_generic_sharing_enabled (MonoClass *class) MONO_INTERNAL;
905
906 #endif /* __MONO_METADATA_CLASS_INTERBALS_H__ */
907