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

◆ CompileConvertToType()

void System.Linq.Expressions.Interpreter.LightCompiler.CompileConvertToType ( Type typeFrom,
Type typeTo,
bool isChecked,
bool isLiftedToNull )
inlineprivate

Definition at line 812 of file LightCompiler.cs.

813 {
814 if (typeTo.Equals(typeFrom) || (typeFrom.IsValueType && typeTo.IsNullableType() && typeTo.GetNonNullableType().Equals(typeFrom)))
815 {
816 return;
817 }
818 if (typeTo.IsValueType && typeFrom.IsNullableType() && typeFrom.GetNonNullableType().Equals(typeTo))
819 {
820 _instructions.Emit(NullableMethodCallInstruction.CreateGetValue());
821 return;
822 }
823 Type type = typeFrom.GetNonNullableType();
824 Type type2 = typeTo.GetNonNullableType();
825 if ((type.IsNumericOrBool() || type.IsEnum) && (type2.IsNumericOrBool() || type2.IsEnum || type2 == typeof(decimal)))
826 {
827 Type type3 = null;
828 if (type.IsEnum)
829 {
830 type = Enum.GetUnderlyingType(type);
831 }
832 if (type2.IsEnum)
833 {
834 type3 = type2;
835 type2 = Enum.GetUnderlyingType(type2);
836 }
837 TypeCode typeCode = type.GetTypeCode();
838 TypeCode typeCode2 = type2.GetTypeCode();
839 if (typeCode == typeCode2)
840 {
841 if ((object)type3 != null)
842 {
843 if (typeFrom.IsNullableType() && !typeTo.IsNullableType())
844 {
845 _instructions.Emit(NullableMethodCallInstruction.CreateGetValue());
846 }
847 }
848 else
849 {
851 }
852 }
853 else if (isChecked)
854 {
856 }
857 else
858 {
860 }
861 if ((object)type3 != null)
862 {
864 }
865 }
866 else if (typeTo.IsEnum)
867 {
868 _instructions.Emit(NullCheckInstruction.Instance);
870 }
871 else if (!(typeTo == typeof(object)) && !typeTo.IsAssignableFrom(typeFrom))
872 {
874 }
875 }
void EmitNumericConvertChecked(TypeCode from, TypeCode to, bool isLiftedToNull)
void EmitConvertToUnderlying(TypeCode to, bool isLiftedToNull)
void EmitNumericConvertUnchecked(TypeCode from, TypeCode to, bool isLiftedToNull)

References System.Linq.Expressions.Interpreter.LightCompiler._instructions, System.Linq.Expressions.Interpreter.NullableMethodCallInstruction.CreateGetValue(), System.Linq.Expressions.Interpreter.InstructionList.Emit(), System.Linq.Expressions.Interpreter.InstructionList.EmitCast(), System.Linq.Expressions.Interpreter.InstructionList.EmitCastReferenceToEnum(), System.Linq.Expressions.Interpreter.InstructionList.EmitCastToEnum(), System.Linq.Expressions.Interpreter.InstructionList.EmitConvertToUnderlying(), System.Linq.Expressions.Interpreter.InstructionList.EmitNumericConvertChecked(), System.Linq.Expressions.Interpreter.InstructionList.EmitNumericConvertUnchecked(), System.Enum.GetUnderlyingType(), System.Linq.Expressions.Interpreter.NullCheckInstruction.Instance, and System.type.

Referenced by System.Linq.Expressions.Interpreter.LightCompiler.CompileCoalesceBinaryExpression(), and System.Linq.Expressions.Interpreter.LightCompiler.CompileConvertUnaryExpression().