mirror of
https://codeberg.org/ProgramSnail/lang_2023.git
synced 2026-01-25 13:07:13 +00:00
better class interloop
This commit is contained in:
parent
c433448952
commit
a1d9e6b190
4 changed files with 66 additions and 20 deletions
|
|
@ -213,6 +213,45 @@ public:
|
|||
return &global_info_.namespaces_[GetCurrentNamespaceId()];
|
||||
}
|
||||
|
||||
std::optional<utils::IdType> GetCurrentNamespaceTypeId() {
|
||||
if (!GetCurrentNamespace()->any_node.has_value()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
return GetCurrentNamespace()->any_node.value()->link_type_id_;
|
||||
}
|
||||
|
||||
std::optional<definition::Type*> GetCurrentNamespaceAnyType() {
|
||||
std::optional<utils::IdType> id = GetCurrentNamespaceTypeId();
|
||||
if (!id.has_value()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
return &global_info_.GetAnyTypeInfo(id.value());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::optional<T*> GetCurrentNamespaceType() {
|
||||
std::optional<utils::IdType> id = GetCurrentNamespaceTypeId();
|
||||
if (!id.has_value()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
return global_info_.GetTypeInfo<T>(id.value());
|
||||
}
|
||||
|
||||
std::optional<utils::IdType> GetCurrentNamespaceTypeclassId() {
|
||||
if (!GetCurrentNamespace()->any_node.has_value()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
return GetCurrentNamespace()->any_node.value()->link_typeclass_id_;
|
||||
}
|
||||
|
||||
std::optional<definition::Typeclass*> GetCurrentNamespaceTypeclass() {
|
||||
std::optional<utils::IdType> id = GetCurrentNamespaceTypeclassId();
|
||||
if (!id.has_value()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
return &global_info_.GetTypeclassInfo(id.value());
|
||||
}
|
||||
|
||||
bool IsInGlobalNamespace() {
|
||||
return namespace_stack_.size() == 1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue