Show / Hide Table of Contents

Class BottomUpRewriter<TSource, TSourceNodeType, TTarget, TWildcardFactory>

Defines a bottom-up rewriter for TSource trees to TTarget trees.

Inheritance
System.Object
BottomUpRewriter<TSource, TSourceNodeType, TTarget, TWildcardFactory>
BottomUpExpressionRewriter<TTarget>
BottomUpOptimizer<TTree, TTreeNodeType, TWildcardFactory>
Namespace: System.Linq.CompilerServices
Assembly: Nuqleon.Linq.CompilerServices.dll
Syntax
public class BottomUpRewriter<TSource, TSourceNodeType, TTarget, TWildcardFactory> : Object where TSource : ITree<TSourceNodeType> where TTarget : ITree where TWildcardFactory : IWildcardFactory<TSource>, new()
Type Parameters
Name Description
TSource

Type of the source trees. Needs to implement ITree<TSourceNodeType>.

TSourceNodeType

Node type of the source trees.

TTarget

Type of the target trees. Needs to implement ITree.

TWildcardFactory

Wildcard factory type for source tree wildcard nodes.

Constructors

BottomUpRewriter()

Creates a new bottom up rewriter instance with no initial rewrite rule definitions. Collection initializer syntax can be used for the Leaves, Rules, and Fallbacks properties.

Declaration
public BottomUpRewriter()

BottomUpRewriter(IEqualityComparer<TSourceNodeType>)

Creates a new bottom up rewriter instance with no initial rewrite rule definitions. Collection initializer syntax can be used for the Leaves, Rules, and Fallbacks properties.

Declaration
public BottomUpRewriter(IEqualityComparer<TSourceNodeType> sourceNodeComparer)
Parameters
Type Name Description
System.Collections.Generic.IEqualityComparer<TSourceNodeType> sourceNodeComparer

Equality comparer used to compare source tree nodes during construction of the rule table and during tree matching.

Properties

DebugView

Gets a string representation of the internal tables in the rewriter, useful for debugging purposes.

Declaration
public string DebugView { get; }
Property Value
Type Description
System.String

Fallbacks

Gets the collection of fallback rules used by the rewriter.

Declaration
public FallbackCollection<TSource, TTarget> Fallbacks { get; }
Property Value
Type Description
FallbackCollection<TSource, TTarget>

Leaves

Gets the collection of leaves recognized by the rewriter.

Declaration
public LeafCollection<TSource, TTarget> Leaves { get; }
Property Value
Type Description
LeafCollection<TSource, TTarget>

Log

Gets or sets a logger object used to log activity in the rewriter.

Declaration
public TextWriter Log { get; set; }
Property Value
Type Description
System.IO.TextWriter

Rules

Gets the collection of rewrite pattern rules recognized by the rewriter.

Declaration
public RuleCollection<TSource, TTarget> Rules { get; }
Property Value
Type Description
RuleCollection<TSource, TTarget>

Methods

OnFallbackAdded(Fallback<TSource, TTarget>)

Callback from the fallback collection upon addition of a fallback rule.

Declaration
protected virtual void OnFallbackAdded(Fallback<TSource, TTarget> fallback)
Parameters
Type Name Description
Fallback<TSource, TTarget> fallback

Fallback rule that has been added.

OnLeafAdded(Leaf<TSource, TTarget>)

Callback from the leaf collection upon addition of a leaf rule.

Declaration
protected virtual void OnLeafAdded(Leaf<TSource, TTarget> leaf)
Parameters
Type Name Description
Leaf<TSource, TTarget> leaf

Leaf rule that has been added.

OnRuleAdded(Rule<TSource, TTarget>)

Callback from the rule collection upon addition of a rewrite rule.

Declaration
protected virtual void OnRuleAdded(Rule<TSource, TTarget> rule)
Parameters
Type Name Description
Rule<TSource, TTarget> rule

Rewrite rule that has been added.

Rewrite(TSource)

Rewrites the given source tree to a target tree using the rules in the table.

Declaration
public TTarget Rewrite(TSource source)
Parameters
Type Name Description
TSource source

Source tree to rewrite.

Returns
Type Description
TTarget

Target tree after applying the rewrite rules in the table.

WriteLog(String)

Writes an entry to the log.

Declaration
protected void WriteLog(string message)
Parameters
Type Name Description
System.String message

Message to log.

In This Article
Back to top Generated by DocFX