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

◆ EmitConvertToType()

static void System.Linq.Expressions.Compiler.ILGen.EmitConvertToType ( this ILGenerator il,
Type typeFrom,
Type typeTo,
bool isChecked,
ILocalCache locals )
inlinestaticpackage

Definition at line 447 of file ILGen.cs.

448 {
449 if (!TypeUtils.AreEquivalent(typeFrom, typeTo))
450 {
451 bool flag = typeFrom.IsNullableType();
452 bool flag2 = typeTo.IsNullableType();
453 Type nonNullableType = typeFrom.GetNonNullableType();
454 Type nonNullableType2 = typeTo.GetNonNullableType();
455 if (typeFrom.IsInterface || typeTo.IsInterface || typeFrom == typeof(object) || typeTo == typeof(object) || typeFrom == typeof(Enum) || typeFrom == typeof(ValueType) || TypeUtils.IsLegalExplicitVariantDelegateConversion(typeFrom, typeTo))
456 {
457 il.EmitCastToType(typeFrom, typeTo);
458 }
459 else if (flag || flag2)
460 {
461 il.EmitNullableConversion(typeFrom, typeTo, isChecked, locals);
462 }
463 else if ((!typeFrom.IsConvertible() || !typeTo.IsConvertible()) && (nonNullableType.IsAssignableFrom(nonNullableType2) || nonNullableType2.IsAssignableFrom(nonNullableType)))
464 {
465 il.EmitCastToType(typeFrom, typeTo);
466 }
467 else if (typeFrom.IsArray && typeTo.IsArray)
468 {
469 il.EmitCastToType(typeFrom, typeTo);
470 }
471 else
472 {
473 il.EmitNumericConversion(typeFrom, typeTo, isChecked);
474 }
475 }
476 }
static bool IsLegalExplicitVariantDelegateConversion(Type source, Type dest)
Definition TypeUtils.cs:382
static bool AreEquivalent(Type t1, Type t2)
Definition TypeUtils.cs:664

References System.Dynamic.Utils.TypeUtils.AreEquivalent(), System.Type.IsArray, System.Type.IsAssignableFrom(), System.Type.IsInterface, and System.Dynamic.Utils.TypeUtils.IsLegalExplicitVariantDelegateConversion().