diff --git a/CMakeLists.txt b/CMakeLists.txt index 89e1146..716cd83 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required(VERSION 3.30) project(pslang CXX) +set(CMAKE_CXX_STANDARD 23) + add_subdirectory(libs/types) add_subdirectory(libs/ast) add_subdirectory(libs/parser) diff --git a/libs/ast/include/pslang/ast/expression_visitor.hpp b/libs/ast/include/pslang/ast/expression_visitor.hpp index 1839cab..920006d 100644 --- a/libs/ast/include/pslang/ast/expression_visitor.hpp +++ b/libs/ast/include/pslang/ast/expression_visitor.hpp @@ -18,12 +18,16 @@ namespace pslang::ast return [this](auto const & type){ return derived().apply(type); }; } - auto apply(literal const & expression) + template + requires (std::is_same_v) + auto apply(Expression const & expression) { return std::visit(make_visitor(), expression); } - auto apply(expression const & expression) + template + requires (std::is_same_v) + auto apply(Expression const & expression) { return std::visit(make_visitor(), expression); } @@ -42,12 +46,16 @@ namespace pslang::ast return [this](auto & type){ return derived().apply(type); }; } - auto apply(literal & expression) + template + requires (std::is_same_v) + auto apply(Expression & expression) { return std::visit(make_visitor(), expression); } - auto apply(expression & expression) + template + requires (std::is_same_v) + auto apply(Expression & expression) { return std::visit(make_visitor(), expression); } diff --git a/libs/ast/include/pslang/ast/statement_visitor.hpp b/libs/ast/include/pslang/ast/statement_visitor.hpp index 19b8fd2..e88fd72 100644 --- a/libs/ast/include/pslang/ast/statement_visitor.hpp +++ b/libs/ast/include/pslang/ast/statement_visitor.hpp @@ -18,12 +18,16 @@ namespace pslang::ast return [this](auto const & type){ return derived().apply(type); }; } - auto apply(statement const & statement) + template + requires (std::is_same_v) + auto apply(Statement const & statement) { return std::visit(make_visitor(), statement); } - void apply(statement_list const & statement_list) + template + requires (std::is_same_v) + void apply(Statement const & statement_list) { for (auto const & statement : statement_list.statements) derived().apply(*statement); @@ -43,12 +47,16 @@ namespace pslang::ast return [this](auto & type){ return derived().apply(type); }; } - auto apply(statement & statement) + template + requires (std::is_same_v) + auto apply(Statement & statement) { return std::visit(make_visitor(), statement); } - void apply(statement_list & statement_list) + template + requires (std::is_same_v) + void apply(Statement & statement_list) { for (auto & statement : statement_list.statements) derived().apply(*statement); diff --git a/libs/ast/include/pslang/ast/type_visitor.hpp b/libs/ast/include/pslang/ast/type_visitor.hpp index 879a3ec..6747dfd 100644 --- a/libs/ast/include/pslang/ast/type_visitor.hpp +++ b/libs/ast/include/pslang/ast/type_visitor.hpp @@ -18,12 +18,16 @@ namespace pslang::ast return [this](auto const & type){ return derived().apply(type); }; } - auto apply(types::primitive_type const & type) + template + requires (std::is_same_v) + auto apply(Type const & type) { return std::visit(make_visitor(), type); } - auto apply(ast::type const & type) + template + requires (std::is_same_v) + auto apply(Type const & type) { return std::visit(make_visitor(), type); } @@ -42,12 +46,16 @@ namespace pslang::ast return [this](auto & type){ return derived().apply(type); }; } - auto apply(types::primitive_type & type) + template + requires (std::is_same_v) + auto apply(Type & type) { return std::visit(make_visitor(), type); } - auto apply(ast::type & type) + template + requires (std::is_same_v) + auto apply(Type & type) { return std::visit(make_visitor(), type); } diff --git a/libs/types/include/pslang/types/type_visitor.hpp b/libs/types/include/pslang/types/type_visitor.hpp index b759ecf..37b5d05 100644 --- a/libs/types/include/pslang/types/type_visitor.hpp +++ b/libs/types/include/pslang/types/type_visitor.hpp @@ -18,12 +18,16 @@ namespace pslang::types return [this](auto const & type){ return derived().apply(type); }; } - auto apply(types::primitive_type const & type) + template + requires (std::is_same_v) + auto apply(Type const & type) { return std::visit(make_visitor(), type); } - auto apply(types::type const & type) + template + requires (std::is_same_v) + auto apply(Type const & type) { return std::visit(make_visitor(), type); } @@ -42,12 +46,16 @@ namespace pslang::types return [this](auto & type){ return derived().apply(type); }; } - auto apply(types::primitive_type & type) + template + requires (std::is_same_v) + auto apply(Type & type) { return std::visit(make_visitor(), type); } - auto apply(types::type & type) + template + requires (std::is_same_v) + auto apply(Type & type) { return std::visit(make_visitor(), type); }