1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-21 12:02:58 +02:00

add some helper methods to make the type more uniform.

llvm-svn: 157554
This commit is contained in:
Chris Lattner 2012-05-28 01:29:59 +00:00
parent b051169784
commit 6cdc78cdf4

View File

@ -120,6 +120,14 @@ public:
return Val.template get<VecTy*>()->front();
}
EltTy back() const {
assert(!empty() && "vector empty");
if (EltTy V = Val.template dyn_cast<EltTy>())
return V;
return Val.template get<VecTy*>()->back();
}
void push_back(EltTy NewVal) {
assert(NewVal != 0 && "Can't add a null value");
@ -139,6 +147,15 @@ public:
Val.template get<VecTy*>()->push_back(NewVal);
}
void pop_back() {
// If we have a single value, convert to empty.
if (Val.template is<EltTy>())
Val = (EltTy)0;
else if (VecTy *Vec = Val.template get<VecTy*>())
Vec->pop_back();
}
void clear() {
// If we have a single value, convert to empty.
if (Val.template is<EltTy>()) {