示例#1
0
            //-------------------------------------------------------------------------------------------------------------------------------------------------

            private void EmitIncrement(ILGenerator il, IOperand <T> operand)
            {
                var overloads = TypeOperators.GetOperators(operand.OperandType);

                operand.EmitLoad(il);

                if (m_Position == UnaryOperatorPosition.Postfix && m_ShouldLeaveValueOnStack)
                {
                    il.Emit(OpCodes.Dup);
                }

                var overloadedOperator = (m_Positive ? overloads.OpIncrement : overloads.OpDecrement);

                if (overloadedOperator != null)
                {
                    il.Emit(OpCodes.Call, overloadedOperator);
                }
                else
                {
                    Helpers.EmitConvertible(il, 1);
                    Helpers.EmitCast(il, typeof(int), operand.OperandType);

                    il.Emit(m_Positive ? OpCodes.Add : OpCodes.Sub);
                }

                if (m_Position == UnaryOperatorPosition.Prefix && m_ShouldLeaveValueOnStack)
                {
                    il.Emit(OpCodes.Dup);
                }
            }
示例#2
0
            public override void Apply(TypeOperators operators)
            {
                var type = typeof(string);

                operators.m_OpAddition = type.GetMethod(
                    "Concat",
                    BindingFlags.Static | BindingFlags.Public,
                    null,
                    new[] { typeof(string), typeof(string) },
                    null);
            }
示例#3
0
            public void Emit(ILGenerator il, IOperand <T> operand)
            {
                var overloads = TypeOperators.GetOperators(operand.OperandType);

                if (overloads.OpNegation != null)
                {
                    Helpers.EmitCall(il, null, overloads.OpNegation, operand);
                }
                else
                {
                    operand.EmitTarget(il);
                    operand.EmitLoad(il);

                    il.Emit(OpCodes.Neg);
                }
            }
示例#4
0
            public void Emit(ILGenerator il, IOperand <T> operand)
            {
                var overloads = TypeOperators.GetOperators(operand.OperandType);

                if (overloads.OpUnaryPlus != null)
                {
                    Helpers.EmitCall(il, null, overloads.OpUnaryPlus, operand);
                }
                else
                {
                    operand.EmitTarget(il);
                    operand.EmitLoad(il);

                    // by default this operator does nothing to the operand
                }
            }
示例#5
0
            //-------------------------------------------------------------------------------------------------------------------------------------------------

            public virtual void Emit(ILGenerator il, IOperand <TLeft> left, IOperand <TRight> right)
            {
                var typeOverloads = TypeOperators.GetOperators(left.OperandType);
                var overload      = m_OverloadSelector(typeOverloads);

                if (overload != null)
                {
                    m_Overloaded = true;
                    Helpers.EmitCall(il, null, overload, left, right);
                }
                else
                {
                    left.EmitTarget(il);
                    left.EmitLoad(il);

                    right.EmitTarget(il);
                    right.EmitLoad(il);

                    il.Emit(m_Instruction);
                }
            }
示例#6
0
 public abstract void Apply(TypeOperators operators);