1 #ifndef __MONO_OBJECT_INTERNALS_H__
2 #define __MONO_OBJECT_INTERNALS_H__
4 #include <mono/metadata/object.h>
5 #include <mono/metadata/threads.h>
6 #include <mono/metadata/reflection.h>
7 #include <mono/metadata/mempool.h>
8 #include <mono/metadata/class-internals.h>
9 #include <mono/io-layer/io-layer.h>
10 #include "mono/utils/mono-compiler.h"
13 * We should find a better place for this stuff. We can't put it in mono-compiler.h,
14 * since that is included by libgc.
17 #define G_LIKELY(a) (a)
18 #define G_UNLIKELY(a) (a)
22 * glib defines this macro and uses it in the definition of G_LIKELY, and thus,
23 * g_assert (). The macro expands to a complex piece of code, preventing some
24 * gcc versions like 4.3.0 from handling the __builtin_expect construct properly,
25 * causing the generation of the unlikely branch into the middle of the code.
27 #ifdef _G_BOOLEAN_EXPR
28 #undef _G_BOOLEAN_EXPR
29 #define _G_BOOLEAN_EXPR(expr) (gsize)(expr)
34 #define mono_assert(expr) G_STMT_START{ \
38 char *msg = g_strdup_printf ("file %s: line %d (%s): " \
39 "assertion failed: (%s)", __FILE__, __LINE__, \
40 __PRETTY_FUNCTION__, #expr); \
41 ex = mono_get_exception_execution_engine (msg); \
43 mono_raise_exception (ex); \
46 #define mono_assert_not_reached() G_STMT_START{ \
48 char *msg = g_strdup_printf ("file %s: line %d (%s): " \
49 "should not be reached", __FILE__, __LINE__, __PRETTY_FUNCTION__); \
50 ex = mono_get_exception_execution_engine (msg); \
52 mono_raise_exception (ex); \
55 #define mono_assert(expr) G_STMT_START{ \
59 char *msg = g_strdup_printf ("file %s: line %d: " \
60 "assertion failed: (%s)", __FILE__, __LINE__, \
62 ex = mono_get_exception_execution_engine (msg); \
64 mono_raise_exception (ex); \
67 #define mono_assert_not_reached() G_STMT_START{ \
69 char *msg = g_strdup_printf ("file %s: line %d): " \
70 "should not be reached", __FILE__, __LINE__); \
71 ex = mono_get_exception_execution_engine (msg); \
73 mono_raise_exception (ex); \
77 #define mono_assert(expr) g_assert(expr)
78 #define mono_assert_not_reached() g_assert_not_reached()
81 #define MONO_CHECK_ARG(arg, expr) G_STMT_START{ \
85 char *msg = g_strdup_printf ("assertion `%s' failed", \
87 if (arg) {} /* check if the name exists */ \
88 ex = mono_get_exception_argument (#arg, msg); \
90 mono_raise_exception (ex); \
93 #define MONO_CHECK_ARG_NULL(arg) G_STMT_START{ \
97 if (arg) {} /* check if the name exists */ \
98 ex = mono_get_exception_argument_null (#arg); \
99 mono_raise_exception (ex); \
102 /* 16 == default capacity */
103 #define mono_stringbuilder_capacity(sb) ((sb)->str ? ((sb)->str->length) : 16)
106 * Macros which cache the results of lookups locally.
107 * These should be used instead of the original versions, if the __GNUC__
108 * restriction is acceptable.
113 /* namespace and name should be a constant */
114 #define mono_class_from_name_cached(image,namespace,name) ({ \
115 static MonoClass *tmp_klass; \
117 tmp_klass = mono_class_from_name ((image), (namespace), (name)); \
118 g_assert (tmp_klass); \
121 /* name should be a compile-time constant */
122 #define mono_class_get_field_from_name_cached(klass,name) ({ \
123 static MonoClassField *tmp_field; \
125 tmp_field = mono_class_get_field_from_name ((klass), (name)); \
126 g_assert (tmp_field); \
129 /* eclass should be a run-time constant */
130 #define mono_array_class_get_cached(eclass,rank) ({ \
131 static MonoClass *tmp_klass; \
133 tmp_klass = mono_array_class_get ((eclass), (rank)); \
134 g_assert (tmp_klass); \
137 /* eclass should be a run-time constant */
138 #define mono_array_new_cached(domain, eclass, size) mono_array_new_specific (mono_class_vtable ((domain), mono_array_class_get_cached ((eclass), 1)), (size))
142 #define mono_class_from_name_cached(image,namespace,name) mono_class_from_name ((image), (namespace), (name))
143 #define mono_class_get_field_from_name_cached(klass,name) mono_class_get_field_from_name ((klass), (name))
144 #define mono_array_class_get_cached(eclass,rank) mono_array_class_get ((eclass), (rank))
145 #define mono_array_new_cached(domain, eclass, size) mono_array_new_specific (mono_class_vtable ((domain), mono_array_class_get_cached ((eclass), 1)), (size))
151 MonoObject *identity;
152 } MonoMarshalByRefObject;
154 /* This is a copy of System.AppDomain */
155 struct _MonoAppDomain {
156 MonoMarshalByRefObject mbr;
164 MonoString *cached_str;
176 } MonoArgumentHandle;
179 MonoMethodSignature *sig;
185 struct _MonoException {
187 /* Stores the IPs and the generic sharing infos
188 (vtable/MRGCTX) of the frames. */
189 MonoArray *trace_ips;
190 MonoObject *inner_ex;
192 MonoString *help_link;
193 MonoString *class_name;
194 MonoString *stack_trace;
195 MonoString *remote_stack_trace;
196 gint32 remote_stack_index;
204 } MonoSystemException;
207 MonoSystemException base;
208 MonoString *param_name;
209 } MonoArgumentException;
212 MonoSystemException base;
214 MonoString *type_name;
215 } MonoTypeLoadException;
219 MonoObject *async_state;
221 MonoObject *async_delegate;
223 MonoObject *object_data;
224 MonoBoolean sync_completed;
225 MonoBoolean completed;
226 MonoBoolean endinvoke_called;
227 MonoObject *async_callback;
228 MonoObject *execution_context;
229 MonoObject *original_context;
233 MonoMarshalByRefObject object;
235 MonoBoolean disposed;
238 /* This is a copy of System.Runtime.Remoting.Messaging.CallType */
241 CallType_BeginInvoke = 1,
242 CallType_EndInvoke = 2,
246 /* This corresponds to System.Type */
247 struct _MonoReflectionType {
253 MonoReflectionType type;
254 MonoObject *type_info;
255 } MonoReflectionMonoType;
259 MonoReflectionType *class_to_proxy;
261 MonoObject *unwrapped_server;
262 gint32 target_domain_id;
263 MonoString *target_uri;
264 MonoObject *object_identity;
266 MonoObject *stub_data;
270 MonoMarshalByRefObject object;
272 GHashTable* itf_hash;
276 MonoRealProxy real_proxy;
277 MonoComObject *com_object;
279 } MonoComInteropProxy;
284 MonoRemoteClass *remote_class;
285 MonoBoolean custom_type_info;
286 } MonoTransparentProxy;
290 MonoReflectionMethod *method;
293 MonoArray *arg_types;
297 MonoAsyncResult *async_result;
304 gint32 native_offset;
305 MonoReflectionMethod *method;
306 MonoString *filename;
309 MonoString *internal_method_name;
314 int lock_thread_id; /* to be used as the pre-shifted thread id in thin locks */
316 MonoArray *cached_culture_info;
318 MonoBoolean threadpool_thread;
322 MonoException *abort_exc;
323 int abort_state_handle;
324 guint64 tid; /* This is accessed as a gsize in the code (so it can hold a 64bit pointer on systems that need it), but needs to reserve 64 bits of space on all machines as it corresponds to a field in managed code */
327 gpointer *static_data;
330 MonoAppContext *current_appcontext;
332 MonoObject *start_obj;
333 GSList *appdomain_refs;
334 /* This is modified using atomic ops, so keep it a gint32 */
335 gint32 interruption_requested;
336 gpointer suspend_event;
337 gpointer suspended_event;
338 gpointer resume_event;
339 CRITICAL_SECTION *synch_cs;
340 guint8* serialized_culture_info;
341 guint32 serialized_culture_info_len;
342 guint8* serialized_ui_culture_info;
343 guint32 serialized_ui_culture_info_len;
344 MonoBoolean thread_dump_requested;
345 gpointer end_stack; /* This is only used when running in the debugger. */
346 MonoBoolean thread_interrupt_requested;
347 guint8 apartment_state;
348 gint32 critical_region_level;
349 guint32 small_id; /* A small, unique id, used for the hazard pointer table. */
350 MonoThreadManageCallback manage_callback;
351 MonoException *pending_exception;
352 MonoObject *ec_to_set;
354 * These fields are used to avoid having to increment corlib versions
355 * when a new field is added to the unmanaged MonoThread structure.
357 gpointer interrupt_on_stop;
366 MonoReflectionType *type;
368 } MonoSerializationEntry;
372 MonoObject *additional;
373 } MonoStreamingContext;
377 MonoBoolean readOnly;
378 MonoString *AMDesignator;
379 MonoString *PMDesignator;
380 MonoString *DateSeparator;
381 MonoString *TimeSeparator;
382 MonoString *ShortDatePattern;
383 MonoString *LongDatePattern;
384 MonoString *ShortTimePattern;
385 MonoString *LongTimePattern;
386 MonoString *MonthDayPattern;
387 MonoString *YearMonthPattern;
388 MonoString *FullDateTimePattern;
389 MonoString *RFC1123Pattern;
390 MonoString *SortableDateTimePattern;
391 MonoString *UniversalSortableDateTimePattern;
392 guint32 FirstDayOfWeek;
393 MonoObject *Calendar;
394 guint32 CalendarWeekRule;
395 MonoArray *AbbreviatedDayNames;
397 MonoArray *MonthNames;
398 MonoArray *AbbreviatedMonthNames;
399 MonoArray *ShortDatePatterns;
400 MonoArray *LongDatePatterns;
401 MonoArray *ShortTimePatterns;
402 MonoArray *LongTimePatterns;
403 MonoArray *MonthDayPatterns;
404 MonoArray *YearMonthPatterns;
405 MonoArray *shortDayNames;
406 } MonoDateTimeFormatInfo;
411 MonoBoolean readOnly;
412 MonoString *decimalFormats;
413 MonoString *currencyFormats;
414 MonoString *percentFormats;
415 MonoString *digitPattern;
416 MonoString *zeroPattern;
417 gint32 currencyDecimalDigits;
418 MonoString *currencyDecimalSeparator;
419 MonoString *currencyGroupSeparator;
420 MonoArray *currencyGroupSizes;
421 gint32 currencyNegativePattern;
422 gint32 currencyPositivePattern;
423 MonoString *currencySymbol;
424 MonoString *naNSymbol;
425 MonoString *negativeInfinitySymbol;
426 MonoString *negativeSign;
427 guint32 numberDecimalDigits;
428 MonoString *numberDecimalSeparator;
429 MonoString *numberGroupSeparator;
430 MonoArray *numberGroupSizes;
431 gint32 numberNegativePattern;
432 gint32 percentDecimalDigits;
433 MonoString *percentDecimalSeparator;
434 MonoString *percentGroupSeparator;
435 MonoArray *percentGroupSizes;
436 gint32 percentNegativePattern;
437 gint32 percentPositivePattern;
438 MonoString *percentSymbol;
439 MonoString *perMilleSymbol;
440 MonoString *positiveInfinitySymbol;
441 MonoString *positiveSign;
442 } MonoNumberFormatInfo;
447 MonoString *icu_name;
448 gpointer ICU_collator;
453 MonoBoolean is_read_only;
456 gint32 specific_lcid;
457 gint32 datetime_index;
459 MonoBoolean use_user_override;
460 MonoNumberFormatInfo *number_format;
461 MonoDateTimeFormatInfo *datetime_format;
462 MonoObject *textinfo;
464 MonoString *displayname;
465 MonoString *englishname;
466 MonoString *nativename;
467 MonoString *iso3lang;
468 MonoString *iso2lang;
469 MonoString *icu_name;
470 MonoString *win3lang;
471 MonoString *territory;
472 MonoCompareInfo *compareinfo;
473 const gint32 *calendar_data;
474 const void* text_info_data;
480 MonoString *iso2name;
481 MonoString *iso3name;
482 MonoString *win3name;
483 MonoString *english_name;
484 MonoString *currency_symbol;
485 MonoString *iso_currency_symbol;
486 MonoString *currency_english_name;
500 } MonoInterfaceTypeAttribute;
503 * Callbacks supplied by the runtime and called by the modules in metadata/
504 * This interface is easier to extend than adding a new function type +
505 * a new 'install' function for every callback.
508 gpointer (*create_ftnptr) (MonoDomain *domain, gpointer addr);
509 gpointer (*get_addr_from_ftnptr) (gpointer descr);
510 } MonoRuntimeCallbacks;
512 /* used to free a dynamic method */
513 typedef void (*MonoFreeMethodFunc) (MonoDomain *domain, MonoMethod *method);
515 /* Used to initialize the method pointers inside vtables */
516 typedef gboolean (*MonoInitVTableFunc) (MonoVTable *vtable);
518 void mono_set_pending_exception (MonoException *exc) MONO_INTERNAL;
520 /* remoting and async support */
523 mono_async_result_new (MonoDomain *domain, HANDLE handle,
524 MonoObject *state, gpointer data, MonoObject *object_data) MONO_INTERNAL;
527 mono_wait_handle_new (MonoDomain *domain, HANDLE handle) MONO_INTERNAL;
530 mono_wait_handle_get_handle (MonoWaitHandle *handle) MONO_INTERNAL;
533 mono_message_init (MonoDomain *domain, MonoMethodMessage *this_obj,
534 MonoReflectionMethod *method, MonoArray *out_args) MONO_INTERNAL;
537 mono_remoting_invoke (MonoObject *real_proxy, MonoMethodMessage *msg,
538 MonoObject **exc, MonoArray **out_args) MONO_INTERNAL;
541 mono_message_invoke (MonoObject *target, MonoMethodMessage *msg,
542 MonoObject **exc, MonoArray **out_args) MONO_INTERNAL;
545 mono_method_call_message_new (MonoMethod *method, gpointer *params, MonoMethod *invoke,
546 MonoDelegate **cb, MonoObject **state) MONO_INTERNAL;
549 mono_method_return_message_restore (MonoMethod *method, gpointer *params, MonoArray *out_args) MONO_INTERNAL;
552 mono_delegate_ctor_with_method (MonoObject *this, MonoObject *target, gpointer addr, MonoMethod *method) MONO_INTERNAL;
555 mono_delegate_ctor (MonoObject *this_obj, MonoObject *target, gpointer addr) MONO_INTERNAL;
558 mono_class_get_allocation_ftn (MonoVTable *vtable, gboolean for_box, gboolean *pass_size_in_words) MONO_INTERNAL;
561 mono_runtime_free_method (MonoDomain *domain, MonoMethod *method) MONO_INTERNAL;
563 /* runtime initialization functions */
564 typedef void (*MonoExceptionFunc) (MonoException *ex);
567 mono_install_handler (MonoExceptionFunc func) MONO_INTERNAL;
570 mono_install_runtime_invoke (MonoInvokeFunc func) MONO_INTERNAL;
573 mono_install_compile_method (MonoCompileFunc func) MONO_INTERNAL;
576 mono_install_free_method (MonoFreeMethodFunc func) MONO_INTERNAL;
579 mono_install_callbacks (MonoRuntimeCallbacks *cbs) MONO_INTERNAL;
582 mono_type_initialization_init (void) MONO_INTERNAL;
585 mono_type_initialization_cleanup (void) MONO_INTERNAL;
588 mono_thread_get_tls_key (void) MONO_INTERNAL;
591 mono_thread_get_tls_offset (void) MONO_INTERNAL;
594 mono_domain_get_tls_key (void) MONO_INTERNAL;
597 mono_domain_get_tls_offset (void) MONO_INTERNAL;
599 /* Reflection and Reflection.Emit support */
602 * Handling System.Type objects:
604 * Fields defined as System.Type in managed code should be defined as MonoObject*
605 * in unmanaged structures, and the monotype_cast () function should be used for
606 * casting them to MonoReflectionType* to avoid crashes/security issues when
607 * encountering instances of user defined subclasses of System.Type.
610 #define IS_MONOTYPE(obj) (!(obj) || (((MonoObject*)(obj))->vtable->klass->image == mono_defaults.corlib && ((MonoReflectionType*)(obj))->type != NULL))
613 * Make sure the argument, which should be a System.Type is a System.MonoType object
614 * or equivalent, and not an instance of
615 * a user defined subclass of System.Type. This should be used in places were throwing
616 * an exception is safe.
618 #define CHECK_MONOTYPE(obj) do { \
619 if (!IS_MONOTYPE (obj)) \
620 mono_raise_exception (mono_get_exception_not_supported ("User defined subclasses of System.Type are not yet supported")); \
623 /* This should be used for accessing members of Type[] arrays */
624 #define mono_type_array_get(arr,index) monotype_cast (mono_array_get ((arr), gpointer, (index)))
627 * Cast an object to MonoReflectionType, making sure it is a System.MonoType or
630 static inline MonoReflectionType*
631 monotype_cast (MonoObject *obj)
633 g_assert (IS_MONOTYPE (obj));
635 return (MonoReflectionType*)obj;
639 * The following structure must match the C# implementation in our corlib.
642 struct _MonoReflectionMethod {
646 MonoReflectionType *reftype;
649 typedef struct _MonoReflectionGenericMethod MonoReflectionGenericMethod;
650 struct _MonoReflectionGenericMethod {
651 MonoReflectionMethod method;
654 struct _MonoDelegate {
656 /* The compiled code of the target method */
658 /* The invoke code */
659 gpointer invoke_impl;
662 gpointer delegate_trampoline;
664 * If non-NULL, this points to a memory location which stores the address of
665 * the compiled code of the method, or NULL if it is not yet compiled.
667 guint8 **method_code;
668 MonoReflectionMethod *method_info;
669 MonoReflectionMethod *original_method_info;
673 typedef struct _MonoMulticastDelegate MonoMulticastDelegate;
674 struct _MonoMulticastDelegate {
675 MonoDelegate delegate;
676 MonoMulticastDelegate *prev;
679 struct _MonoReflectionField {
682 MonoClassField *field;
684 MonoReflectionType *type;
688 struct _MonoReflectionProperty {
691 MonoProperty *property;
694 /*This is System.EventInfo*/
695 struct _MonoReflectionEvent {
697 MonoObject *cached_add_event;
701 MonoReflectionEvent object;
704 } MonoReflectionMonoEvent;
708 MonoReflectionType *ClassImpl;
709 MonoObject *DefaultValueImpl;
710 MonoObject *MemberImpl;
711 MonoString *NameImpl;
714 MonoObject *MarshalAsImpl;
715 } MonoReflectionParameter;
717 struct _MonoReflectionMethodBody {
722 MonoBoolean init_locals;
723 guint32 local_var_sig_token;
727 struct _MonoReflectionAssembly {
729 MonoAssembly *assembly;
730 MonoObject *resolve_event_holder;
732 MonoObject *evidence; /* Evidence */
733 MonoObject *minimum; /* PermissionSet - for SecurityAction.RequestMinimum */
734 MonoObject *optional; /* PermissionSet - for SecurityAction.RequestOptional */
735 MonoObject *refuse; /* PermissionSet - for SecurityAction.RequestRefuse */
736 MonoObject *granted; /* PermissionSet - for the resolved assembly granted permissions */
737 MonoObject *denied; /* PermissionSet - for the resolved assembly denied permissions */
739 MonoBoolean from_byte_array;
744 MonoReflectionType *utype;
750 MonoReflectionType *parent;
751 MonoReflectionType *ret;
758 MonoReflectionType *parent;
760 MonoReflectionMethod *get;
761 MonoReflectionMethod *set;
766 MonoReflectionType *declaring_type;
767 MonoReflectionType *reflected_type;
769 MonoReflectionMethod *add_method;
770 MonoReflectionMethod *remove_method;
771 MonoReflectionMethod *raise_method;
773 MonoArray *other_methods;
778 MonoString *name_space;
779 MonoReflectionType *etype;
780 MonoReflectionType *nested_in;
781 MonoReflectionAssembly *assembly;
783 MonoBoolean isprimitive;
789 } MonoReflectionILTokenInfo;
798 MonoArray *ex_handlers;
799 gint32 num_token_fixups;
800 MonoArray *token_fixups;
801 } MonoReflectionILGen;
808 } MonoILExceptionInfo;
815 gint32 filter_offset;
816 } MonoILExceptionBlock;
820 MonoObject *catch_type;
821 gint32 filter_offset;
825 gint32 handler_offset;
826 gint32 handler_length;
827 } MonoReflectionExceptionHandlingClause;
831 MonoReflectionType *local_type;
832 MonoBoolean is_pinned;
834 } MonoReflectionLocalVariableInfo;
838 * Must have the same layout as MonoReflectionLocalVariableInfo, since
839 * LocalBuilder inherits from it under net 2.0.
843 MonoBoolean is_pinned;
846 } MonoReflectionLocalBuilder;
855 MonoString *marshaltype;
856 MonoObject *marshaltyperef;
858 MonoBoolean has_size;
859 } MonoReflectionMarshal;
866 MonoReflectionMarshal *marshal_info;
870 MonoObject *def_value;
871 } MonoReflectionParamBuilder;
876 MonoReflectionILGen *ilgen;
877 MonoArray *parameters;
885 MonoBoolean init_locals;
886 MonoArray *param_modreq;
887 MonoArray *param_modopt;
888 MonoArray *permissions;
889 } MonoReflectionCtorBuilder;
895 MonoArray *parameters;
901 MonoReflectionILGen *ilgen;
905 MonoReflectionMethod *override_method;
907 MonoString *dllentry;
912 MonoBoolean init_locals;
913 MonoGenericContainer *generic_container;
914 MonoArray *generic_params;
915 MonoArray *return_modreq;
916 MonoArray *return_modopt;
917 MonoArray *param_modreq;
918 MonoArray *param_modopt;
919 MonoArray *permissions;
920 } MonoReflectionMethodBuilder;
925 MonoReflectionType *parent;
926 MonoReflectionType *ret;
927 MonoArray *parameters;
931 } MonoReflectionArrayMethod;
936 MonoString *filename;
940 } MonoReflectionResource;
947 } MonoReflectionWin32Resource;
952 } MonoReflectionPermissionSet;
955 MonoReflectionAssembly assembly;
956 MonoDynamicAssembly *dynamic_assembly;
957 MonoReflectionMethod *entry_point;
962 MonoArray *resources;
963 MonoArray *public_key;
969 MonoBoolean delay_sign;
971 MonoArray *loaded_modules;
972 MonoArray *win32_resources;
974 MonoArray *permissions_minimum;
975 MonoArray *permissions_optional;
976 MonoArray *permissions_refused;
979 MonoBoolean corlib_internal;
980 MonoArray *type_forwarders;
981 MonoArray *pktoken; /* as hexadecimal byte[] */
982 } MonoReflectionAssemblyBuilder;
989 MonoObject *def_value;
992 MonoReflectionType *typeb;
995 MonoReflectionMarshal *marshal_info;
996 MonoClassField *handle;
999 } MonoReflectionFieldBuilder;
1006 MonoArray *parameters;
1008 MonoObject *def_value;
1009 MonoReflectionMethodBuilder *set_method;
1010 MonoReflectionMethodBuilder *get_method;
1012 } MonoReflectionPropertyBuilder;
1014 struct _MonoReflectionModule {
1017 MonoReflectionAssembly *assembly;
1020 MonoString *scopename;
1021 MonoBoolean is_resource;
1026 MonoReflectionModule module;
1027 MonoDynamicImage *dynamic_image;
1033 MonoReflectionAssemblyBuilder *assemblyb;
1034 MonoArray *global_methods;
1035 MonoArray *global_fields;
1037 MonoArray *resources;
1038 } MonoReflectionModuleBuilder;
1041 MonoReflectionType type;
1045 MonoReflectionType *nesting_type;
1046 MonoArray *interfaces;
1050 MonoArray *properties;
1055 MonoArray *subtypes;
1058 MonoReflectionModuleBuilder *module;
1060 gint32 packing_size;
1061 MonoGenericContainer *generic_container;
1062 MonoArray *generic_params;
1063 MonoArray *permissions;
1064 MonoReflectionType *created;
1065 } MonoReflectionTypeBuilder;
1068 MonoReflectionType type;
1069 MonoReflectionType *element_type;
1071 } MonoReflectionArrayType;
1074 MonoReflectionType type;
1075 MonoReflectionType *element_type;
1076 } MonoReflectionDerivedType;
1079 MonoReflectionType type;
1080 MonoReflectionTypeBuilder *tbuilder;
1081 MonoReflectionMethodBuilder *mbuilder;
1084 MonoReflectionType *base_type;
1085 MonoArray *iface_constraints;
1088 } MonoReflectionGenericParam;
1090 typedef struct _MonoReflectionGenericClass MonoReflectionGenericClass;
1091 struct _MonoReflectionGenericClass {
1092 MonoReflectionType type;
1093 /* From System.MonoType */
1094 MonoObject *type_info;
1095 MonoReflectionTypeBuilder *generic_type;
1096 MonoArray *type_arguments;
1097 guint32 initialized;
1103 MonoString *codebase;
1104 gint32 major, minor, build, revision;
1105 MonoObject *cultureInfo;
1108 MonoObject *keypair;
1109 MonoArray *publicKey;
1110 MonoArray *keyToken;
1111 guint32 versioncompat;
1112 MonoObject *version;
1113 guint32 processor_architecture;
1114 } MonoReflectionAssemblyName;
1119 MonoReflectionType *type;
1120 MonoReflectionTypeBuilder *typeb;
1122 MonoReflectionMethodBuilder *add_method;
1123 MonoReflectionMethodBuilder *remove_method;
1124 MonoReflectionMethodBuilder *raise_method;
1125 MonoArray *other_methods;
1128 } MonoReflectionEventBuilder;
1132 MonoReflectionMethod *ctor;
1134 } MonoReflectionCustomAttr;
1141 MonoString *entry_point;
1142 MonoBoolean exact_spelling;
1143 MonoBoolean preserve_sig;
1144 MonoBoolean set_last_error;
1145 MonoBoolean best_fit_mapping;
1146 MonoBoolean throw_on_unmappable;
1147 } MonoReflectionDllImportAttribute;
1153 MonoBoolean set_last_error;
1154 MonoBoolean best_fit_mapping;
1155 MonoBoolean throw_on_unmappable;
1156 } MonoReflectionUnmanagedFunctionPointerAttribute;
1161 } MonoReflectionGuidAttribute;
1165 MonoMethod *mhandle;
1167 MonoReflectionType *rtype;
1168 MonoArray *parameters;
1171 MonoReflectionModule *module;
1172 MonoBoolean skip_visibility;
1173 MonoBoolean init_locals;
1174 MonoReflectionILGen *ilgen;
1177 GSList *referenced_by;
1178 MonoReflectionType *owner;
1179 } MonoReflectionDynamicMethod;
1183 MonoReflectionModuleBuilder *module;
1184 MonoArray *arguments;
1186 MonoReflectionType *return_type;
1188 guint32 unmanaged_call_conv;
1191 } MonoReflectionSigHelper;
1195 MonoReflectionGenericClass *inst;
1196 MonoReflectionFieldBuilder *fb;
1197 } MonoReflectionFieldOnTypeBuilderInst;
1201 MonoReflectionGenericClass *inst;
1202 MonoReflectionCtorBuilder *cb;
1203 } MonoReflectionCtorOnTypeBuilderInst;
1207 MonoReflectionGenericClass *inst;
1208 MonoReflectionMethodBuilder *mb;
1209 } MonoReflectionMethodOnTypeBuilderInst;
1213 MonoBoolean visible;
1214 } MonoReflectionComVisibleAttribute;
1217 RESOURCE_LOCATION_EMBEDDED = 1,
1218 RESOURCE_LOCATION_ANOTHER_ASSEMBLY = 2,
1219 RESOURCE_LOCATION_IN_MANIFEST = 4
1224 MonoReflectionAssembly *assembly;
1225 MonoString *filename;
1227 } MonoManifestResourceInfo;
1229 /* A boxed IntPtr */
1235 /* Keep in sync with System.GenericParameterAttributes */
1237 GENERIC_PARAMETER_ATTRIBUTE_NON_VARIANT = 0,
1238 GENERIC_PARAMETER_ATTRIBUTE_COVARIANT = 1,
1239 GENERIC_PARAMETER_ATTRIBUTE_CONTRAVARIANT = 2,
1240 GENERIC_PARAMETER_ATTRIBUTE_VARIANCE_MASK = 3,
1242 GENERIC_PARAMETER_ATTRIBUTE_NO_SPECIAL_CONSTRAINT = 0,
1243 GENERIC_PARAMETER_ATTRIBUTE_REFERENCE_TYPE_CONSTRAINT = 4,
1244 GENERIC_PARAMETER_ATTRIBUTE_VALUE_TYPE_CONSTRAINT = 8,
1245 GENERIC_PARAMETER_ATTRIBUTE_CONSTRUCTOR_CONSTRAINT = 16,
1246 GENERIC_PARAMETER_ATTRIBUTE_SPECIAL_CONSTRAINTS_MASK = 28
1247 } GenericParameterAttributes;
1249 void mono_image_create_pefile (MonoReflectionModuleBuilder *module, HANDLE file) MONO_INTERNAL;
1250 void mono_image_basic_init (MonoReflectionAssemblyBuilder *assembly) MONO_INTERNAL;
1251 MonoReflectionModule * mono_image_load_module_dynamic (MonoReflectionAssemblyBuilder *assembly, MonoString *file_name) MONO_INTERNAL;
1252 guint32 mono_image_insert_string (MonoReflectionModuleBuilder *module, MonoString *str) MONO_INTERNAL;
1253 guint32 mono_image_create_token (MonoDynamicImage *assembly, MonoObject *obj, gboolean create_methodspec, gboolean register_token) MONO_INTERNAL;
1254 guint32 mono_image_create_method_token (MonoDynamicImage *assembly, MonoObject *obj, MonoArray *opt_param_types) MONO_INTERNAL;
1255 void mono_image_module_basic_init (MonoReflectionModuleBuilder *module) MONO_INTERNAL;
1256 void mono_image_register_token (MonoDynamicImage *assembly, guint32 token, MonoObject *obj) MONO_INTERNAL;
1257 void mono_dynamic_image_free (MonoDynamicImage *image) MONO_INTERNAL;
1258 void mono_image_set_wrappers_type (MonoReflectionModuleBuilder *mb, MonoReflectionType *type) MONO_INTERNAL;
1260 void mono_reflection_setup_internal_class (MonoReflectionTypeBuilder *tb) MONO_INTERNAL;
1262 void mono_reflection_create_internal_class (MonoReflectionTypeBuilder *tb) MONO_INTERNAL;
1264 void mono_reflection_setup_generic_class (MonoReflectionTypeBuilder *tb) MONO_INTERNAL;
1266 void mono_reflection_create_generic_class (MonoReflectionTypeBuilder *tb) MONO_INTERNAL;
1268 MonoReflectionType* mono_reflection_create_runtime_class (MonoReflectionTypeBuilder *tb) MONO_INTERNAL;
1270 void mono_reflection_get_dynamic_overrides (MonoClass *klass, MonoMethod ***overrides, int *num_overrides) MONO_INTERNAL;
1272 void mono_reflection_create_dynamic_method (MonoReflectionDynamicMethod *m) MONO_INTERNAL;
1273 void mono_reflection_destroy_dynamic_method (MonoReflectionDynamicMethod *mb) MONO_INTERNAL;
1275 void mono_reflection_initialize_generic_parameter (MonoReflectionGenericParam *gparam) MONO_INTERNAL;
1276 void mono_reflection_create_unmanaged_type (MonoReflectionType *type) MONO_INTERNAL;
1278 MonoArray* mono_param_get_objects_internal (MonoDomain *domain, MonoMethod *method, MonoClass *refclass) MONO_INTERNAL;
1281 mono_class_bind_generic_parameters (MonoClass *klass, int type_argc, MonoType **types, gboolean is_dynamic) MONO_INTERNAL;
1283 mono_reflection_bind_generic_parameters (MonoReflectionType *type, int type_argc, MonoType **types) MONO_INTERNAL;
1284 MonoReflectionMethod*
1285 mono_reflection_bind_generic_method_parameters (MonoReflectionMethod *method, MonoArray *types) MONO_INTERNAL;
1287 mono_reflection_generic_class_initialize (MonoReflectionGenericClass *type, MonoArray *methods, MonoArray *ctors, MonoArray *fields, MonoArray *properties, MonoArray *events) MONO_INTERNAL;
1288 MonoReflectionEvent *
1289 mono_reflection_event_builder_get_event_info (MonoReflectionTypeBuilder *tb, MonoReflectionEventBuilder *eb) MONO_INTERNAL;
1291 MonoArray *mono_reflection_sighelper_get_signature_local (MonoReflectionSigHelper *sig) MONO_INTERNAL;
1293 MonoArray *mono_reflection_sighelper_get_signature_field (MonoReflectionSigHelper *sig) MONO_INTERNAL;
1295 MonoReflectionMarshal* mono_reflection_marshal_from_marshal_spec (MonoDomain *domain, MonoClass *klass, MonoMarshalSpec *spec) MONO_INTERNAL;
1298 mono_reflection_lookup_dynamic_token (MonoImage *image, guint32 token, gboolean valid_token, MonoClass **handle_class, MonoGenericContext *context) MONO_INTERNAL;
1301 mono_reflection_call_is_assignable_to (MonoClass *klass, MonoClass *oklass) MONO_INTERNAL;
1304 mono_reflection_is_valid_dynamic_token (MonoDynamicImage *image, guint32 token) MONO_INTERNAL;
1307 mono_reflection_type_get_handle (MonoReflectionType *ref) MONO_INTERNAL;
1310 mono_image_build_metadata (MonoReflectionModuleBuilder *module) MONO_INTERNAL;
1313 mono_get_constant_value_from_blob (MonoDomain* domain, MonoTypeEnum type, const char *blob, void *value) MONO_INTERNAL;
1316 mono_release_type_locks (MonoThread *thread) MONO_INTERNAL;
1319 mono_string_to_utf8_mp (MonoMemPool *mp, MonoString *s) MONO_INTERNAL;
1322 mono_string_to_utf8_image (MonoImage *image, MonoString *s) MONO_INTERNAL;
1326 mono_array_clone_in_domain (MonoDomain *domain, MonoArray *array) MONO_INTERNAL;
1329 mono_array_full_copy (MonoArray *src, MonoArray *dest) MONO_INTERNAL;
1332 mono_remote_class_vtable (MonoDomain *domain, MonoRemoteClass *remote_class, MonoRealProxy *real_proxy) MONO_INTERNAL;
1335 mono_upgrade_remote_class (MonoDomain *domain, MonoObject *tproxy, MonoClass *klass) MONO_INTERNAL;
1338 mono_create_ftnptr (MonoDomain *domain, gpointer addr) MONO_INTERNAL;
1341 mono_get_addr_from_ftnptr (gpointer descr) MONO_INTERNAL;
1344 mono_nullable_init (guint8 *buf, MonoObject *value, MonoClass *klass) MONO_INTERNAL;
1347 mono_nullable_box (guint8 *buf, MonoClass *klass) MONO_INTERNAL;
1349 #define MONO_IMT_SIZE 19
1353 gpointer target_code;
1356 typedef struct _MonoImtBuilderEntry {
1358 struct _MonoImtBuilderEntry *next;
1359 MonoImtItemValue value;
1361 guint8 has_target_code : 1;
1362 } MonoImtBuilderEntry;
1364 typedef struct _MonoIMTCheckItem MonoIMTCheckItem;
1366 struct _MonoIMTCheckItem {
1368 int check_target_idx;
1369 MonoImtItemValue value;
1371 guint8 *code_target;
1373 guint8 compare_done;
1375 guint8 short_branch;
1376 guint8 has_target_code;
1379 typedef gpointer (*MonoImtThunkBuilder) (MonoVTable *vtable, MonoDomain *domain,
1380 MonoIMTCheckItem **imt_entries, int count, gpointer fail_trunk);
1383 mono_install_imt_thunk_builder (MonoImtThunkBuilder func) MONO_INTERNAL;
1386 mono_install_imt_trampoline (gpointer tramp) MONO_INTERNAL;
1389 mono_install_vtable_trampoline (gpointer tramp) MONO_INTERNAL;
1392 mono_vtable_build_imt_slot (MonoVTable* vtable, int imt_slot) MONO_INTERNAL;
1395 mono_method_get_imt_slot (MonoMethod *method) MONO_INTERNAL;
1398 mono_method_add_generic_virtual_invocation (MonoDomain *domain, MonoVTable *vtable,
1399 gpointer *vtable_slot,
1400 MonoMethod *method, gpointer code) MONO_INTERNAL;
1403 mono_method_alloc_generic_virtual_thunk (MonoDomain *domain, int size) MONO_INTERNAL;
1406 MONO_UNHANDLED_POLICY_LEGACY,
1407 MONO_UNHANDLED_POLICY_CURRENT
1408 } MonoRuntimeUnhandledExceptionPolicy;
1410 MonoRuntimeUnhandledExceptionPolicy
1411 mono_runtime_unhandled_exception_policy_get (void) MONO_INTERNAL;
1413 mono_runtime_unhandled_exception_policy_set (MonoRuntimeUnhandledExceptionPolicy policy) MONO_INTERNAL;
1416 mono_class_try_get_vtable (MonoDomain *domain, MonoClass *class) MONO_INTERNAL;
1419 mono_runtime_class_init_full (MonoVTable *vtable, gboolean raise_exception) MONO_INTERNAL;
1422 mono_method_clear_object (MonoDomain *domain, MonoMethod *method) MONO_INTERNAL;
1425 mono_class_compute_gc_descriptor (MonoClass *class) MONO_INTERNAL;
1427 #endif /* __MONO_OBJECT_INTERNALS_H__ */