Skip to content

Commit da30258

Browse files
committed
RequirementMachine: Remove RewriteSystem::TypeWitness
1 parent bdbf50e commit da30258

File tree

2 files changed

+0
-114
lines changed

2 files changed

+0
-114
lines changed

lib/AST/RequirementMachine/PropertyRelations.cpp

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -143,55 +143,4 @@ unsigned RewriteSystem::recordSameTypeWitnessRelation(
143143
return recordRelation(
144144
Term::get(lhsTerm, Context),
145145
Term::get(rhsTerm, Context));
146-
}
147-
148-
RewriteSystem::TypeWitness::TypeWitness(
149-
Term lhs, llvm::PointerUnion<Symbol, Term> rhs)
150-
: LHS(lhs), RHS(rhs) {
151-
assert(LHS.size() >= 2);
152-
assert(getConcreteConformance().getKind() ==
153-
Symbol::Kind::ConcreteConformance);
154-
assert(getAssocType().getKind() == Symbol::Kind::AssociatedType);
155-
if (RHS.is<Symbol>())
156-
assert(RHS.get<Symbol>().getKind() == Symbol::Kind::ConcreteType);
157-
assert(getAssocType().getProtocols().size() == 1);
158-
assert(getAssocType().getProtocols()[0] ==
159-
getConcreteConformance().getProtocol());
160-
}
161-
162-
namespace swift {
163-
namespace rewriting {
164-
bool operator==(const RewriteSystem::TypeWitness &lhs,
165-
const RewriteSystem::TypeWitness &rhs) {
166-
return lhs.LHS == rhs.LHS && lhs.RHS == rhs.RHS;
167-
}
168-
}
169-
}
170-
171-
void RewriteSystem::TypeWitness::dump(llvm::raw_ostream &out) const {
172-
out << "Subject type: " << LHS << "\n";
173-
if (RHS.is<Symbol>())
174-
out << "Concrete type witness: " << RHS.get<Symbol>() << "\n";
175-
else
176-
out << "Abstract type witness: " << RHS.get<Term>() << "\n";
177-
}
178-
179-
unsigned RewriteSystem::recordTypeWitness(
180-
RewriteSystem::TypeWitness witness) {
181-
unsigned index = TypeWitnesses.size();
182-
auto inserted = TypeWitnessMap.insert(std::make_pair(witness.LHS, index));
183-
184-
if (!inserted.second) {
185-
index = inserted.first->second;
186-
} else {
187-
TypeWitnesses.push_back(witness);
188-
}
189-
190-
assert(TypeWitnesses[index] == witness);
191-
return index;
192-
}
193-
194-
const RewriteSystem::TypeWitness &
195-
RewriteSystem::getTypeWitness(unsigned index) const {
196-
return TypeWitnesses[index];
197146
}

lib/AST/RequirementMachine/RewriteSystem.h

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -360,69 +360,6 @@ class RewriteSystem final {
360360
Symbol concreteConformanceSymbol,
361361
Symbol associatedTypeSymbol);
362362

363-
/// A type witness has a subject type, stored in LHS, which takes the form:
364-
///
365-
/// T.[concrete: C : P].[P:X]
366-
///
367-
/// For some concrete type C, protocol P and associated type X.
368-
///
369-
/// The type witness of X in the conformance C : P is either a concrete type,
370-
/// or an abstract type parameter.
371-
///
372-
/// If it is a concrete type, then RHS stores the concrete type symbol.
373-
///
374-
/// If it is an abstract type parameter, then RHS stores the type term.
375-
///
376-
/// Think of these as rewrite rules which are lazily created, but always
377-
/// "there" -- they encode information about concrete conformances, which
378-
/// are solved outside of the requirement machine itself.
379-
///
380-
/// We don't want to eagerly pull in all concrete conformances and walk
381-
/// them recursively introducing rewrite rules.
382-
///
383-
/// The RewriteStep::{Concrete,Same,Abstract}TypeWitness rewrite step kinds
384-
/// reference TypeWitnesses via their RuleID field.
385-
///
386-
/// Type witnesses are recorded lazily in property map construction, in
387-
/// PropertyMap::computeConstraintTermForTypeWitness().
388-
struct TypeWitness {
389-
Term LHS;
390-
llvm::PointerUnion<Symbol, Term> RHS;
391-
392-
TypeWitness(Term lhs, llvm::PointerUnion<Symbol, Term> rhs);
393-
394-
friend bool operator==(const TypeWitness &lhs,
395-
const TypeWitness &rhs);
396-
397-
Symbol getConcreteConformance() const {
398-
return *(LHS.end() - 2);
399-
}
400-
401-
Symbol getAssocType() const {
402-
return *(LHS.end() - 1);
403-
}
404-
405-
Symbol getConcreteType() const {
406-
return RHS.get<Symbol>();
407-
}
408-
409-
Term getAbstractType() const {
410-
return RHS.get<Term>();
411-
}
412-
413-
void dump(llvm::raw_ostream &out) const;
414-
};
415-
416-
private:
417-
/// Cache for concrete type witnesses. The value in the map is an index
418-
/// into the vector.
419-
llvm::DenseMap<Term, unsigned> TypeWitnessMap;
420-
std::vector<TypeWitness> TypeWitnesses;
421-
422-
public:
423-
unsigned recordTypeWitness(TypeWitness witness);
424-
const TypeWitness &getTypeWitness(unsigned index) const;
425-
426363
private:
427364
//////////////////////////////////////////////////////////////////////////////
428365
///

0 commit comments

Comments
 (0)