about summary refs log tree commit diff
path: root/tvix/eval/src/compiler.rs (follow)
AgeCommit message (Collapse)AuthorFilesLines
2022-09-02 r/4602 chore(tvix/eval): move compiler module to a new folderVincent Ambo1-1093/+0
Change-Id: I76157f9cf1369cd17506de1b1ded1a4fd06f004a Reviewed-on: https://cl.tvl.fyi/c/depot/+/6268 Reviewed-by: grfn <grfn@gws.fyi> Tested-by: BuildkiteCI
2022-09-02 r/4600 refactor(tvix/eval): separate out `let inherit ...` logicVincent Ambo1-9/+14
Compilation of `let`-expressions is going to become a lot more complicated due to attempts to avoid thunking when encountering internal references, so this is just being moved out of the way. Change-Id: Iecfa4b13d14532e21c2540e6561b4235ce29736a Reviewed-on: https://cl.tvl.fyi/c/depot/+/6266 Reviewed-by: grfn <grfn@gws.fyi> Tested-by: BuildkiteCI
2022-09-02 r/4598 fix(tvix/eval): consider `let ... inherit ...` in dynamic scopesVincent Ambo1-3/+24
In conditions where no dynamic identifiers exist in a scope, inheriting is usually a no-op - *unless* the identifier is not statically known and the scope has a non-empty `with`-stack. Change-Id: Iff4138d9cd4c56e844bc574203708dacc11c3f73 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6264 Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2022-09-02 r/4591 feat(tvix/eval): emit warnings when globals are being shadowedVincent Ambo1-0/+1
Change-Id: I7dae6978c2a4548382d7fa059b20ccdf35d2cf7f Reviewed-on: https://cl.tvl.fyi/c/depot/+/6257 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-09-02 r/4588 feat(tvix/eval): introduce mechanism for defining builtinsVincent Ambo1-5/+6
Adds a new builtins module in which builtins can be constructed. The functions in this module should return a correctly structured value to be passed to the compiler's `globals`. This is wired up all the way to the compiler with an example `toString` builtin, available as a global. Note that this does not yet actually behave like the real toString, which has some differences from `Display`. Change-Id: Ibb5f6fbe6207782fdf2434435567fc1bd80039a5 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6254 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-09-02 r/4587 refactor(tvix/eval): handle scope poisoning & globals dynamicallyVincent Ambo1-61/+125
Previously, the tokens that could poison a scope (`true`, `false`, `null`) had individual fields in the scope to track whether or not they were poisoned. This commit sets up new machinery that instead tracks scope poisoning dynamically using a HashMap, and which makes it possible to introduce additional tokens to the top-level ("global") scope that are directly resolved by the compiler by passing a map of runtime values to be used. With this solution, the compiler now contains all machinery required for wiring up builtins resolution. The set of builtins to be exposed at runtime must, however, be constructed *outside* of the compiler and passed in. Everything is prepared for this, but it is not yet wired up (so the only existing builtins are the ones we already had before). Note that this technically opens up an optimisation potential when compiling selection operations, where the attribute set being selected from is `builtins`. The compiler could directly resolve the builtins and place the right values on the stack. Change-Id: Ia7dad3c2a98703e7ea0c6ace1a722d57cc70a65c Reviewed-on: https://cl.tvl.fyi/c/depot/+/6253 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-09-02 r/4584 feat(tvix/eval): compile function applicationsVincent Ambo1-1/+11
Change-Id: I1b9230601895a1f09ef1a8037201147020b85f36 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6250 Reviewed-by: sterni <sternenseemann@systemli.org> Reviewed-by: grfn <grfn@gws.fyi> Tested-by: BuildkiteCI
2022-09-01 r/4581 feat(tvix/eval): compile lambda definitionsVincent Ambo1-1/+40
Compiles lambda definitions of the simple form (i.e. without formals arguments) and emits them as constants like any other value. This does not yet implement actually invoking these functions in the VM. Change-Id: Ie1e0a13220b68c1728be229b875f0992e685c5ef Reviewed-on: https://cl.tvl.fyi/c/depot/+/6247 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
2022-09-01 r/4580 refactor(tvix/eval): introduce LambdaCtx structure to compilerVincent Ambo1-7/+28
This structure carries context about the lambda currently being compiled (which may well be the top-level lambda of an input AST). Using the indirection helpers in the compiler, things like the scope, code and constants of the function being compiled are now taken from the current lambda context instead. Change-Id: If5f864d826c2e72855cee4b728ea1830e9b5ac06 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6246 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
2022-09-01 r/4579 refactor(tvix/eval): add compiler accessor for current scopeVincent Ambo1-38/+42
Change-Id: I7488087d95c1b3fb7f70fc29af0d5b0d0a25a428 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6245 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
2022-09-01 r/4576 refactor(tvix/eval): return a lambda from the compilerVincent Ambo1-6/+7
Changes the internal compiler plumbing to not just return a chunk of code, but the same chunk wrapped inside of a lambda value. This is one more step towards compiling runtime lambdas. Change-Id: If0035f8e65a2970c5ae123fc068a2396e1d8fd72 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6240 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
2022-09-01 r/4575 refactor(tvix/eval): add accessor indirection helpers to compilerVincent Ambo1-73/+74
With these indirections in place it becomes easier to change internals of the compiler when introducing functions, which need the compiler to be able to target different code chunks. Change-Id: I4eb11572a93c140b1d059ba0a5af905756745d65 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6239 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
2022-09-01 r/4573 feat(tvix/eval): emit warnings for unused local bindingsVincent Ambo1-20/+49
Change-Id: I6e876a8f4d062297abae812b14ed8ec17a502f2c Reviewed-on: https://cl.tvl.fyi/c/depot/+/6237 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
2022-09-01 r/4572 refactor(tvix/eval): collect vector of errors in compilerVincent Ambo1-99/+100
Instead of exiting the compiler at the first sight of an error, skip any erroneous nodes and continue compiling, collecting more errors along the way. This paves the way for nicer error reporting in which multiple errors can be reported at once, avoiding situations in which users are hunting a fault error-by-error and possibly getting distracted by less useful output. Change-Id: I80c9a87272e33a31297167ae2eb2706a46adf15a Reviewed-on: https://cl.tvl.fyi/c/depot/+/6236 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
2022-09-01 r/4571 feat(tvix/eval): carry optional SyntaxNode in error typeVincent Ambo1-7/+7
This starts paving the way for nicer, source-code based error reporting. Right now the code paths in the VM do not emit annotated errors, as we do not yet preserve that structure from the compiler. However, error emitting code paths in the compiler have been amended to include known nodes. Change-Id: I1b74410ffd891c40cd913361bd73c4336ec8aa5b Reviewed-on: https://cl.tvl.fyi/c/depot/+/6235 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
2022-09-01 r/4570 refactor(tvix/eval): add helper for emitting compiler warningsVincent Ambo1-8/+6
Change-Id: I2d98dbb7274d07985f64e7cc8944e316bf42e1bf Reviewed-on: https://cl.tvl.fyi/c/depot/+/6234 Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2022-09-01 r/4569 chore(tvix/eval): bump rnix-parser to latest masterVincent Ambo1-5/+5
In this commit, the string interpolation parsing is identical to nixpkgs which makes some of the upstream Nix tests for interpolation-related weirdness pass. Change-Id: I3a295cfdc404c32228a54846e6efd3c0dcee5842 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6233 Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2022-09-01 r/4567 refactor(tvix/eval): Upgrade to latest rnix-parserVincent Ambo1-454/+345
Since the latest published version of rnix-parser on crates.io, the crate has undergone major changes which are only available in the git repository at the moment. This commit updates the compiler to this newer version of rnix. Most notably, the entire AST provided by rnix is now wrapped in the AST type system. As a result of this traversal is much nicer in many places, especially for things like nested attribute selection. There are a handful of smaller features missing for full feature parity with the previous version, especially handling of path literals, but PRs for these already exist in rnix-parser. Change-Id: Icde6d393067976549492b7d89c4cc49e5e575fc7 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6231 Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2022-09-01 r/4566 feat(tvix/eval): implement `assert` operatorVincent Ambo1-0/+16
This implements `assert`, which evaluates an expression and aborts evaluation if the value is not `true`. At this point we should introduce eval-failed-* tests; probably asserting against some representation of the error enum? Change-Id: If54c8f616d89b829c1860a4835dde60a2cd70d7a Reviewed-on: https://cl.tvl.fyi/c/depot/+/6230 Reviewed-by: grfn <grfn@gws.fyi> Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2022-09-01 r/4562 refactor(tvix/eval): improve naming for locals manipulator methodsVincent Ambo1-5/+9
`push_local`/`push_phantom` were worse names because they sound like the value itself is being pushed, where in actuality it is just being declared to the compiler. Change-Id: Ibfda5c4c8e47d5d3262bfe005b0f1f84908a117e Reviewed-on: https://cl.tvl.fyi/c/depot/+/6228 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-08-31 r/4561 feat(tvix/eval): implement scope poisoning for true/false/nullVincent Ambo1-5/+45
These tokens are optionally parsed as identifiers by Nix, which means that within any scopes that resolve them the compiler needs to track whether they have been overridden to know whether to emit the literal instructions or resolve a variable. This is implemented by a new concept of "scope poisoning", where the compiler's scope structure tracks whether or not any builtin identifiers have been overridden. Change-Id: I3ab711146e229f843f6e1f0343385382ee0aecb6 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6227 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org> Reviewed-by: grfn <grfn@gws.fyi>
2022-08-31 r/4560 refactor(tvix/eval): simplify `let ... in ...` before recursionVincent Ambo1-30/+6
While full recursion through thunking is not available, there are actually incorrect behaviours introduced by declaring before binding (example in the newly introduced test). This commit simplifies the implementation to avoid this issue, and also because I intend to explore a bit more how far we can get in non left-to-right bindings *without* introducing thunks immediately. Change-Id: I21fd3007ac3946570639772d7d624d70bd209958 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6226 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org> Reviewed-by: grfn <grfn@gws.fyi>
2022-08-31 r/4557 feat(tvix/eval): emit instructions for dynamic var resolutionVincent Ambo1-1/+11
If an unknown variable is encountered and the with stack is not empty, emit instructions for resolving the variable at runtime. Change-Id: I752f4bd0025335744e4747364abd1bd34130374e Reviewed-on: https://cl.tvl.fyi/c/depot/+/6223 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org> Reviewed-by: grfn <grfn@gws.fyi>
2022-08-31 r/4554 feat(tvix/eval): emit instructions to close `with` at scope endVincent Ambo1-0/+7
Change-Id: I340b7a0964a4d4c5be58f46d00d2376ec5682517 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6220 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org> Reviewed-by: grfn <grfn@gws.fyi>
2022-08-31 r/4551 feat(tvix/eval): compile `with` expressionVincent Ambo1-11/+60
Adds an additional structure to the compiler's scope to track the runtime "with stack", i.e. the stack of values through which identifiers should be dynamically resolved within a with-scope. When encountering a `with` expression, the value from which the bindings should be resolved is pushed onto the stack and tracked by the compiler in the "with stack", as well as with a "phantom value" which indicates that the stack contains an additional slot which is not available to users via identifiers. Runtime handling of this is not yet implemented. Change-Id: I5e96fb55b6378e8e2a59c20c8518caa6df83da1c Reviewed-on: https://cl.tvl.fyi/c/depot/+/6217 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-08-31 r/4550 refactor(tvix/eval): rename `Locals` to `Scope`Vincent Ambo1-11/+11
This name is much more sensible actually; its more than just a collection of locals as it tracks additional scope information in the case of Nix. Change-Id: Ia2739bbd39aab222b1c4355e9248828973b0db43 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6216 Reviewed-by: sterni <sternenseemann@systemli.org> Reviewed-by: grfn <grfn@gws.fyi> Tested-by: BuildkiteCI
2022-08-31 r/4549 feat(tvix/eval): implement inherit in let expressionsVincent Ambo1-14/+40
Note that at this point recursive bindings do not yet work in either attrsets or let, so inheriting from the same scope is generally not possible yet. Change-Id: I6ca820d04b8ded5c22fb7ea18e2ec203bcaa8e9c Reviewed-on: https://cl.tvl.fyi/c/depot/+/6215 Reviewed-by: sterni <sternenseemann@systemli.org> Reviewed-by: grfn <grfn@gws.fyi> Tested-by: BuildkiteCI
2022-08-31 r/4548 feat(tvix/eval): implement `inherit` in attribute set literalsVincent Ambo1-12/+33
Straightforward implementation, evaluating the elements of an inherit and preparing the stack so that `OpAttrs` sees all relevant values when constructing the attribute set itself. The emitted instructions for inheriting a lot of values from the same attribute set are inefficient, but it's too early to say whether this actually matters. Change-Id: Icb55a20936d4ef77173f34433811c5fa5d2c9ecc Reviewed-on: https://cl.tvl.fyi/c/depot/+/6214 Reviewed-by: grfn <grfn@gws.fyi> Tested-by: BuildkiteCI
2022-08-30 r/4545 feat(tvix/eval): Implement inherit from outer scope in attrsVincent Ambo1-0/+26
Change-Id: I97fa45059b7f2cbe96eb60bd1821e3e25832df66 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6212 Reviewed-by: grfn <grfn@gws.fyi> Tested-by: BuildkiteCI
2022-08-30 r/4544 fix(tvix/eval): `?` operator should use OpAttrsOrNotFoundVincent Ambo1-1/+1
Using `OpAttrSelect`, the ? operator will fail when encountering a nested value that is not an attribute set. This however breaks valid code, such as: { bs = 42; } ? bs.a.b The fix is simply to use the same operator used in the `or` statement, which leaves a sentinal on the stack if a field is not found or the value is not an attribute set. Change-Id: Ib28fc8a96e6d592b4cdbc3e65ba129ad8faecd66 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6211 Reviewed-by: grfn <grfn@gws.fyi> Tested-by: BuildkiteCI
2022-08-30 r/4541 fix(tvix/eval): emit correct count in OpAttrPathVincent Ambo1-1/+1
Not sure how exactly this snuck in, but it caused some subtle breakages in deeply nested attribute sets. Change-Id: I8049ce912405d3750031f79cc8d86ff1c3c02c2b Reviewed-on: https://cl.tvl.fyi/c/depot/+/6208 Reviewed-by: grfn <grfn@gws.fyi> Tested-by: BuildkiteCI
2022-08-30 r/4537 fix(tvix/eval): address various clippy lintsVincent Ambo1-2/+1
Change-Id: I3ea0f51475e80948adfeb5d1620c1f2665cc39bc Reviewed-on: https://cl.tvl.fyi/c/depot/+/6201 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-08-29 r/4529 feat(tvix/eval): emit warnings on useless inheritVincent Ambo1-1/+8
Change-Id: Ifb9993cf8b85393eb43e1b204c7ab2f889b7113b Reviewed-on: https://cl.tvl.fyi/c/depot/+/6194 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-08-29 r/4528 fix(tvix/eval): skip inherit with no explicit parent in letVincent Ambo1-2/+7
Using `inherit` in a let-binding can not possibly have an effect, as the given identifier is already bound exactly the same way in the current scope. This introduces a subtle bug that is fixed later on, as there actually *is* a (single) condition where these inherits are meaningful. Change-Id: I8b24f0edcfe80db8153bb7e86cf478d36957d6f8 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6192 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
2022-08-28 r/4524 feat(tvix/eval): add local identifier accessVincent Ambo1-1/+20
This makes basic `let ... in ...` statements work correctly. It does not yet account for the call frames pushed into the VM during function application. Change-Id: I67155171daf1a43011b96716dd9d1ab04b27db33 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6190 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
2022-08-28 r/4523 feat(tvix/eval): detect dynamic identifier names in `let`Vincent Ambo1-4/+45
Nix does not allow dynamic identifiers in let expressions (only in attribute sets), but there are several different kinds of things it considers static identifiers. The functions introduced here put the path components of a let expression into normalised (string) form, and surface an error about dynamic keys if one is encountered. Change-Id: Ia3ebd95c6f3ed3cd33b94e156930d2e9c39b6cbf Reviewed-on: https://cl.tvl.fyi/c/depot/+/6189 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
2022-08-28 r/4522 feat(tvix/eval): compile simple `let ... in ...` expressionsVincent Ambo1-0/+81
These expressions now leave the binding values on the stack, and clean up the scope after the body of the expression. While variable access is not yet implemented (as the identifier node remains unhandled), this already gives us the correct stack behaviour. Change-Id: I138c20ace9c64502c94b2c0f99a6077cd912c00d Reviewed-on: https://cl.tvl.fyi/c/depot/+/6188 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
2022-08-28 r/4521 feat(tvix/eval): prepare structures for simulating locals stackVincent Ambo1-0/+24
These are going to be used during compilation of `let`-expressions to determine stack offsets for local variables. Change-Id: Ibb79f3f1ae86650303f88eacf623ae456458de87 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6187 Reviewed-by: grfn <grfn@gws.fyi> Tested-by: BuildkiteCI
2022-08-28 r/4520 fix(tvix/eval): use path_clean instead of fs::canonicalize for pathsVincent Ambo1-10/+6
Canonicalisation performs much more functionality than what C++ Nix implements for paths, and causes some undesirable behaviour (e.g. handling non-existant files becomes difficult, but should be possible in literals). Instead, the path_clean crate provides a pure normalisation method. There is an intention to add this to Rust itself: https://github.com/rust-lang/rfcs/issues/2208 Change-Id: I775d238136db0a52cf6b12a68985833c8fb32882 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6186 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-08-28 r/4519 feat(tvix/eval): resolve relative path literalsVincent Ambo1-3/+23
Resolves relative paths (e.g. `./foo`) either relative to the location of the Nix file, or relative to the working directory if none is supplied. Change-Id: I70ec574657b221b458015117a004b6e4a9c25a30 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6185 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-08-28 r/4518 refactor(tvix/eval): implement error variant for path resolutionVincent Ambo1-7/+13
There are multiple things that can theoretically fail while resolving a path, as some of it includes I/O. A new error variant has been added for this and appropriate errors have been introduced. Change-Id: Ie222245425207dabbf203166eb5ed1eec0114483 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6184 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-08-28 r/4517 feat(tvix/eval): support absolute and home-anchored pathsVincent Ambo1-1/+32
These two paths are the easiest to handle, as they are simply built up from the components supplied in the text node and then normalised. Note that the normalisation of fs::canonicalize includes symlink resolution, which Nix does not actually do. We will need to fix that at some point. Change-Id: I54158f0684f197dd2a2583f7d0982d54c7619993 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6183 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-08-27 r/4513 refactor(tvix/eval): rename Chunk::add_* functions to ::push_*Vincent Ambo1-53/+53
grfn pointed out in cl/6069 that naming them like this makes it clear that things are being added to the end of the state. Change-Id: I6a23215c4fef713869a3c85b0dde1ebbda7637e9 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6179 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
2022-08-26 r/4508 feat(tvix/eval): add warning for deprecated URL literalsVincent Ambo1-5/+9
Change-Id: I8a9cfcb5d99680344ee0e3461a4a52526b846c92 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6175 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi> Reviewed-by: sterni <sternenseemann@systemli.org>
2022-08-26 r/4507 feat(tvix/eval): add mechanism for emitting warnings from compilerVincent Ambo1-2/+16
These can be used predominantly to emit warnings about things that the compiler can infer, such as deprecated language features. Change-Id: I3649c625459d7f3f95cdf42d5c651d23d66569ec Reviewed-on: https://cl.tvl.fyi/c/depot/+/6174 Reviewed-by: grfn <grfn@gws.fyi> Tested-by: BuildkiteCI
2022-08-26 r/4506 fix(tvix/compiler): handle literal URL valuesVincent Ambo1-1/+8
The parser creates this node type from literal URL values. Technically these are deprecated and have been removed from nixpkgs. Change-Id: I4d05034dd9b4d8348e4ed8a2bbb37c1b6ccef8bc Reviewed-on: https://cl.tvl.fyi/c/depot/+/6173 Reviewed-by: grfn <grfn@gws.fyi> Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2022-08-26 r/4502 style(tvix/eval): minor rephrasing in a commentVincent Ambo1-1/+1
From cl/6070 Change-Id: I8ce8c1b40032d85cd2c01b04e225ae4a2842c7b7 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6172 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-08-26 r/4500 feat(tvix/compiler): implement `or` operator for attribute setsVincent Ambo1-2/+76
This operator allows for accessing attribute sets (including nested access) while also providing a default value. This is one of the more complex operations to compile, as it needs to keep track of a fairly large number of jumps that all need to be patched correctly. To make this easier to understand there's a small diagram included in the comments. Change-Id: Ia53bb20d8f779859bfd1692fa3f6d72af74c3a1f Reviewed-on: https://cl.tvl.fyi/c/depot/+/6167 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-08-26 r/4498 refactor(tvix/value): replace static representation with SmolStrVincent Ambo1-2/+2
The only uses of the static variant were for `"name"` and `"value"`, which are both small enough to fit into a SmolStr. The size of NixString accomodates `String` anyways, so we may as well inline them. Additionally smol_str is already in the dependency graph because rnix uses it, and using it for representations of identifiers is sensible. Change-Id: I9969312256d1657d69128e54c47dc7294a18ce58 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6165 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org> Reviewed-by: grfn <grfn@gws.fyi>
2022-08-26 r/4496 feat(tvix/eval): implement nested '?' operatorVincent Ambo1-13/+25
Implements the nested presence check operator for attribuet sets by traversing the chain of lookups through instructions that push/pop sequentially deeper attribute sets onto the stack. Note that this commit introduces a bug in case of nested attributes not being found, which is fixed in a later commit. Change-Id: Ic8b4c8648736f6cb048e3aa52592e4d075bf0544 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6163 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org> Reviewed-by: grfn <grfn@gws.fyi>