use crate::syntax::ast::node::Node;
use boa_interner::{Interner, Sym, ToInternedString};
#[cfg(feature = "deser")]
use serde::{Deserialize, Serialize};
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct Continue {
label: Option<Sym>,
}
impl Continue {
pub fn new<L>(label: L) -> Self
where
L: Into<Option<Sym>>,
{
Self {
label: label.into(),
}
}
pub fn label(&self) -> Option<Sym> {
self.label
}
}
impl ToInternedString for Continue {
fn to_interned_string(&self, interner: &Interner) -> String {
if let Some(label) = self.label {
format!("continue {}", interner.resolve_expect(label))
} else {
"continue".to_owned()
}
}
}
impl From<Continue> for Node {
fn from(cont: Continue) -> Self {
Self::Continue(cont)
}
}