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

◆ EmitSwitchExpression()

void System.Linq.Expressions.Compiler.LambdaCompiler.EmitSwitchExpression ( Expression expr,
CompilationFlags flags )
inlineprivate

Definition at line 2959 of file LambdaCompiler.cs.

2960 {
2961 SwitchExpression switchExpression = (SwitchExpression)expr;
2962 if (switchExpression.Cases.Count == 0)
2963 {
2965 if (switchExpression.DefaultBody != null)
2966 {
2967 EmitExpressionAsType(switchExpression.DefaultBody, switchExpression.Type, flags);
2968 }
2969 }
2970 else
2971 {
2973 {
2974 return;
2975 }
2976 ParameterExpression parameterExpression = Expression.Parameter(switchExpression.SwitchValue.Type, "switchValue");
2977 ParameterExpression parameterExpression2 = Expression.Parameter(GetTestValueType(switchExpression), "testValue");
2980 EmitExpression(switchExpression.SwitchValue);
2982 Label[] array = new Label[switchExpression.Cases.Count];
2983 bool[] array2 = new bool[switchExpression.Cases.Count];
2984 int i = 0;
2985 for (int count = switchExpression.Cases.Count; i < count; i++)
2986 {
2988 foreach (Expression testValue in switchExpression.Cases[i].TestValues)
2989 {
2993 }
2994 }
2996 Label @default = ((switchExpression.DefaultBody == null) ? label : _ilg.DefineLabel());
2997 EmitSwitchCases(switchExpression, array, array2, @default, label, flags);
2998 }
2999 }
void EmitSet(ParameterExpression variable)
void AddLocal(LambdaCompiler gen, ParameterExpression variable)
static Type GetTestValueType(SwitchExpression node)
bool TryEmitHashtableSwitch(SwitchExpression node, CompilationFlags flags)
bool TryEmitSwitchInstruction(SwitchExpression node, CompilationFlags flags)
void EmitExpressionAndBranch(bool branchValue, Expression node, Label label)
void DefineSwitchCaseLabel(SwitchCase @case, out Label label, out bool isGoto)
void EmitSwitchCases(SwitchExpression node, Label[] labels, bool[] isGoto, Label @default, Label end, CompilationFlags flags)
void EmitExpressionAsType(Expression node, Type type, CompilationFlags flags)

References System.Linq.Expressions.Compiler.LambdaCompiler._ilg, System.Linq.Expressions.Compiler.LambdaCompiler._scope, System.Linq.Expressions.Compiler.CompilerScope.AddLocal(), System.array, System.Linq.count, System.Collections.Generic.Dictionary< TKey, TValue >.Count, System.Reflection.Emit.ILGenerator.DefineLabel(), System.Linq.Expressions.Compiler.LambdaCompiler.DefineSwitchCaseLabel(), System.Linq.Expressions.Compiler.LambdaCompiler.EmitExpression(), System.Linq.Expressions.Compiler.LambdaCompiler.EmitExpressionAndBranch(), System.Linq.Expressions.Compiler.LambdaCompiler.EmitExpressionAsType(), System.Linq.Expressions.Compiler.LambdaCompiler.EmitExpressionAsVoid(), System.Linq.Expressions.Compiler.CompilerScope.EmitSet(), System.Linq.Expressions.Compiler.LambdaCompiler.EmitSwitchCases(), System.Linq.Expressions.Expression< TDelegate >.Equal(), System.Linq.Expressions.Compiler.LambdaCompiler.GetTestValueType(), System.Linq.Expressions.Expression< TDelegate >.Parameter(), System.Linq.Expressions.Compiler.LambdaCompiler.TryEmitHashtableSwitch(), and System.Linq.Expressions.Compiler.LambdaCompiler.TryEmitSwitchInstruction().

Referenced by System.Linq.Expressions.Compiler.LambdaCompiler.EmitExpression().