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

◆ CompileBinaryExpression()

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

Definition at line 517 of file LightCompiler.cs.

518 {
519 BinaryExpression binaryExpression = (BinaryExpression)expr;
520 if (binaryExpression.Method != null)
521 {
522 if (binaryExpression.IsLifted)
523 {
524 BranchLabel label = _instructions.MakeLabel();
525 LocalDefinition definition = _locals.DefineLocal(Expression.Parameter(binaryExpression.Left.Type), _instructions.Count);
528 LocalDefinition definition2 = _locals.DefineLocal(Expression.Parameter(binaryExpression.Right.Type), _instructions.Count);
531 ExpressionType nodeType = binaryExpression.NodeType;
532 if ((nodeType == ExpressionType.Equal || nodeType == ExpressionType.NotEqual) && !binaryExpression.IsLiftedToNull)
533 {
534 BranchLabel branchLabel = _instructions.MakeLabel();
535 BranchLabel branchLabel2 = _instructions.MakeLabel();
537 _instructions.EmitLoad(null, typeof(object));
541 _instructions.EmitLoad(null, typeof(object));
542 if (binaryExpression.NodeType == ExpressionType.Equal)
543 {
545 }
546 else
547 {
549 }
553 _instructions.EmitLoad(null, typeof(object));
556 _instructions.EmitLoad((binaryExpression.NodeType == ExpressionType.Equal) ? Utils.BoxedFalse : Utils.BoxedTrue, typeof(bool));
562 }
563 else
564 {
565 BranchLabel branchLabel3 = _instructions.MakeLabel();
566 if (binaryExpression.Left.Type.IsNullableOrReferenceType())
567 {
569 _instructions.EmitLoad(null, typeof(object));
572 }
573 if (binaryExpression.Right.Type.IsNullableOrReferenceType())
574 {
576 _instructions.EmitLoad(null, typeof(object));
579 }
586 if (((uint)(nodeType2 - 15) <= 1u || (uint)(nodeType2 - 20) <= 1u) && !binaryExpression.IsLiftedToNull)
587 {
588 _instructions.EmitLoad(Utils.BoxedFalse, typeof(object));
589 }
590 else
591 {
592 _instructions.EmitLoad(null, typeof(object));
593 }
594 }
598 }
599 else
600 {
604 }
605 }
606 else
607 {
608 switch (binaryExpression.NodeType)
609 {
610 case ExpressionType.ArrayIndex:
614 break;
615 case ExpressionType.Add:
616 case ExpressionType.AddChecked:
617 case ExpressionType.Divide:
618 case ExpressionType.Modulo:
619 case ExpressionType.Multiply:
620 case ExpressionType.MultiplyChecked:
621 case ExpressionType.Subtract:
622 case ExpressionType.SubtractChecked:
624 break;
625 case ExpressionType.ExclusiveOr:
629 break;
630 case ExpressionType.Or:
634 break;
635 case ExpressionType.And:
639 break;
640 case ExpressionType.Equal:
642 break;
643 case ExpressionType.NotEqual:
645 break;
646 case ExpressionType.GreaterThan:
647 case ExpressionType.GreaterThanOrEqual:
648 case ExpressionType.LessThan:
649 case ExpressionType.LessThanOrEqual:
651 break;
652 case ExpressionType.LeftShift:
656 break;
657 case ExpressionType.RightShift:
661 break;
662 default:
663 throw new PlatformNotSupportedException(System.SR.Format(System.SR.UnsupportedExpressionType, binaryExpression.NodeType));
664 }
665 }
666 }
void Add(TKey key, TValue value)
void EmitEqual(Type type, bool liftedToNull=false)
void EmitNotEqual(Type type, bool liftedToNull=false)
void EmitBranch(OffsetInstruction instruction, BranchLabel label)
void CompileNotEqual(Expression left, Expression right, bool liftedToNull)
void Compile(Expression expr, bool asVoid)
void CompileEqual(Expression left, Expression right, bool liftedToNull)
void CompileArithmetic(ExpressionType nodeType, Expression left, Expression right)
void UndefineLocal(LocalDefinition definition, int end)
LocalDefinition DefineLocal(ParameterExpression variable, int start)
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string UnsupportedExpressionType
Definition SR.cs:180
Definition SR.cs:7

References System.Linq.Expressions.Interpreter.LightCompiler._instructions, System.Linq.Expressions.Interpreter.LightCompiler._locals, System.Collections.Generic.Dictionary< TKey, TValue >.Add(), System.Linq.Expressions.Utils.BoxedFalse, System.Linq.Expressions.Utils.BoxedTrue, System.Linq.Expressions.Interpreter.LightCompiler.Compile(), System.Linq.Expressions.Interpreter.LightCompiler.CompileArithmetic(), System.Linq.Expressions.Interpreter.LightCompiler.CompileComparison(), System.Linq.Expressions.Interpreter.LightCompiler.CompileEqual(), System.Linq.Expressions.Interpreter.LightCompiler.CompileNotEqual(), System.Linq.Expressions.Interpreter.InstructionList.Count, System.Linq.Expressions.Interpreter.LocalVariables.DefineLocal(), System.Linq.Expressions.Interpreter.InstructionList.EmitAnd(), System.Linq.Expressions.Interpreter.InstructionList.EmitBranch(), System.Linq.Expressions.Interpreter.InstructionList.EmitBranchFalse(), System.Linq.Expressions.Interpreter.InstructionList.EmitBranchTrue(), System.Linq.Expressions.Interpreter.InstructionList.EmitCall(), System.Linq.Expressions.Interpreter.InstructionList.EmitEqual(), System.Linq.Expressions.Interpreter.InstructionList.EmitExclusiveOr(), System.Linq.Expressions.Interpreter.InstructionList.EmitGetArrayItem(), System.Linq.Expressions.Interpreter.InstructionList.EmitLeftShift(), System.Linq.Expressions.Interpreter.InstructionList.EmitLoad(), System.Linq.Expressions.Interpreter.InstructionList.EmitLoadLocal(), System.Linq.Expressions.Interpreter.InstructionList.EmitNotEqual(), System.Linq.Expressions.Interpreter.InstructionList.EmitOr(), System.Linq.Expressions.Interpreter.InstructionList.EmitRightShift(), System.Linq.Expressions.Interpreter.InstructionList.EmitStoreLocal(), System.SR.Format(), System.Linq.Expressions.Interpreter.InstructionList.MakeLabel(), System.Linq.Expressions.Interpreter.InstructionList.MarkLabel(), System.Linq.Expressions.Expression< TDelegate >.Parameter(), System.Linq.Expressions.Interpreter.LocalVariables.UndefineLocal(), and System.SR.UnsupportedExpressionType.

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