1 //===-- Module.cpp - Implement the Module class ------------------*- C++ -*--=//
3 // This file implements the Module class for the VMCore library.
5 //===----------------------------------------------------------------------===//
7 #include "llvm/Module.h"
8 #include "llvm/Method.h"
9 #include "llvm/BasicBlock.h"
10 #include "llvm/InstrTypes.h"
11 #include "llvm/ValueHolderImpl.h"
12 #include "llvm/Support/STLExtras.h"
13 #include "llvm/Type.h"
15 // Instantiate Templates - This ugliness is the price we have to pay
16 // for having a DefHolderImpl.h file seperate from DefHolder.h! :(
18 template class ValueHolder<Method, Module, Module>;
21 : Value(Type::VoidTy, Value::ModuleVal, ""), SymTabValue(this),
22 MethodList(this, this) {
27 MethodList.delete_all();
28 MethodList.setParent(0);
32 // dropAllReferences() - This function causes all the subinstructions to "let
33 // go" of all references that they are maintaining. This allows one to
34 // 'delete' a whole class at a time, even though there may be circular
35 // references... first all references are dropped, and all use counts go to
36 // zero. Then everything is delete'd for real. Note that no operations are
37 // valid on an object that has "dropped all references", except operator
40 void Module::dropAllReferences() {
41 MethodListType::iterator MI = MethodList.begin();
42 for (; MI != MethodList.end(); ++MI)
43 (*MI)->dropAllReferences();
46 // reduceApply - Apply the specified function to all of the methods in this
47 // module. The result values are or'd together and the result is returned.
49 bool Module::reduceApply(bool (*Func)(Method*)) {
50 return reduce_apply_bool(begin(), end(), Func);
52 bool Module::reduceApply(bool (*Func)(const Method*)) const {
53 return reduce_apply_bool(begin(), end(), Func);