summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/src/main.rs2
-rw-r--r--docs/src/lib.rs6
-rw-r--r--library/src/compute/calc.rs2
-rw-r--r--library/src/compute/construct.rs2
-rw-r--r--library/src/compute/foundations.rs2
-rw-r--r--library/src/lib.rs3
-rw-r--r--library/src/math/accent.rs2
-rw-r--r--library/src/math/mod.rs6
-rw-r--r--library/src/math/op.rs2
-rw-r--r--library/src/prelude.rs12
-rw-r--r--library/src/symbols/emoji.rs2
-rw-r--r--library/src/symbols/sym.rs2
-rw-r--r--macros/src/castable.rs34
-rw-r--r--macros/src/func.rs20
-rw-r--r--macros/src/node.rs16
-rw-r--r--macros/src/symbols.rs4
-rw-r--r--src/doc.rs5
-rw-r--r--src/eval/args.rs (renamed from src/model/args.rs)0
-rw-r--r--src/eval/array.rs (renamed from src/model/array.rs)4
-rw-r--r--src/eval/cast.rs (renamed from src/model/cast.rs)5
-rw-r--r--src/eval/dict.rs (renamed from src/model/dict.rs)2
-rw-r--r--src/eval/func.rs (renamed from src/model/func.rs)6
-rw-r--r--src/eval/library.rs (renamed from src/model/library.rs)5
-rw-r--r--src/eval/methods.rs (renamed from src/model/methods.rs)0
-rw-r--r--src/eval/mod.rs (renamed from src/model/eval.rs)43
-rw-r--r--src/eval/module.rs (renamed from src/model/module.rs)0
-rw-r--r--src/eval/ops.rs (renamed from src/model/ops.rs)0
-rw-r--r--src/eval/scope.rs (renamed from src/model/scope.rs)0
-rw-r--r--src/eval/str.rs (renamed from src/model/str.rs)2
-rw-r--r--src/eval/symbol.rs (renamed from src/model/symbol.rs)0
-rw-r--r--src/eval/value.rs (renamed from src/model/value.rs)2
-rw-r--r--src/ide/analyze.rs2
-rw-r--r--src/ide/complete.rs2
-rw-r--r--src/ide/tooltip.rs2
-rw-r--r--src/lib.rs12
-rw-r--r--src/model/content.rs8
-rw-r--r--src/model/mod.rs43
-rw-r--r--src/model/styles.rs3
-rw-r--r--src/model/typeset.rs5
-rw-r--r--tests/src/benches.rs21
-rw-r--r--tests/src/tests.rs12
41 files changed, 148 insertions, 153 deletions
diff --git a/cli/src/main.rs b/cli/src/main.rs
index 39769968..65b21e22 100644
--- a/cli/src/main.rs
+++ b/cli/src/main.rs
@@ -18,8 +18,8 @@ use same_file::{is_same_file, Handle};
use siphasher::sip128::{Hasher128, SipHasher};
use termcolor::{ColorChoice, StandardStream, WriteColor};
use typst::diag::{FileError, FileResult, SourceError, StrResult};
+use typst::eval::Library;
use typst::font::{Font, FontBook, FontInfo, FontVariant};
-use typst::model::Library;
use typst::syntax::{Source, SourceId};
use typst::util::{Buffer, PathExt};
use typst::World;
diff --git a/docs/src/lib.rs b/docs/src/lib.rs
index 1989970e..c32f9ff9 100644
--- a/docs/src/lib.rs
+++ b/docs/src/lib.rs
@@ -15,9 +15,9 @@ use serde::de::DeserializeOwned;
use serde::{Deserialize, Serialize};
use serde_yaml as yaml;
use typst::doc::Frame;
+use typst::eval::{CastInfo, Func, FuncInfo, Library, Module, ParamInfo, Value};
use typst::font::{Font, FontBook};
use typst::geom::{Abs, Sides, Smart};
-use typst::model::{CastInfo, Func, FuncInfo, Library, Module, ParamInfo, Value};
use typst_library::layout::PageNode;
use unscanny::Scanner;
@@ -43,7 +43,7 @@ static LIBRARY: Lazy<Prehashed<Library>> = Lazy::new(|| {
lib.styles.set(PageNode::HEIGHT, Smart::Auto);
lib.styles
.set(PageNode::MARGIN, Sides::splat(Some(Smart::Custom(Abs::pt(15.0).into()))));
- typst::model::set_lang_items(lib.items.clone());
+ typst::eval::set_lang_items(lib.items.clone());
Prehashed::new(lib)
});
@@ -630,7 +630,7 @@ fn symbol_page(resolver: &dyn Resolver, parent: &str, name: &str) -> PageModel {
.find(|&(_, x)| x == c)
.map(|(s, _)| s),
codepoint: c as u32,
- accent: typst::model::combining_accent(c).is_some(),
+ accent: typst::eval::combining_accent(c).is_some(),
unicode_name: unicode_names2::name(c)
.map(|s| s.to_string().to_title_case()),
alternates: symbol
diff --git a/library/src/compute/calc.rs b/library/src/compute/calc.rs
index 8eae1185..9ebce84c 100644
--- a/library/src/compute/calc.rs
+++ b/library/src/compute/calc.rs
@@ -1,7 +1,7 @@
use std::cmp::Ordering;
use std::ops::Rem;
-use typst::model::{Module, Scope};
+use typst::eval::{Module, Scope};
use crate::prelude::*;
diff --git a/library/src/compute/construct.rs b/library/src/compute/construct.rs
index b6f2de8f..8355e20f 100644
--- a/library/src/compute/construct.rs
+++ b/library/src/compute/construct.rs
@@ -1,7 +1,7 @@
use std::str::FromStr;
use ecow::EcoVec;
-use typst::model::Regex;
+use typst::eval::Regex;
use crate::prelude::*;
diff --git a/library/src/compute/foundations.rs b/library/src/compute/foundations.rs
index ccf7a165..1619fb60 100644
--- a/library/src/compute/foundations.rs
+++ b/library/src/compute/foundations.rs
@@ -137,5 +137,5 @@ pub fn assert(args: &mut Args) -> SourceResult<Value> {
#[func]
pub fn eval(vm: &Vm, args: &mut Args) -> SourceResult<Value> {
let Spanned { v: text, span } = args.expect::<Spanned<String>>("source")?;
- typst::model::eval_code_str(vm.world(), &text, span)
+ typst::eval::eval_code_str(vm.world(), &text, span)
}
diff --git a/library/src/lib.rs b/library/src/lib.rs
index 31da5b71..0759f73f 100644
--- a/library/src/lib.rs
+++ b/library/src/lib.rs
@@ -10,8 +10,9 @@ pub mod symbols;
pub mod text;
pub mod visualize;
+use typst::eval::{LangItems, Library, Module, Scope};
use typst::geom::{Align, Color, Dir, GenAlign};
-use typst::model::{LangItems, Library, Module, Node, NodeId, Scope, StyleMap};
+use typst::model::{Node, NodeId, StyleMap};
use self::layout::LayoutRoot;
diff --git a/library/src/math/accent.rs b/library/src/math/accent.rs
index aa6d0523..9c474eee 100644
--- a/library/src/math/accent.rs
+++ b/library/src/math/accent.rs
@@ -1,4 +1,4 @@
-use typst::model::combining_accent;
+use typst::eval::combining_accent;
use super::*;
diff --git a/library/src/math/mod.rs b/library/src/math/mod.rs
index c455d106..d73b1769 100644
--- a/library/src/math/mod.rs
+++ b/library/src/math/mod.rs
@@ -29,9 +29,9 @@ pub use self::style::*;
pub use self::underover::*;
use ttf_parser::{GlyphId, Rect};
-use typst::font::Font;
-use typst::font::FontWeight;
-use typst::model::{Guard, Module, Scope, SequenceNode, StyledNode};
+use typst::eval::{Module, Scope};
+use typst::font::{Font, FontWeight};
+use typst::model::{Guard, SequenceNode, StyledNode};
use unicode_math_class::MathClass;
use self::ctx::*;
diff --git a/library/src/math/op.rs b/library/src/math/op.rs
index 772013bd..4eb9c48c 100644
--- a/library/src/math/op.rs
+++ b/library/src/math/op.rs
@@ -1,4 +1,4 @@
-use typst::model::Scope;
+use typst::eval::Scope;
use super::*;
diff --git a/library/src/prelude.rs b/library/src/prelude.rs
index 22458a55..a406e586 100644
--- a/library/src/prelude.rs
+++ b/library/src/prelude.rs
@@ -14,13 +14,17 @@ pub use typst::diag::{bail, error, At, SourceResult, StrResult};
#[doc(no_inline)]
pub use typst::doc::*;
#[doc(no_inline)]
+pub use typst::eval::{
+ array, castable, dict, format_str, func, Args, Array, AutoValue, Cast, CastInfo,
+ Dict, Func, NoneValue, Str, Symbol, Value, Vm,
+};
+#[doc(no_inline)]
pub use typst::geom::*;
#[doc(no_inline)]
pub use typst::model::{
- array, capability, capable, castable, dict, format_str, func, node, Args, Array,
- AutoValue, Cast, CastInfo, Content, Dict, Finalize, Fold, Func, Introspector, Label,
- Node, NodeId, NoneValue, Prepare, Resolve, Selector, Show, StabilityProvider, Str,
- StyleChain, StyleMap, StyleVec, Symbol, Unlabellable, Value, Vm, Vt,
+ capability, capable, node, Content, Finalize, Fold, Introspector, Label, Node,
+ NodeId, Prepare, Resolve, Selector, Show, StabilityProvider, StyleChain, StyleMap,
+ StyleVec, Unlabellable, Vt,
};
#[doc(no_inline)]
pub use typst::syntax::{Span, Spanned};
diff --git a/library/src/symbols/emoji.rs b/library/src/symbols/emoji.rs
index efde0e76..07c7004b 100644
--- a/library/src/symbols/emoji.rs
+++ b/library/src/symbols/emoji.rs
@@ -1,4 +1,4 @@
-use typst::model::{symbols, Module, Scope, Symbol};
+use typst::eval::{symbols, Module, Scope, Symbol};
/// A module with all emoji.
pub fn emoji() -> Module {
diff --git a/library/src/symbols/sym.rs b/library/src/symbols/sym.rs
index 6a6ca758..90c89fc3 100644
--- a/library/src/symbols/sym.rs
+++ b/library/src/symbols/sym.rs
@@ -1,4 +1,4 @@
-use typst::model::{symbols, Module, Scope, Symbol};
+use typst::eval::{symbols, Module, Scope, Symbol};
/// A module with all general symbols.
pub fn sym() -> Module {
diff --git a/macros/src/castable.rs b/macros/src/castable.rs
index 6738ee1d..c39df90a 100644
--- a/macros/src/castable.rs
+++ b/macros/src/castable.rs
@@ -18,20 +18,20 @@ pub fn castable(stream: TokenStream) -> Result<TokenStream> {
let describe_func = create_describe_func(&castable);
let dynamic_impls = castable.name.as_ref().map(|name| {
quote! {
- impl ::typst::model::Type for #ty {
+ impl ::typst::eval::Type for #ty {
const TYPE_NAME: &'static str = #name;
}
- impl From<#ty> for ::typst::model::Value {
+ impl From<#ty> for ::typst::eval::Value {
fn from(v: #ty) -> Self {
- ::typst::model::Value::Dyn(::typst::model::Dynamic::new(v))
+ ::typst::eval::Value::Dyn(::typst::eval::Dynamic::new(v))
}
}
}
});
Ok(quote! {
- impl ::typst::model::Cast for #ty {
+ impl ::typst::eval::Cast for #ty {
#is_func
#cast_func
#describe_func
@@ -53,7 +53,7 @@ fn create_is_func(castable: &Castable) -> TokenStream {
}
Pattern::Ty(_, ty) => {
cast_checks.push(quote! {
- if <#ty as ::typst::model::Cast>::is(value) {
+ if <#ty as ::typst::eval::Cast>::is(value) {
return true;
}
});
@@ -63,7 +63,7 @@ fn create_is_func(castable: &Castable) -> TokenStream {
let dynamic_check = castable.name.is_some().then(|| {
quote! {
- if let ::typst::model::Value::Dyn(dynamic) = &value {
+ if let ::typst::eval::Value::Dyn(dynamic) = &value {
if dynamic.is::<Self>() {
return true;
}
@@ -73,7 +73,7 @@ fn create_is_func(castable: &Castable) -> TokenStream {
let str_check = (!string_arms.is_empty()).then(|| {
quote! {
- if let ::typst::model::Value::Str(string) = &value {
+ if let ::typst::eval::Value::Str(string) = &value {
match string.as_str() {
#(#string_arms,)*
_ => {}
@@ -83,7 +83,7 @@ fn create_is_func(castable: &Castable) -> TokenStream {
});
quote! {
- fn is(value: &typst::model::Value) -> bool {
+ fn is(value: &::typst::eval::Value) -> bool {
#dynamic_check
#str_check
#(#cast_checks)*
@@ -105,8 +105,8 @@ fn create_cast_func(castable: &Castable) -> TokenStream {
}
Pattern::Ty(binding, ty) => {
cast_checks.push(quote! {
- if <#ty as ::typst::model::Cast>::is(&value) {
- let #binding = <#ty as ::typst::model::Cast>::cast(value)?;
+ if <#ty as ::typst::eval::Cast>::is(&value) {
+ let #binding = <#ty as ::typst::eval::Cast>::cast(value)?;
return Ok(#expr);
}
});
@@ -116,7 +116,7 @@ fn create_cast_func(castable: &Castable) -> TokenStream {
let dynamic_check = castable.name.is_some().then(|| {
quote! {
- if let ::typst::model::Value::Dyn(dynamic) = &value {
+ if let ::typst::eval::Value::Dyn(dynamic) = &value {
if let Some(concrete) = dynamic.downcast::<Self>() {
return Ok(concrete.clone());
}
@@ -126,7 +126,7 @@ fn create_cast_func(castable: &Castable) -> TokenStream {
let str_check = (!string_arms.is_empty()).then(|| {
quote! {
- if let ::typst::model::Value::Str(string) = &value {
+ if let ::typst::eval::Value::Str(string) = &value {
match string.as_str() {
#(#string_arms,)*
_ => {}
@@ -136,11 +136,11 @@ fn create_cast_func(castable: &Castable) -> TokenStream {
});
quote! {
- fn cast(value: ::typst::model::Value) -> ::typst::diag::StrResult<Self> {
+ fn cast(value: ::typst::eval::Value) -> ::typst::diag::StrResult<Self> {
#dynamic_check
#str_check
#(#cast_checks)*
- <Self as ::typst::model::Cast>::error(value)
+ <Self as ::typst::eval::Cast>::error(value)
}
}
}
@@ -153,10 +153,10 @@ fn create_describe_func(castable: &Castable) -> TokenStream {
let docs = documentation(&cast.attrs);
infos.push(match &cast.pattern {
Pattern::Str(lit) => {
- quote! { ::typst::model::CastInfo::Value(#lit.into(), #docs) }
+ quote! { ::typst::eval::CastInfo::Value(#lit.into(), #docs) }
}
Pattern::Ty(_, ty) => {
- quote! { <#ty as ::typst::model::Cast>::describe() }
+ quote! { <#ty as ::typst::eval::Cast>::describe() }
}
});
}
@@ -168,7 +168,7 @@ fn create_describe_func(castable: &Castable) -> TokenStream {
}
quote! {
- fn describe() -> ::typst::model::CastInfo {
+ fn describe() -> ::typst::eval::CastInfo {
#(#infos)+*
}
}
diff --git a/macros/src/func.rs b/macros/src/func.rs
index 41504b20..f65c135e 100644
--- a/macros/src/func.rs
+++ b/macros/src/func.rs
@@ -21,7 +21,7 @@ pub fn func(item: syn::Item) -> Result<TokenStream> {
let docs = docs.trim();
let info = quote! {
- ::typst::model::FuncInfo {
+ ::typst::eval::FuncInfo {
name,
display: #display,
category: #category,
@@ -54,9 +54,9 @@ pub fn func(item: syn::Item) -> Result<TokenStream> {
#[doc(hidden)]
#vis enum #ty {}
- impl::typst::model::FuncType for #ty {
- fn create_func(name: &'static str) -> ::typst::model::Func {
- ::typst::model::Func::from_fn(#full, #info)
+ impl::typst::eval::FuncType for #ty {
+ fn create_func(name: &'static str) -> ::typst::eval::Func {
+ ::typst::eval::Func::from_fn(#full, #info)
}
}
})
@@ -72,9 +72,9 @@ pub fn func(item: syn::Item) -> Result<TokenStream> {
Ok(quote! {
#item
- impl #params ::typst::model::FuncType for #ident #args #clause {
- fn create_func(name: &'static str) -> ::typst::model::Func {
- ::typst::model::Func::from_node::<Self>(#info)
+ impl #params ::typst::eval::FuncType for #ident #args #clause {
+ fn create_func(name: &'static str) -> ::typst::eval::Func {
+ ::typst::eval::Func::from_node::<Self>(#info)
}
}
})
@@ -159,11 +159,11 @@ fn params(docs: &mut String) -> Result<(Vec<TokenStream>, Vec<String>)> {
let docs = docs.trim();
infos.push(quote! {
- ::typst::model::ParamInfo {
+ ::typst::eval::ParamInfo {
name: #name,
docs: #docs,
- cast: <#ty as ::typst::model::Cast<
- ::typst::syntax::Spanned<::typst::model::Value>
+ cast: <#ty as ::typst::eval::Cast<
+ ::typst::syntax::Spanned<::typst::eval::Value>
>>::describe(),
named: #named,
positional: #positional,
diff --git a/macros/src/node.rs b/macros/src/node.rs
index b551182f..0d59a402 100644
--- a/macros/src/node.rs
+++ b/macros/src/node.rs
@@ -270,8 +270,8 @@ fn create_node_construct_func(node: &Node) -> syn::ImplItemMethod {
node.construct.clone().unwrap_or_else(|| {
parse_quote! {
fn construct(
- _: &::typst::model::Vm,
- args: &mut ::typst::model::Args,
+ _: &::typst::eval::Vm,
+ args: &mut ::typst::eval::Args,
) -> ::typst::diag::SourceResult<::typst::model::Content> {
::typst::diag::bail!(args.span, "cannot be constructed manually");
}
@@ -317,7 +317,7 @@ fn create_node_set_func(node: &Node) -> syn::ImplItemMethod {
parse_quote! {
fn set(
- args: &mut ::typst::model::Args,
+ args: &mut ::typst::eval::Args,
constructor: bool,
) -> ::typst::diag::SourceResult<::typst::model::StyleMap> {
let mut styles = ::typst::model::StyleMap::new();
@@ -340,11 +340,11 @@ fn create_node_properties_func(node: &Node) -> syn::ImplItemMethod {
let docs = docs.trim();
quote! {
- ::typst::model::ParamInfo {
+ ::typst::eval::ParamInfo {
name: #name,
docs: #docs,
- cast: <#value_ty as ::typst::model::Cast<
- ::typst::syntax::Spanned<::typst::model::Value>
+ cast: <#value_ty as ::typst::eval::Cast<
+ ::typst::syntax::Spanned<::typst::eval::Value>
>>::describe(),
named: true,
positional: #shorthand,
@@ -356,7 +356,7 @@ fn create_node_properties_func(node: &Node) -> syn::ImplItemMethod {
});
parse_quote! {
- fn properties() -> ::std::vec::Vec<::typst::model::ParamInfo>
+ fn properties() -> ::std::vec::Vec<::typst::eval::ParamInfo>
where
Self: Sized
{
@@ -372,7 +372,7 @@ fn create_node_field_method(node: &Node) -> syn::ImplItemMethod {
fn field(
&self,
_: &str,
- ) -> ::std::option::Option<::typst::model::Value> {
+ ) -> ::std::option::Option<::typst::eval::Value> {
None
}
}
diff --git a/macros/src/symbols.rs b/macros/src/symbols.rs
index fb120883..efa4834d 100644
--- a/macros/src/symbols.rs
+++ b/macros/src/symbols.rs
@@ -62,11 +62,11 @@ impl Parse for Kind {
impl Kind {
fn expand(&self) -> TokenStream {
match self {
- Self::Single(c) => quote! { typst::model::Symbol::new(#c), },
+ Self::Single(c) => quote! { typst::eval::Symbol::new(#c), },
Self::Multiple(variants) => {
let variants = variants.iter().map(Variant::expand);
quote! {
- typst::model::Symbol::list(&[#(#variants),*])
+ typst::eval::Symbol::list(&[#(#variants),*])
}
}
}
diff --git a/src/doc.rs b/src/doc.rs
index 55e2f467..cba3ca99 100644
--- a/src/doc.rs
+++ b/src/doc.rs
@@ -7,15 +7,14 @@ use std::sync::Arc;
use ecow::EcoString;
+use crate::eval::{dict, Dict, Value};
use crate::font::Font;
use crate::geom::{
self, rounded_rect, Abs, Align, Axes, Color, Corners, Dir, Em, Geometry, Numeric,
Paint, Point, Rel, RgbaColor, Shape, Sides, Size, Stroke, Transform,
};
use crate::image::Image;
-use crate::model::{
- capable, dict, node, Content, Dict, Fold, StableId, StyleChain, Value,
-};
+use crate::model::{capable, node, Content, Fold, StableId, StyleChain};
/// A finished document with metadata and page frames.
#[derive(Debug, Default, Clone, Hash)]
diff --git a/src/model/args.rs b/src/eval/args.rs
index 159e9a77..159e9a77 100644
--- a/src/model/args.rs
+++ b/src/eval/args.rs
diff --git a/src/model/array.rs b/src/eval/array.rs
index 746763ab..53bae06f 100644
--- a/src/model/array.rs
+++ b/src/eval/array.rs
@@ -12,11 +12,11 @@ use crate::diag::{bail, At, SourceResult, StrResult};
#[doc(hidden)]
macro_rules! __array {
($value:expr; $count:expr) => {
- $crate::model::Array::from_vec($crate::model::eco_vec![$value.into(); $count])
+ $crate::eval::Array::from_vec($crate::eval::eco_vec![$value.into(); $count])
};
($($value:expr),* $(,)?) => {
- $crate::model::Array::from_vec($crate::model::eco_vec![$($value.into()),*])
+ $crate::eval::Array::from_vec($crate::eval::eco_vec![$($value.into()),*])
};
}
diff --git a/src/model/cast.rs b/src/eval/cast.rs
index 4c300550..77521f7f 100644
--- a/src/model/cast.rs
+++ b/src/eval/cast.rs
@@ -4,9 +4,7 @@ use std::str::FromStr;
use ecow::EcoString;
-use super::{
- castable, Array, Content, Dict, Func, Label, Regex, Selector, Str, Transform, Value,
-};
+use super::{castable, Array, Dict, Func, Regex, Str, Value};
use crate::diag::StrResult;
use crate::doc::{Destination, Lang, Location, Region};
use crate::font::{FontStretch, FontStyle, FontWeight};
@@ -14,6 +12,7 @@ use crate::geom::{
Axes, Color, Corners, Dir, GenAlign, Get, Length, Paint, PartialStroke, Point, Ratio,
Rel, Sides, Smart,
};
+use crate::model::{Content, Label, Selector, Transform};
use crate::syntax::Spanned;
/// Cast from a value to a specific type.
diff --git a/src/model/dict.rs b/src/eval/dict.rs
index 50a2275f..6c1934c9 100644
--- a/src/model/dict.rs
+++ b/src/eval/dict.rs
@@ -18,7 +18,7 @@ macro_rules! __dict {
#[allow(unused_mut)]
let mut map = std::collections::BTreeMap::new();
$(map.insert($key.into(), $value.into());)*
- $crate::model::Dict::from_map(map)
+ $crate::eval::Dict::from_map(map)
}};
}
diff --git a/src/model/func.rs b/src/eval/func.rs
index 2ba462d3..e5280932 100644
--- a/src/model/func.rs
+++ b/src/eval/func.rs
@@ -5,11 +5,9 @@ use std::sync::Arc;
use comemo::{Prehashed, Track, Tracked, TrackedMut};
use ecow::EcoString;
-use super::{
- Args, CastInfo, Dict, Eval, Flow, Node, NodeId, Route, Scope, Scopes, Selector,
- StyleMap, Tracer, Value, Vm,
-};
+use super::{Args, CastInfo, Dict, Eval, Flow, Route, Scope, Scopes, Tracer, Value, Vm};
use crate::diag::{bail, SourceResult, StrResult};
+use crate::model::{Node, NodeId, Selector, StyleMap};
use crate::syntax::ast::{self, AstNode, Expr};
use crate::syntax::{SourceId, Span, SyntaxNode};
use crate::util::hash128;
diff --git a/src/model/library.rs b/src/eval/library.rs
index 8ef22f10..adfcc6e7 100644
--- a/src/model/library.rs
+++ b/src/eval/library.rs
@@ -5,10 +5,11 @@ use std::num::NonZeroUsize;
use ecow::EcoString;
use once_cell::sync::OnceCell;
-use super::{Content, Module, NodeId, StyleChain, StyleMap, Vt};
+use super::Module;
use crate::diag::SourceResult;
use crate::doc::Document;
use crate::geom::{Abs, Dir};
+use crate::model::{Content, NodeId, StyleChain, StyleMap, Vt};
use crate::util::hash128;
/// Definition of Typst's standard library.
@@ -139,6 +140,6 @@ pub fn set_lang_items(items: LangItems) {
/// Access a lang item.
macro_rules! item {
($name:ident) => {
- $crate::model::LANG_ITEMS.get().unwrap().$name
+ $crate::eval::LANG_ITEMS.get().unwrap().$name
};
}
diff --git a/src/model/methods.rs b/src/eval/methods.rs
index dcb1ca31..dcb1ca31 100644
--- a/src/model/methods.rs
+++ b/src/eval/methods.rs
diff --git a/src/model/eval.rs b/src/eval/mod.rs
index 225c5e7a..2cf6f4d1 100644
--- a/src/model/eval.rs
+++ b/src/eval/mod.rs
@@ -1,5 +1,40 @@
//! Evaluation of markup into modules.
+#[macro_use]
+mod library;
+#[macro_use]
+mod cast;
+#[macro_use]
+mod array;
+#[macro_use]
+mod dict;
+#[macro_use]
+mod str;
+#[macro_use]
+mod value;
+mod args;
+mod func;
+mod methods;
+mod module;
+mod ops;
+mod scope;
+mod symbol;
+
+pub use typst_macros::{castable, func};
+
+pub use self::args::*;
+pub use self::array::*;
+pub use self::cast::*;
+pub use self::dict::*;
+pub use self::func::*;
+pub use self::library::*;
+pub use self::methods::*;
+pub use self::module::*;
+pub use self::scope::*;
+pub use self::str::*;
+pub use self::symbol::*;
+pub use self::value::*;
+
use std::collections::BTreeMap;
use std::mem;
use std::path::{Path, PathBuf};
@@ -8,14 +43,10 @@ use comemo::{Track, Tracked, TrackedMut};
use ecow::EcoVec;
use unicode_segmentation::UnicodeSegmentation;
-use super::{
- combining_accent, methods, ops, Arg, Args, Array, CapturesVisitor, Closure, Content,
- Dict, Func, Label, LangItems, Module, Recipe, Scopes, Selector, StyleMap, Symbol,
- Transform, Value,
-};
use crate::diag::{
bail, error, At, SourceError, SourceResult, StrResult, Trace, Tracepoint,
};
+use crate::model::{Content, Label, Recipe, Selector, StyleMap, Transform};
use crate::syntax::ast::AstNode;
use crate::syntax::{
ast, parse_code, Source, SourceId, Span, Spanned, SyntaxKind, SyntaxNode,
@@ -43,7 +74,7 @@ pub fn eval(
// Hook up the lang items.
let library = world.library();
- super::set_lang_items(library.items.clone());
+ set_lang_items(library.items.clone());
// Evaluate the module.
let route = unsafe { Route::insert(route, id) };
diff --git a/src/model/module.rs b/src/eval/module.rs
index e911d859..e911d859 100644
--- a/src/model/module.rs
+++ b/src/eval/module.rs
diff --git a/src/model/ops.rs b/src/eval/ops.rs
index 52b9b06a..52b9b06a 100644
--- a/src/model/ops.rs
+++ b/src/eval/ops.rs
diff --git a/src/model/scope.rs b/src/eval/scope.rs
index f6bd2164..f6bd2164 100644
--- a/src/model/scope.rs
+++ b/src/eval/scope.rs
diff --git a/src/model/str.rs b/src/eval/str.rs
index 5fcc1d05..63ea5dc8 100644
--- a/src/model/str.rs
+++ b/src/eval/str.rs
@@ -15,7 +15,7 @@ use crate::geom::GenAlign;
#[doc(hidden)]
macro_rules! __format_str {
($($tts:tt)*) => {{
- $crate::model::Str::from($crate::model::eco_format!($($tts)*))
+ $crate::eval::Str::from($crate::eval::eco_format!($($tts)*))
}};
}
diff --git a/src/model/symbol.rs b/src/eval/symbol.rs
index 73c41067..73c41067 100644
--- a/src/model/symbol.rs
+++ b/src/eval/symbol.rs
diff --git a/src/model/value.rs b/src/eval/value.rs
index f6ab95de..5e06da76 100644
--- a/src/model/value.rs
+++ b/src/eval/value.rs
@@ -461,7 +461,7 @@ primitive! { Args: "arguments", Args }
#[cfg(test)]
mod tests {
use super::*;
- use crate::model::{array, dict};
+ use crate::eval::{array, dict};
#[track_caller]
fn test(value: impl Into<Value>, exp: &str) {
diff --git a/src/ide/analyze.rs b/src/ide/analyze.rs
index 357e98f8..3c46cca1 100644
--- a/src/ide/analyze.rs
+++ b/src/ide/analyze.rs
@@ -2,7 +2,7 @@ use std::path::PathBuf;
use comemo::Track;
-use crate::model::{eval, Module, Route, Tracer, Value};
+use crate::eval::{eval, Module, Route, Tracer, Value};
use crate::syntax::{ast, LinkedNode, Source, SyntaxKind};
use crate::util::PathExt;
use crate::World;
diff --git a/src/ide/complete.rs b/src/ide/complete.rs
index fe1afe66..06ab53a1 100644
--- a/src/ide/complete.rs
+++ b/src/ide/complete.rs
@@ -4,7 +4,7 @@ use ecow::{eco_format, EcoString};
use if_chain::if_chain;
use super::{analyze_expr, analyze_import, plain_docs_sentence, summarize_font_family};
-use crate::model::{methods_on, CastInfo, Scope, Value};
+use crate::eval::{methods_on, CastInfo, Scope, Value};
use crate::syntax::{ast, LinkedNode, Source, SyntaxKind};
use crate::World;
diff --git a/src/ide/tooltip.rs b/src/ide/tooltip.rs
index 0796c09e..ac0cb60b 100644
--- a/src/ide/tooltip.rs
+++ b/src/ide/tooltip.rs
@@ -2,8 +2,8 @@ use if_chain::if_chain;
use unicode_segmentation::UnicodeSegmentation;
use super::{analyze_expr, plain_docs_sentence, summarize_font_family};
+use crate::eval::{CastInfo, Tracer, Value};
use crate::geom::{round_2, Length, Numeric};
-use crate::model::{CastInfo, Tracer, Value};
use crate::syntax::ast;
use crate::syntax::{LinkedNode, Source, SyntaxKind};
use crate::World;
diff --git a/src/lib.rs b/src/lib.rs
index 1c399864..d73055d1 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -23,8 +23,8 @@
//! [parsed]: syntax::parse
//! [syntax tree]: syntax::SyntaxNode
//! [AST]: syntax::ast
-//! [evaluate]: model::eval
-//! [module]: model::Module
+//! [evaluate]: eval::eval
+//! [module]: eval::Module
//! [content]: model::Content
//! [typeset]: model::typeset
//! [document]: doc::Document
@@ -43,23 +43,23 @@ pub mod geom;
#[macro_use]
pub mod diag;
#[macro_use]
-pub mod model;
+pub mod eval;
pub mod doc;
pub mod export;
pub mod font;
pub mod ide;
pub mod image;
+pub mod model;
pub mod syntax;
use std::path::Path;
use comemo::{Prehashed, Track};
-use model::Tracer;
use crate::diag::{FileResult, SourceResult};
use crate::doc::Document;
+use crate::eval::{Library, Route, Tracer};
use crate::font::{Font, FontBook};
-use crate::model::{Library, Route};
use crate::syntax::{Source, SourceId};
use crate::util::Buffer;
@@ -68,7 +68,7 @@ pub fn compile(world: &(dyn World + 'static), source: &Source) -> SourceResult<D
// Evaluate the source file into a module.
let route = Route::default();
let mut tracer = Tracer::default();
- let module = model::eval(world.track(), route.track(), tracer.track_mut(), source)?;
+ let module = eval::eval(world.track(), route.track(), tracer.track_mut(), source)?;
// Typeset the module's contents.
model::typeset(world.track(), &module.content())
diff --git a/src/model/content.rs b/src/model/content.rs
index b8047ffa..b10a3409 100644
--- a/src/model/content.rs
+++ b/src/model/content.rs
@@ -10,11 +10,9 @@ use ecow::{EcoString, EcoVec};
use siphasher::sip128::{Hasher128, SipHasher};
use typst_macros::node;
-use super::{
- capability, capable, Args, Guard, Key, ParamInfo, Property, Recipe, Style, StyleMap,
- Value, Vm,
-};
+use super::{capability, capable, Guard, Key, Property, Recipe, Style, StyleMap};
use crate::diag::{SourceResult, StrResult};
+use crate::eval::{Args, ParamInfo, Value, Vm};
use crate::syntax::Span;
use crate::util::ReadableTypeId;
use crate::World;
@@ -243,7 +241,7 @@ impl Content {
}
/// Whether a label can be attached to the content.
- pub(super) fn labellable(&self) -> bool {
+ pub(crate) fn labellable(&self) -> bool {
!self.has::<dyn Unlabellable>()
}
diff --git a/src/model/mod.rs b/src/model/mod.rs
index 32b0a003..692d18d5 100644
--- a/src/model/mod.rs
+++ b/src/model/mod.rs
@@ -1,49 +1,16 @@
-//! Content and computation model.
+//! The document model.
#[macro_use]
-mod library;
-#[macro_use]
-mod cast;
-#[macro_use]
-mod array;
-#[macro_use]
-mod dict;
-#[macro_use]
-mod str;
-#[macro_use]
-mod value;
-#[macro_use]
mod styles;
-mod args;
mod content;
-mod eval;
-mod func;
-mod methods;
-mod module;
-mod ops;
mod realize;
-mod scope;
-mod symbol;
mod typeset;
-#[doc(hidden)]
-pub use once_cell;
-pub use typst_macros::{capability, capable, castable, func, node};
-
-pub use self::args::*;
-pub use self::array::*;
-pub use self::cast::*;
pub use self::content::*;
-pub use self::dict::*;
-pub use self::eval::*;
-pub use self::func::*;
-pub use self::library::*;
-pub use self::methods::*;
-pub use self::module::*;
pub use self::realize::*;
-pub use self::scope::*;
-pub use self::str::*;
pub use self::styles::*;
-pub use self::symbol::*;
pub use self::typeset::*;
-pub use self::value::*;
+
+#[doc(hidden)]
+pub use once_cell;
+pub use typst_macros::{capability, capable, node};
diff --git a/src/model/styles.rs b/src/model/styles.rs
index 27c40309..18507491 100644
--- a/src/model/styles.rs
+++ b/src/model/styles.rs
@@ -7,8 +7,9 @@ use std::sync::Arc;
use comemo::{Prehashed, Tracked};
-use super::{Args, Content, Dict, Func, Label, NodeId, Regex, Value};
+use super::{Content, Label, NodeId};
use crate::diag::{SourceResult, Trace, Tracepoint};
+use crate::eval::{Args, Dict, Func, Regex, Value};
use crate::geom::{
Abs, Align, Axes, Corners, Em, GenAlign, Length, Numeric, PartialStroke, Rel, Sides,
Smart,
diff --git a/src/model/typeset.rs b/src/model/typeset.rs
index 7af8094c..f8b5e012 100644
--- a/src/model/typeset.rs
+++ b/src/model/typeset.rs
@@ -5,9 +5,10 @@ use std::num::NonZeroUsize;
use comemo::{Track, Tracked, TrackedMut};
-use super::{Content, Selector, StyleChain, Value};
+use super::{Content, Selector, StyleChain};
use crate::diag::SourceResult;
use crate::doc::{Document, Element, Frame, Location, Meta};
+use crate::eval::Value;
use crate::geom::Transform;
use crate::util::hash128;
use crate::World;
@@ -46,7 +47,7 @@ pub fn typeset(world: Tracked<dyn World>, content: &Content) -> SourceResult<Doc
/// A virtual typesetter.
///
/// Holds the state needed to [typeset] content. This is the equivalent to the
-/// [Vm](super::Vm) for typesetting.
+/// [Vm](crate::eval::Vm) for typesetting.
pub struct Vt<'a> {
/// The compilation environment.
#[doc(hidden)]
diff --git a/tests/src/benches.rs b/tests/src/benches.rs
index 1628f32d..ea53f602 100644
--- a/tests/src/benches.rs
+++ b/tests/src/benches.rs
@@ -3,8 +3,8 @@ use std::path::Path;
use comemo::{Prehashed, Track, Tracked};
use iai::{black_box, main, Iai};
use typst::diag::{FileError, FileResult};
+use typst::eval::Library;
use typst::font::{Font, FontBook};
-use typst::model::Library;
use typst::syntax::{Source, SourceId};
use typst::util::Buffer;
use typst::World;
@@ -59,24 +59,19 @@ fn bench_edit(iai: &mut Iai) {
fn bench_eval(iai: &mut Iai) {
let world = BenchWorld::new();
- let route = typst::model::Route::default();
- let mut tracer = typst::model::Tracer::default();
+ let route = typst::eval::Route::default();
+ let mut tracer = typst::eval::Tracer::default();
iai.run(|| {
- typst::model::eval(
- world.track(),
- route.track(),
- tracer.track_mut(),
- &world.source,
- )
- .unwrap()
+ typst::eval::eval(world.track(), route.track(), tracer.track_mut(), &world.source)
+ .unwrap()
});
}
fn bench_typeset(iai: &mut Iai) {
let world = BenchWorld::new();
- let route = typst::model::Route::default();
- let mut tracer = typst::model::Tracer::default();
- let module = typst::model::eval(
+ let route = typst::eval::Route::default();
+ let mut tracer = typst::eval::Tracer::default();
+ let module = typst::eval::eval(
world.track(),
route.track(),
tracer.track_mut(),
diff --git a/tests/src/tests.rs b/tests/src/tests.rs
index 62e6f3f5..0c2b0490 100644
--- a/tests/src/tests.rs
+++ b/tests/src/tests.rs
@@ -13,9 +13,9 @@ use once_cell::unsync::OnceCell;
use tiny_skia as sk;
use typst::diag::{bail, FileError, FileResult, SourceResult};
use typst::doc::{Document, Element, Frame, Meta};
+use typst::eval::{func, Library, Value};
use typst::font::{Font, FontBook};
use typst::geom::{Abs, RgbaColor, Sides, Smart};
-use typst::model::{func, Library, Value};
use typst::syntax::{Source, SourceId, Span, SyntaxNode};
use typst::util::{Buffer, PathExt};
use typst::World;
@@ -150,7 +150,7 @@ fn library() -> Library {
/// ## Category
/// test
#[func]
- fn test(args: &mut typst::model::Args) -> SourceResult<Value> {
+ fn test(args: &mut typst::eval::Args) -> SourceResult<Value> {
let lhs = args.expect::<Value>("left-hand side")?;
let rhs = args.expect::<Value>("right-hand side")?;
if lhs != rhs {
@@ -163,7 +163,7 @@ fn library() -> Library {
/// ## Category
/// test
#[func]
- fn print(args: &mut typst::model::Args) -> SourceResult<Value> {
+ fn print(args: &mut typst::eval::Args) -> SourceResult<Value> {
print!("> ");
for (i, value) in args.all::<Value>()?.into_iter().enumerate() {
if i > 0 {
@@ -441,10 +441,10 @@ fn test_part(
if world.print.model {
let world = (world as &dyn World).track();
- let route = typst::model::Route::default();
- let mut tracer = typst::model::Tracer::default();
+ let route = typst::eval::Route::default();
+ let mut tracer = typst::eval::Tracer::default();
let module =
- typst::model::eval(world, route.track(), tracer.track_mut(), source).unwrap();
+ typst::eval::eval(world, route.track(), tracer.track_mut(), source).unwrap();
println!("Model:\n{:#?}\n", module.content());
}