Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(
VERSION 3.28
VERSION 3.31
)
include(CheckIPOSupported)

Expand Down Expand Up @@ -59,7 +59,7 @@ target_sources(${PROJECT_NAME}

set_target_properties(${PROJECT_NAME}
PROPERTIES
CXX_STANDARD 20
CXX_STANDARD 23
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
)
Expand Down
11 changes: 11 additions & 0 deletions include/ipr/impl
Original file line number Diff line number Diff line change
Expand Up @@ -1965,11 +1965,21 @@ namespace ipr::impl {
const ipr::Region& lexical_region() const final { return lexreg.get(); }
};

struct Concept : impl::Decl<ipr::Concept> {
impl::Parameter_list inputs;
util::ref<const ipr::Expr> init;
explicit Concept(const ipr::Region& r) : inputs{r, { }} { }
const ipr::Parameter_list& parameters() const final { return inputs; }
const ipr::Expr& result() const final { return init.get(); }
Optional<ipr::Expr> initializer() const final { return { *this }; }
};

// For a non-defining function declaration, the parameters - if any is named
// or has a default argument - are stored with that particular declaration.
// A function definition is one that specifies the initializer (Mapping) which
// already has room for the named parameters or the default arguments.
struct fundecl_data : std::variant<impl::Parameter_list*, impl::Mapping*> {
ipr::FunctionTraits traits { };
impl::Parameter_list* parameters() const { return std::get<0>(*this); }
impl::Mapping* mapping() const { return std::get<1>(*this); }
};
Expand All @@ -1980,6 +1990,7 @@ namespace ipr::impl {

Fundecl();

ipr::FunctionTraits traits() const final { return data.traits; }
const ipr::Parameter_list& parameters() const final;
Optional<ipr::Mapping> mapping() const final;
Optional<ipr::Expr> initializer() const final;
Expand Down
58 changes: 53 additions & 5 deletions include/ipr/interface
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ namespace ipr {
#include <ipr/node-category>
};

// -- General structural utility types.
// -- General structural utility types and functions.

// -- General node category class.
template<Category_code Cat, class T = Expr>
struct Category : T {
protected:
Expand All @@ -102,6 +103,33 @@ namespace ipr {
virtual const T& result() const = 0;
};

// -- DeclSpecifiers --
enum class DeclSpecifiers : std::uint32_t {
None = 0,
Register = 1 << 0, // Banned from C++17.
Static = 1 << 1,
Extern = 1 << 2,
Mutable = 1 << 3,
Thread = 1 << 4,
StorageClass = Register | Static | Extern | Mutable | Thread,

Inline = 1 << 5,
Virtual = 1 << 6, // also used as storage class specifier
// for virtual base subobjects
Explicit = 1 << 7,

Friend = 1 << 9,
Typedef = 1 << 10,

Public = 1 << 11,
Protected = 1 << 12,
Private = 1 << 13,
AccessProtection = Public | Protected | Private,

Export = 1 << 14, // For exported declarations.
Constexpr = 1 << 15, // C++ 11
};

// -- Logogram --
// A class of words (from a C++ input source) standing for themselves, with no particular elaboration.
struct Logogram : Basic_unary<const String&> {
Expand Down Expand Up @@ -245,12 +273,13 @@ namespace ipr {
}

// -- Lambda_specifiers --
// Declaration specifiers that can appear on a lambda expression.
// Declaration specifiers that can appear in a lambda expression.
enum class Lambda_specifiers : std::uint32_t {
None = 0,
Mutable = 1 << 0,
Constexpr = 1 << 1,
Consteval = 1 << 2,
Mutable = 1 << 0, // `mutable` lambda
Constexpr = 1 << 1, // `constexpr` lambda
Consteval = 1 << 2, // `consteval` lambda
ExplicitObject = 1 << 3, // explicit object parameter `this`.
};

// -- Module_name --
Expand Down Expand Up @@ -1841,15 +1870,33 @@ namespace ipr {
Optional<Expr> initializer() const final { return { }; }
};

// -- Semantic traits of a function declaration.
enum class FunctionTraits : std::uint32_t {
Nothing = 0x0, // No particular traits
Pure = 1 << 0, // pure virtual function
Virtual = 1 << 1, // virtual function
Static = 1 << 2, // static member-function, NOT linkage
Inline = 1 << 3, // inline function
Explicit = 1 << 4, // function declared `explicit`
Constexpr = 1 << 5, // constexpr function
Consteval = 1 << 6, // consteval function
ExplicitObject = 1 << 7, // function with explicit object parameter.
};

// -- Fundecl --
// This node represents a function declaration. Notice that the
// exception specification is actually made part of the function type.
struct Fundecl : Category<Category_code::Fundecl, Decl> {
virtual FunctionTraits traits() const = 0;
virtual Optional<Mapping> mapping() const = 0;
virtual const Parameter_list& parameters() const = 0;
virtual Optional<Fundecl> definition() const = 0;
};

// -- Concept --
struct Concept : Category<Category_code::Concept, Decl>, Parameterization<Expr> {
};

// -- Var --
// This represents a variable declaration. It is also used to
// represent a static data member.
Expand Down Expand Up @@ -2152,6 +2199,7 @@ namespace ipr {
virtual void visit(const Field&);
virtual void visit(const Fundecl&);
virtual void visit(const Template&);
virtual void visit(const Concept&);
virtual void visit(const Parameter&);
virtual void visit(const Parameter_list&);
virtual void visit(const Typedecl&);
Expand Down
1 change: 1 addition & 0 deletions include/ipr/node-category
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ Field, // ipr::Field
Bitfield, // ipr::Bitfield
Fundecl, // ipr::Fundecl
Template, // ipr::Template
Concept, // ipr::Concept
Parameter, // ipr::Parameter
Typedecl, // ipr::Typedecl
Var, // ipr::Var
Expand Down
1 change: 1 addition & 0 deletions include/ipr/synopsis
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ namespace ipr {
struct Bitfield; // bitfield
struct Fundecl; // function-declaration
struct Template; // template-declaration
struct Concept; // concept definition
struct Parameter; // function or template parameter
struct Typedecl; // declaration for a type
struct Var; // variable declaration
Expand Down
5 changes: 5 additions & 0 deletions src/traversal.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,11 @@ ipr::Visitor::visit(const Fundecl& d)
visit(as<Decl>(d));
}

void ipr::Visitor::visit(const Concept& d)
{
visit(as<Decl>(d));
}

void
ipr::Visitor::visit(const Parameter& d)
{
Expand Down
Loading