コード例 #1
0
		public static CGExpr BuildExpression(FullCellAddr addr,
											 Dictionary<FullCellAddr, Variable> addressToVariable) {
			Cell cell;
			if (!addr.TryGetCell(out cell)) {
				return new CGTextConst(TextValue.EMPTY);
			}
			else if (cell is NumberCell) {
				return new CGNumberConst(((NumberCell)cell).value);
			}
			else if (cell is TextCell) {
				return new CGTextConst(((TextCell)cell).value);
			}
			else if (cell is QuoteCell) {
				return new CGTextConst(((QuoteCell)cell).value);
			}
			else if (cell is BlankCell) {
				return new CGError("#FUNERR: Blank cell in function");
			}
			else if (cell is Formula) {
				// Translate the expr relative to its containing cell at addr
				CGExpressionBuilder cgBuilder = new CGExpressionBuilder(addressToVariable, addr);
				Expr expr = ((Formula)cell).Expr;
				expr.VisitorCall(cgBuilder);
				return cgBuilder.result;
			}
			else if (cell is ArrayFormula) {
				return new CGError("#FUNERR: Array formula in function");
			}
			else {
				throw new ImpossibleException("BuildExpression: " + cell);
			}
		}
コード例 #2
0
ファイル: ProgramLines.cs プロジェクト: glycerine/SDFCalc
        /// <summary>
        /// Count number of references from cell at fromFca to cell address toFca
        /// </summary>
        private static int GetCount(FullCellAddr fromFca, FullCellAddr toFca)
        {
            int  count = 0;
            Cell fromCell;

            if (fromFca.TryGetCell(out fromCell))
            {
                fromCell.DependsOn(fromFca,
                                   delegate(FullCellAddr fca) {
                    if (toFca.Equals(fca))
                    {
                        count++;
                    }
                });
            }
            return(count);
        }
コード例 #3
0
        public static CGExpr BuildExpression(FullCellAddr addr,
                                             Dictionary <FullCellAddr, Variable> addressToVariable)
        {
            Cell cell;

            if (!addr.TryGetCell(out cell))
            {
                return(new CGTextConst(TextValue.EMPTY));
            }
            else if (cell is NumberCell)
            {
                return(new CGNumberConst(((NumberCell)cell).value));
            }
            else if (cell is TextCell)
            {
                return(new CGTextConst(((TextCell)cell).value));
            }
            else if (cell is QuoteCell)
            {
                return(new CGTextConst(((QuoteCell)cell).value));
            }
            else if (cell is BlankCell)
            {
                return(new CGError("#FUNERR: Blank cell in function"));
            }
            else if (cell is Formula)
            {
                // Translate the expr relative to its containing cell at addr
                CGExpressionBuilder cgBuilder = new CGExpressionBuilder(addressToVariable, addr);
                Expr expr = ((Formula)cell).Expr;
                expr.VisitorCall(cgBuilder);
                return(cgBuilder.result);
            }
            else if (cell is ArrayFormula)
            {
                return(new CGError("#FUNERR: Array formula in function"));
            }
            else
            {
                throw new ImpossibleException("BuildExpression: " + cell);
            }
        }
コード例 #4
0
ファイル: ProgramLines.cs プロジェクト: josiahdj/SDFCalc
		/// <summary>
		/// Count number of references from cell at fromFca to cell address toFca
		/// </summary>
		private static int GetCount(FullCellAddr fromFca, FullCellAddr toFca) {
			int count = 0;
			Cell fromCell;
			if (fromFca.TryGetCell(out fromCell)) {
				fromCell.DependsOn(fromFca,
								   delegate(FullCellAddr fca) {
									   if (toFca.Equals(fca)) {
										   count++;
									   }
								   });
			}
			return count;
		}