Exemplo n.º 1
0
 public override RpnNode Evaluate(RpnStack stack)
 {
     int stackCount = stack.Count;
     double x = stack[stackCount - 1].Value() + stack[stackCount - 2].Value();
     stack.RemoveRange(stackCount - 2, 2);
     return new RpnNodeConst(x);
 }
Exemplo n.º 2
0
        public override RpnNode Evaluate(RpnStack stack)
        {
            int    stackCount = stack.Count;
            double x          = stack[stackCount - 1].Value() + stack[stackCount - 2].Value();

            stack.RemoveRange(stackCount - 2, 2);
            return(new RpnNodeConst(x));
        }
Exemplo n.º 3
0
        /// <summary>
        ///	Evaluate the expression relative to cell(row, col)
        /// </summary>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <returns></returns>
        public double Evaluate(RpnExpression expr, int row, int col)
        {
            FormulaCell thisCell = (FormulaCell)_sheet.Cells[row, col];

            if (!thisCell.IsDirty)
            {
                return(thisCell.Value);
            }

            RpnStack stack = new RpnStack();

            foreach (RpnNode n in expr.Nodes)
            {
                if (n.IsValueType())
                {
                    stack.Add(n);
                }
                else if (n.GetType() == typeof(RpnNodeCellRef))
                {
                    RpnNodeCellRef n1   = (RpnNodeCellRef)n;
                    int            row1 = row + n1._row;
                    int            col1 = col + n1._col;
                    _sheet.Cells[row1, col1].AddDependency(thisCell);           // TODO - only needs to be done on first evaluate
                    double x = this.Value(row1, col1);                          // here's the magic recursive call to evaluate upstream
                    stack.Add(new RpnNodeConst(x));
                }
                else
                {
                    stack.Add(n.Evaluate(stack));
                }
            }
            Debug.Assert(stack.Count == 1);
            Debug.Assert(stack[0].IsValueType());
            double ret = stack[0].Value();

            thisCell.Value = ret;
            return(ret);
        }
Exemplo n.º 4
0
 public virtual RpnNode Evaluate(RpnStack stack)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 5
0
 public override RpnNode Evaluate(RpnStack stack)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 6
0
 public override RpnNode Evaluate(RpnStack stack)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 7
0
 public virtual RpnNode Evaluate(RpnStack stack)
 {
     throw new NotImplementedException();
 }