diff options
author | Guillaume Maudoux <guillaume.maudoux@tweag.io> | 2022-04-29 00:12:25 +0200 |
---|---|---|
committer | Guillaume Maudoux <guillaume.maudoux@tweag.io> | 2022-04-29 00:12:25 +0200 |
commit | e93b59fbc5ada40e77d6f2b2a8bbd8e482418d6a (patch) | |
tree | f9436753bba299d648a6721845a9465b34a50062 /src/libexpr/value.hh | |
parent | f6baa4d18845297f3f7fc2434b7ade93a45718e7 (diff) | |
parent | 35393dc2c65765acb6cc99d6a976eab62c28a51d (diff) |
Merge remote-tracking branch 'origin/master' into coerce-string
Diffstat (limited to 'src/libexpr/value.hh')
-rw-r--r-- | src/libexpr/value.hh | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/libexpr/value.hh b/src/libexpr/value.hh index 18e4218c5..3fa43bc5c 100644 --- a/src/libexpr/value.hh +++ b/src/libexpr/value.hh @@ -56,7 +56,10 @@ struct Expr; struct ExprLambda; struct PrimOp; class Symbol; +class PosIdx; struct Pos; +class StorePath; +class Store; class EvalState; class XMLWriter; class JSONPlaceholder; @@ -64,6 +67,8 @@ class JSONPlaceholder; typedef int64_t NixInt; typedef double NixFloat; +typedef std::pair<StorePath, std::string> NixStringContextElem; +typedef std::vector<NixStringContextElem> NixStringContext; /* External values must descend from ExternalValueBase, so that * type-agnostic nix functions (e.g. showType) can be implemented @@ -99,7 +104,7 @@ class ExternalValueBase /* Print the value as XML. Defaults to unevaluated */ virtual void printValueAsXML(EvalState & state, bool strict, bool location, XMLWriter & doc, PathSet & context, PathSet & drvsSeen, - const Pos & pos) const; + const PosIdx pos) const; virtual ~ExternalValueBase() { @@ -115,10 +120,13 @@ private: InternalType internalType; friend std::string showType(const Value & v); - friend void printValue(std::ostream & str, std::set<const void *> & seen, const Value & v); + + void print(const SymbolTable & symbols, std::ostream & str, std::set<const void *> * seen) const; public: + void print(const SymbolTable & symbols, std::ostream & str, bool showRepeated = false) const; + // Functions needed to distinguish the type // These should be removed eventually, by putting the functionality that's // needed by callers into methods of this type @@ -243,11 +251,6 @@ public: void mkStringMove(const char * s, const PathSet & context); - inline void mkString(const Symbol & s) - { - mkString(((const std::string &) s).c_str()); - } - inline void mkPath(const char * s) { clearValue(); @@ -361,14 +364,14 @@ public: return internalType == tList1 ? 1 : internalType == tList2 ? 2 : bigList.size; } - Pos determinePos(const Pos & pos) const; + PosIdx determinePos(const PosIdx pos) const; /* Check whether forcing this value requires a trivial amount of computation. In particular, function applications are non-trivial. */ bool isTrivial() const; - std::vector<std::pair<Path, std::string>> getContext(); + NixStringContext getContext(const Store &); auto listItems() { |