feat: add ExprRef sumtype with better expression iteration

This commit is contained in:
Anand Balakrishnan 2023-03-20 10:28:26 -07:00
parent 79384d436d
commit 0359029741
No known key found for this signature in database
5 changed files with 93 additions and 19 deletions

View file

@ -1,19 +1,17 @@
use std::any::Any;
use super::iter::AstIter;
use super::{iter::AstIter, ExprRef};
/// A trait representing expressions
pub trait Expr {
fn args(&self) -> Vec<&dyn Expr>;
fn is_numeric(&self) -> bool;
fn is_boolean(&self) -> bool;
fn args(&self) -> Vec<ExprRef<'_>>;
fn as_any(&self) -> &dyn Any;
fn iter(&self) -> AstIter<'_>
where
Self: Sized,
{
AstIter::new(self)
}
fn iter(&self) -> AstIter<'_>;
}
impl dyn Expr {