mirror of
https://codeberg.org/ProgramSnail/lang_2023.git
synced 2025-12-26 16:58:45 +00:00
type_check_visitor part
This commit is contained in:
parent
d13faf104d
commit
94ef8702fb
11 changed files with 496 additions and 288 deletions
|
|
@ -34,18 +34,18 @@ void FindSymbolsVisitor::Visit(Namespace* node) {
|
|||
|
||||
// TODO: add imported symbols to symbol table (global info)
|
||||
void FindSymbolsVisitor::Visit(ImportStatement* node) {
|
||||
is_in_statement = true;
|
||||
is_in_statement_ = true;
|
||||
|
||||
info::definition::Import info;
|
||||
info.module_name = node->module_name;
|
||||
info.symbols = node->symbols;
|
||||
namespace_visitor_.AddImport(std::move(info), node->name);
|
||||
|
||||
is_in_statement = false;
|
||||
is_in_statement_ = false;
|
||||
}
|
||||
|
||||
void FindSymbolsVisitor::Visit(AliasDefinitionStatement* node) {
|
||||
is_in_statement = true;
|
||||
is_in_statement_ = true;
|
||||
|
||||
info::definition::Type info;
|
||||
|
||||
|
|
@ -73,12 +73,12 @@ void FindSymbolsVisitor::Visit(AliasDefinitionStatement* node) {
|
|||
|
||||
node->type_id_ = namespace_visitor_.AddType(node->type, std::move(info));
|
||||
|
||||
is_in_statement = false;
|
||||
is_in_statement_ = false;
|
||||
}
|
||||
|
||||
void FindSymbolsVisitor::Visit(FunctionDeclaration* node) {
|
||||
bool was_in_statement = is_in_statement;
|
||||
is_in_statement = true;
|
||||
bool was_in_statement = is_in_statement_;
|
||||
is_in_statement_ = true;
|
||||
|
||||
info::definition::FunctionDeclaration info;
|
||||
|
||||
|
|
@ -100,12 +100,12 @@ void FindSymbolsVisitor::Visit(FunctionDeclaration* node) {
|
|||
current_info_ = std::move(info);
|
||||
} else {
|
||||
node->function_id_ = namespace_visitor_.AddFunctionDeclaration(node->name.name, std::move(info));
|
||||
is_in_statement = false;
|
||||
is_in_statement_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
void FindSymbolsVisitor::Visit(FunctionDefinitionStatement* node) {
|
||||
is_in_statement = true;
|
||||
is_in_statement_ = true;
|
||||
|
||||
info::definition::FunctionDefinition info;
|
||||
|
||||
|
|
@ -120,11 +120,11 @@ void FindSymbolsVisitor::Visit(FunctionDefinitionStatement* node) {
|
|||
|
||||
node->function_id_ = namespace_visitor_.AddFunctionDefinition(definition->name.name, std::move(info));
|
||||
|
||||
is_in_statement = false;
|
||||
is_in_statement_ = false;
|
||||
}
|
||||
|
||||
void FindSymbolsVisitor::Visit(TypeDefinitionStatement* node) {
|
||||
is_in_statement = true;
|
||||
is_in_statement_ = true;
|
||||
|
||||
info::definition::Type info;
|
||||
|
||||
|
|
@ -151,11 +151,11 @@ void FindSymbolsVisitor::Visit(TypeDefinitionStatement* node) {
|
|||
|
||||
node->type_id_ = namespace_visitor_.AddType(type, std::move(info));
|
||||
|
||||
is_in_statement = false;
|
||||
is_in_statement_ = false;
|
||||
}
|
||||
|
||||
void FindSymbolsVisitor::Visit(AbstractTypeDefinitionStatement* node) {
|
||||
is_in_statement = true;
|
||||
is_in_statement_ = true;
|
||||
|
||||
info::definition::AbstractType info;
|
||||
|
||||
|
|
@ -176,11 +176,11 @@ void FindSymbolsVisitor::Visit(AbstractTypeDefinitionStatement* node) {
|
|||
|
||||
node->type_id_ = namespace_visitor_.AddAbstractType(type, std::move(info));
|
||||
|
||||
is_in_statement = false;
|
||||
is_in_statement_ = false;
|
||||
}
|
||||
|
||||
void FindSymbolsVisitor::Visit(TypeclassDefinitionStatement* node) {
|
||||
is_in_statement = true;
|
||||
is_in_statement_ = true;
|
||||
|
||||
info::definition::Typeclass info;
|
||||
|
||||
|
|
@ -202,7 +202,7 @@ void FindSymbolsVisitor::Visit(TypeclassDefinitionStatement* node) {
|
|||
|
||||
node->typeclass_id_ = namespace_visitor_.AddTypeclass(definition->type.get()->type, std::move(info));
|
||||
|
||||
is_in_statement = false;
|
||||
is_in_statement_ = false;
|
||||
}
|
||||
|
||||
// Definition parts
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue