2010-05-13 Rodrigo Kumpera <rkumpera@novell.com>
[mono.git] / mono / metadata / method-builder.h
blob73b4e273aad4e39af6a057db92ea0298c8c3d403
1 /*
2 * method-builder.h: Functions for creating IL methods at runtime.
3 *
4 * Author:
5 * Paolo Molaro (lupus@ximian.com)
7 * (C) 2002 Ximian, Inc. http://www.ximian.com
9 */
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>
20 G_BEGIN_DECLS
22 typedef struct _MonoMethodBuilder {
23 MonoMethod *method;
24 char *name;
25 GList *locals_list;
26 int locals;
27 gboolean dynamic;
28 gboolean no_dup_name;
29 gboolean skip_visibility;
30 guint32 code_size, pos;
31 unsigned char *code;
32 int num_clauses;
33 MonoExceptionClause *clauses;
34 } MonoMethodBuilder;
36 MonoMethodBuilder *
37 mono_mb_new (MonoClass *klass, const char *name, MonoWrapperType type) MONO_INTERNAL;
39 MonoMethodBuilder *
40 mono_mb_new_no_dup_name (MonoClass *klass, const char *name, MonoWrapperType type) MONO_INTERNAL;
42 void
43 mono_mb_free (MonoMethodBuilder *mb) MONO_INTERNAL;
45 void
46 mono_mb_patch_addr (MonoMethodBuilder *mb, int pos, int value) MONO_INTERNAL;
48 void
49 mono_mb_patch_addr_s (MonoMethodBuilder *mb, int pos, gint8 value) MONO_INTERNAL;
51 void
52 mono_mb_patch_branch (MonoMethodBuilder *mb, guint32 pos) MONO_INTERNAL;
54 void
55 mono_mb_patch_short_branch (MonoMethodBuilder *mb, guint32 pos) MONO_INTERNAL;
57 int
58 mono_mb_get_label (MonoMethodBuilder *mb) MONO_INTERNAL;
60 int
61 mono_mb_get_pos (MonoMethodBuilder *mb) MONO_INTERNAL;
63 guint32
64 mono_mb_add_data (MonoMethodBuilder *mb, gpointer data) MONO_INTERNAL;
66 void
67 mono_mb_emit_ptr (MonoMethodBuilder *mb, gpointer ptr) MONO_INTERNAL;
69 void
70 mono_mb_emit_calli (MonoMethodBuilder *mb, MonoMethodSignature *sig) MONO_INTERNAL;
72 void
73 mono_mb_emit_native_call (MonoMethodBuilder *mb, MonoMethodSignature *sig, gpointer func) MONO_INTERNAL;
75 void
76 mono_mb_emit_managed_call (MonoMethodBuilder *mb, MonoMethod *method, MonoMethodSignature *opt_sig) MONO_INTERNAL;
78 void
79 mono_mb_emit_icall (MonoMethodBuilder *mb, gpointer func) MONO_INTERNAL;
81 int
82 mono_mb_add_local (MonoMethodBuilder *mb, MonoType *type) MONO_INTERNAL;
84 MonoMethod *
85 mono_mb_create_method (MonoMethodBuilder *mb, MonoMethodSignature *signature, int max_stack) MONO_INTERNAL;
87 void
88 mono_mb_emit_ldarg (MonoMethodBuilder *mb, guint argnum) MONO_INTERNAL;
90 void
91 mono_mb_emit_ldarg_addr (MonoMethodBuilder *mb, guint argnum) MONO_INTERNAL;
93 void
94 mono_mb_emit_ldloc (MonoMethodBuilder *mb, guint num) MONO_INTERNAL;
96 void
97 mono_mb_emit_ldloc_addr (MonoMethodBuilder *mb, guint locnum) MONO_INTERNAL;
99 void
100 mono_mb_emit_stloc (MonoMethodBuilder *mb, guint num) MONO_INTERNAL;
102 void
103 mono_mb_emit_exception (MonoMethodBuilder *mb, const char *exc_name, const char *msg) MONO_INTERNAL;
105 void
106 mono_mb_emit_exception_full (MonoMethodBuilder *mb, const char *exc_nspace, const char *exc_name, const char *msg) MONO_INTERNAL;
108 void
109 mono_mb_emit_icon (MonoMethodBuilder *mb, gint32 value) MONO_INTERNAL;
111 guint32
112 mono_mb_emit_branch (MonoMethodBuilder *mb, guint8 op) MONO_INTERNAL;
114 guint32
115 mono_mb_emit_short_branch (MonoMethodBuilder *mb, guint8 op) MONO_INTERNAL;
117 void
118 mono_mb_emit_branch_label (MonoMethodBuilder *mb, guint8 op, guint32 label) MONO_INTERNAL;
120 void
121 mono_mb_emit_add_to_local (MonoMethodBuilder *mb, guint16 local, gint32 incr) MONO_INTERNAL;
123 void
124 mono_mb_emit_ldflda (MonoMethodBuilder *mb, gint32 offset) MONO_INTERNAL;
126 void
127 mono_mb_emit_byte (MonoMethodBuilder *mb, guint8 op) MONO_INTERNAL;
129 void
130 mono_mb_emit_i2 (MonoMethodBuilder *mb, gint16 data) MONO_INTERNAL;
132 void
133 mono_mb_emit_i4 (MonoMethodBuilder *mb, gint32 data) MONO_INTERNAL;
135 void
136 mono_mb_emit_op (MonoMethodBuilder *mb, guint8 op, gpointer data) MONO_INTERNAL;
138 void
139 mono_mb_emit_ldstr (MonoMethodBuilder *mb, char *str) MONO_INTERNAL;
141 void
142 mono_mb_set_clauses (MonoMethodBuilder *mb, int num_clauses, MonoExceptionClause *clauses) MONO_INTERNAL;
144 G_END_DECLS
146 #endif /* __MONO_METHOD_BUILDER_H__ */