Commit graph

60 commits

Author SHA1 Message Date
Vincent Ambo
3577841bde feat(tvix/compiler): compile non-interpolated string literals
This sets up the scaffolding for compiling interpolation, but those
instructions do not yet exist.

Change-Id: Ife41bbbf432d9661abe566c92437409dd0da44e7
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6097
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
2022-08-13 18:28:36 +00:00
Vincent Ambo
910336c68c feat(tvix/compiler): compile list literals
Change-Id: I2c6fedc3dbb7d449d700f3972c3fbd4a7d147f6c
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6095
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
Autosubmit: tazjin <tazjin@tvl.su>
2022-08-13 15:39:26 +00:00
Vincent Ambo
57a723aaa9 feat(tvix/eval): implement trivial attribute set literals
Implements attribute set literals without nesting. Technically this
already supports dynamic key fragments (evaluating to strings), though
the only way to create these (interpolation) is not yet implemented.

However, creating simple attribute sets like `{ }`, or `{ a = 15; }`
or `{ a = 10 * 2; }` works.

Recursive attribute sets are not yet implemented as we do not have any
kind of scope access yet anyways.

This is implemented using a new instruction that creates an attribute
set with a given number of elements by popping key/value pairs off the
stack.

Change-Id: I0f9aac7a131a112d3f66b131297686b38aaeddf2
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6091
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
2022-08-13 15:31:50 +00:00
Vincent Ambo
9c5a249b30 feat(tvix/compiler): incompletely handle true/false/null literals
These are a bit tricky to implement because Nix technically treats
them as identifiers, and only if the identifier is not explicitly
overridden within the scope does it yield the expected literal values.

Note that weirdness even occurs with scopedImport.

Change-Id: Ie55723405ccfcc25da37c5a08fa3332f37cf9ae5
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6080
Tested-by: BuildkiteCI
Autosubmit: tazjin <tazjin@tvl.su>
Reviewed-by: grfn <grfn@gws.fyi>
2022-08-12 14:09:27 +00:00
Vincent Ambo
ded0fb9e21 feat(tvix/eval): implement equality operator
Change-Id: I9dd54aed72cd7e67593dc76f5a046ebbda40c26f
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6078
Tested-by: BuildkiteCI
Autosubmit: tazjin <tazjin@tvl.su>
Reviewed-by: grfn <grfn@gws.fyi>
2022-08-12 14:09:27 +00:00
Vincent Ambo
28f57abac1 refactor(tvix/compiler): use rnix's typed AST for literal values
Change-Id: Ic56ab64ad82343c7cdf8168ef41ee0a97f7e1dd9
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6077
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
2022-08-12 13:24:10 +00:00
Vincent Ambo
18fe188c3e feat(tvix/compiler): implement parens precedence
Change-Id: I8944354b3690d7504e4fe4254f14be5b849b9bcf
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6076
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
2022-08-12 13:24:10 +00:00
Vincent Ambo
72be759e1e feat(tvix/eval): implement unary negation operator
Change-Id: I5d012cc073e55d79d7b34b88283aab3164864293
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6075
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
2022-08-12 13:24:10 +00:00
Vincent Ambo
d35ecc0caf feat(tvix/eval): implement simple arithmetic binary operations
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 13:24:10 +00:00
Vincent Ambo
34df2c8473 feat(tvix/eval): add initial barebones compiler
This compiler can only take care of very trivial literals so far.

Change-Id: I9dfac75a801b7235f868061a979ae24159fe1425
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6070
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
2022-08-12 13:05:16 +00:00