Made the following changes:
[oota-llvm.git] / include / llvm / Module.h
1 //===-- llvm/Module.h - C++ class to represent a VM module -------*- C++ -*--=//
2 //
3 // This file contains the declarations for the Module class that is used to 
4 // maintain all the information related to a VM module.
5 //
6 //===----------------------------------------------------------------------===//
7
8 #ifndef LLVM_MODULE_H
9 #define LLVM_MODULE_H
10
11 #include "llvm/Value.h"
12 #include "llvm/SymTabValue.h"
13 class Method;
14
15 class Module : public Value, public SymTabValue {
16 public:
17   typedef ValueHolder<Method, Module, Module> MethodListType;
18
19   // Method iterators...
20   typedef MethodListType::iterator iterator;
21   typedef MethodListType::const_iterator const_iterator;
22   typedef reverse_iterator<const_iterator> const_reverse_iterator;
23   typedef reverse_iterator<iterator>             reverse_iterator;
24 private:
25   MethodListType MethodList;     // The Methods
26
27 public:
28   Module();
29   ~Module();
30
31   // reduceApply - Apply the specified function to all of the methods in this 
32   // module.  The result values are or'd together and the result is returned.
33   //
34   bool reduceApply(bool (*Func)(Method*));
35   bool reduceApply(bool (*Func)(const Method*)) const;
36
37
38   // Get the underlying elements of the Module...
39   inline const MethodListType &getMethodList() const  { return MethodList; }
40   inline       MethodListType &getMethodList()        { return MethodList; }
41
42   //===--------------------------------------------------------------------===//
43   // Module iterator forwarding functions
44   //
45   inline iterator                begin()       { return MethodList.begin(); }
46   inline const_iterator          begin() const { return MethodList.begin(); }
47   inline iterator                end  ()       { return MethodList.end();   }
48   inline const_iterator          end  () const { return MethodList.end();   }
49
50   inline reverse_iterator       rbegin()       { return MethodList.rbegin(); }
51   inline const_reverse_iterator rbegin() const { return MethodList.rbegin(); }
52   inline reverse_iterator       rend  ()       { return MethodList.rend();   }
53   inline const_reverse_iterator rend  () const { return MethodList.rend();   }
54
55   inline unsigned                 size() const { return MethodList.size(); }
56   inline bool                    empty() const { return MethodList.empty(); }
57   inline const Method           *front() const { return MethodList.front(); }
58   inline       Method           *front()       { return MethodList.front(); }
59   inline const Method            *back() const { return MethodList.back(); }
60   inline       Method            *back()       { return MethodList.back(); }
61
62
63   // dropAllReferences() - This function causes all the subinstructions to "let
64   // go" of all references that they are maintaining.  This allows one to
65   // 'delete' a whole class at a time, even though there may be circular
66   // references... first all references are dropped, and all use counts go to
67   // zero.  Then everything is delete'd for real.  Note that no operations are
68   // valid on an object that has "dropped all references", except operator 
69   // delete.
70   //
71   void dropAllReferences();
72 };
73
74 #endif