boa_ast/expression/
import_meta.rs

1//! `import.meta` ECMAScript expression.
2
3use crate::{
4    Span, Spanned,
5    visitor::{VisitWith, Visitor, VisitorMut},
6};
7use boa_interner::{Interner, ToInternedString};
8use core::ops::ControlFlow;
9
10use super::Expression;
11
12/// ECMAScript's `ImportMeta` expression AST node.
13#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
14#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
15#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
16pub struct ImportMeta {
17    span: Span,
18}
19
20impl ImportMeta {
21    /// Creates a new [`ImportMeta`] AST Expression.
22    #[inline]
23    #[must_use]
24    pub const fn new(span: Span) -> Self {
25        Self { span }
26    }
27}
28
29impl Spanned for ImportMeta {
30    #[inline]
31    fn span(&self) -> Span {
32        self.span
33    }
34}
35
36impl From<ImportMeta> for Expression {
37    #[inline]
38    fn from(value: ImportMeta) -> Self {
39        Expression::ImportMeta(value)
40    }
41}
42
43impl ToInternedString for ImportMeta {
44    #[inline]
45    fn to_interned_string(&self, _interner: &Interner) -> String {
46        String::from("import.meta")
47    }
48}
49
50impl VisitWith for ImportMeta {
51    fn visit_with<'a, V>(&'a self, _visitor: &mut V) -> ControlFlow<V::BreakTy>
52    where
53        V: Visitor<'a>,
54    {
55        ControlFlow::Continue(())
56    }
57
58    fn visit_with_mut<'a, V>(&'a mut self, _visitor: &mut V) -> ControlFlow<V::BreakTy>
59    where
60        V: VisitorMut<'a>,
61    {
62        ControlFlow::Continue(())
63    }
64}