Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
OrInstruction.cs
Go to the documentation of this file.
2
4
5internal abstract class OrInstruction : Instruction
6{
7 private sealed class OrSByte : OrInstruction
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 OrInt16 : OrInstruction
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 OrInt32 : OrInstruction
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 OrInt64 : OrInstruction
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 OrByte : OrInstruction
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 OrUInt16 : OrInstruction
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 OrUInt32 : OrInstruction
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 OrUInt64 : OrInstruction
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 OrBoolean : OrInstruction
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) ? Utils.BoxedTrue : null);
150 }
151 return 1;
152 }
153 if (obj == null)
154 {
155 frame.Push(((bool)obj2) ? Utils.BoxedTrue : null);
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 => "Or";
186
188 {
189 }
190
192 {
193 return type.GetNonNullableType().GetTypeCode() switch
194 {
195 TypeCode.SByte => s_SByte ?? (s_SByte = new OrSByte()),
196 TypeCode.Int16 => s_Int16 ?? (s_Int16 = new OrInt16()),
197 TypeCode.Int32 => s_Int32 ?? (s_Int32 = new OrInt32()),
198 TypeCode.Int64 => s_Int64 ?? (s_Int64 = new OrInt64()),
199 TypeCode.Byte => s_Byte ?? (s_Byte = new OrByte()),
200 TypeCode.UInt16 => s_UInt16 ?? (s_UInt16 = new OrUInt16()),
201 TypeCode.UInt32 => s_UInt32 ?? (s_UInt32 = new OrUInt32()),
202 TypeCode.UInt64 => s_UInt64 ?? (s_UInt64 = new OrUInt64()),
203 TypeCode.Boolean => s_Boolean ?? (s_Boolean = new OrBoolean()),
204 _ => throw ContractUtils.Unreachable,
205 };
206 }
207}
static readonly object BoxedTrue
Definition Utils.cs:10
TypeCode
Definition TypeCode.cs:4