57 lines
1.3 KiB
Rust
57 lines
1.3 KiB
Rust
use crate::ast::node::expression::Expression;
|
|
use crate::ast::node::names::Identifier;
|
|
|
|
#[derive(Debug)]
|
|
pub struct ObjectAccess {
|
|
receiver: Box<Expression>,
|
|
navigations: Box<ObjectNavigations>,
|
|
}
|
|
|
|
impl ObjectAccess {
|
|
pub fn new(receiver: Box<Expression>, navigations: Box<ObjectNavigations>) -> Self {
|
|
Self {
|
|
receiver,
|
|
navigations,
|
|
}
|
|
}
|
|
|
|
pub fn receiver(&self) -> &Expression {
|
|
&self.receiver
|
|
}
|
|
|
|
pub fn receiver_mut(&mut self) -> &mut Expression {
|
|
&mut self.receiver
|
|
}
|
|
|
|
pub fn navigations(&self) -> &ObjectNavigations {
|
|
&self.navigations
|
|
}
|
|
|
|
pub fn navigations_mut(&mut self) -> &mut ObjectNavigations {
|
|
&mut self.navigations
|
|
}
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub struct ObjectNavigations(Vec<Box<ObjectNavigation>>);
|
|
|
|
impl ObjectNavigations {
|
|
pub fn new(navigations: Vec<Box<ObjectNavigation>>) -> Self {
|
|
Self(navigations)
|
|
}
|
|
|
|
pub fn navigations(&self) -> Vec<&ObjectNavigation> {
|
|
self.0.iter().map(Box::as_ref).collect()
|
|
}
|
|
|
|
pub fn navigations_mut(&mut self) -> Vec<&mut ObjectNavigation> {
|
|
self.0.iter_mut().map(Box::as_mut).collect()
|
|
}
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub enum ObjectNavigation {
|
|
Index(Box<Expression>),
|
|
Identifier(Box<Identifier>),
|
|
}
|