about summary refs log tree commit diff
path: root/src/fstate.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2003-07-16T11·05+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2003-07-16T11·05+0000
commitb9ecadee6e32eddac07d09a228f0dda2b340c7ac (patch)
tree0d4c3c1279801332235202dcab52ba757ed0c82a /src/fstate.cc
parentc11bbcfd26e554ca044c1cce293097e4e87ef31e (diff)
* Fix the -qr query.
Diffstat (limited to 'src/fstate.cc')
-rw-r--r--src/fstate.cc36
1 files changed, 30 insertions, 6 deletions
diff --git a/src/fstate.cc b/src/fstate.cc
index 60a8d475c9..cdd620cf10 100644
--- a/src/fstate.cc
+++ b/src/fstate.cc
@@ -186,9 +186,10 @@ void registerSuccessor(const FSId & id1, const FSId & id2)
 }
 
 
-static FSId storeSuccessor(const FSId & id1, FState sc)
+static FSId storeSuccessor(const FSId & id1, FState sc,
+    string * p)
 {
-    FSId id2 = writeTerm(sc, "-s-" + (string) id1, 0);
+    FSId id2 = writeTerm(sc, "-s-" + (string) id1, p);
     registerSuccessor(id1, id2);
     return id2;
 }
@@ -267,7 +268,7 @@ static FState unparseSlice(const Slice & slice)
 typedef set<FSId> FSIdSet;
 
 
-Slice normaliseFState(FSId id)
+static Slice normaliseFState2(FSId id, StringSet & usedPaths)
 {
     debug(format("normalising fstate"));
     Nest nest(true);
@@ -281,12 +282,16 @@ Slice normaliseFState(FSId id)
     }
 
     /* Get the fstate expression. */
-    FState fs = termFromId(id);
+    string fsPath;
+    FState fs = termFromId(id, &fsPath);
 
     /* Already in normal form (i.e., a slice)? */
     if (ATgetType(fs) == AT_APPL && 
         (string) ATgetName(ATgetAFun(fs)) == "Slice")
+    {
+        usedPaths.insert(fsPath);
         return parseSlice(fs);
+    }
     
     /* Then we it's a Derive node. */
     ATermList outs, ins, bnds;
@@ -402,12 +407,20 @@ Slice normaliseFState(FSId id)
 
     FState nf = unparseSlice(slice);
     debug(printTerm(nf));
-    storeSuccessor(id, nf);
+    storeSuccessor(id, nf, &fsPath);
+    usedPaths.insert(fsPath);
 
     return slice;
 }
 
 
+Slice normaliseFState(FSId id)
+{
+    StringSet dummy;
+    return normaliseFState2(id, dummy);
+}
+
+
 static void checkSlice(const Slice & slice)
 {
     if (slice.elems.size() == 0)
@@ -475,7 +488,7 @@ void realiseSlice(const Slice & slice)
 }
 
 
-Strings fstatePaths(FSId id, bool normalise)
+Strings fstatePaths(const FSId & id, bool normalise)
 {
     Strings paths;
 
@@ -520,3 +533,14 @@ Strings fstatePaths(FSId id, bool normalise)
 
     return paths;
 }
+
+
+StringSet fstateRefs(const FSId & id)
+{
+    StringSet paths;
+    Slice slice = normaliseFState2(id, paths);
+    for (SliceElems::const_iterator i = slice.elems.begin();
+         i != slice.elems.end(); i++)
+        paths.insert(i->path);
+    return paths;
+}