aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/nixexpr.hh
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-03-06 05:24:35 +0100
committereldritch horrors <pennae@lix.systems>2024-03-05 23:46:18 -0700
commit89e99d94e4ae492db09c0ebc0c35e4890ef7db25 (patch)
treeeab2defee911a6c0e39d4b073062690bd9a3a058 /src/libexpr/nixexpr.hh
parente9b5929b22116cb714adfe88ba39a817e89b019c (diff)
Merge pull request #9634 from 9999years/combine-abstract-pos-and-pos
Combine `AbstractPos`, `PosAdapter`, and `Pos` (cherry picked from commit 113499d16fc87d53b73fb62fe6242154909756ed) === this is a bit cursed because originally it was based on InputAccessor code that we don't have and moved/patched features we likewise don't have (fetchToStore caching, all the individual accessors, ContentAddressMethod). the commit is adjusted accordingly to match (remove caching, ignore accessors, use FileIngestionMethod). note that `state.rootPath . CanonPath == abs` and computeStorePathForPath works relative to cwd, so the slight rewrite in the moved fetchToStore is legal. Change-Id: I05fd340c273f0bcc8ffabfebdc4a88b98083bce5
Diffstat (limited to 'src/libexpr/nixexpr.hh')
-rw-r--r--src/libexpr/nixexpr.hh26
1 files changed, 2 insertions, 24 deletions
diff --git a/src/libexpr/nixexpr.hh b/src/libexpr/nixexpr.hh
index b38f19b41..6f2a4c0f9 100644
--- a/src/libexpr/nixexpr.hh
+++ b/src/libexpr/nixexpr.hh
@@ -8,6 +8,7 @@
#include "symbol-table.hh"
#include "error.hh"
#include "chunked-vector.hh"
+#include "position.hh"
namespace nix {
@@ -29,27 +30,6 @@ public:
using EvalError::EvalError;
};
-/**
- * Position objects.
- */
-struct Pos
-{
- uint32_t line;
- uint32_t column;
-
- struct none_tag { };
- struct Stdin { ref<std::string> source; };
- struct String { ref<std::string> source; };
-
- typedef std::variant<none_tag, Stdin, String, SourcePath> Origin;
-
- Origin origin;
-
- explicit operator bool() const { return line > 0; }
-
- operator std::shared_ptr<AbstractPos>() const;
-};
-
class PosIdx {
friend class PosTable;
@@ -82,7 +62,7 @@ public:
mutable uint32_t idx = std::numeric_limits<uint32_t>::max();
// Used for searching in PosTable::[].
- explicit Origin(uint32_t idx): idx(idx), origin{Pos::none_tag()} {}
+ explicit Origin(uint32_t idx): idx(idx), origin{std::monostate()} {}
public:
const Pos::Origin origin;
@@ -133,8 +113,6 @@ public:
inline PosIdx noPos = {};
-std::ostream & operator << (std::ostream & str, const Pos & pos);
-
struct Env;
struct Value;