#include <context.h>
Context storing compiler-wide state
◆ Context()
Context::Context |
( |
Options |
options | ) |
|
|
explicit |
- Parameters
-
options | options to use for code compilation |
◆ ~Context()
◆ cacheUnit()
void Context::cacheUnit |
( |
const std::shared_ptr< Unit > & |
unit | ) |
|
Caches a code unit inside the context. The cache uses a unit's (ID, path)
tuple as the index. Any previously cached unit with the same index tuple will be replaced.
- Parameters
-
- Returns
- the meta data associated with the newly registered module
◆ dumpUnitCache()
Dumps the current state of the unit cache to a debug stream.
- Parameters
-
stream | debug stream to write to |
◆ lookupDependenciesForUnit()
std::vector< std::weak_ptr< Unit > > Context::lookupDependenciesForUnit |
( |
const context::CacheIndex & |
idx, |
|
|
const hilti::rt::filesystem::path & |
extension |
|
) |
| |
Returns all (direct & indirect) dependencies that a module imports. This information will be complete only once all AST have been fully resolved.
- Parameters
-
idx | cache index for the module which to return dependencies for |
- Returns
- set of dependencies
◆ lookupUnit() [1/3]
std::optional< CacheEntry > Context::lookupUnit |
( |
const ID & |
id, |
|
|
const std::optional< ID > & |
scope, |
|
|
const hilti::rt::filesystem::path & |
extension |
|
) |
| |
Looks up a previously cached unit by its ID.
- Parameters
-
id | module ID look up a unit for |
scope | import-from scope associated with the import operation, if any |
extension | a file extension expected for the unit, indicating its source language; a cached unit will only be returned if its extension matches |
- Returns
- the cache entry associated with the path if found
◆ lookupUnit() [2/3]
std::optional< CacheEntry > Context::lookupUnit |
( |
const hilti::rt::filesystem::path & |
path, |
|
|
const std::optional< ID > & |
scope, |
|
|
std::optional< hilti::rt::filesystem::path > |
ast_extension = {} |
|
) |
| |
Looks up a previously cached unit by its path. It will only return a cached module if its extension matches that of the given path.
- Parameters
-
path | path to look up a unit for |
scope | import-from scope associated with the path being imported, if any |
- Returns
- the cache entry associated with the path if found
◆ lookupUnit() [3/3]
Looks up a previously cached unit using an existing cache index as the key.
- Parameters
-
idx | cache index to look up |
- Returns
- the cache entry associated with the path if found
◆ options()
const Options& hilti::Context::options |
( |
| ) |
const |
|
inline |
Returns the context's compiler options.
The documentation for this class was generated from the following files:
- /home/docs/checkouts/readthedocs.org/user_builds/spicy-docs/checkouts/v1.6.1/hilti/toolchain/include/compiler/context.h
- /home/docs/checkouts/readthedocs.org/user_builds/spicy-docs/checkouts/v1.6.1/hilti/toolchain/src/compiler/context.cc