diff options
author | Vincent Ambo <mail@tazj.in> | 2022-08-24T08·00+0300 |
---|---|---|
committer | tazjin <tazjin@tvl.su> | 2022-09-02T12·59+0000 |
commit | e0f1356ae31783664f597b33f8b69b060a9e3033 (patch) | |
tree | 54dc3a82429b2844b2c443ab9eb0911fc78f1615 /tvix/eval/src/vm.rs | |
parent | 64746388e2c81c3dac7f520c40a4c4aacb3dc376 (diff) |
feat(tvix/eval): add initial representation of builtins r/4585
Builtins are represented as a Rust function pointer that accepts a vector of arguments, which represents variable arity builtins. Change-Id: Ibab7e662a646caf1172695d876d2f55e187c03dd Reviewed-on: https://cl.tvl.fyi/c/depot/+/6251 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
Diffstat (limited to 'tvix/eval/src/vm.rs')
-rw-r--r-- | tvix/eval/src/vm.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/tvix/eval/src/vm.rs b/tvix/eval/src/vm.rs index ff81349a1531..b6d5a9838c3a 100644 --- a/tvix/eval/src/vm.rs +++ b/tvix/eval/src/vm.rs @@ -358,6 +358,11 @@ impl VM { let callable = self.pop(); match callable { Value::Lambda(lambda) => self.call(lambda, 1), + Value::Builtin(builtin) => { + let arg = self.pop(); + let result = builtin.apply(arg)?; + self.push(result); + } _ => return Err(ErrorKind::NotCallable.into()), }; } |