[mini] Always emit safepoints, except WASM
[mono-project.git] / mono / metadata / sre-internals.h
blob3a56a9006152326403d4e0358077e956ccf86a27
1 /**
2 * \file
3 * Copyright 2016 Microsoft
4 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
5 */
6 #ifndef __MONO_METADATA_SRE_INTERNALS_H__
7 #define __MONO_METADATA_SRE_INTERNALS_H__
9 #include <mono/metadata/object-internals.h>
11 /* Keep in sync with System.Reflection.Emit.AssemblyBuilderAccess */
12 enum MonoAssemblyBuilderAccess {
13 MonoAssemblyBuilderAccess_Run = 1, /* 0b0001 */
14 MonoAssemblyBuilderAccess_Save = 2, /* 0b0010 */
15 MonoAssemblyBuilderAccess_RunAndSave = 3, /* Run | Save */
16 MonoAssemblyBuilderAccess_ReflectionOnly = 6, /* Refonly | Save */
17 MonoAssemblyBuilderAccess_RunAndCollect = 9, /* Collect | Run */
20 typedef struct _ArrayMethod ArrayMethod;
22 typedef struct {
23 guint32 owner;
24 MonoReflectionGenericParam *gparam;
25 } GenericParamTableEntry;
27 typedef struct {
28 MonoReflectionILGen *ilgen;
29 MonoReflectionType *rtype;
30 MonoArray *parameters;
31 MonoArray *generic_params;
32 MonoGenericContainer *generic_container;
33 MonoArray *pinfo;
34 MonoArray *opt_types;
35 guint32 attrs;
36 guint32 iattrs;
37 guint32 call_conv;
38 guint32 *table_idx; /* note: it's a pointer */
39 MonoArray *code;
40 MonoObject *type;
41 MonoString *name;
42 MonoBoolean init_locals;
43 MonoBoolean skip_visibility;
44 MonoArray *return_modreq;
45 MonoArray *return_modopt;
46 MonoArray *param_modreq;
47 MonoArray *param_modopt;
48 MonoArray *permissions;
49 MonoMethod *mhandle;
50 guint32 nrefs;
51 gpointer *refs;
52 /* for PInvoke */
53 int charset, extra_flags, native_cc;
54 MonoString *dll, *dllentry;
55 } ReflectionMethodBuilder; /* FIXME raw pointers to managed objects */
57 void
58 mono_reflection_emit_init (void);
60 void
61 mono_reflection_dynimage_basic_init (MonoReflectionAssemblyBuilder *assemblyb);
63 gpointer
64 mono_image_g_malloc0 (MonoImage *image, guint size);
66 #define mono_image_g_malloc0(image, size) (g_cast (mono_image_g_malloc0 ((image), (size))))
68 gboolean
69 mono_is_sre_type_builder (MonoClass *klass);
71 gboolean
72 mono_is_sre_generic_instance (MonoClass *klass);
74 gboolean
75 mono_is_sre_method_on_tb_inst (MonoClass *klass);
77 gboolean
78 mono_is_sre_ctor_builder (MonoClass *klass);
80 gboolean
81 mono_is_sre_ctor_on_tb_inst (MonoClass *klass);
83 gboolean
84 mono_is_sr_mono_cmethod (MonoClass *klass);
86 gboolean
87 mono_is_sr_mono_property (MonoClass *klass);
89 MonoType*
90 mono_reflection_type_get_handle (MonoReflectionType *ref, MonoError *error);
92 gpointer
93 mono_reflection_resolve_object (MonoImage *image, MonoObject *obj, MonoClass **handle_class, MonoGenericContext *context, MonoError *error);
95 gpointer
96 mono_reflection_resolve_object_handle (MonoImage *image, MonoObjectHandle obj, MonoClass **handle_class, MonoGenericContext *context, MonoError *error);
98 MonoType* mono_type_array_get_and_resolve (MonoArrayHandle array, int idx, MonoError* error);
100 void
101 mono_sre_array_method_free (ArrayMethod *am);
103 void
104 mono_sre_generic_param_table_entry_free (GenericParamTableEntry *entry);
106 gboolean
107 mono_reflection_methodbuilder_from_method_builder (ReflectionMethodBuilder *rmb, MonoReflectionMethodBuilder *mb,
108 MonoError *error);
109 gboolean
110 mono_reflection_methodbuilder_from_ctor_builder (ReflectionMethodBuilder *rmb, MonoReflectionCtorBuilder *mb,
111 MonoError *error);
113 guint32
114 mono_reflection_resolution_scope_from_image (MonoDynamicImage *assembly, MonoImage *image);
116 guint32 mono_reflection_method_count_clauses (MonoReflectionILGen *ilgen);
119 /* sre-encode */
121 guint32
122 mono_dynimage_encode_field_signature (MonoDynamicImage *assembly, MonoReflectionFieldBuilder *fb, MonoError *error);
124 guint32
125 mono_dynimage_encode_constant (MonoDynamicImage *assembly, MonoObject *val, MonoTypeEnum *ret_type);
127 guint32
128 mono_dynimage_encode_locals (MonoDynamicImage *assembly, MonoReflectionILGen *ilgen, MonoError *error);
130 guint32
131 mono_dynimage_encode_fieldref_signature (MonoDynamicImage *assembly, MonoImage *field_image, MonoType *type);
133 guint32
134 mono_dynimage_encode_method_signature (MonoDynamicImage *assembly, MonoMethodSignature *sig);
136 guint32
137 mono_dynimage_encode_method_builder_signature (MonoDynamicImage *assembly, ReflectionMethodBuilder *mb,
138 MonoError *error);
140 guint32
141 mono_dynimage_encode_generic_method_sig (MonoDynamicImage *assembly, MonoGenericContext *context);
143 guint32
144 mono_dynimage_encode_typedef_or_ref_full (MonoDynamicImage *assembly, MonoType *type, gboolean try_typespec);
146 guint32
147 mono_dynimage_encode_reflection_sighelper (MonoDynamicImage *assembly, MonoReflectionSigHelperHandle helper,
148 MonoError *error);
150 /* sre-encode, without DISABLE_REFLECTION_EMIT_SAVE (o.w. g_assert_not_reached ()) */
152 guint32
153 mono_dynimage_save_encode_marshal_blob (MonoDynamicImage *assembly, MonoReflectionMarshal *minfo, MonoError *error);
155 guint32
156 mono_dynimage_save_encode_property_signature (MonoDynamicImage *assembly, MonoReflectionPropertyBuilder *fb, MonoError *error);
158 guint32
159 mono_image_get_methodref_token (MonoDynamicImage *assembly, MonoMethod *method, gboolean create_typespec);
161 #endif /* __MONO_METADATA_SRE_INTERNALS_H__ */