part of type_check_visitor

This commit is contained in:
ProgramSnail 2023-05-04 16:11:25 +03:00
parent 94ef8702fb
commit f7e985a448
10 changed files with 377 additions and 88 deletions

View file

@ -48,9 +48,14 @@ public:
bool operator<(const DefinedType& type) const;
bool operator>(const DefinedType& type) const;
utils::IdType GetTypeId() {
utils::IdType GetTypeId() const {
return type_id_;
}
utils::IdType GetType() const {
return type_;
}
private:
utils::IdType type_id_; // in defined types
utils::IdType type_; // in types manager, created using context types (if specific type)
@ -82,6 +87,7 @@ public:
const std::vector<std::pair<std::optional<std::string>, utils::IdType>>& GetFields() const {
return fields_;
}
private:
std::optional<std::string> name_;
std::vector<std::pair<std::optional<std::string>, utils::IdType>> fields_;
@ -103,6 +109,7 @@ public:
const std::vector<TupleType>& GetConstructors() const {
return constructors_;
}
private:
std::optional<std::string> name_;
std::vector<TupleType> constructors_;
@ -119,6 +126,7 @@ public:
bool Same(const OptionalType& type) const;
bool operator<(const OptionalType& type) const;
bool operator>(const OptionalType& type) const;
private:
utils::IdType type_;
TypeManager* type_manager_ = nullptr;
@ -136,6 +144,7 @@ public:
bool Same(const ReferenceToType& type) const;
bool operator<(const ReferenceToType& type) const;
bool operator>(const ReferenceToType& type) const;
private:
std::vector<utils::ReferenceType> references_;
utils::IdType type_;
@ -156,6 +165,7 @@ public:
bool Same(const FunctionType& type) const;
bool operator<(const FunctionType& type) const;
bool operator>(const FunctionType& type) const;
private:
std::vector<utils::IdType> argument_types_;
utils::IdType return_type_;
@ -178,6 +188,7 @@ public:
utils::IdType GetElementsType() {
return elements_type_;
}
private:
size_t size_; // = 0 for dynamic
utils::IdType elements_type_;
@ -193,6 +204,7 @@ public:
bool Same(const Type& type) const;
bool operator<(const Type& type) const; // TODO: rule exceptions
bool operator>(const Type& type) const;
private:
std::variant<AbstractType,
DefinedType,
@ -216,6 +228,7 @@ public:
bool AddTypeRequirement(utils::IdType type, utils::IdType requrement);
bool EqualTypes(utils::IdType first_type, utils::IdType second_type);
private:
std::vector<info::type::Type> types_;
};