feat: create scoped language functions from native calls
This commit is contained in:
@@ -58,6 +58,20 @@ impl<'a> NativeContext<'a> {
|
||||
self.allocate(crate::Record)
|
||||
}
|
||||
|
||||
/// Build a language function under this native scope using validated code.
|
||||
pub fn new_function(
|
||||
&mut self,
|
||||
name: impl Into<String>,
|
||||
code: ObjectRef,
|
||||
globals: ObjectRef,
|
||||
) -> Result<ObjectRef, VmError> {
|
||||
let function = self
|
||||
.store
|
||||
.new_function(name, code, globals, vec![], vec![])?;
|
||||
self.roots.push(function);
|
||||
Ok(function)
|
||||
}
|
||||
|
||||
pub fn new_dict(&mut self) -> Result<ObjectRef, VmError> {
|
||||
let object = self.store.new_dict()?;
|
||||
self.roots.push(object);
|
||||
|
||||
Reference in New Issue
Block a user