-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate the green tree root to the scriban template system.
- Loading branch information
1 parent
0260349
commit dfc39e3
Showing
4 changed files
with
220 additions
and
254 deletions.
There are no files selected for viewing
102 changes: 102 additions & 0 deletions
102
...rees.RedGreen/Tsu.Trees.RedGreen.SourceGenerator.Generator/Sample.Internal.GreenRoot.g.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
// <auto-generated /> | ||
|
||
#nullable enable | ||
|
||
using System.Diagnostics; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Linq; | ||
|
||
namespace Tsu.Trees.RedGreen.Sample.Internal | ||
{ | ||
abstract partial class GreenNode | ||
{ | ||
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 index); | ||
|
||
public global::Tsu.Trees.RedGreen.Sample.Internal.GreenNode GetRequiredSlot(int index) | ||
{ | ||
var node = this.GetSlot(index); | ||
Debug.Assert(node != null); | ||
return node!; | ||
} | ||
|
||
protected virtual int GetSlotCount() => _slotCount; | ||
|
||
public global::System.Collections.Generic.IEnumerable<global::Tsu.Trees.RedGreen.Sample.Internal.GreenNode> ChildNodes() | ||
{ | ||
var count = this.SlotCount; | ||
for (var index = 0; index < count; index++) | ||
yield return this.GetRequiredSlot(index); | ||
} | ||
|
||
public global::System.Collections.Generic.IEnumerable<global::Tsu.Trees.RedGreen.Sample.Internal.GreenNode> EnumerateDescendants() | ||
{ | ||
var stack = new Stack<global::Tsu.Trees.RedGreen.Sample.Internal.GreenNode>(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); | ||
|
||
public abstract void Accept(global::Tsu.Trees.RedGreen.Sample.Internal.SampleVisitor visitor); | ||
public abstract TResult? Accept<TResult>(global::Tsu.Trees.RedGreen.Sample.Internal.SampleVisitor<TResult> visitor); | ||
public abstract TResult? Accept<T1, TResult>(global::Tsu.Trees.RedGreen.Sample.Internal.SampleVisitor<T1, TResult> visitor, T1 arg1); | ||
public abstract TResult? Accept<T1, T2, TResult>(global::Tsu.Trees.RedGreen.Sample.Internal.SampleVisitor<T1, T2, TResult> visitor, T1 arg1, T2 arg2); | ||
public abstract TResult? Accept<T1, T2, T3, TResult>(global::Tsu.Trees.RedGreen.Sample.Internal.SampleVisitor<T1, T2, T3, TResult> visitor, T1 arg1, T2 arg2, T3 arg3); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.