Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Base type of an enum #263

Merged
merged 1 commit into from
May 15, 2022
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
2 changes: 2 additions & 0 deletions include/ipr/impl
Original file line number Diff line number Diff line change
Expand Up @@ -1857,6 +1857,7 @@ namespace ipr::impl {
};

struct Enum : impl::Type<ipr::Enum> {
Optional<ipr::Type> underlying;
homogeneous_region<impl::Enumerator, obj_sequence> body;
Optional<ipr::Name> id;
const Kind enum_kind;
Expand All @@ -1867,6 +1868,7 @@ namespace ipr::impl {
const ipr::Region& region() const final;
const Sequence<ipr::Enumerator>& members() const final;
Kind kind() const final;
Optional<ipr::Type> base() const final { return underlying; }
impl::Enumerator* add_member(const ipr::Name&);
};

Expand Down
3 changes: 3 additions & 0 deletions include/ipr/interface
Original file line number Diff line number Diff line change
Expand Up @@ -707,12 +707,15 @@ namespace ipr {
// An enumeration is an object-type whose members are named constants
// the definitions of which as part of the definition of the enumeration
// itself. By historical accident, enumerators are not "properly scoped".
// The underlying type of the enumeration is given by `base()`, when explicitly
// specified or inferred from the enumerator list.
struct Enum : Category<Category_code::Enum, Udt<Enumerator>> {
enum class Kind : std::uint8_t { // The kind of enum.
Legacy, // traditional C-style enum
Scoped // scoped enum (C++11)
};
virtual Kind kind() const = 0;
virtual Optional<Type> base() const = 0;
};

// -- Auto --
Expand Down