mirror of
https://codeberg.org/ProgramSnail/lang_2023.git
synced 2026-01-25 13:07:13 +00:00
partition syntax changed, interface modifier added
This commit is contained in:
parent
3fca384446
commit
b1aff1935d
22 changed files with 299 additions and 266 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <asm-generic/errno.h>
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include <unordered_map>
|
||||
|
|
@ -11,14 +12,22 @@
|
|||
|
||||
namespace info {
|
||||
|
||||
// TODO: partitions
|
||||
// TODO: better test / executable partitions support (tree, etc.)
|
||||
// TODO: add classes / structs and functions module interface
|
||||
class GlobalInfo {
|
||||
friend class NamespaceVisitor;
|
||||
public:
|
||||
struct PartitionInfo {
|
||||
std::vector<std::string> path;
|
||||
std::string name;
|
||||
interpreter::tokens::PartitionStatement* node = nullptr;
|
||||
};
|
||||
|
||||
class NamespaceVisitor {
|
||||
friend GlobalInfo;
|
||||
NamespaceVisitor() = delete;
|
||||
public:
|
||||
|
||||
struct Path {
|
||||
std::vector<std::optional<utils::IdType>> path_types;
|
||||
definition::Namespace* result;
|
||||
|
|
@ -57,6 +66,10 @@ public:
|
|||
definition::Constructor&& constructor_info,
|
||||
const interpreter::tokens::BaseNode& base_node);
|
||||
|
||||
utils::IdType AddPartition(const std::vector<std::string>& path,
|
||||
const std::string& name,
|
||||
interpreter::tokens::PartitionStatement* node);
|
||||
|
||||
std::optional<definition::Namespace*> FindNamespace(const std::optional<std::vector<std::string>>& path);
|
||||
|
||||
std::optional<utils::IdType> FindFunction(const std::optional<std::vector<std::string>>& path,
|
||||
|
|
@ -145,6 +158,11 @@ public:
|
|||
return constructors_.at(id);
|
||||
}
|
||||
|
||||
// remember about vector realloc
|
||||
const PartitionInfo& GetPartitionInfo(utils::IdType id) {
|
||||
return partitions_.at(id);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
std::vector<definition::Function> functions_;
|
||||
|
|
@ -156,6 +174,8 @@ private:
|
|||
std::unordered_map<std::string, utils::IdType> name_to_typeclass_;
|
||||
std::unordered_map<std::string, utils::IdType> name_to_abstract_type_;
|
||||
|
||||
std::vector<PartitionInfo> partitions_;
|
||||
|
||||
definition::Namespace global_namespace_;
|
||||
std::vector<definition::Import> imports_;
|
||||
std::unordered_map<std::string, definition::Import> usages_;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue