mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-16 12:01:13 +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:
@@ -16,6 +16,8 @@ use crate::lexer::token::Token;
|
||||
use crate::lexer::Lexer;
|
||||
use crate::parser::error::Error as ParserError;
|
||||
use crate::parser::identifier::Identifier;
|
||||
use crate::visitor::AstNode;
|
||||
use crate::visitor::AstVisitor;
|
||||
|
||||
use self::function_call::FunctionCall;
|
||||
use self::literal::Literal;
|
||||
@@ -144,3 +146,21 @@ impl Expression {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl AstNode for Expression {
|
||||
fn accept(&self, ast_visitor: &mut impl AstVisitor) {
|
||||
ast_visitor.visit_expression(self);
|
||||
}
|
||||
|
||||
fn visit_children(&self, ast_visitor: &mut impl AstVisitor) {
|
||||
match self {
|
||||
Self::FunctionCall(inner) => inner.accept(ast_visitor),
|
||||
Self::Identifier(inner) => inner.accept(ast_visitor),
|
||||
Self::Literal(inner) => inner.accept(ast_visitor),
|
||||
}
|
||||
}
|
||||
|
||||
fn location(&self) -> Location {
|
||||
self.location()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user