lix/src/expr.hh

74 lines
1.3 KiB
C++
Raw Normal View History

#ifndef __FSTATE_H
#define __FSTATE_H
extern "C" {
#include <aterm2.h>
}
#include "store.hh"
/* Abstract syntax of Nix expressions. */
2003-06-27 09:55:31 +00:00
typedef list<FSId> FSIds;
struct ClosureElem
{
FSId id;
StringSet refs;
};
typedef map<string, ClosureElem> ClosureElems;
struct Closure
{
StringSet roots;
ClosureElems elems;
};
typedef map<string, FSId> DerivationOutputs;
typedef map<string, string> StringPairs;
2003-07-20 19:29:38 +00:00
struct Derivation
2003-07-20 19:29:38 +00:00
{
DerivationOutputs outputs;
FSIdSet inputs;
2003-07-20 19:29:38 +00:00
string platform;
string builder;
Strings args;
2003-07-20 19:29:38 +00:00
StringPairs env;
};
struct NixExpr
2003-07-20 19:29:38 +00:00
{
enum { neClosure, neDerivation } type;
Closure closure;
Derivation derivation;
2003-07-20 19:29:38 +00:00
};
2003-06-17 13:37:44 +00:00
/* Return a canonical textual representation of an expression. */
string printTerm(ATerm t);
2003-07-06 14:20:47 +00:00
/* Throw an exception with an error message containing the given
aterm. */
Error badTerm(const format & f, ATerm t);
/* Hash an aterm. */
Hash hashTerm(ATerm t);
/* Read an aterm from disk, given its id. */
2003-07-20 19:29:38 +00:00
ATerm termFromId(const FSId & id);
2003-07-06 14:20:47 +00:00
/* Write an aterm to the Nix store directory, and return its hash. */
FSId writeTerm(ATerm t, const string & suffix, FSId id = FSId());
/* Parse a Nix expression. */
NixExpr parseNixExpr(ATerm t);
2003-07-16 11:05:59 +00:00
/* Parse a Nix expression. */
ATerm unparseNixExpr(const NixExpr & ne);
2003-07-15 22:28:27 +00:00
#endif /* !__FSTATE_H */