//------------------------------------------------------------------------------------------------------------------------------------------------- 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); } }
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); }
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); } }
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 } }
//------------------------------------------------------------------------------------------------------------------------------------------------- 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); } }
public abstract void Apply(TypeOperators operators);