aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/nixexpr.cc
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.cc
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.cc')
-rw-r--r--src/libexpr/nixexpr.cc63
1 files changed, 0 insertions, 63 deletions
diff --git a/src/libexpr/nixexpr.cc b/src/libexpr/nixexpr.cc
index b34112be1..eb5d0d3d4 100644
--- a/src/libexpr/nixexpr.cc
+++ b/src/libexpr/nixexpr.cc
@@ -11,58 +11,6 @@ namespace nix {
ExprBlackHole eBlackHole;
-struct PosAdapter : AbstractPos
-{
- Pos::Origin origin;
-
- PosAdapter(Pos::Origin origin)
- : origin(std::move(origin))
- {
- }
-
- std::optional<std::string> getSource() const override
- {
- return std::visit(overloaded {
- [](const Pos::none_tag &) -> std::optional<std::string> {
- return std::nullopt;
- },
- [](const Pos::Stdin & s) -> std::optional<std::string> {
- // Get rid of the null terminators added by the parser.
- return std::string(s.source->c_str());
- },
- [](const Pos::String & s) -> std::optional<std::string> {
- // Get rid of the null terminators added by the parser.
- return std::string(s.source->c_str());
- },
- [](const SourcePath & path) -> std::optional<std::string> {
- try {
- return path.readFile();
- } catch (Error &) {
- return std::nullopt;
- }
- }
- }, origin);
- }
-
- void print(std::ostream & out) const override
- {
- std::visit(overloaded {
- [&](const Pos::none_tag &) { out << "«none»"; },
- [&](const Pos::Stdin &) { out << "«stdin»"; },
- [&](const Pos::String & s) { out << "«string»"; },
- [&](const SourcePath & path) { out << path; }
- }, origin);
- }
-};
-
-Pos::operator std::shared_ptr<AbstractPos>() const
-{
- auto pos = std::make_shared<PosAdapter>(origin);
- pos->line = line;
- pos->column = column;
- return pos;
-}
-
// FIXME: remove, because *symbols* are abstract and do not have a single
// textual representation; see printIdentifier()
std::ostream & operator <<(std::ostream & str, const SymbolStr & symbol)
@@ -268,17 +216,6 @@ void ExprPos::show(const SymbolTable & symbols, std::ostream & str) const
}
-std::ostream & operator << (std::ostream & str, const Pos & pos)
-{
- if (auto pos2 = (std::shared_ptr<AbstractPos>) pos) {
- str << *pos2;
- } else
- str << "undefined position";
-
- return str;
-}
-
-
std::string showAttrPath(const SymbolTable & symbols, const AttrPath & attrPath)
{
std::ostringstream out;