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