diff options
author | pennae <github@quasiparticle.net> | 2022-04-22 21:45:39 +0200 |
---|---|---|
committer | pennae <github@quasiparticle.net> | 2022-04-25 15:37:01 +0200 |
commit | a385e51a086006c0f7d7c4bc6ed910dbe5375c4d (patch) | |
tree | 2b9776ddd7fa0977827e21379cd138cc54943071 /src/libexpr/value.hh | |
parent | 7f814d6d9af9d78f922d59115a94078f807676a8 (diff) |
rename SymbolIdx -> Symbol, Symbol -> SymbolStr
after #6218 `Symbol` no longer confers a uniqueness invariant on the
string it wraps, it is now possible to create multiple symbols that
compare equal but whose string contents have different addresses. this
guarantee is now only provided by `SymbolIdx`, leaving `Symbol` only as
a string wrapper that knows about the intricacies of how symbols need to
be formatted for output.
this change renames `SymbolIdx` to `Symbol` to restore the previous
semantics of `Symbol` to that name. we also keep the wrapper type and
rename it to `SymbolStr` instead of returning plain strings from lookups
into the symbol table because symbols are formatted for output in many
places. theoretically we do not need `SymbolStr`, only a function that
formats a string for output as a symbol, but having to wrap every symbol
that appears in a message into eg `formatSymbol()` is error-prone and
inconvient.
Diffstat (limited to 'src/libexpr/value.hh')
-rw-r--r-- | src/libexpr/value.hh | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/libexpr/value.hh b/src/libexpr/value.hh index c46dd4b73..58a8a56a0 100644 --- a/src/libexpr/value.hh +++ b/src/libexpr/value.hh @@ -55,7 +55,7 @@ struct Env; struct Expr; struct ExprLambda; struct PrimOp; -class SymbolIdx; +class Symbol; class PosIdx; struct Pos; class StorePath; @@ -251,11 +251,6 @@ public: void mkStringMove(const char * s, const PathSet & context); - inline void mkString(const Symbol & s) - { - mkString(std::string_view(s).data()); - } - inline void mkPath(const char * s) { clearValue(); @@ -410,12 +405,12 @@ public: #if HAVE_BOEHMGC typedef std::vector<Value *, traceable_allocator<Value *> > ValueVector; -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; +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; #else typedef std::vector<Value *> ValueVector; -typedef std::map<SymbolIdx, Value *> ValueMap; -typedef std::map<SymbolIdx, ValueVector> ValueVectorMap; +typedef std::map<Symbol, Value *> ValueMap; +typedef std::map<Symbol, ValueVector> ValueVectorMap; #endif |