better partitions system in global_info, trie in utils

This commit is contained in:
ProgramSnail 2023-05-11 14:56:27 +03:00
parent 6e487c8fd9
commit a97a6125de
3 changed files with 130 additions and 8 deletions

View file

@ -248,22 +248,25 @@ utils::IdType GlobalInfo::NamespaceVisitor::AddConstructor(const std::string& co
}
utils::IdType GlobalInfo::NamespaceVisitor::AddPartition(const std::vector<std::string>& path,
const std::string& name,
interpreter::tokens::PartitionStatement* node) {
PartitionInfo partition;
partition.path.reserve(current_path_.size() + path.size());
partition.path.reserve(current_path_.size() + path.size() - 1);
partition.path = current_path_;
for (auto& path_namespace : path) {
partition.path.push_back(path_namespace);
for (size_t i = 0; i + 1 < path.size(); ++i) {
partition.path.push_back(path[i]);
}
partition.name = name;
partition.name = path.back();
partition.node = node;
utils::IdType id = global_info_.partitions_.size();
global_info_.partitions_.push_back(partition);
return global_info_.partitions_.size() - 1;
global_info_.partitions_trie_.Insert(partition.path, id);
return id;
}
std::optional<definition::Namespace*> GlobalInfo::NamespaceVisitor::FindNamespace(const std::optional<std::vector<std::string>>& path) {