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 //===-- ast/SignatureSet.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 // The following class provides a container for the set of signatures associated 00010 // with a particular model. Note that is class is not a member of the Ast 00011 // hierarchy. 00012 // 00013 // SignatureSet's are populated by specifying the direct signatures (those 00014 // signatures which are explicitly named in the declaration of the associated 00015 // model). Recursively, the SignatureSet's associated with the direct 00016 // signatures are then consulted to obtain the set of indirect signatures. 00017 // 00018 //===----------------------------------------------------------------------===// 00019 00020 #ifndef COMMA_AST_SIGNATURESET_HDR_GUARD 00021 #define COMMA_AST_SIGNATURESET_HDR_GUARD 00022 00023 #include "comma/ast/AstBase.h" 00024 00025 #include "llvm/ADT/SetVector.h" 00026 00027 namespace comma { 00028 00029 class SignatureSet { 00030 00031 typedef llvm::SetVector<SigInstanceDecl*> SignatureTable; 00032 SignatureTable directSignatures; 00033 SignatureTable allSignatures; 00034 00035 public: 00043 bool addDirectSignature(SigInstanceDecl *signature, 00044 const AstRewriter &rewriter); 00045 00048 bool contains(SigInstanceDecl *signature) const { 00049 return allSignatures.count(signature); 00050 } 00051 00054 bool isDirect(SigInstanceDecl *signature) const { 00055 return directSignatures.count(signature); 00056 } 00057 00060 bool isIndirect(SigInstanceDecl *signature) const { 00061 return contains(signature) && !isDirect(signature); 00062 } 00063 00065 unsigned numSignatures() const { return allSignatures.size(); } 00066 00068 unsigned size() const { return numSignatures(); } 00069 00071 bool empty() const { return numSignatures() == 0; } 00072 00074 unsigned numDirectSignatures() const { return directSignatures.size(); } 00075 00077 unsigned numIndirectSignatures() const { 00078 return numSignatures() - numDirectSignatures(); 00079 } 00080 00081 typedef SignatureTable::iterator iterator; 00082 typedef SignatureTable::const_iterator const_iterator; 00083 00088 iterator beginDirect() { return directSignatures.begin(); } 00089 iterator endDirect() { return directSignatures.end(); } 00090 00091 const_iterator beginDirect() const { return directSignatures.begin(); } 00092 const_iterator endDirect() const { return directSignatures.end(); } 00093 00098 iterator begin() { return allSignatures.begin(); } 00099 iterator end() { return allSignatures.end(); } 00100 00101 const_iterator begin() const { return allSignatures.begin(); } 00102 const_iterator end() const { return allSignatures.end(); } 00103 }; 00104 00105 } // End comma namespace 00106 00107 #endif