protected virtual CalcExpression VisitFunctionExpression(CalcFunctionExpression expr, int baseRow, int baseColumn) { int argCount = expr.ArgCount; CalcExpression[] args = new CalcExpression[argCount]; bool flag = false; for (int i = 0; i < argCount; i++) { CalcExpression arg = expr.GetArg(i); args[i] = this.Visit(arg, baseRow, baseColumn); if (arg != args[i]) { flag = true; } } if (!flag) { return(expr); } if (object.ReferenceEquals(expr.Function, null)) { return(new CalcFunctionExpression(expr.FunctionName, args)); } return(new CalcFunctionExpression(expr.Function, args)); }
/// <summary> /// Initializes a new instance of the <see cref="T:Dt.CalcEngine.Expressions.CalcUnaryOperatorExpression" /> class. /// </summary> /// <param name="oper">The unary operator.</param> /// <param name="operand">The operand.</param> /// <exception cref="T:System.ArgumentNullException"><paramref name="oper" /> or <paramref name="operand" /> is <see langword="null" />.</exception> public CalcUnaryOperatorExpression(CalcUnaryOperator oper, CalcExpression operand) { base.ThrowIfArgumentNull <CalcUnaryOperator>(oper, "oper"); base.ThrowIfArgumentNull <CalcExpression>(operand, "operand"); this._operator = oper; this._operand = operand; }
/// <summary> /// Initializes a new instance of the <see cref="T:Dt.CalcEngine.Expressions.CalcBinaryOperatorExpression" /> class. /// </summary> /// <param name="oper">The binary operator.</param> /// <param name="left">The left operand.</param> /// <param name="right">The right operand.</param> public CalcBinaryOperatorExpression(CalcBinaryOperator oper, CalcExpression left, CalcExpression right) { base.ThrowIfArgumentNull <CalcBinaryOperator>(oper, "oper"); base.ThrowIfArgumentNull <CalcExpression>(left, "left"); base.ThrowIfArgumentNull <CalcExpression>(right, "right"); this._operator = oper; this._left = left; this._right = right; }
protected virtual CalcExpression VisitUnaryOperatorExpression(CalcUnaryOperatorExpression expr, int baseRow, int baseColumn) { CalcExpression operand = expr.Operand; CalcExpression expression2 = this.Visit(operand, baseRow, baseColumn); if (operand != expression2) { return(new CalcUnaryOperatorExpression(expr.Operator, expression2)); } return(expr); }
private CalcExpression VisitParenthesesExpression(CalcParenthesesExpression expr, int baseRow, int baseColumn) { CalcExpression arg = expr.Arg; CalcExpression expression2 = this.Visit(arg, baseRow, baseColumn); if (arg != expression2) { return(new CalcParenthesesExpression(expression2)); } return(expr); }
protected virtual CalcExpression VisitBinaryOperatorExpression(CalcBinaryOperatorExpression expr, int baseRow, int baseColumn) { CalcExpression left = expr.Left; CalcExpression right = expr.Right; CalcExpression expression3 = this.Visit(left, baseRow, baseColumn); CalcExpression expression4 = this.Visit(right, baseRow, baseColumn); if ((left == expression3) && (right == expression4)) { return(expr); } return(new CalcBinaryOperatorExpression(expr.Operator, expression3, expression4)); }
/// <summary> /// Get a new expression with specific offset. /// </summary> /// <param name="row">the row offset</param> /// <param name="column">the column offset</param> /// <param name="offsetAbsolute"><c>true</c> if offset the absolute indexes.</param> /// <param name="offsetRelative"><c>true</c> if offset the relative indexes.</param> /// <returns> /// Return a <see cref="T:Dt.CalcEngine.Expressions.CalcExpression" /> which offset from current expression. /// </returns> public override CalcExpression Offset(int row, int column, bool offsetAbsolute = false, bool offsetRelative = true) { CalcExpression[] args = new CalcExpression[this.ArgCount]; for (int i = 0; i < args.Length; i++) { args[i] = this.GetArg(i).Offset(row, column, offsetAbsolute, offsetRelative); } if (this.Function != null) { return(new CalcFunctionExpression(this.Function, args)); } return(new CalcFunctionExpression(this.FunctionName, args)); }
public virtual CalcExpression Visit(CalcExpression expr, int baseRow, int baseColumn) { CalcConstantExpression expression = expr as CalcConstantExpression; if (expression != null) { return(this.VisitConstantExpression(expression)); } CalcCellExpression expression2 = expr as CalcCellExpression; if (expression2 != null) { return(this.VisitCellExpression(expression2, baseRow, baseColumn)); } CalcRangeExpression expression3 = expr as CalcRangeExpression; if (expression3 != null) { return(this.VisitRangeExpression(expression3, baseRow, baseColumn)); } CalcUnaryOperatorExpression expression4 = expr as CalcUnaryOperatorExpression; if (expression4 != null) { return(this.VisitUnaryOperatorExpression(expression4, baseRow, baseColumn)); } CalcBinaryOperatorExpression expression5 = expr as CalcBinaryOperatorExpression; if (expression5 != null) { return(this.VisitBinaryOperatorExpression(expression5, baseRow, baseColumn)); } CalcFunctionExpression expression6 = expr as CalcFunctionExpression; if (expression6 != null) { return(this.VisitFunctionExpression(expression6, baseRow, baseColumn)); } CalcExternalCellExpression expression7 = expr as CalcExternalCellExpression; if (expression7 != null) { return(this.VisitExternalCellExpression(expression7, baseRow, baseColumn)); } CalcExternalRangeExpression expression8 = expr as CalcExternalRangeExpression; if (expression8 != null) { return(this.VisitExternalRangeExpression(expression8, baseRow, baseColumn)); } if (expr is CalcSharedExpression) { CalcExpression expression9 = (expr as CalcSharedExpression).Expression; CalcExpression expression10 = this.Visit(expression9, baseRow, baseColumn); if (expression10 == expression9) { return(expr); } return(new CalcSharedExpression(expression10)); } CalcParenthesesExpression expression11 = expr as CalcParenthesesExpression; if (expression11 != null) { return(this.VisitParenthesesExpression(expression11, baseRow, baseColumn)); } CalcNameExpression expression12 = expr as CalcNameExpression; if (expression12 != null) { return(this.VisitNameExpression(expression12, baseRow, baseColumn)); } CalcExternalNameExpression expression13 = expr as CalcExternalNameExpression; if (expression13 != null) { return(this.VisitExternalNameExpression(expression13, baseRow, baseColumn)); } CalcSheetRangeExpression expression14 = expr as CalcSheetRangeExpression; if (expression14 != null) { return(this.VisitSheetRangeExpression(expression14, baseRow, baseColumn)); } return(expr); }
/// <summary> /// Initializes a new instance of the <see cref="T:Dt.CalcEngine.Expressions.CalcParenthesesExpression" /> class. /// </summary> /// <param name="arg">Expression inside the parentheses.</param> /// <exception cref="T:System.ArgumentNullException">arg is <see langword="null" />. </exception> public CalcParenthesesExpression(CalcExpression arg) { base.ThrowIfArgumentNull <CalcExpression>(arg, "arg"); this._argument = arg; }
/// <summary> /// Initializes a new instance of the <see cref="T:Dt.CalcEngine.Expressions.CalcSharedExpression" />. /// </summary> /// <param name="expr"></param> public CalcSharedExpression(CalcExpression expr) { this.Expression = expr; }