Terraria v1.4.4.9
Terraria source code documentation
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros
NotInstruction.cs
Go to the documentation of this file.
2
4
5internal abstract class NotInstruction : Instruction
6{
7 private sealed class NotBoolean : NotInstruction
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(!(bool)obj);
19 }
20 return 1;
21 }
22 }
23
24 private sealed class NotInt64 : NotInstruction
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(~(long)obj);
36 }
37 return 1;
38 }
39 }
40
41 private sealed class NotInt32 : NotInstruction
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(~(int)obj);
53 }
54 return 1;
55 }
56 }
57
58 private sealed class NotInt16 : NotInstruction
59 {
60 public override int Run(InterpretedFrame frame)
61 {
62 object obj = frame.Pop();
63 if (obj == null)
64 {
65 frame.Push(null);
66 }
67 else
68 {
69 frame.Push((short)(~(short)obj));
70 }
71 return 1;
72 }
73 }
74
75 private sealed class NotUInt64 : NotInstruction
76 {
77 public override int Run(InterpretedFrame frame)
78 {
79 object obj = frame.Pop();
80 if (obj == null)
81 {
82 frame.Push(null);
83 }
84 else
85 {
86 frame.Push(~(ulong)obj);
87 }
88 return 1;
89 }
90 }
91
92 private sealed class NotUInt32 : NotInstruction
93 {
94 public override int Run(InterpretedFrame frame)
95 {
96 object obj = frame.Pop();
97 if (obj == null)
98 {
99 frame.Push(null);
100 }
101 else
102 {
103 frame.Push(~(uint)obj);
104 }
105 return 1;
106 }
107 }
108
109 private sealed class NotUInt16 : NotInstruction
110 {
111 public override int Run(InterpretedFrame frame)
112 {
113 object obj = frame.Pop();
114 if (obj == null)
115 {
116 frame.Push(null);
117 }
118 else
119 {
120 frame.Push((ushort)(~(ushort)obj));
121 }
122 return 1;
123 }
124 }
125
126 private sealed class NotByte : NotInstruction
127 {
128 public override int Run(InterpretedFrame frame)
129 {
130 object obj = frame.Pop();
131 if (obj == null)
132 {
133 frame.Push(null);
134 }
135 else
136 {
137 frame.Push((byte)(~(byte)obj));
138 }
139 return 1;
140 }
141 }
142
143 private sealed class NotSByte : NotInstruction
144 {
145 public override int Run(InterpretedFrame frame)
146 {
147 object obj = frame.Pop();
148 if (obj == null)
149 {
150 frame.Push(null);
151 }
152 else
153 {
154 frame.Push((sbyte)(~(sbyte)obj));
155 }
156 return 1;
157 }
158 }
159
160 public static Instruction s_Boolean;
161
162 public static Instruction s_Int64;
163
164 public static Instruction s_Int32;
165
166 public static Instruction s_Int16;
167
168 public static Instruction s_UInt64;
169
170 public static Instruction s_UInt32;
171
172 public static Instruction s_UInt16;
173
174 public static Instruction s_Byte;
175
176 public static Instruction s_SByte;
177
178 public override int ConsumedStack => 1;
179
180 public override int ProducedStack => 1;
181
182 public override string InstructionName => "Not";
183
185 {
186 }
187
189 {
190 return type.GetNonNullableType().GetTypeCode() switch
191 {
192 TypeCode.Boolean => s_Boolean ?? (s_Boolean = new NotBoolean()),
193 TypeCode.Int64 => s_Int64 ?? (s_Int64 = new NotInt64()),
194 TypeCode.Int32 => s_Int32 ?? (s_Int32 = new NotInt32()),
195 TypeCode.Int16 => s_Int16 ?? (s_Int16 = new NotInt16()),
196 TypeCode.UInt64 => s_UInt64 ?? (s_UInt64 = new NotUInt64()),
197 TypeCode.UInt32 => s_UInt32 ?? (s_UInt32 = new NotUInt32()),
198 TypeCode.UInt16 => s_UInt16 ?? (s_UInt16 = new NotUInt16()),
199 TypeCode.Byte => s_Byte ?? (s_Byte = new NotByte()),
200 TypeCode.SByte => s_SByte ?? (s_SByte = new NotSByte()),
201 _ => throw ContractUtils.Unreachable,
202 };
203 }
204}
TypeCode
Definition TypeCode.cs:4