about summary refs log tree commit diff
path: root/tvix/eval/src/builtins/impure.rs
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-10-03T08·26+0300
committertazjin <tazjin@tvl.su>2022-10-04T08·03+0000
commitf0179c92d3248667b7f037de91c6b9eb737a40d2 (patch)
tree0bb7d7da18baf68a100b9bfc8bbef281d1105c00 /tvix/eval/src/builtins/impure.rs
parentb9bfcf2f336b2276d391e75fb04e81bcbad3f692 (diff)
refactor(tvix/eval): allow impure Value builtins r/5026
Allows impure builtins that have a different shape than a Rust
function pointer; specifically this is required for
builtins.currentTime which does not work in WASM.

Change-Id: I1362d8eeafe770ce4d1c5ebe4d119aeb0abb5c9b
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6849
Reviewed-by: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
Reviewed-by: wpcarro <wpcarro@gmail.com>
Diffstat (limited to 'tvix/eval/src/builtins/impure.rs')
-rw-r--r--tvix/eval/src/builtins/impure.rs25
1 files changed, 22 insertions, 3 deletions
diff --git a/tvix/eval/src/builtins/impure.rs b/tvix/eval/src/builtins/impure.rs
index 3438aa06f424..41e3805b2d0e 100644
--- a/tvix/eval/src/builtins/impure.rs
+++ b/tvix/eval/src/builtins/impure.rs
@@ -1,7 +1,26 @@
-use crate::value::Builtin;
+use std::{
+    collections::BTreeMap,
+    time::{SystemTime, UNIX_EPOCH},
+};
+
+use smol_str::SmolStr;
+
+use crate::{
+    value::{Builtin, NixString},
+    Value,
+};
+
+fn impure_builtins() -> Vec<Builtin> {
+    vec![]
+}
 
 /// Return all impure builtins, that is all builtins which may perform I/O outside of the VM and so
 /// cannot be used in all contexts (e.g. WASM).
-pub(super) fn builtins() -> Vec<Builtin> {
-    vec![]
+pub(super) fn builtins() -> BTreeMap<NixString, Value> {
+    let mut map: BTreeMap<NixString, Value> = impure_builtins()
+        .into_iter()
+        .map(|b| (b.name().into(), Value::Builtin(b)))
+        .collect();
+
+    map
 }