about summary refs log tree commit diff
path: root/src/libexpr/eval.cc
AgeCommit message (Collapse)AuthorFilesLines
2014-12-12 Remove canary stuffEelco Dolstra1-21/+0
2014-12-02 Make all ExternalValueBase functions constShea Levy1-3/+3
2014-12-02 Allow external code using libnixexpr to add typesShea Levy1-0/+33
Code that links to libnixexpr (e.g. plugins loaded with importNative, or nix-exec) may want to provide custom value types and operations on values of those types. For example, nix-exec is currently using sets where a custom IO value type would be more appropriate. This commit provides a generic hook for such types in the form of tExternal and the ExternalBase virtual class, which contains all functions necessary for libnixexpr's type-polymorphic functions (e.g. `showType`) to be implemented.
2014-11-25 forceString(): Accept pos argumentEelco Dolstra1-2/+2
2014-11-15 Add functors (callable attribute sets).Shea Levy1-0/+12
With this, attribute sets with a `__functor` attribute can be applied just like normal functions. This can be used to attach arbitrary metadata to a function without callers needing to treat it specially.
2014-10-31 Fix more warningsEelco Dolstra1-11/+1
2014-10-09 mkList: Scrub betterEelco Dolstra1-0/+1
Clearing v.app.right was not enough, because the length field of a list only takes 32 bits, so the most significant 32 bits of v.app.left (a.k.a. v.thunk.env) would remain. This could cause Boehm GC to interpret it as a valid pointer. This change reduces maximum RSS for evaluating the ‘tested’ job in nixos/release-small.nix from 1.33 GiB to 0.80 GiB, and runtime by about 8%.
2014-10-05 Get rid of some unnecessary ExprConcatStrings nodes in dynamic attrsEelco Dolstra1-6/+3
This gives a ~18% speedup in NixOS evaluation (after converting most calls to hasAttr/getAttr to dynamic attrs).
2014-10-05 Show total allocationsEelco Dolstra1-8/+10
2014-10-01 printValue(): Don't print <CYCLE> for repeated valuesEelco Dolstra1-7/+9
2014-09-22 Make forceValueDeep work on values with cyclesEelco Dolstra1-9/+20
2014-09-22 Rename strictForceValue -> forceValueDeepEelco Dolstra1-3/+3
2014-09-22 Handle cycles when printing a valueEelco Dolstra1-5/+23
So this no longer crashes with a stack overflow: nix-instantiate -E --eval 'let as = { x = as; }; in as' Instead it prints: { x = { x = <CYCLE>; }; }
2014-09-22 Add a function ‘valueSize’Eelco Dolstra1-0/+80
It returns the size of value, including all other values and environments reachable from it. It is intended for debugging memory consumption issues.
2014-09-19 Inline Bindings::find()Eelco Dolstra1-9/+0
2014-09-19 Store Attrs inside BindingsEelco Dolstra1-14/+25
This prevents a double allocation per attribute set.
2014-09-17 Add some instrumentation for debugging GC leaksEelco Dolstra1-0/+22
2014-09-02 Fix boost::too_many_args errorEelco Dolstra1-1/+1
Fixes #333.
2014-08-20 Use proper quotes everywhereEelco Dolstra1-14/+14
2014-08-13 Fix warning about non-existant -I directoriesEelco Dolstra1-1/+1
2014-06-10 == operator: Ignore string contextEelco Dolstra1-11/+2
There really is no case I can think of where taking the context into account is useful. Mostly it's just very inconvenient.
2014-05-26 Remove ExprBuiltinEelco Dolstra1-11/+0
It's slower than ExprVar since it doesn't compute a static displacement. Since we're not using the throw primop in the implementation of <...> anymore, it's also not really needed.
2014-05-26 Ensure that -I flags get included in nixPathEelco Dolstra1-4/+3
Also fixes #261.
2014-05-15 Provide a more useful error message when a dynamic attr lookup failsShea Levy1-2/+10
2014-04-04 Show position info in attribute selection errorsEelco Dolstra1-7/+7
2014-04-04 Show position info in Boolean operationsEelco Dolstra1-7/+17
2014-04-04 Show position info in string concatenation / addition errorsEelco Dolstra1-12/+27
2014-04-04 forceString: Show position infoEelco Dolstra1-9/+24
2014-04-04 forceAttrs: Show position infoEelco Dolstra1-1/+1
2014-04-04 forceList: Show position infoEelco Dolstra1-7/+2
2014-04-04 forceInt: Show position infoEelco Dolstra1-2/+2
2014-04-04 Pass position information to primop callsEelco Dolstra1-3/+3
For example: error: `tail' called on an empty list, at /home/eelco/Dev/nixpkgs/pkgs/applications/misc/hello/ex-2/default.nix:13:7
2014-04-04 Include position info in function applicationEelco Dolstra1-12/+19
This allows error messages like: error: the anonymous function at `/etc/nixos/configuration.nix:1:1' called without required argument `foo', at `/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix:77:59'
2014-03-30 boost::shared_ptr -> std::shared_ptrEelco Dolstra1-0/+1
2014-03-10 The expr of AttrNames/DynamicAttrDefs is always an ExprConcatStringsShea Levy1-5/+3
2014-03-10 If a dynamic attribute name evaluates to null, remove it from the setShea Levy1-1/+9
2014-03-05 Revert "Make ifs and asserts tail-recursive"Eelco Dolstra1-10/+4
This reverts commit 273322c7732093a354e86df82cf75d6604b8bce8.
2014-02-27 Correctly detect infinite recursion in function applicationEelco Dolstra1-2/+4
If we're evaluating some application ‘v = f x’, we can't store ‘f’ temporarily in ‘v’, because if ‘f x’ refers to ‘v’, it will get ‘f’ rather than an infinite recursion error. Unfortunately, this breaks the tail call optimisation introduced in c897bac54954373f63511702731fe2cb23c0c98e. Fixes #217.
2014-01-21 Merge branch 'master' into makeEelco Dolstra1-4/+51
Conflicts: src/libexpr/eval.cc
2013-12-31 Don't use any syntactic sugar for dynamic attrsShea Levy1-3/+17
This doesn't change any functionality but moves some behavior out of the parser and into the evaluator in order to simplify the code. Signed-off-by: Shea Levy <shea@shealevy.com>
2013-12-31 Dynamic attrsShea Levy1-1/+23
This adds new syntax for attribute names: * attrs."${name}" => getAttr name attrs * attrs ? "${name}" => isAttrs attrs && hasAttr attrs name * attrs."${name}" or def => if attrs ? "${name}" then attrs."${name}" else def * { "${name}" = value; } => listToAttrs [{ inherit name value; }] Of course, it's a bit more complicated than that. The attribute chains can be arbitrarily long and contain combinations of static and dynamic parts (e.g. attrs."${foo}".bar."${baz}" or qux), which is relatively straightforward for the getAttrs/hasAttrs cases but is more complex for the listToAttrs case due to rules about duplicate attribute definitions. For attribute sets with dynamic attribute names, duplicate static attributes are detected at parse time while duplicate dynamic attributes are detected when the attribute set is forced. So, for example, { a = null; a.b = null; "${"c"}" = true; } will be a parse-time error, while { a = {}; "${"a"}".b = null; c = true; } will be an eval-time error (technically that case could theoretically be detected at parse time, but the general case would require full evaluation). Moreover, duplicate dynamic attributes are not allowed even in cases where they would be with static attributes ({ a.b.d = true; a.b.c = false; } is legal, but { a."${"b"}".d = true; a."${"b"}".c = false; } is not). This restriction might be relaxed in the future in cases where the static variant would not be an error, but it is not obvious that that is desirable. Finally, recursive attribute sets with dynamic attributes have the static attributes in scope but not the dynamic ones. So rec { a = true; "${"b"}" = a; } is equivalent to { a = true; b = true; } but rec { "${"a"}" = true; b = a; } would be an error or use a from the surrounding scope if it exists. Note that the getAttr, getAttr or default, and hasAttr are all implemented purely in the parser as syntactic sugar, while attribute sets with dynamic attribute names required changes to the AST to be implemented cleanly. This is an alternative solution to and closes #167 Signed-off-by: Shea Levy <shea@shealevy.com>
2013-12-31 Add the ExprBuiltin Expr type to the ASTShea Levy1-0/+11
Certain desugaring schemes may require the parser to use some builtin function to do some of the work (e.g. currently `throw` is used to lazily cause an error if a `<>`-style path is not in the search path) Unfortunately, these names are not reserved keywords, so an expression that uses such a syntactic sugar will not see the expected behavior (see tests/lang/eval-okay-redefine-builtin.nix for an example). This adds the ExprBuiltin AST type, which when evaluated uses the value from the rootmost variable scope (which of course is initialized internally and can't shadow any of the builtins). Signed-off-by: Shea Levy <shea@shealevy.com>
2013-11-23 Drop the dependency on libgc in libmainEelco Dolstra1-0/+17
Instead, libexpr now depends on libgc. This means commands like nix-store that don't do any evaluation no longer require libgc.
2013-11-23 Initialise Boehm GC only onceEelco Dolstra1-2/+2
2013-11-19 Add a toJSON primopEelco Dolstra1-20/+23
2013-11-18 Add a primop unsafeGetAttrPos to return the position of an attributeEelco Dolstra1-5/+14
2013-11-18 Add a symbol __curPos that expands to the current source locationEelco Dolstra1-0/+13
I.e. an attribute set { file = <string>; line = <int>; column = <int>; }.
2013-11-12 Make function calls show up in stack traces againEelco Dolstra1-20/+28
Note that adding --show-trace prevents functions calls from being tail-recursive, so an expression that evaluates without --show-trace may fail with a stack overflow if --show-trace is given.
2013-11-12 Make function calls tail-recursiveEelco Dolstra1-38/+60
2013-11-12 Make ifs and asserts tail-recursiveEelco Dolstra1-4/+10
The local Value object prevented g++ from making a tail call. Not clear why. In any case, not using a temporary makes g++ do the tail call.