summaryrefslogtreecommitdiff
path: root/src/exec
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-06-30 11:40:27 +0200
committerLaurenz <laurmaedje@gmail.com>2021-06-30 11:40:27 +0200
commit470f8001a1dba0022ec9d3e46c67c3bbc31359be (patch)
treed68f60533201658148ea508c90ba704f806561d5 /src/exec
parent45812b700114a51f0ee21e31f4454cde3729eaf5 (diff)
No more collisions between syntax::Tree and layout::Tree
Diffstat (limited to 'src/exec')
-rw-r--r--src/exec/context.rs14
-rw-r--r--src/exec/mod.rs20
2 files changed, 17 insertions, 17 deletions
diff --git a/src/exec/context.rs b/src/exec/context.rs
index 3994fdb9..0f6d47f5 100644
--- a/src/exec/context.rs
+++ b/src/exec/context.rs
@@ -6,9 +6,9 @@ use crate::diag::{Diag, DiagSet, Pass};
use crate::eval::{ExprMap, TemplateValue};
use crate::geom::{Align, Dir, Gen, GenAxis, Length, Linear, Sides, Size};
use crate::layout::{
- AnyNode, PadNode, PageRun, ParChild, ParNode, StackChild, StackNode, Tree,
+ AnyNode, LayoutTree, PadNode, PageRun, ParChild, ParNode, StackChild, StackNode,
};
-use crate::syntax::{self, Span};
+use crate::syntax::{Span, SyntaxTree};
/// The context for execution.
pub struct ExecContext {
@@ -17,7 +17,7 @@ pub struct ExecContext {
/// Execution diagnostics.
pub diags: DiagSet,
/// The tree of finished page runs.
- tree: Tree,
+ tree: LayoutTree,
/// When we are building the top-level stack, this contains metrics of the
/// page. While building a group stack through `exec_group`, this is `None`.
page: Option<PageBuilder>,
@@ -30,7 +30,7 @@ impl ExecContext {
pub fn new(state: State) -> Self {
Self {
diags: DiagSet::new(),
- tree: Tree { runs: vec![] },
+ tree: LayoutTree { runs: vec![] },
page: Some(PageBuilder::new(&state, true)),
stack: StackBuilder::new(&state),
state,
@@ -56,8 +56,8 @@ impl ExecContext {
self.exec_stack(|ctx| template.exec(ctx))
}
- /// Execute a tree with a map and return the result as a stack node.
- pub fn exec_tree_stack(&mut self, tree: &syntax::Tree, map: &ExprMap) -> StackNode {
+ /// Execute a syntax tree with a map and return the result as a stack node.
+ pub fn exec_tree_stack(&mut self, tree: &SyntaxTree, map: &ExprMap) -> StackNode {
self.exec_stack(|ctx| tree.exec_with_map(ctx, map))
}
@@ -137,7 +137,7 @@ impl ExecContext {
}
/// Finish execution and return the created layout tree.
- pub fn finish(mut self) -> Pass<Tree> {
+ pub fn finish(mut self) -> Pass<LayoutTree> {
assert!(self.page.is_some());
self.pagebreak(true, false, Span::default());
Pass::new(self.tree, self.diags)
diff --git a/src/exec/mod.rs b/src/exec/mod.rs
index 882f1d0b..8e369d12 100644
--- a/src/exec/mod.rs
+++ b/src/exec/mod.rs
@@ -11,12 +11,12 @@ use std::rc::Rc;
use crate::diag::Pass;
use crate::eval::{ExprMap, TemplateFunc, TemplateNode, TemplateValue, Value};
use crate::geom::{Dir, Gen};
-use crate::layout::{self, StackChild, StackNode};
+use crate::layout::{LayoutTree, StackChild, StackNode};
use crate::pretty::pretty;
-use crate::syntax;
+use crate::syntax::*;
/// Execute a template to produce a layout tree.
-pub fn exec(template: &TemplateValue, state: State) -> Pass<layout::Tree> {
+pub fn exec(template: &TemplateValue, state: State) -> Pass<LayoutTree> {
let mut ctx = ExecContext::new(state);
template.exec(&mut ctx);
ctx.finish()
@@ -40,7 +40,7 @@ pub trait ExecWithMap {
fn exec_with_map(&self, ctx: &mut ExecContext, map: &ExprMap);
}
-impl ExecWithMap for syntax::Tree {
+impl ExecWithMap for SyntaxTree {
fn exec_with_map(&self, ctx: &mut ExecContext, map: &ExprMap) {
for node in self {
node.exec_with_map(ctx, map);
@@ -48,7 +48,7 @@ impl ExecWithMap for syntax::Tree {
}
}
-impl ExecWithMap for syntax::Node {
+impl ExecWithMap for Node {
fn exec_with_map(&self, ctx: &mut ExecContext, map: &ExprMap) {
match self {
Self::Text(text) => ctx.push_text(text),
@@ -66,7 +66,7 @@ impl ExecWithMap for syntax::Node {
}
}
-impl Exec for syntax::RawNode {
+impl Exec for RawNode {
fn exec(&self, ctx: &mut ExecContext) {
if self.block {
ctx.parbreak();
@@ -83,7 +83,7 @@ impl Exec for syntax::RawNode {
}
}
-impl ExecWithMap for syntax::HeadingNode {
+impl ExecWithMap for HeadingNode {
fn exec_with_map(&self, ctx: &mut ExecContext, map: &ExprMap) {
ctx.parbreak();
@@ -100,20 +100,20 @@ impl ExecWithMap for syntax::HeadingNode {
}
}
-impl ExecWithMap for syntax::ListItem {
+impl ExecWithMap for ListItem {
fn exec_with_map(&self, ctx: &mut ExecContext, map: &ExprMap) {
exec_item(ctx, "•".to_string(), &self.body, map);
}
}
-impl ExecWithMap for syntax::EnumItem {
+impl ExecWithMap for EnumItem {
fn exec_with_map(&self, ctx: &mut ExecContext, map: &ExprMap) {
let label = self.number.unwrap_or(1).to_string() + ".";
exec_item(ctx, label, &self.body, map);
}
}
-fn exec_item(ctx: &mut ExecContext, label: String, body: &syntax::Tree, map: &ExprMap) {
+fn exec_item(ctx: &mut ExecContext, label: String, body: &SyntaxTree, map: &ExprMap) {
let label = ctx.exec_stack(|ctx| ctx.push_text(label));
let body = ctx.exec_tree_stack(body, map);
let stack = StackNode {