* roottypes.cs: Rename from tree.cs.
[mono.git] / mono / metadata / metadata-internals.h
index 311b9680f933b48c32147dbc1d85ee6a55b2ba60..664652767da18a6acbea144aaa0af6e3af3e8d8b 100644 (file)
@@ -5,14 +5,26 @@
 #include "mono/metadata/image.h"
 #include "mono/metadata/blob.h"
 #include "mono/metadata/mempool.h"
+#include "mono/metadata/domain-internals.h"
 #include "mono/utils/mono-hash.h"
+#include "mono/utils/mono-compiler.h"
+#include "mono/utils/monobitset.h"
 
 struct _MonoAssembly {
+       /* 
+        * The number of appdomains which have this assembly loaded plus the number of 
+        * assemblies referencing this assembly through an entry in their image->references
+        * arrays. The later is needed because entries in the image->references array
+        * might point to assemblies which are only loaded in some appdomains, and without
+        * the additional reference, they can be freed at any time.
+        * The ref_count is initially 0.
+        */
        int ref_count; /* use atomic operations only */
        char *basedir;
        MonoAssemblyName aname;
        GModule *aot_module;
        MonoImage *image;
+       GSList *friend_assembly_names;
        guint8 in_gac;
        guint8 dynamic;
        guint8 corlib_internal;
@@ -47,7 +59,15 @@ struct _MonoTableInfo {
        guint32   size_bitfield;
 };
 
+#define REFERENCE_MISSING ((gpointer) -1)
+
 struct _MonoImage {
+       /*
+        * The number of assemblies which reference this MonoImage though their 'image'
+        * field plus the number of images which reference this MonoImage through their 
+        * 'modules' field, plus the number of threads holding temporary references to
+        * this image between calls of mono_image_open () and mono_image_close ().
+        */
        int   ref_count;
        FILE *file_descr;
        /* if file_descr is NULL the image was loaded from raw data */
@@ -58,10 +78,14 @@ struct _MonoImage {
        /* Whenever this is a dynamically emitted module */
        guint8 dynamic;
 
+       /* Whenever this is a reflection only image */
+       guint8 ref_only;
+
        char *name;
        const char *assembly_name;
        const char *module_name;
-       const char *version;
+       char *version;
+       gint16 md_version_major, md_version_minor;
        char *guid;
        void *image_info;
        MonoMemPool         *mempool;
@@ -115,16 +139,19 @@ struct _MonoImage {
        GHashTable *memberref_signatures;
        GHashTable *helper_signatures;
 
+       /* Indexed by blob heap indexes */
+       GHashTable *method_signatures;
+
        /*
         * Indexes namespaces to hash tables that map class name to typedef token.
         */
        GHashTable *name_cache;
 
        /*
-        * Indexed by ((rank << 24) | (typedef & 0xffffff)), which limits us to a
-        * maximal rank of 255
+        * Indexed by MonoClass
         */
        GHashTable *array_cache;
+       GHashTable *ptr_cache;
 
        /*
         * indexed by MonoMethodSignature 
@@ -142,6 +169,20 @@ struct _MonoImage {
        GHashTable *remoting_invoke_cache;
        GHashTable *synchronized_cache;
        GHashTable *unbox_wrapper_cache;
+       GHashTable *cominterop_invoke_cache;
+       GHashTable *cominterop_wrapper_cache;
+
+       /*
+        * indexed by MonoClass pointers
+        */
+       GHashTable *ldfld_wrapper_cache;
+       GHashTable *ldflda_wrapper_cache;
+       GHashTable *ldfld_remote_wrapper_cache;
+       GHashTable *stfld_wrapper_cache;
+       GHashTable *stfld_remote_wrapper_cache;
+       GHashTable *isinst_cache;
+       GHashTable *castclass_cache;
+       GHashTable *proxy_isinst_cache;
 
        void *reflection_info;
 
@@ -153,6 +194,9 @@ struct _MonoImage {
 
        /* dll map entries */
        GHashTable *dll_map;
+
+       /* interfaces IDs from this image */
+       MonoBitSet *interface_bitset;
 };
 
 enum {
@@ -233,80 +277,124 @@ struct _MonoDynamicImage {
        MonoDynamicTable tables [MONO_TABLE_NUM];
 };
 
+/* Contains information about assembly binding */
+typedef struct _MonoAssemblyBindingInfo {
+       char *name;
+       char *culture;
+       guchar public_key_token [MONO_PUBLIC_KEY_TOKEN_LENGTH];
+       int major;
+       int minor;
+       AssemblyVersionSet old_version_bottom;
+       AssemblyVersionSet old_version_top;
+       AssemblyVersionSet new_version;
+       guint has_old_version_bottom : 1;
+       guint has_old_version_top : 1;
+       guint has_new_version : 1;
+       guint is_valid : 1;
+} MonoAssemblyBindingInfo;
+
+struct _MonoMethodHeader {
+       guint32      code_size;
+       const unsigned char  *code;
+       guint16      max_stack;
+       unsigned int num_clauses : 15;
+       /* if num_locals != 0, then the following apply: */
+       unsigned int init_locals : 1;
+       guint16      num_locals;
+       MonoExceptionClause *clauses;
+       MonoType    *locals [MONO_ZERO_LEN_ARRAY];
+};
+
 /* for use with allocated memory blocks (assumes alignment is to 8 bytes) */
-guint mono_aligned_addr_hash (gconstpointer ptr);
+guint mono_aligned_addr_hash (gconstpointer ptr) MONO_INTERNAL;
+
+void
+mono_metadata_cleanup (void);
 
-const char *   mono_meta_table_name              (int table);
-void           mono_metadata_compute_table_bases (MonoImage *meta);
+const char *   mono_meta_table_name              (int table) MONO_INTERNAL;
+void           mono_metadata_compute_table_bases (MonoImage *meta) MONO_INTERNAL;
 
-MonoClass**
+gboolean
 mono_metadata_interfaces_from_typedef_full  (MonoImage             *image,
-                                            guint32                table_index,
-                                            guint                 *count,
-                                            MonoGenericContext    *context);
+                                                                                        guint32                table_index,
+                                                                                        MonoClass           ***interfaces,
+                                                                                        guint                 *count,
+                                                                                        MonoGenericContext    *context) MONO_INTERNAL;
 
 MonoArrayType *
 mono_metadata_parse_array_full              (MonoImage             *image,
-                                            MonoGenericContext    *generic_context,
+                                            MonoGenericContainer  *container,
                                             const char            *ptr,
-                                            const char           **rptr);
+                                            const char           **rptr) MONO_INTERNAL;
 
 MonoType *
 mono_metadata_parse_type_full               (MonoImage             *image,
-                                            MonoGenericContext    *generic_context,
+                                            MonoGenericContainer  *container,
                                             MonoParseTypeMode      mode,
                                             short                  opt_attrs,
                                             const char            *ptr,
                                             const char           **rptr);
 
-MonoType *
-mono_type_create_from_typespec_full         (MonoImage             *image,
-                                            MonoGenericContext    *generic_context,
-                                            guint32                type_spec);
-
 MonoMethodSignature *
 mono_metadata_parse_signature_full          (MonoImage             *image,
-                                            MonoGenericContext    *generic_context,
-                                            guint32                token);
+                                            MonoGenericContainer  *generic_container,
+                                            guint32                token) MONO_INTERNAL;
 
 MonoMethodSignature *
 mono_metadata_parse_method_signature_full   (MonoImage             *image,
-                                            MonoGenericContext    *generic_context,
+                                            MonoGenericContainer  *generic_container,
                                             int                     def,
                                             const char             *ptr,
                                             const char            **rptr);
 
 MonoMethodHeader *
 mono_metadata_parse_mh_full                 (MonoImage             *image,
-                                            MonoGenericContext    *generic_context,
+                                            MonoGenericContainer  *container,
                                             const char            *ptr);
 
+int* mono_metadata_get_param_attrs          (MonoImage *m, int def);
+
 guint
-mono_metadata_generic_method_hash           (MonoGenericMethod     *gmethod);
+mono_metadata_generic_method_hash           (MonoGenericMethod     *gmethod) MONO_INTERNAL;
 
 gboolean
 mono_metadata_generic_method_equal          (MonoGenericMethod     *g1,
-                                            MonoGenericMethod     *g2);
+                                            MonoGenericMethod     *g2) MONO_INTERNAL;
 
 MonoGenericInst *
 mono_metadata_parse_generic_inst            (MonoImage             *image,
-                                            MonoGenericContext    *generic_context,
+                                            MonoGenericContainer  *container,
                                             int                    count,
                                             const char            *ptr,
-                                            const char           **rptr);
+                                            const char           **rptr) MONO_INTERNAL;
 
 MonoGenericInst *
