Files
swift-mirror/include/swift/AST/LazyResolver.h
Jordan Rose c2b00fc2d4 Excise the global TranslationUnit from TypeChecker.
Now that TypeChecker is being used to check all sorts of things (not all
from a single TU), it's not really correct to have a single top-level TU
that gets used everywhere. Instead, we should be using the TU that's
appropriate for whatever's being checked. This is a small correctness win
for order-independent type-checking, but is critical for multi-file
translation units, which is needed for implicit visibility.

This basically involves passing around DeclContexts much more.

Caveat: we aren't smart about, say, filtering extensions based on the
current context, so we're still not 100% correct here.

Swift SVN r9006
2013-10-07 23:47:55 +00:00

79 lines
2.7 KiB
C++

//===--- LazyResolver.h - Lazy Resolution for ASTs --------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This file defines the LazyResolver abstract interface.
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_AST_LAZYRESOLVER_H
#define SWIFT_AST_LAZYRESOLVER_H
#include "swift/Basic/Optional.h"
namespace swift {
class DeclContext;
class ExtensionDecl;
class Identifier;
class NominalTypeDecl;
class ProtocolConformance;
class ProtocolDecl;
class Type;
class ValueDecl;
/// Abstract interface used to lazily resolve aspects of the AST, such as the
/// types of declarations or protocol conformance structures.
class LazyResolver {
public:
virtual ~LazyResolver();
/// Resolve the conformance of the given nominal type to the given protocol.
///
/// \param type The nominal type that conforms to the given protocol.
////
/// \param protocol The protocol to which the type conforms.
///
/// \param ext If the conforms occurs via an extension, the extension
/// declaration.
///
/// \returns the protocol conformance, or null if the type does not conform
/// to the protocol.
virtual ProtocolConformance *resolveConformance(NominalTypeDecl *type,
ProtocolDecl *protocol,
ExtensionDecl *ext) = 0;
/// Resolve the "existential conforms to itself" bit for the given protocol.
virtual void resolveExistentialConformsToItself(ProtocolDecl *proto) = 0;
/// Resolve a member type.
///
/// \param dc The context in which to resolve the type.
/// \param type The type in which we will search for the member type.
/// \param name The name of the member type.
///
/// \returns the member type, or an empty type if no such type could be
/// found.
virtual Type resolveMemberType(DeclContext *dc, Type type,
Identifier name) = 0;
/// Resolve the type and declaration attributes of a value.
///
/// This can be called when the type or signature of a value is needed.
/// It does not perform full type-checking, only checks for basic
/// consistency and provides the value a type.
virtual void resolveDeclSignature(ValueDecl *VD) = 0;
};
}
#endif // LLVM_SWIFT_AST_LAZYRESOLVER_H