Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
LessThanInstruction.cs
Go to the documentation of this file.
2
4
5internal abstract class LessThanInstruction : Instruction
6{
7 private sealed class LessThanSByte : LessThanInstruction
8 {
9 public LessThanSByte(object nullValue)
10 : base(nullValue)
11 {
12 }
13
14 public override int Run(InterpretedFrame frame)
15 {
16 object obj = frame.Pop();
17 object obj2 = frame.Pop();
18 if (obj2 == null || obj == null)
19 {
20 frame.Push(_nullValue);
21 }
22 else
23 {
24 frame.Push((sbyte)obj2 < (sbyte)obj);
25 }
26 return 1;
27 }
28 }
29
30 private sealed class LessThanInt16 : LessThanInstruction
31 {
32 public LessThanInt16(object nullValue)
33 : base(nullValue)
34 {
35 }
36
37 public override int Run(InterpretedFrame frame)
38 {
39 object obj = frame.Pop();
40 object obj2 = frame.Pop();
41 if (obj2 == null || obj == null)
42 {
43 frame.Push(_nullValue);
44 }
45 else
46 {
47 frame.Push((short)obj2 < (short)obj);
48 }
49 return 1;
50 }
51 }
52
53 private sealed class LessThanChar : LessThanInstruction
54 {
55 public LessThanChar(object nullValue)
56 : base(nullValue)
57 {
58 }
59
60 public override int Run(InterpretedFrame frame)
61 {
62 object obj = frame.Pop();
63 object obj2 = frame.Pop();
64 if (obj2 == null || obj == null)
65 {
66 frame.Push(_nullValue);
67 }
68 else
69 {
70 frame.Push((char)obj2 < (char)obj);
71 }
72 return 1;
73 }
74 }
75
76 private sealed class LessThanInt32 : LessThanInstruction
77 {
78 public LessThanInt32(object nullValue)
79 : base(nullValue)
80 {
81 }
82
83 public override int Run(InterpretedFrame frame)
84 {
85 object obj = frame.Pop();
86 object obj2 = frame.Pop();
87 if (obj2 == null || obj == null)
88 {
89 frame.Push(_nullValue);
90 }
91 else
92 {
93 frame.Push((int)obj2 < (int)obj);
94 }
95 return 1;
96 }
97 }
98
99 private sealed class LessThanInt64 : LessThanInstruction
100 {
101 public LessThanInt64(object nullValue)
102 : base(nullValue)
103 {
104 }
105
106 public override int Run(InterpretedFrame frame)
107 {
108 object obj = frame.Pop();
109 object obj2 = frame.Pop();
110 if (obj2 == null || obj == null)
111 {
112 frame.Push(_nullValue);
113 }
114 else
115 {
116 frame.Push((long)obj2 < (long)obj);
117 }
118 return 1;
119 }
120 }
121
122 private sealed class LessThanByte : LessThanInstruction
123 {
124 public LessThanByte(object nullValue)
125 : base(nullValue)
126 {
127 }
128
129 public override int Run(InterpretedFrame frame)
130 {
131 object obj = frame.Pop();
132 object obj2 = frame.Pop();
133 if (obj2 == null || obj == null)
134 {
135 frame.Push(_nullValue);
136 }
137 else
138 {
139 frame.Push((byte)obj2 < (byte)obj);
140 }
141 return 1;
142 }
143 }
144
145 private sealed class LessThanUInt16 : LessThanInstruction
146 {
147 public LessThanUInt16(object nullValue)
148 : base(nullValue)
149 {
150 }
151
152 public override int Run(InterpretedFrame frame)
153 {
154 object obj = frame.Pop();
155 object obj2 = frame.Pop();
156 if (obj2 == null || obj == null)
157 {
158 frame.Push(_nullValue);
159 }
160 else
161 {
162 frame.Push((ushort)obj2 < (ushort)obj);
163 }
164 return 1;
165 }
166 }
167
168 private sealed class LessThanUInt32 : LessThanInstruction
169 {
170 public LessThanUInt32(object nullValue)
171 : base(nullValue)
172 {
173 }
174
175 public override int Run(InterpretedFrame frame)
176 {
177 object obj = frame.Pop();
178 object obj2 = frame.Pop();
179 if (obj2 == null || obj == null)
180 {
181 frame.Push(_nullValue);
182 }
183 else
184 {
185 frame.Push((uint)obj2 < (uint)obj);
186 }
187 return 1;
188 }
189 }
190
191 private sealed class LessThanUInt64 : LessThanInstruction
192 {
193 public LessThanUInt64(object nullValue)
194 : base(nullValue)
195 {
196 }
197
198 public override int Run(InterpretedFrame frame)
199 {
200 object obj = frame.Pop();
201 object obj2 = frame.Pop();
202 if (obj2 == null || obj == null)
203 {
204 frame.Push(_nullValue);
205 }
206 else
207 {
208 frame.Push((ulong)obj2 < (ulong)obj);
209 }
210 return 1;
211 }
212 }
213
214 private sealed class LessThanSingle : LessThanInstruction
215 {
216 public LessThanSingle(object nullValue)
217 : base(nullValue)
218 {
219 }
220
221 public override int Run(InterpretedFrame frame)
222 {
223 object obj = frame.Pop();
224 object obj2 = frame.Pop();
225 if (obj2 == null || obj == null)
226 {
227 frame.Push(_nullValue);
228 }
229 else
230 {
231 frame.Push((float)obj2 < (float)obj);
232 }
233 return 1;
234 }
235 }
236
237 private sealed class LessThanDouble : LessThanInstruction
238 {
239 public LessThanDouble(object nullValue)
240 : base(nullValue)
241 {
242 }
243
244 public override int Run(InterpretedFrame frame)
245 {
246 object obj = frame.Pop();
247 object obj2 = frame.Pop();
248 if (obj2 == null || obj == null)
249 {
250 frame.Push(_nullValue);
251 }
252 else
253 {
254 frame.Push((double)obj2 < (double)obj);
255 }
256 return 1;
257 }
258 }
259
260 private readonly object _nullValue;
261
262 private static Instruction s_SByte;
263
264 private static Instruction s_Int16;
265
266 private static Instruction s_Char;
267
268 private static Instruction s_Int32;
269
270 private static Instruction s_Int64;
271
272 private static Instruction s_Byte;
273
274 private static Instruction s_UInt16;
275
276 private static Instruction s_UInt32;
277
278 private static Instruction s_UInt64;
279
280 private static Instruction s_Single;
281
282 private static Instruction s_Double;
283
285
287
289
291
293
295
297
299
301
303
305
306 public override int ConsumedStack => 2;
307
308 public override int ProducedStack => 1;
309
310 public override string InstructionName => "LessThan";
311
312 private LessThanInstruction(object nullValue)
313 {
314 _nullValue = nullValue;
315 }
316
317 public static Instruction Create(Type type, bool liftedToNull = false)
318 {
319 if (liftedToNull)
320 {
321 return type.GetNonNullableType().GetTypeCode() switch
322 {
323 TypeCode.SByte => s_liftedToNullSByte ?? (s_liftedToNullSByte = new LessThanSByte(null)),
334 _ => throw ContractUtils.Unreachable,
335 };
336 }
337 return type.GetNonNullableType().GetTypeCode() switch
338 {
339 TypeCode.SByte => s_SByte ?? (s_SByte = new LessThanSByte(Utils.BoxedFalse)),
341 TypeCode.Char => s_Char ?? (s_Char = new LessThanChar(Utils.BoxedFalse)),
344 TypeCode.Byte => s_Byte ?? (s_Byte = new LessThanByte(Utils.BoxedFalse)),
350 _ => throw ContractUtils.Unreachable,
351 };
352 }
353}
static Instruction Create(Type type, bool liftedToNull=false)
static readonly object BoxedFalse
Definition Utils.cs:8
TypeCode
Definition TypeCode.cs:4