107 lines
2.3 KiB
Rust
107 lines
2.3 KiB
Rust
use crate::ast::node::expression::Expression;
|
|
use crate::ast::node::generics::GenericArguments;
|
|
|
|
#[derive(Debug)]
|
|
pub struct CallExpression {
|
|
callee: Box<Expression>,
|
|
turbo_fish: Option<Box<TurboFish>>,
|
|
arguments: Box<CallArguments>,
|
|
}
|
|
|
|
impl CallExpression {
|
|
pub fn new(
|
|
callee: Box<Expression>,
|
|
turbo_fish: Option<Box<TurboFish>>,
|
|
arguments: Box<CallArguments>,
|
|
) -> Self {
|
|
Self {
|
|
callee,
|
|
turbo_fish,
|
|
arguments,
|
|
}
|
|
}
|
|
|
|
pub fn callee(&self) -> &Expression {
|
|
&self.callee
|
|
}
|
|
|
|
pub fn callee_mut(&mut self) -> &mut Expression {
|
|
&mut self.callee
|
|
}
|
|
|
|
pub fn turbo_fish(&self) -> Option<&TurboFish> {
|
|
if let Some(turbo_fish) = &self.turbo_fish {
|
|
Some(turbo_fish.as_ref())
|
|
} else {
|
|
None
|
|
}
|
|
}
|
|
|
|
pub fn turbo_fish_mut(&mut self) -> Option<&mut TurboFish> {
|
|
if let Some(turbo_fish) = &mut self.turbo_fish {
|
|
Some(turbo_fish.as_mut())
|
|
} else {
|
|
None
|
|
}
|
|
}
|
|
|
|
pub fn arguments(&self) -> &CallArguments {
|
|
&self.arguments
|
|
}
|
|
|
|
pub fn arguments_mut(&mut self) -> &mut CallArguments {
|
|
&mut self.arguments
|
|
}
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub struct TurboFish(Box<GenericArguments>);
|
|
|
|
impl TurboFish {
|
|
pub fn new(generics: Box<GenericArguments>) -> Self {
|
|
Self(generics)
|
|
}
|
|
|
|
pub fn generics(&self) -> &GenericArguments {
|
|
&self.0
|
|
}
|
|
|
|
pub fn generics_mut(&mut self) -> &mut GenericArguments {
|
|
&mut self.0
|
|
}
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub struct CallArguments(Vec<Box<CallArgument>>);
|
|
|
|
impl CallArguments {
|
|
pub fn new(arguments: Vec<Box<CallArgument>>) -> Self {
|
|
Self(arguments)
|
|
}
|
|
|
|
pub fn arguments(&self) -> Vec<&CallArgument> {
|
|
self.0.iter().map(Box::as_ref).collect()
|
|
}
|
|
|
|
pub fn arguments_mut(&mut self) -> Vec<&mut CallArgument> {
|
|
self.0.iter_mut().map(Box::as_mut).collect()
|
|
}
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub struct CallArgument(Box<Expression>);
|
|
|
|
impl CallArgument {
|
|
pub fn new(expression: Box<Expression>) -> Self {
|
|
Self(expression)
|
|
}
|
|
|
|
pub fn expression(&self) -> &Expression {
|
|
&self.0
|
|
}
|
|
|
|
pub fn expression_mut(&mut self) -> &mut Expression {
|
|
&mut self.0
|
|
}
|
|
}
|