2023-07-19 11:02:11 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "basic_nodes.hpp"
|
2023-07-20 14:38:44 +03:00
|
|
|
#include "docs.hpp"
|
|
|
|
|
#include "expression_nodes.hpp"
|
|
|
|
|
#include "type_nodes.hpp"
|
2023-07-19 11:02:11 +03:00
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
// IN PROGRESS
|
|
|
|
|
|
|
|
|
|
namespace nodes {
|
|
|
|
|
|
2023-07-20 14:38:44 +03:00
|
|
|
// IN PROGRESS: add another constructors ??
|
2023-07-19 11:02:11 +03:00
|
|
|
class Import : public Node {
|
|
|
|
|
public:
|
2023-07-20 14:38:44 +03:00
|
|
|
Import(Node node, const Identifier &import_name,
|
|
|
|
|
const Identifier &module_name, std::vector<Identifier> &&symbols = {})
|
|
|
|
|
: Node(node), import_name_(import_name), module_name_(module_name),
|
|
|
|
|
symbols_(std::move(symbols)) {}
|
|
|
|
|
|
|
|
|
|
size_t symbols_size() const { return symbols_.size(); }
|
|
|
|
|
|
|
|
|
|
std::string *get_symbol(size_t id) { return symbols_.at(id).get(); }
|
|
|
|
|
|
|
|
|
|
const std::string *get_symbol(size_t id) const {
|
|
|
|
|
return symbols_.at(id).get();
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-19 11:02:11 +03:00
|
|
|
private:
|
|
|
|
|
Identifier import_name_;
|
|
|
|
|
Identifier module_name_;
|
|
|
|
|
std::vector<Identifier> symbols_;
|
2023-07-20 14:38:44 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class Constraint : public Node {
|
|
|
|
|
public:
|
|
|
|
|
Constraint(Node node, ExpressionProxy expression)
|
|
|
|
|
: Node(node), expression_(expression) {}
|
|
|
|
|
|
|
|
|
|
Expression *get_expression() { return expression_.get(); }
|
|
|
|
|
|
|
|
|
|
const Expression *get_expression() const { return expression_.get(); }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
ExpressionProxy expression_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class FunctionDefinition : public Node {
|
|
|
|
|
public:
|
|
|
|
|
enum ModifierType {
|
|
|
|
|
STATIC,
|
|
|
|
|
LET,
|
|
|
|
|
VAR,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
FunctionDefinition(Node node, SymbolDocs &&docs,
|
|
|
|
|
std::vector<Constraint> &&constraints,
|
|
|
|
|
ModifierType modifier, const Identifier &name,
|
|
|
|
|
std::vector<std::string> &&annotations,
|
|
|
|
|
std::vector<Identifier> &&arguments,
|
|
|
|
|
std::vector<ReferenceType> &&reference_types,
|
|
|
|
|
std::vector<TypeProxy> &&types)
|
|
|
|
|
: Node(node), docs_(std::move(docs)),
|
|
|
|
|
constraints_(std::move(constraints)), modifier_(modifier), name_(name),
|
|
|
|
|
annotations_(std::move(annotations)), arguments_(std::move(arguments)),
|
|
|
|
|
reference_types_(std::move(reference_types)), types_(std::move(types)) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
SymbolDocs docs_;
|
|
|
|
|
std::vector<Constraint> constraints_;
|
|
|
|
|
ModifierType modifier_;
|
|
|
|
|
Identifier name_;
|
|
|
|
|
std::vector<std::string> annotations_;
|
|
|
|
|
std::vector<Identifier> arguments_;
|
|
|
|
|
std::vector<ReferenceType> reference_types_;
|
|
|
|
|
std::vector<TypeProxy> types_;
|
|
|
|
|
// std::vector<bool> optional_arguments_; // ??
|
2023-07-19 11:02:11 +03:00
|
|
|
}; // IN PROGRESS
|
|
|
|
|
|
2023-07-20 14:38:44 +03:00
|
|
|
class TypeDefinition : public Node {
|
|
|
|
|
public:
|
|
|
|
|
TypeDefinition(Node node, SymbolDocs &&docs, bool is_on_heap,
|
|
|
|
|
const Identifier &name, std::vector<Identifier> &&arguments,
|
|
|
|
|
VariantType &&type, std::vector<FunctionDefinition> &&methods)
|
|
|
|
|
: Node(node), docs_(std::move(docs)), is_on_heap_(is_on_heap),
|
|
|
|
|
name_(name), arguments_(std::move(arguments)), type_(std::move(type)),
|
|
|
|
|
methods_(std::move(methods)) {}
|
2023-07-19 11:02:11 +03:00
|
|
|
|
2023-07-20 14:38:44 +03:00
|
|
|
private:
|
|
|
|
|
SymbolDocs docs_;
|
|
|
|
|
bool is_on_heap_;
|
|
|
|
|
Identifier name_;
|
|
|
|
|
std::vector<Identifier> arguments_;
|
|
|
|
|
VariantType type_; // TupleType is VariantType with one variant
|
|
|
|
|
std::vector<FunctionDefinition> methods_;
|
|
|
|
|
}; // IN PROGRESS
|
2023-07-19 11:02:11 +03:00
|
|
|
|
2023-07-20 14:38:44 +03:00
|
|
|
class TypeclassDefinition : public Node {
|
|
|
|
|
public:
|
|
|
|
|
TypeclassDefinition(Node node, SymbolDocs &&docs, const Identifier &name,
|
|
|
|
|
std::vector<Identifier> &&base_typeclasses,
|
|
|
|
|
std::vector<FunctionDefinition> &&methods)
|
|
|
|
|
: Node(node), docs_(std::move(docs)), name_(name),
|
|
|
|
|
base_typeclasses_(std::move(base_typeclasses)),
|
|
|
|
|
methods_(std::move(methods)) {}
|
2023-07-19 11:02:11 +03:00
|
|
|
|
2023-07-20 14:38:44 +03:00
|
|
|
private:
|
|
|
|
|
SymbolDocs docs_;
|
|
|
|
|
Identifier name_;
|
|
|
|
|
std::vector<Identifier> base_typeclasses_;
|
|
|
|
|
std::vector<FunctionDefinition> methods_;
|
|
|
|
|
}; // IN PROGRESS
|
2023-07-19 11:02:11 +03:00
|
|
|
|
|
|
|
|
} // namespace nodes
|