mirror of
https://codeberg.org/ProgramSnail/lang_2023.git
synced 2026-01-25 13:07:13 +00:00
part of type_check_visitor
This commit is contained in:
parent
94ef8702fb
commit
f7e985a448
10 changed files with 377 additions and 88 deletions
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
// for clangd
|
||||
#include "definitions.hpp"
|
||||
#include "interpreter_tree.hpp"
|
||||
#include "utils.hpp"
|
||||
|
||||
namespace info {
|
||||
|
|
@ -82,6 +83,10 @@ public:
|
|||
const std::vector<std::string>& GetCurrentPath() {
|
||||
return current_path_;
|
||||
}
|
||||
|
||||
definition::Namespace* GetCurrentNamespace() {
|
||||
return namespace_stack_.back();
|
||||
}
|
||||
private:
|
||||
NamespaceVisitor(GlobalInfo& global_info) : global_info_(global_info),
|
||||
namespace_stack_({&global_info.global_namespace_}) {}
|
||||
|
|
@ -104,23 +109,31 @@ public:
|
|||
}
|
||||
|
||||
// remember about vector realloc
|
||||
definition::Function* GetFunctionInfo(utils::IdType id) {
|
||||
return &functions_[id];
|
||||
const definition::Function& GetFunctionInfo(utils::IdType id) {
|
||||
return functions_.at(id);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
const std::optional<T>& GetTypeInfo(utils::IdType id) {
|
||||
if (!std::holds_alternative<T>(types_.at(id).type)) {
|
||||
return std::nullopt;
|
||||
}
|
||||
return std::get<T>(types_[id].type);
|
||||
}
|
||||
|
||||
// remember about vector realloc
|
||||
definition::Type* GetTypeInfo(utils::IdType id) {
|
||||
return &types_[id];
|
||||
const definition::Type& GetAnyTypeInfo(utils::IdType id) {
|
||||
return types_.at(id);
|
||||
}
|
||||
|
||||
// remember about vector realloc
|
||||
definition::Typeclass* GetTypeclassInfo(utils::IdType id) {
|
||||
return &typeclasses_[id];
|
||||
const definition::Typeclass& GetTypeclassInfo(utils::IdType id) {
|
||||
return typeclasses_.at(id);
|
||||
}
|
||||
|
||||
// remember about vector realloc
|
||||
definition::Constructor* GetConstructorInfo(utils::IdType id) {
|
||||
return &constructors_[id];
|
||||
const definition::Constructor& GetConstructorInfo(utils::IdType id) {
|
||||
return constructors_.at(id);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue