summaryrefslogtreecommitdiff
path: root/crates/typst-macros/src
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-11-25 16:10:28 +0100
committerLaurenz <laurmaedje@gmail.com>2023-11-26 19:03:21 +0100
commit85b1d1d4dd4628d1fb8901c3280cde84da450bbe (patch)
treeb69a629be9295268e071667b1587a5701f2bc7ef /crates/typst-macros/src
parent2f795b5c07171affa0709195a9dae3ed5c0afbeb (diff)
Rework `Vt` into `Engine`
- Moves as much data out of the `Vm` - Removes duplication with call_vm and call_vt flavours - Uses tracked chain instead of fixed int for determining max nesting depth - This means that nesting checks now generalizes to layout and realization, to detect crashing show rules and overly nested layouts
Diffstat (limited to 'crates/typst-macros/src')
-rw-r--r--crates/typst-macros/src/elem.rs4
-rw-r--r--crates/typst-macros/src/func.rs13
2 files changed, 7 insertions, 10 deletions
diff --git a/crates/typst-macros/src/elem.rs b/crates/typst-macros/src/elem.rs
index 9791427b..ce80cc66 100644
--- a/crates/typst-macros/src/elem.rs
+++ b/crates/typst-macros/src/elem.rs
@@ -1083,7 +1083,7 @@ fn create_construct_impl(element: &Elem) -> TokenStream {
quote! {
impl #foundations::Construct for #ident {
fn construct(
- vm: &mut ::typst::eval::Vm,
+ engine: &mut ::typst::engine::Engine,
args: &mut #foundations::Args,
) -> ::typst::diag::SourceResult<#foundations::Content> {
#(#pre)*
@@ -1115,7 +1115,7 @@ fn create_set_impl(element: &Elem) -> TokenStream {
quote! {
impl #foundations::Set for #ident {
fn set(
- vm: &mut ::typst::eval::Vm,
+ engine: &mut ::typst::engine::Engine,
args: &mut #foundations::Args,
) -> ::typst::diag::SourceResult<#foundations::Styles> {
let mut styles = #foundations::Styles::new();
diff --git a/crates/typst-macros/src/func.rs b/crates/typst-macros/src/func.rs
index 8537ac4f..953df428 100644
--- a/crates/typst-macros/src/func.rs
+++ b/crates/typst-macros/src/func.rs
@@ -36,8 +36,7 @@ struct Func {
#[derive(Default)]
struct SpecialParams {
self_: Option<Param>,
- vm: bool,
- vt: bool,
+ engine: bool,
args: bool,
span: bool,
}
@@ -171,8 +170,7 @@ fn parse_param(
};
match ident.to_string().as_str() {
- "vm" => special.vm = true,
- "vt" => special.vt = true,
+ "engine" => special.engine = true,
"args" => special.args = true,
"span" => special.span = true,
_ => {
@@ -322,13 +320,12 @@ fn create_wrapper_closure(func: &Func) -> TokenStream {
.as_ref()
.map(bind)
.map(|tokens| quote! { #tokens, });
- let vm_ = func.special.vm.then(|| quote! { vm, });
- let vt_ = func.special.vt.then(|| quote! { &mut vm.vt, });
+ let vt_ = func.special.engine.then(|| quote! { engine, });
let args_ = func.special.args.then(|| quote! { args, });
let span_ = func.special.span.then(|| quote! { args.span, });
let forwarded = func.params.iter().filter(|param| !param.external).map(bind);
quote! {
- __typst_func(#self_ #vm_ #vt_ #args_ #span_ #(#forwarded,)*)
+ __typst_func(#self_ #vt_ #args_ #span_ #(#forwarded,)*)
}
};
@@ -336,7 +333,7 @@ fn create_wrapper_closure(func: &Func) -> TokenStream {
let ident = &func.ident;
let parent = func.parent.as_ref().map(|ty| quote! { #ty:: });
quote! {
- |vm, args| {
+ |engine, args| {
let __typst_func = #parent #ident;
#handlers
#finish