1 #ifndef __MONO_METADATA_CLASS_INTERBALS_H__
2 #define __MONO_METADATA_CLASS_INTERBALS_H__
4 #include <mono/metadata/class.h>
5 #include <mono/io-layer/io-layer.h>
7 #define MONO_CLASS_IS_ARRAY(c) ((c)->rank)
9 #define MONO_DEFAULT_SUPERTABLE_SIZE 6
11 extern gboolean mono_print_vtable;
13 typedef void (*MonoStackWalkImpl) (MonoStackWalk func, gpointer user_data);
15 typedef struct _MonoMethodNormal MonoMethodNormal;
16 typedef struct _MonoMethodWrapper MonoMethodWrapper;
17 typedef struct _MonoMethodInflated MonoMethodInflated;
18 typedef struct _MonoMethodPInvoke MonoMethodPInvoke;
22 MONO_WRAPPER_DELEGATE_INVOKE,
23 MONO_WRAPPER_DELEGATE_BEGIN_INVOKE,
24 MONO_WRAPPER_DELEGATE_END_INVOKE,
25 MONO_WRAPPER_RUNTIME_INVOKE,
26 MONO_WRAPPER_NATIVE_TO_MANAGED,
27 MONO_WRAPPER_MANAGED_TO_NATIVE,
28 MONO_WRAPPER_REMOTING_INVOKE,
29 MONO_WRAPPER_REMOTING_INVOKE_WITH_CHECK,
32 MONO_WRAPPER_SYNCHRONIZED,
33 MONO_WRAPPER_DYNAMIC_METHOD,
38 guint16 flags; /* method flags */
39 guint16 iflags; /* method implementation flags */
42 MonoMethodSignature *signature;
44 gpointer info; /* runtime info */
45 gpointer remoting_tramp;
47 /* name is useful mostly for debugging */
49 /* this is used by the inlining algorithm */
50 unsigned int inline_info:1;
51 unsigned int uses_this:1;
52 unsigned int wrapper_type:4;
53 unsigned int string_ctor:1;
54 unsigned int save_lmf:1;
58 struct _MonoMethodNormal {
60 MonoMethodHeader *header;
63 struct _MonoMethodWrapper {
64 MonoMethodNormal method;
68 struct _MonoMethodInflated {
69 MonoMethodNormal nmethod;
70 MonoGenericContext *context;
71 MonoMethod *declaring;
74 struct _MonoMethodPInvoke {
77 /* add marshal info */
78 guint16 piflags; /* pinvoke flags */
79 guint16 implmap_idx; /* index into IMPLMAP */
88 MonoType *generic_type;
89 gpointer reflection_info;
93 * MonoClassField is just a runtime representation of the metadata for
94 * field, it doesn't contain the data directly. Static fields are
95 * stored in MonoVTable->data. Instance fields are allocated in the
96 * objects after the object header.
98 struct _MonoClassField {
99 /* Type of the field */
102 /* If this is an instantiated generic type, this is the
103 * "original" type, ie. the MONO_TYPE_VAR or MONO_TYPE_GENERICINST
104 * it was instantiated from.
106 MonoInflatedField *generic_info;
109 * Offset where this field is stored; if it is an instance
110 * field, it's the offset from the start of the object, if
111 * it's static, it's from the start of the memory chunk
112 * allocated for statics for the class.
119 * Pointer to the data (from the RVA address, valid only for
120 * fields with the has rva flag).
124 /* Type where the field was defined */
128 * If the field is constant, pointer to the metadata where the
129 * constant value can be loaded. Initialized lazily during vtable creation.
131 MonoConstant *def_value;
134 /* a field is ignored if it's named "_Deleted" and it has the specialname and rtspecialname flags set */
135 #define mono_field_is_deleted(field) ((field)->name[0] == '_' && ((field)->type->attrs & 0x600) && (strcmp ((field)->name, "_Deleted") == 0))
138 MonoClassField *field;
140 MonoMarshalSpec *mspec;
146 MonoMarshalField fields [MONO_ZERO_LEN_ARRAY];
149 struct _MonoProperty {
170 /* The underlying type of the enum */
171 MonoType *enum_basetype;
172 /* element class for arrays and enum */
173 MonoClass *element_class;
174 /* used for subtype checks */
175 MonoClass *cast_class;
176 /* array dimension */
180 /* We use init_pending to detect cyclic calls to mono_class_init */
181 guint init_pending : 1;
183 /* A class contains static and non static data. Static data can be
184 * of the same type as the class itselfs, but it does not influence
185 * the instance size of the class. To avoid cyclic calls to
186 * mono_class_init (from mono_class_instance_size ()) we first
187 * initialise all non static fields. After that we set size_inited
188 * to 1, because we know the instance size now. After that we
189 * initialise all static fields.
191 guint size_inited : 1;
192 guint valuetype : 1; /* derives from System.ValueType */
193 guint enumtype : 1; /* derives from System.Enum */
194 guint blittable : 1; /* class is blittable */
195 guint unicode : 1; /* class uses unicode char when marshalled */
196 guint wastypebuilder : 1; /* class was created at runtime from a TypeBuilder */
199 guint packing_size : 4;
201 guint ghcimpl : 1; /* class has its own GetHashCode impl */
202 guint has_finalize : 1; /* class has its own Finalize impl */
203 guint marshalbyref : 1; /* class is a MarshalByRefObject */
204 guint contextbound : 1; /* class is a ContextBoundObject */
205 guint delegate : 1; /* class is a Delegate */
206 guint gc_descr_inited : 1; /* gc_descr is initialized */
207 guint dummy : 1; /* temporary hack */
210 MonoClass *nested_in;
211 GList *nested_classes;
215 const char *name_space;
217 guint interface_count;
218 guint interface_id; /* unique inderface id (for interfaces) */
219 guint max_interface_id;
220 gint *interface_offsets;
221 MonoClass **interfaces;
223 /* for fast subtype checks */
225 MonoClass **supertypes;
228 * Computed object instance size, total.
232 int vtable_size; /* number of slots */
235 * From the TypeDef table
241 } field, method, property, event;
243 /* loaded on demand */
244 MonoMarshalType *marshal_info;
247 * Field information: Type and location from object base
249 MonoClassField *fields;
251 MonoProperty *properties;
255 MonoMethod **methods;
257 /* used as the type of the this argument and when passing the arg by value */
261 MonoGenericInst *generic_inst;
262 MonoGenericParam *gen_params;
263 guint16 num_gen_params;
265 void *reflection_info;
270 MonoMethod *ptr_to_str;
271 MonoMethod *str_to_ptr;
273 MonoVTable *cached_vtable;
280 * According to comments in gc_gcj.h, this should be the second word in
284 MonoDomain *domain; /* each object/vtable belongs to exactly one domain */
285 guint max_interface_id;
286 gpointer *interface_offsets;
287 gpointer data; /* to store static class data */
288 gpointer type; /* System.Type type for klass */
289 guint remote : 1; /* class is remotely activated */
290 guint initialized : 1; /* cctor has been run */
291 /* do not add any fields after vtable, the structure is dynamically extended */
292 gpointer vtable [MONO_ZERO_LEN_ARRAY];
296 * Generic instantiation data type encoding.
298 struct _MonoGenericInst {
299 MonoGenericContext *context;
304 MonoType *generic_type;
305 MonoDynamicGenericInst *dynamic_info;
307 MonoType **type_argv;
309 guint initialized : 1;
310 guint init_pending : 1;
311 guint is_dynamic : 1;
314 struct _MonoDynamicGenericInst {
316 MonoMethod **methods;
320 MonoClassField *fields;
321 int count_properties;
322 MonoProperty *properties;
327 struct _MonoGenericMethod {
328 gpointer reflection_info;
330 MonoType **mtype_argv;
334 struct _MonoGenericContext {
335 MonoGenericInst *ginst;
336 MonoGenericMethod *gmethod;
339 struct _MonoGenericParam {
345 MonoClass** constraints; /* NULL means end of list */
348 #define mono_class_has_parent(klass,parent) (((klass)->idepth >= (parent)->idepth) && ((klass)->supertypes [(parent)->idepth - 1] == (parent)))
351 gulong new_object_count;
352 gulong initialized_class_count;
353 gulong used_class_count;
354 gulong class_vtable_size;
355 gulong class_static_data_size;
356 gulong generic_instance_count;
357 gulong inflated_method_count;
358 gulong inflated_type_count;
359 gulong generics_metadata_size;
362 extern MonoStats mono_stats;
364 typedef gpointer (*MonoTrampoline) (MonoMethod *method);
366 typedef gpointer (*MonoLookupDynamicToken) (MonoImage *image, guint32 token);
369 mono_classes_init (void);
372 mono_class_layout_fields (MonoClass *klass);
375 mono_class_setup_vtable (MonoClass *klass, MonoMethod **overrides, int onum);
378 mono_class_setup_mono_type (MonoClass *klass);
381 mono_class_setup_parent (MonoClass *klass, MonoClass *parent);
384 mono_class_setup_supertypes (MonoClass *klass);
387 mono_class_is_open_constructed_type (MonoType *t);
390 mono_class_get_overrides (MonoImage *image, guint32 type_token, gint32 *num_overrides);
393 mono_class_needs_cctor_run (MonoClass *klass, MonoMethod *caller);
396 mono_install_trampoline (MonoTrampoline func);
399 mono_install_remoting_trampoline (MonoTrampoline func);
402 mono_lookup_dynamic_token (MonoImage *image, guint32 token);
405 mono_install_lookup_dynamic_token (MonoLookupDynamicToken func);
409 MonoClass *object_class;
410 MonoClass *byte_class;
411 MonoClass *void_class;
412 MonoClass *boolean_class;
413 MonoClass *sbyte_class;
414 MonoClass *int16_class;
415 MonoClass *uint16_class;
416 MonoClass *int32_class;
417 MonoClass *uint32_class;
418 MonoClass *int_class;
419 MonoClass *uint_class;
420 MonoClass *int64_class;
421 MonoClass *uint64_class;
422 MonoClass *single_class;
423 MonoClass *double_class;
424 MonoClass *char_class;
425 MonoClass *string_class;
426 MonoClass *enum_class;
427 MonoClass *array_class;
428 MonoClass *delegate_class;
429 MonoClass *multicastdelegate_class;
430 MonoClass *asyncresult_class;
431 MonoClass *waithandle_class;
432 MonoClass *typehandle_class;
433 MonoClass *fieldhandle_class;
434 MonoClass *methodhandle_class;
435 MonoClass *monotype_class;
436 MonoClass *exception_class;
437 MonoClass *threadabortexception_class;
438 MonoClass *thread_class;
439 MonoClass *transparent_proxy_class;
440 MonoClass *real_proxy_class;
441 MonoClass *mono_method_message_class;
442 MonoClass *appdomain_class;
443 MonoClass *field_info_class;
444 MonoClass *method_info_class;
445 MonoClass *stringbuilder_class;
446 MonoClass *math_class;
447 MonoClass *stack_frame_class;
448 MonoClass *stack_trace_class;
449 MonoClass *marshal_class;
450 MonoClass *iserializeable_class;
451 MonoClass *serializationinfo_class;
452 MonoClass *streamingcontext_class;
453 MonoClass *typed_reference_class;
454 MonoClass *argumenthandle_class;
455 MonoClass *marshalbyrefobject_class;
456 MonoClass *monitor_class;
457 MonoClass *iremotingtypeinfo_class;
460 extern MonoDefaults mono_defaults;
463 mono_loader_init (void);
466 mono_loader_lock (void);
469 mono_loader_unlock (void);
472 mono_init_icall (void);
475 mono_method_get_wrapper_data (MonoMethod *method, guint32 id);
478 mono_install_stack_walk (MonoStackWalkImpl func);
480 MonoGenericParam *mono_metadata_load_generic_params (MonoImage *image, guint32 token, guint32 *num);
482 #endif /* __MONO_METADATA_CLASS_INTERBALS_H__ */