text regex source gen framework is briefly done. Going on ir2code
This commit is contained in:
@@ -48,6 +48,15 @@ namespace StgSharp.RegularAnalysis.Abstraction
|
||||
private readonly Node _head;
|
||||
private Node _tail;
|
||||
|
||||
private SequenceEmitter(
|
||||
Node node
|
||||
)
|
||||
{
|
||||
_isRoot = true;
|
||||
_head = node;
|
||||
_tail = _head;
|
||||
}
|
||||
|
||||
public SequenceEmitter()
|
||||
{
|
||||
_isRoot = true;
|
||||
@@ -57,8 +66,6 @@ namespace StgSharp.RegularAnalysis.Abstraction
|
||||
|
||||
public int Count { get; private set; }
|
||||
|
||||
private static bool IsString { get; } = typeof(T) == typeof(string);
|
||||
|
||||
public SequenceEmitter<T> Append(
|
||||
T unit
|
||||
)
|
||||
@@ -92,6 +99,16 @@ namespace StgSharp.RegularAnalysis.Abstraction
|
||||
return this;
|
||||
}
|
||||
|
||||
public SequenceEmitter<T> Clone()
|
||||
{
|
||||
if (!_isRoot) {
|
||||
throw new InvalidOperationException("This emitter has been appended to another emitter. It is now readonly.");
|
||||
}
|
||||
SequenceEmitter<T> clone = new();
|
||||
Node current = _head;
|
||||
return clone;
|
||||
}
|
||||
|
||||
public Enumerator GetEnumerator()
|
||||
{
|
||||
return _isRoot ?
|
||||
@@ -173,6 +190,18 @@ namespace StgSharp.RegularAnalysis.Abstraction
|
||||
private sealed class Node
|
||||
{
|
||||
|
||||
public Node()
|
||||
{
|
||||
IRList = [];
|
||||
}
|
||||
|
||||
public Node(
|
||||
int capacity
|
||||
)
|
||||
{
|
||||
IRList = new(capacity);
|
||||
}
|
||||
|
||||
public T this[
|
||||
int index
|
||||
]
|
||||
@@ -185,7 +214,7 @@ namespace StgSharp.RegularAnalysis.Abstraction
|
||||
|
||||
public int Count => IRList.Count;
|
||||
|
||||
public List<T> IRList { get; } = [];
|
||||
public List<T> IRList { get; }
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Add(
|
||||
@@ -195,6 +224,13 @@ namespace StgSharp.RegularAnalysis.Abstraction
|
||||
IRList.Add(ir);
|
||||
}
|
||||
|
||||
public void AddRange(
|
||||
IEnumerable<T> irs
|
||||
)
|
||||
{
|
||||
IRList.AddRange(irs);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user