5#ifndef HOSHI_LANG_CODEGENOBJECTCACHE_HPP
6#define HOSHI_LANG_CODEGENOBJECTCACHE_HPP
15 namespace serialization {
16 template <
typename T>
void write(FILE *fp,
const T &value) {
17 static_assert(std::is_trivially_copyable_v<T>,
"T must be trivially copyable, otherwise explicit serialization method must be provided.");
19 fwrite(&value,
sizeof(T), 1, fp);
22 template <
typename T>
void read(FILE *fp, T &value) {
23 static_assert(std::is_trivially_copyable_v<T>,
24 "T must be trivially copyable, otherwise explicit deserialization method must be provided.");
26 fread(&value,
sizeof(T), 1, fp);
64 std::map<yoi::wstr, CodegenObjectCacheEntry>
cache;
121 namespace serialization {
130 template <>
void write(FILE *fp,
const std::set<yoi::indexT> &value);
132 template <>
void read(FILE *fp, std::set<yoi::indexT> &value);
void purge_and_update(const yoi::vec< yoi::wstr > &source_files)
purge the cache, add the entries that previously not in the cache, remove the entries that are not in...
CodegenObjectCacheEntry get_entry(const yoi::wstr &abs_path_on_disk)
get the entry from the cache
yoi::indexT register_entry(const yoi::wstr &abs_path_on_disk)
register a new entry to the cache
yoi::indexT register_entry_unlocked(const yoi::wstr &abs_path_on_disk)
CodegenObjectCache & setCompilerCtx(const std::shared_ptr< compilerContext > &compilerCtx)
set the build config
void remove_entry(const yoi::wstr &abs_path_on_disk)
remove the entry from the cache
std::set< yoi::indexT > free_list
std::shared_ptr< compilerContext > compilerCtx
yoi::indexT get_entry_index(const yoi::wstr &abs_path_on_disk)
get the entry from the cache
void update_last_modification(const yoi::wstr &abs_path_on_disk, yoi::indexT last_modification)
update the last modification time of an entry
std::map< yoi::wstr, CodegenObjectCacheEntry > cache
void write(FILE *fp, const yoi::wstr &value)
void read(FILE *fp, yoi::wstr &value)
CodegenObjectCacheEntry setAbsPathOnDisk(const yoi::wstr &abs_path_on_disk)
const yoi::wstr & getObjectFilename() const
yoi::indexT last_modification
yoi::wstr object_filename
CodegenObjectCacheEntry setHash(yoi::indexT hash)
const std::set< yoi::indexT > & getDependBy() const
CodegenObjectCacheEntry setLastModification(yoi::indexT last_modification)
yoi::indexT getHash() const
CodegenObjectCacheEntry()=default
const yoi::wstr & getAbsPathOnDisk() const
CodegenObjectCacheEntry setObjectFilename(const yoi::wstr &object_filename)
yoi::wstr abs_path_on_disk
CodegenObjectCacheEntry setDependBy(const std::set< yoi::indexT > &depend_by)
yoi::indexT getLastModification() const
std::set< yoi::indexT > depend_by