dd8d8c6839c67edb40f1053efd17745c149fd966
[mono.git] / mcs / tools / ildasm / tables.cs
1 using System;
2 using System.IO;
3 using System.Text;
4 using System.Collections.Generic;
5 using System.Linq;
6 using Mono.Cecil;
7 using Mono.Cecil.Cil;
8 using Mono;
9
10 /*
11  * This partial class contains the tables used by the disassembler.
12  */
13 public partial class ILDAsm {
14
15         Dictionary<uint, string> type_access_map = new Dictionary <uint, string> () {
16                 { (uint)TypeAttributes.NotPublic, "private " },
17                 { (uint)TypeAttributes.Public, "public " },
18                 { (uint)TypeAttributes.NestedPublic, "nested public " },
19                 { (uint)TypeAttributes.NestedPrivate, "nested private " },
20                 { (uint)TypeAttributes.NestedFamily, "nested family " },
21                 { (uint)TypeAttributes.NestedAssembly, "nested assembly " },
22                 { (uint)TypeAttributes.NestedFamANDAssem, "nested famandassem " },
23                 { (uint)TypeAttributes.NestedFamORAssem, "nested famorassem " },
24         };
25         Dictionary<uint, string> type_layout_map = new Dictionary <uint, string> () {
26                 { (uint)TypeAttributes.AutoLayout, "auto " },
27                 { (uint)TypeAttributes.SequentialLayout, "sequential " },
28                 { (uint)TypeAttributes.ExplicitLayout, "explicit " }
29         };
30         Dictionary<uint, string> type_string_format_map = new Dictionary <uint, string> () {
31                 { (uint)TypeAttributes.AnsiClass, "ansi " },
32                 { (uint)TypeAttributes.UnicodeClass, "unicode " },
33                 //{ (uint)TypeAttributes.AutoClass, "unicode " },
34         };
35         Dictionary<uint, string> type_flag_map = new Dictionary <uint, string> () {
36                 { (uint)TypeAttributes.Abstract, "abstract " },
37                 { (uint)TypeAttributes.Sealed, "sealed " },
38                 { (uint)TypeAttributes.SpecialName, "specialname " },
39                 { (uint)TypeAttributes.Import, "import " },
40                 { (uint)TypeAttributes.Serializable, "serializable " },
41                 { (uint)TypeAttributes.BeforeFieldInit, "beforefieldinit " },
42                 { (uint)TypeAttributes.RTSpecialName, "rtspecialname " },
43                 //{ (uint)TypeAttributes.HasSecurity, "rtspecialname " },
44                 //{ (uint)TypeAttributes.Forwarder, "rtspecialname " },
45         };
46
47         Dictionary<uint, string> type_sem_map = new Dictionary <uint, string> () {
48                 { (uint)TypeAttributes.Class, "" },
49                 { (uint)TypeAttributes.Interface, "interface " },
50         };
51
52
53         Dictionary<uint, string> field_access_map = new Dictionary <uint, string> () {
54                 { (uint)FieldAttributes.Private, "private " },
55                 { (uint)FieldAttributes.FamANDAssem, "famandassem " },
56                 { (uint)FieldAttributes.Assembly, "assembly " },
57                 { (uint)FieldAttributes.Family, "family " },
58                 { (uint)FieldAttributes.FamORAssem, "famorassem " },
59                 { (uint)FieldAttributes.Public, "public " },
60         };
61
62         Dictionary<uint, string> field_flag_map = new Dictionary <uint, string> () {
63                 { (uint)FieldAttributes.Static, "static " },
64                 { (uint)FieldAttributes.Literal, "literal " },
65                 { (uint)FieldAttributes.InitOnly, "initonly " },
66                 { (uint)FieldAttributes.SpecialName, "specialname " },
67                 { (uint)FieldAttributes.RTSpecialName, "rtspecialname " },
68                 { (uint)FieldAttributes.NotSerialized, "notserialized " },              
69         };
70
71
72         Dictionary<uint, string> method_access_map = new Dictionary <uint, string> () {
73                 { (uint)MethodAttributes.CompilerControlled, "privatescope " },
74                 { (uint)MethodAttributes.Private, "private " },
75                 { (uint)MethodAttributes.Public, "public " },
76                 { (uint)MethodAttributes.Family, "family " },
77                 { (uint)MethodAttributes.FamORAssem, "famorassem " },
78                 { (uint)MethodAttributes.Assembly, "assembly " }
79         };
80
81         Dictionary<uint, string> method_flag_map = new Dictionary <uint, string> () {
82                 { (uint)MethodAttributes.Static, "static " },
83                 { (uint)MethodAttributes.Final, "final " },
84                 { (uint)MethodAttributes.Virtual, "virtual " },
85                 { (uint)MethodAttributes.HideBySig, "hidebysig " },
86                 { (uint)MethodAttributes.NewSlot, "newslot " },
87                 { (uint)MethodAttributes.CheckAccessOnOverride, "strict " },
88                 { (uint)MethodAttributes.Abstract, "abstract " },
89                 { (uint)MethodAttributes.SpecialName, "specialname " },
90                 { (uint)MethodAttributes.RTSpecialName, "rtspecialname " },
91         };
92
93
94         Dictionary<uint, string> method_impl_map = new Dictionary <uint, string> () {
95                 { (uint)MethodImplAttributes.IL, "cil " },
96                 { (uint)MethodImplAttributes.Runtime, "runtime " }
97         };
98         Dictionary<uint, string> method_managed_map = new Dictionary <uint, string> () {
99                 { (uint)MethodImplAttributes.Managed, "managed " }
100         };
101         Dictionary<uint, string> method_impl_flag_map = new Dictionary <uint, string> () {
102                 { (uint)MethodImplAttributes.PreserveSig, "preservesig " },
103                 { (uint)MethodImplAttributes.InternalCall, "internalcall " },
104                 { (uint)MethodImplAttributes.Synchronized, "synchronized " },
105                 { (uint)MethodImplAttributes.NoInlining, "noinlining " },
106         };
107
108
109         Dictionary<NativeType, string> native_type_to_str = new Dictionary<NativeType, string> () {
110                 { NativeType.Boolean, "bool" },
111                 { NativeType.I1, "int8" },
112                 { NativeType.U1, "unsigned int8" },
113                 { NativeType.I2, "int16" },
114                 { NativeType.U2, "unsigned int16" },
115                 { NativeType.I4, "int32" },
116                 { NativeType.U4, "unsigned int32" },
117                 { NativeType.I8, "int64" },
118                 { NativeType.U8, "unsigned int64" },
119                 //{ NativeType.R4, "int32" },
120                 //{ NativeType.R8, "unsigned int32" },
121                 { NativeType.LPStr, "lpstr" },
122                 { NativeType.Int, "int" },
123                 //{ NativeType.Int, "int" },
124                 { NativeType.Func, "method" },
125                 //{ NativeType.Array, "int" },
126                 //{ NativeType.Currency, "method" },
127                 { NativeType.BStr, "bstr " },
128                 { NativeType.LPWStr, "lpwstr" },
129                 //{ NativeType.LPTStr, "lpwstr" },
130                 //{ NativeType.FixedSysString, "lpwstr" },
131                 { NativeType.IUnknown, "iunknown" },
132                 { NativeType.IDispatch, "idispatch" },
133                 { NativeType.Struct, "struct" },
134                 { NativeType.IntF, "interface" },
135                 //{ NativeType.SafeArray, "interface" },
136                 //{ NativeType.FixedArray, "interface" },
137                 //{ NativeType.ByValStr, "interface" },
138                 //{ NativeType.ANSIBStr, "interface" },
139                 //{ NativeType.TBStr, "interface" },
140                 { NativeType.VariantBool, "variant bool" },
141                 { NativeType.ASAny, "as any" },
142                 { NativeType.LPStruct, "lpstruct" },
143                 //{ NativeType.CustomMarshaler, "lpstruct" },
144                 //{ NativeType.Error, "lpstruct" },
145         };
146
147
148         Dictionary<uint, string> pinvoke_char_set_map = new Dictionary <uint, string> () {
149                 { (uint)PInvokeAttributes.CharSetNotSpec, "" },
150                 { (uint)PInvokeAttributes.CharSetAnsi, "ansi " },
151                 { (uint)PInvokeAttributes.CharSetUnicode, "unicode " },
152                 { (uint)PInvokeAttributes.CharSetAuto, "autochar " },
153         };
154
155         Dictionary<uint, string> pinvoke_cconv_map = new Dictionary <uint, string> () {
156                 { (uint)PInvokeAttributes.CallConvWinapi, "winapi " },
157                 { (uint)PInvokeAttributes.CallConvCdecl, "cdecl " },
158                 { (uint)PInvokeAttributes.CallConvStdCall, "stdcall " },
159                 { (uint)PInvokeAttributes.CallConvThiscall, "thiscall " },
160                 { (uint)PInvokeAttributes.CallConvFastcall, "fastcall " },
161         };
162
163         Dictionary<uint, string> pinvoke_flags_map = new Dictionary <uint, string> () {
164                 { (uint)PInvokeAttributes.SupportsLastError, "lasterr " },
165         };
166
167
168         Dictionary<SecurityAction, string> sec_action_to_string = new Dictionary<SecurityAction, string> () {
169                 //{ SecurityAction.Request, "reqmin" },
170                 { SecurityAction.Demand, "demand" },
171                 { SecurityAction.Assert, "assert" },
172                 { SecurityAction.Deny, "deny" },
173                 { SecurityAction.PermitOnly, "permitonly" },
174                 { SecurityAction.LinkDemand, "linkcheck" },
175                 { SecurityAction.InheritDemand, "inheritcheck" },
176                 { SecurityAction.RequestMinimum, "reqmin" },
177                 { SecurityAction.RequestOptional, "reqopt" },
178                 { SecurityAction.RequestRefuse, "reqrefuse" },
179                 //{ SecurityAction.PreJitGrant, "reqmin" },
180                 //{ SecurityAction.PreJitDeny, "reqmin" },
181                 //{ SecurityAction.NonCasDemand, "reqmin" },
182                 //{ SecurityAction.NonCasLinkDemand, "reqmin" },
183                 //{ SecurityAction.NonCasInheritance, "reqmin" },
184         };
185
186
187         Dictionary<string, bool> keyword_table = new Dictionary<string, bool> {
188                 {"9", true},
189                 {"abstract", true},
190                 {"add", true},
191                 {"add.ovf", true},
192                 {"add.ovf.un", true},
193                 {"algorithm", true},
194                 {"alignment", true},
195                 {"and", true},
196                 {"ansi", true},
197                 {"any", true},
198                 {"arglist", true},
199                 {"array", true},
200                 {"as", true},
201                 {"assembly", true},
202                 {"assert", true},
203                 {"at", true},
204                 {"autochar", true},
205                 {"auto", true},
206                 {"beforefieldinit", true},
207                 {"bestfit", true},
208                 {"beq", true},
209                 {"beq.s", true},
210                 {"bge", true},
211                 {"bge.s", true},
212                 {"bge.un", true},
213                 {"bge.un.s", true},
214                 {"bgt", true},
215                 {"bgt.s", true},
216                 {"bgt.un", true},
217                 {"bgt.un.s", true},
218                 {"ble", true},
219                 {"ble.s", true},
220                 {"ble.un", true},
221                 {"ble.un.s", true},
222                 {"blob", true},
223                 {"blob_object", true},
224                 {"blt", true},
225                 {"blt.s", true},
226                 {"blt.un", true},
227                 {"blt.un.s", true},
228                 {"bne.un", true},
229                 {"bne.un.s", true},
230                 {"bool", true},
231                 {"box", true},
232                 {"break", true},
233                 {"brfalse", true},
234                 {"brfalse.s", true},
235                 {"br", true},
236                 {"brinst", true},
237                 {"brinst.s", true},
238                 {"brnull", true},
239                 {"brnull.s", true},
240                 {"br.s", true},
241                 {"brtrue", true},
242                 {"brtrue.s", true},
243                 {"brzero", true},
244                 {"brzero.s", true},
245                 {"bstr", true},
246                 {"bytearray", true},
247                 {"byvalstr", true},
248                 {"call", true},
249                 {"callconv", true},
250                 {"calli", true},
251                 {"callmostderived", true},
252                 {"callvirt", true},
253                 {"carray", true},
254                 {"castclass", true},
255                 {"catch", true},
256                 {"cdecl", true},
257                 {"ceq", true},
258                 {"cf", true},
259                 {"cgt", true},
260                 {"cgt.un", true},
261                 {"char", true},
262                 {"charmaperror", true},
263                 {"cil", true},
264                 {"ckfinite", true},
265                 {"class", true},
266                 {"clsid", true},
267                 {"clt", true},
268                 {"clt.un", true},
269                 {"Compilercontrolled", true},
270                 {"const", true},
271                 {"conv.i1", true},
272                 {"conv.i2", true},
273                 {"conv.i4", true},
274                 {"conv.i8", true},
275                 {"conv.i", true},
276                 {"conv.ovf.i1", true},
277                 {"conv.ovf.i1.un", true},
278                 {"conv.ovf.i2", true},
279                 {"conv.ovf.i2.un", true},
280                 {"conv.ovf.i4", true},
281                 {"conv.ovf.i4.un", true},
282                 {"conv.ovf.i8", true},
283                 {"conv.ovf.i8.un", true},
284                 {"conv.ovf.i", true},
285                 {"conv.ovf.i.un", true},
286                 {"conv.ovf.u1", true},
287                 {"conv.ovf.u1.un", true},
288                 {"conv.ovf.u2", true},
289                 {"conv.ovf.u2.un", true},
290                 {"conv.ovf.u4", true},
291                 {"conv.ovf.u4.un", true},
292                 {"conv.ovf.u8", true},
293                 {"conv.ovf.u8.un", true},
294                 {"conv.ovf.u", true},
295                 {"conv.ovf.u.un", true},
296                 {"conv.r4", true},
297                 {"conv.r8", true},
298                 {"conv.r.un", true},
299                 {"conv.u1", true},
300                 {"conv.u2", true},
301                 {"conv.u4", true},
302                 {"conv.u8", true},
303                 {"conv.u", true},
304                 {"cpblk", true},
305                 {"cpobj", true},
306                 {"currency", true},
307                 {"custom", true},
308                 {"date", true},
309                 {"decimal", true},
310                 {"default", true},
311                 {"demand", true},
312                 {"deny", true},
313                 {"div", true},
314                 {"div.un", true},
315                 {"dup", true},
316                 {"endfault", true},
317                 {"endfilter", true},
318                 {"endfinally", true},
319                 {"endmac", true},
320                 {"enum", true},
321                 {"error", true},
322                 {"explicit", true},
323                 {"extends", true},
324                 {"extern", true},
325                 {"false", true},
326                 {"famandassem", true},
327                 {"family", true},
328                 {"famorassem", true},
329                 {"fastcall", true},
330                 {"fault", true},
331                 {"field", true},
332                 {"filetime", true},
333                 {"filter", true},
334                 {"final", true},
335                 {"finally", true},
336                 {"fixed", true},
337                 {"flags", true},
338                 {"float32", true},
339                 {"float64", true},
340                 {"float", true},
341                 {"forwardref", true},
342                 {"fromunmanaged", true},
343                 {"handler", true},
344                 {"hidebysig", true},
345                 {"hresult", true},
346                 {"idispatch", true},
347                 {"il", true},
348                 {"illegal", true},
349                 {"implements", true},
350                 {"implicitcom", true},
351                 {"implicitres", true},
352                 {"import", true},
353                 {"in", true},
354                 {"inheritcheck", true},
355                 {"initblk", true},
356                 {"init", true},
357                 {"initobj", true},
358                 {"initonly", true},
359                 {"instance", true},
360                 {"int16", true},
361                 {"int32", true},
362                 {"int64", true},
363                 {"int8", true},
364                 {"interface", true},
365                 {"internalcall", true},
366                 {"int", true},
367                 {"isinst", true},
368                 {"iunknown", true},
369                 {"jmp", true},
370                 {"lasterr", true},
371                 {"lcid", true},
372                 {"ldarg.0", true},
373                 {"ldarg.1", true},
374                 {"ldarg.2", true},
375                 {"ldarg.3", true},
376                 {"ldarga", true},
377                 {"ldarga.s", true},
378                 {"ldarg", true},
379                 {"ldarg.s", true},
380                 {"ldc.i4.0", true},
381                 {"ldc.i4.1", true},
382                 {"ldc.i4.2", true},
383                 {"ldc.i4.3", true},
384                 {"ldc.i4.4", true},
385                 {"ldc.i4.5", true},
386                 {"ldc.i4.6", true},
387                 {"ldc.i4.7", true},
388                 {"ldc.i4.8", true},
389                 {"ldc.i4", true},
390                 {"ldc.i4.m1", true},
391                 {"ldc.i4.M1", true},
392                 {"ldc.i4.s", true},
393                 {"ldc.i8", true},
394                 {"ldc.r4", true},
395                 {"ldc.r8", true},
396                 {"ldelem", true},
397                 {"ldelema", true},
398                 {"ldelem.i1", true},
399                 {"ldelem.i2", true},
400                 {"ldelem.i4", true},
401                 {"ldelem.i8", true},
402                 {"ldelem.i", true},
403                 {"ldelem.r4", true},
404                 {"ldelem.r8", true},
405                 {"ldelem.ref", true},
406                 {"ldelem.u1", true},
407                 {"ldelem.u2", true},
408                 {"ldelem.u4", true},
409                 {"ldelem.u8", true},
410                 {"ldflda", true},
411                 {"ldfld", true},
412                 {"ldftn", true},
413                 {"ldind.i1", true},
414                 {"ldind.i2", true},
415                 {"ldind.i4", true},
416                 {"ldind.i8", true},
417                 {"ldind.i", true},
418                 {"ldind.r4", true},
419                 {"ldind.r8", true},
420                 {"ldind.ref", true},
421                 {"ldind.u1", true},
422                 {"ldind.u2", true},
423                 {"ldind.u4", true},
424                 {"ldind.u8", true},
425                 {"ldlen", true},
426                 {"ldloc.0", true},
427                 {"ldloc.1", true},
428                 {"ldloc.2", true},
429                 {"ldloc.3", true},
430                 {"ldloca", true},
431                 {"ldloca.s", true},
432                 {"ldloc", true},
433                 {"ldloc.s", true},
434                 {"ldnull", true},
435                 {"ldobj", true},
436                 {"ldsflda", true},
437                 {"ldsfld", true},
438                 {"ldstr", true},
439                 {"ldtoken", true},
440                 {"ldvirtftn", true},
441                 {"leave", true},
442                 {"leave.s", true},
443                 {"legacy", true},
444                 {"linkcheck", true},
445                 {"literal", true},
446                 {"localloc", true},
447                 {"lpstr", true},
448                 {"lpstruct", true},
449                 {"lptstr", true},
450                 {"lpvoid", true},
451                 {"lpwstr", true},
452                 {"managed", true},
453                 {"marshal", true},
454                 {"method", true},
455                 {"mkrefany", true},
456                 {"modopt", true},
457                 {"modreq", true},
458                 {"mul", true},
459                 {"mul.ovf", true},
460                 {"mul.ovf.un", true},
461                 {"native", true},
462                 {"neg", true},
463                 {"nested", true},
464                 {"newarr", true},
465                 {"newobj", true},
466                 {"newslot", true},
467                 {"noappdomain", true},
468                 {"noinlining", true},
469                 {"nomachine", true},
470                 {"nomangle", true},
471                 {"nometadata", true},
472                 {"noncasdemand", true},
473                 {"noncasinheritance", true},
474                 {"noncaslinkdemand", true},
475                 {"nop", true},
476                 {"noprocess", true},
477                 {"not", true},
478                 {"not_in_gc_heap", true},
479                 {"notremotable", true},
480                 {"notserialized", true},
481                 {"null", true},
482                 {"nullref", true},
483                 {"object", true},
484                 {"objectref", true},
485                 {"off", true},
486                 {"on", true},
487                 {"opt", true},
488                 {"optil", true},
489                 {"or", true},
490                 {"out", true},
491                 {"permitonly", true},
492                 {"pinned", true},
493                 {"pinvokeimpl", true},
494                 {"pop", true},
495                 {"prefix1", true},
496                 {"prefix2", true},
497                 {"prefix3", true},
498                 {"prefix4", true},
499                 {"prefix5", true},
500                 {"prefix6", true},
501                 {"prefix7", true},
502                 {"prefixref", true},
503                 {"prejitdeny", true},
504                 {"prejitgrant", true},
505                 {"preservesig", true},
506                 {"private", true},
507                 {"privatescope", true},
508                 {"property", true},
509                 {"protected", true},
510                 {"public", true},
511                 {"readonly", true},
512                 {"record", true},
513                 {"refany", true},
514                 {"refanytype", true},
515                 {"refanyval", true},
516                 {"rem", true},
517                 {"rem.un", true},
518                 {"reqmin", true},
519                 {"reqopt", true},
520                 {"reqrefuse", true},
521                 {"reqsecobj", true},
522                 {"request", true},
523                 {"ret", true},
524                 {"rethrow", true},
525                 {"retval", true},
526                 {"rtspecialname", true},
527                 {"runtime", true},
528                 {"safearray", true},
529                 {"sealed", true},
530                 {"sequential", true},
531                 {"serializable", true},
532                 {"shl", true},
533                 {"shr", true},
534                 {"shr.un", true},
535                 {"sizeof", true},
536                 {"special", true},
537                 {"specialname", true},
538                 {"starg", true},
539                 {"starg.s", true},
540                 {"static", true},
541                 {"stdcall", true},
542                 {"stelem", true},
543                 {"stelem.i1", true},
544                 {"stelem.i2", true},
545                 {"stelem.i4", true},
546                 {"stelem.i8", true},
547                 {"stelem.i", true},
548                 {"stelem.r4", true},
549                 {"stelem.r8", true},
550                 {"stelem.ref", true},
551                 {"stfld", true},
552                 {"stind.i1", true},
553                 {"stind.i2", true},
554                 {"stind.i4", true},
555                 {"stind.i8", true},
556                 {"stind.i", true},
557                 {"stind.r4", true},
558                 {"stind.r8", true},
559                 {"stloc", true},
560                 {"stobj", true},
561                 {"storage", true},
562                 {"stored_object", true},
563                 {"streamed_object", true},
564                 {"stream", true},
565                 {"strict", true},
566                 {"string", true},
567                 {"struct", true},
568                 {"stsfld", true},
569                 {"sub", true},
570                 {"sub.ovf", true},
571                 {"sub.ovf.un", true},
572                 {"switch", true},
573                 {"synchronized", true},
574                 {"syschar", true},
575                 {"sysstring", true},
576                 {"tbstr", true},
577                 {"thiscall", true},
578                 {"tls", true},
579                 {"to", true},
580                 {"true", true},
581                 {"type", true},
582                 {"typedref", true},
583                 {"uint", true},
584                 {"uint8", true},
585                 {"uint16", true},
586                 {"uint32", true},
587                 {"uint64", true},
588                 {"unbox", true},
589                 {"unicode", true},
590                 {"unmanagedexp", true},
591                 {"unmanaged", true},
592                 {"unsigned", true},
593                 {"userdefined", true},
594                 {"value", true},
595                 {"valuetype", true},
596                 {"vararg", true},
597                 {"variant", true},
598                 {"vector", true},
599                 {"virtual", true},
600                 {"void", true},
601                 {"wchar", true},
602                 {"winapi", true},
603                 {"with", true},
604                 {"xor", true},
605         };
606 }