1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-24 22:11:15 +02:00

libexpr: Add and use pathAccessor getter

This commit is contained in:
Sergei Zimmerman 2025-06-12 20:01:38 +00:00
parent e4df189123
commit bc6b52aff0
No known key found for this signature in database
GPG key ID: A9B0B557CA632325
2 changed files with 6 additions and 3 deletions

View file

@ -2636,7 +2636,7 @@ void EvalState::assertEqValues(Value & v1, Value & v2, const PosIdx pos, std::st
return; return;
case nPath: case nPath:
if (v1.payload.path.accessor != v2.payload.path.accessor) { if (v1.pathAccessor() != v2.pathAccessor()) {
error<AssertionError>( error<AssertionError>(
"path '%s' is not equal to path '%s' because their accessors are different", "path '%s' is not equal to path '%s' because their accessors are different",
ValuePrinter(*this, v1, errorPrintOptions), ValuePrinter(*this, v1, errorPrintOptions),
@ -2810,7 +2810,7 @@ bool EvalState::eqValues(Value & v1, Value & v2, const PosIdx pos, std::string_v
case nPath: case nPath:
return return
// FIXME: compare accessors by their fingerprint. // FIXME: compare accessors by their fingerprint.
v1.payload.path.accessor == v2.payload.path.accessor v1.pathAccessor() == v2.pathAccessor()
&& strcmp(v1.pathStr(), v2.pathStr()) == 0; && strcmp(v1.pathStr(), v2.pathStr()) == 0;
case nNull: case nNull:

View file

@ -444,7 +444,7 @@ public:
{ {
assert(internalType == tPath); assert(internalType == tPath);
return SourcePath( return SourcePath(
ref(payload.path.accessor->shared_from_this()), ref(pathAccessor()->shared_from_this()),
CanonPath(CanonPath::unchecked_t(), pathStr())); CanonPath(CanonPath::unchecked_t(), pathStr()));
} }
@ -497,6 +497,9 @@ public:
const char * pathStr() const const char * pathStr() const
{ return payload.path.path; } { return payload.path.path; }
SourceAccessor * pathAccessor() const
{ return payload.path.accessor; }
}; };