mirror of
https://codeberg.org/ProgramSnail/lang_2023.git
synced 2025-12-27 01:08:44 +00:00
fixes
This commit is contained in:
parent
b723fd6a65
commit
3abac1b643
6 changed files with 27 additions and 18 deletions
|
|
@ -156,7 +156,7 @@ void FindSymbolsVisitor::Visit(TypeclassDefinitionStatement* node) {
|
|||
}
|
||||
|
||||
void FindSymbolsVisitor::Visit(PartitionStatement* node) {
|
||||
node->executable_id_ = namespace_visitor_.AddPartition(node->name.path, node);
|
||||
node->executable_id_ = namespace_visitor_.AddPartition(node->name.path, node, node->base);
|
||||
}
|
||||
|
||||
// Definition parts
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -843,6 +843,7 @@ void TypeCheckVisitor::Visit(TypeConstructor* node) {
|
|||
|
||||
utils::IdType constructor_id = node->constructor->constructor_id_.value();
|
||||
|
||||
// TODO: take type_id_ ??
|
||||
info::definition::Constructor constructor_info = global_info_.GetConstructorInfo(constructor_id);
|
||||
|
||||
utils::IdType type_id = constructor_info.type_id;
|
||||
|
|
@ -912,6 +913,10 @@ void TypeCheckVisitor::Visit(TypeConstructor* node) {
|
|||
|
||||
current_type_ = TypeInContext(current_type_, context);
|
||||
|
||||
current_type_ = context_manager_.AddValue(
|
||||
info::type::DefinedType(type_id, current_type_, type_info.modifier, context_manager_.GetValueManager()),
|
||||
utils::ValueType::Tmp);
|
||||
|
||||
node->base.type_ = current_type_;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue