mirror of
https://codeberg.org/ProgramSnail/lang_2023.git
synced 2026-01-25 13:07:13 +00:00
fixes, builtin function fixes, deep copy, string access
This commit is contained in:
parent
3af0772da6
commit
9aaac90ef6
13 changed files with 450 additions and 152 deletions
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
// for clangd
|
||||
#include "error_handling.hpp"
|
||||
#include "typeclass_graph.hpp"
|
||||
#include "utils.hpp"
|
||||
|
||||
namespace info::type {
|
||||
|
|
@ -19,23 +20,12 @@ class TypeManager;
|
|||
|
||||
class AbstractType { // latter will be found in context
|
||||
public:
|
||||
AbstractType() = default;
|
||||
AbstractType(utils::AbstractTypeModifier modifier,
|
||||
const std::string& name,
|
||||
const std::vector<utils::IdType>& requirement_graph_ids)
|
||||
utils::IdType graph_id,
|
||||
info::TypeclassGraph& typeclass_graph)
|
||||
: modifier_(modifier),
|
||||
name_(name) {
|
||||
for (auto& requirement_graph_id : requirement_graph_ids) {
|
||||
requirement_graph_ids_.insert(requirement_graph_id);
|
||||
}
|
||||
}
|
||||
|
||||
AbstractType(utils::AbstractTypeModifier modifier,
|
||||
const std::string& name,
|
||||
const std::unordered_set<utils::IdType>& requirement_graph_ids)
|
||||
: modifier_(modifier),
|
||||
name_(name),
|
||||
requirement_graph_ids_(requirement_graph_ids) {}
|
||||
graph_id_(graph_id),
|
||||
typeclass_graph_(typeclass_graph) {}
|
||||
|
||||
std::optional<utils::IdType> InContext(const std::unordered_map<std::string, utils::IdType>& context);
|
||||
bool Same(const AbstractType& type) const;
|
||||
|
|
@ -45,21 +35,21 @@ public:
|
|||
std::optional<utils::IdType> GetFieldType(const std::string& name,
|
||||
const std::unordered_set<utils::IdType>& type_namespaces) const;
|
||||
|
||||
const std::string& GetName() {
|
||||
return name_;
|
||||
utils::IdType GetGraphId() {
|
||||
return graph_id_;
|
||||
}
|
||||
|
||||
bool HasTypeclass(utils::IdType graph_id) {
|
||||
return requirement_graph_ids_.count(graph_id) != 0;
|
||||
bool HasTypeclass(utils::IdType graph_id) { // TODO: cache dependencies set
|
||||
return graph_id == graph_id_ || typeclass_graph_.GetDependenciesSet(graph_id_).count(graph_id) != 0;
|
||||
}
|
||||
|
||||
std::string ToString() {
|
||||
return "Abstract " + name_;
|
||||
return "Abstract " + std::to_string(graph_id_);
|
||||
}
|
||||
private:
|
||||
utils::AbstractTypeModifier modifier_;
|
||||
std::string name_;
|
||||
std::unordered_set<utils::IdType> requirement_graph_ids_; // TODO: all typeclasses from tree
|
||||
utils::IdType graph_id_;
|
||||
info::TypeclassGraph& typeclass_graph_;
|
||||
};
|
||||
|
||||
class DefinedType {
|
||||
|
|
@ -324,8 +314,6 @@ private:
|
|||
|
||||
class Type {
|
||||
public:
|
||||
Type() = default;
|
||||
|
||||
template<typename T>
|
||||
explicit Type(const T& type) : type_(type) {}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue