+22
-7
src/execution/lazy.rs
+22
-7
src/execution/lazy.rs
···
62
};
63
64
let mut locals = VariableMap::new();
65
-
let mut cursor = QueryCursor::new();
66
let mut store = LazyStore::new();
67
let mut scoped_store = LazyScopedVariables::new();
68
let mut lazy_graph = Vec::new();
69
let mut function_parameters = Vec::new();
70
let mut prev_element_debug_info = HashMap::new();
71
72
-
let query = &self.query.as_ref().unwrap();
73
-
let matches = cursor.matches(query, tree.root_node(), source.as_bytes());
74
-
for mat in matches {
75
cancellation_flag.check("processing matches")?;
76
-
let stanza = &self.stanzas[mat.pattern_index];
77
stanza.execute_lazy(
78
source,
79
&mat,
···
87
&mut prev_element_debug_info,
88
&self.shorthands,
89
cancellation_flag,
90
-
)?;
91
-
}
92
93
let mut exec = EvaluationContext {
94
source,
···
108
store.evaluate_all(&mut exec)?;
109
scoped_store.evaluate_all(&mut exec)?;
110
111
Ok(())
112
}
113
}
···
62
};
63
64
let mut locals = VariableMap::new();
65
let mut store = LazyStore::new();
66
let mut scoped_store = LazyScopedVariables::new();
67
let mut lazy_graph = Vec::new();
68
let mut function_parameters = Vec::new();
69
let mut prev_element_debug_info = HashMap::new();
70
71
+
self.try_visit_matches_lazy(tree, source, |stanza, mat| {
72
cancellation_flag.check("processing matches")?;
73
stanza.execute_lazy(
74
source,
75
&mat,
···
83
&mut prev_element_debug_info,
84
&self.shorthands,
85
cancellation_flag,
86
+
)
87
+
})?;
88
89
let mut exec = EvaluationContext {
90
source,
···
104
store.evaluate_all(&mut exec)?;
105
scoped_store.evaluate_all(&mut exec)?;
106
107
+
Ok(())
108
+
}
109
+
110
+
pub(super) fn try_visit_matches_lazy<'a, 'tree, E, F>(
111
+
&self,
112
+
tree: &'tree Tree,
113
+
source: &'tree str,
114
+
mut visit: F,
115
+
) -> Result<(), E>
116
+
where
117
+
F: FnMut(&ast::Stanza, QueryMatch<'_, 'tree>) -> Result<(), E>,
118
+
{
119
+
let mut cursor = QueryCursor::new();
120
+
let query = self.query.as_ref().unwrap();
121
+
let matches = cursor.matches(query, tree.root_node(), source.as_bytes());
122
+
for mat in matches {
123
+
let stanza = &self.stanzas[mat.pattern_index];
124
+
visit(stanza, mat)?;
125
+
}
126
Ok(())
127
}
128
}