Skip to content

Commit

Permalink
Enhancements/make abstractions scalable (#253)
Browse files Browse the repository at this point in the history
  • Loading branch information
TilakMaddy authored Apr 1, 2024
1 parent 6cd7655 commit 03f9664
Show file tree
Hide file tree
Showing 27 changed files with 335 additions and 1,204 deletions.
5 changes: 5 additions & 0 deletions aderyn_core/src/ast/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ impl Node for Block {
visitor.visit_immediate_children(self.id, children_ids)?;
Ok(())
}

fn accept_id(&self, visitor: &mut impl ASTConstVisitor) -> Result<()> {
visitor.visit_node_id(Some(self.id))?;
Ok(())
}
}

impl Display for Block {
Expand Down
14 changes: 14 additions & 0 deletions aderyn_core/src/ast/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ impl Node for ContractDefinitionNode {
) => user_defined_value_type_definition.accept(visitor),
}
}

fn accept_id(&self, visitor: &mut impl ASTConstVisitor) -> Result<()> {
visitor.visit_node_id(self.get_node_id())?;
Ok(())
}
}

impl ContractDefinitionNode {
Expand Down Expand Up @@ -154,6 +159,10 @@ impl Node for InheritanceSpecifier {
visitor.visit_immediate_children(self.id, argument_ids)?;
Ok(())
}
fn accept_id(&self, visitor: &mut impl ASTConstVisitor) -> Result<()> {
visitor.visit_node_id(Some(self.id))?;
Ok(())
}
}

impl Display for InheritanceSpecifier {
Expand Down Expand Up @@ -231,6 +240,11 @@ impl Node for ContractDefinition {
visitor.visit_immediate_children(self.id, node_ids)?;
Ok(())
}

fn accept_id(&self, visitor: &mut impl ASTConstVisitor) -> Result<()> {
visitor.visit_node_id(Some(self.id))?;
Ok(())
}
}

impl ContractDefinition {
Expand Down
8 changes: 8 additions & 0 deletions aderyn_core/src/ast/enumerations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ impl Node for EnumValue {
visitor.visit_enum_value(self)?;
visitor.end_visit_enum_value(self)
}
fn accept_id(&self, visitor: &mut impl ASTConstVisitor) -> Result<()> {
visitor.visit_node_id(Some(self.id))?;
Ok(())
}
}

impl Display for EnumValue {
Expand Down Expand Up @@ -55,6 +59,10 @@ impl Node for EnumDefinition {
visitor.visit_immediate_children(self.id, member_ids.clone())?;
Ok(())
}
fn accept_id(&self, visitor: &mut impl ASTConstVisitor) -> Result<()> {
visitor.visit_node_id(Some(self.id))?;
Ok(())
}
}

impl Display for EnumDefinition {
Expand Down
4 changes: 4 additions & 0 deletions aderyn_core/src/ast/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ impl Node for ErrorDefinition {
// TODO: send documentation nodes to visitor
visitor.visit_immediate_children(self.id, vec![self.parameters.id])
}
fn accept_id(&self, visitor: &mut impl ASTConstVisitor) -> Result<()> {
visitor.visit_node_id(Some(self.id))?;
Ok(())
}
}

impl Display for ErrorDefinition {
Expand Down
4 changes: 4 additions & 0 deletions aderyn_core/src/ast/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ impl Node for EventDefinition {
visitor.visit_immediate_children(self.id, vec![self.parameters.id])?;
Ok(())
}
fn accept_id(&self, visitor: &mut impl ASTConstVisitor) -> Result<()> {
visitor.visit_node_id(Some(self.id))?;
Ok(())
}
}

impl Display for EventDefinition {
Expand Down
53 changes: 53 additions & 0 deletions aderyn_core/src/ast/expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ impl Node for Expression {
}
}
}

fn accept_id(&self, visitor: &mut impl ASTConstVisitor) -> Result<()> {
visitor.visit_node_id(self.get_node_id())?;
Ok(())
}
}

impl Expression {
Expand Down Expand Up @@ -308,6 +313,10 @@ impl Node for UnaryOperation {
}
Ok(())
}
fn accept_id(&self, visitor: &mut impl ASTConstVisitor) -> Result<()> {
visitor.visit_node_id(Some(self.id))?;
Ok(())
}
}

