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