Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
NegateCheckedInstruction.cs
Go to the documentation of this file.
2
4
5internal abstract class NegateCheckedInstruction : Instruction
6{
8 {
9 public override int Run(InterpretedFrame frame)
10 {
11 object obj = frame.Pop();
12 if (obj == null)
13 {
14 frame.Push(null);
15 }
16 else
17 {
18 frame.Push(checked(-(int)obj));
19 }
20 return 1;
21 }
22 }
23
25 {
26 public override int Run(InterpretedFrame frame)
27 {
28 object obj = frame.Pop();
29 if (obj == null)
30 {
31 frame.Push(null);
32 }
33 else
34 {
35 frame.Push(checked((short)(-(short)obj)));
36 }
37 return 1;
38 }
39 }
40
42 {
43 public override int Run(InterpretedFrame frame)
44 {
45 object obj = frame.Pop();
46 if (obj == null)
47 {
48 frame.Push(null);
49 }
50 else
51 {
52 frame.Push(checked(-(long)obj));
53 }
54 return 1;
55 }
56 }
57
58 private static Instruction s_Int16;
59
60 private static Instruction s_Int32;
61
62 private static Instruction s_Int64;
63
64 public override int ConsumedStack => 1;
65
66 public override int ProducedStack => 1;
67
68 public override string InstructionName => "NegateChecked";
69
71 {
72 }
73
74 public static Instruction Create(Type type)
75 {
76 return type.GetNonNullableType().GetTypeCode() switch
77 {
78 TypeCode.Int16 => s_Int16 ?? (s_Int16 = new NegateCheckedInt16()),
79 TypeCode.Int32 => s_Int32 ?? (s_Int32 = new NegateCheckedInt32()),
80 TypeCode.Int64 => s_Int64 ?? (s_Int64 = new NegateCheckedInt64()),
82 };
83 }
84}
TypeCode
Definition TypeCode.cs:4