diff options
author | Chris Lattner <sabre@nondot.org> | 2001-09-10 07:58:01 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2001-09-10 07:58:01 +0000 |
commit | 70cc3397f84c2e1fd69c059a0ef89e398e847b00 (patch) | |
tree | ca2156daf75e4abf788d92925bdce4063da36e58 /include/llvm/Module.h | |
parent | 7720c8e1a7a252e983e3f3e7f841d7901dfea80c (diff) |
Implement global variable support
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@530 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Module.h')
-rw-r--r-- | include/llvm/Module.h | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/include/llvm/Module.h b/include/llvm/Module.h index 866f5e0e9e..bf710d1223 100644 --- a/include/llvm/Module.h +++ b/include/llvm/Module.h @@ -12,17 +12,27 @@ #include "llvm/SymTabValue.h" #include "llvm/ValueHolder.h" class Method; +class GlobalVariable; class Module : public Value, public SymTabValue { public: + typedef ValueHolder<GlobalVariable, Module, Module> GlobalListType; typedef ValueHolder<Method, Module, Module> MethodListType; + // Global Variable iterators... + typedef GlobalListType::iterator giterator; + typedef GlobalListType::const_iterator const_giterator; + typedef reverse_iterator<giterator> reverse_giterator; + typedef reverse_iterator<const_giterator> const_reverse_giterator; + // Method iterators... - typedef MethodListType::iterator iterator; - typedef MethodListType::const_iterator const_iterator; + typedef MethodListType::iterator iterator; + typedef MethodListType::const_iterator const_iterator; typedef reverse_iterator<const_iterator> const_reverse_iterator; typedef reverse_iterator<iterator> reverse_iterator; + private: + GlobalListType GlobalList; // The Global Variables MethodListType MethodList; // The Methods public: @@ -32,17 +42,40 @@ public: // reduceApply - Apply the specified function to all of the methods in this // module. The result values are or'd together and the result is returned. // + bool reduceApply(bool (*Func)(GlobalVariable*)); + bool reduceApply(bool (*Func)(const GlobalVariable*)) const; bool reduceApply(bool (*Func)(Method*)); bool reduceApply(bool (*Func)(const Method*)) const; // Get the underlying elements of the Module... + inline const GlobalListType &getGlobalList() const { return GlobalList; } + inline GlobalListType &getGlobalList() { return GlobalList; } inline const MethodListType &getMethodList() const { return MethodList; } inline MethodListType &getMethodList() { return MethodList; } //===--------------------------------------------------------------------===// // Module iterator forwarding functions // + inline giterator gbegin() { return GlobalList.begin(); } + inline const_giterator gbegin() const { return GlobalList.begin(); } + inline giterator gend () { return GlobalList.end(); } + inline const_giterator gend () const { return GlobalList.end(); } + + inline reverse_giterator grbegin() { return GlobalList.rbegin(); } + inline const_reverse_giterator grbegin() const { return GlobalList.rbegin(); } + inline reverse_giterator grend () { return GlobalList.rend(); } + inline const_reverse_giterator grend () const { return GlobalList.rend(); } + + inline unsigned gsize() const { return GlobalList.size(); } + inline bool gempty() const { return GlobalList.empty(); } + inline const GlobalVariable *gfront() const { return GlobalList.front(); } + inline GlobalVariable *gfront() { return GlobalList.front(); } + inline const GlobalVariable *gback() const { return GlobalList.back(); } + inline GlobalVariable *gback() { return GlobalList.back(); } + + + inline iterator begin() { return MethodList.begin(); } inline const_iterator begin() const { return MethodList.begin(); } inline iterator end () { return MethodList.end(); } |