Working on tree optimizer

This commit is contained in:
Youmu Liu
2026-02-11 18:02:45 +08:00
parent 4735b987f4
commit 39dd32992d
9 changed files with 193 additions and 63 deletions
@@ -181,9 +181,20 @@ namespace StgSharp.RegularAnalysis.Abstraction
_state = 0;
}
public void SkipNode()
/// <summary>
/// Skips the node and its subtree if the current node is the given node. Otherwise, do
/// nothing.
/// </summary>
/// <param name="node">
/// The node to skip.
/// </param>
public void SkipNode(
TNode node
)
{
if (_stack.TryPop(out Record? r)) {
if (_stack.TryPeek(out Record? r) && ReferenceEquals(r.Node, node))
{
_ = _stack.Pop();
_recycle.Push(r);
}
}
@@ -176,6 +176,7 @@ namespace StgSharp.RegularAnalysis.Abstraction
#region depth
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void DecreaseDepth(
)
{
@@ -185,6 +186,7 @@ namespace StgSharp.RegularAnalysis.Abstraction
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void IncreaseDepth(
int mark
)
@@ -66,14 +66,6 @@ namespace StgSharp.RegularAnalysis.Abstraction
TNode nextToken
);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static virtual bool IsNullOrEmpty(
TNode node
)
{
return node is null || node.Equals(TNode.Empty);
}
void PrependNode(
TNode previousNode
);