Skip to content

Commit

Permalink
Add the intial attributes.
Browse files Browse the repository at this point in the history
  • Loading branch information
GGG-KILLER committed Jan 28, 2024
1 parent 84789bd commit 65d54cb
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Tsu.Trees.RedGreen/src/ChildAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Tsu.Trees.RedGreen;

/// <summary>
/// Indicates this field/property stores a child node.
/// </summary>
/// <remarks>
/// This is used in generation of GetChildren and GetSlot.
/// </remarks>
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, Inherited = false, AllowMultiple = false)]
public sealed class ChildAttribute : Attribute
{
/// <summary>
/// The override for the slot of this child.
/// </summary>
public int? Slot { get; }
}
17 changes: 17 additions & 0 deletions Tsu.Trees.RedGreen/src/GreenNodeKindAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace Tsu.Trees.RedGreen;

/// <summary>
/// Overrides the kind for a given green node.
/// </summary>
/// <param name="kind">
/// The value of the kind this node should have.
/// This should be the value on the enum (e.g.: SyntaxKind.ClassDeclarationSyntax)
/// </param>
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
public sealed class GreenNodeKindAttribute(object kind) : Attribute
{
/// <summary>
/// This node's Kind.
/// </summary>
public object Kind { get; } = kind;
}
34 changes: 34 additions & 0 deletions Tsu.Trees.RedGreen/src/GreenNodeRoot.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
namespace Tsu.Trees.RedGreen;

/// <summary>
/// An attribute that marks the given class as the base class for all nodes in a green node tree.
/// </summary>
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
public sealed class GreenNodeRootAttribute(string listName, Type redRoot) : Attribute
{
/// <summary>
/// The name of the list type for this green tree.
/// </summary>
public string ListName { get; } = listName;

/// <summary>
/// The base node type for all nodes in the red tree.
/// </summary>
public Type RedBase { get; } = redRoot;

/// <summary>
/// The enum type that contains the definitions for the node kinds.
/// </summary>
public Type? KindEnum { get; set; }

// NOTE: Make cache configurable?
// /// <summary>
// /// Whether to enable the green cache or not.
// /// </summary>
// public bool CacheEnabled { get; set; } = true;

// /// <summary>
// /// The amount of bits from the hash to use for caching.
// /// </summary>
// public int CacheSizeBits { get; set; } = 16;
}

0 comments on commit 65d54cb

Please sign in to comment.