internal Expression(ReportDefn r, ReportLink p, String xNode, ExpressionType et) : base(r, p) { _Source = xNode; _Type = TypeCode.Empty; _ExpectedType = et; _Expr = null; }
public DynamicExpression(Report rpt, ReportLink p, string expr, Row row) { _Source=expr; _Expr = null; _rl = p; _Type = DoParse(rpt); }
public Function(string name, IExpr fst, IExpr snd) { this.IsBinary = true; this.Name = name; this.FirstArgument = fst; this.SecondArgument = snd; }
string _key; // key for cache when scope is dataset we can cache the result /// <summary> /// Aggregate function: Stdevp = (sqrt(n sum(square(x)) - square((sum(x))) / n*n) /// Stdev assumes values are a sample of the population of data. If the data /// is the entire representation then use Stdevp. /// /// Return type is decimal for decimal expressions and double for all /// other expressions. /// </summary> public FunctionAggrStdevp(List<ICacheData> dataCache, IExpr e, object scp) : base(e, scp) { _key = "aggrstdevp" + Interlocked.Increment(ref Parser.Counter).ToString(); dataCache.Add(this); }
string _UniqueName; // unique name of expression; not always created internal Expression(ReportDefn r, ReportLink p, XmlNode xNode, ExpressionType et) : base(r, p) { _Source=xNode.InnerText; _Type = TypeCode.Empty; _ExpectedType = et; _Expr = null; }
public virtual IExpr ConstantOptimization() { _ArgExpr = _ArgExpr.ConstantOptimization(); if (_ArgExpr.IsConstant()) { string o = _ArgExpr.EvaluateString(null, null); if (o == null) throw new Exception("Globals collection argument is null"); switch (o.ToLower()) { case "pagenumber": return new FunctionPageNumber(); case "totalpages": return new FunctionTotalPages(); case "executiontime": return new FunctionExecutionTime(); case "reportfolder": return new FunctionReportFolder(); case "reportname": return new FunctionReportName(); default: throw new Exception(string.Format("Globals collection argument '{0}' is unknown.", o)); } } return this; }
internal void SetParameterMethod(string pm, IExpr[] args) { if (!this.p.MultiValue) throw new ArgumentException(string.Format("{0} must be a MultiValue parameter to accept methods", this.p.Name.Nm)); if (pm == null) { _type = ReportParameterMethodEnum.Index; } else switch (pm) { case "Contains": _type = ReportParameterMethodEnum.Contains; break; case "BinarySearch": _type = ReportParameterMethodEnum.BinarySearch; break; case "Count": _type = ReportParameterMethodEnum.Count; if (args != null) throw new ArgumentException("Count does not have any arguments."); break; case "IndexOf": _type = ReportParameterMethodEnum.IndexOf; break; case "LastIndexOf": _type = ReportParameterMethodEnum.LastIndexOf; break; case "Value": _type = ReportParameterMethodEnum.Value; break; default: throw new ArgumentException(string.Format("{0} is an unknown array method.", pm)); } if (_type != ReportParameterMethodEnum.Count) { if (args == null || args.Length != 1) throw new ArgumentException(string.Format("{0} must have exactly one argument.", pm)); _arg = args[0]; } return; }
TypeCode _ReturnTypeCode; // the return type /// <summary> /// passed class name, function name, and args for evaluation /// </summary> public FunctionSystem(string c, string f, IExpr[] a, TypeCode type) { _Cls = c; _Func = f; _Args = a; _ReturnTypeCode = type; }
string _key; // key used for caching value #endregion Fields #region Constructors /// <summary> /// Aggregate function: CountDistinct /// /// Return type is double /// </summary> public FunctionAggrCountDistinct(List<ICacheData> dataCache, IExpr e, object scp) : base(e, scp) { _key = "countdistinct" + Interlocked.Increment(ref Parser.Counter).ToString(); dataCache.Add(this); }
public Elt(What what, IExpr ty) { Contract.Requires(what != What.Bottom || ty == null); Contract.Requires(what != What.Exact || ty != null); this.what = what; this.ty = ty; this.manyBounds = null; }
string _key; // key for caching /// <summary> /// Aggregate function: Max returns the highest value /// Return type is same as input expression /// </summary> public FunctionAggrMax(List<ICacheData> dataCache, IExpr e, object scp) : base(e, scp) { _key = "aggrmax" + Interlocked.Increment(ref Parser.Counter).ToString(); // Determine the result _tc = e.GetTypeCode(); dataCache.Add(this); }
public ExprGetMethod( IExpr klassExpr, ValueSymbol selector, SourceInfo info ) { KlassExpr = klassExpr; Selector = selector; mInfo = info; }
private TypeCode _tc; // type of result: decimal or double #endregion Fields #region Constructors /// <summary> /// Aggregate function: RunningValue Sum returns the sum of all values of the /// expression within the scope up to that row /// Return type is decimal for decimal expressions and double for all /// other expressions. /// </summary> public FunctionAggrRvSum(List<ICacheData> dataCache, IExpr e, object scp) : base(e, scp) { _key = "aggrrvsum" + Interlocked.Increment(ref Parser.Counter).ToString(); // Determine the result _tc = e.GetTypeCode(); if (_tc != TypeCode.Decimal) // if not decimal _tc = TypeCode.Double; // force result to double dataCache.Add(this); }
public IExpr ConstantOptimization() { _rhs = _rhs.ConstantOptimization(); if (_rhs.IsConstant()) { bool b = EvaluateBoolean(null, null); return new ConstantBoolean(b); } return this; }
public IExpr ConstantOptimization() { _rhs = _rhs.ConstantOptimization(); if (_rhs.IsConstant()) { decimal d = EvaluateDecimal(null, null); return new ConstantDecimal(d); } return this; }
public IExpr ConstantOptimization() { _rhs = _rhs.ConstantOptimization(); if (_rhs.IsConstant()) { double d = EvaluateDouble(null, null); return new ConstantInteger((int) d); } return this; }
public ExprSetMethod( IExpr klassExpr, ValueSymbol selector, IExpr valueExpr, SourceInfo info ) { mKlassExpr = klassExpr; mSelector = selector; mValueExpr = valueExpr; mInfo = info; }
public ExprSend( IExpr recvExpr, ValueSymbol selector, IList<IExpr> argExprs, SourceInfo info ) { RecvExpr = recvExpr; Selector = selector; ArgExprs = argExprs; mInfo = info; }
public IExpr ConstantOptimization() { _Formatee = _Formatee.ConstantOptimization(); _Format = _Format.ConstantOptimization(); if (_Formatee.IsConstant() && _Format.IsConstant()) { string s = EvaluateString(null, null); return new ConstantString(s); } return this; }
TypeCode _ReturnTypeCode; // the return type #endregion Fields #region Constructors /// <summary> /// passed ReportClass, function name, and args for evaluation /// </summary> public FunctionCode(string f, IExpr[] a, TypeCode type) { _Func = f; _Args = a; _ReturnTypeCode = type; _ArgTypes = new Type[a.Length]; int i=0; foreach (IExpr ex in a) { _ArgTypes[i++] = XmlUtil.GetTypeFromTypeCode(ex.GetTypeCode()); } }
public IExpr ConstantOptimization() { _If = _If.ConstantOptimization(); _IfTrue = _IfTrue.ConstantOptimization(); _IfFalse = _IfFalse.ConstantOptimization(); if (_If.IsConstant()) { bool result = _If.EvaluateBoolean(null, null); return result? _IfTrue: _IfFalse; } return this; }
TypeCode _ReturnTypeCode; // the return type #endregion Fields #region Constructors /// <summary> /// passed ReportClass, function name, and args for evaluation /// </summary> public FunctionCustomInstance(ReportClass rc, string f, IExpr[] a, TypeCode type) { _Cls = null; _Func = f; _Args = a; _Rc = rc; _ReturnTypeCode = type; _ArgTypes = new Type[a.Length]; int i=0; foreach (IExpr ex in a) { _ArgTypes[i++] = XmlUtil.GetTypeFromTypeCode(ex.GetTypeCode()); } }
TypeCode _ReturnTypeCode; // the return type #endregion Fields #region Constructors /// <summary> /// passed class name, function name, and args for evaluation /// </summary> public FunctionCustomStatic(CodeModules cm, string c, string f, IExpr[] a, TypeCode type) { _Cls = c; _Func = f; _Args = a; _Cm = cm; _ReturnTypeCode = type; _ArgTypes = new Type[a.Length]; int i=0; foreach (IExpr ex in a) { _ArgTypes[i++] = XmlUtil.GetTypeFromTypeCode(ex.GetTypeCode()); } }
public Elt(IExpr[]/*!*/ bounds) { Contract.Requires(bounds != null); Contract.Requires(Contract.ForAll(0, bounds.Length, i => bounds[i] != null)); this.what = What.Bounds; if (bounds.Length == 0) { this.ty = null; this.manyBounds = null; } else if (bounds.Length == 1) { this.ty = bounds[0]; this.manyBounds = null; } else { this.ty = null; this.manyBounds = bounds; } }
public virtual IExpr ConstantOptimization() { _ArgExpr = _ArgExpr.ConstantOptimization(); if (_ArgExpr.IsConstant()) { string o = _ArgExpr.EvaluateString(null, null); if (o == null) throw new Exception("Parameter collection argument is null"); ReportParameter rp = _Parameters[o] as ReportParameter; if (rp == null) throw new Exception(string.Format("Parameter collection argument {0} is invalid", o)); return new FunctionReportParameter(rp); } return this; }
public virtual IExpr ConstantOptimization() { _ArgExpr = _ArgExpr.ConstantOptimization(); if (_ArgExpr.IsConstant()) { string o = _ArgExpr.EvaluateString(null, null); if (o == null) throw new Exception(Strings.FunctionParameterCollection_Error_ParameterCollectionNull); ReportParameter rp = _Parameters[o] as ReportParameter; if (rp == null) throw new Exception(string.Format(Strings.FunctionParameterCollection_Error_ParameterCollectionInvalid, o)); return new FunctionReportParameter(rp); } return this; }
public virtual IExpr ConstantOptimization() { _ArgExpr = _ArgExpr.ConstantOptimization(); if (_ArgExpr.IsConstant()) { string o = _ArgExpr.EvaluateString(null, null); if (o == null) throw new Exception(Strings.FunctionReportItemCollection_Error_ReportItemCollectionNull); Textbox ri = _ReportItems[o] as Textbox; if (ri == null) throw new Exception(string.Format(Strings.FunctionReportItemCollection_Error_ReportItemCollectionInvalid, o)); return new FunctionTextbox(ri, null); // no access to unique name } return this; }
public virtual IExpr ConstantOptimization() { _ArgExpr = _ArgExpr.ConstantOptimization(); if (_ArgExpr.IsConstant()) { string o = _ArgExpr.EvaluateString(null, null); if (o == null) throw new Exception("ReportItem collection argument is null"); Textbox ri = _ReportItems[o] as Textbox; if (ri == null) throw new Exception(string.Format("ReportItem collection argument {0} is invalid", o)); return new FunctionTextbox(ri, null); // no access to unique name } return this; }
public virtual IExpr ConstantOptimization() { _ArgExpr = _ArgExpr.ConstantOptimization(); if (_ArgExpr.IsConstant()) { string o = _ArgExpr.EvaluateString(null, null); if (o == null) throw new Exception(Strings.FunctionFieldCollection_Error_FieldCollectionNull); Field f = _Fields[o] as Field; if (f == null) throw new Exception(string.Format(Strings.FunctionFieldCollection_Error_FieldCollectionInvalid, o)); return new FunctionField(f); } return this; }
public virtual IExpr ConstantOptimization() { _ArgExpr = _ArgExpr.ConstantOptimization(); if (_ArgExpr.IsConstant()) { string o = _ArgExpr.EvaluateString(null, null); if (o == null) throw new Exception("Field collection argument is null"); Field f = _Fields[o] as Field; if (f == null) throw new Exception(string.Format("Field collection argument {0} is invalid", o)); return new FunctionField(f); } return this; }
/// <summary> /// obtain value of Field /// </summary> public FunctionReportItemCollection(IDictionary reportitems, IExpr arg) { _ReportItems = reportitems; _ArgExpr = arg; }
public ExprTree(IExpr exp) { Content = exp; }
/// <summary> /// Evaluate the expression (that is assured to be an arithmetic expression, in the state passed as a parameter /// </summary> private IntervalElement /*!*/ Eval(IExpr /*!*/ exp, IFunctionalMap /* Var -> Element */ state) { Contract.Requires((exp != null)); Contract.Ensures(Contract.Result <IntervalElement>() != null); IntervalElement /*!*/ retVal = (IntervalElement /*!*/)cce.NonNull(Top); // Eval the expression by structural induction if (exp is IVariable && state != null) // A variable { object lookup = state[exp]; if (lookup is IntervalElement) { retVal = (IntervalElement)lookup; } else { retVal = (IntervalElement)Top; } } else if (exp is IFunApp) { IFunApp fun = (IFunApp)exp; if (fun.FunctionSymbol is IntSymbol) // An integer { IntSymbol intSymb = (IntSymbol)fun.FunctionSymbol; BigNum val = intSymb.Value; retVal = IntervalElement.Factory(val); } else if (fun.FunctionSymbol.Equals(Int.Negate)) // An unary minus { IExpr /*!*/ arg = (IExpr /*!*/)cce.NonNull(fun.Arguments[0]); IntervalElement /*!*/ argEval = Eval(arg, state); Contract.Assert(argEval != null); IntervalElement /*!*/ zero = IntervalElement.Factory(BigNum.ZERO); Contract.Assert(zero != null); retVal = zero - argEval; } else if (fun.Arguments.Count == 2) { IExpr /*!*/ left = (IExpr /*!*/)cce.NonNull(fun.Arguments[0]); IExpr /*!*/ right = (IExpr /*!*/)cce.NonNull(fun.Arguments[1]); IntervalElement /*!*/ leftVal = Eval(left, state); Contract.Assert(leftVal != null); IntervalElement /*!*/ rightVal = Eval(right, state); Contract.Assert(rightVal != null); if (fun.FunctionSymbol.Equals(Int.Add)) { retVal = leftVal + rightVal; } else if (fun.FunctionSymbol.Equals(Int.Sub)) { retVal = leftVal - rightVal; } else if (fun.FunctionSymbol.Equals(Int.Mul)) { retVal = leftVal * rightVal; } else if (fun.FunctionSymbol.Equals(Int.Div)) { retVal = leftVal / rightVal; } else if (fun.FunctionSymbol.Equals(Int.Mod)) { retVal = leftVal % rightVal; } } } return(retVal); }
public BinaryExpr(IExpr left, IExpr right, Func <int, int, int> op) { this.left = left; this.right = right; this.op = op; }
public abstract bool Equals(IExpr other);
public FunctionUnaryMinusInteger(IExpr r) { _rhs = r; }
internal ReturnCommand(IExpr value) { this.value = value; }
internal IfCommand(IExpr cond, int trueLabel, int falseLabel) { this.cond = cond; this.trueLabel = trueLabel; this.falseLabel = falseLabel; }
internal AssignCommand(string var, IExpr exp) { this.var = var; this.exp = exp; }
public static IExpr AddExp(IExpr left, IExpr right) { return(new BinaryExpr(left, right, (x, y) => x + y)); }
public static ICommand ReturnCmd(IExpr v) { return(new ReturnCommand(v)); }
/// <summary> /// obtain value of Field /// </summary> public FunctionParameterCollection(IDictionary parameters, IExpr arg) { _Parameters = parameters; _ArgExpr = arg; }
public VariableDeclaration(Variable variable, IExpr initializer) { Variable = variable; Initializer = initializer; }
public static ICommand AssignCmd(string var, IExpr exp) { return(new AssignCommand(var, exp)); }
IExpr _rhs; // rhs /// <summary> /// Do minus on decimal data type /// </summary> public FunctionUnaryMinusInteger() { _rhs = null; }
public Return(IExpr e) { this.e = e; }
public Return(IExpr expr) => Expr = expr;
public IfStatement(IExpr condition, IExpr body, SourcePosition position) : base(position, "if", LexTokenType.None) { this.Condition = condition; this.Body = body; this.m_follow = null; }
string _key; // key for caching when scope is dataset we can cache the result /// <summary> /// Aggregate function: Stdev = (sqrt(n sum(square(x)) - square((sum(x))) / n(n-1) /// Stdev assumes values are a sample of the population of data. If the data /// is the entire representation then use Stdevp. /// /// Return type is decimal for decimal expressions and double for all /// other expressions. /// </summary> public FunctionAggrStdev(List <ICacheData> dataCache, IExpr e, object scp) : base(e, scp) { _key = "aggrstdev" + Interlocked.Increment(ref Parser.Counter).ToString(); dataCache.Add(this); }
/// <summary> /// Evaluate the predicate passed as input according the semantics of intervals /// </summary> public override Element /*!*/ EvaluatePredicate(IExpr /*!*/ pred) { //Contract.Requires(pred != null); Contract.Ensures(Contract.Result <Element>() != null); return(this.EvaluatePredicateWithState(pred, null)); }
public FunctionCall(string name, IExpr argument) { FunctionName = name; Argument = argument; }
public IExpr _rhs; // rhs /// <summary> /// Arbitrary binary operater; might be a /// </summary> public FunctionBinary() { _lhs = null; _rhs = null; }
public BinaryOperation(IExpr left, BinaryOperator op, IExpr right) { LeftOperand = left; Operator = op; RightOperand = right; }
public Assignment(Variable variable, IExpr assignedExpression) { Variable = variable; AssignedExpression = assignedExpression; }
public static ICommand IfCmd(IExpr exp, int ltrue, int lfalse) { return(new IfCommand(exp, ltrue, lfalse)); }
public FunctionBinary(IExpr l, IExpr r) { _lhs = l; _rhs = r; }