8#ifndef SEN_CORE_LANG_STL_RESOLVER_H
9#define SEN_CORE_LANG_STL_RESOLVER_H
20#include <unordered_map>
21#include <unordered_set>
38 std::vector<ConstTypeHandle<sen::CustomType>>
types;
53 using TypeSetStorageContainerType = std::vector<std::unique_ptr<TypeSet>>;
58 using IterBaseTy = TypeSetStorageContainerType::const_iterator;
62 using value_type =
typename TypeSetStorageContainerType::const_iterator::value_type::element_type;
68 reference operator[](IterBaseTy::difference_type idx)
const {
return *(this->IterBaseTy::operator[](idx)); }
74 return typeSets_.emplace_back(std::make_unique<TypeSet>()).get();
77 void prepend(std::unique_ptr<TypeSet> newTypeSet) { typeSets_.insert(typeSets_.begin(), std::move(newTypeSet)); }
78 void append(std::unique_ptr<TypeSet> newTypeSet) { typeSets_.push_back(std::move(newTypeSet)); }
79 void reserve(
size_t n) { typeSets_.reserve(n); }
80 [[nodiscard]]
size_t size()
const {
return typeSets_.size(); }
86 void recordReadFile(
const std::filesystem::path& file) { readFiles_.insert(file); }
89 [[nodiscard]]
const std::set<std::filesystem::path>&
readFiles()
const {
return readFiles_; }
92 TypeSetStorageContainerType typeSets_;
93 std::set<std::filesystem::path> readFiles_;
121 const std::vector<StlStatement>& statements_;
128 const std::vector<std::filesystem::path>& includePaths,
131 std::string_view from = {});
StlResolver(const std::vector< StlStatement > &statements, const ResolverContext &context, TypeSetContext &globalContext) noexcept
Stores the statements, context, and the global context.
const TypeSet * resolve(const TypeSettings &settings)
Do the resolution based on the inputs passed on the constructor.
Definition stl_resolver.h:57
value_type * pointer
Definition stl_resolver.h:63
value_type & reference
Definition stl_resolver.h:64
typename TypeSetStorageContainerType::const_iterator::value_type::element_type value_type
Definition stl_resolver.h:62
reference operator*() const
Definition stl_resolver.h:66
pointer operator->() const
Definition stl_resolver.h:67
reference operator[](IterBaseTy::difference_type idx) const
Definition stl_resolver.h:68
The set of types used during resolution.
Definition stl_resolver.h:52
void prepend(std::unique_ptr< TypeSet > newTypeSet)
Definition stl_resolver.h:77
TypeSetIterator begin() const
Definition stl_resolver.h:82
const std::set< std::filesystem::path > & readFiles() const
Every file read while resolving, transitive imports included.
Definition stl_resolver.h:89
void reserve(size_t n)
Definition stl_resolver.h:79
size_t size() const
Definition stl_resolver.h:80
void recordReadFile(const std::filesystem::path &file)
Records a file the resolver opened. Sorted, so a depfile is reproducible.
Definition stl_resolver.h:86
void append(std::unique_ptr< TypeSet > newTypeSet)
Definition stl_resolver.h:78
TypeSet * createNewTypeSet() noexcept(noexcept(TypeSet()))
Definition stl_resolver.h:72
TypeSetIterator end() const
Definition stl_resolver.h:83
std::vector< ConstTypeHandle< sen::CustomType > > types
Definition stl_resolver.h:38
std::vector< const TypeSet * > importedSets
Definition stl_resolver.h:39
std::vector< std::string > package
Definition stl_resolver.h:37
std::string fileName
Definition stl_resolver.h:35
std::filesystem::path originalFileName
Definition stl_resolver.h:45
std::string parentDirectory
Definition stl_resolver.h:36
std::filesystem::path absoluteFileName
Definition stl_resolver.h:46
std::vector< std::filesystem::path > includePaths
Definition stl_resolver.h:47
std::unordered_set< std::string > deferredMethods
Definition stl_resolver.h:99
std::unordered_set< std::string > checkedProperties
Definition stl_resolver.h:98
std::string computePackagePrefix(const std::vector< std::string > &path)
Joins a package path (e.g. ["sen", "components", "jsonrpc"]) into the dotted form used in STL declara...
const TypeSet * readTypesFile(const std::filesystem::path &fileName, const std::vector< std::filesystem::path > &includePaths, TypeSetContext &globalTypeSetContext, const TypeSettings &settings, std::string_view from={})
Helper function to use the resolver.
Definition stl_resolver.h:97
The environment where a resolution takes place.
Definition stl_resolver.h:44
A set of types coming from a STL file.
Definition stl_resolver.h:34
Definition code_location.h:14
Definition stl_resolver.h:103
std::unordered_map< std::string, ClassAnnotations > classAnnotations
Qualified class name to its annotations.
Definition stl_resolver.h:105