00001 //===-- codegen/CodeGenCapsule.h ------------------------------ -*- C++ -*-===// 00002 // 00003 // This file is distributed under the MIT license. See LICENSE.txt for details. 00004 // 00005 // Copyright (C) 2009, Stephen Wilson 00006 // 00007 //===----------------------------------------------------------------------===// 00008 00009 #ifndef COMMA_CODEGEN_CODEGENCAPSULE_HDR_GUARD 00010 #define COMMA_CODEGEN_CODEGENCAPSULE_HDR_GUARD 00011 00012 #include "comma/ast/AstBase.h" 00013 #include "llvm/ADT/UniqueVector.h" 00014 00015 namespace comma { 00016 00017 class CodeGen; 00018 00019 class CodeGenCapsule { 00020 00021 private: 00022 typedef llvm::UniqueVector<DomainInstanceDecl *> InstanceList; 00023 00024 public: 00025 CodeGenCapsule(CodeGen &CG, Domoid *domoid); 00026 00028 CodeGen &getCodeGen() { return CG; } 00029 const CodeGen &getCodeGen() const { return CG; } 00030 00032 Domoid *getCapsule() { return capsule; } 00033 const Domoid *getCapsule() const { return capsule; } 00034 00036 const std::string &getLinkName() const { return linkName; } 00037 00041 unsigned addCapsuleDependency(DomainInstanceDecl *instance); 00042 00044 unsigned dependencyCount() const { return requiredInstances.size(); } 00045 00047 DomainInstanceDecl *getDependency(unsigned ID) { 00048 return requiredInstances[ID]; 00049 } 00050 00053 unsigned getDependencyID(DomainInstanceDecl *instance) { 00054 return requiredInstances.idFor(instance); 00055 } 00056 00057 private: 00059 CodeGen &CG; 00060 00062 Domoid *capsule; 00063 00065 std::string linkName; 00066 00068 llvm::UniqueVector<DomainInstanceDecl *> requiredInstances; 00069 00071 void emit(); 00072 }; 00073 00074 } // end comma namespace. 00075 00076 #endif