aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-02-09 04:36:50 +0000
committerChris Lattner <sabre@nondot.org>2004-02-09 04:36:50 +0000
commit037b8b70d04ce214464c89d2480811484f9ec13d (patch)
tree117c4b823f02af9d95172f79af55f45e12bbef98
parente3235afe0905b2c642c1823cc4b1f8be6890ece7 (diff)
downloadexternal_llvm-037b8b70d04ce214464c89d2480811484f9ec13d.zip
external_llvm-037b8b70d04ce214464c89d2480811484f9ec13d.tar.gz
external_llvm-037b8b70d04ce214464c89d2480811484f9ec13d.tar.bz2
Increase encapsulation of the StructType class, eliminating the getElementTypes() member
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11227 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/DerivedTypes.h24
1 files changed, 15 insertions, 9 deletions
diff --git a/include/llvm/DerivedTypes.h b/include/llvm/DerivedTypes.h
index 1ed6ee4..9fdff68 100644
--- a/include/llvm/DerivedTypes.h
+++ b/include/llvm/DerivedTypes.h
@@ -123,8 +123,7 @@ public:
class FunctionType : public DerivedType {
friend class TypeMap<FunctionValType, FunctionType>;
PATypeHandle ResultType;
- typedef std::vector<PATypeHandle> ParamTypes;
- ParamTypes ParamTys;
+ std::vector<PATypeHandle> ParamTys;
bool isVarArgs;
FunctionType(const FunctionType &); // Do not implement
@@ -153,7 +152,7 @@ public:
inline bool isVarArg() const { return isVarArgs; }
inline const Type *getReturnType() const { return ResultType; }
- typedef ParamTypes::const_iterator param_iterator;
+ typedef std::vector<PATypeHandle>::const_iterator param_iterator;
param_iterator param_begin() const { return ParamTys.begin(); }
param_iterator param_end() const { return ParamTys.end(); }
@@ -212,12 +211,9 @@ public:
};
-struct StructType : public CompositeType {
+class StructType : public CompositeType {
friend class TypeMap<StructValType, StructType>;
- typedef std::vector<PATypeHandle> ElementTypes;
-
-private:
- ElementTypes ETypes; // Element types of struct
+ std::vector<PATypeHandle> ETypes; // Element types of struct
StructType(const StructType &); // Do not implement
const StructType &operator=(const StructType &); // Do not implement
@@ -240,7 +236,17 @@ public:
/// StructType.
static StructType *get(const std::vector<const Type*> &Params);
- inline const ElementTypes &getElementTypes() const { return ETypes; }
+ // Iterator access to the elements
+ typedef std::vector<PATypeHandle>::const_iterator element_iterator;
+ element_iterator element_begin() const { return ETypes.begin(); }
+ element_iterator element_end() const { return ETypes.end(); }
+
+ // Random access to the elements
+ unsigned getNumElements() const { return ETypes.size(); }
+ const Type *getElementType(unsigned N) const {
+ assert(N < ETypes.size() && "Element number out of range!");
+ return ETypes[N];
+ }
virtual const Type *getContainedType(unsigned i) const {
return ETypes[i].get();