Add Builtin AST node

This commit is contained in:
Kamil Śliwak 2023-09-12 16:26:42 +02:00
parent 8304aca1c1
commit 13abd0c9eb
4 changed files with 46 additions and 0 deletions

View File

@ -2596,6 +2596,35 @@ private:
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;
};
/// @}
}

View File

@ -105,6 +105,7 @@ class TypeClassDefinition;
class TypeClassInstantiation;
class TypeClassName;
class TypeDefinition;
class Builtin;
/// @}
class VariableScope;

View File

@ -115,6 +115,7 @@ public:
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); }
@ -178,6 +179,7 @@ public:
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:
@ -263,6 +265,7 @@ public:
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); }
@ -326,6 +329,7 @@ public:
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:

View File

@ -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);
}
/// @}
}