mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-12 08:11:02 +00:00
YUL tree visitor interface (#369)
- Implement the visitor interface. This simplifies working with the AST, for example transformations into other IRs or collecting and analyzing various statistics. - Switch the explorer to use the visitor interface. - Add the reciprocal function name conversion for function names. - Some drive-by cosmetic fixes. --------- Signed-off-by: xermicus <bigcyrill@hotmail.com>
This commit is contained in:
@@ -17,6 +17,8 @@ use crate::parser::error::Error as ParserError;
|
||||
use crate::parser::statement::assignment::Assignment;
|
||||
use crate::parser::statement::expression::Expression;
|
||||
use crate::parser::statement::Statement;
|
||||
use crate::visitor::AstNode;
|
||||
use crate::visitor::AstVisitor;
|
||||
|
||||
/// The Yul source code block.
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
|
||||
@@ -226,6 +228,22 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl AstNode for Block {
|
||||
fn accept(&self, ast_visitor: &mut impl AstVisitor) {
|
||||
ast_visitor.visit_block(self);
|
||||
}
|
||||
|
||||
fn visit_children(&self, ast_visitor: &mut impl AstVisitor) {
|
||||
for statement in &self.statements {
|
||||
statement.accept(ast_visitor);
|
||||
}
|
||||
}
|
||||
|
||||
fn location(&self) -> Location {
|
||||
self.location
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::lexer::token::location::Location;
|
||||
|
||||
Reference in New Issue
Block a user