summaryrefslogtreecommitdiff
path: root/src/eval
diff options
context:
space:
mode:
Diffstat (limited to 'src/eval')
-rw-r--r--src/eval/mod.rs6
-rw-r--r--src/eval/scope.rs12
-rw-r--r--src/eval/state.rs2
-rw-r--r--src/eval/value.rs10
4 files changed, 12 insertions, 18 deletions
diff --git a/src/eval/mod.rs b/src/eval/mod.rs
index dc35ce71..3796669b 100644
--- a/src/eval/mod.rs
+++ b/src/eval/mod.rs
@@ -90,13 +90,13 @@ impl Eval for ExprCall {
let span = self.name.span;
let args = self.args.eval(ctx).await;
- if let Some(func) = ctx.state.scope.func(name) {
- ctx.f.decorations.push(Decoration::Resolved.span_with(span));
+ if let Some(func) = ctx.state.scope.get(name) {
+ ctx.f.decos.push(Deco::Resolved.span_with(span));
(func.clone())(args, ctx).await
} else {
if !name.is_empty() {
error!(@ctx.f, span, "unknown function");
- ctx.f.decorations.push(Decoration::Unresolved.span_with(span));
+ ctx.f.decos.push(Deco::Unresolved.span_with(span));
}
Value::Dict(args)
}
diff --git a/src/eval/scope.rs b/src/eval/scope.rs
index 7d69e1fc..fc530bbb 100644
--- a/src/eval/scope.rs
+++ b/src/eval/scope.rs
@@ -18,15 +18,15 @@ impl Scope {
Self { functions: HashMap::new() }
}
- /// Associate the given name with the function.
- pub fn insert(&mut self, name: impl Into<String>, function: ValueFunc) {
- self.functions.insert(name.into(), function);
- }
-
/// Return the function with the given name if there is one.
- pub fn func(&self, name: &str) -> Option<&ValueFunc> {
+ pub fn get(&self, name: &str) -> Option<&ValueFunc> {
self.functions.get(name)
}
+
+ /// Associate the given name with the function.
+ pub fn set(&mut self, name: impl Into<String>, function: ValueFunc) {
+ self.functions.insert(name.into(), function);
+ }
}
impl Debug for Scope {
diff --git a/src/eval/state.rs b/src/eval/state.rs
index d6e0b195..e4e9f793 100644
--- a/src/eval/state.rs
+++ b/src/eval/state.rs
@@ -75,7 +75,7 @@ impl TextState {
}
/// The absolute paragraph spacing.
- pub fn paragraph_spacing(&self) -> f64 {
+ pub fn par_spacing(&self) -> f64 {
self.par_spacing.eval(self.font_size())
}
}
diff --git a/src/eval/value.rs b/src/eval/value.rs
index f1ffc6de..16c3dca8 100644
--- a/src/eval/value.rs
+++ b/src/eval/value.rs
@@ -530,10 +530,7 @@ mod tests {
dict.expect::<String>("", Span::ZERO, &mut f),
Some("hi".to_string())
);
- assert_eq!(f.diagnostics, [error!(
- Span::ZERO,
- "expected string, found bool"
- )]);
+ assert_eq!(f.diags, [error!(Span::ZERO, "expected string, found bool")]);
assert_eq!(dict.len(), 1);
}
@@ -545,10 +542,7 @@ mod tests {
dict.insert("hi", entry(Value::Bool(true)));
assert_eq!(dict.take::<bool>(), Some(false));
assert_eq!(dict.take_key::<f64>("hi", &mut f), None);
- assert_eq!(f.diagnostics, [error!(
- Span::ZERO,
- "expected float, found bool"
- )]);
+ assert_eq!(f.diags, [error!(Span::ZERO, "expected float, found bool")]);
assert!(dict.is_empty());
}