Implement changes to parsing/sema/etc so that we can implement a REPL and the main module parses the same way as a REPL.

Next step: implement an actual REPL.



Swift SVN r1441
This commit is contained in:
Eli Friedman
2012-04-16 23:52:01 +00:00
parent fe8ab72db6
commit 37de44a35d
16 changed files with 305 additions and 108 deletions

View File

@@ -113,6 +113,11 @@ static TUModuleCache &getTUCachePimpl(void *&Ptr, TranslationUnit &TU) {
return *(TUModuleCache*)Ptr;
}
static void freeTUCachePimpl(void *&Ptr) {
delete (TUModuleCache*)Ptr;
Ptr = 0;
}
/// Populate our cache on the first name lookup.
TUModuleCache::TUModuleCache(TranslationUnit &TU) {
@@ -191,6 +196,11 @@ static TUExtensionCache &getTUExtensionCachePimpl(void *&Ptr,
return *(TUExtensionCache*)Ptr;
}
static void freeTUExtensionCachePimpl(void *&Ptr) {
delete (TUExtensionCache*)Ptr;
Ptr = 0;
}
TUExtensionCache::TUExtensionCache(TranslationUnit &TU) {
for (auto Elt : TU.Body->getElements()) {
if (Decl *D = Elt.dyn_cast<Decl*>()) {
@@ -347,3 +357,11 @@ void Module::lookupGlobalExtensionMethods(Type BaseType, Identifier Name,
}
}
//===----------------------------------------------------------------------===//
// TranslationUnit Implementation
//===----------------------------------------------------------------------===//
void TranslationUnit::clearLookupCache() {
freeTUCachePimpl(LookupCachePimpl);
freeTUExtensionCachePimpl(ExtensionCachePimpl);
}