2 * method-builder.h: Functions for creating IL methods at runtime.
5 * Paolo Molaro (lupus@ximian.com)
7 * (C) 2002 Ximian, Inc. http://www.ximian.com
11 #ifndef __MONO_METHOD_BUILDER_H__
12 #define __MONO_METHOD_BUILDER_H__
14 #include <mono/metadata/class.h>
15 #include <mono/metadata/object-internals.h>
16 #include <mono/metadata/class-internals.h>
17 #include <mono/metadata/opcodes.h>
18 #include <mono/metadata/reflection.h>
22 typedef struct _MonoMethodBuilder
{
29 gboolean skip_visibility
;
30 guint32 code_size
, pos
;
33 MonoExceptionClause
*clauses
;
37 mono_mb_new (MonoClass
*klass
, const char *name
, MonoWrapperType type
) MONO_INTERNAL
;
40 mono_mb_new_no_dup_name (MonoClass
*klass
, const char *name
, MonoWrapperType type
) MONO_INTERNAL
;
43 mono_mb_free (MonoMethodBuilder
*mb
) MONO_INTERNAL
;
46 mono_mb_patch_addr (MonoMethodBuilder
*mb
, int pos
, int value
) MONO_INTERNAL
;
49 mono_mb_patch_addr_s (MonoMethodBuilder
*mb
, int pos
, gint8 value
) MONO_INTERNAL
;
52 mono_mb_patch_branch (MonoMethodBuilder
*mb
, guint32 pos
) MONO_INTERNAL
;
55 mono_mb_patch_short_branch (MonoMethodBuilder
*mb
, guint32 pos
) MONO_INTERNAL
;
58 mono_mb_get_label (MonoMethodBuilder
*mb
) MONO_INTERNAL
;
61 mono_mb_get_pos (MonoMethodBuilder
*mb
) MONO_INTERNAL
;
64 mono_mb_add_data (MonoMethodBuilder
*mb
, gpointer data
) MONO_INTERNAL
;
67 mono_mb_emit_ptr (MonoMethodBuilder
*mb
, gpointer ptr
) MONO_INTERNAL
;
70 mono_mb_emit_calli (MonoMethodBuilder
*mb
, MonoMethodSignature
*sig
) MONO_INTERNAL
;
73 mono_mb_emit_native_call (MonoMethodBuilder
*mb
, MonoMethodSignature
*sig
, gpointer func
) MONO_INTERNAL
;
76 mono_mb_emit_managed_call (MonoMethodBuilder
*mb
, MonoMethod
*method
, MonoMethodSignature
*opt_sig
) MONO_INTERNAL
;
79 mono_mb_emit_icall (MonoMethodBuilder
*mb
, gpointer func
) MONO_INTERNAL
;
82 mono_mb_add_local (MonoMethodBuilder
*mb
, MonoType
*type
) MONO_INTERNAL
;
85 mono_mb_create_method (MonoMethodBuilder
*mb
, MonoMethodSignature
*signature
, int max_stack
) MONO_INTERNAL
;
88 mono_mb_emit_ldarg (MonoMethodBuilder
*mb
, guint argnum
) MONO_INTERNAL
;
91 mono_mb_emit_ldarg_addr (MonoMethodBuilder
*mb
, guint argnum
) MONO_INTERNAL
;
94 mono_mb_emit_ldloc (MonoMethodBuilder
*mb
, guint num
) MONO_INTERNAL
;
97 mono_mb_emit_ldloc_addr (MonoMethodBuilder
*mb
, guint locnum
) MONO_INTERNAL
;
100 mono_mb_emit_stloc (MonoMethodBuilder
*mb
, guint num
) MONO_INTERNAL
;
103 mono_mb_emit_exception (MonoMethodBuilder
*mb
, const char *exc_name
, const char *msg
) MONO_INTERNAL
;
106 mono_mb_emit_exception_full (MonoMethodBuilder
*mb
, const char *exc_nspace
, const char *exc_name
, const char *msg
) MONO_INTERNAL
;
109 mono_mb_emit_icon (MonoMethodBuilder
*mb
, gint32 value
) MONO_INTERNAL
;
112 mono_mb_emit_branch (MonoMethodBuilder
*mb
, guint8 op
) MONO_INTERNAL
;
115 mono_mb_emit_short_branch (MonoMethodBuilder
*mb
, guint8 op
) MONO_INTERNAL
;
118 mono_mb_emit_branch_label (MonoMethodBuilder
*mb
, guint8 op
, guint32 label
) MONO_INTERNAL
;
121 mono_mb_emit_add_to_local (MonoMethodBuilder
*mb
, guint16 local
, gint32 incr
) MONO_INTERNAL
;
124 mono_mb_emit_ldflda (MonoMethodBuilder
*mb
, gint32 offset
) MONO_INTERNAL
;
127 mono_mb_emit_byte (MonoMethodBuilder
*mb
, guint8 op
) MONO_INTERNAL
;
130 mono_mb_emit_i2 (MonoMethodBuilder
*mb
, gint16 data
) MONO_INTERNAL
;
133 mono_mb_emit_i4 (MonoMethodBuilder
*mb
, gint32 data
) MONO_INTERNAL
;
136 mono_mb_emit_op (MonoMethodBuilder
*mb
, guint8 op
, gpointer data
) MONO_INTERNAL
;
139 mono_mb_emit_ldstr (MonoMethodBuilder
*mb
, char *str
) MONO_INTERNAL
;
142 mono_mb_set_clauses (MonoMethodBuilder
*mb
, int num_clauses
, MonoExceptionClause
*clauses
) MONO_INTERNAL
;
146 #endif /* __MONO_METHOD_BUILDER_H__ */