Skip to content

RequirementMachine: The great renaming #38611

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 24, 2021
Merged
7 changes: 5 additions & 2 deletions include/swift/AST/ASTContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ namespace swift {
class TupleTypeElt;
class EnumElementDecl;
class ProtocolDecl;
class RequirementMachine;
class SubstitutableType;
class SourceManager;
class ValueDecl;
Expand All @@ -135,6 +134,10 @@ namespace namelookup {
class ImportCache;
}

namespace rewriting {
class RequirementMachine;
}

namespace syntax {
class SyntaxArena;
}
Expand Down Expand Up @@ -1160,7 +1163,7 @@ class ASTContext final {

/// Retrieve or create a term rewriting system for answering queries on
/// type parameters written against the given generic signature.
RequirementMachine *getOrCreateRequirementMachine(
rewriting::RequirementMachine *getOrCreateRequirementMachine(
CanGenericSignature sig);

/// Retrieve a generic signature with a single unconstrained type parameter,
Expand Down
9 changes: 6 additions & 3 deletions include/swift/AST/GenericSignature.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@ namespace swift {
class GenericSignatureBuilder;
class ProtocolConformanceRef;
class ProtocolType;
class RequirementMachine;
class SubstitutionMap;
class GenericEnvironment;

namespace rewriting {
class RequirementMachine;
}

/// An access path used to find a particular protocol conformance within
/// a generic signature.
///
Expand Down Expand Up @@ -82,7 +85,7 @@ class ConformanceAccessPath {

friend class GenericSignatureImpl;
friend class GenericSignatureBuilder;
friend class RequirementMachine;
friend class rewriting::RequirementMachine;

public:
typedef const Entry *const_iterator;
Expand Down Expand Up @@ -320,7 +323,7 @@ class alignas(1 << TypeAlignInBits) GenericSignatureImpl final
GenericSignatureBuilder *getGenericSignatureBuilder() const;

/// Retrieve the requirement machine for the given generic signature.
RequirementMachine *getRequirementMachine() const;
rewriting::RequirementMachine *getRequirementMachine() const;

/// Collects a set of requirements on a type parameter. Used by
/// GenericEnvironment for building archetypes.
Expand Down
11 changes: 6 additions & 5 deletions lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
#include "swift/AST/PropertyWrappers.h"
#include "swift/AST/ProtocolConformance.h"
#include "swift/AST/RawComment.h"
#include "swift/AST/RequirementMachine.h"
#include "swift/AST/SILLayout.h"
#include "swift/AST/SemanticAttrs.h"
#include "swift/AST/SourceFile.h"
Expand All @@ -67,6 +66,7 @@
#include <algorithm>
#include <memory>

#include "RequirementMachine/RequirementMachine.h"
#include "RequirementMachine/RewriteContext.h"

using namespace swift;
Expand Down Expand Up @@ -420,7 +420,8 @@ struct ASTContext::Implementation {
GenericSignatureBuilders;

/// Stored requirement machines for canonical generic signatures.
llvm::DenseMap<GenericSignature, std::unique_ptr<RequirementMachine>>
llvm::DenseMap<GenericSignature,
std::unique_ptr<rewriting::RequirementMachine>>
RequirementMachines;

/// The set of function types.
Expand Down Expand Up @@ -1892,8 +1893,8 @@ GenericSignatureBuilder *ASTContext::getOrCreateGenericSignatureBuilder(
return builder;
}

RequirementMachine *ASTContext::getOrCreateRequirementMachine(
CanGenericSignature sig) {
rewriting::RequirementMachine *
ASTContext::getOrCreateRequirementMachine(CanGenericSignature sig) {
assert(!sig.hasTypeVariable());

auto &rewriteCtx = getImpl().TheRewriteContext;
Expand All @@ -1917,7 +1918,7 @@ RequirementMachine *ASTContext::getOrCreateRequirementMachine(
return machine;
}

auto *machine = new RequirementMachine(*rewriteCtx);
auto *machine = new rewriting::RequirementMachine(*rewriteCtx);

// Store this requirement machine before adding the signature,
// to catch re-entrant construction via addGenericSignature()
Expand Down
2 changes: 1 addition & 1 deletion lib/AST/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ add_swift_host_library(swiftAST STATIC
ProtocolConformance.cpp
RawComment.cpp
RequirementEnvironment.cpp
RequirementMachine/EquivalenceClassMap.cpp
RequirementMachine/GenericSignatureQueries.cpp
RequirementMachine/PropertyMap.cpp
RequirementMachine/ProtocolGraph.cpp
RequirementMachine/RequirementMachine.cpp
RequirementMachine/RewriteContext.cpp
Expand Down
4 changes: 2 additions & 2 deletions lib/AST/GenericSignature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
#include "swift/AST/GenericEnvironment.h"
#include "swift/AST/Module.h"
#include "swift/AST/PrettyStackTrace.h"
#include "swift/AST/RequirementMachine.h"
#include "swift/AST/Types.h"
#include "swift/Basic/STLExtras.h"
#include "RequirementMachine/RequirementMachine.h"
#include <functional>

using namespace swift;
Expand Down Expand Up @@ -191,7 +191,7 @@ GenericSignatureImpl::getGenericSignatureBuilder() const {
CanGenericSignature(this));
}

RequirementMachine *
rewriting::RequirementMachine *
GenericSignatureImpl::getRequirementMachine() const {
// The requirement machine is associated with the canonical signature.
if (!isCanonical())
Expand Down
Loading