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

◆ EmitNullableCoalesce()

void System.Linq.Expressions.Compiler.LambdaCompiler.EmitNullableCoalesce ( BinaryExpression b)
inlineprivate

Definition at line 2457 of file LambdaCompiler.cs.

2458 {
2459 LocalBuilder local = GetLocal(b.Left.Type);
2462 EmitExpression(b.Left);
2465 _ilg.EmitHasValue(b.Left.Type);
2467 Type nonNullableType = b.Left.Type.GetNonNullableType();
2468 if (b.Conversion != null)
2469 {
2470 ParameterExpression parameter = b.Conversion.GetParameter(0);
2471 EmitLambdaExpression(b.Conversion);
2472 if (!parameter.Type.IsAssignableFrom(b.Left.Type))
2473 {
2475 _ilg.EmitGetValueOrDefault(b.Left.Type);
2476 }
2477 else
2478 {
2480 }
2481 _ilg.Emit(OpCodes.Callvirt, b.Conversion.Type.GetInvokeMethod());
2482 }
2483 else if (TypeUtils.AreEquivalent(b.Type, b.Left.Type))
2484 {
2486 }
2487 else
2488 {
2490 _ilg.EmitGetValueOrDefault(b.Left.Type);
2492 {
2493 _ilg.EmitConvertToType(nonNullableType, b.Type, isChecked: true, this);
2494 }
2495 }
2499 EmitExpression(b.Right);
2500 if (!TypeUtils.AreEquivalent(b.Right.Type, b.Type))
2501 {
2502 _ilg.EmitConvertToType(b.Right.Type, b.Type, isChecked: true, this);
2503 }
2505 }
static bool AreEquivalent(Type t1, Type t2)
Definition TypeUtils.cs:664
virtual void MarkLabel(Label loc)
virtual void Emit(OpCode opcode)
static readonly OpCode Ldloca
Definition OpCodes.cs:427
static readonly OpCode Brfalse
Definition OpCodes.cs:117
static readonly OpCode Callvirt
Definition OpCodes.cs:225
static readonly OpCode Stloc
Definition OpCodes.cs:429
static readonly OpCode Br
Definition OpCodes.cs:115
static readonly OpCode Ldloc
Definition OpCodes.cs:425

References System.Linq.Expressions.Compiler.LambdaCompiler._ilg, System.Dynamic.Utils.TypeUtils.AreEquivalent(), System.Reflection.Emit.OpCodes.Br, System.Reflection.Emit.OpCodes.Brfalse, System.Reflection.Emit.OpCodes.Callvirt, System.Reflection.Emit.ILGenerator.DefineLabel(), System.Reflection.Emit.ILGenerator.Emit(), System.Linq.Expressions.Compiler.LambdaCompiler.EmitExpression(), System.Linq.Expressions.Compiler.LambdaCompiler.EmitLambdaExpression(), System.Linq.Expressions.Compiler.LambdaCompiler.FreeLocal(), System.Linq.Expressions.Compiler.LambdaCompiler.GetLocal(), System.Reflection.Emit.OpCodes.Ldloc, System.Reflection.Emit.OpCodes.Ldloca, System.Reflection.Emit.ILGenerator.MarkLabel(), and System.Reflection.Emit.OpCodes.Stloc.

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