Class QueryVisitor<TQueryTree, TMonadMember, TQueryOperator>
Query expression visitor to rewrite a query expression tree into a target type.
Namespace: System.Linq.CompilerServices.Optimizers
Assembly: Nuqleon.Linq.CompilerServices.Optimizers.dll
Syntax
public abstract class QueryVisitor<TQueryTree, TMonadMember, TQueryOperator> : Object where TMonadMember : TQueryTree where TQueryOperator : TMonadMember
Type Parameters
Name | Description |
---|---|
TQueryTree | Target type for query expressions. |
TMonadMember | Target type for monad member expressions. This type has to derive from TQueryTree. |
TQueryOperator | Target type for query operator expressions. This type has to derive from TMonadMember. |
Constructors
QueryVisitor()
Declaration
protected QueryVisitor()
Methods
MakeFirst(FirstOperator, TMonadMember)
Makes a FirstOperator with the given children.
Declaration
protected abstract TQueryOperator MakeFirst(FirstOperator node, TMonadMember source)
Parameters
Type | Name | Description |
---|---|---|
FirstOperator | node | Original query expression. |
TMonadMember | source | Source query expression. |
Returns
Type | Description |
---|---|
TQueryOperator | Representation of the original query expression. |
MakeFirstPredicate(FirstPredicateOperator, TMonadMember, TQueryTree)
Makes a FirstPredicateOperator with the given children.
Declaration
protected abstract TQueryOperator MakeFirstPredicate(FirstPredicateOperator node, TMonadMember source, TQueryTree predicate)
Parameters
Type | Name | Description |
---|---|---|
FirstPredicateOperator | node | Original query expression. |
TMonadMember | source | Source query expression. |
TQueryTree | predicate | Predicate query expression. |
Returns
Type | Description |
---|---|
TQueryOperator | Representation of the original query expression. |
MakeLambdaAbstraction(LambdaAbstraction, ReadOnlyCollection<TQueryTree>)
Makes a LambdaAbstraction with the given children.
Declaration
protected abstract TQueryTree MakeLambdaAbstraction(LambdaAbstraction node, ReadOnlyCollection<TQueryTree> arguments)
Parameters
Type | Name | Description |
---|---|---|
LambdaAbstraction | node | Original query expression. |
System.Collections.ObjectModel.ReadOnlyCollection<TQueryTree> | arguments | Argument query expressions. |
Returns
Type | Description |
---|---|
TQueryTree | Representation of the original query expression. |
MakeMonadAbstraction(MonadAbstraction, TQueryTree)
Makes a MonadAbstraction with the given children.
Declaration
protected abstract TMonadMember MakeMonadAbstraction(MonadAbstraction node, TQueryTree inner)
Parameters
Type | Name | Description |
---|---|---|
MonadAbstraction | node | Original query expression. |
TQueryTree | inner | Inner query expression. |
Returns
Type | Description |
---|---|
TMonadMember | Representation of the original query expression. |
MakeSelect(SelectOperator, TMonadMember, TQueryTree)
Makes a SelectOperator with the given children.
Declaration
protected abstract TQueryOperator MakeSelect(SelectOperator node, TMonadMember source, TQueryTree selector)
Parameters
Type | Name | Description |
---|---|---|
SelectOperator | node | Original query expression. |
TMonadMember | source | Source query expression. |
TQueryTree | selector | Selector query expression. |
Returns
Type | Description |
---|---|
TQueryOperator | Representation of the original query expression. |
MakeTake(TakeOperator, TMonadMember, TQueryTree)
Makes a TakeOperator with the given children.
Declaration
protected abstract TQueryOperator MakeTake(TakeOperator node, TMonadMember source, TQueryTree count)
Parameters
Type | Name | Description |
---|---|---|
TakeOperator | node | Original query expression. |
TMonadMember | source | Source query expression. |
TQueryTree | count | Count query expression. |
Returns
Type | Description |
---|---|
TQueryOperator | Representation of the original query expression. |
MakeWhere(WhereOperator, TMonadMember, TQueryTree)
Makes a WhereOperator with the given children.
Declaration
protected abstract TQueryOperator MakeWhere(WhereOperator node, TMonadMember source, TQueryTree predicate)
Parameters
Type | Name | Description |
---|---|---|
WhereOperator | node | Original query expression. |
TMonadMember | source | Source query expression. |
TQueryTree | predicate | Predicate query expression. |
Returns
Type | Description |
---|---|
TQueryOperator | Representation of the original query expression. |
Visit(QueryTree)
Visits the specified query expression and rewrites it to the target query expression type.
Declaration
public virtual TQueryTree Visit(QueryTree expression)
Parameters
Type | Name | Description |
---|---|---|
QueryTree | expression | Query expression to visit. |
Returns
Type | Description |
---|---|
TQueryTree | Result of visiting the query expression. |
Visit<TSource, TResult>(ReadOnlyCollection<TSource>, Func<TSource, TResult>)
Visits the elements in the specified input collection.
Declaration
protected ReadOnlyCollection<TResult> Visit<TSource, TResult>(ReadOnlyCollection<TSource> nodes, Func<TSource, TResult> visitor)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.ObjectModel.ReadOnlyCollection<TSource> | nodes | Input collection whose elements to visit. |
System.Func<TSource, TResult> | visitor | Function to visit elements in the input collection. |
Returns
Type | Description |
---|---|
System.Collections.ObjectModel.ReadOnlyCollection<TResult> | Collection of visited input elements. |
Type Parameters
Name | Description |
---|---|
TSource | Element type in the input collection. |
TResult | Element type in the result collection. |
VisitAndConvert<TStronglyTypedResult>(QueryTree)
Visits the specified query expression and rewrites it to the specified target query expression type.
Declaration
protected TStronglyTypedResult VisitAndConvert<TStronglyTypedResult>(QueryTree node)
where TStronglyTypedResult : TQueryTree
Parameters
Type | Name | Description |
---|---|---|
QueryTree | node | Expression to visit. |
Returns
Type | Description |
---|---|
TStronglyTypedResult | Result of visiting the expression. |
Type Parameters
Name | Description |
---|---|
TStronglyTypedResult | Type of the result of the rewrite. This type should derive from TQueryTree. |
VisitFirst(FirstOperator)
Visits a FirstOperator node.
Declaration
protected virtual TQueryOperator VisitFirst(FirstOperator op)
Parameters
Type | Name | Description |
---|---|---|
FirstOperator | op | Node to visit. |
Returns
Type | Description |
---|---|
TQueryOperator | Result of visiting the node. |
VisitFirstPredicate(FirstPredicateOperator)
Visits a FirstPredicateOperator node.
Declaration
protected virtual TQueryOperator VisitFirstPredicate(FirstPredicateOperator op)
Parameters
Type | Name | Description |
---|---|---|
FirstPredicateOperator | op | Node to visit. |
Returns
Type | Description |
---|---|
TQueryOperator | Result of visiting the node. |
VisitLambdaAbstraction(LambdaAbstraction)
Visits a LambdaAbstraction node.
Declaration
protected virtual TQueryTree VisitLambdaAbstraction(LambdaAbstraction node)
Parameters
Type | Name | Description |
---|---|---|
LambdaAbstraction | node | Node to visit. |
Returns
Type | Description |
---|---|
TQueryTree | Result of visiting the node. |
VisitMonadAbstraction(MonadAbstraction)
Visits a MonadAbstraction node.
Declaration
protected virtual TMonadMember VisitMonadAbstraction(MonadAbstraction node)
Parameters
Type | Name | Description |
---|---|---|
MonadAbstraction | node | Node to visit. |
Returns
Type | Description |
---|---|
TMonadMember | Result of visiting the node. |
VisitSelect(SelectOperator)
Visits a SelectOperator node.
Declaration
protected virtual TQueryOperator VisitSelect(SelectOperator op)
Parameters
Type | Name | Description |
---|---|---|
SelectOperator | op | Node to visit. |
Returns
Type | Description |
---|---|
TQueryOperator | Result of visiting the node. |
VisitTake(TakeOperator)
Visits a TakeOperator node.
Declaration
protected virtual TQueryOperator VisitTake(TakeOperator op)
Parameters
Type | Name | Description |
---|---|---|
TakeOperator | op | Node to visit. |
Returns
Type | Description |
---|---|
TQueryOperator | Result of visiting the node. |
VisitWhere(WhereOperator)
Visits a WhereOperator node.
Declaration
protected virtual TQueryOperator VisitWhere(WhereOperator op)
Parameters
Type | Name | Description |
---|---|---|
WhereOperator | op | Node to visit. |
Returns
Type | Description |
---|---|
TQueryOperator | Result of visiting the node. |