summaryrefslogtreecommitdiff
path: root/src/eval/mod.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2020-11-27 22:35:42 +0100
committerLaurenz <laurmaedje@gmail.com>2020-11-27 22:35:42 +0100
commit475ca7a62ec99f0b4d8319410b7ee3134a5fcfec (patch)
tree75037761e1da5681b2971e79e605f95903ba6032 /src/eval/mod.rs
parentbc997b7c3380d5f516f0aa58efc3dd513d75fafb (diff)
Basic environment and resource loader 🏞
Diffstat (limited to 'src/eval/mod.rs')
-rw-r--r--src/eval/mod.rs12
1 files changed, 8 insertions, 4 deletions
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<Document> {
- let mut ctx = EvalContext::new(state);
+pub fn eval(tree: &SynTree, env: SharedEnv, state: State) -> Pass<Document> {
+ 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<Document> {
/// 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![],