grit_pattern_matcher/pattern/undefined.rs
1use super::{resolved_pattern::ResolvedPattern, state::State};
2use crate::context::QueryContext;
3use grit_util::{error::GritResult, AnalysisLogs};
4
5// Undefined is a pattern that matches when a *Grit variable* is undefined.
6// It is *not* meant to match against a *JavaScript* `undefined` value.
7
8pub struct Undefined {}
9
10impl Undefined {
11 pub fn execute<'a, Q: QueryContext>(
12 binding: &Q::ResolvedPattern<'a>,
13 _init_state: &mut State<'a, Q>,
14 _context: &'a Q::ExecContext<'a>,
15 _logs: &mut AnalysisLogs,
16 ) -> GritResult<bool> {
17 Ok(binding.matches_undefined())
18 }
19}