/// <summary>Runs the Operator on two operands.</summary> /// <param name="left">The left operand.</param> /// <param name="right">The right operand.</param> /// <param name="vars">The local variable storage.</param> /// <param name="context">An object representing context.</param> public CalcValue Run(CalcObject left, CalcObject right, CLLocalStore vars = null, CLContextProvider context = null) { // If the operator is value-based, we'll automatically convert expressions. if (ValueBasedLeft) { left = left.GetValue(vars, context); } if (ValueBasedRight) { right = right.GetValue(vars, context); } // Now get the func. CLBinaryOperatorFunc func = this[left.GetType(), right.GetType()]; // If it's null, we'll throw an exception. if (func == null) { throw new CLException( "Binary operator " + Symbol + " doesn't support parameters " + left.GetType().Name + " and " + right.GetType().Name ); } // Now let's run it. return(func(left, right, vars, context)); }
/// <summary>Runs the Operator on two operands.</summary> /// <param name="param">The right operand.</param> /// <param name="vars">The local variable storage.</param> /// <param name="context">An object representing context.</param> public CalcValue Run(CalcObject param, CLLocalStore vars = null, CLContextProvider context = null) { // If the operator is value-based, we'll automatically convert expressions. if (ValueBased) { param = param.GetValue(vars, context); } // Now get the func. CLUnaryOperatorFunc func = this[param.GetType()]; // If it's null, we'll throw an exception. if (func == null) { throw new CLException( "Binary operator " + Symbol + " doesn't support parameter " + param.GetType().Name ); } // Now let's run it. return(func(param, vars, context)); }