3 * Copyright 2018 Microsoft
4 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
6 #ifndef __MONO_METHOD_BUILDER_ILGEN_H__
7 #define __MONO_METHOD_BUILDER_ILGEN_H__
10 #include <mono/metadata/class.h>
11 #include <mono/metadata/object-internals.h>
12 #include <mono/metadata/class-internals.h>
13 #include <mono/metadata/opcodes.h>
14 #include <mono/metadata/reflection.h>
15 #include <mono/metadata/method-builder.h>
18 mono_method_builder_ilgen_init (void);
21 mono_mb_patch_addr (MonoMethodBuilder
*mb
, int pos
, int value
);
24 mono_mb_patch_addr_s (MonoMethodBuilder
*mb
, int pos
, gint8 value
);
27 mono_mb_patch_branch (MonoMethodBuilder
*mb
, guint32 pos
);
30 mono_mb_patch_short_branch (MonoMethodBuilder
*mb
, guint32 pos
);
33 mono_mb_get_label (MonoMethodBuilder
*mb
);
36 mono_mb_get_pos (MonoMethodBuilder
*mb
);
39 mono_mb_emit_ptr (MonoMethodBuilder
*mb
, gpointer ptr
);
42 mono_mb_emit_calli (MonoMethodBuilder
*mb
, MonoMethodSignature
*sig
);
45 mono_mb_emit_native_call (MonoMethodBuilder
*mb
, MonoMethodSignature
*sig
, gpointer func
);
50 mono_mb_emit_native_call (MonoMethodBuilder
*mb
, MonoMethodSignature
*sig
, T func
)
52 mono_mb_emit_native_call (mb
, sig
, (gpointer
)func
);
57 mono_mb_emit_managed_call (MonoMethodBuilder
*mb
, MonoMethod
*method
, MonoMethodSignature
*opt_sig
);
60 mono_mb_emit_icall_id (MonoMethodBuilder
*mb
, MonoJitICallId jit_icall_id
);
62 #define mono_mb_emit_icall(mb, name) (mono_mb_emit_icall_id ((mb), MONO_JIT_ICALL_ ## name))
65 mono_mb_add_local (MonoMethodBuilder
*mb
, MonoType
*type
);
68 mono_mb_emit_ldarg (MonoMethodBuilder
*mb
, guint argnum
);
71 mono_mb_emit_ldarg_addr (MonoMethodBuilder
*mb
, guint argnum
);
74 mono_mb_emit_ldloc (MonoMethodBuilder
*mb
, guint num
);
77 mono_mb_emit_ldloc_addr (MonoMethodBuilder
*mb
, guint locnum
);
80 mono_mb_emit_stloc (MonoMethodBuilder
*mb
, guint num
);
83 mono_mb_emit_exception (MonoMethodBuilder
*mb
, const char *exc_name
, const char *msg
);
86 mono_mb_emit_exception_full (MonoMethodBuilder
*mb
, const char *exc_nspace
, const char *exc_name
, const char *msg
);
89 mono_mb_emit_exception_for_error (MonoMethodBuilder
*mb
, MonoError
*error
);
92 mono_mb_emit_icon (MonoMethodBuilder
*mb
, gint32 value
);
95 mono_mb_emit_icon8 (MonoMethodBuilder
*mb
, gint64 value
);
98 mono_mb_emit_branch (MonoMethodBuilder
*mb
, guint8 op
);
101 mono_mb_emit_short_branch (MonoMethodBuilder
*mb
, guint8 op
);
104 mono_mb_emit_branch_label (MonoMethodBuilder
*mb
, guint8 op
, guint32 label
);
107 mono_mb_emit_add_to_local (MonoMethodBuilder
*mb
, guint16 local
, gint32 incr
);
110 mono_mb_emit_ldflda (MonoMethodBuilder
*mb
, gint32 offset
);
113 mono_mb_emit_byte (MonoMethodBuilder
*mb
, guint8 op
);
116 mono_mb_emit_i2 (MonoMethodBuilder
*mb
, gint16 data
);
119 mono_mb_emit_i4 (MonoMethodBuilder
*mb
, gint32 data
);
122 mono_mb_emit_i8 (MonoMethodBuilder
*mb
, gint64 data
);
125 mono_mb_emit_op (MonoMethodBuilder
*mb
, guint8 op
, gpointer data
);
128 mono_mb_emit_ldstr (MonoMethodBuilder
*mb
, char *str
);
131 mono_mb_set_clauses (MonoMethodBuilder
*mb
, int num_clauses
, MonoExceptionClause
*clauses
);
134 mono_mb_set_param_names (MonoMethodBuilder
*mb
, const char **param_names
);
137 mono_mb_strdup (MonoMethodBuilder
*mb
, const char *s
);