summaryrefslogtreecommitdiff
path: root/src/eval/mod.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-01-30 10:24:51 +0100
committerLaurenz <laurmaedje@gmail.com>2021-01-30 10:24:51 +0100
commitac24075469f171fe83a976b9a97b9b1ea078a7e3 (patch)
treee89155de4670efa636b71f4a9a5e5f422c76214d /src/eval/mod.rs
parent2036663ed25b5885a87eb3a80caec3fa2e258d77 (diff)
Moves captures visitor into separate file 🚚
Diffstat (limited to 'src/eval/mod.rs')
-rw-r--r--src/eval/mod.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/eval/mod.rs b/src/eval/mod.rs
index 9e45a67b..af3303af 100644
--- a/src/eval/mod.rs
+++ b/src/eval/mod.rs
@@ -3,13 +3,14 @@
#[macro_use]
mod value;
mod call;
+mod capture;
mod context;
mod ops;
mod scope;
mod state;
-mod template;
pub use call::*;
+pub use capture::*;
pub use context::*;
pub use scope::*;
pub use state::*;
@@ -208,6 +209,17 @@ impl Eval for Spanned<&ExprDict> {
}
}
+impl Eval for Spanned<&ExprTemplate> {
+ type Output = Value;
+
+ fn eval(self, ctx: &mut EvalContext) -> Self::Output {
+ let mut template = self.v.clone();
+ let mut visitor = CapturesVisitor::new(&ctx.scopes);
+ visitor.visit_template(&mut template);
+ Value::Template(template)
+ }
+}
+
impl Eval for Spanned<&ExprBlock> {
type Output = Value;