Skip to content

Commit

Permalink
Adjust item kind enums for TupleStructItems and TuplePatternItems
Browse files Browse the repository at this point in the history
gcc/rust/ChangeLog:

	* hir/tree/rust-hir-pattern.h
	(TupleStructItems::ItemType::RANGE): Rename to...
	(TupleStructItems::ItemType::RANGED): ...here.
	(TupleStructItems::ItemType::NO_RANGE): Rename to...
	(TupleStructItems::ItemType::MULTIPLE): ...here.

	(TuplePatternItems::TuplePatternItemType): Rename to...
	(TuplePatternItems::ItemType): ...here.

	: Handle renames.

	* backend/rust-compile-pattern.cc: Likewise.
	* typecheck/rust-hir-type-check-pattern.cc: Likewise.

Signed-off-by: Owen Avery <[email protected]>
  • Loading branch information
powerboat9 committed Nov 1, 2023
1 parent e489a69 commit db98b23
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 22 deletions.
8 changes: 4 additions & 4 deletions gcc/rust/backend/rust-compile-pattern.cc
Original file line number Diff line number Diff line change
Expand Up @@ -457,13 +457,13 @@ CompilePatternBindings::visit (HIR::TupleStructPattern &pattern)
std::unique_ptr<HIR::TupleStructItems> &items = pattern.get_items ();
switch (items->get_item_type ())
{
case HIR::TupleStructItems::RANGE: {
case HIR::TupleStructItems::RANGED: {
// TODO
rust_unreachable ();
}
break;

case HIR::TupleStructItems::NO_RANGE: {
case HIR::TupleStructItems::MULTIPLE: {
HIR::TupleStructItemsNoRange &items_no_range
= static_cast<HIR::TupleStructItemsNoRange &> (*items.get ());

Expand Down Expand Up @@ -667,7 +667,7 @@ CompilePatternLet::visit (HIR::TuplePattern &pattern)

switch (pattern.get_items ()->get_item_type ())
{
case HIR::TuplePatternItems::TuplePatternItemType::RANGED: {
case HIR::TuplePatternItems::ItemType::RANGED: {
size_t tuple_idx = 0;
auto &items
= static_cast<HIR::TuplePatternItemsRanged &> (*pattern.get_items ());
Expand Down Expand Up @@ -711,7 +711,7 @@ CompilePatternLet::visit (HIR::TuplePattern &pattern)

return;
}
case HIR::TuplePatternItems::TuplePatternItemType::MULTIPLE: {
case HIR::TuplePatternItems::ItemType::MULTIPLE: {
size_t tuple_idx = 0;
auto &items = static_cast<HIR::TuplePatternItemsMultiple &> (
*pattern.get_items ());
Expand Down
22 changes: 8 additions & 14 deletions gcc/rust/hir/tree/rust-hir-pattern.h
Original file line number Diff line number Diff line change
Expand Up @@ -783,8 +783,8 @@ class TupleStructItems : public FullVisitable
public:
enum ItemType
{
RANGE,
NO_RANGE
MULTIPLE,
RANGED,
};

virtual ~TupleStructItems () {}
Expand Down Expand Up @@ -852,7 +852,7 @@ class TupleStructItemsNoRange : public TupleStructItems
return patterns;
}

ItemType get_item_type () const override final { return ItemType::NO_RANGE; }
ItemType get_item_type () const override final { return ItemType::MULTIPLE; }

protected:
/* Use covariance to implement clone function as returning this object rather
Expand Down Expand Up @@ -931,7 +931,7 @@ class TupleStructItemsRange : public TupleStructItems
return upper_patterns;
}

ItemType get_item_type () const override final { return ItemType::RANGE; }
ItemType get_item_type () const override final { return ItemType::RANGED; }

protected:
/* Use covariance to implement clone function as returning this object rather
Expand Down Expand Up @@ -1014,7 +1014,7 @@ class TupleStructPattern : public Pattern
class TuplePatternItems : public FullVisitable
{
public:
enum TuplePatternItemType
enum ItemType
{
MULTIPLE,
RANGED,
Expand All @@ -1032,7 +1032,7 @@ class TuplePatternItems : public FullVisitable

virtual std::string as_string () const = 0;

virtual TuplePatternItemType get_item_type () const = 0;
virtual ItemType get_item_type () const = 0;

protected:
// pure virtual clone implementation
Expand Down Expand Up @@ -1077,10 +1077,7 @@ class TuplePatternItemsMultiple : public TuplePatternItems

void accept_vis (HIRFullVisitor &vis) override;

TuplePatternItemType get_item_type () const override
{
return TuplePatternItemType::MULTIPLE;
}
ItemType get_item_type () const override { return ItemType::MULTIPLE; }

std::vector<std::unique_ptr<Pattern>> &get_patterns () { return patterns; }
const std::vector<std::unique_ptr<Pattern>> &get_patterns () const
Expand Down Expand Up @@ -1147,10 +1144,7 @@ class TuplePatternItemsRanged : public TuplePatternItems

void accept_vis (HIRFullVisitor &vis) override;

TuplePatternItemType get_item_type () const override
{
return TuplePatternItemType::RANGED;
}
ItemType get_item_type () const override { return ItemType::RANGED; }

std::vector<std::unique_ptr<Pattern>> &get_lower_patterns ()
{
Expand Down
8 changes: 4 additions & 4 deletions gcc/rust/typecheck/rust-hir-type-check-pattern.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ TypeCheckPattern::visit (HIR::TupleStructPattern &pattern)
std::unique_ptr<HIR::TupleStructItems> &items = pattern.get_items ();
switch (items->get_item_type ())
{
case HIR::TupleStructItems::RANGE: {
case HIR::TupleStructItems::RANGED: {
// TODO
rust_unreachable ();
}
break;

case HIR::TupleStructItems::NO_RANGE: {
case HIR::TupleStructItems::MULTIPLE: {
HIR::TupleStructItemsNoRange &items_no_range
= static_cast<HIR::TupleStructItemsNoRange &> (*items.get ());

Expand Down Expand Up @@ -297,7 +297,7 @@ TypeCheckPattern::visit (HIR::TuplePattern &pattern)
std::unique_ptr<HIR::TuplePatternItems> items;
switch (pattern.get_items ()->get_item_type ())
{
case HIR::TuplePatternItems::TuplePatternItemType::MULTIPLE: {
case HIR::TuplePatternItems::ItemType::MULTIPLE: {
HIR::TuplePatternItemsMultiple &ref
= *static_cast<HIR::TuplePatternItemsMultiple *> (
pattern.get_items ().get ());
Expand Down Expand Up @@ -336,7 +336,7 @@ TypeCheckPattern::visit (HIR::TuplePattern &pattern)
}
break;

case HIR::TuplePatternItems::TuplePatternItemType::RANGED: {
case HIR::TuplePatternItems::ItemType::RANGED: {
// HIR::TuplePatternItemsRanged &ref
// = *static_cast<HIR::TuplePatternItemsRanged *> (
// pattern.get_items ().get ());
Expand Down

0 comments on commit db98b23

Please sign in to comment.