예제 #1
0
        public object HandleAssignmentOperator(CParser withparser, string Operator, string LValue, CParser RValue)
        {
            //Three steps:

            //if the Operator is not the standard Assignment Operator, =...

            //first, we need to figure out what the assign the value to.
            //for now, we either find or create a Variable.
            Variable usevariable = withparser.Variables[LValue];

            if (Operator == ":=")
            {
                usevariable.Value = RValue.Execute();
            }
            else
            {
                //it must be something like += or -=. Get the Binary operator...
                String binop    = Operator.Substring(0, Operator.Length - 1);
                Object OperandA = usevariable.Value;
                Object OperandB = RValue.Execute();
                //perform the binary operation.
                Object result = withparser.HandleOperation(binop, OperandA, OperandB);
                //store it back into the variable.
                usevariable.Value = result;
            }

            return(usevariable.Value);



            return(null);
        }