00001 //===-- codegen/CGContext.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_CODEGENCONTEXT_HDR_GUARD 00010 #define COMMA_CODEGEN_CODEGENCONTEXT_HDR_GUARD 00011 00012 #include "CodeGenTypes.h" 00013 #include "InstanceInfo.h" 00014 00015 #include <map> 00016 00017 namespace comma { 00018 00019 class CodeGenTypes; 00020 00029 class CGContext { 00030 00031 public: 00034 CGContext(CodeGen &CG, InstanceInfo *IInfo); 00035 00037 00038 const CodeGen &getCG() const { return CG; } 00039 CodeGen &getCG() { return CG; } 00041 00047 CodeGenTypes &getCGT() { return CGT; } 00048 00050 00051 00052 bool generatingCapsule() const { return IInfo != 0; } 00053 00055 bool generatingCapsuleInstance() const; 00057 00059 00060 00061 const InstanceInfo *getInstanceInfo() const { return IInfo; } 00062 InstanceInfo *getInstanceInfo() { return IInfo; } 00064 00070 00071 00073 typedef std::map<Type*, Type*> ParameterMap; 00074 00076 const ParameterMap &getParameterMap() const { return paramMap; } 00077 00079 00080 00081 DomainInstanceDecl * 00082 rewriteAbstractDecl(AbstractDomainDecl *abstract) const; 00083 00084 const DomainInstanceDecl * 00085 rewriteAbstractDecl(const AbstractDomainDecl *abstract) const { 00086 return rewriteAbstractDecl(const_cast<AbstractDomainDecl*>(abstract)); 00087 } 00089 00090 00091 private: 00092 CodeGen &CG; 00093 InstanceInfo *IInfo; 00094 CodeGenTypes CGT; 00095 ParameterMap paramMap; 00096 }; 00097 00098 } // end comma namespace. 00099 00100 #endif