mirror of
https://codeberg.org/ProgramSnail/lang_2023.git
synced 2025-12-06 06:58:45 +00:00
71 lines
1.5 KiB
C++
71 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include <optional>
|
|
#include <string>
|
|
#include <variant>
|
|
#include <memory>
|
|
|
|
// for clangd
|
|
#include "utils.hpp"
|
|
|
|
namespace info::type {
|
|
|
|
// // Temporary frozen, TODO
|
|
// struct AbstractType {
|
|
// utils::IdType graph_id;
|
|
// std::vector<utils::IdType> paramaters;
|
|
// };
|
|
|
|
// TODO: check, if defined type is variant, etc.
|
|
struct DefinedType {
|
|
utils::IdType type_id; // in defined types
|
|
utils::IdType type; // in types manager, created using context types
|
|
};
|
|
|
|
enum class InternalType {
|
|
Float,
|
|
Int,
|
|
String,
|
|
Char,
|
|
Bool,
|
|
Unit,
|
|
};
|
|
|
|
struct TupleType {
|
|
std::optional<std::string> type;
|
|
std::vector<std::pair<std::optional<std::string>, utils::IdType>> fields;
|
|
};
|
|
|
|
struct VariantType {
|
|
std::optional<std::string> type;
|
|
std::vector<TupleType> constructors;
|
|
};
|
|
|
|
struct OptionalType {
|
|
std::optional<utils::IdType> type; // Can be empty (Some or None)
|
|
};
|
|
|
|
struct ReferenceToType {
|
|
std::vector<utils::ReferenceType> references;
|
|
utils::IdType type;
|
|
};
|
|
|
|
struct FunctionType {
|
|
std::vector<utils::IdType> argument_types;
|
|
utils::IdType return_type;
|
|
};
|
|
|
|
struct ArrayType {
|
|
size_t size; // ?? = 0 for dynamic ??
|
|
std::optional<utils::IdType> elements_type;
|
|
};
|
|
|
|
using Type = std::variant<DefinedType,
|
|
InternalType,
|
|
TupleType,
|
|
VariantType,
|
|
ReferenceToType,
|
|
FunctionType,
|
|
ArrayType>;
|
|
|
|
} // namespace info::type
|