mirror of
https://github.com/erg-lang/erg.git
synced 2025-10-01 13:11:11 +00:00
Fix constant evaluation methods to return EvalResult
This commit is contained in:
parent
e2bd64ebe5
commit
e1eebb252f
7 changed files with 217 additions and 100 deletions
|
@ -2846,7 +2846,7 @@ impl Expr {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
pub struct Module(Vec<Expr>);
|
||||
pub struct Module(Block);
|
||||
|
||||
impl fmt::Display for Module {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
|
@ -2860,7 +2860,31 @@ impl Locational for Module {
|
|||
}
|
||||
}
|
||||
|
||||
impl_stream_for_wrapper!(Module, Expr);
|
||||
impl Stream<Expr> for Module {
|
||||
fn payload(self) -> Vec<Expr> {
|
||||
self.0.payload()
|
||||
}
|
||||
fn ref_payload(&self) -> &Vec<Expr> {
|
||||
self.0.ref_payload()
|
||||
}
|
||||
fn ref_mut_payload(&mut self) -> &mut Vec<Expr> {
|
||||
self.0.ref_mut_payload()
|
||||
}
|
||||
}
|
||||
|
||||
impl Module {
|
||||
pub const fn empty() -> Self {
|
||||
Self(Block::empty())
|
||||
}
|
||||
#[inline]
|
||||
pub fn with_capacity(capacity: usize) -> Self {
|
||||
Self(Block::with_capacity(capacity))
|
||||
}
|
||||
|
||||
pub fn block(&self) -> &Block {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct AST {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue