On second thought, components need to be known in the AST.

Swift SVN r918
This commit is contained in:
John McCall
2011-12-07 03:57:41 +00:00
parent a1b7419a36
commit 6b935588e5
9 changed files with 36 additions and 25 deletions

View File

@@ -25,6 +25,7 @@
namespace swift {
class ASTContext;
class BraceStmt;
class Component;
class ExtensionDecl;
class OneOfElementDecl;
class NameAliasType;
@@ -45,6 +46,7 @@ namespace swift {
class Module : public DeclContext {
void *LookupCachePimpl;
void *ExtensionCachePimpl;
Component *Comp;
public:
ASTContext &Ctx;
Identifier Name;
@@ -68,14 +70,20 @@ public:
} ASTStage;
protected:
Module(DeclContextKind Kind, Identifier Name, ASTContext &Ctx)
Module(DeclContextKind Kind, Identifier Name, Component *C, ASTContext &Ctx)
: DeclContext(Kind, nullptr), LookupCachePimpl(0), ExtensionCachePimpl(0),
Ctx(Ctx), Name(Name), ASTStage(Parsing) {
Comp(C), Ctx(Ctx), Name(Name), ASTStage(Parsing) {
assert(Comp != nullptr || Kind == DeclContextKind::BuiltinModule);
}
public:
typedef ArrayRef<std::pair<Identifier, SourceLoc>> AccessPathTy;
Component *getComponent() const {
assert(Comp && "fetching component for the builtin module");
return Comp;
}
/// lookupType - Look up a type at top-level scope (but with the specified
/// access path, which may come from an import decl) within the current
/// module. This does a simple local lookup, not recursively looking through
@@ -155,8 +163,8 @@ public:
/// expressions and declarations for a translation unit.
BraceStmt *Body;
TranslationUnit(Identifier Name, ASTContext &C)
: Module(DeclContextKind::TranslationUnit, Name, C) {
TranslationUnit(Identifier Name, Component *Comp, ASTContext &C)
: Module(DeclContextKind::TranslationUnit, Name, Comp, C) {
}
ArrayRef<TypeAliasDecl*> getUnresolvedTypes() const {
@@ -209,7 +217,7 @@ public:
class BuiltinModule : public Module {
public:
BuiltinModule(Identifier Name, ASTContext &Ctx)
: Module(DeclContextKind::BuiltinModule, Name, Ctx) {
: Module(DeclContextKind::BuiltinModule, Name, nullptr, Ctx) {
// The Builtin module is always well formed.
ASTStage = TypeChecked;
}