public static ExprInNode MakeInSetNode(bool isNotIn) { // Build : s0.intPrimitive in (1, 2) ExprInNode inNode = new ExprInNodeImpl(isNotIn); inNode.AddChildNode(MakeIdentNode("IntPrimitive", "s0")); inNode.AddChildNode(new SupportExprNode(1)); inNode.AddChildNode(new SupportExprNode(2)); Validate3Stream(inNode); return(inNode); }
public static ExprNode RewriteOrToInIfApplicable(ExprNode constituent) { if (!(constituent is ExprOrNode) || constituent.ChildNodes.Length < 2) { return constituent; } // check eligibility var childNodes = constituent.ChildNodes; foreach (var child in childNodes) { if (!(child is ExprEqualsNode)) { return constituent; } var equalsNode = (ExprEqualsNode) child; if (equalsNode.IsIs || equalsNode.IsNotEquals) { return constituent; } } // find common-expression node ExprNode commonExpressionNode; var lhs = childNodes[0].ChildNodes[0]; var rhs = childNodes[0].ChildNodes[1]; if (ExprNodeUtility.DeepEquals(lhs, rhs)) { return constituent; } if (IsExprExistsInAllEqualsChildNodes(childNodes, lhs)) { commonExpressionNode = lhs; } else if (IsExprExistsInAllEqualsChildNodes(childNodes, rhs)) { commonExpressionNode = rhs; } else { return constituent; } // build node var @in = new ExprInNodeImpl(false); @in.AddChildNode(commonExpressionNode); for (var i = 0; i < constituent.ChildNodes.Length; i++) { var child = constituent.ChildNodes[i]; var nodeindex = ExprNodeUtility.DeepEquals(commonExpressionNode, childNodes[i].ChildNodes[0]) ? 1 : 0; @in.AddChildNode(child.ChildNodes[nodeindex]); } // validate try { @in.ValidateWithoutContext(); } catch (ExprValidationException) { return constituent; } return @in; }
public void QExprIn(ExprInNodeImpl exprInNode) { }
public static ExprNode RewriteOrToInIfApplicable( ExprNode constituent, bool rewriteRegardlessOfLookupable) { if (!(constituent is ExprOrNode) || constituent.ChildNodes.Length < 2) { return constituent; } // check eligibility var childNodes = constituent.ChildNodes; foreach (var child in childNodes) { if (!(child is ExprEqualsNode)) { return constituent; } var equalsNode = (ExprEqualsNode) child; if (equalsNode.IsIs || equalsNode.IsNotEquals) { return constituent; } } // find common-expression node ExprNode commonExpressionNode; var lhs = childNodes[0].ChildNodes[0]; var rhs = childNodes[0].ChildNodes[1]; if (ExprNodeUtilityCompare.DeepEquals(lhs, rhs, false)) { return constituent; } if (IsExprExistsInAllEqualsChildNodes(childNodes, lhs)) { commonExpressionNode = lhs; } else if (IsExprExistsInAllEqualsChildNodes(childNodes, rhs)) { commonExpressionNode = rhs; } else { return constituent; } // if the common expression doesn't reference an event property, no need to rewrite if (!rewriteRegardlessOfLookupable) { var lookupableVisitor = new FilterSpecExprNodeVisitorLookupableLimitedExpr(); commonExpressionNode.Accept(lookupableVisitor); if (!lookupableVisitor.HasStreamZeroReference || !lookupableVisitor.IsLimited) { return constituent; } } // build node var @in = new ExprInNodeImpl(false); @in.AddChildNode(commonExpressionNode); for (var i = 0; i < constituent.ChildNodes.Length; i++) { var child = constituent.ChildNodes[i]; var nodeindex = ExprNodeUtilityCompare.DeepEquals(commonExpressionNode, childNodes[i].ChildNodes[0], false) ? 1 : 0; @in.AddChildNode(child.ChildNodes[nodeindex]); } // validate try { @in.ValidateWithoutContext(); } catch (ExprValidationException) { return constituent; } return @in; }