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"
14 // Instantiate Templates - This ugliness is the price we have to pay
15 // for having a DefHolderImpl.h file seperate from DefHolder.h! :(
17 template class ValueHolder<Method, Module, Module>;
20 : Value(0/*TODO: REAL TYPE*/, Value::ModuleVal, ""), SymTabValue(this),
21 MethodList(this, this) {
26 MethodList.delete_all();
27 MethodList.setParent(0);
31 // dropAllReferences() - This function causes all the subinstructions to "let
32 // go" of all references that they are maintaining. This allows one to
33 // 'delete' a whole class at a time, even though there may be circular
34 // references... first all references are dropped, and all use counts go to
35 // zero. Then everything is delete'd for real. Note that no operations are
36 // valid on an object that has "dropped all references", except operator
39 void Module::dropAllReferences() {
40 MethodListType::iterator MI = MethodList.begin();
41 for (; MI != MethodList.end(); ++MI)
42 (*MI)->dropAllReferences();
45 // reduceApply - Apply the specified function to all of the methods in this
46 // module. The result values are or'd together and the result is returned.
48 bool Module::reduceApply(bool (*Func)(Method*)) {
49 return reduce_apply_bool(begin(), end(), Func);
51 bool Module::reduceApply(bool (*Func)(const Method*)) const {
52 return reduce_apply_bool(begin(), end(), Func);