diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-03-12 14:24:24 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-03-12 14:24:24 +0100 |
| commit | 2890a156d27c02a101137bf01dc2046597110bd1 (patch) | |
| tree | c6bdeb48242c0fbd5b5e13120ca3c8f502d41b75 /src/eval/scope.rs | |
| parent | 5ac7eb3860ebd3247f6486c227e816894cb8fd91 (diff) | |
Remove classes and improve naming
Diffstat (limited to 'src/eval/scope.rs')
| -rw-r--r-- | src/eval/scope.rs | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/eval/scope.rs b/src/eval/scope.rs index e09d05c8..19899cae 100644 --- a/src/eval/scope.rs +++ b/src/eval/scope.rs @@ -4,7 +4,7 @@ use std::hash::{Hash, Hasher}; use std::iter; use std::sync::{Arc, RwLock}; -use super::{Args, Class, Construct, Func, Set, Value}; +use super::{Args, Func, Node, Value}; use crate::diag::TypResult; use crate::util::EcoString; use crate::Context; @@ -83,21 +83,18 @@ impl Scope { self.values.insert(var.into(), slot); } - /// Define a constant native function. - pub fn def_func( + /// Define a function through a native rust function. + pub fn def_fn( &mut self, name: &'static str, func: fn(&mut Context, &mut Args) -> TypResult<Value>, ) { - self.def_const(name, Func::native(name, func)); + self.def_const(name, Func::from_fn(name, func)); } - /// Define a constant class. - pub fn def_class<T>(&mut self, name: &'static str) - where - T: Construct + Set + 'static, - { - self.def_const(name, Class::new::<T>(name)); + /// Define a function through a native rust node. + pub fn def_node<T: Node>(&mut self, name: &'static str) { + self.def_const(name, Func::from_node::<T>(name)); } /// Look up the value of a variable. |
