Spicy
Public Member Functions | List of all members
hilti::Context Class Reference

#include <context.h>

Public Member Functions

 Context (Options options)
 
 ~Context ()
 
const Optionsoptions () const
 
const context::CachedModuleregisterModule (const context::ModuleIndex &idx, Node &&module, bool requires_compilation)
 
void updateModule (const context::CachedModule &module)
 
std::optional< context::CachedModulelookupModule (const ID &id)
 
std::optional< context::CachedModulelookupModule (const hilti::rt::filesystem::path &path)
 
std::vector< context::CachedModulelookupDependenciesForModule (const ID &id)
 

Detailed Description

Context storing compiler-wide state

Constructor & Destructor Documentation

◆ Context()

Context::Context ( Options  options)
explicit
Parameters
optionsoptions to use for code compilation

◆ ~Context()

Context::~Context ( )

Destructor.

Member Function Documentation

◆ lookupDependenciesForModule()

std::vector< CachedModule > Context::lookupDependenciesForModule ( const ID id)

Returns all (direct) dependencies that a module imports. This information may be correct yet, if final isn't set in the module meta data.

Parameters
metadata for all dependencies

◆ lookupModule() [1/2]

std::optional< CachedModule > Context::lookupModule ( const ID id)

Looks up a previously cached module AST.

Parameters
idID that was used to cache the AST
Returns
the meta data associated with the previously cached module, or not set if no module is associated with that ID

◆ lookupModule() [2/2]

std::optional< CachedModule > Context::lookupModule ( const hilti::rt::filesystem::path &  path)

Looks up a previously cached module AST.

Parameters
pathpath that was used to cache the AST
Returns
the meta data associated with the previously cached module, or not set if no module is associated with that path

◆ options()

const Options& hilti::Context::options ( ) const
inline

Returns the context's compiler options.

◆ registerModule()

const CachedModule & Context::registerModule ( const context::ModuleIndex idx,
Node &&  module,
bool  requires_compilation 
)

Makes a new module known to the context, which will take ownershiup and cache it, along with further meta data. A module with the same ID or path must only be registered once, the method will abort otherwise.

Parameters
idxcache index for module
modulemodule to cache
requires_compilationinitial value for the corresponding CachedModule field; this may later be overridden if AST processing finds out more
Returns
the meta data associated with the newly registered module

◆ updateModule()

void Context::updateModule ( const context::CachedModule module)

Updates the meta data associated with a previoysly cached module AST.

Parameters
modulemodule to cache; all the fields of the struct must have been filled out

The documentation for this class was generated from the following files: