summaryrefslogtreecommitdiff
path: root/src/model/scope.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-12-14 10:09:44 +0100
committerLaurenz <laurmaedje@gmail.com>2022-12-14 10:09:44 +0100
commit9ba4d2c134479aad876a0e2ac4cd1622a353109e (patch)
treea94e0e6ae53a1ba440e869fca26cc2ea0b179057 /src/model/scope.rs
parent4c73456fc1f5df8ebb3a89d9db657c3c54624d66 (diff)
New macro setup
Diffstat (limited to 'src/model/scope.rs')
-rw-r--r--src/model/scope.rs21
1 files changed, 6 insertions, 15 deletions
diff --git a/src/model/scope.rs b/src/model/scope.rs
index d21d0587..c54cf1b3 100644
--- a/src/model/scope.rs
+++ b/src/model/scope.rs
@@ -2,8 +2,8 @@ use std::collections::BTreeMap;
use std::fmt::{self, Debug, Formatter};
use std::hash::Hash;
-use super::{Args, Func, Node, Value, Vm};
-use crate::diag::{SourceResult, StrResult};
+use super::{Func, FuncType, Value};
+use crate::diag::StrResult;
use crate::util::EcoString;
/// A stack of scopes.
@@ -75,17 +75,8 @@ impl Scope {
}
/// Define a function through a native rust function.
- pub fn def_fn(
- &mut self,
- name: &'static str,
- func: fn(&Vm, &mut Args) -> SourceResult<Value>,
- ) {
- self.define(name, Func::from_fn(name, func));
- }
-
- /// Define a function through a native rust node.
- pub fn def_node<T: Node>(&mut self, name: &'static str) {
- self.define(name, Func::from_node::<T>(name));
+ pub fn def_func<T: FuncType>(&mut self, name: &'static str) {
+ self.define(name, Func::from_type::<T>(name));
}
/// Define a captured, immutable binding.
@@ -108,8 +99,8 @@ impl Scope {
}
/// Iterate over all definitions.
- pub fn iter(&self) -> impl Iterator<Item = (&str, &Value)> {
- self.0.iter().map(|(k, v)| (k.as_str(), v.read()))
+ pub fn iter(&self) -> impl Iterator<Item = (&EcoString, &Value)> {
+ self.0.iter().map(|(k, v)| (k, v.read()))
}
}