source gen and ir gen now use the same seq generator
This commit is contained in:
@@ -18,7 +18,8 @@ namespace StgSharp.RegularAnalysis.Text
|
||||
{
|
||||
|
||||
internal static List<RegexIR> EmitPrefix(
|
||||
List<RegexIR> irList
|
||||
List<RegexIR> irList,
|
||||
ref RegexInfo info
|
||||
)
|
||||
{
|
||||
List<RegexIR> origin = irList;
|
||||
@@ -27,8 +28,9 @@ namespace StgSharp.RegularAnalysis.Text
|
||||
|
||||
int region_name = 1;
|
||||
EmitPrefix(origin_span, result, 0, 0);
|
||||
FixLineObservation(result);
|
||||
|
||||
int single_line_count = FixLineObservation(result);
|
||||
info.RegionCount = region_name - 1;
|
||||
info.SingleLineResultCount = single_line_count;
|
||||
return result;
|
||||
|
||||
void EmitPrefix(
|
||||
@@ -408,10 +410,14 @@ namespace StgSharp.RegularAnalysis.Text
|
||||
}
|
||||
}
|
||||
|
||||
static void FixLineObservation(
|
||||
List<RegexIR> result
|
||||
static int FixLineObservation(
|
||||
List<RegexIR> result
|
||||
)
|
||||
{
|
||||
// Observe_Line uses relative offsets while nested regions are emitted.
|
||||
// Positive offsets point to larger line numbers; this pass resolves them
|
||||
// into absolute IR line indexes after the final instruction order is known.
|
||||
HashSet<int> single_required = [];
|
||||
for (int i = 0; i < result.Count; i++)
|
||||
{
|
||||
RegexIRPrefix prefix = result[i].Prefix;
|
||||
@@ -420,11 +426,15 @@ namespace StgSharp.RegularAnalysis.Text
|
||||
continue;
|
||||
}
|
||||
|
||||
result[i].Prefix = new RegexIRPrefix(
|
||||
int observeSource = i + prefix.ObserveSource;
|
||||
RegexIRPrefix prefix_new = new RegexIRPrefix(
|
||||
prefix.WorkingRegion,
|
||||
prefix.Mask,
|
||||
i - 1);
|
||||
observeSource);
|
||||
result[i].Prefix = prefix_new;
|
||||
_ = single_required.Add(prefix_new.ObserveSource);
|
||||
}
|
||||
return single_required.Count;
|
||||
}
|
||||
|
||||
static bool IsFoldableSingleTryInstruction(
|
||||
|
||||
Reference in New Issue
Block a user