Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

Dep.C

Go to the documentation of this file.
00001 // Copyright (C) 2001, Compaq Computer Corporation
00002 // 
00003 // This file is part of Vesta.
00004 // 
00005 // Vesta is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 // 
00010 // Vesta is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with Vesta; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00019 // File: Dep.C
00020 // Last Modified On Mon Apr 25 10:52:02 EDT 2005 by irina.furman@intel.com 
00021 //      Modified On Fri Aug  6 12:43:54 EDT 2004 by ken@xorian.net 
00022 //      Modified On Sat Feb 12 17:47:52 PST 2000 by mann      
00023 //      Modified On Tue May  4 14:24:00 PDT 1999 by heydon    
00024 //      Modified On Fri Mar 13 23:45:00 PST 1998 by yuanyu    
00025 //      modified on Tue Feb 27 15:47:00 PST 1996 by levin
00026 
00027 #include "Dep.H"
00028 #include "Files.H"
00029 #include "Val.H"
00030 #include <FP.H>
00031 #include <SharedTable.H>
00032 
00033 using std::ostream;
00034 
00035 // DepPathC
00036 DepPath::DepPathC::DepPathC(const Text& id, PathKind pk)
00037 : pKind(pk), pathFP(id), dpathVersion(0) {
00038   this->path = NEW(ArcSeq);
00039   this->path->addhi(id);
00040 }
00041 
00042 DepPath::DepPathC::DepPathC(ArcSeq *tpath, PathKind pk)
00043 : pKind(pk), path(tpath), dpathVersion(0) {
00044   RawFP fp = POLY_ONE;
00045   if (tpath->size() != 0) {
00046     FP::Tag::ExtendRaw(/*INOUT*/ fp, tpath->get(0));
00047     for (int i = 1; i < tpath->size(); i++) {
00048       FP::Tag::ExtendRaw(/*INOUT*/ fp, PathnameSep);
00049       FP::Tag::ExtendRaw(/*INOUT*/ fp, tpath->get(i));
00050     }
00051   }
00052   this->pathFP.Permute(fp);
00053 }
00054 
00055 // DepPath
00056 void DepPath::Print(ostream *os) {
00057   Text arc;
00058 
00059   *os << (char)(this->content->pKind);
00060   ArcSeq *path = this->content->path;
00061   for (int i = 0; i < path->size(); i++) {
00062     arc = path->get(i);
00063     int n = ArcInt(arc);
00064     if (n == -1) 
00065       *os << "/" << arc;
00066     else
00067       *os << "/" << n;
00068   }
00069 }
00070 
00071 void DepPath::Extend(const Text& id, PathKind pk) {
00072   // assert(this->content->path->size() != 0);
00073   this->content->path->addhi(id);
00074   RawFP fp;
00075   this->content->pathFP.Unpermute(/*OUT*/ fp);
00076   FP::Tag::ExtendRaw(/*INOUT*/ fp, PathnameSep);
00077   FP::Tag::ExtendRaw(/*INOUT*/ fp, id);
00078   this->content->pathFP.Permute(fp);
00079   this->content->pKind = pk;
00080 }
00081 
00082 void DepPath::Extend(const ArcSeq& p, PathKind pk) {
00083   /* assert(this->content->pKind == NormPK) &&
00084      assert(this->content->path->size() != 0)  */
00085   RawFP fp;
00086   this->content->pathFP.Unpermute(/*OUT*/ fp);
00087   for (int i = 0; i < p.size(); i++) {
00088     this->content->path->addhi(p.get(i));
00089     FP::Tag::ExtendRaw(/*INOUT*/ fp, PathnameSep);
00090     FP::Tag::ExtendRaw(/*INOUT*/ fp, p.get(i));
00091   }
00092   this->content->pathFP.Permute(fp);
00093   this->content->pKind = pk;
00094 }
00095 
00096 void DepPath::ExtendLow(const DepPath *dp) {
00097   // assert(dp->content->path->size() != 0);
00098   ArcSeq *p = dp->content->path;
00099   ArcSeq *p1 = this->content->path;
00100   RawFP fp;
00101   dp->content->pathFP.Unpermute(/*OUT*/ fp);
00102   int i;
00103   for (i = 0; i < content->path->size(); i++) {
00104     FP::Tag::ExtendRaw(/*INOUT*/ fp, PathnameSep);
00105     FP::Tag::ExtendRaw(/*INOUT*/ fp, p1->get(i));
00106   }
00107   this->content->pathFP.Permute(fp);
00108   for (i = p->size() - 1; i >= 0; i--) {
00109     p1->addlo(p->get(i));
00110   }
00111 }
00112 
00113 // DepPathTbl
00114 DPaths* DepPathTbl::DPS::Add(DepPath *dp, Val v, PathKind pk) {
00115   if (dp != NULL) {
00116     KVPairPtr ptr;
00117     if (pk == DummyPK)
00118       ptr = NEW_CONSTR(KVPair, (*dp, v));
00119     else {
00120       // We do not copy path, since only pKind is changed.
00121       DepPath newPath(dp->content->path, pk, dp->content->pathFP);
00122       ptr = NEW_CONSTR(KVPair, (newPath, v));
00123     }
00124     this->Put(ptr); 
00125   }
00126   return this;
00127 }
00128 
00129 DPaths* DepPathTbl::DPS::AddExtend(DepPath *dp, Val v, 
00130                                    PathKind pk, const Text& id) {
00131   if (dp != NULL) {
00132     // We have to deepcopy dp for newPath, since both path and 
00133     // pKind are changed.
00134     DepPath newPath(dp->content);
00135     newPath.Extend(id);
00136     newPath.content->pKind = pk;
00137     KVPairPtr ptr = NEW_CONSTR(KVPair, (newPath, v));
00138     this->Put(ptr);
00139   }
00140   return this;
00141 }
00142 
00143 void DepPathTbl::DPS::Print(ostream *os) {
00144   TIter iter(this);
00145   KVPairPtr ptr;
00146   int n = 0;
00147   while (iter.Next(ptr)) {
00148     *os << "\n  " << n++ << ". ";
00149     ptr->key.Print(os);
00150     *os << " : ";
00151     ptr->val->PrintD(os);
00152   }
00153   *os << "\n";
00154 }

Generated on Mon May 8 00:48:37 2006 for Vesta by  doxygen 1.4.2