about summary refs log tree commit diff
path: root/src/fstate.hh
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2003-07-20T19·29+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2003-07-20T19·29+0000
commit6f1a0f948dc5a98f2efcdafb0fdde96bebbf90da (patch)
treeb25798966aefa5ca7d883ced33a19d3d754e1392 /src/fstate.hh
parentab350eafd2c1a98ea98090fdb3bd9b7ae4f7336b (diff)
* Refactorings.
Diffstat (limited to 'src/fstate.hh')
-rw-r--r--src/fstate.hh89
1 files changed, 28 insertions, 61 deletions
diff --git a/src/fstate.hh b/src/fstate.hh
index 0d89e7e360c7..681a8d094180 100644
--- a/src/fstate.hh
+++ b/src/fstate.hh
@@ -5,55 +5,13 @@ extern "C" {
 #include <aterm2.h>
 }
 
-#include "hash.hh"
 #include "store.hh"
 
-using namespace std;
 
-
-/* \section{Abstract syntax of Nix file system state expressions}
-
-   A Nix file system state expression, or FState, describes a
-   (partial) state of the file system.
-
-     Slice : [Id] * [(Path, Id, [Id])] -> FState
-
-   (update)
-   Path(path, content, refs) specifies a file object (its full path
-   and contents), along with all file objects referenced by it (that
-   is, that it has pointers to).  We assume that all files are
-   self-referential.  This prevents us from having to deal with
-   cycles.
-
-     Derive : [(Path, Id)] * [FStateId] * Path * [(String, String)] -> FState
-
-   (update)
-   Derive(platform, builder, ins, outs, env) specifies the creation of
-   new file objects (in paths declared by `outs') by the execution of
-   a program `builder' on a platform `platform'.  This execution takes
-   place in a file system state given by `ins'.  `env' specifies a
-   mapping of strings to strings.
-
-   A FState expression is in {\em $f$-normal form} if all Derive nodes
-   have been reduced to File nodes.
-
-   DISCUSSION: the idea is that a Regular/Directory is interchangeable
-   with its CHash.  This would appear to break referential
-   transparency, e.g., Derive(..., ..., [...CHash(h)...], ...) can
-   only be reduced in a context were the Regular/Directory equivalent
-   of Hash(h) is known.  However, CHash should be viewed strictly as a
-   shorthand; that is, when we export an expression containing a
-   CHash, we should also export the file object referenced by that
-   CHash.
-
-*/
-
-typedef ATerm FState;
-typedef ATerm Content;
+/* Abstract syntax of fstate-expressions. */
 
 typedef list<FSId> FSIds;
 
-
 struct SliceElem
 {
     string path;
@@ -69,6 +27,27 @@ struct Slice
     SliceElems elems;
 };
 
+typedef pair<string, FSId> DeriveOutput;
+typedef pair<string, string> StringPair;
+typedef list<DeriveOutput> DeriveOutputs;
+typedef list<StringPair> StringPairs;
+
+struct Derive
+{
+    DeriveOutputs outputs;
+    FSIds inputs;
+    string builder;
+    string platform;
+    StringPairs env;
+};
+
+struct FState
+{
+    enum { fsSlice, fsDerive } type;
+    Slice slice;
+    Derive derive;
+};
+
 
 /* Return a canonical textual representation of an expression. */
 string printTerm(ATerm t);
@@ -81,28 +60,16 @@ Error badTerm(const format & f, ATerm t);
 Hash hashTerm(ATerm t);
 
 /* Read an aterm from disk, given its id. */
-ATerm termFromId(const FSId & id, string * p = 0);
+ATerm termFromId(const FSId & id);
 
 /* Write an aterm to the Nix store directory, and return its hash. */
-FSId writeTerm(ATerm t, const string & suffix, string * p = 0);
-
-/* Register a successor. */
-void registerSuccessor(const FSId & id1, const FSId & id2);
-
-
-/* Normalise an fstate-expression, that is, return an equivalent
-   Slice. */
-Slice normaliseFState(FSId id);
-
-/* Realise a Slice in the file system. */
-void realiseSlice(const Slice & slice);
+FSId writeTerm(ATerm t, const string & suffix);
 
-/* Get the list of root (output) paths of the given
-   fstate-expression. */
-Strings fstatePaths(const FSId & id, bool normalise);
+/* Parse an fstate-expression. */
+FState parseFState(ATerm t);
 
-/* Get the list of paths referenced by the given fstate-expression. */
-StringSet fstateRefs(const FSId & id);
+/* Parse an fstate-expression. */
+ATerm unparseFState(const FState & fs);
 
 
 #endif /* !__FSTATE_H */