00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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
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( fp, tpath->get(0));
00047 for (int i = 1; i < tpath->size(); i++) {
00048 FP::Tag::ExtendRaw( fp, PathnameSep);
00049 FP::Tag::ExtendRaw( fp, tpath->get(i));
00050 }
00051 }
00052 this->pathFP.Permute(fp);
00053 }
00054
00055
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
00073 this->content->path->addhi(id);
00074 RawFP fp;
00075 this->content->pathFP.Unpermute( fp);
00076 FP::Tag::ExtendRaw( fp, PathnameSep);
00077 FP::Tag::ExtendRaw( 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
00084
00085 RawFP fp;
00086 this->content->pathFP.Unpermute( fp);
00087 for (int i = 0; i < p.size(); i++) {
00088 this->content->path->addhi(p.get(i));
00089 FP::Tag::ExtendRaw( fp, PathnameSep);
00090 FP::Tag::ExtendRaw( 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
00098 ArcSeq *p = dp->content->path;
00099 ArcSeq *p1 = this->content->path;
00100 RawFP fp;
00101 dp->content->pathFP.Unpermute( fp);
00102 int i;
00103 for (i = 0; i < content->path->size(); i++) {
00104 FP::Tag::ExtendRaw( fp, PathnameSep);
00105 FP::Tag::ExtendRaw( 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
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
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
00133
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 }