mirror of
https://codeberg.org/ProgramSnail/lang_2023.git
synced 2025-12-05 22:48:42 +00:00
fixes, optional type name added
This commit is contained in:
parent
d38d75c9d8
commit
0850e6aa6b
14 changed files with 163 additions and 99 deletions
|
|
@ -31,6 +31,11 @@ public:
|
|||
};
|
||||
|
||||
void ExecutePartition(interpreter::tokens::PartitionStatement* partition) {
|
||||
for (size_t i = 0; i < info::type::InternalTypesCount; ++i) {
|
||||
info::type::InternalType type = static_cast<info::type::InternalType>(i);
|
||||
std::string type_name = info::type::ToString(type);
|
||||
context_manager_.DefineLocalType(type_name, global_info_.FindAbstractType(type_name).value()->node->type->graph_id_);
|
||||
}
|
||||
Visit(partition);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -93,8 +93,6 @@ public:
|
|||
|
||||
std::optional<utils::IdType> FindLocalTypeId(const std::string& type);
|
||||
|
||||
std::optional<utils::IdType> FindAbstractTypeId(const std::string& abstract_type);
|
||||
|
||||
std::optional<utils::IdType> FindTypeclassId(const std::string& typeclass);
|
||||
|
||||
std::optional<utils::IdType> FindConstructorId(const std::optional<std::vector<std::string>>& path,
|
||||
|
|
@ -164,14 +162,6 @@ public:
|
|||
return global_info_.GetTypeInfo<T>(id.value());
|
||||
}
|
||||
|
||||
std::optional<definition::AbstractType*> FindAbstractType(const std::string& abstract_type) {
|
||||
std::optional<utils::IdType> id = FindAbstractTypeId(abstract_type);
|
||||
if (!id.has_value()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
return &global_info_.GetAbstractTypeInfo(id.value());
|
||||
}
|
||||
|
||||
std::optional<definition::Typeclass*> FindTypeclass(const std::string& typeclass) {
|
||||
std::optional<utils::IdType> id = FindTypeclassId(typeclass);
|
||||
if (!id.has_value()) {
|
||||
|
|
@ -368,6 +358,16 @@ public:
|
|||
// function declarations & definitions should be added latter
|
||||
std::optional<utils::IdType> AddAnnotatedTypeToGraph(interpreter::tokens::AnnotatedType* node);
|
||||
|
||||
std::optional<utils::IdType> FindAbstractTypeId(const std::string& abstract_type);
|
||||
|
||||
std::optional<definition::AbstractType*> FindAbstractType(const std::string& abstract_type) {
|
||||
std::optional<utils::IdType> id = FindAbstractTypeId(abstract_type);
|
||||
if (!id.has_value()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
return &GetAbstractTypeInfo(id.value());
|
||||
}
|
||||
|
||||
private:
|
||||
void CollectFunctionInfo(
|
||||
utils::IdType current_namespace,
|
||||
|
|
|
|||
|
|
@ -654,6 +654,7 @@ struct TypeExpression {
|
|||
ParametrizedType type;
|
||||
|
||||
std::optional<size_t> array_size; // if array; 0 - dynamic size
|
||||
bool is_optional = false; // for optionals
|
||||
|
||||
std::optional<utils::IdType> type_id_;
|
||||
std::optional<utils::IdType> constructor_id_;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public:
|
|||
// init internal type abstrac types
|
||||
for (size_t i = 0; i < info::type::InternalTypesCount; ++i) {
|
||||
info::type::InternalType type = static_cast<info::type::InternalType>(i);
|
||||
Visit(namespace_visitor_.FindAbstractType(info::type::ToString(type)).value()->node);
|
||||
Visit(global_info_.FindAbstractType(info::type::ToString(type)).value()->node);
|
||||
}
|
||||
|
||||
Visit(source_file);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue