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

◆ CompileConvertUnaryExpression()

void System.Linq.Expressions.Interpreter.LightCompiler.CompileConvertUnaryExpression ( Expression expr)
inlineprivate

Definition at line 742 of file LightCompiler.cs.

743 {
744 UnaryExpression unaryExpression = (UnaryExpression)expr;
745 if (unaryExpression.Method != null)
746 {
747 BranchLabel label = _instructions.MakeLabel();
748 BranchLabel branchLabel = _instructions.MakeLabel();
750 ParameterInfo[] parametersCached = method.GetParametersCached();
753 Type type = operand.Type;
754 LocalDefinition definition = _locals.DefineLocal(Expression.Parameter(type), _instructions.Count);
755 ByRefUpdater byRefUpdater = null;
756 Type type2 = parameterInfo.ParameterType;
757 if (type2.IsByRef)
758 {
759 if (unaryExpression.IsLifted)
760 {
761 Compile(unaryExpression.Operand);
762 }
763 else
764 {
766 type2 = type2.GetElementType();
767 }
768 }
769 else
770 {
771 Compile(unaryExpression.Operand);
772 }
774 if (!type.IsValueType || (type.IsNullableType() && unaryExpression.IsLiftedToNull))
775 {
777 _instructions.EmitLoad(null, typeof(object));
780 }
782 if (type.IsNullableType() && type2.Equals(type.GetNonNullableType()))
783 {
784 _instructions.Emit(NullableMethodCallInstruction.CreateGetValue());
785 }
786 if (byRefUpdater == null)
787 {
789 }
790 else
791 {
793 byRefUpdater.UndefineTemps(_instructions, _locals);
794 }
797 _instructions.EmitLoad(null, typeof(object));
800 }
801 else if (unaryExpression.Type == typeof(void))
802 {
804 }
805 else
806 {
807 Compile(unaryExpression.Operand);
808 CompileConvertToType(unaryExpression.Operand.Type, unaryExpression.Type, unaryExpression.NodeType == ExpressionType.ConvertChecked, unaryExpression.IsLiftedToNull);
809 }
810 }
void EmitEqual(Type type, bool liftedToNull=false)
void EmitByRefCall(MethodInfo method, ParameterInfo[] parameters, ByRefUpdater[] byrefArgs)
void EmitBranch(OffsetInstruction instruction, BranchLabel label)
void Compile(Expression expr, bool asVoid)
void CompileConvertToType(Type typeFrom, Type typeTo, bool isChecked, bool isLiftedToNull)
ByRefUpdater CompileAddress(Expression node, int index)
void UndefineLocal(LocalDefinition definition, int end)
LocalDefinition DefineLocal(ParameterExpression variable, int start)

References System.Linq.Expressions.Interpreter.LightCompiler._instructions, System.Linq.Expressions.Interpreter.LightCompiler._locals, System.Linq.Expressions.Interpreter.LightCompiler.Compile(), System.Linq.Expressions.Interpreter.LightCompiler.CompileAddress(), System.Linq.Expressions.Interpreter.LightCompiler.CompileAsVoid(), System.Linq.Expressions.Interpreter.LightCompiler.CompileConvertToType(), System.Linq.Expressions.Interpreter.InstructionList.Count, System.Linq.Expressions.Interpreter.NullableMethodCallInstruction.CreateGetValue(), System.Linq.Expressions.Interpreter.LocalVariables.DefineLocal(), System.Linq.Expressions.Interpreter.InstructionList.Emit(), System.Linq.Expressions.Interpreter.InstructionList.EmitBranch(), System.Linq.Expressions.Interpreter.InstructionList.EmitBranchTrue(), System.Linq.Expressions.Interpreter.InstructionList.EmitByRefCall(), System.Linq.Expressions.Interpreter.InstructionList.EmitCall(), System.Linq.Expressions.Interpreter.InstructionList.EmitEqual(), System.Linq.Expressions.Interpreter.InstructionList.EmitLoad(), System.Linq.Expressions.Interpreter.InstructionList.EmitLoadLocal(), System.Linq.Expressions.Interpreter.InstructionList.EmitStoreLocal(), System.Linq.Expressions.Interpreter.InstructionList.MakeLabel(), System.Linq.Expressions.Interpreter.InstructionList.MarkLabel(), System.Linq.Expressions.Expression< TDelegate >.Parameter(), System.type, and System.Linq.Expressions.Interpreter.LocalVariables.UndefineLocal().

Referenced by System.Linq.Expressions.Interpreter.LightCompiler.CompileNoLabelPush().