Skip to content

Commit

Permalink
Add Builtin AST node
Browse files Browse the repository at this point in the history
  • Loading branch information
cameel committed Oct 30, 2023
1 parent 9147dac commit 7a50541
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
29 changes: 29 additions & 0 deletions libsolidity/ast/AST.h
Original file line number Diff line number Diff line change
Expand Up @@ -2596,6 +2596,35 @@ class TypeClassName: public ASTNode
std::variant<Token, ASTPointer<IdentifierPath>> m_name;
};

class Builtin: public Expression
{
public:
Builtin(
int64_t _id,
SourceLocation _location,
ASTPointer<ASTString> _nameParameter,
SourceLocation _nameParameterLocation
):
Expression(_id, std::move(_location)),
m_nameParameter(std::move(_nameParameter)),
m_nameParameterLocation(std::move(_nameParameterLocation))
{
solAssert(m_nameParameter);
}

void accept(ASTVisitor& _visitor) override;
void accept(ASTConstVisitor& _visitor) const override;

bool experimentalSolidityOnly() const override { return true; }

ASTString const& nameParameter() const { return *m_nameParameter; }
SourceLocation const& nameParameterLocation() const { return m_nameParameterLocation; }

private:
ASTPointer<ASTString> m_nameParameter;
SourceLocation m_nameParameterLocation;
};

/// @}

}
1 change: 1 addition & 0 deletions libsolidity/ast/ASTForward.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class TypeClassDefinition;
class TypeClassInstantiation;
class TypeClassName;
class TypeDefinition;
class Builtin;
/// @}

class VariableScope;
Expand Down
4 changes: 4 additions & 0 deletions libsolidity/ast/ASTVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class ASTVisitor
virtual bool visit(TypeClassInstantiation& _node) { return visitNode(_node); }
virtual bool visit(TypeDefinition& _node) { return visitNode(_node); }
virtual bool visit(TypeClassName& _node) { return visitNode(_node); }
virtual bool visit(Builtin& _node) { return visitNode(_node); }
/// @}

virtual void endVisit(SourceUnit& _node) { endVisitNode(_node); }
Expand Down Expand Up @@ -178,6 +179,7 @@ class ASTVisitor
virtual void endVisit(TypeClassInstantiation& _node) { endVisitNode(_node); }
virtual void endVisit(TypeDefinition& _node) { endVisitNode(_node); }
virtual void endVisit(TypeClassName& _node) { endVisitNode(_node); }
virtual void endVisit(Builtin& _node) { endVisitNode(_node); }
/// @}

protected:
Expand Down Expand Up @@ -263,6 +265,7 @@ class ASTConstVisitor
virtual bool visit(TypeClassInstantiation const& _node) { return visitNode(_node); }
virtual bool visit(TypeDefinition const& _node) { return visitNode(_node); }
virtual bool visit(TypeClassName const& _node) { return visitNode(_node); }
virtual bool visit(Builtin const& _node) { return visitNode(_node); }
/// @}

virtual void endVisit(SourceUnit const& _node) { endVisitNode(_node); }
Expand Down Expand Up @@ -326,6 +329,7 @@ class ASTConstVisitor
virtual void endVisit(TypeClassInstantiation const& _node) { endVisitNode(_node); }
virtual void endVisit(TypeDefinition const& _node) { endVisitNode(_node); }
virtual void endVisit(TypeClassName const& _node) { endVisitNode(_node); }
virtual void endVisit(Builtin const& _node) { endVisitNode(_node); }
/// @}

protected:
Expand Down
12 changes: 12 additions & 0 deletions libsolidity/ast/AST_accept.h
Original file line number Diff line number Diff line change
Expand Up @@ -1128,6 +1128,18 @@ void TypeClassName::accept(ASTConstVisitor& _visitor) const
}
_visitor.endVisit(*this);
}

void Builtin::accept(ASTVisitor& _visitor)
{
_visitor.visit(*this);
_visitor.endVisit(*this);
}

void Builtin::accept(ASTConstVisitor& _visitor) const
{
_visitor.visit(*this);
_visitor.endVisit(*this);
}
/// @}

}

0 comments on commit 7a50541

Please sign in to comment.