Esempio n. 1
0
        public override Value DoOperation(Operator op, Value right, bool assign)
        {
            var     number    = right as NumberValue;
            Complex?newValue  = null;
            bool?   boolValue = null;

            if (number == null)
            {
                switch (op)
                {
                case Operator.Negate:
                    newValue = -Value;
                    break;

                case Operator.Substitute:
                case Operator.Evaluate:
                    return(this);

                case Operator.Magnitude:
                    return(RealValue.Get(Magnitude));
                }
            }
            else
            {
                newValue = BinaryOperation(op, Value, number.AsComplex);
                if (newValue == null)
                {
                    boolValue = Test(op, Value, number.AsComplex);
                }
            }
            if (boolValue.HasValue)
            {
                return(BoolValue.Get(boolValue.Value));
            }
            else if (newValue.HasValue)
            {
                return(assign ? SetValue(newValue.Value) : Get(newValue.Value));
            }
            return(null);
        }