Add a :print_module directive to the REPL.

This is basically the same as doing a :print_decl on every decl in the module,
except that it does not print extensions that come from other modules, and
/does/ print extensions and operators that come from this module.

Does not yet work for Clang modules or the Builtin module.

Swift SVN r7601
This commit is contained in:
Jordan Rose
2013-08-26 23:07:51 +00:00
parent 803f5dc551
commit eef39ff914
8 changed files with 114 additions and 1 deletions

View File

@@ -344,6 +344,23 @@ void Module::lookupClassMember(AccessPathTy accessPath,
return owner.lookupClassMember(this, accessPath, name, results);
}
void Module::getDisplayDecls(SmallVectorImpl<Decl*> &results) {
if (isa<BuiltinModule>(this)) {
// FIXME: The Builtin module isn't usually visible, but it would be nice
// to have the option to display its decls. Unfortunately those decls are
// lazily generated.
return;
}
if (auto TU = dyn_cast<TranslationUnit>(this)) {
results.append(TU->Decls.begin(), TU->Decls.end());
return;
}
ModuleLoader &owner = cast<LoadedModule>(this)->getOwner();
return owner.getDisplayDecls(this, results);
}
namespace {
// Returns Nothing on error, Optional(nullptr) if no operator decl found, or
// Optional(decl) if decl was found.