コード例 #1
0
ファイル: Expression.cs プロジェクト: myersBR/My-FyiReporting
 internal Expression(ReportDefn r, ReportLink p, String xNode, ExpressionType et) : base(r, p)
 {
     _Source = xNode;
     _Type = TypeCode.Empty;
     _ExpectedType = et;
     _Expr = null;
 }
コード例 #2
0
		public DynamicExpression(Report rpt, ReportLink p, string expr, Row row)
		{
			_Source=expr;
			_Expr = null;
            _rl = p;
            _Type = DoParse(rpt);
		}
コード例 #3
0
ファイル: DataStructures.cs プロジェクト: Zaid-Ajaj/Demos
 public Function(string name, IExpr fst, IExpr snd)
 {
     this.IsBinary = true;
     this.Name = name;
     this.FirstArgument = fst;
     this.SecondArgument = snd;
 }
コード例 #4
0
		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);
		}
コード例 #5
0
		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;
		}
コード例 #6
0
        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;
        }
コード例 #7
0
        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;
        }
コード例 #8
0
ファイル: FunctionSystem.cs プロジェクト: mnisl/OD
		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;
		}
コード例 #9
0
        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);
        }
コード例 #10
0
 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;
 }
コード例 #11
0
		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);
		}
コード例 #12
0
ファイル: ExprGetMethod.cs プロジェクト: takuto-h/rhea
 public ExprGetMethod(
     IExpr klassExpr,
     ValueSymbol selector,
     SourceInfo info
 )
 {
     KlassExpr = klassExpr;
     Selector = selector;
     mInfo = info;
 }
コード例 #13
0
        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);
        }
コード例 #14
0
        public IExpr ConstantOptimization()
        {
            _rhs = _rhs.ConstantOptimization();
            if (_rhs.IsConstant())
            {
                bool b = EvaluateBoolean(null, null);
                return new ConstantBoolean(b);
            }

            return this;
        }
コード例 #15
0
        public IExpr ConstantOptimization()
        {
            _rhs = _rhs.ConstantOptimization();
            if (_rhs.IsConstant())
            {
                decimal d = EvaluateDecimal(null, null);
                return new ConstantDecimal(d);
            }

            return this;
        }
コード例 #16
0
        public IExpr ConstantOptimization()
        {
            _rhs = _rhs.ConstantOptimization();
            if (_rhs.IsConstant())
            {
                double d = EvaluateDouble(null, null);
                return new ConstantInteger((int) d);
            }

            return this;
        }
コード例 #17
0
ファイル: ExprSetMethod.cs プロジェクト: takuto-h/rhea
 public ExprSetMethod(
     IExpr klassExpr,
     ValueSymbol selector,
     IExpr valueExpr,
     SourceInfo info
 )
 {
     mKlassExpr = klassExpr;
     mSelector = selector;
     mValueExpr = valueExpr;
     mInfo = info;
 }
コード例 #18
0
ファイル: ExprSend.cs プロジェクト: takuto-h/rhea
 public ExprSend(
     IExpr recvExpr,
     ValueSymbol selector,
     IList<IExpr> argExprs,
     SourceInfo info
 )
 {
     RecvExpr = recvExpr;
     Selector = selector;
     ArgExprs = argExprs;
     mInfo = info;
 }
コード例 #19
0
ファイル: FunctionFormat.cs プロジェクト: mnisl/OD
		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;
		}
コード例 #20
0
        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());
            }
        }
コード例 #21
0
		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;
		}
コード例 #22
0
        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());
            }
        }
コード例 #23
0
        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());
            }
        }
コード例 #24
0
 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;
   }
 }
コード例 #25
0
		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;
		}
コード例 #26
0
		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;
		}
コード例 #27
0
		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;
		}
コード例 #28
0
        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;
        }
コード例 #29
0
		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;
		}
コード例 #30
0
		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;
		}
