This machine mirrors various open-source projects.
20 Gbit/s uplink.
If there are any issues or you want another project mirrored, please contact
mirror-service -=AT=- netcologne DOT de !
00001 //===-- codegen/DependencySet.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 //===----------------------------------------------------------------------===// 00013 //===----------------------------------------------------------------------===// 00014 00015 #ifndef COMMA_CODEGEN_DEPENDENCYSET_HDR_GUARD 00016 #define COMMA_CODEGEN_DEPENDENCYSET_HDR_GUARD 00017 00018 #include "llvm/ADT/UniqueVector.h" 00019 00020 #include <iterator> 00021 00022 namespace comma { 00023 00024 class DependencySet; 00025 class DomainInstanceDecl; 00026 class Domoid; 00027 00029 class DependencySetIterator 00030 : public std::iterator<std::bidirectional_iterator_tag, 00031 const DomainInstanceDecl*> { 00032 00033 const DependencySet *DS; 00034 unsigned index; 00035 00036 DependencySetIterator(const DependencySet *DS) : DS(DS), index(0) { } 00037 00038 DependencySetIterator(const DependencySet *DS, unsigned index) 00039 : DS(DS), index(index) { } 00040 00041 friend class DependencySet; 00042 00043 public: 00044 bool operator ==(const DependencySetIterator &iter) const { 00045 return (DS == iter.DS && index == iter.index); 00046 } 00047 00048 bool operator !=(const DependencySetIterator &iter) const { 00049 return !(*this == iter); 00050 } 00051 00052 DependencySetIterator &operator++() { 00053 index++; 00054 return *this; 00055 } 00056 00057 DependencySetIterator operator++(int) { 00058 DependencySetIterator res = *this; 00059 index++; 00060 return res; 00061 } 00062 00063 DependencySetIterator &operator--() { 00064 index--; 00065 return *this; 00066 } 00067 00068 DependencySetIterator operator--(int) { 00069 DependencySetIterator res = *this; 00070 index--; 00071 return res; 00072 } 00073 00074 const DomainInstanceDecl *operator*() const; 00075 00076 const DomainInstanceDecl *operator->() const; 00077 }; 00078 00090 class DependencySet { 00091 00092 typedef llvm::UniqueVector<const DomainInstanceDecl*> DependenceVector; 00093 00094 const Domoid *capsule; 00095 DependenceVector dependents; 00096 00097 public: 00098 DependencySet(const Domoid *domoid) : capsule(domoid) { scan(); } 00099 00100 typedef DependencySetIterator iterator; 00101 iterator begin() const { return DependencySetIterator(this); } 00102 iterator end() const { return DependencySetIterator(this, size()); } 00103 00104 // Returns the capsule this dependency set represents. 00105 const Domoid *getCapsule() const { return capsule; } 00106 00107 unsigned getDependentID(iterator I) const { 00108 return dependents.idFor(*I) - 1; 00109 } 00110 00111 const DomainInstanceDecl *getDependent(unsigned ID) const { 00112 return dependents[ID + 1]; 00113 } 00114 00115 iterator find(const DomainInstanceDecl *instance) const; 00116 00117 unsigned size() const { return dependents.size(); } 00118 00119 private: 00121 void scan(); 00122 }; 00123 00124 inline const DomainInstanceDecl *DependencySetIterator::operator*() const { 00125 return DS->getDependent(index); 00126 } 00127 00128 inline const DomainInstanceDecl *DependencySetIterator::operator->() const { 00129 return DS->getDependent(index); 00130 } 00131 00132 } // end comma namespace. 00133 00134 #endif