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