2003-10-13 11:32:08 +08:00
|
|
|
//===-- Module.cpp - Implement the Module class ---------------------------===//
|
2005-04-22 07:48:37 +08:00
|
|
|
//
|
2003-10-21 03:43:21 +08:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-30 04:36:04 +08:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-22 07:48:37 +08:00
|
|
|
//
|
2003-10-21 03:43:21 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2001-06-07 04:29:01 +08:00
|
|
|
//
|
|
|
|
// This file implements the Module class for the VMCore library.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/Module.h"
|
2001-06-30 12:35:40 +08:00
|
|
|
#include "llvm/InstrTypes.h"
|
2002-04-29 03:55:58 +08:00
|
|
|
#include "llvm/Constants.h"
|
2002-03-29 11:44:18 +08:00
|
|
|
#include "llvm/DerivedTypes.h"
|
2009-07-02 00:58:40 +08:00
|
|
|
#include "llvm/LLVMContext.h"
|
2004-09-02 06:55:40 +08:00
|
|
|
#include "llvm/ADT/STLExtras.h"
|
2006-05-18 10:10:31 +08:00
|
|
|
#include "llvm/ADT/StringExtras.h"
|
2004-09-02 06:55:40 +08:00
|
|
|
#include "llvm/Support/LeakDetector.h"
|
2002-06-26 00:13:24 +08:00
|
|
|
#include "SymbolTableListTraitsImpl.h"
|
2007-01-06 15:24:44 +08:00
|
|
|
#include "llvm/TypeSymbolTable.h"
|
2002-06-26 00:13:24 +08:00
|
|
|
#include <algorithm>
|
2003-08-31 08:19:28 +08:00
|
|
|
#include <cstdarg>
|
2006-05-18 10:10:31 +08:00
|
|
|
#include <cstdlib>
|
2003-11-22 04:23:48 +08:00
|
|
|
using namespace llvm;
|
2003-11-12 06:41:34 +08:00
|
|
|
|
2003-12-31 16:43:01 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2004-04-22 02:27:56 +08:00
|
|
|
// Methods to implement the globals and functions lists.
|
2003-12-31 16:43:01 +08:00
|
|
|
//
|
|
|
|
|
2005-01-30 08:09:23 +08:00
|
|
|
GlobalVariable *ilist_traits<GlobalVariable>::createSentinel() {
|
2009-07-09 03:03:57 +08:00
|
|
|
GlobalVariable *Ret = new GlobalVariable(getGlobalContext(), Type::Int32Ty,
|
|
|
|
false, GlobalValue::ExternalLinkage);
|
2002-09-09 02:59:35 +08:00
|
|
|
// This should not be garbage monitored.
|
|
|
|
LeakDetector::removeGarbageObject(Ret);
|
|
|
|
return Ret;
|
2002-06-26 00:13:24 +08:00
|
|
|
}
|
2007-04-25 22:27:10 +08:00
|
|
|
GlobalAlias *ilist_traits<GlobalAlias>::createSentinel() {
|
2009-07-09 03:03:57 +08:00
|
|
|
GlobalAlias *Ret = new GlobalAlias(Type::Int32Ty,
|
2008-01-29 20:09:55 +08:00
|
|
|
GlobalValue::ExternalLinkage);
|
2007-04-25 22:27:10 +08:00
|
|
|
// This should not be garbage monitored.
|
|
|
|
LeakDetector::removeGarbageObject(Ret);
|
|
|
|
return Ret;
|
|
|
|
}
|
2002-06-26 00:13:24 +08:00
|
|
|
|
|
|
|
// Explicit instantiations of SymbolTableListTraits since some of the methods
|
2006-01-24 12:13:11 +08:00
|
|
|
// are not in the public header file.
|
2007-04-17 11:26:42 +08:00
|
|
|
template class SymbolTableListTraits<GlobalVariable, Module>;
|
|
|
|
template class SymbolTableListTraits<Function, Module>;
|
2007-04-25 22:27:10 +08:00
|
|
|
template class SymbolTableListTraits<GlobalAlias, Module>;
|
2001-06-07 04:29:01 +08:00
|
|
|
|
2003-12-31 16:43:01 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Primitive Module methods.
|
|
|
|
//
|
2001-10-13 14:58:40 +08:00
|
|
|
|
2009-07-02 07:13:44 +08:00
|
|
|
Module::Module(const std::string &MID, LLVMContext& C)
|
2009-07-02 00:58:40 +08:00
|
|
|
: Context(C), ModuleID(MID), DataLayout("") {
|
2007-02-06 04:47:22 +08:00
|
|
|
ValSymTab = new ValueSymbolTable();
|
2007-01-06 15:24:44 +08:00
|
|
|
TypeSymTab = new TypeSymbolTable();
|
2001-06-07 04:29:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Module::~Module() {
|
|
|
|
dropAllReferences();
|
2002-06-26 00:13:24 +08:00
|
|
|
GlobalList.clear();
|
|
|
|
FunctionList.clear();
|
2007-04-25 22:27:10 +08:00
|
|
|
AliasList.clear();
|
2004-07-26 02:08:57 +08:00
|
|
|
LibraryList.clear();
|
2007-01-06 15:24:44 +08:00
|
|
|
delete ValSymTab;
|
|
|
|
delete TypeSymTab;
|
2001-06-07 04:29:01 +08:00
|
|
|
}
|
|
|
|
|
2006-05-18 10:10:31 +08:00
|
|
|
/// Target endian information...
|
|
|
|
Module::Endianness Module::getEndianness() const {
|
|
|
|
std::string temp = DataLayout;
|
2006-05-18 13:46:08 +08:00
|
|
|
Module::Endianness ret = AnyEndianness;
|
2006-05-18 10:10:31 +08:00
|
|
|
|
2006-05-18 13:46:08 +08:00
|
|
|
while (!temp.empty()) {
|
2006-05-18 10:10:31 +08:00
|
|
|
std::string token = getToken(temp, "-");
|
|
|
|
|
|
|
|
if (token[0] == 'e') {
|
2006-05-18 13:46:08 +08:00
|
|
|
ret = LittleEndian;
|
2006-05-18 10:10:31 +08:00
|
|
|
} else if (token[0] == 'E') {
|
2006-05-18 13:46:08 +08:00
|
|
|
ret = BigEndian;
|
2006-05-18 10:10:31 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-18 13:46:08 +08:00
|
|
|
return ret;
|
2006-05-18 10:10:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Target Pointer Size information...
|
|
|
|
Module::PointerSize Module::getPointerSize() const {
|
|
|
|
std::string temp = DataLayout;
|
2006-05-18 13:46:08 +08:00
|
|
|
Module::PointerSize ret = AnyPointerSize;
|
2006-05-18 10:10:31 +08:00
|
|
|
|
2006-05-18 13:46:08 +08:00
|
|
|
while (!temp.empty()) {
|
2006-05-18 10:10:31 +08:00
|
|
|
std::string token = getToken(temp, "-");
|
|
|
|
char signal = getToken(token, ":")[0];
|
|
|
|
|
|
|
|
if (signal == 'p') {
|
|
|
|
int size = atoi(getToken(token, ":").c_str());
|
|
|
|
if (size == 32)
|
2006-05-18 13:46:08 +08:00
|
|
|
ret = Pointer32;
|
2006-05-18 10:10:31 +08:00
|
|
|
else if (size == 64)
|
2006-05-18 13:46:08 +08:00
|
|
|
ret = Pointer64;
|
2006-05-18 10:10:31 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-18 13:46:08 +08:00
|
|
|
return ret;
|
2006-05-18 10:10:31 +08:00
|
|
|
}
|
|
|
|
|
2009-03-07 06:04:43 +08:00
|
|
|
/// getNamedValue - Return the first global value in the module with
|
|
|
|
/// the specified name, of arbitrary type. This method returns null
|
|
|
|
/// if a global with the specified name is not found.
|
|
|
|
GlobalValue *Module::getNamedValue(const std::string &Name) const {
|
|
|
|
return cast_or_null<GlobalValue>(getValueSymbolTable().lookup(Name));
|
|
|
|
}
|
|
|
|
|
|
|
|
GlobalValue *Module::getNamedValue(const char *Name) const {
|
|
|
|
llvm::Value *V = getValueSymbolTable().lookup(Name, Name+strlen(Name));
|
|
|
|
return cast_or_null<GlobalValue>(V);
|
|
|
|
}
|
|
|
|
|
2003-12-31 16:43:01 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Methods for easy access to the functions in the module.
|
|
|
|
//
|
|
|
|
|
2007-02-06 04:47:22 +08:00
|
|
|
// getOrInsertFunction - Look up the specified function in the module symbol
|
|
|
|
// table. If it does not exist, add a prototype for the function and return
|
|
|
|
// it. This is nice because it allows most passes to get away with not handling
|
|
|
|
// the symbol table directly for this common task.
|
|
|
|
//
|
2007-01-07 16:09:25 +08:00
|
|
|
Constant *Module::getOrInsertFunction(const std::string &Name,
|
2009-01-05 06:54:40 +08:00
|
|
|
const FunctionType *Ty,
|
|
|
|
AttrListPtr AttributeList) {
|
2007-02-06 04:47:22 +08:00
|
|
|
// See if we have a definition for the specified function already.
|
2009-03-07 06:04:43 +08:00
|
|
|
GlobalValue *F = getNamedValue(Name);
|
2007-01-07 16:09:25 +08:00
|
|
|
if (F == 0) {
|
2007-02-06 04:47:22 +08:00
|
|
|
// Nope, add it
|
2008-04-07 04:25:17 +08:00
|
|
|
Function *New = Function::Create(Ty, GlobalVariable::ExternalLinkage, Name);
|
2009-01-05 06:54:40 +08:00
|
|
|
if (!New->isIntrinsic()) // Intrinsics get attrs set on construction
|
|
|
|
New->setAttributes(AttributeList);
|
2002-03-29 11:44:18 +08:00
|
|
|
FunctionList.push_back(New);
|
2007-01-07 16:09:25 +08:00
|
|
|
return New; // Return the new prototype.
|
|
|
|
}
|
|
|
|
|
|
|
|
// Okay, the function exists. Does it have externally visible linkage?
|
2009-01-16 04:18:42 +08:00
|
|
|
if (F->hasLocalLinkage()) {
|
2008-06-28 05:25:24 +08:00
|
|
|
// Clear the function's name.
|
|
|
|
F->setName("");
|
2007-01-07 16:09:25 +08:00
|
|
|
// Retry, now there won't be a conflict.
|
2008-06-28 05:25:24 +08:00
|
|
|
Constant *NewF = getOrInsertFunction(Name, Ty);
|
|
|
|
F->setName(&Name[0], Name.size());
|
|
|
|
return NewF;
|
2002-03-29 11:44:18 +08:00
|
|
|
}
|
2007-01-07 16:09:25 +08:00
|
|
|
|
|
|
|
// If the function exists but has the wrong type, return a bitcast to the
|
|
|
|
// right type.
|
2007-12-17 09:12:55 +08:00
|
|
|
if (F->getType() != PointerType::getUnqual(Ty))
|
|
|
|
return ConstantExpr::getBitCast(F, PointerType::getUnqual(Ty));
|
2007-01-07 16:09:25 +08:00
|
|
|
|
|
|
|
// Otherwise, we just found the existing function or a prototype.
|
|
|
|
return F;
|
2002-03-29 11:44:18 +08:00
|
|
|
}
|
|
|
|
|
2009-02-05 09:49:45 +08:00
|
|
|
Constant *Module::getOrInsertTargetIntrinsic(const std::string &Name,
|
|
|
|
const FunctionType *Ty,
|
|
|
|
AttrListPtr AttributeList) {
|
|
|
|
// See if we have a definition for the specified function already.
|
2009-03-07 06:04:43 +08:00
|
|
|
GlobalValue *F = getNamedValue(Name);
|
2009-02-05 09:49:45 +08:00
|
|
|
if (F == 0) {
|
|
|
|
// Nope, add it
|
|
|
|
Function *New = Function::Create(Ty, GlobalVariable::ExternalLinkage, Name);
|
|
|
|
New->setAttributes(AttributeList);
|
|
|
|
FunctionList.push_back(New);
|
|
|
|
return New; // Return the new prototype.
|
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise, we just found the existing function or a prototype.
|
|
|
|
return F;
|
|
|
|
}
|
|
|
|
|
2009-01-05 06:54:40 +08:00
|
|
|
Constant *Module::getOrInsertFunction(const std::string &Name,
|
|
|
|
const FunctionType *Ty) {
|
|
|
|
AttrListPtr AttributeList = AttrListPtr::get((AttributeWithIndex *)0, 0);
|
|
|
|
return getOrInsertFunction(Name, Ty, AttributeList);
|
|
|
|
}
|
|
|
|
|
2003-08-31 08:19:28 +08:00
|
|
|
// getOrInsertFunction - Look up the specified function in the module symbol
|
|
|
|
// table. If it does not exist, add a prototype for the function and return it.
|
|
|
|
// This version of the method takes a null terminated list of function
|
|
|
|
// arguments, which makes it easier for clients to use.
|
|
|
|
//
|
2007-01-07 16:09:25 +08:00
|
|
|
Constant *Module::getOrInsertFunction(const std::string &Name,
|
2009-01-05 06:54:40 +08:00
|
|
|
AttrListPtr AttributeList,
|
2003-08-31 08:19:28 +08:00
|
|
|
const Type *RetTy, ...) {
|
|
|
|
va_list Args;
|
|
|
|
va_start(Args, RetTy);
|
|
|
|
|
|
|
|
// Build the list of argument types...
|
|
|
|
std::vector<const Type*> ArgTys;
|
|
|
|
while (const Type *ArgTy = va_arg(Args, const Type*))
|
|
|
|
ArgTys.push_back(ArgTy);
|
|
|
|
|
|
|
|
va_end(Args);
|
|
|
|
|
|
|
|
// Build the function type and chain to the other getOrInsertFunction...
|
2009-01-05 06:54:40 +08:00
|
|
|
return getOrInsertFunction(Name, FunctionType::get(RetTy, ArgTys, false),
|
|
|
|
AttributeList);
|
2003-08-31 08:19:28 +08:00
|
|
|
}
|
|
|
|
|
2009-01-05 06:54:40 +08:00
|
|
|
Constant *Module::getOrInsertFunction(const std::string &Name,
|
|
|
|
const Type *RetTy, ...) {
|
|
|
|
va_list Args;
|
|
|
|
va_start(Args, RetTy);
|
|
|
|
|
|
|
|
// Build the list of argument types...
|
|
|
|
std::vector<const Type*> ArgTys;
|
|
|
|
while (const Type *ArgTy = va_arg(Args, const Type*))
|
|
|
|
ArgTys.push_back(ArgTy);
|
|
|
|
|
|
|
|
va_end(Args);
|
|
|
|
|
|
|
|
// Build the function type and chain to the other getOrInsertFunction...
|
|
|
|
return getOrInsertFunction(Name, FunctionType::get(RetTy, ArgTys, false),
|
|
|
|
AttrListPtr::get((AttributeWithIndex *)0, 0));
|
|
|
|
}
|
2003-08-31 08:19:28 +08:00
|
|
|
|
2002-03-29 11:44:18 +08:00
|
|
|
// getFunction - Look up the specified function in the module symbol table.
|
|
|
|
// If it does not exist, return null.
|
|
|
|
//
|
2007-02-06 04:47:22 +08:00
|
|
|
Function *Module::getFunction(const std::string &Name) const {
|
2009-03-07 06:04:43 +08:00
|
|
|
return dyn_cast_or_null<Function>(getNamedValue(Name));
|
2002-11-09 04:34:02 +08:00
|
|
|
}
|
|
|
|
|
2008-06-28 05:09:10 +08:00
|
|
|
Function *Module::getFunction(const char *Name) const {
|
2009-03-07 06:04:43 +08:00
|
|
|
return dyn_cast_or_null<Function>(getNamedValue(Name));
|
2008-06-28 05:09:10 +08:00
|
|
|
}
|
|
|
|
|
2003-12-31 16:43:01 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Methods for easy access to the global variables in the module.
|
|
|
|
//
|
|
|
|
|
|
|
|
/// getGlobalVariable - Look up the specified global variable in the module
|
2005-12-05 13:30:21 +08:00
|
|
|
/// symbol table. If it does not exist, return null. The type argument
|
|
|
|
/// should be the underlying type of the global, i.e., it should not have
|
|
|
|
/// the top-level PointerType, which represents the address of the global.
|
2009-01-16 04:18:42 +08:00
|
|
|
/// If AllowLocal is set to true, this function will return types that
|
|
|
|
/// have an local. By default, these types are not returned.
|
2003-12-31 16:43:01 +08:00
|
|
|
///
|
2005-04-22 07:48:37 +08:00
|
|
|
GlobalVariable *Module::getGlobalVariable(const std::string &Name,
|
2009-01-16 04:18:42 +08:00
|
|
|
bool AllowLocal) const {
|
2009-03-07 06:04:43 +08:00
|
|
|
if (GlobalVariable *Result =
|
|
|
|
dyn_cast_or_null<GlobalVariable>(getNamedValue(Name)))
|
|
|
|
if (AllowLocal || !Result->hasLocalLinkage())
|
2003-12-31 16:43:01 +08:00
|
|
|
return Result;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-11-06 07:42:27 +08:00
|
|
|
/// getOrInsertGlobal - Look up the specified global in the module symbol table.
|
|
|
|
/// 1. If it does not exist, add a declaration of the global and return it.
|
|
|
|
/// 2. Else, the global exists but has the wrong type: return the function
|
|
|
|
/// with a constantexpr cast to the right type.
|
|
|
|
/// 3. Finally, if the existing global is the correct delclaration, return the
|
|
|
|
/// existing global.
|
2008-11-05 06:51:24 +08:00
|
|
|
Constant *Module::getOrInsertGlobal(const std::string &Name, const Type *Ty) {
|
|
|
|
// See if we have a definition for the specified global already.
|
2009-03-07 06:04:43 +08:00
|
|
|
GlobalVariable *GV = dyn_cast_or_null<GlobalVariable>(getNamedValue(Name));
|
2008-11-05 06:51:24 +08:00
|
|
|
if (GV == 0) {
|
|
|
|
// Nope, add it
|
|
|
|
GlobalVariable *New =
|
2009-07-09 03:03:57 +08:00
|
|
|
new GlobalVariable(*this, Ty, false, GlobalVariable::ExternalLinkage,
|
|
|
|
0, Name);
|
|
|
|
return New; // Return the new declaration.
|
2008-11-05 06:51:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// If the variable exists but has the wrong type, return a bitcast to the
|
|
|
|
// right type.
|
|
|
|
if (GV->getType() != PointerType::getUnqual(Ty))
|
|
|
|
return ConstantExpr::getBitCast(GV, PointerType::getUnqual(Ty));
|
|
|
|
|
|
|
|
// Otherwise, we just found the existing function or a prototype.
|
|
|
|
return GV;
|
|
|
|
}
|
|
|
|
|
2007-04-25 22:27:10 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Methods for easy access to the global variables in the module.
|
|
|
|
//
|
|
|
|
|
|
|
|
// getNamedAlias - Look up the specified global in the module symbol table.
|
|
|
|
// If it does not exist, return null.
|
|
|
|
//
|
|
|
|
GlobalAlias *Module::getNamedAlias(const std::string &Name) const {
|
2009-03-07 06:04:43 +08:00
|
|
|
return dyn_cast_or_null<GlobalAlias>(getNamedValue(Name));
|
2007-04-25 22:27:10 +08:00
|
|
|
}
|
|
|
|
|
2003-12-31 16:43:01 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Methods for easy access to the types in the module.
|
|
|
|
//
|
|
|
|
|
2002-11-09 04:34:02 +08:00
|
|
|
|
2003-12-31 15:09:33 +08:00
|
|
|
// addTypeName - Insert an entry in the symbol table mapping Str to Type. If
|
|
|
|
// there is already an entry for this name, true is returned and the symbol
|
|
|
|
// table is not modified.
|
|
|
|
//
|
|
|
|
bool Module::addTypeName(const std::string &Name, const Type *Ty) {
|
2007-01-06 15:24:44 +08:00
|
|
|
TypeSymbolTable &ST = getTypeSymbolTable();
|
2003-12-31 15:09:33 +08:00
|
|
|
|
2007-01-06 15:24:44 +08:00
|
|
|
if (ST.lookup(Name)) return true; // Already in symtab...
|
2005-04-22 07:48:37 +08:00
|
|
|
|
2003-12-31 15:09:33 +08:00
|
|
|
// Not in symbol table? Set the name with the Symtab as an argument so the
|
|
|
|
// type knows what to update...
|
2004-07-11 00:37:42 +08:00
|
|
|
ST.insert(Name, Ty);
|
2003-12-31 15:09:33 +08:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// getTypeByName - Return the type with the specified name in this module, or
|
|
|
|
/// null if there is none by that name.
|
|
|
|
const Type *Module::getTypeByName(const std::string &Name) const {
|
2007-01-06 15:24:44 +08:00
|
|
|
const TypeSymbolTable &ST = getTypeSymbolTable();
|
|
|
|
return cast_or_null<Type>(ST.lookup(Name));
|
2003-12-31 15:09:33 +08:00
|
|
|
}
|
2002-11-09 04:34:02 +08:00
|
|
|
|
2002-04-14 02:58:33 +08:00
|
|
|
// getTypeName - If there is at least one entry in the symbol table for the
|
|
|
|
// specified type, return it.
|
|
|
|
//
|
2003-12-31 15:09:33 +08:00
|
|
|
std::string Module::getTypeName(const Type *Ty) const {
|
2007-01-06 15:24:44 +08:00
|
|
|
const TypeSymbolTable &ST = getTypeSymbolTable();
|
2002-04-14 02:58:33 +08:00
|
|
|
|
2007-01-06 15:24:44 +08:00
|
|
|
TypeSymbolTable::const_iterator TI = ST.begin();
|
|
|
|
TypeSymbolTable::const_iterator TE = ST.end();
|
2004-05-25 16:52:20 +08:00
|
|
|
if ( TI == TE ) return ""; // No names for types
|
2002-04-14 02:58:33 +08:00
|
|
|
|
2004-05-25 16:52:20 +08:00
|
|
|
while (TI != TE && TI->second != Ty)
|
2002-04-14 02:58:33 +08:00
|
|
|
++TI;
|
|
|
|
|
|
|
|
if (TI != TE) // Must have found an entry!
|
|
|
|
return TI->first;
|
|
|
|
return ""; // Must not have found anything...
|
|
|
|
}
|
|
|
|
|
2003-12-31 16:43:01 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Other module related stuff.
|
|
|
|
//
|
|
|
|
|
|
|
|
|
2002-08-18 07:32:47 +08:00
|
|
|
// dropAllReferences() - This function causes all the subelementss to "let go"
|
|
|
|
// of all references that they are maintaining. This allows one to 'delete' a
|
|
|
|
// whole module at a time, even though there may be circular references... first
|
|
|
|
// all references are dropped, and all use counts go to zero. Then everything
|
2003-10-11 01:54:14 +08:00
|
|
|
// is deleted for real. Note that no operations are valid on an object that
|
2002-08-18 07:32:47 +08:00
|
|
|
// has "dropped all references", except operator delete.
|
2001-06-07 04:29:01 +08:00
|
|
|
//
|
|
|
|
void Module::dropAllReferences() {
|
2002-06-26 00:13:24 +08:00
|
|
|
for(Module::iterator I = begin(), E = end(); I != E; ++I)
|
|
|
|
I->dropAllReferences();
|
2001-10-13 14:58:40 +08:00
|
|
|
|
2005-03-15 12:54:21 +08:00
|
|
|
for(Module::global_iterator I = global_begin(), E = global_end(); I != E; ++I)
|
2002-06-26 00:13:24 +08:00
|
|
|
I->dropAllReferences();
|
2007-04-28 21:45:00 +08:00
|
|
|
|
|
|
|
for(Module::alias_iterator I = alias_begin(), E = alias_end(); I != E; ++I)
|
|
|
|
I->dropAllReferences();
|
2001-06-07 04:29:01 +08:00
|
|
|
}
|
2001-06-30 12:35:40 +08:00
|
|
|
|
2007-02-04 08:40:42 +08:00
|
|
|
void Module::addLibrary(const std::string& Lib) {
|
|
|
|
for (Module::lib_iterator I = lib_begin(), E = lib_end(); I != E; ++I)
|
|
|
|
if (*I == Lib)
|
|
|
|
return;
|
|
|
|
LibraryList.push_back(Lib);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Module::removeLibrary(const std::string& Lib) {
|
|
|
|
LibraryListType::iterator I = LibraryList.begin();
|
|
|
|
LibraryListType::iterator E = LibraryList.end();
|
|
|
|
for (;I != E; ++I)
|
|
|
|
if (*I == Lib) {
|
|
|
|
LibraryList.erase(I);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|