2003-09-18 16:17:06 +00:00
|
|
|
//===-- ModuleProvider.cpp - Base implementation for module providers -----===//
|
|
|
|
//
|
|
|
|
// Minimal implementation of the abstract interface for providing a module.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/ModuleProvider.h"
|
|
|
|
#include "llvm/Module.h"
|
|
|
|
|
|
|
|
/// ctor - always have a valid Module
|
|
|
|
///
|
2003-10-04 20:14:59 +00:00
|
|
|
ModuleProvider::ModuleProvider() : TheModule(0) { }
|
2003-09-18 16:17:06 +00:00
|
|
|
|
|
|
|
/// dtor - when we leave, we take our Module with us
|
|
|
|
///
|
2003-10-04 20:14:59 +00:00
|
|
|
ModuleProvider::~ModuleProvider() {
|
2003-09-22 23:44:13 +00:00
|
|
|
delete TheModule;
|
2003-09-18 16:17:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// materializeFunction - make sure the given function is fully read.
|
|
|
|
///
|
2003-10-17 18:27:13 +00:00
|
|
|
Module* ModuleProvider::materializeModule() {
|
|
|
|
// FIXME: throw an exception instead?
|
|
|
|
if (!TheModule) return 0;
|
2003-09-22 23:44:13 +00:00
|
|
|
|
|
|
|
for (Module::iterator i = TheModule->begin(), e = TheModule->end();
|
|
|
|
i != e; ++i)
|
2003-09-18 16:17:06 +00:00
|
|
|
materializeFunction(i);
|
2003-10-17 18:27:13 +00:00
|
|
|
|
|
|
|
return TheModule;
|
2003-09-18 16:17:06 +00:00
|
|
|
}
|