public static ExprNode MathGetExpr(IParseTree ctx, IDictionary <ITree, ExprNode> astExprNodeMap, ConfigurationInformation configurationInformation) { var count = 1; var @base = ASTExprHelper.ExprCollectSubNodes(ctx.GetChild(0), 0, astExprNodeMap)[0]; while (true) { int token = ASTUtil.GetAssertTerminatedTokenType(ctx.GetChild(count)); var mathArithTypeEnum = TokenToMathEnum(token); var right = ASTExprHelper.ExprCollectSubNodes(ctx.GetChild(count + 1), 0, astExprNodeMap)[0]; var math = new ExprMathNode(mathArithTypeEnum, configurationInformation.EngineDefaults.ExpressionConfig.IsIntegerDivision, configurationInformation.EngineDefaults.ExpressionConfig.IsDivisionByZeroReturnsNull); math.AddChildNode(@base); math.AddChildNode(right); @base = math; count += 2; if (count >= ctx.ChildCount) { break; } } return(@base); }
public static IList <SelectClauseExprRawSpec> MakeAggregateSelectListNoProps() { var container = SupportContainer.Instance; /* * top (*) * c1 (sum) c2 (10) * c1_1 (5) */ ExprNode top = new ExprMathNode(MathArithTypeEnum.MULTIPLY, false, false); ExprNode c1 = new ExprSumNode(false); ExprNode c1_1 = new SupportExprNode(5); ExprNode c2 = new SupportExprNode(10); top.AddChildNode(c1); top.AddChildNode(c2); c1.AddChildNode(c1_1); ExprNodeUtility.GetValidatedSubtree(ExprNodeOrigin.SELECT, top, SupportExprValidationContextFactory.MakeEmpty(container)); IList <SelectClauseExprRawSpec> selectionList = new List <SelectClauseExprRawSpec>(); selectionList.Add(new SelectClauseExprRawSpec(top, null, false)); return(selectionList); }
public static ExprNode MakeMathNode(MathArithTypeEnum operator_, object valueLeft_, object valueRight_) { var mathNode = new ExprMathNode(operator_, false, false); mathNode.AddChildNode(new SupportExprNode(valueLeft_)); mathNode.AddChildNode(new SupportExprNode(valueRight_)); Validate3Stream(mathNode); return(mathNode); }
private ExprMathNode MakeNode(Object valueLeft, Type typeLeft, Object valueRight, Type typeRight) { ExprMathNode mathNode = new ExprMathNode(MathArithTypeEnum.MULTIPLY, false, false); mathNode.AddChildNode(new SupportExprNode(valueLeft, typeLeft)); mathNode.AddChildNode(new SupportExprNode(valueRight, typeRight)); SupportExprNodeUtil.Validate(mathNode); return(mathNode); }
public static ExprNode MakeMathNode() { ExprIdentNode node1 = new ExprIdentNodeImpl("IntBoxed", "s0"); ExprIdentNode node2 = new ExprIdentNodeImpl("IntPrimitive", "s0"); var mathNode = new ExprMathNode(MathArithTypeEnum.MULTIPLY, false, false); mathNode.AddChildNode(node1); mathNode.AddChildNode(node2); Validate3Stream(mathNode); return(mathNode); }
public void TestToExpressionString() { // Build sum(4-2) ExprMathNode arithNodeChild = new ExprMathNode(MathArithTypeEnum.SUBTRACT, false, false); arithNodeChild.AddChildNode(new SupportExprNode(4)); arithNodeChild.AddChildNode(new SupportExprNode(2)); _maxNode.AddChildNode(arithNodeChild); Assert.AreEqual("max(4-2)", _maxNode.ToExpressionStringMinPrecedenceSafe()); _minNode.AddChildNode(arithNodeChild); Assert.AreEqual("min(4-2)", _minNode.ToExpressionStringMinPrecedenceSafe()); }
public void TestToExpressionString() { // Build (5*(4-2)), not the same as 5*4-2 ExprMathNode arithNodeChild = new ExprMathNode(MathArithTypeEnum.SUBTRACT, false, false); arithNodeChild.AddChildNode(new SupportExprNode(4)); arithNodeChild.AddChildNode(new SupportExprNode(2)); _arithNode = new ExprMathNode(MathArithTypeEnum.MULTIPLY, false, false); _arithNode.AddChildNode(new SupportExprNode(5)); _arithNode.AddChildNode(arithNodeChild); Assert.AreEqual("5*(4-2)", _arithNode.ToExpressionStringMinPrecedenceSafe()); }
public void TestEvaluate() { _arithNode.AddChildNode(new SupportExprNode(10)); _arithNode.AddChildNode(new SupportExprNode(1.5)); ExprNodeUtility.GetValidatedSubtree(ExprNodeOrigin.SELECT, _arithNode, SupportExprValidationContextFactory.MakeEmpty()); Assert.AreEqual(11.5d, _arithNode.Evaluate(new EvaluateParams(null, false, null))); _arithNode = MakeNode(null, typeof(int), 5d, typeof(double?)); Assert.IsNull(_arithNode.Evaluate(new EvaluateParams(null, false, null))); _arithNode = MakeNode(5, typeof(int), null, typeof(double?)); Assert.IsNull(_arithNode.Evaluate(new EvaluateParams(null, false, null))); _arithNode = MakeNode(null, typeof(int), null, typeof(double?)); Assert.IsNull(_arithNode.Evaluate(new EvaluateParams(null, false, null))); }
public static ExprNode MakeSumAndFactorNode() { // sum node var sum = new ExprSumNode(false); ExprIdentNode ident = new ExprIdentNodeImpl("IntPrimitive", "s0"); sum.AddChildNode(ident); ExprIdentNode node = new ExprIdentNodeImpl("IntBoxed", "s0"); var mathNode = new ExprMathNode(MathArithTypeEnum.MULTIPLY, false, false); mathNode.AddChildNode(node); mathNode.AddChildNode(sum); Validate3Stream(mathNode); return(mathNode); }
public void QExprMath(ExprMathNode exprMathNode, string op) { }
public void SetUp() { _arithNode = new ExprMathNode(MathArithTypeEnum.ADD, false, false); }