Thread operator lookup through Module to ModuleLoader...

...even though Swift modules don't provide this lookup yet, and Clang
modules never will.

Swift SVN r5173
This commit is contained in:
Jordan Rose
2013-05-16 00:23:10 +00:00
parent 803aa24b3e
commit ec1e47cbf0
4 changed files with 65 additions and 2 deletions

View File

@@ -35,6 +35,7 @@ namespace swift {
class BraceStmt;
class Component;
class Decl;
enum class DeclKind : uint8_t;
class ExtensionDecl;
class IdentifierType;
class InfixOperatorDecl;
@@ -316,6 +317,19 @@ public:
// Inherited from Module.
ArrayRef<ExtensionDecl*> lookupExtensions(Type T);
/// Look up an operator declaration.
///
/// \param name The operator name ("+", ">>", etc.)
///
/// \param fixity One of PrefixOperator, InfixOperator, or PostfixOperator.
OperatorDecl *lookupOperator(Identifier name, DeclKind fixity);
/// Look up an operator declaration.
template <typename T>
T *lookupOperator(Identifier name) {
static_assert((T*){}, "Must specify prefix, postfix, or infix operator");
}
static bool classof(const DeclContext *DC) {
return DC->getContextKind() >= DeclContextKind::First_LoadedModule &&
DC->getContextKind() <= DeclContextKind::Last_LoadedModule;
@@ -341,6 +355,18 @@ public:
}
};
template <>
PrefixOperatorDecl *
LoadedModule::lookupOperator<PrefixOperatorDecl>(Identifier name);
template <>
PostfixOperatorDecl *
LoadedModule::lookupOperator<PostfixOperatorDecl>(Identifier name);
template <>
InfixOperatorDecl *
LoadedModule::lookupOperator<InfixOperatorDecl>(Identifier name);
} // end namespace swift