use crate::syntax::ast::node::{Call, 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 New {
call: Call,
}
impl New {
pub fn expr(&self) -> &Node {
self.call.expr()
}
pub fn args(&self) -> &[Node] {
self.call.args()
}
pub(crate) fn call(&self) -> &Call {
&self.call
}
}
impl From<Call> for New {
fn from(call: Call) -> Self {
Self { call }
}
}
impl ToInternedString for New {
fn to_interned_string(&self, interner: &Interner) -> String {
format!("new {}", self.call.to_interned_string(interner))
}
}
impl From<New> for Node {
fn from(new: New) -> Self {
Self::New(new)
}
}