diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-06-30 11:40:27 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-06-30 11:40:27 +0200 |
| commit | 470f8001a1dba0022ec9d3e46c67c3bbc31359be (patch) | |
| tree | d68f60533201658148ea508c90ba704f806561d5 /src/eval | |
| parent | 45812b700114a51f0ee21e31f4454cde3729eaf5 (diff) | |
No more collisions between syntax::Tree and layout::Tree
Diffstat (limited to 'src/eval')
| -rw-r--r-- | src/eval/mod.rs | 10 | ||||
| -rw-r--r-- | src/eval/value.rs | 14 |
2 files changed, 12 insertions, 12 deletions
diff --git a/src/eval/mod.rs b/src/eval/mod.rs index a9fff56b..8579025f 100644 --- a/src/eval/mod.rs +++ b/src/eval/mod.rs @@ -30,11 +30,11 @@ pub fn eval( loader: &mut dyn Loader, cache: &mut Cache, path: Option<&Path>, - tree: Rc<Tree>, + ast: Rc<SyntaxTree>, scope: &Scope, ) -> Pass<Module> { let mut ctx = EvalContext::new(loader, cache, path, scope); - let template = tree.eval(&mut ctx); + let template = ast.eval(&mut ctx); let module = Module { scope: ctx.scopes.top, template }; Pass::new(module, ctx.diags) } @@ -148,8 +148,8 @@ impl<'a> EvalContext<'a> { self.route.push(hash); // Evaluate the module. - let tree = Rc::new(parsed.output); - let template = tree.eval(self); + let ast = Rc::new(parsed.output); + let template = ast.eval(self); // Restore the old context. let new_scopes = mem::replace(&mut self.scopes, old_scopes); @@ -212,7 +212,7 @@ pub trait Eval { fn eval(&self, ctx: &mut EvalContext) -> Self::Output; } -impl Eval for Rc<Tree> { +impl Eval for Rc<SyntaxTree> { type Output = TemplateValue; fn eval(&self, ctx: &mut EvalContext) -> Self::Output { diff --git a/src/eval/value.rs b/src/eval/value.rs index 0da2a5be..472df0ea 100644 --- a/src/eval/value.rs +++ b/src/eval/value.rs @@ -10,7 +10,7 @@ use super::EvalContext; use crate::color::{Color, RgbaColor}; use crate::exec::ExecContext; use crate::geom::{Angle, Fractional, Length, Linear, Relative}; -use crate::syntax::{Expr, Span, Spanned, Tree}; +use crate::syntax::{Expr, Span, Spanned, SyntaxTree}; /// A computational value. #[derive(Debug, Clone, PartialEq)] @@ -165,8 +165,8 @@ pub enum TemplateNode { /// expression. Tree { /// The syntax tree of the corresponding template expression. - tree: Rc<Tree>, - /// The evaluated expressions for the `tree`. + tree: Rc<SyntaxTree>, + /// The evaluated expressions in the syntax tree. map: ExprMap, }, /// A template that was converted from a string. @@ -184,10 +184,10 @@ impl PartialEq for TemplateNode { /// A map from expressions to the values they evaluated to. /// -/// The raw pointers point into the expressions contained in some [`Tree`]. -/// Since the lifetime is erased, the tree could go out of scope while the hash -/// map still lives. Although this could lead to lookup panics, it is not unsafe -/// since the pointers are never dereferenced. +/// The raw pointers point into the expressions contained in some +/// [`SyntaxTree`]. Since the lifetime is erased, the tree could go out of scope +/// while the hash map still lives. Although this could lead to lookup panics, +/// it is not unsafe since the pointers are never dereferenced. pub type ExprMap = HashMap<*const Expr, Value>; /// A reference-counted dynamic template node that can implement custom |
