@@ -366,12 +366,11 @@ void PropertyMap::addSuperclassProperty(
366366
367367// / Given a rule (V.[LHS] => V) and a rewrite path (T.[RHS] => T) where
368368// / T == U.V, build a rewrite path from T.[RHS] to T.[LHS].
369- static void buildRewritePathForUnifier (Term key,
370- unsigned lhsRuleID,
371- const RewritePath &rhsPath,
372- const RewriteSystem &system,
373- RewritePath *path) {
374- unsigned lhsLength = system.getRule (lhsRuleID).getRHS ().size ();
369+ void RewriteSystem::buildRewritePathForUnifier (Term key,
370+ unsigned lhsRuleID,
371+ const RewritePath &rhsPath,
372+ RewritePath *path) const {
373+ unsigned lhsLength = getRule (lhsRuleID).getRHS ().size ();
375374 unsigned lhsPrefix = key.size () - lhsLength;
376375
377376 path->append (rhsPath);
@@ -452,7 +451,7 @@ static void buildRewritePathForInducedRule(Term key,
452451 path->add (RewriteStep::forRightConcreteProjection (
453452 differenceID, substitutionIndex, /* inverse=*/ false ));
454453
455- buildRewritePathForUnifier (key, lhsRuleID, rhsPath, system , path);
454+ system. buildRewritePathForUnifier (key, lhsRuleID, rhsPath, path);
456455
457456 // Pop T.[LHS] from the stack, leaving behind Xn.
458457 path->add (RewriteStep::forLeftConcreteProjection (
@@ -461,14 +460,13 @@ static void buildRewritePathForInducedRule(Term key,
461460
462461// / Given that LHS and RHS are known to simplify to the same term, build a
463462// / rewrite path from RHS to LHS.
464- static void buildPathJoiningTerms (MutableTerm lhsTerm,
465- MutableTerm rhsTerm,
466- RewriteSystem &system,
467- RewritePath *path) {
468- (void ) system.simplify (rhsTerm, path);
463+ void RewriteSystem::buildRewritePathForJoiningTerms (MutableTerm lhsTerm,
464+ MutableTerm rhsTerm,
465+ RewritePath *path) const {
466+ (void ) simplify (rhsTerm, path);
469467
470468 RewritePath lhsPath;
471- (void ) system. simplify (lhsTerm, &lhsPath);
469+ (void ) simplify (lhsTerm, &lhsPath);
472470 lhsPath.invert ();
473471
474472 path->append (lhsPath);
@@ -487,10 +485,10 @@ static void buildPathJoiningTerms(MutableTerm lhsTerm,
487485// /
488486// / Finally, builds a rewrite loop relating the two concrete type rules
489487// / via the induced rules.
490- void PropertyMap ::processTypeDifference (const TypeDifference &difference,
491- unsigned differenceID,
492- unsigned lhsRuleID,
493- const RewritePath &rhsPath) {
488+ void RewriteSystem ::processTypeDifference (const TypeDifference &difference,
489+ unsigned differenceID,
490+ unsigned lhsRuleID,
491+ const RewritePath &rhsPath) {
494492 bool debug = Debug.contains (DebugFlags::ConcreteUnification);
495493
496494 if (debug) {
@@ -521,17 +519,17 @@ void PropertyMap::processTypeDifference(const TypeDifference &difference,
521519 RewritePath inducedRulePath;
522520 buildRewritePathForInducedRule (difference.BaseTerm , differenceID,
523521 lhsRuleID, rhsPath, index,
524- System , &inducedRulePath);
522+ * this , &inducedRulePath);
525523
526524 if (debug) {
527525 llvm::dbgs () << " %% Induced rule " << lhsTerm
528526 << " => " << rhsTerm << " with path " ;
529- inducedRulePath.dump (llvm::dbgs (), lhsTerm, System );
527+ inducedRulePath.dump (llvm::dbgs (), lhsTerm, * this );
530528 llvm::dbgs () << " \n " ;
531529 }
532530
533- System. addRule (lhsTerm, rhsTerm, &inducedRulePath);
534- buildPathJoiningTerms (lhsTerm, rhsTerm, System , &unificationPath);
531+ addRule (lhsTerm, rhsTerm, &inducedRulePath);
532+ buildRewritePathForJoiningTerms (lhsTerm, rhsTerm, &unificationPath);
535533 }
536534
537535 // All simplified substitutions are now on the primary stack. Collect them to
@@ -543,17 +541,17 @@ void PropertyMap::processTypeDifference(const TypeDifference &difference,
543541 // newly-recorded induced rules. Close the loop with a path from
544542 // T.[RHS] to R.[LHS] via the concrete type rules being unified.
545543 buildRewritePathForUnifier (difference.BaseTerm , lhsRuleID, rhsPath,
546- System, &unificationPath);
544+ &unificationPath);
547545
548546 // Record a rewrite loop at T.[LHS].
549547 MutableTerm basepoint (difference.BaseTerm );
550548 basepoint.add (difference.LHS );
551- System. recordRewriteLoop (basepoint, unificationPath);
549+ recordRewriteLoop (basepoint, unificationPath);
552550
553551 // Optimization: If the LHS rule applies to the entire base term and not
554552 // a suffix, mark it substitution-simplified so that we can skip recording
555553 // the same rewrite loop in concretelySimplifyLeftHandSideSubstitutions().
556- auto &lhsRule = System. getRule (lhsRuleID);
554+ auto &lhsRule = getRule (lhsRuleID);
557555 if (lhsRule.getRHS () == difference.BaseTerm )
558556 lhsRule.markSubstitutionSimplified ();
559557}
@@ -629,15 +627,15 @@ void PropertyMap::unifyConcreteTypes(
629627
630628 // Recover a rewrite path from T to T.[LHS ∧ RHS].
631629 RewritePath path;
632- buildPathJoiningTerms (rhsTerm, lhsTerm, System , &path);
630+ System. buildRewritePathForJoiningTerms (rhsTerm, lhsTerm, &path);
633631
634632 // Process LHS -> (LHS ∧ RHS).
635- processTypeDifference (lhsDifference, *lhsDifferenceID,
636- *existingRuleID, path);
633+ System. processTypeDifference (lhsDifference, *lhsDifferenceID,
634+ *existingRuleID, path);
637635
638636 // Process RHS -> (LHS ∧ RHS).
639- processTypeDifference (rhsDifference, *rhsDifferenceID,
640- ruleID, path);
637+ System. processTypeDifference (rhsDifference, *rhsDifferenceID,
638+ ruleID, path);
641639 }
642640
643641 // The new property is more specific, so update ConcreteType and
@@ -663,8 +661,8 @@ void PropertyMap::unifyConcreteTypes(
663661 /* startOffset=*/ 0 , /* endOffset=*/ 0 ,
664662 /* ruleID=*/ ruleID, /* inverse=*/ false ));
665663
666- processTypeDifference (lhsDifference, *lhsDifferenceID,
667- *existingRuleID, path);
664+ System. processTypeDifference (lhsDifference, *lhsDifferenceID,
665+ *existingRuleID, path);
668666 }
669667
670668 // The new property is more specific, so update existingProperty and
@@ -698,8 +696,8 @@ void PropertyMap::unifyConcreteTypes(
698696 /* startOffset=*/ prefix, /* endOffset=*/ 0 ,
699697 /* ruleID=*/ *existingRuleID, /* inverse=*/ false ));
700698
701- processTypeDifference (rhsDifference, *rhsDifferenceID,
702- ruleID, path);
699+ System. processTypeDifference (rhsDifference, *rhsDifferenceID,
700+ ruleID, path);
703701 }
704702
705703 // The new property is less specific, so existingProperty and existingRuleID
@@ -730,7 +728,7 @@ void PropertyMap::unifyConcreteTypes(
730728 /* ruleID=*/ ruleID, /* inverse=*/ false ));
731729
732730 RewritePath path;
733- buildRewritePathForUnifier (key, *existingRuleID, rhsPath, System , &path);
731+ System. buildRewritePathForUnifier (key, *existingRuleID, rhsPath, &path);
734732 System.recordRewriteLoop (MutableTerm (rule.getLHS ()), path);
735733
736734 rule.markSubstitutionSimplified ();
0 commit comments