From 475ca7a62ec99f0b4d8319410b7ee3134a5fcfec Mon Sep 17 00:00:00 2001 From: Laurenz Date: Fri, 27 Nov 2020 22:35:42 +0100 Subject: =?UTF-8?q?Basic=20environment=20and=20resource=20loader=20?= =?UTF-8?q?=F0=9F=8F=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/eval/mod.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/eval/mod.rs') diff --git a/src/eval/mod.rs b/src/eval/mod.rs index c45e46ae..4cfebd3e 100644 --- a/src/eval/mod.rs +++ b/src/eval/mod.rs @@ -22,6 +22,7 @@ use fontdock::FontStyle; use crate::diag::Diag; use crate::diag::{Deco, Feedback, Pass}; +use crate::env::SharedEnv; use crate::geom::{BoxAlign, Dir, Flow, Gen, Length, Linear, Relative, Sides, Size}; use crate::layout::{ Document, Expansion, LayoutNode, Pad, Pages, Par, Softness, Spacing, Stack, Text, @@ -30,10 +31,10 @@ use crate::syntax::*; /// Evaluate a syntax tree into a document. /// -/// The given `state` the base state that may be updated over the course of +/// The given `state` is the base state that may be updated over the course of /// evaluation. -pub fn eval(tree: &SynTree, state: State) -> Pass { - let mut ctx = EvalContext::new(state); +pub fn eval(tree: &SynTree, env: SharedEnv, state: State) -> Pass { + let mut ctx = EvalContext::new(env, state); ctx.start_page_group(false); tree.eval(&mut ctx); ctx.end_page_group(); @@ -43,6 +44,8 @@ pub fn eval(tree: &SynTree, state: State) -> Pass { /// The context for evaluation. #[derive(Debug)] pub struct EvalContext { + /// The environment from which resources are gathered. + pub env: SharedEnv, /// The active evaluation state. pub state: State, /// The accumulated feedback. @@ -62,8 +65,9 @@ pub struct EvalContext { impl EvalContext { /// Create a new evaluation context with a base state. - pub fn new(state: State) -> Self { + pub fn new(env: SharedEnv, state: State) -> Self { Self { + env, state, groups: vec![], inner: vec![], -- cgit v1.2.3