chigraph  master
Systems programming language written for beginners in LLVM
chi::DefaultModuleCache Struct Reference
+ Inheritance diagram for chi::DefaultModuleCache:
+ Collaboration diagram for chi::DefaultModuleCache:

Public Member Functions

 DefaultModuleCache (Context &ctx)
 Default constrcutor. More...
 
Result cacheModule (const boost::filesystem::path &moduleName, llvm::Module &compiledModule, std::time_t timeAtFileRead) override
 Cache a module. More...
 
boost::filesystem::path cachePathForModule (const boost::filesystem::path &moduleName) const
 Get the cache name for a module. More...
 
std::time_t cacheUpdateTime (const boost::filesystem::path &moduleName) const override
 Get the time that a cache was updated. More...
 
Contextcontext () const
 Get the context this cache is bound to. More...
 
void invalidateCache (const boost::filesystem::path &moduleName) override
 
std::unique_ptr< llvm::Module > retrieveFromCache (const boost::filesystem::path &moduleName, std::time_t atLeastThisNew) override
 Retrieve a module from the cache. More...
 

Detailed Description

Definition at line 10 of file DefaultModuleCache.hpp.

Constructor & Destructor Documentation

◆ DefaultModuleCache()

chi::DefaultModuleCache::DefaultModuleCache ( chi::Context ctx)

Default constrcutor.

Parameters
ctxThe context to cache for

Definition at line 26 of file DefaultModuleCache.cpp.

Member Function Documentation

◆ cacheModule()

Result chi::DefaultModuleCache::cacheModule ( const boost::filesystem::path &  moduleName,
llvm::Module &  compiledModule,
std::time_t  timeAtFileRead 
)
overridevirtual

Cache a module.

Parameters
moduleNameThe name of the module to cache
Precondition
!moduleName.empty()
Parameters
compiledModuleThe IR that's been compiled from this module
timeAtFileReadThe time to store as the cache time. Should be the time the module was read from disk
Returns
The Result

Implements chi::ModuleCache.

Definition at line 28 of file DefaultModuleCache.cpp.

References cachePathForModule().

+ Here is the call graph for this function:

◆ cachePathForModule()

boost::filesystem::path chi::DefaultModuleCache::cachePathForModule ( const boost::filesystem::path &  moduleName) const

Get the cache name for a module.

Basically context().workspacePath() / moduleName + ".bc"

Parameters
moduleNameThe name of the module to get a cache path for
Returns
The path

Definition at line 70 of file DefaultModuleCache.cpp.

References chi::ModuleCache::context(), and chi::Context::workspacePath().

Referenced by cacheModule(), cacheUpdateTime(), invalidateCache(), and retrieveFromCache().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cacheUpdateTime()

std::time_t chi::DefaultModuleCache::cacheUpdateTime ( const boost::filesystem::path &  moduleName) const
overridevirtual

Get the time that a cache was updated.

Parameters
moduleNameThe module to get the last update time for
Returns
The time it was updated, or 0 if there is no cache

Implements chi::ModuleCache.

Definition at line 83 of file DefaultModuleCache.cpp.

References cachePathForModule().

Referenced by retrieveFromCache().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ context()

Context& chi::ModuleCache::context ( ) const
inlineinherited

Get the context this cache is bound to.

Returns
the Context

Definition at line 59 of file ModuleCache.hpp.

Referenced by cachePathForModule(), and retrieveFromCache().

+ Here is the caller graph for this function:

◆ invalidateCache()

void chi::DefaultModuleCache::invalidateCache ( const boost::filesystem::path &  moduleName)
overridevirtual

Implements chi::ModuleCache.

Definition at line 75 of file DefaultModuleCache.cpp.

References cachePathForModule().

+ Here is the call graph for this function:

◆ retrieveFromCache()

std::unique_ptr< llvm::Module > chi::DefaultModuleCache::retrieveFromCache ( const boost::filesystem::path &  moduleName,
std::time_t  atLeastThisNew 
)
overridevirtual

Retrieve a module from the cache.

Parameters
moduleNameThe name of the module to retrieve
Precondition
!moduleName.empty()
Parameters
atLeastThisNewMake sure the cache is at least as new as this
Returns
A llvm::Module, or nullptr if no suitable cache was found

Implements chi::ModuleCache.

Definition at line 87 of file DefaultModuleCache.cpp.

References cachePathForModule(), cacheUpdateTime(), chi::ModuleCache::context(), and chi::parseBitcodeFile().

+ Here is the call graph for this function:

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