@@ -459,16 +459,16 @@ fileprivate extension Compiler.ByteCodeGen {
459
459
assert ( high != 0 )
460
460
assert ( ( 0 ... ( high ?? Int . max) ) . contains ( low) )
461
461
462
- let extraTrips : Int ?
462
+ let maxExtraTrips : Int ?
463
463
if let h = high {
464
- extraTrips = h - low
464
+ maxExtraTrips = h - low
465
465
} else {
466
- extraTrips = nil
466
+ maxExtraTrips = nil
467
467
}
468
468
let minTrips = low
469
- assert ( ( extraTrips ?? 1 ) >= 0 )
469
+ assert ( ( maxExtraTrips ?? 1 ) >= 0 )
470
470
471
- if tryEmitFastQuant ( child, updatedKind, minTrips, extraTrips ) {
471
+ if tryEmitFastQuant ( child, updatedKind, minTrips, maxExtraTrips ) {
472
472
return
473
473
}
474
474
@@ -486,19 +486,19 @@ fileprivate extension Compiler.ByteCodeGen {
486
486
decrement %minTrips and fallthrough
487
487
488
488
loop-body:
489
- <if can't guarantee forward progress && extraTrips = nil>:
489
+ <if can't guarantee forward progress && maxExtraTrips = nil>:
490
490
mov currentPosition %pos
491
491
evaluate the subexpression
492
- <if can't guarantee forward progress && extraTrips = nil>:
492
+ <if can't guarantee forward progress && maxExtraTrips = nil>:
493
493
if %pos is currentPosition:
494
494
goto exit
495
495
goto min-trip-count control block
496
496
497
497
exit-policy control block:
498
- if %extraTrips is zero:
498
+ if %maxExtraTrips is zero:
499
499
goto exit
500
500
else:
501
- decrement %extraTrips and fallthrough
501
+ decrement %maxExtraTrips and fallthrough
502
502
503
503
<if eager>:
504
504
save exit and goto loop-body
@@ -525,12 +525,12 @@ fileprivate extension Compiler.ByteCodeGen {
525
525
/* fallthrough */
526
526
"""
527
527
528
- // Specialization based on `extraTrips ` for 0 or unbounded
528
+ // Specialization based on `maxExtraTrips ` for 0 or unbounded
529
529
_ = """
530
530
exit-policy control block:
531
- <if extraTrips == 0>:
531
+ <if maxExtraTrips == 0>:
532
532
goto exit
533
- <if extraTrips == .unbounded>:
533
+ <if maxExtraTrips == .unbounded>:
534
534
/* fallthrough */
535
535
"""
536
536
@@ -563,12 +563,12 @@ fileprivate extension Compiler.ByteCodeGen {
563
563
minTripsReg = nil
564
564
}
565
565
566
- let extraTripsReg : IntRegister ?
567
- if ( extraTrips ?? 0 ) > 0 {
568
- extraTripsReg = builder. makeIntRegister (
569
- initialValue: extraTrips !)
566
+ let maxExtraTripsReg : IntRegister ?
567
+ if ( maxExtraTrips ?? 0 ) > 0 {
568
+ maxExtraTripsReg = builder. makeIntRegister (
569
+ initialValue: maxExtraTrips !)
570
570
} else {
571
- extraTripsReg = nil
571
+ maxExtraTripsReg = nil
572
572
}
573
573
574
574
// Set up a dummy save point for possessive to update
@@ -600,7 +600,7 @@ fileprivate extension Compiler.ByteCodeGen {
600
600
let startPosition : PositionRegister ?
601
601
let emitPositionChecking =
602
602
( !optimizationsEnabled || !child. guaranteesForwardProgress) &&
603
- extraTrips == nil
603
+ maxExtraTrips == nil
604
604
605
605
if emitPositionChecking {
606
606
startPosition = builder. makePositionRegister ( )
@@ -610,7 +610,7 @@ fileprivate extension Compiler.ByteCodeGen {
610
610
}
611
611
try emitNode ( child)
612
612
if emitPositionChecking {
613
- // in all quantifier cases, no matter what minTrips or extraTrips is,
613
+ // in all quantifier cases, no matter what minTrips or maxExtraTrips is,
614
614
// if we have a successful non-advancing match, branch to exit because it
615
615
// can match an arbitrary number of times
616
616
builder. buildCondBranch ( to: exit, ifSamePositionAs: startPosition!)
@@ -623,20 +623,20 @@ fileprivate extension Compiler.ByteCodeGen {
623
623
}
624
624
625
625
// exit-policy:
626
- // condBranch(to: exit, ifZeroElseDecrement: %extraTrips )
626
+ // condBranch(to: exit, ifZeroElseDecrement: %maxExtraTrips )
627
627
// <eager: split(to: loop, saving: exit)>
628
628
// <possesive:
629
629
// clearSavePoint
630
630
// split(to: loop, saving: exit)>
631
631
// <reluctant: save(restoringAt: loop)
632
632
builder. label ( exitPolicy)
633
- switch extraTrips {
633
+ switch maxExtraTrips {
634
634
case nil : break
635
635
case 0 : builder. buildBranch ( to: exit)
636
636
default :
637
- assert ( extraTripsReg != nil , " logic inconsistency " )
637
+ assert ( maxExtraTripsReg != nil , " logic inconsistency " )
638
638
builder. buildCondBranch (
639
- to: exit, ifZeroElseDecrement: extraTripsReg !)
639
+ to: exit, ifZeroElseDecrement: maxExtraTripsReg !)
640
640
}
641
641
642
642
switch updatedKind {
@@ -666,12 +666,12 @@ fileprivate extension Compiler.ByteCodeGen {
666
666
_ child: DSLTree . Node ,
667
667
_ kind: AST . Quantification . Kind ,
668
668
_ minTrips: Int ,
669
- _ extraTrips : Int ?
669
+ _ maxExtraTrips : Int ?
670
670
) -> Bool {
671
671
let isScalarSemantics = options. semanticLevel == . unicodeScalar
672
672
guard optimizationsEnabled
673
673
&& minTrips <= QuantifyPayload . maxStorableTrips
674
- && extraTrips ?? 0 <= QuantifyPayload . maxStorableTrips
674
+ && maxExtraTrips ?? 0 <= QuantifyPayload . maxStorableTrips
675
675
&& kind != . reluctant else {
676
676
return false
677
677
}
@@ -681,7 +681,7 @@ fileprivate extension Compiler.ByteCodeGen {
681
681
guard let bitset = ccc. asAsciiBitset ( options) else {
682
682
return false
683
683
}
684
- builder. buildQuantify ( bitset: bitset, kind, minTrips, extraTrips , isScalarSemantics: isScalarSemantics)
684
+ builder. buildQuantify ( bitset: bitset, kind, minTrips, maxExtraTrips , isScalarSemantics: isScalarSemantics)
685
685
686
686
case . atom( let atom) :
687
687
switch atom {
@@ -690,17 +690,17 @@ fileprivate extension Compiler.ByteCodeGen {
690
690
guard let val = c. _singleScalarAsciiValue else {
691
691
return false
692
692
}
693
- builder. buildQuantify ( asciiChar: val, kind, minTrips, extraTrips , isScalarSemantics: isScalarSemantics)
693
+ builder. buildQuantify ( asciiChar: val, kind, minTrips, maxExtraTrips , isScalarSemantics: isScalarSemantics)
694
694
695
695
case . any:
696
696
builder. buildQuantifyAny (
697
- matchesNewlines: true , kind, minTrips, extraTrips , isScalarSemantics: isScalarSemantics)
697
+ matchesNewlines: true , kind, minTrips, maxExtraTrips , isScalarSemantics: isScalarSemantics)
698
698
case . anyNonNewline:
699
699
builder. buildQuantifyAny (
700
- matchesNewlines: false , kind, minTrips, extraTrips , isScalarSemantics: isScalarSemantics)
700
+ matchesNewlines: false , kind, minTrips, maxExtraTrips , isScalarSemantics: isScalarSemantics)
701
701
case . dot:
702
702
builder. buildQuantifyAny (
703
- matchesNewlines: options. dotMatchesNewline, kind, minTrips, extraTrips , isScalarSemantics: isScalarSemantics)
703
+ matchesNewlines: options. dotMatchesNewline, kind, minTrips, maxExtraTrips , isScalarSemantics: isScalarSemantics)
704
704
705
705
case . characterClass( let cc) :
706
706
// Custom character class that consumes a single grapheme
@@ -709,19 +709,19 @@ fileprivate extension Compiler.ByteCodeGen {
709
709
model: model,
710
710
kind,
711
711
minTrips,
712
- extraTrips ,
712
+ maxExtraTrips ,
713
713
isScalarSemantics: isScalarSemantics)
714
714
default :
715
715
return false
716
716
}
717
717
case . convertedRegexLiteral( let node, _) :
718
- return tryEmitFastQuant ( node, kind, minTrips, extraTrips )
718
+ return tryEmitFastQuant ( node, kind, minTrips, maxExtraTrips )
719
719
case . nonCapturingGroup( let groupKind, let node) :
720
720
// .nonCapture nonCapturingGroups are ignored during compilation
721
721
guard groupKind. ast == . nonCapture else {
722
722
return false
723
723
}
724
- return tryEmitFastQuant ( node, kind, minTrips, extraTrips )
724
+ return tryEmitFastQuant ( node, kind, minTrips, maxExtraTrips )
725
725
default :
726
726
return false
727
727
}
0 commit comments