mirror of
https://codeberg.org/ProgramSnail/lang_2023.git
synced 2026-01-25 13:07:13 +00:00
variable namespace, function declaration fixes
This commit is contained in:
parent
c31b20fa24
commit
f973f65b5b
17 changed files with 511 additions and 98 deletions
71
include/types.hpp
Normal file
71
include/types.hpp
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
#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
|
||||
Loading…
Add table
Add a link
Reference in a new issue