feat(tvix/eval): add initial representation of builtins
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>
This commit is contained in:
parent
64746388e2
commit
e0f1356ae3
3 changed files with 76 additions and 1 deletions
|
|
@ -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()),
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue