aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/value.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/libexpr/value.hh')
-rw-r--r--src/libexpr/value.hh28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/libexpr/value.hh b/src/libexpr/value.hh
index d0fa93e92..c46dd4b73 100644
--- a/src/libexpr/value.hh
+++ b/src/libexpr/value.hh
@@ -55,8 +55,11 @@ struct Env;
struct Expr;
struct ExprLambda;
struct PrimOp;
-class Symbol;
+class SymbolIdx;
+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
@@ -245,7 +253,7 @@ public:
inline void mkString(const Symbol & s)
{
- mkString(((const std::string &) s).c_str());
+ mkString(std::string_view(s).data());
}
inline void mkPath(const char * s)
@@ -361,14 +369,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()
{
@@ -402,12 +410,12 @@ public:
#if HAVE_BOEHMGC
typedef std::vector<Value *, traceable_allocator<Value *> > ValueVector;
-typedef std::map<Symbol, Value *, std::less<Symbol>, traceable_allocator<std::pair<const Symbol, Value *> > > ValueMap;
-typedef std::map<Symbol, ValueVector, std::less<Symbol>, traceable_allocator<std::pair<const Symbol, ValueVector> > > ValueVectorMap;
+typedef std::map<SymbolIdx, Value *, std::less<SymbolIdx>, traceable_allocator<std::pair<const SymbolIdx, Value *> > > ValueMap;
+typedef std::map<SymbolIdx, ValueVector, std::less<SymbolIdx>, traceable_allocator<std::pair<const SymbolIdx, ValueVector> > > ValueVectorMap;
#else
typedef std::vector<Value *> ValueVector;
-typedef std::map<Symbol, Value *> ValueMap;
-typedef std::map<Symbol, ValueVector> ValueVectorMap;
+typedef std::map<SymbolIdx, Value *> ValueMap;
+typedef std::map<SymbolIdx, ValueVector> ValueVectorMap;
#endif