This commit is contained in:
ProgramSnail 2023-05-17 18:29:39 +03:00
parent b723fd6a65
commit 3abac1b643
6 changed files with 27 additions and 18 deletions

View file

@ -281,23 +281,25 @@ utils::IdType GlobalInfo::NamespaceVisitor::AddConstructor(const std::string& co
}
utils::IdType GlobalInfo::NamespaceVisitor::AddPartition(const std::vector<std::string>& path,
interpreter::tokens::PartitionStatement* node) {
interpreter::tokens::PartitionStatement* node,
const interpreter::tokens::BaseNode& base_node) {
PartitionInfo partition;
partition.path.reserve(current_path_.size() + path.size() - 1);
partition.path.reserve(current_path_.size() + path.size());
partition.path = current_path_;
for (size_t i = 0; i + 1 < path.size(); ++i) {
partition.path.push_back(path[i]);
for (auto& path_name : path) {
partition.path.push_back(path_name);
}
partition.name = path.back();
partition.node = node;
utils::IdType id = global_info_.partitions_.size();
global_info_.partitions_.push_back(partition);
global_info_.partitions_trie_.Insert(partition.path, id);
if (!global_info_.partitions_trie_.Insert(partition.path, id)) {
error_handling::HandleNamesError("Partition with this name already exists", base_node);
}
return id;
}