impl UnaryOperation {
Expand Down Expand Up @@ -361,6 +370,10 @@ impl Node for BinaryOperation {
}
Ok(())
}
fn accept_id(&self, visitor: &mut impl ASTConstVisitor) -> Result<()> {
visitor.visit_node_id(Some(self.id))?;
Ok(())
}
}

impl BinaryOperation {
Expand Down Expand Up @@ -418,6 +431,10 @@ impl Node for Conditional {
}
Ok(())
}
fn accept_id(&self, visitor: &mut impl ASTConstVisitor) -> Result<()> {
visitor.visit_node_id(Some(self.id))?;
Ok(())
}
}

impl Conditional {
Expand Down Expand Up @@ -471,6 +488,10 @@ impl Node for Assignment {
}
Ok(())
}
fn accept_id(&self, visitor: &mut impl ASTConstVisitor) -> Result<()> {
visitor.visit_node_id(Some(self.id))?;
Ok(())
}
}

impl Assignment {
Expand Down Expand Up @@ -536,6 +557,10 @@ impl Node for FunctionCall {
visitor.visit_immediate_children(self.id, argument_ids)?;
Ok(())
}
fn accept_id(&self, visitor: &mut impl ASTConstVisitor) -> Result<()> {
visitor.visit_node_id(Some(self.id))?;
Ok(())
}
}

impl FunctionCall {
Expand Down Expand Up @@ -610,6 +635,10 @@ impl Node for FunctionCallOptions {
}
Ok(())
}
fn accept_id(&self, visitor: &mut impl ASTConstVisitor) -> Result<()> {
visitor.visit_node_id(Some(self.id))?;
Ok(())
}
}

impl FunctionCallOptions {
Expand Down Expand Up @@ -703,6 +732,10 @@ impl Node for IndexAccess {
}
Ok(())
}
fn accept_id(&self, visitor: &mut impl ASTConstVisitor) -> Result<()> {
visitor.visit_node_id(Some(self.id))?;
Ok(())
}
}

impl IndexAccess {
Expand Down Expand Up @@ -762,6 +795,10 @@ impl Node for IndexRangeAccess {
}
Ok(())
}
fn accept_id(&self, visitor: &mut impl ASTConstVisitor) -> Result<()> {
visitor.visit_node_id(Some(self.id))?;
Ok(())
}
}

impl IndexRangeAccess {
Expand Down Expand Up @@ -826,6 +863,10 @@ impl Node for MemberAccess {
}
Ok(())
}
fn accept_id(&self, visitor: &mut impl ASTConstVisitor) -> Result<()> {
visitor.visit_node_id(Some(self.id))?;
Ok(())
}
}

impl MemberAccess {
Expand Down Expand Up @@ -859,6 +900,10 @@ impl Node for ElementaryTypeNameExpression {
visitor.visit_elementary_type_name_expression(self)?;
visitor.end_visit_elementary_type_name_expression(self)
}
fn accept_id(&self, visitor: &mut impl ASTConstVisitor) -> Result<()> {
visitor.visit_node_id(Some(self.id))?;
Ok(())
}
}

impl Display for ElementaryTypeNameExpression {
Expand Down Expand Up @@ -904,6 +949,10 @@ impl Node for TupleExpression {
visitor.visit_immediate_children(self.id, comp_ids)?;
Ok(())
}
fn accept_id(&self, visitor: &mut impl ASTConstVisitor) -> Result<()> {
visitor.visit_node_id(Some(self.id))?;
Ok(())
}
}

impl TupleExpression {
Expand Down Expand Up @@ -961,6 +1010,10 @@ impl Node for NewExpression {
}
visitor.end_visit_new_expression(self)
}
fn accept_id(&self, visitor: &mut impl ASTConstVisitor) -> Result<()> {
visitor.visit_node_id(Some(self.id))?;
Ok(())
}
}

impl Display for NewExpression {
Expand Down
12 changes: 12 additions & 0 deletions aderyn_core/src/ast/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ impl Node for ParameterList {
visitor.visit_immediate_children(self.id, parameters_ids.clone())?;
Ok(())
}
fn accept_id(&self, visitor: &mut impl ASTConstVisitor) -> Result<()> {
visitor.visit_node_id(Some(self.id))?;
Ok(())
}
}

