Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Loading...
Searching...
No Matches
nixexpr.hh
Go to the documentation of this file.
1#pragma once
3
4#include <map>
5#include <span>
6#include <memory>
7#include <vector>
8#include <memory_resource>
9#include <algorithm>
10
11#include "nix/expr/gc-small-vector.hh"
12#include "nix/expr/value.hh"
14#include "nix/expr/eval-error.hh"
16#include "nix/util/pos-idx.hh"
17#include "nix/expr/counter.hh"
18#include "nix/util/pos-table.hh"
19#include "nix/util/error.hh"
21
22namespace nix {
23
24class EvalState;
25class PosTable;
26struct Env;
27struct ExprWith;
28struct StaticEnv;
29struct Value;
30
49{
50
55
60
68 operator bool() const
69 {
70 return static_cast<bool>(begin);
71 }
72
73 std::string getInnerText(const PosTable & positions) const;
74};
75
79struct AttrName
80{
81 Symbol symbol;
82 Expr * expr = nullptr;
83 AttrName(Symbol s)
84 : symbol(s) {};
85 AttrName(Expr * e)
86 : expr(e) {};
87};
88
89static_assert(std::is_trivially_copy_constructible_v<AttrName>);
90
91typedef std::vector<AttrName> AttrSelectionPath;
92
93std::string showAttrSelectionPath(const SymbolTable & symbols, std::span<const AttrName> attrPath);
94
95using UpdateQueue = SmallTemporaryValueVector<conservativeStackReservation>;
96
97/* Abstract syntax of Nix expressions. */
98
99struct Expr
100{
102 {
103 Symbol sub, lessThan, mul, div, or_, findFile, nixPath, body;
104 };
105
106 static Counter nrExprs;
107
108 Expr()
109 {
110 nrExprs++;
111 }
112
113 virtual ~Expr() {};
114 virtual void show(const SymbolTable & symbols, std::ostream & str) const;
115 virtual void bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env);
116
118 virtual void eval(EvalState & state, Env & env, Value & v);
119
121 void eval(EvalState & state, Env & env, Value & v, std::string_view errorCtx);
122
129 virtual Value * maybeThunk(EvalState & state, Env & env);
130
137 virtual void evalForUpdate(EvalState & state, Env & env, UpdateQueue & q, std::string_view errorCtx);
138 virtual void setName(Symbol name);
139 virtual void setDocComment(DocComment docComment) {};
140
141 virtual PosIdx getPos() const
142 {
143 return noPos;
144 }
145
146 // These are temporary methods to be used only in parser.y
147 virtual void resetCursedOr() {};
148 virtual void warnIfCursedOr(const SymbolTable & symbols, const PosTable & positions) {};
149};
150
151#define COMMON_METHODS \
152 void show(const SymbolTable & symbols, std::ostream & str) const override; \
153 void eval(EvalState & state, Env & env, Value & v) override; \
154 void bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) override;
155
156struct ExprInt : Expr
157{
158 Value v;
159
160 ExprInt(NixInt n)
161 {
162 v.mkInt(n);
163 };
164
165 ExprInt(NixInt::Inner n)
166 {
167 v.mkInt(n);
168 };
169
170 Value * maybeThunk(EvalState & state, Env & env) override;
171 COMMON_METHODS
172};
173
174struct ExprFloat : Expr
175{
176 Value v;
177
178 ExprFloat(NixFloat nf)
179 {
180 v.mkFloat(nf);
181 };
182
183 Value * maybeThunk(EvalState & state, Env & env) override;
184 COMMON_METHODS
185};
186
187struct ExprString : Expr
188{
189 Value v;
190
196 {
197 v.mkStringNoCopy(s);
198 };
199
200 ExprString(std::pmr::polymorphic_allocator<char> & alloc, std::string_view sv)
201 {
202 if (sv.size() == 0) {
203 v.mkStringNoCopy(""_sds);
204 return;
205 }
206 v.mkStringNoCopy(StringData::make(*alloc.resource(), sv));
207 };
208
209 Value * maybeThunk(EvalState & state, Env & env) override;
210 COMMON_METHODS
211};
212
213struct ExprPath : Expr
214{
215 ref<SourceAccessor> accessor;
216 Value v;
217
218 ExprPath(std::pmr::polymorphic_allocator<char> & alloc, ref<SourceAccessor> accessor, std::string_view sv)
219 : accessor(accessor)
220 {
221 v.mkPath(&*accessor, StringData::make(*alloc.resource(), sv));
222 }
223
224 Value * maybeThunk(EvalState & state, Env & env) override;
225 COMMON_METHODS
226};
227
228typedef uint32_t Level;
229typedef uint32_t Displacement;
230
231struct ExprVar : Expr
232{
233 PosIdx pos;
234 Symbol name;
235
236 /* Whether the variable comes from an environment (e.g. a rec, let
237 or function argument) or from a "with".
238
239 `nullptr`: Not from a `with`.
240 Valid pointer: the nearest, innermost `with` expression to query first. */
241 ExprWith * fromWith = nullptr;
242
243 /* In the former case, the value is obtained by going `level`
244 levels up from the current environment and getting the
245 `displ`th value in that environment. In the latter case, the
246 value is obtained by getting the attribute named `name` from
247 the set stored in the environment that is `level` levels up
248 from the current one.*/
249 Level level = 0;
250 Displacement displ = 0;
251
252 ExprVar(Symbol name)
253 : name(name) {};
254 ExprVar(const PosIdx & pos, Symbol name)
255 : pos(pos)
256 , name(name) {};
257 Value * maybeThunk(EvalState & state, Env & env) override;
258
259 PosIdx getPos() const override
260 {
261 return pos;
262 }
263
264 COMMON_METHODS
265};
266
272struct ExprInheritFrom : ExprVar
273{
274 ExprInheritFrom(PosIdx pos, Displacement displ)
275 : ExprVar(pos, {})
276 {
277 this->level = 0;
278 this->displ = displ;
279 this->fromWith = nullptr;
280 }
281
282 void bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) override;
283};
284
285struct ExprSelect : Expr
286{
287 PosIdx pos;
288 uint32_t nAttrPath;
289 Expr *e, *def;
290 AttrName * attrPathStart;
291
292 ExprSelect(
293 std::pmr::polymorphic_allocator<char> & alloc,
294 const PosIdx & pos,
295 Expr * e,
296 std::span<const AttrName> attrPath,
297 Expr * def)
298 : pos(pos)
299 , nAttrPath(attrPath.size())
300 , e(e)
301 , def(def)
302 , attrPathStart(alloc.allocate_object<AttrName>(nAttrPath))
303 {
304 std::ranges::copy(attrPath, attrPathStart);
305 };
306
307 ExprSelect(std::pmr::polymorphic_allocator<char> & alloc, const PosIdx & pos, Expr * e, Symbol name)
308 : pos(pos)
309 , nAttrPath(1)
310 , e(e)
311 , def(0)
312 , attrPathStart((alloc.allocate_object<AttrName>()))
313 {
314 *attrPathStart = AttrName(name);
315 };
316
317 PosIdx getPos() const override
318 {
319 return pos;
320 }
321
325 std::span<const AttrName> getAttrPath() const
326 {
327 return {attrPathStart, nAttrPath};
328 }
329
339 Symbol evalExceptFinalSelect(EvalState & state, Env & env, Value & attrs);
340
341 COMMON_METHODS
342};
343
344struct ExprOpHasAttr : Expr
345{
346 Expr * e;
347 std::span<AttrName> attrPath;
348
349 ExprOpHasAttr(std::pmr::polymorphic_allocator<char> & alloc, Expr * e, std::span<AttrName> attrPath)
350 : e(e)
351 , attrPath({alloc.allocate_object<AttrName>(attrPath.size()), attrPath.size()})
352 {
353 std::ranges::copy(attrPath, this->attrPath.begin());
354 };
355
356 PosIdx getPos() const override
357 {
358 return e->getPos();
359 }
360
361 COMMON_METHODS
362};
363
364struct ExprAttrs : Expr
365{
366 bool recursive;
367 PosIdx pos;
368
369 struct AttrDef
370 {
371 enum class Kind {
373 Plain,
375 Inherited,
377 InheritedFrom,
378 };
379
380 Kind kind;
381 Expr * e;
382 PosIdx pos;
383 Displacement displ = 0; // displacement
384 AttrDef(Expr * e, const PosIdx & pos, Kind kind = Kind::Plain)
385 : kind(kind)
386 , e(e)
387 , pos(pos) {};
388 AttrDef() {};
389
390 template<typename T>
391 const T & chooseByKind(const T & plain, const T & inherited, const T & inheritedFrom) const
392 {
393 switch (kind) {
394 case Kind::Plain:
395 return plain;
396 case Kind::Inherited:
397 return inherited;
398 default:
400 return inheritedFrom;
401 }
402 }
403 };
404
405 typedef std::pmr::map<Symbol, AttrDef> AttrDefs;
410 std::optional<AttrDefs> attrs;
411 std::unique_ptr<std::pmr::vector<Expr *>> inheritFromExprs;
412
413 struct DynamicAttrDef
414 {
415 Expr *nameExpr, *valueExpr;
416 PosIdx pos;
417 DynamicAttrDef(Expr * nameExpr, Expr * valueExpr, const PosIdx & pos)
418 : nameExpr(nameExpr)
419 , valueExpr(valueExpr)
420 , pos(pos) {};
421 };
422
423 typedef std::pmr::vector<DynamicAttrDef> DynamicAttrDefs;
427 std::optional<DynamicAttrDefs> dynamicAttrs;
428 ExprAttrs(const PosIdx & pos)
429 : recursive(false)
430 , pos(pos)
431 , attrs(AttrDefs{})
432 , dynamicAttrs(DynamicAttrDefs{}) {};
433 ExprAttrs()
434 : recursive(false)
435 , attrs(AttrDefs{})
436 , dynamicAttrs(DynamicAttrDefs{}) {};
437
438 PosIdx getPos() const override
439 {
440 return pos;
441 }
442
443 COMMON_METHODS
444
445 std::shared_ptr<const StaticEnv> bindInheritSources(EvalState & es, const std::shared_ptr<const StaticEnv> & env);
446 Env * buildInheritFromEnv(EvalState & state, Env & up);
447 void showBindings(const SymbolTable & symbols, std::ostream & str) const;
448 void moveDataToAllocator(std::pmr::polymorphic_allocator<char> & alloc);
449};
450
451struct ExprList : Expr
452{
453 std::span<Expr *> elems;
454
455 ExprList(std::pmr::polymorphic_allocator<char> & alloc, std::span<Expr *> exprs)
456 : elems({alloc.allocate_object<Expr *>(exprs.size()), exprs.size()})
457 {
458 std::ranges::copy(exprs, elems.begin());
459 };
460
461 COMMON_METHODS
462 Value * maybeThunk(EvalState & state, Env & env) override;
463
464 PosIdx getPos() const override
465 {
466 return elems.empty() ? noPos : elems.front()->getPos();
467 }
468};
469
470struct Formal
471{
472 PosIdx pos;
473 Symbol name;
474 Expr * def;
475};
476
478{
479 typedef std::vector<Formal> Formals_;
483 Formals_ formals;
484 bool ellipsis;
485
486 bool has(Symbol arg) const
487 {
488 auto it = std::lower_bound(
489 formals.begin(), formals.end(), arg, [](const Formal & f, const Symbol & sym) { return f.name < sym; });
490 return it != formals.end() && it->name == arg;
491 }
492};
493
494struct Formals
495{
496 std::span<Formal> formals;
497 bool ellipsis;
498
499 Formals(std::span<Formal> formals, bool ellipsis)
500 : formals(formals)
501 , ellipsis(ellipsis) {};
502
503 bool has(Symbol arg) const
504 {
505 auto it = std::lower_bound(
506 formals.begin(), formals.end(), arg, [](const Formal & f, const Symbol & sym) { return f.name < sym; });
507 return it != formals.end() && it->name == arg;
508 }
509
510 std::vector<Formal> lexicographicOrder(const SymbolTable & symbols) const
511 {
512 std::vector<Formal> result(formals.begin(), formals.end());
513 std::sort(result.begin(), result.end(), [&](const Formal & a, const Formal & b) {
514 std::string_view sa = symbols[a.name], sb = symbols[b.name];
515 return sa < sb;
516 });
517 return result;
518 }
519};
520
521struct ExprLambda : Expr
522{
523 PosIdx pos;
524 Symbol name;
525 Symbol arg;
526
527private:
528 bool hasFormals;
529 bool ellipsis;
530 uint16_t nFormals;
531 Formal * formalsStart;
532public:
533
534 std::optional<Formals> getFormals() const
535 {
536 if (hasFormals)
537 return Formals{{formalsStart, nFormals}, ellipsis};
538 else
539 return std::nullopt;
540 }
541
542 Expr * body;
543 DocComment docComment;
544
545 ExprLambda(
546 const PosTable & positions,
547 std::pmr::polymorphic_allocator<char> & alloc,
548 PosIdx pos,
549 Symbol arg,
550 const FormalsBuilder & formals,
551 Expr * body)
552 : pos(pos)
553 , arg(arg)
554 , hasFormals(true)
555 , ellipsis(formals.ellipsis)
556 , nFormals(formals.formals.size())
557 , formalsStart(alloc.allocate_object<Formal>(nFormals))
558 , body(body)
559 {
560 if (formals.formals.size() > nFormals) [[unlikely]] {
561 auto err = Error(
562 "too many formal arguments, implementation supports at most %1%",
563 std::numeric_limits<decltype(nFormals)>::max());
564 if (pos)
565 err.atPos(positions[pos]);
566 throw std::move(err);
567 }
568 std::uninitialized_copy_n(formals.formals.begin(), nFormals, formalsStart);
569 };
570
571 ExprLambda(PosIdx pos, Symbol arg, Expr * body)
572 : pos(pos)
573 , arg(arg)
574 , hasFormals(false)
575 , ellipsis(false)
576 , nFormals(0)
577 , formalsStart(nullptr)
578 , body(body) {};
579
580 ExprLambda(
581 const PosTable & positions,
582 std::pmr::polymorphic_allocator<char> & alloc,
583 PosIdx pos,
584 const FormalsBuilder & formals,
585 Expr * body)
586 : ExprLambda(positions, alloc, pos, Symbol(), formals, body) {};
587
588 void setName(Symbol name) override;
589 std::string showNamePos(const EvalState & state) const;
590
591 PosIdx getPos() const override
592 {
593 return pos;
594 }
595
596 virtual void setDocComment(DocComment docComment) override;
597 COMMON_METHODS
598};
599
600struct ExprCall : Expr
601{
602 Expr * fun;
606 std::optional<std::pmr::vector<Expr *>> args;
607 PosIdx pos;
608 std::optional<PosIdx> cursedOrEndPos; // used during parsing to warn about https://github.com/NixOS/nix/issues/11118
609
610 ExprCall(const PosIdx & pos, Expr * fun, std::pmr::vector<Expr *> && args)
611 : fun(fun)
612 , args(args)
613 , pos(pos)
614 , cursedOrEndPos({})
615 {
616 }
617
618 ExprCall(const PosIdx & pos, Expr * fun, std::pmr::vector<Expr *> && args, PosIdx && cursedOrEndPos)
619 : fun(fun)
620 , args(args)
621 , pos(pos)
622 , cursedOrEndPos(cursedOrEndPos)
623 {
624 }
625
626 PosIdx getPos() const override
627 {
628 return pos;
629 }
630
631 virtual void resetCursedOr() override;
632 virtual void warnIfCursedOr(const SymbolTable & symbols, const PosTable & positions) override;
633 void moveDataToAllocator(std::pmr::polymorphic_allocator<char> & alloc);
634 COMMON_METHODS
635};
636
637struct ExprLet : Expr
638{
639 ExprAttrs * attrs;
640 Expr * body;
641 ExprLet(ExprAttrs * attrs, Expr * body)
642 : attrs(attrs)
643 , body(body) {};
644 COMMON_METHODS
645};
646
647struct ExprWith : Expr
648{
649 PosIdx pos;
650 uint32_t prevWith;
651 Expr *attrs, *body;
652 ExprWith * parentWith;
653 ExprWith(const PosIdx & pos, Expr * attrs, Expr * body)
654 : pos(pos)
655 , attrs(attrs)
656 , body(body) {};
657
658 PosIdx getPos() const override
659 {
660 return pos;
661 }
662
663 COMMON_METHODS
664};
665
666struct ExprIf : Expr
667{
668 PosIdx pos;
669 Expr *cond, *then, *else_;
670 ExprIf(const PosIdx & pos, Expr * cond, Expr * then, Expr * else_)
671 : pos(pos)
672 , cond(cond)
673 , then(then)
674 , else_(else_) {};
675
676 PosIdx getPos() const override
677 {
678 return pos;
679 }
680
681 COMMON_METHODS
682};
683
684struct ExprAssert : Expr
685{
686 PosIdx pos;
687 Expr *cond, *body;
688 ExprAssert(const PosIdx & pos, Expr * cond, Expr * body)
689 : pos(pos)
690 , cond(cond)
691 , body(body) {};
692
693 PosIdx getPos() const override
694 {
695 return pos;
696 }
697
698 COMMON_METHODS
699};
700
701struct ExprOpNot : Expr
702{
703 Expr * e;
704 ExprOpNot(Expr * e)
705 : e(e) {};
706
707 PosIdx getPos() const override
708 {
709 return e->getPos();
710 }
711
712 COMMON_METHODS
713};
714
715#define MakeBinOpMembers(name, s) \
716 PosIdx pos; \
717 Expr *e1, *e2; \
718 name(Expr * e1, Expr * e2) \
719 : e1(e1) \
720 , e2(e2){}; \
721 name(const PosIdx & pos, Expr * e1, Expr * e2) \
722 : pos(pos) \
723 , e1(e1) \
724 , e2(e2){}; \
725 void show(const SymbolTable & symbols, std::ostream & str) const override \
726 { \
727 str << "("; \
728 e1->show(symbols, str); \
729 str << " " s " "; \
730 e2->show(symbols, str); \
731 str << ")"; \
732 } \
733 void bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) override \
734 { \
735 e1->bindVars(es, env); \
736 e2->bindVars(es, env); \
737 } \
738 void eval(EvalState & state, Env & env, Value & v) override; \
739 PosIdx getPos() const override \
740 { \
741 return pos; \
742 }
743
744#define MakeBinOp(name, s) \
745 struct name : Expr \
746 { \
747 MakeBinOpMembers(name, s) \
748 }
749
750MakeBinOp(ExprOpEq, "==");
751MakeBinOp(ExprOpNEq, "!=");
752MakeBinOp(ExprOpAnd, "&&");
753MakeBinOp(ExprOpOr, "||");
754MakeBinOp(ExprOpImpl, "->");
755MakeBinOp(ExprOpConcatLists, "++");
756
757struct ExprOpUpdate : Expr
758{
759private:
761 void eval(EvalState & state, Value & v, Value & v1, Value & v2);
762 void evalForUpdate(EvalState & state, Env & env, UpdateQueue & q);
763
764public:
765 MakeBinOpMembers(ExprOpUpdate, "//");
766 virtual void evalForUpdate(EvalState & state, Env & env, UpdateQueue & q, std::string_view errorCtx) override;
767};
768
769struct ExprConcatStrings : Expr
770{
771 PosIdx pos;
772 bool forceString;
773 std::span<std::pair<PosIdx, Expr *>> es;
774
775 ExprConcatStrings(
776 std::pmr::polymorphic_allocator<char> & alloc,
777 const PosIdx & pos,
778 bool forceString,
779 std::span<std::pair<PosIdx, Expr *>> es)
780 : pos(pos)
781 , forceString(forceString)
782 , es({alloc.allocate_object<std::pair<PosIdx, Expr *>>(es.size()), es.size()})
783 {
784 std::ranges::copy(es, this->es.begin());
785 };
786
787 ExprConcatStrings(
788 std::pmr::polymorphic_allocator<char> & alloc,
789 const PosIdx & pos,
790 bool forceString,
791 std::initializer_list<std::pair<PosIdx, Expr *>> es)
792 : pos(pos)
793 , forceString(forceString)
794 , es({alloc.allocate_object<std::pair<PosIdx, Expr *>>(es.size()), es.size()})
795 {
796 std::ranges::copy(es, this->es.begin());
797 };
798
799 PosIdx getPos() const override
800 {
801 return pos;
802 }
803
804 COMMON_METHODS
805};
806
807struct ExprPos : Expr
808{
809 PosIdx pos;
810 ExprPos(const PosIdx & pos)
811 : pos(pos) {};
812
813 PosIdx getPos() const override
814 {
815 return pos;
816 }
817
818 COMMON_METHODS
819};
820
821/* only used to mark thunks as black holes. */
822struct ExprBlackHole : Expr
823{
824 void show(const SymbolTable & symbols, std::ostream & str) const override {}
825
826 void eval(EvalState & state, Env & env, Value & v) override;
827
828 void bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> & env) override {}
829
830 [[noreturn]] static void throwInfiniteRecursionError(EvalState & state, Value & v);
831};
832
833extern ExprBlackHole eBlackHole;
834
835class Exprs
836{
837 /* Thread-safe fallback resource, which might be a bit slower. */
838 std::pmr::synchronized_pool_resource fallbackResource;
839 BumpMemoryResource buffer{BumpMemoryResource::defaultReserveSize, &fallbackResource};
840
841public:
842 std::pmr::polymorphic_allocator<char> alloc{&buffer};
843
844 template<class C>
845 [[gnu::always_inline]]
846 C * add(auto &&... args)
847 {
848 return alloc.new_object<C>(std::forward<decltype(args)>(args)...);
849 }
850
851 // we define some calls to add explicitly so that the argument can be passed in as initializer lists
852 template<class C>
853 [[gnu::always_inline]]
854 C * add(const PosIdx & pos, Expr * fun, std::pmr::vector<Expr *> && args)
855 requires(std::same_as<C, ExprCall>)
856 {
857 return alloc.new_object<C>(pos, fun, std::move(args));
858 }
859
860 template<class C>
861 [[gnu::always_inline]]
862 C * add(const PosIdx & pos, Expr * fun, std::pmr::vector<Expr *> && args, PosIdx && cursedOrEndPos)
863 requires(std::same_as<C, ExprCall>)
864 {
865 return alloc.new_object<C>(pos, fun, std::move(args), std::move(cursedOrEndPos));
866 }
867
868 template<class C>
869 [[gnu::always_inline]]
870 C *
871 add(std::pmr::polymorphic_allocator<char> & alloc,
872 const PosIdx & pos,
873 bool forceString,
874 std::span<std::pair<PosIdx, Expr *>> es)
875 requires(std::same_as<C, ExprConcatStrings>)
876 {
877 return alloc.new_object<C>(alloc, pos, forceString, es);
878 }
879
880 template<class C>
881 [[gnu::always_inline]]
882 C *
883 add(std::pmr::polymorphic_allocator<char> & alloc,
884 const PosIdx & pos,
885 bool forceString,
886 std::initializer_list<std::pair<PosIdx, Expr *>> es)
887 requires(std::same_as<C, ExprConcatStrings>)
888 {
889 return alloc.new_object<C>(alloc, pos, forceString, es);
890 }
891};
892
893/* Static environments are used to map variable names onto (level,
894 displacement) pairs used to obtain the value of the variable at
895 runtime. */
896struct StaticEnv
897{
898 ExprWith * isWith;
899 std::shared_ptr<const StaticEnv> up;
900
901 // Note: these must be in sorted order.
902 typedef std::vector<std::pair<Symbol, Displacement>> Vars;
903 Vars vars;
904
905 StaticEnv(ExprWith * isWith, std::shared_ptr<const StaticEnv> up, size_t expectedSize = 0)
906 : isWith(isWith)
907 , up(std::move(up))
908 {
909 vars.reserve(expectedSize);
910 };
911
912 void sort()
913 {
914 std::stable_sort(vars.begin(), vars.end(), [](const Vars::value_type & a, const Vars::value_type & b) {
915 return a.first < b.first;
916 });
917 }
918
919 void deduplicate()
920 {
921 auto it = vars.begin(), jt = it, end = vars.end();
922 while (jt != end) {
923 *it = *jt++;
924 while (jt != end && it->first == jt->first)
925 *it = *jt++;
926 it++;
927 }
928 vars.erase(it, end);
929 }
930
931 Vars::const_iterator find(Symbol name) const
932 {
933 Vars::value_type key(name, 0);
934 auto i = std::lower_bound(vars.begin(), vars.end(), key);
935 if (i != vars.end() && i->first == name)
936 return i;
937 return vars.end();
938 }
939};
940
941} // namespace nix
Definition bump-memory-resource.hh:15
Definition error.hh:310
Definition eval.hh:420
Definition nixexpr.hh:836
Definition pos-idx.hh:10
Definition pos-table.hh:15
Definition value.hh:213
static const StringData & make(EvalMemory &mem, std::string_view s)
Definition eval.cc:98
Definition symbol-table.hh:266
Definition symbol-table.hh:24
Definition fun.hh:19
Definition ref.hh:58
This file defines two main structs/classes used in nix error handling.
Definition nixexpr.hh:80
Definition counter.hh:15
Definition nixexpr.hh:49
PosIdx end
Definition nixexpr.hh:59
PosIdx begin
Definition nixexpr.hh:54
Definition eval.hh:197
Definition nixexpr.hh:370
Kind
Definition nixexpr.hh:371
@ Plain
Definition nixexpr.hh:373
@ Inherited
Definition nixexpr.hh:375
@ InheritedFrom
Definition nixexpr.hh:377
Definition nixexpr.hh:365
std::optional< DynamicAttrDefs > dynamicAttrs
Definition nixexpr.hh:427
std::optional< AttrDefs > attrs
Definition nixexpr.hh:410
Definition nixexpr.hh:823
void eval(EvalState &state, Env &env, Value &v) override
Definition eval.cc:2239
std::optional< std::pmr::vector< Expr * > > args
Definition nixexpr.hh:606
Value * maybeThunk(EvalState &state, Env &env) override
Definition eval.cc:1103
Value * maybeThunk(EvalState &state, Env &env) override
Definition eval.cc:1097
Value * maybeThunk(EvalState &state, Env &env) override
Definition eval.cc:1428
Value * maybeThunk(EvalState &state, Env &env) override
Definition eval.cc:1109
std::span< const AttrName > getAttrPath() const
Definition nixexpr.hh:325
Symbol evalExceptFinalSelect(EvalState &state, Env &env, Value &attrs)
Definition eval.cc:1537
Value * maybeThunk(EvalState &state, Env &env) override
Definition eval.cc:1091
ExprString(const StringData &s)
Definition nixexpr.hh:195
Value * maybeThunk(EvalState &state, Env &env) override
Definition eval.cc:1079
Definition nixexpr.hh:648
Definition nixexpr.hh:102
Definition nixexpr.hh:100
virtual void eval(EvalState &state, Env &env, Value &v)
Definition eval.cc:1258
virtual void evalForUpdate(EvalState &state, Env &env, UpdateQueue &q, std::string_view errorCtx)
Definition eval.cc:2072
virtual Value * maybeThunk(EvalState &state, Env &env)
Definition eval.cc:1072
Definition nixexpr.hh:471
Definition nixexpr.hh:478
Formals_ formals
Definition nixexpr.hh:483
Definition nixexpr.hh:495
Definition nixexpr.hh:897
Definition value.hh:1166