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, gboolean do_il_offset, 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,
30 MONO_WRAPPER_XDOMAIN_INVOKE,
31 MONO_WRAPPER_XDOMAIN_DISPATCH,
34 MONO_WRAPPER_SYNCHRONIZED,
35 MONO_WRAPPER_DYNAMIC_METHOD,
37 MONO_WRAPPER_CASTCLASS,
38 MONO_WRAPPER_PROXY_ISINST,
39 MONO_WRAPPER_STELEMREF,
45 MONO_REMOTING_TARGET_UNKNOWN,
46 MONO_REMOTING_TARGET_APPDOMAIN
50 guint16 flags; /* method flags */
51 guint16 iflags; /* method implementation flags */
54 MonoMethodSignature *signature;
55 gpointer info; /* runtime info */
56 /* name is useful mostly for debugging */
58 /* this is used by the inlining algorithm */
59 unsigned int inline_info:1;
60 unsigned int uses_this:1;
61 unsigned int wrapper_type:5;
62 unsigned int string_ctor:1;
63 unsigned int save_lmf:1;
64 unsigned int dynamic:1; /* created & destroyed during runtime */
65 unsigned int is_inflated:1;
69 struct _MonoMethodNormal {
71 MonoGenericContainer *generic_container;
72 MonoMethodHeader *header;
75 struct _MonoMethodWrapper {
76 MonoMethodNormal method;
80 struct _MonoMethodInflated {
81 MonoMethodNormal nmethod;
82 MonoGenericContext *context;
83 MonoMethod *declaring;
84 MonoMethodInflated *inflated;
87 struct _MonoMethodPInvoke {
90 /* add marshal info */
91 guint16 piflags; /* pinvoke flags */
92 guint16 implmap_idx; /* index into IMPLMAP */
96 MonoType *generic_type;
97 gpointer reflection_info;
101 * MonoClassField is just a runtime representation of the metadata for
102 * field, it doesn't contain the data directly. Static fields are
103 * stored in MonoVTable->data. Instance fields are allocated in the
104 * objects after the object header.
106 struct _MonoClassField {
107 /* Type of the field */
110 /* If this is an instantiated generic type, this is the
111 * "original" type, ie. the MONO_TYPE_VAR or MONO_TYPE_GENERICINST
112 * it was instantiated from.
114 MonoInflatedField *generic_info;
117 * Offset where this field is stored; if it is an instance
118 * field, it's the offset from the start of the object, if
119 * it's static, it's from the start of the memory chunk
120 * allocated for statics for the class.
127 * If the field is constant, pointer to the metadata constant
129 * If the field has an RVA flag, pointer to the data.
134 /* Type where the field was defined */
138 * If the field is constant, the type of the constant.
140 MonoTypeEnum def_type;
143 /* a field is ignored if it's named "_Deleted" and it has the specialname and rtspecialname flags set */
144 #define mono_field_is_deleted(field) ((field)->name[0] == '_' && ((field)->type->attrs & 0x600) && (strcmp ((field)->name, "_Deleted") == 0))
147 MonoClassField *field;
149 MonoMarshalSpec *mspec;
155 MonoMarshalField fields [MONO_ZERO_LEN_ARRAY];
158 struct _MonoProperty {
179 /* The underlying type of the enum */
180 MonoType *enum_basetype;
181 /* element class for arrays and enum */
182 MonoClass *element_class;
183 /* used for subtype checks */
184 MonoClass *cast_class;
185 /* array dimension */
189 /* We use init_pending to detect cyclic calls to mono_class_init */
190 guint init_pending : 1;
192 /* A class contains static and non static data. Static data can be
193 * of the same type as the class itselfs, but it does not influence
194 * the instance size of the class. To avoid cyclic calls to
195 * mono_class_init (from mono_class_instance_size ()) we first
196 * initialise all non static fields. After that we set size_inited
197 * to 1, because we know the instance size now. After that we
198 * initialise all static fields.
200 guint size_inited : 1;
201 guint valuetype : 1; /* derives from System.ValueType */
202 guint enumtype : 1; /* derives from System.Enum */
203 guint blittable : 1; /* class is blittable */
204 guint unicode : 1; /* class uses unicode char when marshalled */
205 guint wastypebuilder : 1; /* class was created at runtime from a TypeBuilder */
208 guint packing_size : 4;
210 guint ghcimpl : 1; /* class has its own GetHashCode impl */
211 guint has_finalize : 1; /* class has its own Finalize impl */
212 guint marshalbyref : 1; /* class is a MarshalByRefObject */
213 guint contextbound : 1; /* class is a ContextBoundObject */
214 guint delegate : 1; /* class is a Delegate */
215 guint gc_descr_inited : 1; /* gc_descr is initialized */
216 guint dummy : 1; /* temporary hack */
217 guint32 declsec_flags; /* declarative security attributes flags */
220 MonoClass *nested_in;
221 GList *nested_classes;
225 const char *name_space;
227 guint interface_count;
228 guint interface_id; /* unique inderface id (for interfaces) */
229 guint max_interface_id;
230 gint *interface_offsets;
231 MonoClass **interfaces;
233 /* for fast subtype checks */
235 MonoClass **supertypes;
238 * Computed object instance size, total.
242 int vtable_size; /* number of slots */
245 * From the TypeDef table
251 } field, method, property, event;
253 /* loaded on demand */
254 MonoMarshalType *marshal_info;
257 * Field information: Type and location from object base
259 MonoClassField *fields;
261 MonoProperty *properties;
265 MonoMethod **methods;
267 /* used as the type of the this argument and when passing the arg by value */
271 MonoGenericClass *generic_class;
272 MonoGenericContainer *generic_container;
274 void *reflection_info;
279 MonoMethod *ptr_to_str;
280 MonoMethod *str_to_ptr;
282 MonoVTable *cached_vtable;
289 * According to comments in gc_gcj.h, this should be the second word in
293 MonoDomain *domain; /* each object/vtable belongs to exactly one domain */
294 guint32 max_interface_id;
295 gpointer *interface_offsets;
296 gpointer data; /* to store static class data */
297 gpointer type; /* System.Type type for klass */
298 guint remote : 1; /* class is remotely activated */
299 guint initialized : 1; /* cctor has been run */
300 /* do not add any fields after vtable, the structure is dynamically extended */
301 gpointer vtable [MONO_ZERO_LEN_ARRAY];
305 * Generic instantiation data type encoding.
307 struct _MonoGenericInst {
311 MonoType **type_argv;
314 struct _MonoGenericClass {
315 MonoGenericInst *inst;
316 MonoClass *container_class;
317 MonoGenericContext *context;
320 guint count_ifaces : 29;
321 guint initialized : 1;
322 guint init_pending : 1;
323 guint is_dynamic : 1;
327 struct _MonoDynamicGenericClass {
328 MonoGenericClass generic_class;
330 MonoMethod **methods;
334 MonoClassField *fields;
335 int count_properties;
336 MonoProperty *properties;
341 struct _MonoGenericMethod {
342 MonoGenericInst *inst;
343 MonoGenericContainer *container;
344 gpointer reflection_info;
347 struct _MonoGenericContext {
348 MonoGenericContainer *container;
349 MonoGenericClass *gclass;
350 MonoGenericMethod *gmethod;
353 struct _MonoGenericContainer {
354 MonoGenericContext context;
355 MonoGenericContainer *parent;
356 GHashTable *method_hash;
360 int is_signature : 1;
361 MonoGenericParam *type_params;
364 struct _MonoGenericParam {
365 MonoGenericContainer *owner;
371 MonoClass** constraints; /* NULL means end of list */
377 gconstpointer wrapper;
378 MonoMethodSignature *sig;
381 #define mono_class_has_parent(klass,parent) (((klass)->idepth >= (parent)->idepth) && ((klass)->supertypes [(parent)->idepth - 1] == (parent)))
384 gulong new_object_count;
385 gulong initialized_class_count;
386 gulong used_class_count;
387 gulong class_vtable_size;
388 gulong class_static_data_size;
389 gulong generic_instance_count;
390 gulong generic_class_count;
391 gulong inflated_method_count;
392 gulong inflated_method_count_2;
393 gulong inflated_type_count;
394 gulong generics_metadata_size;
398 extern MonoStats mono_stats;
400 typedef gpointer (*MonoTrampoline) (MonoMethod *method);
401 typedef gpointer (*MonoRemotingTrampoline) (MonoMethod *method, MonoRemotingTarget target);
403 typedef gpointer (*MonoLookupDynamicToken) (MonoImage *image, guint32 token);
406 mono_classes_init (void);
409 mono_class_layout_fields (MonoClass *klass);
412 mono_class_setup_vtable (MonoClass *klass, MonoMethod **overrides, int onum);
415 mono_class_setup_mono_type (MonoClass *klass);
418 mono_class_setup_parent (MonoClass *klass, MonoClass *parent);
421 mono_class_setup_supertypes (MonoClass *klass);
424 mono_class_get_implemented_interfaces (MonoClass *klass);
427 mono_class_is_open_constructed_type (MonoType *t);
430 mono_class_get_overrides (MonoImage *image, guint32 type_token, gint32 *num_overrides);
433 mono_class_needs_cctor_run (MonoClass *klass, MonoMethod *caller);
436 mono_install_trampoline (MonoTrampoline func);
439 mono_install_remoting_trampoline (MonoRemotingTrampoline func);
442 mono_lookup_dynamic_token (MonoImage *image, guint32 token);
445 mono_install_lookup_dynamic_token (MonoLookupDynamicToken func);
448 mono_class_create_generic (MonoGenericClass *gclass);
451 mono_class_create_generic_2 (MonoGenericClass *gclass);
455 MonoClass *object_class;
456 MonoClass *byte_class;
457 MonoClass *void_class;
458 MonoClass *boolean_class;
459 MonoClass *sbyte_class;
460 MonoClass *int16_class;
461 MonoClass *uint16_class;
462 MonoClass *int32_class;
463 MonoClass *uint32_class;
464 MonoClass *int_class;
465 MonoClass *uint_class;
466 MonoClass *int64_class;
467 MonoClass *uint64_class;
468 MonoClass *single_class;
469 MonoClass *double_class;
470 MonoClass *char_class;
471 MonoClass *string_class;
472 MonoClass *enum_class;
473 MonoClass *array_class;
474 MonoClass *delegate_class;
475 MonoClass *multicastdelegate_class;
476 MonoClass *asyncresult_class;
477 MonoClass *waithandle_class;
478 MonoClass *typehandle_class;
479 MonoClass *fieldhandle_class;
480 MonoClass *methodhandle_class;
481 MonoClass *monotype_class;
482 MonoClass *exception_class;
483 MonoClass *threadabortexception_class;
484 MonoClass *thread_class;
485 MonoClass *transparent_proxy_class;
486 MonoClass *real_proxy_class;
487 MonoClass *mono_method_message_class;
488 MonoClass *appdomain_class;
489 MonoClass *field_info_class;
490 MonoClass *method_info_class;
491 MonoClass *stringbuilder_class;
492 MonoClass *math_class;
493 MonoClass *stack_frame_class;
494 MonoClass *stack_trace_class;
495 MonoClass *marshal_class;
496 MonoClass *iserializeable_class;
497 MonoClass *serializationinfo_class;
498 MonoClass *streamingcontext_class;
499 MonoClass *typed_reference_class;
500 MonoClass *argumenthandle_class;
501 MonoClass *marshalbyrefobject_class;
502 MonoClass *monitor_class;
503 MonoClass *iremotingtypeinfo_class;
504 MonoClass *runtimesecurityframe_class;
507 extern MonoDefaults mono_defaults;
510 mono_loader_init (void);
513 mono_loader_lock (void);
516 mono_loader_unlock (void);
519 mono_init_icall (void);
522 mono_method_get_wrapper_data (MonoMethod *method, guint32 id);
525 mono_install_stack_walk (MonoStackWalkImpl func);
527 MonoGenericContainer *mono_metadata_load_generic_params (MonoImage *image, guint32 token,
528 MonoGenericContainer *parent_container);
531 mono_create_icall_signature (const char *sigstr);
534 mono_register_jit_icall (gconstpointer func, const char *name, MonoMethodSignature *sig, gboolean is_save);
537 mono_register_jit_icall_wrapper (MonoJitICallInfo *info, gconstpointer wrapper);
540 mono_find_jit_icall_by_name (const char *name);
543 mono_find_jit_icall_by_addr (gconstpointer addr);
546 mono_class_inflate_generic_signature (MonoImage *image, MonoMethodSignature *sig, MonoGenericContext *context);
549 mono_get_shared_generic_class (MonoGenericContainer *container, gboolean is_dynamic);
551 #endif /* __MONO_METADATA_CLASS_INTERBALS_H__ */