Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SubOvfInstruction.cs
Go to the documentation of this file.
2
4
5internal abstract class SubOvfInstruction : Instruction
6{
7 private sealed class SubOvfInt16 : SubOvfInstruction
8 {
9 public override int Run(InterpretedFrame frame)
10 {
11 int stackIndex = frame.StackIndex;
12 object[] data = frame.Data;
13 object obj = data[stackIndex - 2];
14 if (obj != null)
15 {
16 object obj2 = data[stackIndex - 1];
17 data[stackIndex - 2] = ((obj2 == null) ? null : ((object)checked((short)((short)obj - (short)obj2))));
18 }
19 frame.StackIndex = stackIndex - 1;
20 return 1;
21 }
22 }
23
24 private sealed class SubOvfInt32 : SubOvfInstruction
25 {
26 public override int Run(InterpretedFrame frame)
27 {
28 int stackIndex = frame.StackIndex;
29 object[] data = frame.Data;
30 object obj = data[stackIndex - 2];
31 if (obj != null)
32 {
33 object obj2 = data[stackIndex - 1];
34 data[stackIndex - 2] = ((obj2 == null) ? null : ScriptingRuntimeHelpers.Int32ToObject(checked((int)obj - (int)obj2)));
35 }
36 frame.StackIndex = stackIndex - 1;
37 return 1;
38 }
39 }
40
41 private sealed class SubOvfInt64 : SubOvfInstruction
42 {
43 public override int Run(InterpretedFrame frame)
44 {
45 int stackIndex = frame.StackIndex;
46 object[] data = frame.Data;
47 object obj = data[stackIndex - 2];
48 if (obj != null)
49 {
50 object obj2 = data[stackIndex - 1];
51 data[stackIndex - 2] = ((obj2 == null) ? null : ((object)checked((long)obj - (long)obj2)));
52 }
53 frame.StackIndex = stackIndex - 1;
54 return 1;
55 }
56 }
57
58 private sealed class SubOvfUInt16 : SubOvfInstruction
59 {
60 public override int Run(InterpretedFrame frame)
61 {
62 int stackIndex = frame.StackIndex;
63 object[] data = frame.Data;
64 object obj = data[stackIndex - 2];
65 if (obj != null)
66 {
67 object obj2 = data[stackIndex - 1];
68 data[stackIndex - 2] = ((obj2 == null) ? null : ((object)checked((ushort)((ushort)obj - (ushort)obj2))));
69 }
70 frame.StackIndex = stackIndex - 1;
71 return 1;
72 }
73 }
74
75 private sealed class SubOvfUInt32 : SubOvfInstruction
76 {
77 public override int Run(InterpretedFrame frame)
78 {
79 int stackIndex = frame.StackIndex;
80 object[] data = frame.Data;
81 object obj = data[stackIndex - 2];
82 if (obj != null)
83 {
84 object obj2 = data[stackIndex - 1];
85 data[stackIndex - 2] = ((obj2 == null) ? null : ((object)checked((uint)obj - (uint)obj2)));
86 }
87 frame.StackIndex = stackIndex - 1;
88 return 1;
89 }
90 }
91
92 private sealed class SubOvfUInt64 : SubOvfInstruction
93 {
94 public override int Run(InterpretedFrame frame)
95 {
96 int stackIndex = frame.StackIndex;
97 object[] data = frame.Data;
98 object obj = data[stackIndex - 2];
99 if (obj != null)
100 {
101 object obj2 = data[stackIndex - 1];
102 data[stackIndex - 2] = ((obj2 == null) ? null : ((object)checked((ulong)obj - (ulong)obj2)));
103 }
104 frame.StackIndex = stackIndex - 1;
105 return 1;
106 }
107 }
108
109 private static Instruction s_Int16;
110
111 private static Instruction s_Int32;
112
113 private static Instruction s_Int64;
114
115 private static Instruction s_UInt16;
116
117 private static Instruction s_UInt32;
118
119 private static Instruction s_UInt64;
120
121 public override int ConsumedStack => 2;
122
123 public override int ProducedStack => 1;
124
125 public override string InstructionName => "SubOvf";
126
128 {
129 }
130
132 {
133 return type.GetNonNullableType().GetTypeCode() switch
134 {
135 TypeCode.Int16 => s_Int16 ?? (s_Int16 = new SubOvfInt16()),
136 TypeCode.Int32 => s_Int32 ?? (s_Int32 = new SubOvfInt32()),
137 TypeCode.Int64 => s_Int64 ?? (s_Int64 = new SubOvfInt64()),
138 TypeCode.UInt16 => s_UInt16 ?? (s_UInt16 = new SubOvfUInt16()),
139 TypeCode.UInt32 => s_UInt32 ?? (s_UInt32 = new SubOvfUInt32()),
140 TypeCode.UInt64 => s_UInt64 ?? (s_UInt64 = new SubOvfUInt64()),
142 };
143 }
144}
TypeCode
Definition TypeCode.cs:4