impl Display for ParameterList {
Expand Down Expand Up @@ -79,6 +83,10 @@ impl Node for OverrideSpecifier {
visitor.visit_immediate_children(self.id, overrides_ids.clone())?;
Ok(())
}
fn accept_id(&self, visitor: &mut impl ASTConstVisitor) -> Result<()> {
visitor.visit_node_id(Some(self.id))?;
Ok(())
}
}

impl Display for OverrideSpecifier {
Expand Down Expand Up @@ -160,6 +168,10 @@ impl Node for FunctionDefinition {
}
Ok(())
}
fn accept_id(&self, visitor: &mut impl ASTConstVisitor) -> Result<()> {
visitor.visit_node_id(Some(self.id))?;
Ok(())
}
}

impl FunctionDefinition {
Expand Down
8 changes: 8 additions & 0 deletions aderyn_core/src/ast/identifiers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ impl Node for Identifier {
fn accept_metadata(&self, _visitor: &mut impl ASTConstVisitor) -> Result<()> {
Ok(())
}
fn accept_id(&self, visitor: &mut impl ASTConstVisitor) -> Result<()> {
visitor.visit_node_id(Some(self.id))?;
Ok(())
}
}

impl PartialEq for Identifier {
Expand Down Expand Up @@ -78,6 +82,10 @@ impl Node for IdentifierPath {
fn accept_metadata(&self, _visitor: &mut impl ASTConstVisitor) -> Result<()> {
Ok(())
}
fn accept_id(&self, visitor: &mut impl ASTConstVisitor) -> Result<()> {
visitor.visit_node_id(Some(self.id))?;
Ok(())
}
}

impl PartialEq for IdentifierPath {
Expand Down
4 changes: 4 additions & 0 deletions aderyn_core/src/ast/import_directives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,8 @@ impl Node for ImportDirective {
visitor.visit_immediate_children(self.id, symbol_alias_ids)?;
Ok(())
}
fn accept_id(&self, visitor: &mut impl ASTConstVisitor) -> Result<()> {
visitor.visit_node_id(Some(self.id))?;
Ok(())
}
}
4 changes: 4 additions & 0 deletions aderyn_core/src/ast/literals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ impl Node for Literal {
visitor.visit_literal(self)?;
visitor.end_visit_literal(self)
}
fn accept_id(&self, visitor: &mut impl ASTConstVisitor) -> Result<()> {
visitor.visit_node_id(Some(self.id))?;
Ok(())
}
}

impl Display for Literal {
Expand Down
8 changes: 8 additions & 0 deletions aderyn_core/src/ast/modifiers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ impl Node for ModifierDefinition {
visitor.visit_immediate_children(self.id, vec![self.parameters.id])?;
Ok(())
}
fn accept_id(&self, visitor: &mut impl ASTConstVisitor) -> Result<()> {
visitor.visit_node_id(Some(self.id))?;
Ok(())
}
}

impl Display for ModifierDefinition {
Expand Down Expand Up @@ -110,6 +114,10 @@ impl Node for ModifierInvocation {
}
Ok(())
}
fn accept_id(&self, visitor: &mut impl ASTConstVisitor) -> Result<()> {
visitor.visit_node_id(Some(self.id))?;
Ok(())
}
}

impl Display for ModifierInvocation {
Expand Down
4 changes: 4 additions & 0 deletions aderyn_core/src/ast/pragma_directives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@ impl Node for PragmaDirective {
visitor.visit_pragma_directive(self)?;
visitor.end_visit_pragma_directive(self)
}
fn accept_id(&self, visitor: &mut impl ASTConstVisitor) -> Result<()> {
visitor.visit_node_id(Some(self.id))?;
Ok(())
}
}
8 changes: 8 additions & 0 deletions aderyn_core/src/ast/source_units.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ impl Node for SourceUnitNode {
}
}
}
fn accept_id(&self, visitor: &mut impl ASTConstVisitor) -> Result<()> {
visitor.visit_node_id(self.get_node_id())?;
Ok(())
}
}

#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
Expand Down Expand Up @@ -90,6 +94,10 @@ impl Node for SourceUnit {
visitor.visit_immediate_children(self.id, node_ids.clone())?;
Ok(())
}
fn accept_id(&self, visitor: &mut impl ASTConstVisitor) -> Result<()> {
visitor.visit_node_id(Some(self.id))?;
Ok(())
}
}

impl SourceUnit {
Expand Down
Loading

0 comments on commit 03f9664

Please sign in to comment.