mirror of
https://codeberg.org/ProgramSnail/lang_2023.git
synced 2025-12-08 16:08:45 +00:00
type_check_visitor first iteration, value, execution_visitor started
This commit is contained in:
parent
173d50672a
commit
890bd90eba
22 changed files with 481 additions and 452 deletions
|
|
@ -466,42 +466,5 @@ std::string Type::GetTypeName() const {
|
|||
return ""; // ??
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
template<typename T>
|
||||
utils::IdType TypeManager::AddType(T&& type, utils::ValueType value_type) {
|
||||
types_.emplace_back({std::forward(type), value_type});
|
||||
return types_.size() - 1;
|
||||
}
|
||||
|
||||
utils::IdType TypeManager::AddAnyType(Type&& type, utils::ValueType value_type) {
|
||||
types_.push_back({std::move(type), value_type});
|
||||
return types_.size() - 1;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::optional<T*> TypeManager::GetType(utils::IdType type_id) {
|
||||
if (!std::holds_alternative<T>(types_.at(type_id).second)) {
|
||||
return std::nullopt;
|
||||
}
|
||||
return &std::get<T>(types_.at(type_id).second);
|
||||
}
|
||||
|
||||
Type* TypeManager::GetAnyType(utils::IdType type_id) {
|
||||
return &types_.at(type_id).first;
|
||||
}
|
||||
|
||||
utils::ValueType TypeManager::GetValueType(utils::IdType type_id) {
|
||||
return types_.at(type_id).second;
|
||||
}
|
||||
|
||||
bool TypeManager::EqualTypes(utils::IdType first_type, utils::IdType second_type) {
|
||||
return GetAnyType(first_type)->Same(*GetAnyType(second_type));
|
||||
}
|
||||
|
||||
bool TypeManager::AddTypeRequirement(utils::IdType type, utils::IdType requrement) {
|
||||
return *GetAnyType(requrement) < *GetAnyType(type);
|
||||
}
|
||||
|
||||
} // namespace info::type
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue