use crate::syntax::ast::node::Node;
use boa_interner::{Interner, ToInternedString};
#[cfg(feature = "deser")]
use serde::{Deserialize, Serialize};
#[cfg(test)]
mod tests;
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, PartialEq)]
pub struct Throw {
expr: Box<Node>,
}
impl Throw {
pub fn expr(&self) -> &Node {
&self.expr
}
pub fn new<V>(val: V) -> Self
where
V: Into<Node>,
{
Self {
expr: Box::new(val.into()),
}
}
}
impl ToInternedString for Throw {
fn to_interned_string(&self, interner: &Interner) -> String {
format!("throw {}", self.expr.to_interned_string(interner))
}
}
impl From<Throw> for Node {
fn from(trw: Throw) -> Self {
Self::Throw(trw)
}
}