some fixes, going to fix function_call_expression typeclass argument types search bug

This commit is contained in:
ProgramSnail 2023-05-22 01:25:12 +03:00
parent f2192b5331
commit 0290b5604a
9 changed files with 307 additions and 111 deletions

View file

@ -50,14 +50,12 @@ public:
}
bool HasTypeclass(utils::IdType graph_id) {
error_handling::DebugPrint(name_);
error_handling::DebugPrint(requirement_graph_ids_.size());
for (auto& requirement_graph_id : requirement_graph_ids_) {
error_handling::DebugPrint(requirement_graph_id);
}
return requirement_graph_ids_.count(graph_id) != 0;
}
std::string ToString() {
return "Abstract";
}
private:
utils::AbstractTypeModifier modifier_;
std::string name_;
@ -93,6 +91,9 @@ public:
return class_modifier_;
}
std::string ToString() {
return "Defined";
}
private:
utils::IdType type_id_; // in defined types
utils::IdType type_; // in types manager, created using context types (if specific type)
@ -140,6 +141,32 @@ inline std::optional<InternalType> ToInternalType(const std::string& type) {
return std::nullopt;
}
inline std::string ToString(InternalType type) {
std::string result;
switch (type) {
case InternalType::Float:
result = "Float";
break;
case InternalType::Int:
result = "Int";
break;
case InternalType::String:
result = "String";
break;
case InternalType::Char:
result = "Char";
break;
case InternalType::Bool:
result = "Bool";
break;
case InternalType::Unit:
result = "Unit";
break;
}
return result;
}
class TupleType {
public:
TupleType() = default;
@ -160,6 +187,7 @@ public:
return fields_;
}
std::string ToString();
private:
std::optional<std::string> name_;
std::vector<std::pair<std::optional<std::string>, utils::IdType>> fields_;
@ -190,6 +218,7 @@ public:
current_constructor_ = constructor;
}
std::string ToString();
private:
std::optional<std::string> name_;
std::vector<TupleType> constructors_;
@ -211,6 +240,7 @@ public:
std::optional<utils::IdType> GetFieldType(const std::string& name,
const std::unordered_set<utils::IdType>& type_namespaces) const;
std::string ToString();
private:
utils::IdType type_;
TypeManager* type_manager_ = nullptr;
@ -232,6 +262,7 @@ public:
std::optional<utils::IdType> GetFieldType(const std::string& name,
const std::unordered_set<utils::IdType>& type_namespaces) const;
std::string ToString();
private:
std::vector<utils::ReferenceModifier> references_;
utils::IdType type_;
@ -256,6 +287,7 @@ public:
std::optional<utils::IdType> GetFieldType(const std::string& name,
const std::unordered_set<utils::IdType>& type_namespaces) const;
std::string ToString();
private:
std::vector<utils::IdType> argument_types_;
utils::IdType return_type_;
@ -282,6 +314,7 @@ public:
return elements_type_;
}
std::string ToString();
private:
size_t size_; // = 0 for dynamic
utils::IdType elements_type_;
@ -316,6 +349,8 @@ public:
OptionalType>& GetType() {
return type_;
}
std::string ToString();
private:
std::variant<AbstractType,
DefinedType,