use crate::{ast::AstPathSegment, ffi::FfiSlice};
use super::{CommonExprData, ExprKind};
#[repr(C)]
#[derive(Debug)]
#[cfg_attr(feature = "driver-api", derive(typed_builder::TypedBuilder))]
pub struct CallExpr<'ast> {
data: CommonExprData<'ast>,
func: ExprKind<'ast>,
#[cfg_attr(feature = "driver-api", builder(setter(into)))]
args: FfiSlice<'ast, ExprKind<'ast>>,
}
impl<'ast> CallExpr<'ast> {
pub fn func(&self) -> ExprKind<'ast> {
self.func
}
pub fn args(&self) -> &[ExprKind<'ast>] {
self.args.get()
}
}
super::impl_expr_data!(CallExpr<'ast>, Call);
#[repr(C)]
#[derive(Debug)]
pub struct MethodExpr<'ast> {
data: CommonExprData<'ast>,
receiver: ExprKind<'ast>,
method: AstPathSegment<'ast>,
args: FfiSlice<'ast, ExprKind<'ast>>,
}
impl<'ast> MethodExpr<'ast> {
pub fn receiver(&self) -> ExprKind<'ast> {
self.receiver
}
pub fn method(&self) -> &AstPathSegment<'ast> {
&self.method
}
pub fn args(&self) -> &[ExprKind<'ast>] {
self.args.get()
}
}
super::impl_expr_data!(MethodExpr<'ast>, Method);
#[cfg(feature = "driver-api")]
impl<'ast> MethodExpr<'ast> {
pub fn new(
data: CommonExprData<'ast>,
receiver: ExprKind<'ast>,
method: AstPathSegment<'ast>,
args: &'ast [ExprKind<'ast>],
) -> Self {
Self {
data,
receiver,
method,
args: args.into(),
}
}
}