Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
RuntimeOps.cs
Go to the documentation of this file.
9
11
14public static class RuntimeOps
15{
16 internal sealed class RuntimeVariables : IRuntimeVariables
17 {
18 private readonly IStrongBox[] _boxes;
19
20 int IRuntimeVariables.Count => _boxes.Length;
21
22 object IRuntimeVariables.this[int index]
23 {
24 get
25 {
26 return _boxes[index].Value;
27 }
28 set
29 {
31 }
32 }
33
35 {
36 _boxes = boxes;
37 }
38 }
39
41 {
42 private readonly IRuntimeVariables _first;
43
44 private readonly IRuntimeVariables _second;
45
46 private readonly int[] _indexes;
47
48 public int Count => _indexes.Length;
49
50 public object this[int index]
51 {
52 get
53 {
55 if (index < 0)
56 {
57 return _second[-1 - index];
58 }
59 return _first[index];
60 }
61 set
62 {
64 if (index >= 0)
65 {
67 }
68 else
69 {
70 _second[-1 - index] = value;
71 }
72 }
73 }
74
76 {
77 _first = first;
78 _second = second;
80 }
81 }
82
83 private sealed class ExpressionQuoter : ExpressionVisitor
84 {
85 private readonly HoistedLocals _scope;
86
87 private readonly object[] _locals;
88
90
91 internal ExpressionQuoter(HoistedLocals scope, object[] locals)
92 {
93 _scope = scope;
95 }
96
97 protected internal override Expression VisitLambda<T>(Expression<T> node)
98 {
99 if (node.ParameterCount > 0)
100 {
102 int i = 0;
103 for (int parameterCount = node.ParameterCount; i < parameterCount; i++)
104 {
105 hashSet.Add(node.GetParameter(i));
106 }
108 }
110 if (node.ParameterCount > 0)
111 {
113 }
114 if (expression == node.Body)
115 {
116 return node;
117 }
118 return node.Rewrite(expression, null);
119 }
120
121 protected internal override Expression VisitBlock(BlockExpression node)
122 {
123 if (node.Variables.Count > 0)
124 {
126 }
128 if (node.Variables.Count > 0)
129 {
131 }
132 if (array == null)
133 {
134 return node;
135 }
136 return node.Rewrite(node.Variables, array);
137 }
138
140 {
141 if (node.Variable != null)
142 {
143 _shadowedVars.Push(new HashSet<ParameterExpression> { node.Variable });
144 }
147 if (node.Variable != null)
148 {
150 }
151 if (expression == node.Body && expression2 == node.Filter)
152 {
153 return node;
154 }
155 return Expression.MakeCatchBlock(node.Test, node.Variable, expression, expression2);
156 }
157
159 {
160 int count = node.Variables.Count;
163 int[] array = new int[count];
164 for (int i = 0; i < array.Length; i++)
165 {
166 IStrongBox box = GetBox(node.Variables[i]);
167 if (box == null)
168 {
169 array[i] = list2.Count;
170 list2.Add(node.Variables[i]);
171 }
172 else
173 {
174 array[i] = -1 - list.Count;
175 list.Add(box);
176 }
177 }
178 if (list.Count == 0)
179 {
180 return node;
181 }
183 if (list2.Count == 0)
184 {
185 return constantExpression;
186 }
188 }
189
191 {
193 if (box == null)
194 {
195 return node;
196 }
198 }
199
201 {
203 {
205 {
206 return null;
207 }
208 }
210 object[] array = _locals;
211 while (true)
212 {
214 {
215 return (IStrongBox)array[value];
216 }
218 if (hoistedLocals == null)
219 {
220 break;
221 }
223 }
225 }
226 }
227
229 {
230 int IRuntimeVariables.Count => 0;
231
232 object IRuntimeVariables.this[int index]
233 {
234 get
235 {
236 throw new IndexOutOfRangeException();
237 }
238 set
239 {
240 throw new IndexOutOfRangeException();
241 }
242 }
243 }
244
246 {
247 private readonly object[] _data;
248
249 private readonly long[] _indexes;
250
251 public int Count => _indexes.Length;
252
253 public object this[int index]
254 {
255 get
256 {
257 return GetStrongBox(index).Value;
258 }
259 set
260 {
262 }
263 }
264
265 internal RuntimeVariableList(object[] data, long[] indexes)
266 {
267 _data = data;
269 }
270
272 {
273 long num = _indexes[index];
274 object[] array = _data;
275 for (int num2 = (int)(num >> 32); num2 > 0; num2--)
276 {
278 }
279 return (IStrongBox)array[(int)num];
280 }
281 }
282
283 [Obsolete("RuntimeOps has been deprecated and is not supported.", true)]
285 public static bool ExpandoTryGetValue(ExpandoObject expando, object? indexClass, int index, string name, bool ignoreCase, out object? value)
286 {
288 }
289
290 [Obsolete("RuntimeOps has been deprecated and is not supported.", true)]
292 public static object? ExpandoTrySetValue(ExpandoObject expando, object? indexClass, int index, object? value, string name, bool ignoreCase)
293 {
294 expando.TrySetValue(indexClass, index, value, name, ignoreCase, add: false);
295 return value;
296 }
297
298 [Obsolete("RuntimeOps has been deprecated and is not supported.", true)]
300 public static bool ExpandoTryDeleteValue(ExpandoObject expando, object? indexClass, int index, string name, bool ignoreCase)
301 {
302 return expando.TryDeleteValue(indexClass, index, name, ignoreCase, ExpandoObject.Uninitialized);
303 }
304
305 [Obsolete("RuntimeOps has been deprecated and is not supported.", true)]
307 public static bool ExpandoCheckVersion(ExpandoObject expando, object? version)
308 {
309 return expando.Class == version;
310 }
311
312 [Obsolete("RuntimeOps has been deprecated and is not supported.", true)]
314 public static void ExpandoPromoteClass(ExpandoObject expando, object oldClass, object newClass)
315 {
316 expando.PromoteClass(oldClass, newClass);
317 }
318
319 [Obsolete("RuntimeOps has been deprecated and is not supported.", true)]
321 [return: NotNullIfNotNull("expression")]
327
328 [Obsolete("RuntimeOps has been deprecated and is not supported.", true)]
331 {
332 return new MergedRuntimeVariables(first, second, indexes);
333 }
334
335 [Obsolete("RuntimeOps has been deprecated and is not supported.", true)]
337 public static IRuntimeVariables CreateRuntimeVariables(object[] data, long[] indexes)
338 {
339 return new RuntimeVariableList(data, indexes);
340 }
341
342 [Obsolete("RuntimeOps has been deprecated and is not supported.", true)]
345 {
346 return new EmptyRuntimeVariables();
347 }
348}
bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value)
bool ICollection< KeyValuePair< TKey, TValue > >. Contains(KeyValuePair< TKey, TValue > keyValuePair)
void Add(TKey key, TValue value)
static readonly object Uninitialized
static Expression[] VisitBlockExpressions(ExpressionVisitor visitor, BlockExpression block)
static object[] GetParent(object[] locals)
virtual ? Expression Visit(Expression? node)
static ConstantExpression Constant(object? value)
static MethodCallExpression Call(MethodInfo method)
static CatchBlock MakeCatchBlock(Type type, ParameterExpression? variable, Expression body, Expression? filter)
static RuntimeVariablesExpression RuntimeVariables(params ParameterExpression[] variables)
static MemberExpression GetStrongBoxValueField(Expression strongbox)
Definition Utils.cs:88
override CatchBlock VisitCatchBlock(CatchBlock node)
override Expression VisitLambda< T >(Expression< T > node)
Definition RuntimeOps.cs:97
readonly Stack< HashSet< ParameterExpression > > _shadowedVars
Definition RuntimeOps.cs:89
IStrongBox GetBox(ParameterExpression variable)
ExpressionQuoter(HoistedLocals scope, object[] locals)
Definition RuntimeOps.cs:91
override Expression VisitParameter(ParameterExpression node)
override Expression VisitBlock(BlockExpression node)
override Expression VisitRuntimeVariables(RuntimeVariablesExpression node)
MergedRuntimeVariables(IRuntimeVariables first, IRuntimeVariables second, int[] indexes)
Definition RuntimeOps.cs:75
static ? object ExpandoTrySetValue(ExpandoObject expando, object? indexClass, int index, object? value, string name, bool ignoreCase)
static bool ExpandoCheckVersion(ExpandoObject expando, object? version)
static IRuntimeVariables CreateRuntimeVariables()
static ? Expression Quote(Expression? expression, object hoistedLocals, object[] locals)
static void ExpandoPromoteClass(ExpandoObject expando, object oldClass, object newClass)
static IRuntimeVariables CreateRuntimeVariables(object[] data, long[] indexes)
static bool ExpandoTryDeleteValue(ExpandoObject expando, object? indexClass, int index, string name, bool ignoreCase)
static bool ExpandoTryGetValue(ExpandoObject expando, object? indexClass, int index, string name, bool ignoreCase, out object? value)
static IRuntimeVariables MergeRuntimeVariables(IRuntimeVariables first, IRuntimeVariables second, int[] indexes)