void DecompileQueries(AstNode node) { QueryExpression query = DecompileQuery(node as InvocationExpression); if (query != null) node.ReplaceWith(query); for (AstNode child = (query ?? node).FirstChild; child != null; child = child.NextSibling) { DecompileQueries(child); } }
void DecompileQueries(AstNode node) { Expression query = DecompileQuery(node as InvocationExpression); if (query != null) { node.ReplaceWith(query); } for (AstNode child = (query ?? node).FirstChild; child != null; child = child.NextSibling) { DecompileQueries(child); } }
private static AstNode IntroduceParenthesis(AstNode node) { for (AstNode child = node.FirstChild; child != null; child = child.NextSibling) { child = IntroduceParenthesis(child); } if (node is QueryExpression && node.Parent is QueryFromClause) { var parenthesizedExpression = new ParenthesizedExpression(); node.ReplaceWith(parenthesizedExpression); parenthesizedExpression.Expression = (Expression)node; } return(node); }
void DecompileQueries(AstNode node) { QueryExpression query = DecompileQuery(node as InvocationExpression); if (query != null) { node.ReplaceWith(query); } AstNode next; for (AstNode child = (query ?? node).FirstChild; child != null; child = next) { // store referece to next child before transformation next = child.NextSibling; DecompileQueries(child); } }
void DecompileQueries(AstNode node) { Expression query = DecompileQuery(node as InvocationExpression); if (query != null) { if (node.Parent is ExpressionStatement && CanUseDiscardAssignment()) { query = new AssignmentExpression(new IdentifierExpression("_"), query); } node.ReplaceWith(query); } AstNode next; for (AstNode child = (query ?? node).FirstChild; child != null; child = next) { // store reference to next child before transformation next = child.NextSibling; DecompileQueries(child); } }
private bool ReplaceConditionalOr(AstNode root, Expression a, AstNode b) { bool? value = null; if (a is PrimitiveExpression && (a as PrimitiveExpression).Value is bool) { value = (bool)(a as PrimitiveExpression).Value; } if (a is UnaryOperatorExpression && (a as UnaryOperatorExpression).Operator == UnaryOperatorType.Not && (a as UnaryOperatorExpression).Expression is PrimitiveExpression && ((a as UnaryOperatorExpression).Expression as PrimitiveExpression).Value is bool) { value = !(bool)((a as UnaryOperatorExpression).Expression as PrimitiveExpression).Value; } if (value != null) { if ((bool)value) root.ReplaceWith(new PrimitiveExpression(true)); else root.ReplaceWith(b); return true; } return false; }