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

◆ EmitSwitchBucket()

void System.Linq.Expressions.Compiler.LambdaCompiler.EmitSwitchBucket ( SwitchInfo info,
List< SwitchLabel > bucket )
inlineprivate

Definition at line 3194 of file LambdaCompiler.cs.

3195 {
3196 if (bucket.Count == 1)
3197 {
3198 _ilg.Emit(OpCodes.Ldloc, info.Value);
3199 EmitConstant(bucket[0].Constant);
3200 _ilg.Emit(OpCodes.Beq, bucket[0].Label);
3201 return;
3202 }
3203 Label? label = null;
3204 if (info.Is64BitSwitch)
3205 {
3207 _ilg.Emit(OpCodes.Ldloc, info.Value);
3208 EmitConstant(bucket[^1].Constant);
3209 _ilg.Emit(info.IsUnsigned ? OpCodes.Bgt_Un : OpCodes.Bgt, label.Value);
3210 _ilg.Emit(OpCodes.Ldloc, info.Value);
3211 EmitConstant(bucket[0].Constant);
3212 _ilg.Emit(info.IsUnsigned ? OpCodes.Blt_Un : OpCodes.Blt, label.Value);
3213 }
3214 _ilg.Emit(OpCodes.Ldloc, info.Value);
3215 decimal key = bucket[0].Key;
3216 if (key != 0m)
3217 {
3218 EmitConstant(bucket[0].Constant);
3220 }
3221 if (info.Is64BitSwitch)
3222 {
3224 }
3225 int num = (int)(bucket[bucket.Count - 1].Key - bucket[0].Key + 1m);
3226 Label[] array = new Label[num];
3227 int num2 = 0;
3228 foreach (SwitchLabel item in bucket)
3229 {
3230 while (key++ != item.Key)
3231 {
3232 array[num2++] = info.Default;
3233 }
3234 array[num2++] = item.Label;
3235 }
3237 if (info.Is64BitSwitch)
3238 {
3239 _ilg.MarkLabel(label.Value);
3240 }
3241 }
virtual void MarkLabel(Label loc)
virtual void Emit(OpCode opcode)
static readonly OpCode Conv_I4
Definition OpCodes.cs:213
static readonly OpCode Blt_Un
Definition OpCodes.cs:139
static readonly OpCode Bgt_Un
Definition OpCodes.cs:135
static readonly OpCode Beq
Definition OpCodes.cs:121
static readonly OpCode Sub
Definition OpCodes.cs:181
static readonly OpCode Switch
Definition OpCodes.cs:141
static readonly OpCode Ldloc
Definition OpCodes.cs:425

References System.Linq.Expressions.Compiler.LambdaCompiler._ilg, System.array, System.Reflection.Emit.OpCodes.Beq, System.Reflection.Emit.OpCodes.Bgt, System.Reflection.Emit.OpCodes.Bgt_Un, System.Reflection.Emit.OpCodes.Blt, System.Reflection.Emit.OpCodes.Blt_Un, System.Linq.Expressions.Constant, System.Reflection.Emit.OpCodes.Conv_I4, System.Collections.Generic.Dictionary< TKey, TValue >.Count, System.Reflection.Emit.ILGenerator.DefineLabel(), System.Reflection.Emit.ILGenerator.Emit(), System.Linq.Expressions.Compiler.LambdaCompiler.EmitConstant(), System.info, System.item, System.key, System.Reflection.Emit.OpCodes.Ldloc, System.Reflection.Emit.ILGenerator.MarkLabel(), System.Reflection.Emit.OpCodes.Sub, and System.Reflection.Emit.OpCodes.Switch.

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