コード例 #31
0

        
コード例 #32
0
 /// <summary>
 /// obtain value of Field
 /// </summary>
 public FunctionReportItemCollection(IDictionary reportitems, IExpr arg)
 {
     _ReportItems = reportitems;
     _ArgExpr     = arg;
 }
コード例 #33
0

        
コード例 #34
0
 public ExprTree(IExpr exp)
 {
     Content = exp;
 }
コード例 #35
0
        /// <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);
        }
コード例 #36
0
 public BinaryExpr(IExpr left, IExpr right, Func <int, int, int> op)
 {
     this.left  = left;
     this.right = right;
     this.op    = op;
 }
コード例 #37
0
ファイル: ExprToken.cs プロジェクト: iExpr/iExpr.Core
 public abstract bool Equals(IExpr other);
コード例 #38
0
 public FunctionUnaryMinusInteger(IExpr r)
 {
     _rhs = r;
 }
コード例 #39
0
 internal ReturnCommand(IExpr value)
 {
     this.value = value;
 }
コード例 #40
0
 internal IfCommand(IExpr cond, int trueLabel, int falseLabel)
 {
     this.cond       = cond;
     this.trueLabel  = trueLabel;
     this.falseLabel = falseLabel;
 }
コード例 #41
0
 internal AssignCommand(string var, IExpr exp)
 {
     this.var = var;
     this.exp = exp;
 }
コード例 #42
0
 public static IExpr AddExp(IExpr left, IExpr right)
 {
     return(new BinaryExpr(left, right, (x, y) => x + y));
 }
コード例 #43
0
 public static ICommand ReturnCmd(IExpr v)
 {
     return(new ReturnCommand(v));
 }
コード例 #44
0
 /// <summary>
 /// obtain value of Field
 /// </summary>
 public FunctionParameterCollection(IDictionary parameters, IExpr arg)
 {
     _Parameters = parameters;
     _ArgExpr    = arg;
 }
コード例 #45
0
 public VariableDeclaration(Variable variable, IExpr initializer)
 {
     Variable    = variable;
     Initializer = initializer;
 }
コード例 #46
0
 public static ICommand AssignCmd(string var, IExpr exp)
 {
     return(new AssignCommand(var, exp));
 }
コード例 #47
0
        IExpr _rhs;                             // rhs

        /// <summary>
        /// Do minus on decimal data type
        /// </summary>
        public FunctionUnaryMinusInteger()
        {
            _rhs = null;
        }
コード例 #48
0
ファイル: Return.cs プロジェクト: sceccotti89/FunWap
 public Return(IExpr e)
 {
     this.e = e;
 }
コード例 #49
0
 public Return(IExpr expr) => Expr = expr;
コード例 #50
0

        
コード例 #51
0
 public IfStatement(IExpr condition, IExpr body, SourcePosition position) : base(position, "if", LexTokenType.None)
 {
     this.Condition = condition;
     this.Body      = body;
     this.m_follow  = null;
 }
コード例 #52
0

        
コード例 #53
0
 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);
 }
コード例 #54
0
 /// <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));
 }
コード例 #55
0
 public FunctionCall(string name, IExpr argument)
 {
     FunctionName = name;
     Argument     = argument;
 }
コード例 #56
0
        public IExpr _rhs;                              // rhs

        /// <summary>
        /// Arbitrary binary operater; might be a
        /// </summary>
        public FunctionBinary()
        {
            _lhs = null;
            _rhs = null;
        }
コード例 #57
0
 public BinaryOperation(IExpr left, BinaryOperator op, IExpr right)
 {
     LeftOperand  = left;
     Operator     = op;
     RightOperand = right;
 }
コード例 #58
0
 public Assignment(Variable variable, IExpr assignedExpression)
 {
     Variable           = variable;
     AssignedExpression = assignedExpression;
 }
コード例 #59
0
 public static ICommand IfCmd(IExpr exp, int ltrue, int lfalse)
 {
     return(new IfCommand(exp, ltrue, lfalse));
 }
コード例 #60
0
 public FunctionBinary(IExpr l, IExpr r)
 {
     _lhs = l;
     _rhs = r;
 }