00001 //===-- ast/SignatureSet.cpp ---------------------------------- -*- 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 #include "comma/ast/AstRewriter.h" 00010 #include "comma/ast/Decl.h" 00011 #include "comma/ast/SignatureSet.h" 00012 #include "comma/ast/Type.h" 00013 00014 using namespace comma; 00015 00016 bool SignatureSet::addDirectSignature(SignatureType *signature) 00017 { 00018 if (directSignatures.insert(signature)) { 00019 Sigoid *sigDecl = signature->getSigoid(); 00020 AstRewriter rewriter; 00021 00022 // Rewrite the percent node of the signature to that of the model 00023 // associated with this set. 00024 rewriter.addRewrite(sigDecl->getPercent(), 00025 associatedModel->getPercent()); 00026 00027 // If the supplied signature is parameterized, install rewrites mapping 00028 // the formal parameters of the signature to the actual parameters of 00029 // the type. 00030 rewriter.installRewrites(signature); 00031 00032 const SignatureSet& sigset = sigDecl->getSignatureSet(); 00033 00034 allSignatures.insert(signature); 00035 for (iterator iter = sigset.begin(); iter != sigset.end(); ++iter) { 00036 SignatureType *rewrite = rewriter.rewrite(*iter); 00037 allSignatures.insert(rewrite); 00038 } 00039 00040 return true; 00041 } 00042 return false; 00043 } 00044