diff --git a/Tsu.Trees.RedGreen/sample/Generated/Tsu.Trees.RedGreen.SourceGenerator/Tsu.Trees.RedGreen.SourceGenerator.Generator/GreenNode.Debug.g.cs b/Tsu.Trees.RedGreen/sample/Generated/Tsu.Trees.RedGreen.SourceGenerator/Tsu.Trees.RedGreen.SourceGenerator.Generator/GreenNode.Debug.g.cs
new file mode 100644
index 0000000..1cbf49a
--- /dev/null
+++ b/Tsu.Trees.RedGreen/sample/Generated/Tsu.Trees.RedGreen.SourceGenerator/Tsu.Trees.RedGreen.SourceGenerator.Generator/GreenNode.Debug.g.cs
@@ -0,0 +1,38 @@
+// GreenBase = global::Tsu.Trees.RedGreen.Sample.Internal.GreenNode
+// RedBase = global::Tsu.Trees.RedGreen.Sample.SampleNode
+// KindEnum = global::Tsu.Trees.RedGreen.Sample.SampleKind
+// CreateVisitors = True
+// CreateWalker = True
+// CreateRewriter = True
+// Root = global::Tsu.Trees.RedGreen.Sample.Internal.GreenNode
+// global::Tsu.Trees.RedGreen.Sample.Internal.GreenNode
+// Children:
+// ExtraData:
+// global::Tsu.Trees.RedGreen.Sample.SampleKind (Name = _kind, IsOptional = False, PassToBase = False)
+// global::Tsu.Trees.RedGreen.Sample.Internal.ExpressionSample
+// Children:
+// ExtraData:
+// global::Tsu.Trees.RedGreen.Sample.SampleKind (Name = _kind, IsOptional = False, PassToBase = True)
+// global::Tsu.Trees.RedGreen.Sample.Internal.FunctionCallExpressionSample
+// Children:
+// global::Tsu.Trees.RedGreen.Sample.Internal.IdentifierExpressionSample (Name = identifier, IsOptional = False, PassToBase = False)
+// global::Tsu.Trees.RedGreen.Sample.Internal.ExpressionSample (Name = firstArg, IsOptional = False, PassToBase = False)
+// global::Tsu.Trees.RedGreen.Sample.Internal.ExpressionSample (Name = secondArg, IsOptional = True, PassToBase = False)
+// ExtraData:
+// global::Tsu.Trees.RedGreen.Sample.SampleKind (Name = _kind, IsOptional = False, PassToBase = True)
+// global::Tsu.Trees.RedGreen.Sample.Internal.BinaryOperationExpressionSample
+// Children:
+// global::Tsu.Trees.RedGreen.Sample.Internal.ExpressionSample (Name = _left, IsOptional = False, PassToBase = False)
+// global::Tsu.Trees.RedGreen.Sample.Internal.ExpressionSample (Name = _right, IsOptional = False, PassToBase = False)
+// ExtraData:
+// global::Tsu.Trees.RedGreen.Sample.SampleKind (Name = _kind, IsOptional = False, PassToBase = True)
+// global::Tsu.Trees.RedGreen.Sample.Internal.NumericalLiteralExpressionSample
+// Children:
+// ExtraData:
+// global::Tsu.Trees.RedGreen.Sample.SampleKind (Name = _kind, IsOptional = False, PassToBase = True)
+// double (Name = _value, IsOptional = False, PassToBase = False)
+// global::Tsu.Trees.RedGreen.Sample.Internal.IdentifierExpressionSample
+// Children:
+// ExtraData:
+// global::Tsu.Trees.RedGreen.Sample.SampleKind (Name = _kind, IsOptional = False, PassToBase = True)
+// string (Name = _name, IsOptional = False, PassToBase = False)
diff --git a/Tsu.Trees.RedGreen/sample/Generated/Tsu.Trees.RedGreen.SourceGenerator/Tsu.Trees.RedGreen.SourceGenerator.Generator/Initialized.g.cs b/Tsu.Trees.RedGreen/sample/Generated/Tsu.Trees.RedGreen.SourceGenerator/Tsu.Trees.RedGreen.SourceGenerator.Generator/Initialized.g.cs
new file mode 100644
index 0000000..631a29a
--- /dev/null
+++ b/Tsu.Trees.RedGreen/sample/Generated/Tsu.Trees.RedGreen.SourceGenerator/Tsu.Trees.RedGreen.SourceGenerator.Generator/Initialized.g.cs
@@ -0,0 +1 @@
+//
\ No newline at end of file
diff --git a/Tsu.Trees.RedGreen/sample/Generated/Tsu.Trees.RedGreen.SourceGenerator/Tsu.Trees.RedGreen.SourceGenerator.Generator/Sample.Internal.g.cs b/Tsu.Trees.RedGreen/sample/Generated/Tsu.Trees.RedGreen.SourceGenerator/Tsu.Trees.RedGreen.SourceGenerator.Generator/Sample.Internal.g.cs
new file mode 100644
index 0000000..0937437
--- /dev/null
+++ b/Tsu.Trees.RedGreen/sample/Generated/Tsu.Trees.RedGreen.SourceGenerator/Tsu.Trees.RedGreen.SourceGenerator.Generator/Sample.Internal.g.cs
@@ -0,0 +1,140 @@
+//
+
+using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+
+namespace Tsu.Trees.RedGreen.Sample.Internal
+{
+ abstract partial class GreenNode : global::Tsu.Trees.RedGreen.Internal.IGreenNode
+ {
+ private readonly global::Tsu.Trees.RedGreen.Sample.SampleKind _kind;
+ private byte _slotCount;
+
+ protected GreenNode(global::Tsu.Trees.RedGreen.Sample.SampleKind kind)
+ {
+ this._kind = kind;
+ }
+
+ public global::Tsu.Trees.RedGreen.Sample.SampleKind Kind => this._kind;
+
+ public int SlotCount
+ {
+ get
+ {
+ int count = this._slotCount;
+ if (count == byte.MaxValue)
+ count = this.GetSlotCount();
+ return count;
+ }
+ protected set => _slotCount = (byte) value;
+ }
+
+ public abstract global::Tsu.Trees.RedGreen.Sample.Internal.GreenNode? GetSlot(int slot);
+
+ public global::Tsu.Trees.RedGreen.Sample.Internal.GreenNode GetRequiredSlot(int slot)
+ {
+ var node = this.GetSlot(slot);
+ Debug.Assert((object)node != null)
+ return node;
+ }
+
+ protected virtual int GetSlotCount() => _slotCount;
+
+ public global::System.Collections.Generic.IEnumerable ChildNodes()
+ {
+ var count = this.SlotCount;
+ for (var slot = 0; slot < count; slot++)
+ yield return this.GetRequiredSlot(slot);
+ }
+
+ public global::System.Collections.Generic.IEnumerable EnumerateDescendants()
+ {
+ var stack = new Stack(24);
+ stack.Push(this);
+
+ while (stack.Count > 0)
+ {
+ var current = stack.Pop();
+
+ yield return current;
+
+ foreach (var child in current.ChildNodes().Reverse())
+ {
+ stack.Push(child);
+ }
+ }
+ }
+
+ public virtual bool IsEquivalentTo([NotNullWhen(true)] global::Tsu.Trees.RedGreen.Sample.Internal.GreenNode? other)
+ {
+ if (this == other) return true;
+ if (other == null) return false;
+ if (this.Kind != other.Kind) return false;
+var n = this.SlotCount;
+ if (n != other.SlotCount) return false;
+
+ for (int i = 0; i < n; i++)
+ {
+ var thisChild = this.GetSlot(i);
+ var otherChild = other.GetSlot(i);
+ if (thisChild != null && otherChild != null && !thisChild.IsEquivalentTo(otherChild))
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ public global::Tsu.Trees.RedGreen.Sample.SampleNode CreateRed() => this.CreateRed(null);
+ public abstract global::Tsu.Trees.RedGreen.Sample.SampleNode CreateRed(global::Tsu.Trees.RedGreen.Sample.SampleNode? parent);
+ }
+
+ abstract partial class ExpressionSample : global::Tsu.Trees.RedGreen.Sample.Internal.GreenNode
+ {
+ protected ExpressionSample(global::Tsu.Trees.RedGreen.Sample.SampleKind kind) : base(kind)
+ {
+ }
+ }
+
+ partial class IdentifierExpressionSample : global::Tsu.Trees.RedGreen.Sample.Internal.ExpressionSample
+ {
+ internal IdentifierExpressionSample(global::Tsu.Trees.RedGreen.Sample.SampleKind kind, string name) : base(kind)
+ {
+ this.SlotCount = 0;
+ this._name = name;
+ }
+ }
+
+ partial class NumericalLiteralExpressionSample : global::Tsu.Trees.RedGreen.Sample.Internal.ExpressionSample
+ {
+ internal NumericalLiteralExpressionSample(global::Tsu.Trees.RedGreen.Sample.SampleKind kind, double value) : base(kind)
+ {
+ this.SlotCount = 0;
+ this._value = value;
+ }
+ }
+
+ partial class BinaryOperationExpressionSample : global::Tsu.Trees.RedGreen.Sample.Internal.ExpressionSample
+ {
+ internal BinaryOperationExpressionSample(global::Tsu.Trees.RedGreen.Sample.SampleKind kind, global::Tsu.Trees.RedGreen.Sample.Internal.ExpressionSample left, global::Tsu.Trees.RedGreen.Sample.Internal.ExpressionSample right) : base(kind)
+ {
+ this.SlotCount = 2;
+ this._left = left;
+ this._right = right;
+ }
+ }
+
+ partial class FunctionCallExpressionSample : global::Tsu.Trees.RedGreen.Sample.Internal.ExpressionSample
+ {
+ internal FunctionCallExpressionSample(global::Tsu.Trees.RedGreen.Sample.SampleKind kind, global::Tsu.Trees.RedGreen.Sample.Internal.IdentifierExpressionSample identifier, global::Tsu.Trees.RedGreen.Sample.Internal.ExpressionSample firstArg, global::Tsu.Trees.RedGreen.Sample.Internal.ExpressionSample secondArg) : base(kind)
+ {
+ this.SlotCount = 3;
+ this.identifier = identifier;
+ this.firstArg = firstArg;
+ this.secondArg = secondArg;
+ }
+ }
+}
+
diff --git a/Tsu.Trees.RedGreen/sample/Tree.cs b/Tsu.Trees.RedGreen/sample/Tree.cs
index 9097b62..7dbee9e 100644
--- a/Tsu.Trees.RedGreen/sample/Tree.cs
+++ b/Tsu.Trees.RedGreen/sample/Tree.cs
@@ -20,6 +20,7 @@ public abstract partial class SampleNode
}
}
+
namespace Tsu.Trees.RedGreen.Sample.Internal
{
[GreenTreeRoot(typeof(SampleNode), "Sample", typeof(SampleKind), CreateRewriter = true, CreateVisitors = true, CreateWalker = true)]
@@ -34,20 +35,20 @@ internal abstract partial class ExpressionSample : GreenNode
[GreenNode(SampleKind.IdentifierExpression)]
internal sealed partial class IdentifierExpressionSample : ExpressionSample
{
- private readonly string name;
+ private readonly string _name;
}
[GreenNode(SampleKind.NumericalLiteralExpression)]
internal sealed partial class NumericalLiteralExpressionSample : ExpressionSample
{
- private readonly double value;
+ private readonly double _value;
}
[GreenNode(SampleKind.AdditionExpression, SampleKind.DivisionExpression, SampleKind.MultiplicationExpression, SampleKind.SubtractionExpression)]
internal sealed partial class BinaryOperationExpressionSample : ExpressionSample
{
- private readonly ExpressionSample left;
- private readonly ExpressionSample right;
+ private readonly ExpressionSample _left;
+ private readonly ExpressionSample _right;
}
[GreenNode(SampleKind.FunctionCallExpression)]