mirror of
https://codeberg.org/ProgramSnail/lang_2023.git
synced 2025-12-05 22:48:42 +00:00
annotated types added to typeclass graph, fixes
This commit is contained in:
parent
d841e2754b
commit
0b53b2f218
8 changed files with 131 additions and 124 deletions
|
|
@ -350,19 +350,8 @@ public:
|
|||
return &typeclass_graph_;
|
||||
}
|
||||
|
||||
// std::unordered_set<utils::IdType>
|
||||
// GetAnnotatedTypeTypeclassesSet(interpreter::tokens::AnnotatedType* node);
|
||||
//
|
||||
// std::vector<utils::IdType>
|
||||
// GetAnnotatedTypeTypeclassesVector(interpreter::tokens::AnnotatedType* node);
|
||||
//
|
||||
// std::unordered_map<std::string, TypeclassGraph::FunctionInfo>
|
||||
// GetAnnotatedTypeFunctionsMap(interpreter::tokens::AnnotatedType* node,
|
||||
// const interpreter::tokens::BaseNode& base_node);
|
||||
//
|
||||
// std::vector<std::pair<std::string, TypeclassGraph::FunctionInfo>>
|
||||
// GetAnnotatedTypeFunctionsVector(interpreter::tokens::AnnotatedType* node,
|
||||
// const interpreter::tokens::BaseNode& base_node);
|
||||
std::optional<definition::Namespace*> GetTypeNamespace(utils::IdType id,
|
||||
utils::ClassInternalsModifier modifier);
|
||||
|
||||
std::unordered_map<std::string, utils::IdType>* ChooseNamespaces(
|
||||
utils::ClassInternalsModifier modifier,
|
||||
|
|
|
|||
|
|
@ -294,7 +294,7 @@ struct AliasDefinitionStatement {
|
|||
std::vector<AbstractTypeIdentifier> parameters;
|
||||
std::unique_ptr<TypeExpression> value;
|
||||
|
||||
utils::IdType type_id_;
|
||||
utils::IdType type_id_ = 0;
|
||||
};
|
||||
|
||||
struct VariableDefinitionStatement {
|
||||
|
|
@ -314,7 +314,7 @@ struct FunctionDeclaration {
|
|||
std::vector<std::unique_ptr<AnnotatedAbstractType>> parameters;
|
||||
std::unique_ptr<FunctionType> type;
|
||||
|
||||
utils::IdType function_id_;
|
||||
utils::IdType function_id_ = 0;
|
||||
};
|
||||
|
||||
struct FunctionDefinitionStatement {
|
||||
|
|
@ -323,7 +323,7 @@ struct FunctionDefinitionStatement {
|
|||
std::unique_ptr<FunctionDefinition> definition;
|
||||
SuperExpression value;
|
||||
|
||||
utils::IdType function_id_;
|
||||
utils::IdType function_id_ = 0;
|
||||
};
|
||||
|
||||
struct TypeDefinitionStatement {
|
||||
|
|
@ -334,7 +334,7 @@ struct TypeDefinitionStatement {
|
|||
std::unique_ptr<TypeDefinition> definition;
|
||||
AnyType value;
|
||||
|
||||
utils::IdType type_id_;
|
||||
utils::IdType type_id_ = 0;
|
||||
};
|
||||
|
||||
struct AbstractTypeDefinitionStatement {
|
||||
|
|
@ -343,8 +343,7 @@ struct AbstractTypeDefinitionStatement {
|
|||
utils::AbstractTypeModifier modifier;
|
||||
std::unique_ptr<AnnotatedType> type;
|
||||
|
||||
utils::IdType type_graph_id_;
|
||||
utils::IdType type_id_;
|
||||
utils::IdType type_id_ = 0;
|
||||
};
|
||||
|
||||
struct TypeclassDefinitionStatement {
|
||||
|
|
@ -354,7 +353,7 @@ struct TypeclassDefinitionStatement {
|
|||
std::vector<std::pair<utils::ClassInternalsModifier,
|
||||
std::unique_ptr<FunctionDeclaration>>> requirements;
|
||||
|
||||
utils::IdType typeclass_id_;
|
||||
utils::IdType typeclass_id_ = 0;
|
||||
};
|
||||
|
||||
struct PartitionStatement {
|
||||
|
|
@ -364,7 +363,7 @@ struct PartitionStatement {
|
|||
PartitionName name;
|
||||
SuperExpression value;
|
||||
|
||||
utils::IdType executable_id_;
|
||||
utils::IdType executable_id_ = 0;
|
||||
};
|
||||
|
||||
// Definition parts -----------------
|
||||
|
|
@ -388,6 +387,8 @@ struct AnyAnnotatedType {
|
|||
|
||||
AnyTypeIdentifier type;
|
||||
std::vector<std::unique_ptr<ParametrizedTypeclass>> typeclasses;
|
||||
|
||||
utils::IdType graph_id_ = 0; // for types
|
||||
};
|
||||
|
||||
// ----------------- Flow control -----------------
|
||||
|
|
@ -566,7 +567,7 @@ struct LambdaFunction {
|
|||
Expression expression;
|
||||
|
||||
std::vector<utils::IdType> argument_graph_ids_;
|
||||
utils::IdType return_type_graph_id_;
|
||||
utils::IdType return_type_graph_id_ = 0;
|
||||
};
|
||||
|
||||
struct ArrayExpression {
|
||||
|
|
@ -662,7 +663,7 @@ struct ParametrizedTypeclass {
|
|||
TypeclassIdentifier typeclass;
|
||||
std::vector<std::unique_ptr<TypeExpression>> parameters;
|
||||
|
||||
utils::IdType typeclass_id_;
|
||||
utils::IdType typeclass_id_ = 0;
|
||||
};
|
||||
|
||||
// ----------------- Comments [IGNORE] -----------------
|
||||
|
|
|
|||
|
|
@ -3,7 +3,10 @@
|
|||
#include <ostream>
|
||||
|
||||
// for clangd
|
||||
#include "definitions.hpp"
|
||||
#include "error_handling.hpp"
|
||||
#include "typeclass_graph.hpp"
|
||||
#include "utils.hpp"
|
||||
#include "visitor.hpp"
|
||||
#include "global_info.hpp"
|
||||
|
||||
|
|
@ -13,7 +16,9 @@ namespace interpreter {
|
|||
class LinkSymbolsVisitor : public Visitor {
|
||||
public:
|
||||
explicit LinkSymbolsVisitor(info::GlobalInfo& global_info)
|
||||
: namespace_visitor_(global_info.CreateVisitor()) {}
|
||||
: namespace_visitor_(global_info.CreateVisitor()),
|
||||
global_info_(global_info),
|
||||
typeclass_graph_(*global_info.GetTypeclassGraph()) {}
|
||||
|
||||
void VisitSourceFile(SourceFile* source_file) override {
|
||||
Visitor::Visit(source_file);
|
||||
|
|
@ -121,8 +126,16 @@ private:
|
|||
// // void Visit(CharLiteral* node) override;
|
||||
// // void Visit(BoolLiteral* node) override;
|
||||
|
||||
//
|
||||
|
||||
void AddTypeFunctionsToTypeclassGraph(utils::IdType type_id,
|
||||
utils::IdType graph_id,
|
||||
utils::ClassInternalsModifier namespace_modifier);
|
||||
|
||||
private:
|
||||
info::GlobalInfo::NamespaceVisitor namespace_visitor_;
|
||||
info::GlobalInfo& global_info_;
|
||||
info::TypeclassGraph& typeclass_graph_;
|
||||
};
|
||||
|
||||
} // namespace interpreter
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
#include <unordered_map>
|
||||
|
||||
// for clangd
|
||||
#include "error_handling.hpp"
|
||||
#include "utils.hpp"
|
||||
|
||||
namespace info::type {
|
||||
|
|
@ -17,7 +16,7 @@ namespace info::type {
|
|||
|
||||
class TypeManager;
|
||||
|
||||
class AbstractType { // later will be found in context
|
||||
class AbstractType { // latter will be found in context
|
||||
public:
|
||||
AbstractType() = default;
|
||||
AbstractType(utils::AbstractTypeModifier modifier,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue