template SymbolTableListTraits<Instruction, BasicBlock, Function>;
+// BasicBlock ctor - If the function parameter is specified, the basic block is
+// automatically inserted at the end of the function.
+//
BasicBlock::BasicBlock(const std::string &name, Function *Parent)
: Value(Type::LabelTy, Value::BasicBlockVal, name) {
// Initialize the instlist...
InstList.clear();
}
+void BasicBlock::setParent(Function *parent) {
+ InstList.setParent(parent);
+}
+
// Specialize setName to take care of symbol table majik
void BasicBlock::setName(const std::string &name, SymbolTable *ST) {
Function *P;
#include "llvm/iOther.h"
#include "SymbolTableListTraitsImpl.h"
+BasicBlock *ilist_traits<BasicBlock>::createNode() {
+ return new BasicBlock();
+}
+
iplist<BasicBlock> &ilist_traits<BasicBlock>::getList(Function *F) {
return F->getBasicBlockList();
}
// Argument Implementation
//===----------------------------------------------------------------------===//
+Argument::Argument(const Type *Ty, const std::string &Name = "", Function *Par)
+ : Value(Ty, Value::ArgumentVal, Name) {
+ Parent = 0;
+ if (Par)
+ Par->getArgumentList().push_back(this);
+}
+
+
// Specialize setName to take care of symbol table majik
void Argument::setName(const std::string &name, SymbolTable *ST) {
Function *P;
if (P && hasName()) P->getSymbolTable()->insert(this);
}
+void Argument::setParent(Function *parent) {
+ Parent = parent;
+}
+
+
//===----------------------------------------------------------------------===//
// Function Implementation
//===----------------------------------------------------------------------===//
-
Function::Function(const FunctionType *Ty, bool isInternal,
const std::string &name, Module *ParentModule)
: GlobalValue(PointerType::get(Ty), Value::FunctionVal, isInternal, name) {
GlobalVariable::GlobalVariable(const Type *Ty, bool constant, bool isIntern,
Constant *Initializer,
- const std::string &Name)
+ const std::string &Name, Module *ParentModule)
: GlobalValue(PointerType::get(Ty), Value::GlobalVariableVal, isIntern, Name),
isConstantGlobal(constant) {
if (Initializer) Operands.push_back(Use((Value*)Initializer, this));
+
+ if (ParentModule)
+ ParentModule->getGlobalList().push_back(this);
+}
+
+void GlobalVariable::setParent(Module *parent) {
+ Parent = parent;
}
// Specialize setName to take care of symbol table majik