mirror of
https://codeberg.org/ProgramSnail/lang_2023.git
synced 2025-12-08 16:08:45 +00:00
contexts fixes
This commit is contained in:
parent
6850863f58
commit
ab29a785bf
7 changed files with 106 additions and 94 deletions
|
|
@ -37,7 +37,7 @@ std::optional<utils::IdType> AbstractType::GetFieldType(const std::string& name)
|
|||
//
|
||||
|
||||
std::optional<utils::IdType> DefinedType::InContext(const std::unordered_map<std::string, utils::IdType>& context) {
|
||||
std::optional<utils::IdType> maybe_type_replacement = type_manager_->GetAnyType(type_)->InContext(context);
|
||||
std::optional<utils::IdType> maybe_type_replacement = type_manager_->GetAnyValue(type_)->InContext(context);
|
||||
|
||||
if (maybe_type_replacement.has_value()) {
|
||||
type_ = maybe_type_replacement.value();
|
||||
|
|
@ -48,12 +48,12 @@ std::optional<utils::IdType> DefinedType::InContext(const std::unordered_map<std
|
|||
|
||||
bool DefinedType::Same(const DefinedType& type) const {
|
||||
return type_id_ == type.type_id_
|
||||
&& type_manager_->GetAnyType(type_)->Same(*type_manager_->GetAnyType(type.type_));
|
||||
&& type_manager_->GetAnyValue(type_)->Same(*type_manager_->GetAnyValue(type.type_));
|
||||
}
|
||||
|
||||
bool DefinedType::operator<(const DefinedType& type) const {
|
||||
return type_id_ == type.type_id_
|
||||
&& *type_manager_->GetAnyType(type_) < *type_manager_->GetAnyType(type.type_);
|
||||
&& *type_manager_->GetAnyValue(type_) < *type_manager_->GetAnyValue(type.type_);
|
||||
}
|
||||
|
||||
bool DefinedType::operator>(const DefinedType& type) const {
|
||||
|
|
@ -61,14 +61,14 @@ bool DefinedType::operator>(const DefinedType& type) const {
|
|||
}
|
||||
|
||||
std::optional<utils::IdType> DefinedType::GetFieldType(const std::string& name) const {
|
||||
return type_manager_->GetAnyType(type_)->GetFieldType(name);
|
||||
return type_manager_->GetAnyValue(type_)->GetFieldType(name);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
std::optional<utils::IdType> TupleType::InContext(const std::unordered_map<std::string, utils::IdType>& context) {
|
||||
for (size_t i = 0; i < fields_.size(); ++i) {
|
||||
std::optional<utils::IdType> maybe_field_replacement = type_manager_->GetAnyType(fields_[i].second)->InContext(context);
|
||||
std::optional<utils::IdType> maybe_field_replacement = type_manager_->GetAnyValue(fields_[i].second)->InContext(context);
|
||||
|
||||
if (maybe_field_replacement.has_value()) {
|
||||
fields_[i].second = maybe_field_replacement.value();
|
||||
|
|
@ -84,7 +84,7 @@ bool TupleType::Same(const TupleType& type) const {
|
|||
}
|
||||
|
||||
for (size_t i = 0; i < fields_.size(); ++i) {
|
||||
if (!type_manager_->GetAnyType(fields_[i].second)->Same(*type_manager_->GetAnyType(type.fields_[i].second))) {
|
||||
if (!type_manager_->GetAnyValue(fields_[i].second)->Same(*type_manager_->GetAnyValue(type.fields_[i].second))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -98,7 +98,7 @@ bool TupleType::operator<(const TupleType& type) const {
|
|||
}
|
||||
|
||||
for (size_t i = 0; i < fields_.size(); ++i) {
|
||||
if (!(*type_manager_->GetAnyType(fields_[i].second) < *type_manager_->GetAnyType(type.fields_[i].second))) {
|
||||
if (!(*type_manager_->GetAnyValue(fields_[i].second) < *type_manager_->GetAnyValue(type.fields_[i].second))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -171,7 +171,7 @@ std::optional<utils::IdType> VariantType::GetFieldType(const std::string& name)
|
|||
//
|
||||
|
||||
std::optional<utils::IdType> OptionalType::InContext(const std::unordered_map<std::string, utils::IdType>& context) {
|
||||
std::optional<utils::IdType> maybe_type_replacement = type_manager_->GetAnyType(type_)->InContext(context);
|
||||
std::optional<utils::IdType> maybe_type_replacement = type_manager_->GetAnyValue(type_)->InContext(context);
|
||||
|
||||
if (maybe_type_replacement.has_value()) {
|
||||
type_ = maybe_type_replacement.value();
|
||||
|
|
@ -181,11 +181,11 @@ std::optional<utils::IdType> OptionalType::InContext(const std::unordered_map<st
|
|||
}
|
||||
|
||||
bool OptionalType::Same(const OptionalType& type) const {
|
||||
return type_manager_->GetAnyType(type_)->Same(*type_manager_->GetAnyType(type.type_));
|
||||
return type_manager_->GetAnyValue(type_)->Same(*type_manager_->GetAnyValue(type.type_));
|
||||
}
|
||||
|
||||
bool OptionalType::operator<(const OptionalType& type) const {
|
||||
return *type_manager_->GetAnyType(type_) < *type_manager_->GetAnyType(type.type_);
|
||||
return *type_manager_->GetAnyValue(type_) < *type_manager_->GetAnyValue(type.type_);
|
||||
}
|
||||
|
||||
bool OptionalType::operator>(const OptionalType& type) const {
|
||||
|
|
@ -199,7 +199,7 @@ std::optional<utils::IdType> OptionalType::GetFieldType(const std::string& name)
|
|||
//
|
||||
|
||||
std::optional<utils::IdType> ReferenceToType::InContext(const std::unordered_map<std::string, utils::IdType>& context) {
|
||||
std::optional<utils::IdType> maybe_type_replacement = type_manager_->GetAnyType(type_)->InContext(context);
|
||||
std::optional<utils::IdType> maybe_type_replacement = type_manager_->GetAnyValue(type_)->InContext(context);
|
||||
|
||||
if (maybe_type_replacement.has_value()) {
|
||||
type_ = maybe_type_replacement.value();
|
||||
|
|
@ -209,11 +209,11 @@ std::optional<utils::IdType> ReferenceToType::InContext(const std::unordered_map
|
|||
}
|
||||
|
||||
bool ReferenceToType::Same(const ReferenceToType& type) const {
|
||||
return references_ == type.references_ && type_manager_->GetAnyType(type_)->Same(*type_manager_->GetAnyType(type.type_));
|
||||
return references_ == type.references_ && type_manager_->GetAnyValue(type_)->Same(*type_manager_->GetAnyValue(type.type_));
|
||||
}
|
||||
|
||||
bool ReferenceToType::operator<(const ReferenceToType& type) const {
|
||||
return references_ == type.references_ && *type_manager_->GetAnyType(type_) < *type_manager_->GetAnyType(type.type_);
|
||||
return references_ == type.references_ && *type_manager_->GetAnyValue(type_) < *type_manager_->GetAnyValue(type.type_);
|
||||
}
|
||||
|
||||
bool ReferenceToType::operator>(const ReferenceToType& type) const {
|
||||
|
|
@ -221,7 +221,7 @@ bool ReferenceToType::operator>(const ReferenceToType& type) const {
|
|||
}
|
||||
|
||||
std::optional<utils::IdType> ReferenceToType::GetFieldType(const std::string& name) const {
|
||||
return type_manager_->GetAnyType(type_)->GetFieldType(name);
|
||||
return type_manager_->GetAnyValue(type_)->GetFieldType(name);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
@ -229,7 +229,7 @@ std::optional<utils::IdType> ReferenceToType::GetFieldType(const std::string& na
|
|||
std::optional<utils::IdType> FunctionType::InContext(const std::unordered_map<std::string, utils::IdType>& context) {
|
||||
for (size_t i = 0; i < argument_types_.size(); ++i) {
|
||||
std::optional<utils::IdType> maybe_argument_type_replacement =
|
||||
type_manager_->GetAnyType(argument_types_[i])->InContext(context);
|
||||
type_manager_->GetAnyValue(argument_types_[i])->InContext(context);
|
||||
|
||||
if (maybe_argument_type_replacement.has_value()) {
|
||||
argument_types_[i] = maybe_argument_type_replacement.value();
|
||||
|
|
@ -245,7 +245,7 @@ bool FunctionType::Same(const FunctionType& type) const {
|
|||
}
|
||||
|
||||
for (size_t i = 0; i < argument_types_.size(); ++i) {
|
||||
if (!type_manager_->GetAnyType(argument_types_[i])->Same(*type_manager_->GetAnyType(type.argument_types_[i]))) {
|
||||
if (!type_manager_->GetAnyValue(argument_types_[i])->Same(*type_manager_->GetAnyValue(type.argument_types_[i]))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -259,7 +259,7 @@ bool FunctionType::operator<(const FunctionType& type) const {
|
|||
}
|
||||
|
||||
for (size_t i = 0; i < argument_types_.size(); ++i) {
|
||||
if (!(*type_manager_->GetAnyType(argument_types_[i]) < *type_manager_->GetAnyType(type.argument_types_[i]))) {
|
||||
if (!(*type_manager_->GetAnyValue(argument_types_[i]) < *type_manager_->GetAnyValue(type.argument_types_[i]))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -279,7 +279,7 @@ std::optional<utils::IdType> FunctionType::GetFieldType(const std::string& name)
|
|||
|
||||
std::optional<utils::IdType> ArrayType::InContext(const std::unordered_map<std::string, utils::IdType>& context) {
|
||||
std::optional<utils::IdType> maybe_elements_type_replacement =
|
||||
type_manager_->GetAnyType(elements_type_)->InContext(context);
|
||||
type_manager_->GetAnyValue(elements_type_)->InContext(context);
|
||||
|
||||
if (maybe_elements_type_replacement.has_value()) {
|
||||
elements_type_ = maybe_elements_type_replacement.value();
|
||||
|
|
@ -289,11 +289,11 @@ std::optional<utils::IdType> ArrayType::InContext(const std::unordered_map<std::
|
|||
}
|
||||
|
||||
bool ArrayType::Same(const ArrayType& type) const {
|
||||
return size_ == type.size_ && type_manager_->GetAnyType(elements_type_)->Same(*type_manager_->GetAnyType(type.elements_type_));
|
||||
return size_ == type.size_ && type_manager_->GetAnyValue(elements_type_)->Same(*type_manager_->GetAnyValue(type.elements_type_));
|
||||
}
|
||||
|
||||
bool ArrayType::operator<(const ArrayType& type) const {
|
||||
return size_ == type.size_ && *type_manager_->GetAnyType(elements_type_) < *type_manager_->GetAnyType(type.elements_type_);
|
||||
return size_ == type.size_ && *type_manager_->GetAnyValue(elements_type_) < *type_manager_->GetAnyValue(type.elements_type_);
|
||||
}
|
||||
|
||||
bool ArrayType::operator>(const ArrayType& type) const {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue