Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ CompileIntSwitchExpression< T >()

void System.Linq.Expressions.Interpreter.LightCompiler.CompileIntSwitchExpression< T > ( SwitchExpression node)
inlineprivate

Definition at line 1200 of file LightCompiler.cs.

1201 {
1202 LabelInfo labelInfo = DefineLabel(null);
1203 bool flag = node.Type != typeof(void);
1204 Compile(node.SwitchValue);
1207 _instructions.EmitIntSwitch(dictionary);
1208 if (node.DefaultBody != null)
1209 {
1210 Compile(node.DefaultBody, !flag);
1211 }
1212 _instructions.EmitBranch(labelInfo.GetLabel(this), hasResult: false, flag);
1213 for (int i = 0; i < node.Cases.Count; i++)
1214 {
1215 SwitchCase switchCase = node.Cases[i];
1216 int value = _instructions.Count - count;
1217 foreach (ConstantExpression testValue in switchCase.TestValues)
1218 {
1219 T key = (T)testValue.Value;
1220 dictionary.TryAdd(key, value);
1221 }
1222 Compile(switchCase.Body, !flag);
1223 if (i < node.Cases.Count - 1)
1224 {
1225 _instructions.EmitBranch(labelInfo.GetLabel(this), hasResult: false, flag);
1226 }
1227 }
1228 _instructions.MarkLabel(labelInfo.GetLabel(this));
1229 }
void EmitBranch(OffsetInstruction instruction, BranchLabel label)
void Compile(Expression expr, bool asVoid)

References System.Linq.Expressions.Interpreter.LightCompiler._instructions, System.Linq.Expressions.Interpreter.LightCompiler.Compile(), System.Linq.Expressions.Interpreter.InstructionList.Count, System.Linq.count, System.Collections.Generic.Dictionary< TKey, TValue >.Count, System.Linq.Expressions.Interpreter.LightCompiler.DefineLabel(), System.dictionary, System.Linq.Expressions.Interpreter.InstructionList.EmitBranch(), System.key, System.Linq.Expressions.Interpreter.InstructionList.MarkLabel(), System.T, and System.value.