Skip to content

Commit cf94fd8

Browse files
committed
single_ast_node: Add TYPE kind
1 parent e8b9587 commit cf94fd8

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

gcc/rust/ast/rust-ast.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,6 +1515,7 @@ class SingleASTNode
15151515
TRAIT,
15161516
IMPL,
15171517
TRAIT_IMPL,
1518+
TYPE,
15181519
};
15191520

15201521
private:
@@ -1528,6 +1529,7 @@ class SingleASTNode
15281529
std::unique_ptr<TraitItem> trait_item;
15291530
std::unique_ptr<InherentImplItem> impl_item;
15301531
std::unique_ptr<TraitImplItem> trait_impl_item;
1532+
std::unique_ptr<Type> type;
15311533

15321534
public:
15331535
SingleASTNode (std::unique_ptr<Expr> expr)
@@ -1558,6 +1560,10 @@ class SingleASTNode
15581560
: kind (TRAIT_IMPL), trait_impl_item (std::move (trait_impl_item))
15591561
{}
15601562

1563+
SingleASTNode (std::unique_ptr<Type> type)
1564+
: kind (TYPE), type (std::move (type))
1565+
{}
1566+
15611567
SingleASTNode (SingleASTNode const &other)
15621568
{
15631569
kind = other.kind;
@@ -1590,6 +1596,10 @@ class SingleASTNode
15901596
case TRAIT_IMPL:
15911597
trait_impl_item = other.trait_impl_item->clone_trait_impl_item ();
15921598
break;
1599+
1600+
case TYPE:
1601+
type = other.type->clone_type ();
1602+
break;
15931603
}
15941604
}
15951605

@@ -1625,6 +1635,10 @@ class SingleASTNode
16251635
case TRAIT_IMPL:
16261636
trait_impl_item = other.trait_impl_item->clone_trait_impl_item ();
16271637
break;
1638+
1639+
case TYPE:
1640+
type = other.type->clone_type ();
1641+
break;
16281642
}
16291643
return *this;
16301644
}
@@ -1699,6 +1713,12 @@ class SingleASTNode
16991713
return std::move (trait_impl_item);
17001714
}
17011715

1716+
std::unique_ptr<Type> take_type ()
1717+
{
1718+
rust_assert (!is_error ());
1719+
return std::move (type);
1720+
}
1721+
17021722
void accept_vis (ASTVisitor &vis)
17031723
{
17041724
switch (kind)
@@ -1730,6 +1750,10 @@ class SingleASTNode
17301750
case TRAIT_IMPL:
17311751
trait_impl_item->accept_vis (vis);
17321752
break;
1753+
1754+
case TYPE:
1755+
type->accept_vis (vis);
1756+
break;
17331757
}
17341758
}
17351759

@@ -1751,6 +1775,8 @@ class SingleASTNode
17511775
return impl_item == nullptr;
17521776
case TRAIT_IMPL:
17531777
return trait_impl_item == nullptr;
1778+
case TYPE:
1779+
return type == nullptr;
17541780
}
17551781

17561782
gcc_unreachable ();
@@ -1775,6 +1801,8 @@ class SingleASTNode
17751801
return "Impl Item: " + impl_item->as_string ();
17761802
case TRAIT_IMPL:
17771803
return "Trait Impl Item: " + impl_item->as_string ();
1804+
case TYPE:
1805+
return "Type: " + type->as_string ();
17781806
}
17791807

17801808
gcc_unreachable ();

0 commit comments

Comments
 (0)