-mono_metadata_lookup_generic_inst           (MonoGenericInst       *ginst);
+mono_metadata_lookup_generic_inst           (MonoGenericInst       *ginst) MONO_INTERNAL;
 
 MonoGenericClass *
-mono_metadata_lookup_generic_class          (MonoGenericClass      *gclass);
+mono_metadata_lookup_generic_class          (MonoGenericClass      *gclass) MONO_INTERNAL;
 
 MonoGenericInst *
 mono_metadata_inflate_generic_inst          (MonoGenericInst       *ginst,
-                                            MonoGenericContext    *context);
+                                            MonoGenericContext    *context) MONO_INTERNAL;
+
+void mono_dynamic_stream_reset (MonoDynamicStream* stream) MONO_INTERNAL;
+void mono_assembly_addref      (MonoAssembly *assembly) MONO_INTERNAL;
+
+void mono_config_parse_publisher_policy (const char *filename, MonoAssemblyBindingInfo *binding_info) MONO_INTERNAL;
+
+gboolean
+mono_assembly_name_parse_full               (const char           *name,
+                                             MonoAssemblyName     *aname,
+                                             gboolean save_public_key,
+                                             gboolean *is_version_defined) MONO_INTERNAL;
+
+guint32 mono_metadata_get_generic_param_row (MonoImage *image, guint32 token, guint32 *owner);
+
+void mono_unload_interface_ids (MonoBitSet *bitset) MONO_INTERNAL;
+
 
-void mono_dynamic_stream_reset (MonoDynamicStream* stream);
-void mono_assembly_addref      (MonoAssembly *assembly);
+MonoType *mono_metadata_type_dup_mp (MonoImage *image, const MonoType *original) MONO_INTERNAL;
 
 #endif /* __MONO_METADATA_INTERNALS_H__ */