summaryrefslogtreecommitdiff
path: root/crates/typst-ide/src/analyze.rs
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-ide/src/analyze.rs
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-ide/src/analyze.rs')
-rw-r--r--crates/typst-ide/src/analyze.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/crates/typst-ide/src/analyze.rs b/crates/typst-ide/src/analyze.rs
index f3e417d5..8c5117f7 100644
--- a/crates/typst-ide/src/analyze.rs
+++ b/crates/typst-ide/src/analyze.rs
@@ -1,9 +1,10 @@
use comemo::Track;
use ecow::{eco_vec, EcoString, EcoVec};
-use typst::eval::{Route, Tracer, Vm};
+use typst::engine::{Engine, Route};
+use typst::eval::{Tracer, Vm};
use typst::foundations::{Label, Scopes, Value};
use typst::introspection::{Introspector, Locator};
-use typst::layout::{Frame, Vt};
+use typst::layout::Frame;
use typst::model::BibliographyElem;
use typst::syntax::{ast, LinkedNode, Span, SyntaxKind};
use typst::World;
@@ -46,7 +47,6 @@ pub fn analyze_expr(world: &dyn World, node: &LinkedNode) -> EcoVec<Value> {
/// Try to load a module from the current source file.
pub fn analyze_import(world: &dyn World, source: &LinkedNode) -> Option<Value> {
- let id = source.span().id()?;
let source = analyze_expr(world, source).into_iter().next()?;
if source.scope().is_some() {
return Some(source);
@@ -55,15 +55,15 @@ pub fn analyze_import(world: &dyn World, source: &LinkedNode) -> Option<Value> {
let mut locator = Locator::default();
let introspector = Introspector::default();
let mut tracer = Tracer::new();
- let vt = Vt {
+ let engine = Engine {
world: world.track(),
+ route: Route::default(),
introspector: introspector.track(),
locator: &mut locator,
tracer: tracer.track_mut(),
};
- let route = Route::default();
- let mut vm = Vm::new(vt, route.track(), Some(id), Scopes::new(Some(world.library())));
+ let mut vm = Vm::new(engine, Scopes::new(Some(world.library())), Span::detached());
typst::eval::import(&mut vm, source, Span::detached(), true)
.ok()
.map(Value::Module)