[corlib] Allow DM with an extra param to have the first one bound to null. Fixes...
[mono-project.git] / mono / dis / push-pop.h
blob6223b5edfb7cbf2a58d853408b2d4ab2fb545e2a
1 #error This file is not used.
3 /* Poping */
4 /* 1 bit */
5 #define Pop0 1
6 /* 2 bits */
7 #define Pop1 2
8 /* 3 bits */
9 #define PopI 8
10 /* 1 bit */
11 #define PopI8 64
12 /* 1 bit */
13 #define Pop8 128
14 /* 1 bit */
15 #define PopR4 256
16 /* 1 bit */
17 #define PopR8 512
18 /* 1 bit */
19 #define PopRef 1024
20 /* 1 bit */
21 #define VarPop 2048
23 /* Pushing */
24 #define Push0 1
25 #define PushI 2
26 #define PushI8 4
27 #define PushR4 8
28 #define PushR8 16
29 #define PushRef 32
30 #define VarPush 64
31 #define Push1 128
34 * dis-cil.c: Disassembles CIL byte codes
36 * Author:
37 * Miguel de Icaza (miguel@ximian.com)
39 * (C) 2001 Ximian, Inc.
41 #include <config.h>
42 #include <glib.h>
43 #include <stdio.h>
44 #include "meta.h"
45 #include "dump.h"
46 #include "dis-cil.h"
48 /* Poping */
49 /* 1 bit */
50 #define Pop0 1
51 /* 2 bits */
52 #define Pop1 2
53 /* 3 bits */
54 #define PopI 8
55 /* 1 bit */
56 #define PopI8 64
57 /* 1 bit */
58 #define Pop8 128
59 /* 1 bit */
60 #define PopR4 256
61 /* 1 bit */
62 #define PopR8 512
63 /* 1 bit */
64 #define PopRef 1024
65 /* 1 bit */
66 #define VarPop 2048
68 /* Pushing */
69 #define Push0 1
70 #define PushI 2
71 #define PushI8 4
72 #define PushR4 8
73 #define PushR8 16
74 #define PushRef 32
75 #define VarPush 64
76 #define Push1 128
78 enum {
79 InlineBrTarget = 0,
80 InlineField = 1,
81 InlineI = 2,
82 InlineI8 = 3,
83 InlineMethod = 4,
84 InlineNone = 5,
85 InlineR = 6,
86 InlineSig = 7,
87 InlineString = 8,
88 InlineSwitch = 9,
89 InlineTok = 10,
90 InlineType = 11,
91 InlineVar = 12,
92 ShortInlineBrTarget = 13,
93 ShortInlineI = 14,
94 ShortInlineR = 15,
95 ShortInlineVar = 16,
98 #define OPDEF(a,b,c,d,e,f,g,h,i,j) \
99 { b, c, d, e, g, h, i },
101 typedef struct {
102 char *name;
103 int pop, push;
104 int argument;
105 int bytes;
106 unsigned char o1, o2;
107 } opcode_t;
109 static opcode_t opcodes [300] = {
110 #include "mono/cil/opcode.def"
113 void
114 disassemble_cil (MonoMetadata *m, const unsigned char *start, int size)
116 const unsigned char *end = start + size;
117 const unsigned char *ptr = start;
118 opcode_t *entry;
120 while (ptr < end){
121 if (*ptr == 0xfe){
122 ptr++;
123 entry = &opcodes [*ptr + 256];
124 } else
125 entry = &opcodes [*ptr];
127 ptr++;
129 fprintf (output, "\tIL_%04x: %s ", ptr - start, entry->name);
130 switch (entry->argument){
131 case InlineBrTarget: {
132 gint target = *(gint32 *) ptr;
133 fprintf (output, "IL_%04x", ptr + 4 + target);
134 ptr += 4;
135 break;
138 case InlineField: {
139 token = *(guint32 *) ptr;
140 fprintf (output, "fieldref-0x%08x", token);
141 ptr += 4;
142 break;
145 case InlineI: {
146 int value = *(int *) ptr;
148 fprintf (output, "%d", value);
149 ptr += 4;
150 break;
153 case InlineI8: {
154 gint64 top = *(guint64 *) value;
156 fprintf (output, "%ld", top);
157 ptr += 8;
158 break;
161 case InlineMethod: {
162 token = *(guint32 *) ptr;
163 fprintf (output, "method-0x%08x", token);
164 ptr += 4;
165 break;
168 case InlineNone:
169 break;
171 case InlineR: {
172 double r = *(double *) ptr;
173 fprintf (output, "%g", r);
174 ptr += 8;
175 break;
178 case InlineSig: {
179 guint32 token = *(guint32 *) ptr;
180 fprintf (output, "signature-0x%08x", token);
181 ptr += 4;
182 break;
185 case InlineString: {
186 guint32 token = *(guint32 *) ptr;
188 fprintf (output, "string-%0x08x", token);
189 ptr += 4;
190 break;
193 case InlineSwitch: {
194 guint32 count = *(guint32 *) ptr;
195 guint32 i;
197 ptr += 4;
198 fprintf (output, "(\n\t\t\t");
199 for (i = 0; i < count; i++){
200 fprintf (output, "IL_%x", *(guint32 *) ptr);
201 ptr += 4;
203 fprintf (output, "\t\t\t)");
204 break;
207 case InlineTok: {
208 guint32 token = *(guint32 *) ptr;
210 fprintf (output, "TOKEN_%08x", token);
211 ptr += 4;
212 break;
215 case InlineType: {
216 guint32 token = *(guint32 *) ptr;
218 fprintf (output, "Type-%08x", token);
219 ptr += 4;
220 break;
223 case InlineVar: {
224 gint16 var_idx = *(gint16 *) ptr;
226 fprintf (output, "variable-%d\n", var_idx);
227 ptr += 2;
228 break;
231 case ShortInlineBrTarget: {
232 signed char x = *ptr;
234 fprintf (output, "IL_%04x", ptr - start + 1 + x);
235 ptr++:
236 break;
239 case ShortInlineI: {
240 char x = *ptr;
242 fprintf (output, "0x%02x", x);
243 ptr++;
244 break;
247 case ShortInlineR: {
248 float f = *(float *) ptr;
250 fprintf (output, "%g", (double) f);
251 ptr += 4;
252 break;
255 case ShortInlineVar: {
256 signed char x = *ptr;
258 fprintf (output, "Varidx-%d", (int) x);
259 ptr++;
260 break;
265 fprintf (output, "\n");