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, 23 insertions, 5 deletions
diff --git a/src/libexpr/value.hh b/src/libexpr/value.hh
index bfae4ee94..eb6f56d07 100644
--- a/src/libexpr/value.hh
+++ b/src/libexpr/value.hh
@@ -5,6 +5,7 @@
#include "symbol-table.hh"
#include "value/context.hh"
+#include "input-accessor.hh"
#if HAVE_BOEHMGC
#include <gc/gc_allocator.h>
@@ -171,7 +172,7 @@ public:
const char * * context; // must be in sorted order
} string;
- const char * path;
+ const char * _path;
Bindings * attrs;
struct {
size_t size;
@@ -251,15 +252,20 @@ public:
void mkStringMove(const char * s, const PathSet & context);
- inline void mkPath(const char * s)
+ inline void mkString(const Symbol & s)
+ {
+ mkString(((const std::string &) s).c_str());
+ }
+
+ void mkPath(const SourcePath & path);
+
+ inline void mkPath(const char * path)
{
clearValue();
internalType = tPath;
- path = s;
+ _path = path;
}
- void mkPath(std::string_view s);
-
inline void mkNull()
{
clearValue();
@@ -400,6 +406,18 @@ public:
auto begin = listElems();
return ConstListIterable { begin, begin + listSize() };
}
+
+ SourcePath path() const
+ {
+ assert(internalType == tPath);
+ return SourcePath{CanonPath(_path)};
+ }
+
+ std::string_view str() const
+ {
+ assert(internalType == tString);
+ return std::string_view(string.s);
+ }
};