Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
AndInstruction.cs
Go to the documentation of this file.
2
4
5internal abstract class AndInstruction : Instruction
6{
7 private sealed class AndSByte : AndInstruction
8 {
9 public override int Run(InterpretedFrame frame)
10 {
11 object obj = frame.Pop();
12 object obj2 = frame.Pop();
13 if (obj == null || obj2 == null)
14 {
15 frame.Push(null);
16 return 1;
17 }
18 frame.Push((sbyte)((sbyte)obj & (sbyte)obj2));
19 return 1;
20 }
21 }
22
23 private sealed class AndInt16 : AndInstruction
24 {
25 public override int Run(InterpretedFrame frame)
26 {
27 object obj = frame.Pop();
28 object obj2 = frame.Pop();
29 if (obj == null || obj2 == null)
30 {
31 frame.Push(null);
32 return 1;
33 }
34 frame.Push((short)((short)obj & (short)obj2));
35 return 1;
36 }
37 }
38
39 private sealed class AndInt32 : AndInstruction
40 {
41 public override int Run(InterpretedFrame frame)
42 {
43 object obj = frame.Pop();
44 object obj2 = frame.Pop();
45 if (obj == null || obj2 == null)
46 {
47 frame.Push(null);
48 return 1;
49 }
50 frame.Push((int)obj & (int)obj2);
51 return 1;
52 }
53 }
54
55 private sealed class AndInt64 : AndInstruction
56 {
57 public override int Run(InterpretedFrame frame)
58 {
59 object obj = frame.Pop();
60 object obj2 = frame.Pop();
61 if (obj == null || obj2 == null)
62 {
63 frame.Push(null);
64 return 1;
65 }
66 frame.Push((long)obj & (long)obj2);
67 return 1;
68 }
69 }
70
71 private sealed class AndByte : AndInstruction
72 {
73 public override int Run(InterpretedFrame frame)
74 {
75 object obj = frame.Pop();
76 object obj2 = frame.Pop();
77 if (obj == null || obj2 == null)
78 {
79 frame.Push(null);
80 return 1;
81 }
82 frame.Push((byte)((byte)obj & (byte)obj2));
83 return 1;
84 }
85 }
86
87 private sealed class AndUInt16 : AndInstruction
88 {
89 public override int Run(InterpretedFrame frame)
90 {
91 object obj = frame.Pop();
92 object obj2 = frame.Pop();
93 if (obj == null || obj2 == null)
94 {
95 frame.Push(null);
96 return 1;
97 }
98 frame.Push((ushort)((ushort)obj & (ushort)obj2));
99 return 1;
100 }
101 }
102
103 private sealed class AndUInt32 : AndInstruction
104 {
105 public override int Run(InterpretedFrame frame)
106 {
107 object obj = frame.Pop();
108 object obj2 = frame.Pop();
109 if (obj == null || obj2 == null)
110 {
111 frame.Push(null);
112 return 1;
113 }
114 frame.Push((uint)obj & (uint)obj2);
115 return 1;
116 }
117 }
118
119 private sealed class AndUInt64 : AndInstruction
120 {
121 public override int Run(InterpretedFrame frame)
122 {
123 object obj = frame.Pop();
124 object obj2 = frame.Pop();
125 if (obj == null || obj2 == null)
126 {
127 frame.Push(null);
128 return 1;
129 }
130 frame.Push((ulong)obj & (ulong)obj2);
131 return 1;
132 }
133 }
134
135 private sealed class AndBoolean : AndInstruction
136 {
137 public override int Run(InterpretedFrame frame)
138 {
139 object obj = frame.Pop();
140 object obj2 = frame.Pop();
141 if (obj2 == null)
142 {
143 if (obj == null)
144 {
145 frame.Push(null);
146 }
147 else
148 {
149 frame.Push(((bool)obj) ? null : Utils.BoxedFalse);
150 }
151 return 1;
152 }
153 if (obj == null)
154 {
155 frame.Push(((bool)obj2) ? null : Utils.BoxedFalse);
156 return 1;
157 }
158 frame.Push((bool)obj2 & (bool)obj);
159 return 1;
160 }
161 }
162
163 private static Instruction s_SByte;
164
165 private static Instruction s_Int16;
166
167 private static Instruction s_Int32;
168
169 private static Instruction s_Int64;
170
171 private static Instruction s_Byte;
172
173 private static Instruction s_UInt16;
174
175 private static Instruction s_UInt32;
176
177 private static Instruction s_UInt64;
178
179 private static Instruction s_Boolean;
180
181 public override int ConsumedStack => 2;
182
183 public override int ProducedStack => 1;
184
185 public override string InstructionName => "And";
186
188 {
189 }
190
192 {
193 return type.GetNonNullableType().GetTypeCode() switch
194 {
195 TypeCode.SByte => s_SByte ?? (s_SByte = new AndSByte()),
196 TypeCode.Int16 => s_Int16 ?? (s_Int16 = new AndInt16()),
197 TypeCode.Int32 => s_Int32 ?? (s_Int32 = new AndInt32()),
198 TypeCode.Int64 => s_Int64 ?? (s_Int64 = new AndInt64()),
199 TypeCode.Byte => s_Byte ?? (s_Byte = new AndByte()),
200 TypeCode.UInt16 => s_UInt16 ?? (s_UInt16 = new AndUInt16()),
201 TypeCode.UInt32 => s_UInt32 ?? (s_UInt32 = new AndUInt32()),
202 TypeCode.UInt64 => s_UInt64 ?? (s_UInt64 = new AndUInt64()),
203 TypeCode.Boolean => s_Boolean ?? (s_Boolean = new AndBoolean()),
204 _ => throw ContractUtils.Unreachable,
205 };
206 }
207}
static readonly object BoxedFalse
Definition Utils.cs:8
TypeCode
Definition TypeCode.cs:4