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
118
archived/symbols_info.hpp
Normal file
118
archived/symbols_info.hpp
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
#pragma once
|
||||
|
||||
#include "interpreter_tree.hpp"
|
||||
#include <string>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
#include <optional>
|
||||
#include <unordered_map>
|
||||
#include <memory>
|
||||
|
||||
// for clangd
|
||||
#include "utils.hpp"
|
||||
|
||||
namespace interpreter {
|
||||
class Node;
|
||||
} // namespace interpreter
|
||||
|
||||
namespace info {
|
||||
|
||||
struct VariantTypeInfo;
|
||||
struct TupleTypeInfo;
|
||||
struct AliasTypeInfo;
|
||||
|
||||
struct TypeInfo;
|
||||
|
||||
struct TypeclassInfo;
|
||||
|
||||
enum class BuiltInTypeInfo {
|
||||
StringT,
|
||||
IntT,
|
||||
FloatT,
|
||||
UnitT,
|
||||
};
|
||||
|
||||
struct TypeUsageInfo {
|
||||
interpreter::tokens::TypeExpression* node;
|
||||
TypeInfo* info = nullptr;
|
||||
};
|
||||
|
||||
struct ParameterInfo {
|
||||
std::string type;
|
||||
std::vector<interpreter::tokens::TypeclassExpression*> typeclass_nodes;
|
||||
std::vector<TypeclassInfo*> typeclass_types;
|
||||
};
|
||||
|
||||
struct AbstractTypeInfo {
|
||||
enum { Basic, Abstract } modifier;
|
||||
ParameterInfo type;
|
||||
};
|
||||
|
||||
struct AliasTypeInfo {
|
||||
enum {Alias, Type, Let} modifier;
|
||||
std::vector<std::string> parameters;
|
||||
TypeUsageInfo value;
|
||||
};
|
||||
|
||||
struct AnyTypeInfo {
|
||||
ParameterInfo type;
|
||||
std::vector<ParameterInfo> parameters;
|
||||
interpreter::tokens::AnyType* value;
|
||||
};
|
||||
|
||||
struct TypeInfo {
|
||||
std::variant<AbstractTypeInfo, AliasTypeInfo, AnyTypeInfo> type;
|
||||
};
|
||||
|
||||
struct ConstructorInfo {
|
||||
std::string name;
|
||||
size_t order;
|
||||
utils::IdType type_id;
|
||||
};
|
||||
|
||||
struct FunctionDeclarationInfo {
|
||||
std::vector<ParameterInfo> parameters;
|
||||
std::vector<interpreter::tokens::AnyType*> argument_type_nodes;
|
||||
std::vector<AnyTypeInfo*> argument_types;
|
||||
interpreter::tokens::FunctionDeclaration* node = nullptr;
|
||||
};
|
||||
|
||||
struct FunctionDefinitionInfo {
|
||||
std::vector<ParameterInfo> parameters;
|
||||
std::vector<std::string> argument_names;
|
||||
interpreter::tokens::FunctionDefinitionStatement* node = nullptr;
|
||||
};
|
||||
|
||||
struct FunctionInfo {
|
||||
size_t argument_count = 0;
|
||||
std::optional<FunctionDeclarationInfo> declaration;
|
||||
std::optional<FunctionDefinitionInfo> definition;
|
||||
};
|
||||
|
||||
struct TypeclassInfo {
|
||||
std::vector<ParameterInfo> parameters;
|
||||
std::vector<FunctionDeclarationInfo> requirements;
|
||||
};
|
||||
|
||||
struct ImportInfo {
|
||||
std::string module_name;
|
||||
std::vector<std::string> symbols;
|
||||
};
|
||||
|
||||
struct NamespaceInfo {
|
||||
enum Modifier { Const, Var };
|
||||
|
||||
std::unordered_map<std::string, utils::IdType> types;
|
||||
std::unordered_map<std::string, utils::IdType> typeclasses;
|
||||
std::unordered_map<std::string, utils::IdType> functions;
|
||||
std::unordered_map<std::string, utils::IdType> constructors;
|
||||
std::unordered_map<std::string, NamespaceInfo> namespaces;
|
||||
std::unordered_map<std::string, std::vector<NamespaceInfo>> variable_namespaces;
|
||||
|
||||
std::optional<Modifier> modifier;
|
||||
std::optional<std::string> variable;
|
||||
std::string type_name;
|
||||
TypeInfo* type_info = nullptr;
|
||||
};
|
||||
|
||||
} // namespace info
|
||||
Loading…
Add table
Add a link
Reference in a new issue