Optimize Condition Resolution (#6279)

* Pack the bits for IfConfigDecls into Decl

* Don't open symbols into a module when evaluating canImport statements

The module loaders now have API to check whether a given module can be
imported without importing the referenced module.  This provides a
significant speed boost to condition resolution and no longer
introduces symbols from the referenced module into the current context
without the user explicitly requesting it.

The definition of ‘canImport’ does not necessarily mean that a full
import without error is possible, merely that the path to the import is
visible to the compiler and the module is loadable in some form or
another.

Note that this means this check is insufficient to guarantee that you
are on one platform or another.  For those kinds of checks, use
‘os(OSNAME)’.
This commit is contained in:
Robert Widmann
2017-01-05 12:08:54 -07:00
committed by GitHub
parent d5a55c4b90
commit dfa41d625b
16 changed files with 211 additions and 24 deletions

View File

@@ -74,6 +74,13 @@ protected:
public:
virtual ~ModuleLoader() = default;
/// \brief Check whether the module with a given name can be imported without
/// importing it.
///
/// Note that even if this check succeeds, errors may still occur if the
/// module is loaded in full.
virtual bool canImportModule(std::pair<Identifier, SourceLoc> named) = 0;
/// \brief Import a module with the given module path.
///
/// \param importLoc The location of the 'import' keyword.