2008-01-09 Rodrigo Kumpera <rkumpera@novell.com>
[mono.git] / mono / metadata / class-internals.h
index 84cbe77bce1c25fe9b046b5ce14ce5b6dcc995e2..59299e00a6cd90a032fde0d011eb4e09c652bc96 100644 (file)
@@ -176,6 +176,7 @@ enum {
        MONO_EXCEPTION_METHOD_ACCESS = 9,
        MONO_EXCEPTION_FIELD_ACCESS = 10,
        MONO_EXCEPTION_GENERIC_SHARING_FAILED = 11,
+       MONO_EXCEPTION_BAD_IMAGE = 12
        /* add other exception type */
 };
 
@@ -189,17 +190,20 @@ typedef struct {
 } MonoClassRuntimeInfo;
 
 struct _MonoClass {
-       MonoImage *image;
-
-       /* The underlying type of the enum */
-       MonoType *enum_basetype;
        /* element class for arrays and enum */
        MonoClass *element_class; 
        /* used for subtype checks */
        MonoClass *cast_class; 
+
+       /* for fast subtype checks */
+       MonoClass **supertypes;
+       guint16     idepth;
+
        /* array dimension */
        guint8     rank;          
 
+       int        instance_size; /* object instance size */
+
        guint inited          : 1;
        /* We use init_pending to detect cyclic calls to mono_class_init */
        guint init_pending    : 1;
@@ -242,19 +246,21 @@ struct _MonoClass {
 
        guint8     exception_type;      /* MONO_EXCEPTION_* */
        void*      exception_data;      /* Additional information about the exception */
-       guint32    declsec_flags;       /* declarative security attributes flags */
 
        MonoClass  *parent;
        MonoClass  *nested_in;
        GList      *nested_classes;
 
-       guint32    type_token;
+       MonoImage *image;
        const char *name;
        const char *name_space;
-       
-       /* for fast subtype checks */
-       MonoClass **supertypes;
-       guint16     idepth;
+
+       /* The underlying type of the enum */
+       MonoType *enum_basetype;
+
+       guint32    declsec_flags;       /* declarative security attributes flags */
+       guint32    type_token;
+       int        vtable_size; /* number of slots */
 
        guint16     interface_count;
        guint16     interface_id;        /* unique inderface id (for interfaces) */
@@ -267,11 +273,6 @@ struct _MonoClass {
        
        MonoClass **interfaces;
 
-       /*
-        * Computed object instance size, total.
-        */
-       int        instance_size;
-       int        vtable_size; /* number of slots */
        union {
                int class_size; /* size of area for static fields */
                int element_size; /* for array types */
@@ -324,6 +325,23 @@ struct _MonoClass {
 #define MONO_CLASS_IMPLEMENTS_INTERFACE(k,uiid) (((uiid) <= (k)->max_interface_id) && ((k)->interface_bitmap [(uiid) >> 3] & (1 << ((uiid)&7))))
 int mono_class_interface_offset (MonoClass *klass, MonoClass *itf);
 
+typedef struct {
+       gpointer static_data;
+       MonoClass *klass;
+       MonoVTable *vtable;
+} MonoRuntimeGenericSuperInfo;
+
+typedef struct {
+       gpointer static_data;
+       MonoClass *klass;
+       MonoVTable *vtable;
+} MonoRuntimeGenericArgInfo;
+
+typedef struct {
+       MonoDomain *domain;
+       MonoRuntimeGenericArgInfo arg_infos [MONO_ZERO_LEN_ARRAY];
+} MonoRuntimeGenericContext;
+
 /* the interface_offsets array is stored in memory before this struct */
 struct MonoVTable {
        MonoClass  *klass;
@@ -342,6 +360,7 @@ struct MonoVTable {
        guint initialized     : 1; /* cctor has been run */
        guint init_failed     : 1; /* cctor execution failed */
        guint32     imt_collisions_bitmap;
+       MonoRuntimeGenericContext *runtime_generic_context;
        /* do not add any fields after vtable, the structure is dynamically extended */
         gpointer    vtable [MONO_ZERO_LEN_ARRAY];      
 };
@@ -498,6 +517,7 @@ typedef struct {
        MonoClass *klass; /* If kind != TYPE */
        const char *member_name; /* If kind != TYPE */
        gboolean ref_only; /* If kind == ASSEMBLY */
+       char *msg; /* If kind == BAD_IMAGE */
 } MonoLoaderError;
 
 #define mono_class_has_parent(klass,parent) (((klass)->idepth >= (parent)->idepth) && ((klass)->supertypes [(parent)->idepth - 1] == (parent)))
@@ -535,6 +555,10 @@ typedef struct {
        gulong generics_sharable_methods;
        gulong generics_unsharable_methods;
        gulong generics_shared_methods;
+       gulong minor_gc_count;
+       gulong major_gc_count;
+       gulong minor_gc_time_usecs;
+       gulong major_gc_time_usecs;
        gboolean enabled;
 } MonoStats;
 
@@ -556,13 +580,20 @@ typedef struct {
        void       *handle;
 } MonoHandleRef;
 
+enum {
+       MONO_GENERIC_SHARING_NONE,
+       MONO_GENERIC_SHARING_CORLIB,
+       MONO_GENERIC_SHARING_ALL
+};
+
 extern MonoStats mono_stats MONO_INTERNAL;
 
 typedef gpointer (*MonoTrampoline)       (MonoMethod *method);
+typedef gpointer (*MonoJumpTrampoline)       (MonoDomain *domain, MonoMethod *method, gboolean add_sync_wrapper);
 typedef gpointer (*MonoRemotingTrampoline)       (MonoMethod *method, MonoRemotingTarget target);
 typedef gpointer (*MonoDelegateTrampoline)       (MonoClass *klass);
 
-typedef gpointer (*MonoLookupDynamicToken) (MonoImage *image, guint32 token, MonoClass **handle_class, MonoGenericContext *context);
+typedef gpointer (*MonoLookupDynamicToken) (MonoImage *image, guint32 token, gboolean valid_token, MonoClass **handle_class, MonoGenericContext *context);
 
 typedef gboolean (*MonoGetCachedClassInfo) (MonoClass *klass, MonoCachedClassInfo *res);
 
@@ -620,9 +651,15 @@ mono_class_needs_cctor_run (MonoClass *klass, MonoMethod *caller) MONO_INTERNAL;
 gboolean
 mono_class_has_special_static_fields (MonoClass *klass) MONO_INTERNAL;
 
+const char*
+mono_class_get_field_default_value (MonoClassField *field, MonoTypeEnum *def_type) MONO_INTERNAL;
+
 void
 mono_install_trampoline (MonoTrampoline func) MONO_INTERNAL;
 
+void
+mono_install_jump_trampoline (MonoJumpTrampoline func) MONO_INTERNAL;
+
 void
 mono_install_remoting_trampoline (MonoRemotingTrampoline func) MONO_INTERNAL;
 
@@ -633,11 +670,17 @@ gpointer
 mono_lookup_dynamic_token (MonoImage *image, guint32 token, MonoGenericContext *context) MONO_INTERNAL;
 
 gpointer
-mono_lookup_dynamic_token_class (MonoImage *image, guint32 token, MonoClass **handle_class, MonoGenericContext *context) MONO_INTERNAL;
+mono_lookup_dynamic_token_class (MonoImage *image, guint32 token, gboolean check_token, MonoClass **handle_class, MonoGenericContext *context) MONO_INTERNAL;
 
 void
 mono_install_lookup_dynamic_token (MonoLookupDynamicToken func) MONO_INTERNAL;
 
+gpointer
+mono_runtime_create_jump_trampoline (MonoDomain *domain, MonoMethod *method, gboolean add_sync_wrapper) MONO_INTERNAL;
+
+gpointer
+mono_runtime_create_delegate_trampoline (MonoClass *klass) MONO_INTERNAL;
+
 void
 mono_install_get_cached_class_info (MonoGetCachedClassInfo func) MONO_INTERNAL;
 
@@ -761,6 +804,8 @@ mono_loader_set_error_method_load (const char *class_name, const char *member_na
 
 void
 mono_loader_set_error_field_load (MonoClass *klass, const char *member_name) MONO_INTERNAL;
+void
+mono_loader_set_error_bad_image (char *msg) MONO_INTERNAL;
 
 MonoException *
 mono_loader_error_prepare_exception (MonoLoaderError *error) MONO_INTERNAL;
@@ -852,5 +897,11 @@ mono_type_get_full        (MonoImage *image, guint32 type_token, MonoGenericCont
 gboolean
 mono_generic_class_is_generic_type_definition (MonoGenericClass *gklass) MONO_INTERNAL;
 
+MonoType*
+mono_type_get_basic_type_from_generic (MonoType *type) MONO_INTERNAL;
+
+gboolean
+mono_class_generic_sharing_enabled (MonoClass *class) MONO_INTERNAL;
+
 #endif /* __MONO_METADATA_CLASS_INTERBALS_H__ */