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

◆ CompileStringSwitchExpression()

void System.Linq.Expressions.Interpreter.LightCompiler.CompileStringSwitchExpression ( SwitchExpression node)
inlineprivate

Definition at line 1231 of file LightCompiler.cs.

1232 {
1233 LabelInfo labelInfo = DefineLabel(null);
1234 bool flag = node.Type != typeof(void);
1235 Compile(node.SwitchValue);
1240 if (node.DefaultBody != null)
1241 {
1242 Compile(node.DefaultBody, !flag);
1243 }
1244 _instructions.EmitBranch(labelInfo.GetLabel(this), hasResult: false, flag);
1245 for (int i = 0; i < node.Cases.Count; i++)
1246 {
1247 SwitchCase switchCase = node.Cases[i];
1248 int value = _instructions.Count - count;
1249 foreach (ConstantExpression testValue in switchCase.TestValues)
1250 {
1251 string text = (string)testValue.Value;
1252 if (text == null)
1253 {
1254 if (strongBox.Value == 1)
1255 {
1256 strongBox.Value = value;
1257 }
1258 }
1259 else
1260 {
1261 dictionary.TryAdd(text, value);
1262 }
1263 }
1264 Compile(switchCase.Body, !flag);
1265 if (i < node.Cases.Count - 1)
1266 {
1267 _instructions.EmitBranch(labelInfo.GetLabel(this), hasResult: false, flag);
1268 }
1269 }
1270 _instructions.MarkLabel(labelInfo.GetLabel(this));
1271 }
void EmitStringSwitch(Dictionary< string, int > cases, StrongBox< int > nullCase)
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.Linq.Expressions.Interpreter.InstructionList.EmitStringSwitch(), System.Linq.Expressions.Interpreter.InstructionList.MarkLabel(), System.text, and System.value.

Referenced by System.Linq.Expressions.Interpreter.LightCompiler.CompileSwitchExpression().