| chigraph master Systems programming language written for beginners in LLVM

Public Member Functions | List of all members
chi::DefaultModuleCache Struct Reference
Inheritance diagram for chi::DefaultModuleCache:
[legend]
Collaboration diagram for chi::DefaultModuleCache:
[legend]

## 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...
Context & | context () 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

  ctx | The 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
| ) |  |
| override virtual

Cache a module.

Parameters

  moduleName | The name of the module to cache

Precondition
  `!moduleName.empty()`

Parameters

  compiledModule | The IR that's been compiled from this module
  timeAtFileRead | The 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

  moduleName | The 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
| override virtual

Get the time that a cache was updated.

Parameters

  moduleName | The 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
| inline inherited

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 | ) |
| override virtual

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
| ) |  |
| override virtual

Retrieve a module from the cache.

Parameters

  moduleName | The name of the module to retrieve

Precondition
  `!moduleName.empty()`

Parameters

  atLeastThisNew | Make 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:

- lib/core/include/chi/DefaultModuleCache.hpp
- lib/core/src/DefaultModuleCache.cpp