00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef Dep_H
00022 #define Dep_H
00023
00024 #include "ValExpr.H"
00025 #include <FV2.H>
00026 #include <FP.H>
00027 #include <SharedTable.H>
00028
00029 typedef FV2::T ArcSeq;
00030
00031
00032 enum PathKind {
00033 NormPK = 'N', BangPK = '!', TypePK = 'T', LLenPK = 'L', BLenPK = 'B',
00034 ExprPK = 'E', DummyPK = 'D' };
00035
00037 class DepPath {
00038
00039 public:
00040 class DepPathC {
00041 public:
00042 DepPathC(int size)
00043 : pKind(NormPK), pathFP("", 0), dpathVersion(0)
00044 { path = NEW_CONSTR(ArcSeq, (size)); };
00045 DepPathC(const Text& id, PathKind pk);
00046 DepPathC(ArcSeq *tpath, PathKind pk);
00047 DepPathC(const ArcSeq& tpath, PathKind pk, const FP::Tag& fp,
00048 int version)
00049 : pKind(pk), pathFP(fp), dpathVersion(version)
00050 { path = NEW_CONSTR(ArcSeq, (tpath)); };
00051 DepPathC(ArcSeq *tpath, PathKind pk, const FP::Tag& fp)
00052 : path(tpath), pKind(pk), pathFP(fp), dpathVersion(0) { };
00053
00054
00055 PathKind pKind;
00056
00057
00058 int dpathVersion;
00059
00060
00061 ArcSeq *path;
00062
00063
00064 FP::Tag pathFP;
00065
00066 };
00067
00068 DepPathC *content;
00069
00070
00071 DepPath() { content = NULL; };
00072
00073
00074 DepPath(int size) { content = NEW_CONSTR(DepPathC, (size)); };
00075
00076
00077 DepPath(ArcSeq *tpath, PathKind pk, const FP::Tag& fp)
00078 { content = NEW_CONSTR(DepPathC, (tpath, pk, fp)); };
00079
00080
00081 DepPath(const Text& id, PathKind pk = NormPK)
00082 { content = NEW_CONSTR(DepPathC, (id, pk)); };
00083
00084
00085 DepPath(ArcSeq *path, PathKind pk)
00086 { content = NEW_CONSTR(DepPathC, (path, pk)); };
00087
00088
00089 DepPath(DepPathC *tcontent, int version = 0)
00090 { content = NEW_CONSTR(DepPathC,
00091 (*tcontent->path,
00092 tcontent->pKind,
00093 tcontent->pathFP,
00094 version)); };
00095
00096
00097 void DeepCopy(const DepPath& dp, int version = 0)
00098 { content = NEW_CONSTR(DepPathC,
00099 (*dp.content->path,
00100 dp.content->pKind,
00101 dp.content->pathFP,
00102 version)); };
00103
00104
00105 DepPath* DeepCopy(int version = 0)
00106 { return NEW_CONSTR(DepPath, (this->content, version)); };
00107
00108
00109 void Print(std::ostream *os);
00110
00111
00112 int Size() { return content->path->size(); };
00113
00114
00115 int Version() { return content->dpathVersion; };
00116
00117
00118 void Extend(const Text& id, PathKind pk = NormPK);
00119
00120
00121 void Extend(const ArcSeq& p, PathKind pk = NormPK);
00122
00123
00124 void ExtendLow(const DepPath *dp);
00125
00126
00127 Word Hash() const throw () { return content->pathFP.Hash(); };
00128
00129
00130 friend bool operator== (const DepPath& p1, const DepPath& p2)
00131 throw () {
00132 return ((p1.content->pathFP == p2.content->pathFP) &&
00133 (p1.content->pKind == p2.content->pKind)); };
00134
00135 };
00136
00138 class DepPathTbl {
00139 public:
00140 typedef SharedTable<DepPath, Val>::T T;
00141 typedef SharedTable<DepPath, Val>::Iterator TIter;
00142 typedef SharedTable<DepPath, Val>::KVPair KVPair;
00143 typedef KVPair *KVPairPtr;
00144
00145 class DPS: public T {
00146 public:
00147 DPS(int sizeHint = 0) throw (): T(sizeHint) { };
00148 bool Member(const DepPath& p) { KVPairPtr dummyKV; return Get(p, dummyKV); };
00149 DPS* Add(DepPath *dp, Val v, PathKind pk = DummyPK);
00150 DPS* AddExtend(DepPath *dp, Val v, PathKind pk, const Text& id);
00151 DPS* Merge(DPS *pds) { if (pds != NULL) this->Copy(pds); return this; };
00152 void Print(std::ostream *os);
00153 };
00154 };
00155
00156 typedef DepPathTbl::DPS DPaths;
00157
00158 #endif // Dep_H