/
object-internals.h
1435 lines (1239 loc) · 38.4 KB
/
object-internals.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#ifndef __MONO_OBJECT_INTERNALS_H__
#define __MONO_OBJECT_INTERNALS_H__
#include <mono/metadata/object.h>
#include <mono/metadata/threads.h>
#include <mono/metadata/reflection.h>
#include <mono/metadata/mempool.h>
#include <mono/metadata/class-internals.h>
#include <mono/io-layer/io-layer.h>
#include "mono/utils/mono-compiler.h"
/*
* We should find a better place for this stuff. We can't put it in mono-compiler.h,
* since that is included by libgc.
*/
#ifndef G_LIKELY
#define G_LIKELY(a) (a)
#define G_UNLIKELY(a) (a)
#endif
/*
* glib defines this macro and uses it in the definition of G_LIKELY, and thus,
* g_assert (). The macro expands to a complex piece of code, preventing some
* gcc versions like 4.3.0 from handling the __builtin_expect construct properly,
* causing the generation of the unlikely branch into the middle of the code.
*/
#ifdef _G_BOOLEAN_EXPR
#undef _G_BOOLEAN_EXPR
#define _G_BOOLEAN_EXPR(expr) (gsize)(expr)
#endif
#if 1
#ifdef __GNUC__
#define mono_assert(expr) G_STMT_START{ \
if (!(expr)) \
{ \
MonoException *ex; \
char *msg = g_strdup_printf ("file %s: line %d (%s): " \
"assertion failed: (%s)", __FILE__, __LINE__, \
__PRETTY_FUNCTION__, #expr); \
ex = mono_get_exception_execution_engine (msg); \
g_free (msg); \
mono_raise_exception (ex); \
}; }G_STMT_END
#define mono_assert_not_reached() G_STMT_START{ \
MonoException *ex; \
char *msg = g_strdup_printf ("file %s: line %d (%s): " \
"should not be reached", __FILE__, __LINE__, __PRETTY_FUNCTION__); \
ex = mono_get_exception_execution_engine (msg); \
g_free (msg); \
mono_raise_exception (ex); \
}G_STMT_END
#else /* not GNUC */
#define mono_assert(expr) G_STMT_START{ \
if (!(expr)) \
{ \
MonoException *ex; \
char *msg = g_strdup_printf ("file %s: line %d: " \
"assertion failed: (%s)", __FILE__, __LINE__, \
#expr); \
ex = mono_get_exception_execution_engine (msg); \
g_free (msg); \
mono_raise_exception (ex); \
}; }G_STMT_END
#define mono_assert_not_reached() G_STMT_START{ \
MonoException *ex; \
char *msg = g_strdup_printf ("file %s: line %d): " \
"should not be reached", __FILE__, __LINE__); \
ex = mono_get_exception_execution_engine (msg); \
g_free (msg); \
mono_raise_exception (ex); \
}G_STMT_END
#endif
#else
#define mono_assert(expr) g_assert(expr)
#define mono_assert_not_reached() g_assert_not_reached()
#endif
#define MONO_CHECK_ARG(arg, expr) G_STMT_START{ \
if (!(expr)) \
{ \
MonoException *ex; \
char *msg = g_strdup_printf ("assertion `%s' failed", \
#expr); \
if (arg) {} /* check if the name exists */ \
ex = mono_get_exception_argument (#arg, msg); \
g_free (msg); \
mono_raise_exception (ex); \
}; }G_STMT_END
#define MONO_CHECK_ARG_NULL(arg) G_STMT_START{ \
if (arg == NULL) \
{ \
MonoException *ex; \
if (arg) {} /* check if the name exists */ \
ex = mono_get_exception_argument_null (#arg); \
mono_raise_exception (ex); \
}; }G_STMT_END
/* 16 == default capacity */
#define mono_stringbuilder_capacity(sb) ((sb)->str ? ((sb)->str->length) : 16)
/*
* Macros which cache the results of lookups locally.
* These should be used instead of the original versions, if the __GNUC__
* restriction is acceptable.
*/
#ifdef __GNUC__
/* namespace and name should be a constant */
#define mono_class_from_name_cached(image,namespace,name) ({ \
static MonoClass *tmp_klass; \
if (!tmp_klass) { \
tmp_klass = mono_class_from_name ((image), (namespace), (name)); \
g_assert (tmp_klass); \
}; \
tmp_klass; })
/* name should be a compile-time constant */
#define mono_class_get_field_from_name_cached(klass,name) ({ \
static MonoClassField *tmp_field; \
if (!tmp_field) { \
tmp_field = mono_class_get_field_from_name ((klass), (name)); \
g_assert (tmp_field); \
}; \
tmp_field; })
/* eclass should be a run-time constant */
#define mono_array_class_get_cached(eclass,rank) ({ \
static MonoClass *tmp_klass; \
if (!tmp_klass) { \
tmp_klass = mono_array_class_get ((eclass), (rank)); \
g_assert (tmp_klass); \
}; \
tmp_klass; })
/* eclass should be a run-time constant */
#define mono_array_new_cached(domain, eclass, size) mono_array_new_specific (mono_class_vtable ((domain), mono_array_class_get_cached ((eclass), 1)), (size))
#else
#define mono_class_from_name_cached(image,namespace,name) mono_class_from_name ((image), (namespace), (name))
#define mono_class_get_field_from_name_cached(klass,name) mono_class_get_field_from_name ((klass), (name))
#define mono_array_class_get_cached(eclass,rank) mono_array_class_get ((eclass), (rank))
#define mono_array_new_cached(domain, eclass, size) mono_array_new_specific (mono_class_vtable ((domain), mono_array_class_get_cached ((eclass), 1)), (size))
#endif
typedef struct {
MonoObject obj;
MonoObject *identity;
} MonoMarshalByRefObject;
/* This is a copy of System.AppDomain */
struct _MonoAppDomain {
MonoMarshalByRefObject mbr;
MonoDomain *data;
};
typedef struct {
MonoObject object;
gint32 length;
MonoString *str;
MonoString *cached_str;
gint32 max_capacity;
} MonoStringBuilder;
typedef struct {
MonoType *type;
gpointer value;
MonoClass *klass;
} MonoTypedRef;
typedef struct {
gpointer args;
} MonoArgumentHandle;
typedef struct {
MonoMethodSignature *sig;
gpointer args;
gint32 next_arg;
gint32 num_args;
} MonoArgIterator;
struct _MonoException {
MonoObject object;
/* Stores the IPs and the generic sharing infos
(vtable/MRGCTX) of the frames. */
MonoArray *trace_ips;
MonoObject *inner_ex;
MonoString *message;
MonoString *help_link;
MonoString *class_name;
MonoString *stack_trace;
MonoString *remote_stack_trace;
gint32 remote_stack_index;
gint32 hresult;
MonoString *source;
MonoObject *_data;
};
typedef struct {
MonoException base;
} MonoSystemException;
typedef struct {
MonoSystemException base;
MonoString *param_name;
} MonoArgumentException;
typedef struct {
MonoSystemException base;
MonoString *msg;
MonoString *type_name;
} MonoTypeLoadException;
typedef struct {
MonoObject object;
MonoObject *async_state;
MonoObject *handle;
MonoObject *async_delegate;
gpointer *data;
MonoObject *object_data;
MonoBoolean sync_completed;
MonoBoolean completed;
MonoBoolean endinvoke_called;
MonoObject *async_callback;
MonoObject *execution_context;
MonoObject *original_context;
} MonoAsyncResult;
typedef struct {
MonoMarshalByRefObject object;
gpointer handle;
MonoBoolean disposed;
} MonoWaitHandle;
/* This is a copy of System.Runtime.Remoting.Messaging.CallType */
typedef enum {
CallType_Sync = 0,
CallType_BeginInvoke = 1,
CallType_EndInvoke = 2,
CallType_OneWay = 3
} MonoCallType;
/* This corresponds to System.Type */
struct _MonoReflectionType {
MonoObject object;
MonoType *type;
};
typedef struct {
MonoReflectionType type;
MonoObject *type_info;
} MonoReflectionMonoType;
typedef struct {
MonoObject object;
MonoReflectionType *class_to_proxy;
MonoObject *context;
MonoObject *unwrapped_server;
gint32 target_domain_id;
MonoString *target_uri;
MonoObject *object_identity;
MonoObject *obj_TP;
MonoObject *stub_data;
} MonoRealProxy;
typedef struct {
MonoMarshalByRefObject object;
gpointer iunknown;
GHashTable* itf_hash;
} MonoComObject;
typedef struct {
MonoRealProxy real_proxy;
MonoComObject *com_object;
gint32 ref_count;
} MonoComInteropProxy;
typedef struct {
MonoObject object;
MonoRealProxy *rp;
MonoRemoteClass *remote_class;
MonoBoolean custom_type_info;
} MonoTransparentProxy;
typedef struct {
MonoObject obj;
MonoReflectionMethod *method;
MonoArray *args;
MonoArray *names;
MonoArray *arg_types;
MonoObject *ctx;
MonoObject *rval;
MonoObject *exc;
MonoAsyncResult *async_result;
guint32 call_type;
} MonoMethodMessage;
typedef struct {
MonoObject obj;
gint32 il_offset;
gint32 native_offset;
MonoReflectionMethod *method;
MonoString *filename;
gint32 line;
gint32 column;
MonoString *internal_method_name;
} MonoStackFrame;
struct _MonoThread {
MonoObject obj;
int lock_thread_id; /* to be used as the pre-shifted thread id in thin locks */
HANDLE handle;
MonoArray *cached_culture_info;
gpointer unused1;
MonoBoolean threadpool_thread;
gunichar2 *name;
guint32 name_len;
guint32 state;
MonoException *abort_exc;
int abort_state_handle;
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 */
HANDLE start_notify;
gpointer stack_ptr;
gpointer *static_data;
gpointer jit_data;
gpointer lock_data;
MonoAppContext *current_appcontext;
int stack_size;
MonoObject *start_obj;
GSList *appdomain_refs;
/* This is modified using atomic ops, so keep it a gint32 */
gint32 interruption_requested;
gpointer suspend_event;
gpointer suspended_event;
gpointer resume_event;
CRITICAL_SECTION *synch_cs;
guint8* serialized_culture_info;
guint32 serialized_culture_info_len;
guint8* serialized_ui_culture_info;
guint32 serialized_ui_culture_info_len;
MonoBoolean thread_dump_requested;
gpointer end_stack; /* This is only used when running in the debugger. */
MonoBoolean thread_interrupt_requested;
guint8 apartment_state;
gint32 critical_region_level;
guint32 small_id; /* A small, unique id, used for the hazard pointer table. */
MonoThreadManageCallback manage_callback;
MonoException *pending_exception;
MonoObject *ec_to_set;
/*
* These fields are used to avoid having to increment corlib versions
* when a new field is added to the unmanaged MonoThread structure.
*/
gpointer interrupt_on_stop;
gpointer unused3;
gpointer unused4;
gpointer unused5;
gpointer unused6;
};
typedef struct {
MonoString *name;
MonoReflectionType *type;
MonoObject *value;
} MonoSerializationEntry;
typedef struct {
guint32 state;
MonoObject *additional;
} MonoStreamingContext;
typedef struct {
MonoObject obj;
MonoBoolean readOnly;
MonoString *AMDesignator;
MonoString *PMDesignator;
MonoString *DateSeparator;
MonoString *TimeSeparator;
MonoString *ShortDatePattern;
MonoString *LongDatePattern;
MonoString *ShortTimePattern;
MonoString *LongTimePattern;
MonoString *MonthDayPattern;
MonoString *YearMonthPattern;
MonoString *FullDateTimePattern;
MonoString *RFC1123Pattern;
MonoString *SortableDateTimePattern;
MonoString *UniversalSortableDateTimePattern;
guint32 FirstDayOfWeek;
MonoObject *Calendar;
guint32 CalendarWeekRule;
MonoArray *AbbreviatedDayNames;
MonoArray *DayNames;
MonoArray *MonthNames;
MonoArray *AbbreviatedMonthNames;
MonoArray *ShortDatePatterns;
MonoArray *LongDatePatterns;
MonoArray *ShortTimePatterns;
MonoArray *LongTimePatterns;
MonoArray *MonthDayPatterns;
MonoArray *YearMonthPatterns;
MonoArray *shortDayNames;
} MonoDateTimeFormatInfo;
typedef struct
{
MonoObject obj;
MonoBoolean readOnly;
MonoString *decimalFormats;
MonoString *currencyFormats;
MonoString *percentFormats;
MonoString *digitPattern;
MonoString *zeroPattern;
gint32 currencyDecimalDigits;
MonoString *currencyDecimalSeparator;
MonoString *currencyGroupSeparator;
MonoArray *currencyGroupSizes;
gint32 currencyNegativePattern;
gint32 currencyPositivePattern;
MonoString *currencySymbol;
MonoString *naNSymbol;
MonoString *negativeInfinitySymbol;
MonoString *negativeSign;
guint32 numberDecimalDigits;
MonoString *numberDecimalSeparator;
MonoString *numberGroupSeparator;
MonoArray *numberGroupSizes;
gint32 numberNegativePattern;
gint32 percentDecimalDigits;
MonoString *percentDecimalSeparator;
MonoString *percentGroupSeparator;
MonoArray *percentGroupSizes;
gint32 percentNegativePattern;
gint32 percentPositivePattern;
MonoString *percentSymbol;
MonoString *perMilleSymbol;
MonoString *positiveInfinitySymbol;
MonoString *positiveSign;
} MonoNumberFormatInfo;
typedef struct {
MonoObject obj;
gint32 lcid;
MonoString *icu_name;
gpointer ICU_collator;
} MonoCompareInfo;
typedef struct {
MonoObject obj;
MonoBoolean is_read_only;
gint32 lcid;
gint32 parent_lcid;
gint32 specific_lcid;
gint32 datetime_index;
gint32 number_index;
MonoBoolean use_user_override;
MonoNumberFormatInfo *number_format;
MonoDateTimeFormatInfo *datetime_format;
MonoObject *textinfo;
MonoString *name;
MonoString *displayname;
MonoString *englishname;
MonoString *nativename;
MonoString *iso3lang;
MonoString *iso2lang;
MonoString *icu_name;
MonoString *win3lang;
MonoString *territory;
MonoCompareInfo *compareinfo;
const gint32 *calendar_data;
const void* text_info_data;
} MonoCultureInfo;
typedef struct {
MonoObject obj;
gint32 region_id;
MonoString *iso2name;
MonoString *iso3name;
MonoString *win3name;
MonoString *english_name;
MonoString *currency_symbol;
MonoString *iso_currency_symbol;
MonoString *currency_english_name;
} MonoRegionInfo;
typedef struct {
MonoObject obj;
MonoString *str;
gint32 options;
MonoArray *key;
gint32 lcid;
} MonoSortKey;
typedef struct {
MonoObject object;
guint32 intType;
} MonoInterfaceTypeAttribute;
/*
* Callbacks supplied by the runtime and called by the modules in metadata/
* This interface is easier to extend than adding a new function type +
* a new 'install' function for every callback.
*/
typedef struct {
gpointer (*create_ftnptr) (MonoDomain *domain, gpointer addr);
gpointer (*get_addr_from_ftnptr) (gpointer descr);
char* (*get_runtime_build_info) (void);
} MonoRuntimeCallbacks;
/* used to free a dynamic method */
typedef void (*MonoFreeMethodFunc) (MonoDomain *domain, MonoMethod *method);
/* Used to initialize the method pointers inside vtables */
typedef gboolean (*MonoInitVTableFunc) (MonoVTable *vtable);
void mono_set_pending_exception (MonoException *exc) MONO_INTERNAL;
/* remoting and async support */
MonoAsyncResult *
mono_async_result_new (MonoDomain *domain, HANDLE handle,
MonoObject *state, gpointer data, MonoObject *object_data) MONO_INTERNAL;
MonoWaitHandle *
mono_wait_handle_new (MonoDomain *domain, HANDLE handle) MONO_INTERNAL;
HANDLE
mono_wait_handle_get_handle (MonoWaitHandle *handle) MONO_INTERNAL;
void
mono_message_init (MonoDomain *domain, MonoMethodMessage *this_obj,
MonoReflectionMethod *method, MonoArray *out_args) MONO_INTERNAL;
MonoObject *
mono_remoting_invoke (MonoObject *real_proxy, MonoMethodMessage *msg,
MonoObject **exc, MonoArray **out_args) MONO_INTERNAL;
MonoObject *
mono_message_invoke (MonoObject *target, MonoMethodMessage *msg,
MonoObject **exc, MonoArray **out_args) MONO_INTERNAL;
MonoMethodMessage *
mono_method_call_message_new (MonoMethod *method, gpointer *params, MonoMethod *invoke,
MonoDelegate **cb, MonoObject **state) MONO_INTERNAL;
void
mono_method_return_message_restore (MonoMethod *method, gpointer *params, MonoArray *out_args) MONO_INTERNAL;
void
mono_delegate_ctor_with_method (MonoObject *this, MonoObject *target, gpointer addr, MonoMethod *method) MONO_INTERNAL;
void
mono_delegate_ctor (MonoObject *this_obj, MonoObject *target, gpointer addr) MONO_INTERNAL;
void*
mono_class_get_allocation_ftn (MonoVTable *vtable, gboolean for_box, gboolean *pass_size_in_words) MONO_INTERNAL;
void
mono_runtime_free_method (MonoDomain *domain, MonoMethod *method) MONO_INTERNAL;
/* runtime initialization functions */
typedef void (*MonoExceptionFunc) (MonoException *ex);
void
mono_install_handler (MonoExceptionFunc func) MONO_INTERNAL;
void
mono_install_runtime_invoke (MonoInvokeFunc func) MONO_INTERNAL;
void
mono_install_compile_method (MonoCompileFunc func) MONO_INTERNAL;
void
mono_install_free_method (MonoFreeMethodFunc func) MONO_INTERNAL;
void
mono_install_callbacks (MonoRuntimeCallbacks *cbs) MONO_INTERNAL;
MonoRuntimeCallbacks*
mono_get_runtime_callbacks (void) MONO_INTERNAL;
void
mono_type_initialization_init (void) MONO_INTERNAL;
void
mono_type_initialization_cleanup (void) MONO_INTERNAL;
guint32
mono_thread_get_tls_key (void) MONO_INTERNAL;
gint32
mono_thread_get_tls_offset (void) MONO_INTERNAL;
guint32
mono_domain_get_tls_key (void) MONO_INTERNAL;
gint32
mono_domain_get_tls_offset (void) MONO_INTERNAL;
/* Reflection and Reflection.Emit support */
/*
* Handling System.Type objects:
*
* Fields defined as System.Type in managed code should be defined as MonoObject*
* in unmanaged structures, and the monotype_cast () function should be used for
* casting them to MonoReflectionType* to avoid crashes/security issues when
* encountering instances of user defined subclasses of System.Type.
*/
#define IS_MONOTYPE(obj) (!(obj) || (((MonoObject*)(obj))->vtable->klass->image == mono_defaults.corlib && ((MonoReflectionType*)(obj))->type != NULL))
/*
* Make sure the argument, which should be a System.Type is a System.MonoType object
* or equivalent, and not an instance of
* a user defined subclass of System.Type. This should be used in places were throwing
* an exception is safe.
*/
#define CHECK_MONOTYPE(obj) do { \
if (!IS_MONOTYPE (obj)) \
mono_raise_exception (mono_get_exception_not_supported ("User defined subclasses of System.Type are not yet supported")); \
} while (0)
/* This should be used for accessing members of Type[] arrays */
#define mono_type_array_get(arr,index) monotype_cast (mono_array_get ((arr), gpointer, (index)))
/*
* Cast an object to MonoReflectionType, making sure it is a System.MonoType or
* a subclass of it.
*/
static inline MonoReflectionType*
monotype_cast (MonoObject *obj)
{
g_assert (IS_MONOTYPE (obj));
return (MonoReflectionType*)obj;
}
/*
* The following structure must match the C# implementation in our corlib.
*/
struct _MonoReflectionMethod {
MonoObject object;
MonoMethod *method;
MonoString *name;
MonoReflectionType *reftype;
};
typedef struct _MonoReflectionGenericMethod MonoReflectionGenericMethod;
struct _MonoReflectionGenericMethod {
MonoReflectionMethod method;
};
struct _MonoDelegate {
MonoObject object;
/* The compiled code of the target method */
gpointer method_ptr;
/* The invoke code */
gpointer invoke_impl;
MonoObject *target;
MonoMethod *method;
gpointer delegate_trampoline;
/*
* If non-NULL, this points to a memory location which stores the address of
* the compiled code of the method, or NULL if it is not yet compiled.
*/
guint8 **method_code;
MonoReflectionMethod *method_info;
MonoReflectionMethod *original_method_info;
MonoObject *data;
};
typedef struct _MonoMulticastDelegate MonoMulticastDelegate;
struct _MonoMulticastDelegate {
MonoDelegate delegate;
MonoMulticastDelegate *prev;
};
struct _MonoReflectionField {
MonoObject object;
MonoClass *klass;
MonoClassField *field;
MonoString *name;
MonoReflectionType *type;
guint32 attrs;
};
struct _MonoReflectionProperty {
MonoObject object;
MonoClass *klass;
MonoProperty *property;
};
/*This is System.EventInfo*/
struct _MonoReflectionEvent {
MonoObject object;
MonoObject *cached_add_event;
};
typedef struct {
MonoReflectionEvent object;
MonoClass *klass;
MonoEvent *event;
} MonoReflectionMonoEvent;
typedef struct {
MonoObject object;
MonoReflectionType *ClassImpl;
MonoObject *DefaultValueImpl;
MonoObject *MemberImpl;
MonoString *NameImpl;
gint32 PositionImpl;
guint32 AttrsImpl;
MonoObject *MarshalAsImpl;
} MonoReflectionParameter;
struct _MonoReflectionMethodBody {
MonoObject object;
MonoArray *clauses;
MonoArray *locals;
MonoArray *il;
MonoBoolean init_locals;
guint32 local_var_sig_token;
guint32 max_stack;
};
struct _MonoReflectionAssembly {
MonoObject object;
MonoAssembly *assembly;
MonoObject *resolve_event_holder;
/* CAS related */
MonoObject *evidence; /* Evidence */
MonoObject *minimum; /* PermissionSet - for SecurityAction.RequestMinimum */
MonoObject *optional; /* PermissionSet - for SecurityAction.RequestOptional */
MonoObject *refuse; /* PermissionSet - for SecurityAction.RequestRefuse */
MonoObject *granted; /* PermissionSet - for the resolved assembly granted permissions */
MonoObject *denied; /* PermissionSet - for the resolved assembly denied permissions */
/* */
MonoBoolean from_byte_array;
MonoString *name;
};
typedef struct {
MonoReflectionType *utype;
MonoArray *values;
MonoArray *names;
} MonoEnumInfo;
typedef struct {
MonoReflectionType *parent;
MonoReflectionType *ret;
guint32 attrs;
guint32 implattrs;
guint32 callconv;
} MonoMethodInfo;
typedef struct {
MonoReflectionType *parent;
MonoString *name;
MonoReflectionMethod *get;
MonoReflectionMethod *set;
guint32 attrs;
} MonoPropertyInfo;
typedef struct {
MonoReflectionType *declaring_type;
MonoReflectionType *reflected_type;
MonoString *name;
MonoReflectionMethod *add_method;
MonoReflectionMethod *remove_method;
MonoReflectionMethod *raise_method;
guint32 attrs;
MonoArray *other_methods;
} MonoEventInfo;
typedef struct {
MonoString *name;
MonoString *name_space;
MonoReflectionType *etype;
MonoReflectionType *nested_in;
MonoReflectionAssembly *assembly;
guint32 rank;
MonoBoolean isprimitive;
} MonoTypeInfo;
typedef struct {
MonoObject *member;
gint32 code_pos;
} MonoReflectionILTokenInfo;
typedef struct {
MonoObject object;
MonoArray *code;
gint32 code_len;
gint32 max_stack;
gint32 cur_stack;
MonoArray *locals;
MonoArray *ex_handlers;
gint32 num_token_fixups;
MonoArray *token_fixups;
} MonoReflectionILGen;
typedef struct {
MonoArray *handlers;
gint32 start;
gint32 len;
gint32 label;
} MonoILExceptionInfo;
typedef struct {
MonoObject *extype;
gint32 type;
gint32 start;
gint32 len;
gint32 filter_offset;
} MonoILExceptionBlock;
typedef struct {
MonoObject object;
MonoObject *catch_type;
gint32 filter_offset;
gint32 flags;
gint32 try_offset;
gint32 try_length;
gint32 handler_offset;
gint32 handler_length;
} MonoReflectionExceptionHandlingClause;
typedef struct {
MonoObject object;
MonoReflectionType *local_type;
MonoBoolean is_pinned;
guint16 local_index;
} MonoReflectionLocalVariableInfo;
typedef struct {
/*
* Must have the same layout as MonoReflectionLocalVariableInfo, since
* LocalBuilder inherits from it under net 2.0.
*/
MonoObject object;
MonoObject *type;
MonoBoolean is_pinned;
guint16 local_index;
MonoString *name;
} MonoReflectionLocalBuilder;
typedef struct {
MonoObject object;
gint32 count;
gint32 type;
gint32 eltype;
MonoString *guid;
MonoString *mcookie;
MonoString *marshaltype;
MonoObject *marshaltyperef;
gint32 param_num;
MonoBoolean has_size;
} MonoReflectionMarshal;
typedef struct {
MonoObject object;
MonoObject* methodb;
MonoString *name;
MonoArray *cattrs;
MonoReflectionMarshal *marshal_info;
guint32 attrs;
int position;
guint32 table_idx;
MonoObject *def_value;
} MonoReflectionParamBuilder;
typedef struct {
MonoObject object;
MonoMethod *mhandle;
MonoReflectionILGen *ilgen;
MonoArray *parameters;
guint32 attrs;
guint32 iattrs;
guint32 table_idx;
guint32 call_conv;
MonoObject *type;
MonoArray *pinfo;
MonoArray *cattrs;
MonoBoolean init_locals;
MonoArray *param_modreq;
MonoArray *param_modopt;
MonoArray *permissions;
} MonoReflectionCtorBuilder;
typedef struct {
MonoObject object;
MonoMethod *mhandle;
MonoObject *rtype;
MonoArray *parameters;
guint32 attrs;
guint32 iattrs;
MonoString *name;
guint32 table_idx;
MonoArray *code;
MonoReflectionILGen *ilgen;
MonoObject *type;
MonoArray *pinfo;
MonoArray *cattrs;
MonoReflectionMethod *override_method;
MonoString *dll;
MonoString *dllentry;
guint32 charset;
guint32 extra_flags;
guint32 native_cc;
guint32 call_conv;
MonoBoolean init_locals;
MonoGenericContainer *generic_container;
MonoArray *generic_params;
MonoArray *return_modreq;
MonoArray *return_modopt;
MonoArray *param_modreq;
MonoArray *param_modopt;
MonoArray *permissions;
} MonoReflectionMethodBuilder;
typedef struct {
MonoObject object;
MonoMethod *mhandle;
MonoReflectionType *parent;
MonoReflectionType *ret;
MonoArray *parameters;
MonoString *name;
guint32 table_idx;
guint32 call_conv;
} MonoReflectionArrayMethod;
typedef struct {
MonoArray *data;
MonoString *name;
MonoString *filename;
guint32 attrs;
guint32 offset;
MonoObject *stream;
} MonoReflectionResource;
typedef struct {
guint32 res_type;
guint32 res_id;
guint32 lang_id;
MonoArray *res_data;
} MonoReflectionWin32Resource;
typedef struct {
guint32 action;
MonoString *pset;
} MonoReflectionPermissionSet;
typedef struct {
MonoReflectionAssembly assembly;
MonoDynamicAssembly *dynamic_assembly;
MonoReflectionMethod *entry_point;
MonoArray *modules;
MonoString *name;
MonoString *dir;
MonoArray *cattrs;
MonoArray *resources;
MonoArray *public_key;
MonoString *version;
MonoString *culture;
guint32 algid;
guint32 flags;
guint32 pekind;
MonoBoolean delay_sign;
guint32 access;
MonoArray *loaded_modules;
MonoArray *win32_resources;
/* CAS related */
MonoArray *permissions_minimum;
MonoArray *permissions_optional;
MonoArray *permissions_refused;
gint32 pe_kind;
gint32 machine;
MonoBoolean corlib_internal;
MonoArray *type_forwarders;
MonoArray *pktoken; /* as hexadecimal byte[] */
} MonoReflectionAssemblyBuilder;
typedef struct {
MonoObject object;
guint32 attrs;
MonoObject *type;
MonoString *name;
MonoObject *def_value;
gint32 offset;
gint32 table_idx;
MonoReflectionType *typeb;
MonoArray *rva_data;
MonoArray *cattrs;
MonoReflectionMarshal *marshal_info;
MonoClassField *handle;