about summary refs log tree commit diff
path: root/tvix/eval/src/eval.rs (follow)
AgeCommit message (Collapse)AuthorFilesLines
2022-09-03 r/4608 fix(tvix/eval): address all current clippy lintsVincent Ambo1-2/+0
Change-Id: I758fc4f3b9078de7ca6228a75a4351c3e085c4cf Reviewed-on: https://cl.tvl.fyi/c/depot/+/6272 Reviewed-by: grfn <grfn@gws.fyi> Tested-by: BuildkiteCI
2022-09-02 r/4599 chore(tvix/eval): print slightly more information about warningsVincent Ambo1-1/+2
This is just for dev comfort, it's not going to be useful for the final version. Change-Id: I05fdd590097a61085ed641810655d9ddaf8f3511 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6265 Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2022-09-02 r/4588 feat(tvix/eval): introduce mechanism for defining builtinsVincent Ambo1-1/+2
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-01 r/4576 refactor(tvix/eval): return a lambda from the compilerVincent Ambo1-2/+2
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/4572 refactor(tvix/eval): collect vector of errors in compilerVincent Ambo1-0/+8
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-2/+2
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/4567 refactor(tvix/eval): Upgrade to latest rnix-parserVincent Ambo1-7/+13
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-08-31 r/4558 chore(tvix/eval): return parse errors out of eval::interpretVincent Ambo1-2/+8
Change-Id: I14f25b9c85260c68be38abf07ed80121ead60c7b Reviewed-on: https://cl.tvl.fyi/c/depot/+/6224 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org> Reviewed-by: grfn <grfn@gws.fyi>
2022-08-30 r/4537 fix(tvix/eval): address various clippy lintsVincent Ambo1-1/+1
Change-Id: I3ea0f51475e80948adfeb5d1620c1f2665cc39bc Reviewed-on: https://cl.tvl.fyi/c/depot/+/6201 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-08-30 r/4534 feat(tvix/eval): implement chunk disassembler outputVincent Ambo1-1/+3
This makes for a much nicer view of an execution if `--feature disassembler` is set, for example: tvix-repl> let value = [ 1 2 { a = 1; } ]; in value ++ [ 1 ] === compiled bytecode (11 operations) === 02 OpConstant(1) 02 OpConstant(2) 02 OpConstant("a") 02 OpConstant(1) 02 OpAttrs(1) 02 OpList(3) 02 OpGetLocal(0) 02 OpConstant(1) 02 OpList(1) 02 OpConcat 02 OpCloseScope(1) === runtime trace === 0001 OpConstant(ConstantIdx(0)) [ 1 ] 0002 OpConstant(ConstantIdx(1)) [ 1 2 ] 0003 OpConstant(ConstantIdx(2)) [ 1 2 "a" ] 0004 OpConstant(ConstantIdx(3)) [ 1 2 "a" 1 ] 0005 OpAttrs(1) [ 1 2 { a = 1; } ] 0006 OpList(3) [ [ 1 2 { a = 1; } ] ] 0007 OpGetLocal(0) [ [ 1 2 { a = 1; } ] [ 1 2 { a = 1; } ] ] 0008 OpConstant(ConstantIdx(4)) [ [ 1 2 { a = 1; } ] [ 1 2 { a = 1; } ] 1 ] 0009 OpList(1) [ [ 1 2 { a = 1; } ] [ 1 2 { a = 1; } ] [ 1 ] ] 0010 OpConcat [ [ 1 2 { a = 1; } ] [ 1 2 { a = 1; } 1 ] ] 0011 OpCloseScope(1) [ [ 1 2 { a = 1; } 1 ] ] => [ 1 2 { a = 1; } 1 ] :: list Change-Id: If79c7fd1f0f18255ddb3763c1ba585fda8041b1b Reviewed-on: https://cl.tvl.fyi/c/depot/+/6195 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-08-28 r/4519 feat(tvix/eval): resolve relative path literalsVincent Ambo1-2/+4
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-26 r/4507 feat(tvix/eval): add mechanism for emitting warnings from compilerVincent Ambo1-3/+11
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-24 r/4463 chore(tvix/eval): only print AST if requestedVincent Ambo1-1/+3
Change-Id: If32c7fd03458a27aecb8c473f2c48b12f8cb5175 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6128 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi> Autosubmit: tazjin <tazjin@tvl.su>
2022-08-24 r/4461 feat(tvix/tests): check in Nix' language test suiteVincent Ambo1-5/+4
This adds scaffolding code for running the Nix language test suite. The majority of eval-okay-* tests should eventually be runnable as-is by Tvix, however the eval-fail-* tests might not as we intend to have more useful error messages than upstream Nix. Change-Id: I4f3227f0889c55e4274b804a3072850fb78dd1bd Reviewed-on: https://cl.tvl.fyi/c/depot/+/6126 Tested-by: BuildkiteCI Autosubmit: tazjin <tazjin@tvl.su> Reviewed-by: grfn <grfn@gws.fyi>
2022-08-13 r/4432 style(tvix/eval): display `Display` representation of runtime valuesVincent Ambo1-1/+1
Change-Id: Ifbe05c2da9493c9e132a2d2e94a451d6091542a5 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6096 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
2022-08-13 r/4424 fix(tvix/eval): print code even if runtime failsVincent Ambo1-6/+2
Change-Id: I357c9adf939cb6001afa73ad02282d94ee22d0ba Reviewed-on: https://cl.tvl.fyi/c/depot/+/6088 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
2022-08-12 r/4417 refactor(tvix/eval): move NumberPair struct definition to vm moduleVincent Ambo1-1/+1
This isn't relevant to the value type itself. Change-Id: I678bc92a8a530b1081ed498bf3ff7925217bcc01 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6081 Tested-by: BuildkiteCI Autosubmit: tazjin <tazjin@tvl.su> Reviewed-by: grfn <grfn@gws.fyi>
2022-08-12 r/4410 feat(tvix/eval): implement simple arithmetic binary operationsVincent Ambo1-1/+1
Implements simple arithmetic operations (+, -, *, /). There is some scaffolding included to pop and coerce pairs of numbers, as the Nix language will let arithmetic operators apply to arbitrary pairs of number types (always resulting in floats if the types are mixed). Change-Id: I5f62c363bdea8baa6ef812cc64c5406759d257cf Reviewed-on: https://cl.tvl.fyi/c/depot/+/6074 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
2022-08-12 r/4408 chore(tvix/eval): wire things up for development flowVincent Ambo1-2/+21
This creates a REPL which outputs compiled bytecode, constants, and VM results for code snippets. Change-Id: If63f79a961456afd6a4cdf59b994107ff7ab8b47 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6072 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi> Autosubmit: tazjin <tazjin@tvl.su>
2022-08-12 r/4401 chore(tvix/eval): bootstrap some evaluator boilerplateVincent Ambo1-0/+5
Change-Id: I7770a20948d18a8506c2418dea21202aa21a6ddc Reviewed-on: https://cl.tvl.fyi/c/depot/+/6064 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>