Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ILOpCodeExtensions.cs
Go to the documentation of this file.
2
3public static class ILOpCodeExtensions
4{
5 public static bool IsBranch(this ILOpCode opCode)
6 {
7 if (opCode - 43 <= ILOpCode.Ldc_i4_3 || opCode - 221 <= ILOpCode.Break)
8 {
9 return true;
10 }
11 return false;
12 }
13
14 public static int GetBranchOperandSize(this ILOpCode opCode)
15 {
16 switch (opCode)
17 {
18 case ILOpCode.Br_s:
19 case ILOpCode.Brfalse_s:
20 case ILOpCode.Brtrue_s:
21 case ILOpCode.Beq_s:
22 case ILOpCode.Bge_s:
23 case ILOpCode.Bgt_s:
24 case ILOpCode.Ble_s:
25 case ILOpCode.Blt_s:
26 case ILOpCode.Bne_un_s:
27 case ILOpCode.Bge_un_s:
28 case ILOpCode.Bgt_un_s:
29 case ILOpCode.Ble_un_s:
30 case ILOpCode.Blt_un_s:
31 case ILOpCode.Leave_s:
32 return 1;
33 case ILOpCode.Br:
34 case ILOpCode.Brfalse:
35 case ILOpCode.Brtrue:
36 case ILOpCode.Beq:
37 case ILOpCode.Bge:
38 case ILOpCode.Bgt:
39 case ILOpCode.Ble:
40 case ILOpCode.Blt:
41 case ILOpCode.Bne_un:
42 case ILOpCode.Bge_un:
43 case ILOpCode.Bgt_un:
44 case ILOpCode.Ble_un:
45 case ILOpCode.Blt_un:
46 case ILOpCode.Leave:
47 return 4;
48 default:
49 throw new ArgumentException(System.SR.Format(System.SR.UnexpectedOpCode, opCode), "opCode");
50 }
51 }
52
53 public static ILOpCode GetShortBranch(this ILOpCode opCode)
54 {
55 switch (opCode)
56 {
57 case ILOpCode.Br_s:
58 case ILOpCode.Brfalse_s:
59 case ILOpCode.Brtrue_s:
60 case ILOpCode.Beq_s:
61 case ILOpCode.Bge_s:
62 case ILOpCode.Bgt_s:
63 case ILOpCode.Ble_s:
64 case ILOpCode.Blt_s:
65 case ILOpCode.Bne_un_s:
66 case ILOpCode.Bge_un_s:
67 case ILOpCode.Bgt_un_s:
68 case ILOpCode.Ble_un_s:
69 case ILOpCode.Blt_un_s:
70 case ILOpCode.Leave_s:
71 return opCode;
72 case ILOpCode.Br:
73 return ILOpCode.Br_s;
74 case ILOpCode.Brfalse:
75 return ILOpCode.Brfalse_s;
76 case ILOpCode.Brtrue:
77 return ILOpCode.Brtrue_s;
78 case ILOpCode.Beq:
79 return ILOpCode.Beq_s;
80 case ILOpCode.Bge:
81 return ILOpCode.Bge_s;
82 case ILOpCode.Bgt:
83 return ILOpCode.Bgt_s;
84 case ILOpCode.Ble:
85 return ILOpCode.Ble_s;
86 case ILOpCode.Blt:
87 return ILOpCode.Blt_s;
88 case ILOpCode.Bne_un:
89 return ILOpCode.Bne_un_s;
90 case ILOpCode.Bge_un:
91 return ILOpCode.Bge_un_s;
92 case ILOpCode.Bgt_un:
93 return ILOpCode.Bgt_un_s;
94 case ILOpCode.Ble_un:
95 return ILOpCode.Ble_un_s;
96 case ILOpCode.Blt_un:
97 return ILOpCode.Blt_un_s;
98 case ILOpCode.Leave:
99 return ILOpCode.Leave_s;
100 default:
101 throw new ArgumentException(System.SR.Format(System.SR.UnexpectedOpCode, opCode), "opCode");
102 }
103 }
104
105 public static ILOpCode GetLongBranch(this ILOpCode opCode)
106 {
107 switch (opCode)
108 {
109 case ILOpCode.Br:
110 case ILOpCode.Brfalse:
111 case ILOpCode.Brtrue:
112 case ILOpCode.Beq:
113 case ILOpCode.Bge:
114 case ILOpCode.Bgt:
115 case ILOpCode.Ble:
116 case ILOpCode.Blt:
117 case ILOpCode.Bne_un:
118 case ILOpCode.Bge_un:
119 case ILOpCode.Bgt_un:
120 case ILOpCode.Ble_un:
121 case ILOpCode.Blt_un:
122 case ILOpCode.Leave:
123 return opCode;
124 case ILOpCode.Br_s:
125 return ILOpCode.Br;
126 case ILOpCode.Brfalse_s:
127 return ILOpCode.Brfalse;
128 case ILOpCode.Brtrue_s:
129 return ILOpCode.Brtrue;
130 case ILOpCode.Beq_s:
131 return ILOpCode.Beq;
132 case ILOpCode.Bge_s:
133 return ILOpCode.Bge;
134 case ILOpCode.Bgt_s:
135 return ILOpCode.Bgt;
136 case ILOpCode.Ble_s:
137 return ILOpCode.Ble;
138 case ILOpCode.Blt_s:
139 return ILOpCode.Blt;
140 case ILOpCode.Bne_un_s:
141 return ILOpCode.Bne_un;
142 case ILOpCode.Bge_un_s:
143 return ILOpCode.Bge_un;
144 case ILOpCode.Bgt_un_s:
145 return ILOpCode.Bgt_un;
146 case ILOpCode.Ble_un_s:
147 return ILOpCode.Ble_un;
148 case ILOpCode.Blt_un_s:
149 return ILOpCode.Blt_un;
150 case ILOpCode.Leave_s:
151 return ILOpCode.Leave;
152 default:
153 throw new ArgumentException(System.SR.Format(System.SR.UnexpectedOpCode, opCode), "opCode");
154 }
155 }
156}
static int GetBranchOperandSize(this ILOpCode opCode)
static ILOpCode GetLongBranch(this ILOpCode opCode)
static ILOpCode GetShortBranch(this ILOpCode opCode)
static bool IsBranch(this ILOpCode opCode)
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string UnexpectedOpCode
Definition SR.cs:22
Definition SR.cs:7