mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-13 01:36:15 +02:00
d7efd76394
concatenation and string coercion. This was a big mess (see e.g. NIX-67). Contexts are now folded into strings, so that they don't cause evaluation errors when they're not expected. The semantics of paths has been clarified (see nixexpr-ast.def). toString() and coerceToString() have been merged. Semantic change: paths are now copied to the store when they're in a concatenation (and in most other situations - that's the formalisation of the meaning of a path). So "foo " + ./bla evaluates to "foo /nix/store/hash...-bla", not "foo /path/to/current-dir/bla". This prevents accidental impurities, and is more consistent with the treatment of derivation outputs, e.g., `"foo " + bla' where `bla' is a derivation. (Here `bla' would be replaced by the output path of `bla'.)
55 lines
866 B
C++
55 lines
866 B
C++
#ifndef __ATERM_H
|
|
#define __ATERM_H
|
|
|
|
#include <aterm2.h>
|
|
|
|
#include "types.hh"
|
|
|
|
|
|
namespace nix {
|
|
|
|
|
|
/* Print an ATerm. */
|
|
string atPrint(ATerm t);
|
|
|
|
class ATermIterator
|
|
{
|
|
ATermList t;
|
|
|
|
public:
|
|
ATermIterator(ATermList _t) : t(_t) { }
|
|
ATermIterator & operator ++ ()
|
|
{
|
|
t = ATgetNext(t);
|
|
return *this;
|
|
}
|
|
ATerm operator * ()
|
|
{
|
|
return ATgetFirst(t);
|
|
}
|
|
operator bool ()
|
|
{
|
|
return t != ATempty;
|
|
}
|
|
};
|
|
|
|
|
|
/* Throw an exception with an error message containing the given
|
|
aterm. */
|
|
Error badTerm(const format & f, ATerm t);
|
|
|
|
|
|
/* Convert strings to ATerms. */
|
|
ATerm toATerm(const char * s);
|
|
ATerm toATerm(const string & s);
|
|
|
|
ATermList toATermList(const StringSet & ss);
|
|
|
|
}
|
|
|
|
|
|
/* Write an ATerm to an output stream. */
|
|
std::ostream & operator << (std::ostream & stream, ATerm e);
|
|
|
|
|
|
#endif /* !__ATERM_H */
|