diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2003-07-15T16·28+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2003-07-15T16·28+0000 |
commit | f5b6fa5256efce5f7a963386cd16e441446f5746 (patch) | |
tree | dd4ada2e432ea1e7bcdeada23583539575b1a342 /src/fstate.hh | |
parent | 8898e86b4fe1ecf8b34a5cca2a7b9b38d395678c (diff) |
* Basic work on allowing derive expressions to build multiple paths.
This is not entirely trivial since this introduces the possibility of mutual recursion. * Made normal forms self-contained. * Use unique ids, not content hashes, for content referencing.
Diffstat (limited to 'src/fstate.hh')
-rw-r--r-- | src/fstate.hh | 57 |
1 files changed, 38 insertions, 19 deletions
diff --git a/src/fstate.hh b/src/fstate.hh index 9d789c834685..f06a4807ef5d 100644 --- a/src/fstate.hh +++ b/src/fstate.hh @@ -8,6 +8,7 @@ extern "C" { } #include "hash.hh" +#include "store.hh" using namespace std; @@ -17,33 +18,24 @@ using namespace std; A Nix file system state expression, or FState, describes a (partial) state of the file system. - Path : Path * Content * [FState] -> FState + 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 : String * Path * [FState] * Path * [(String, String)] -> FState + 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. - [ !!! NOT IMPLEMENTED - Regular : String -> Content - Directory : [(String, Content)] -> Content - (this complicates unambiguous normalisation) - ] - CHash : Hash -> Content - - File content, given either in situ, or through an external reference - to the file system or url-space decorated with a hash to preserve - purity. - A FState expression is in {\em $f$-normal form} if all Derive nodes have been reduced to File nodes. @@ -63,7 +55,26 @@ typedef ATerm Content; typedef set<string> StringSet; +typedef list<FSId> FSIds; + + +struct SliceElem +{ + string path; + FSId id; + FSIds refs; +}; + +typedef list<SliceElem> SliceElems; + +struct Slice +{ + FSIds roots; + SliceElems elems; +}; + +#if 0 /* Realise an fstate expression in the file system. This requires execution of all Derive() nodes. */ FState realiseFState(FState fs, StringSet & paths); @@ -74,6 +85,8 @@ string fstatePath(FState fs); /* Return the paths referenced by fstate expression. */ void fstateRefs(FState fs, StringSet & paths); +#endif + /* Return a canonical textual representation of an expression. */ string printTerm(ATerm t); @@ -85,16 +98,22 @@ Error badTerm(const format & f, ATerm t); /* Hash an aterm. */ Hash hashTerm(ATerm t); -FState hash2fstate(Hash hash); - -/* Read an aterm from disk, given its hash. */ -ATerm termFromHash(const Hash & hash, string * p = 0); +/* Read an aterm from disk, given its id. */ +ATerm termFromId(const FSId & id, string * p = 0); /* Write an aterm to the Nix store directory, and return its hash. */ -Hash writeTerm(ATerm t, const string & suffix, string * p = 0); +FSId writeTerm(ATerm t, const string & suffix, string * p = 0); /* Register a successor. */ -void registerSuccessor(const Hash & fsHash, const Hash & scHash); +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(Slice slice); #endif /* !__FSTATE_H */ |