@@ -459,16 +459,16 @@ fileprivate extension Compiler.ByteCodeGen {
459459 assert ( high != 0 )
460460 assert ( ( 0 ... ( high ?? Int . max) ) . contains ( low) )
461461
462- let extraTrips : Int ?
462+ let maxExtraTrips : Int ?
463463 if let h = high {
464- extraTrips = h - low
464+ maxExtraTrips = h - low
465465 } else {
466- extraTrips = nil
466+ maxExtraTrips = nil
467467 }
468468 let minTrips = low
469- assert ( ( extraTrips ?? 1 ) >= 0 )
469+ assert ( ( maxExtraTrips ?? 1 ) >= 0 )
470470
471- if tryEmitFastQuant ( child, updatedKind, minTrips, extraTrips ) {
471+ if tryEmitFastQuant ( child, updatedKind, minTrips, maxExtraTrips ) {
472472 return
473473 }
474474
@@ -486,19 +486,19 @@ fileprivate extension Compiler.ByteCodeGen {
486486 decrement %minTrips and fallthrough
487487
488488 loop-body:
489- <if can't guarantee forward progress && extraTrips = nil>:
489+ <if can't guarantee forward progress && maxExtraTrips = nil>:
490490 mov currentPosition %pos
491491 evaluate the subexpression
492- <if can't guarantee forward progress && extraTrips = nil>:
492+ <if can't guarantee forward progress && maxExtraTrips = nil>:
493493 if %pos is currentPosition:
494494 goto exit
495495 goto min-trip-count control block
496496
497497 exit-policy control block:
498- if %extraTrips is zero:
498+ if %maxExtraTrips is zero:
499499 goto exit
500500 else:
501- decrement %extraTrips and fallthrough
501+ decrement %maxExtraTrips and fallthrough
502502
503503 <if eager>:
504504 save exit and goto loop-body
@@ -525,12 +525,12 @@ fileprivate extension Compiler.ByteCodeGen {
525525 /* fallthrough */
526526 """
527527
528- // Specialization based on `extraTrips ` for 0 or unbounded
528+ // Specialization based on `maxExtraTrips ` for 0 or unbounded
529529 _ = """
530530 exit-policy control block:
531- <if extraTrips == 0>:
531+ <if maxExtraTrips == 0>:
532532 goto exit
533- <if extraTrips == .unbounded>:
533+ <if maxExtraTrips == .unbounded>:
534534 /* fallthrough */
535535 """
536536
@@ -563,12 +563,12 @@ fileprivate extension Compiler.ByteCodeGen {
563563 minTripsReg = nil
564564 }
565565
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 !)
570570 } else {
571- extraTripsReg = nil
571+ maxExtraTripsReg = nil
572572 }
573573
574574 // Set up a dummy save point for possessive to update
@@ -600,7 +600,7 @@ fileprivate extension Compiler.ByteCodeGen {
600600 let startPosition : PositionRegister ?
601601 let emitPositionChecking =
602602 ( !optimizationsEnabled || !child. guaranteesForwardProgress) &&
603- extraTrips == nil
603+ maxExtraTrips == nil
604604
605605 if emitPositionChecking {
606606 startPosition = builder. makePositionRegister ( )
@@ -610,7 +610,7 @@ fileprivate extension Compiler.ByteCodeGen {
610610 }
611611 try emitNode ( child)
612612 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,
614614 // if we have a successful non-advancing match, branch to exit because it
615615 // can match an arbitrary number of times
616616 builder. buildCondBranch ( to: exit, ifSamePositionAs: startPosition!)
@@ -623,20 +623,20 @@ fileprivate extension Compiler.ByteCodeGen {
623623 }
624624
625625 // exit-policy:
626- // condBranch(to: exit, ifZeroElseDecrement: %extraTrips )
626+ // condBranch(to: exit, ifZeroElseDecrement: %maxExtraTrips )
627627 // <eager: split(to: loop, saving: exit)>
628628 // <possesive:
629629 // clearSavePoint
630630 // split(to: loop, saving: exit)>
631631 // <reluctant: save(restoringAt: loop)
632632 builder. label ( exitPolicy)
633- switch extraTrips {
633+ switch maxExtraTrips {
634634 case nil : break
635635 case 0 : builder. buildBranch ( to: exit)
636636 default :
637- assert ( extraTripsReg != nil , " logic inconsistency " )
637+ assert ( maxExtraTripsReg != nil , " logic inconsistency " )
638638 builder. buildCondBranch (
639- to: exit, ifZeroElseDecrement: extraTripsReg !)
639+ to: exit, ifZeroElseDecrement: maxExtraTripsReg !)
640640 }
641641
642642 switch updatedKind {
@@ -666,12 +666,12 @@ fileprivate extension Compiler.ByteCodeGen {
666666 _ child: DSLTree . Node ,
667667 _ kind: AST . Quantification . Kind ,
668668 _ minTrips: Int ,
669- _ extraTrips : Int ?
669+ _ maxExtraTrips : Int ?
670670 ) -> Bool {
671671 let isScalarSemantics = options. semanticLevel == . unicodeScalar
672672 guard optimizationsEnabled
673673 && minTrips <= QuantifyPayload . maxStorableTrips
674- && extraTrips ?? 0 <= QuantifyPayload . maxStorableTrips
674+ && maxExtraTrips ?? 0 <= QuantifyPayload . maxStorableTrips
675675 && kind != . reluctant else {
676676 return false
677677 }
@@ -681,7 +681,7 @@ fileprivate extension Compiler.ByteCodeGen {
681681 guard let bitset = ccc. asAsciiBitset ( options) else {
682682 return false
683683 }
684- builder. buildQuantify ( bitset: bitset, kind, minTrips, extraTrips , isScalarSemantics: isScalarSemantics)
684+ builder. buildQuantify ( bitset: bitset, kind, minTrips, maxExtraTrips , isScalarSemantics: isScalarSemantics)
685685
686686 case . atom( let atom) :
687687 switch atom {
@@ -690,17 +690,17 @@ fileprivate extension Compiler.ByteCodeGen {
690690 guard let val = c. _singleScalarAsciiValue else {
691691 return false
692692 }
693- builder. buildQuantify ( asciiChar: val, kind, minTrips, extraTrips , isScalarSemantics: isScalarSemantics)
693+ builder. buildQuantify ( asciiChar: val, kind, minTrips, maxExtraTrips , isScalarSemantics: isScalarSemantics)
694694
695695 case . any:
696696 builder. buildQuantifyAny (
697- matchesNewlines: true , kind, minTrips, extraTrips , isScalarSemantics: isScalarSemantics)
697+ matchesNewlines: true , kind, minTrips, maxExtraTrips , isScalarSemantics: isScalarSemantics)
698698 case . anyNonNewline:
699699 builder. buildQuantifyAny (
700- matchesNewlines: false , kind, minTrips, extraTrips , isScalarSemantics: isScalarSemantics)
700+ matchesNewlines: false , kind, minTrips, maxExtraTrips , isScalarSemantics: isScalarSemantics)
701701 case . dot:
702702 builder. buildQuantifyAny (
703- matchesNewlines: options. dotMatchesNewline, kind, minTrips, extraTrips , isScalarSemantics: isScalarSemantics)
703+ matchesNewlines: options. dotMatchesNewline, kind, minTrips, maxExtraTrips , isScalarSemantics: isScalarSemantics)
704704
705705 case . characterClass( let cc) :
706706 // Custom character class that consumes a single grapheme
@@ -709,19 +709,19 @@ fileprivate extension Compiler.ByteCodeGen {
709709 model: model,
710710 kind,
711711 minTrips,
712- extraTrips ,
712+ maxExtraTrips ,
713713 isScalarSemantics: isScalarSemantics)
714714 default :
715715 return false
716716 }
717717 case . convertedRegexLiteral( let node, _) :
718- return tryEmitFastQuant ( node, kind, minTrips, extraTrips )
718+ return tryEmitFastQuant ( node, kind, minTrips, maxExtraTrips )
719719 case . nonCapturingGroup( let groupKind, let node) :
720720 // .nonCapture nonCapturingGroups are ignored during compilation
721721 guard groupKind. ast == . nonCapture else {
722722 return false
723723 }
724- return tryEmitFastQuant ( node, kind, minTrips, extraTrips )
724+ return tryEmitFastQuant ( node, kind, minTrips, maxExtraTrips )
725725 default :
726726 return false
727727 }
0 commit comments