Пример #1
0
        public Term PerformOperation(Executer exec, Operator op, Term otherTerm)
        {
            //these should be in Types.Object really...
            Types.Object oThis = null;

            //TODO: if it's already been evaluated this time, no need to do it again!
            if (this.Expression != null)
            {
                this.Value = this.Expression.Evaluate(exec);
            }

            oThis = this.Value;

            Types.Object oOther = null;
            if (otherTerm != null)
            {
                //TODO: if it's already been evaluated this time, no need to do it again!
                if (otherTerm.Expression != null)
                {
                    otherTerm.Value = otherTerm.Expression.Evaluate(exec);
                }

                oOther = otherTerm.Value;
            }

            //Here's the bad one: can't well set Value - what about next execution?? E.g. if it was a Variable??
            //this.Value = oThis.PerformOperation(exec, op, oOther);
            //return this.Value;
            Term tNew = new Term();

            tNew.Value = oThis.PerformOperation(exec, op, oOther);
            return(tNew);
        }
Пример #2
0
        public override Object PerformOperation(Executer exec, Operator op, Object otherTerm)
        {
            if (op == null)
            {
                return(this);
            }

            if (op.InternalTokens == ".")
            {
                object oUnboxed = null;
                oUnboxed = this.Evaluate(exec).GetUnboxed(exec);

                if (otherTerm.GetType() == typeof(Method))
                {
                    Method func = (Method)otherTerm;
                    func.BelongsToObject = oUnboxed;
                    return(func.Evaluate(exec));
                }
                if (otherTerm.GetType() == typeof(Variable))
                {
                    Variable var = (Variable)otherTerm;
                    var.BelongsToObject = oUnboxed;
                    var.EvaluateToWrapper(exec);
                    return(var);
                }
                return(null);
            }

            if (op.IsSettingOperator)
            {
                this.EvaluateToWrapper(exec);

                if (!op.IsBinary)
                {
                    //TODO: ++ and -- operators
                    return(this);
                }

                Object oNewVal = otherTerm.Evaluate(exec);
                if (op.InternalTokens != "=")
                {
                    //for other than "=", we need to know the current value
                    string   sSubOp = op.InternalTokens.Substring(0, 1);
                    Operator subOp  = Parser.GetOperator(sSubOp);
                    this.PerformOperation(exec, op, oNewVal);
                    oNewVal = this;
                }
                this.ValueWrapper.Value = oNewVal.GetUnboxed(exec);

                return(oNewVal);
            }

            Object oEvaluated = this.Evaluate(exec);

            return(oEvaluated.PerformOperation(exec, op, otherTerm));
        }
Пример #3
0
        public override Object PerformOperation(Executer exec, Operator op, Object otherTerm)
        {
            Object oNew = this.Evaluate(exec);

            if (op == null)
            {
                return(oNew);
            }
            return(oNew.PerformOperation(exec, op, otherTerm));
        }