mirror of
https://codeberg.org/ProgramSnail/lang_2023.git
synced 2025-12-09 08:28:43 +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
|
|
@ -127,6 +127,8 @@ utils::IdType GlobalInfo::NamespaceVisitor::AddType(const std::string& type,
|
|||
|
||||
definition::Type& moved_type_info = global_info_.types_.back();
|
||||
|
||||
// TODO: constructors for tuple types, function types (??), array types (??), ...
|
||||
|
||||
if (std::holds_alternative<definition::AnyType>(moved_type_info.type)) {
|
||||
definition::AnyType& any_type_info = std::get<definition::AnyType>(moved_type_info.type);
|
||||
if (std::holds_alternative<std::unique_ptr<interpreter::tokens::VariantType>>(*any_type_info.value)) {
|
||||
|
|
@ -142,7 +144,10 @@ utils::IdType GlobalInfo::NamespaceVisitor::AddType(const std::string& type,
|
|||
constructor_name = std::get<interpreter::tokens::Constructor>(variant_type_info.constructors[i]);
|
||||
} else if (std::holds_alternative<
|
||||
std::unique_ptr<interpreter::tokens::TupleType>>(variant_type_info.constructors[i])) {
|
||||
auto maybe_constructor_name = std::get<std::unique_ptr<interpreter::tokens::TupleType>>(variant_type_info.constructors[i])->type;
|
||||
constructor_info.constructor_tuple_node =
|
||||
std::get<std::unique_ptr<interpreter::tokens::TupleType>>(variant_type_info.constructors[i]).get();
|
||||
|
||||
auto maybe_constructor_name = constructor_info.constructor_tuple_node.value()->type;
|
||||
|
||||
if (maybe_constructor_name.has_value()) {
|
||||
constructor_name = maybe_constructor_name.value();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue