public static Expression Evaluate(Expression node) { var candidates = Nominator.Nominate(node); var evaluator = new PartialEvaluator(candidates); return(evaluator.Visit(node)); }
public static Expression PartialEval(Expression expression) { Nominator nominator = new Nominator(); SubtreeEvaluator evaluator = new SubtreeEvaluator(nominator.Nominate(expression)); return(evaluator.Eval(expression)); }
/// <summary> /// Performs evaluation and replacement of independent sub-trees /// </summary> /// <param name="expression">The root of the expression tree.</param> /// <param name="canBeEvaluated">A function that decides whether a given expression node can be part of the local function.</param> /// <returns>A new tree with sub-trees evaluated and replaced.</returns> internal static Expression PartialEval(Expression expression, Func <Expression, bool> canBeEvaluated) { Nominator nominator = new Nominator(canBeEvaluated); HashSet <Expression> candidates = nominator.Nominate(expression); return(new SubtreeEvaluator(candidates).Eval(expression)); }
/// <summary> /// Performs evaluation & replacement of independent sub-trees /// </summary> /// <param name="expression"> The root of the expression tree. </param> /// <param name="fnCanBeEvaluated"> A function that decides whether a given expression node can be part of the local function. </param> /// <returns> A new tree with sub-trees evaluated and replaced. </returns> public static Expression PartialEval(Expression expression, Func <Expression, bool> fnCanBeEvaluated) { var nominator = new Nominator(fnCanBeEvaluated); var subtreeEvaluator = new SubtreeEvaluator(nominator.Nominate(expression)); return(subtreeEvaluator.Eval(expression)); }
/// <summary> /// Performs evaluation & replacement of independent sub-trees /// </summary> /// <param name="expression">The root of the expression tree.</param> /// <param name="fnCanBeEvaluated">A function that decides whether a given expression node can be part of the local function.</param> /// <returns>A new tree with sub-trees evaluated and replaced.</returns> private static Expression Eval(Expression expression, Func <Expression, bool> fnCanBeEvaluated) { if (fnCanBeEvaluated == null) { fnCanBeEvaluated = PartialEvaluator.CanBeEvaluatedLocally; } return(SubtreeEvaluator.Eval(Nominator.Nominate(fnCanBeEvaluated, expression), expression)); }
/// <summary> /// Performs evaluation replacement of independent sub-trees /// </summary> /// <param name="expression">The root of the expression tree.</param> /// <param name="fnCanBeEvaluated">A function that decides whether a given expression node can be part of the local function.</param> /// <returns>A new tree with sub-trees evaluated and replaced.</returns> public static Expression Eval(System.Linq.Expressions.Expression expression, Func <System.Linq.Expressions.Expression, bool> fnCanBeEvaluated) { if (fnCanBeEvaluated == null) { fnCanBeEvaluated = AtkPartialEvaluator.CanBeEvaluatedLocally; } return(SubtreeEvaluator.Eval(Nominator.Nominate(fnCanBeEvaluated, expression), expression)); }
public static Expression Eval(Expression expression, Func <Expression, bool> fnCanBeEvaluated, Func <ConstantExpression, Expression> fnPostEval) { if (fnCanBeEvaluated == null) { fnCanBeEvaluated = PartialEvaluator.CanBeEvaluatedLocally; } return(SubtreeEvaluator.Eval(Nominator.Nominate(fnCanBeEvaluated, expression), fnPostEval, expression)); }
private ColumnProjector(Func <Expression, bool> fnCanBeColumn, Expression expression, string newAlias, TextWriter logger, params string[] existingAliases) : base(logger) { this.newAlias = newAlias; this.existingAliases = existingAliases; this.map = new Dictionary <ColumnExpression, ColumnExpression>(); this.columns = new List <ColumnDeclaration>(); this.columnNames = new HashSet <string>(); this.candidates = Nominator.Nominate(fnCanBeColumn, expression, logger); }
/// <summary> /// Performs evaluation & replacement of independent sub-trees /// </summary> /// <param name="expression">The root of the expression tree.</param> /// <param name="fnCanBeEvaluated">A function that decides whether a given expression node can be part of the local function.</param> /// <returns>A new tree with sub-trees evaluated and replaced.</returns> public static Expression PartialEval(Expression expression, Func <Expression, bool> fnCanBeEvaluated) { var nominator = new Nominator(fnCanBeEvaluated); var candidates = nominator.Nominate(expression); var subtreeEvaluator = new SubtreeEvaluator(candidates); var newExpression = subtreeEvaluator.Eval(expression); return(newExpression); }
private ColumnProjector(Func <Expression, bool> fnCanBeColumn, Expression expression, IEnumerable <ColumnDeclaration> existingColumns, TableAlias newAlias, IEnumerable <TableAlias> existingAliases) { this.newAlias = newAlias; this.existingAliases = new HashSet <TableAlias>(existingAliases); this.map = new Dictionary <ColumnExpression, ColumnExpression>(); if (existingColumns != null) { this.columns = new List <ColumnDeclaration>(existingColumns); this.columnNames = new HashSet <string>(existingColumns.Select(c => c.Name)); } else { this.columns = new List <ColumnDeclaration>(); this.columnNames = new HashSet <string>(); } this.candidates = Nominator.Nominate(fnCanBeColumn, expression); }
private ColumnProjector(Expression expression, IEnumerable <ColumnDeclaration> existingColumns, TableAlias newAlias, IEnumerable <TableAlias> existingAliases) { this.newAlias = newAlias; this.existingAliases = new HashSet <TableAlias>(existingAliases, TableAlias.Comparer); this.map = new Dictionary <ColumnExpression, ColumnExpression>(); if (existingColumns != null) { this.columns = new List <ColumnDeclaration>(existingColumns); this.columnNames = new HashSet <string>(existingColumns.Select(c => c.Name), StringComparer.Ordinal); } else { this.columns = new List <ColumnDeclaration>(); this.columnNames = new HashSet <string>(StringComparer.Ordinal); } this.candidates = Nominator.Nominate(expression); }
private ColumnProjector(QueryLanguage language, ProjectionAffinity affinity, Expression expression, IEnumerable <ColumnDeclaration> existingColumns, TableAlias newAlias, IEnumerable <TableAlias> existingAliases) { this.language = language; this.newAlias = newAlias; this.existingAliases = new HashSet <TableAlias>(existingAliases); this.map = new Dictionary <ColumnExpression, ColumnExpression>(); if (existingColumns != null) { this.columns = new List <ColumnDeclaration>(existingColumns); this.columnNames = new HashSet <string>(existingColumns.Select(c => c.Name)); } else { this.columns = new List <ColumnDeclaration>(); this.columnNames = new HashSet <string>(); } this.candidates = Nominator.Nominate(language, affinity, expression); }
/// <summary> /// Performs evaluation & replacement of independent sub-trees /// </summary> /// <param name="expression">The root of the expression tree.</param> /// <param name="fnCanBeEvaluated">A function that decides whether a given expression node can be part of the local function.</param> /// <returns>A new tree with sub-trees evaluated and replaced.</returns> public static Expression PartialEval(Expression expression, IExpressionEvaluator evaluator, Func <Expression, bool> fnCanBeEvaluated) => new SubtreeEvaluator(evaluator, Nominator.Nominate(expression, fnCanBeEvaluated)).Eval(expression);
/// <summary> /// Performs evaluation and replacement of independent sub-trees /// </summary> /// <param name="expression">The root of the expression tree.</param> /// <param name="fnCanBeEvaluated">A function that decides whether a given expression node can be part of the local function.</param> /// <returns>A new tree with sub-trees evaluated and replaced.</returns> public static Expression Eval(Expression expression, Func <Expression, bool> fnCanBeEvaluated) { return(SubtreeEvaluator.Eval(Nominator.Nominate(fnCanBeEvaluated, expression), expression)); }
internal static Expression PartialEval(Expression expression, Func<Expression, bool> canBeEvaluated) { Nominator nominator = new Nominator(canBeEvaluated); return new SubtreeEvaluator(nominator.Nominate(expression)).Eval(expression); }
internal ColumnProjector(Expression expression, string newAlias, IEnumerable <string> existingAliases) { _candidates = Nominator.Nominate(existingAliases, expression); _newAlias = newAlias; }
/// <summary> /// Performs evaluation & replacement of independent sub-trees /// </summary> /// <param name="expression">The root of the expression tree.</param> /// <param name="fnCanBeEvaluated">A function that decides whether a given expression node can be part of the local function.</param> /// <returns>A new tree with sub-trees evaluated and replaced.</returns> public static Expression PartialEval(Expression expression, Func <Expression, bool> fnCanBeEvaluated, TextWriter logger) { return(SubtreeEvaluator.Eval(Nominator.Nominate(fnCanBeEvaluated, expression, logger), expression, logger)); }
/// <summary> /// Performs evaluation & replacement of independent sub-trees /// </summary> /// <param name="expression"> The root of the expression tree. </param> /// <param name="fnCanBeEvaluated"> A function that decides whether a given expression node can be part of the local function. </param> /// <returns> A new tree with sub-trees evaluated and replaced. </returns> public static Expression PartialEval(Expression expression, Func<Expression, bool> fnCanBeEvaluated) { var nominator = new Nominator(fnCanBeEvaluated); var subtreeEvaluator = new SubtreeEvaluator(nominator.Nominate(expression)); return subtreeEvaluator.Eval(expression); }
/// <summary> /// Performs evaluation & replacement of independent sub-trees /// </summary> /// <param name="expression">The root of the expression tree.</param> /// <param name="fnCanBeEvaluated"> /// A function that decides whether a given expression node can be part of the local /// function. /// </param> /// <returns>A new tree with sub-trees evaluated and replaced.</returns> static public Expression PartialEval(Expression expression, Func <Expression, bool> fnCanBeEvaluated) { return(SubtreeEvaluator.Eval(expression, Nominator.Nominate(fnCanBeEvaluated, expression))); }
public static Expression PartialEval(Expression expression) { Nominator nominator = new Nominator(); SubtreeEvaluator evaluator = new SubtreeEvaluator(nominator.Nominate(expression)); return evaluator.Eval(expression); }