mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
libyul: Adds Comment as new AST node type, to be used for pretty printing (and preserving) comments in yul-format.
This commit is contained in:
@@ -153,6 +153,11 @@ Statement ASTCopier::operator ()(Block const& _block)
|
||||
return translate(_block);
|
||||
}
|
||||
|
||||
Statement ASTCopier::operator()(Comment const& _comment)
|
||||
{
|
||||
return Comment{_comment.location, _comment.text};
|
||||
}
|
||||
|
||||
Expression ASTCopier::translate(Expression const& _expression)
|
||||
{
|
||||
return _expression.apply_visitor(static_cast<ExpressionCopier&>(*this));
|
||||
|
||||
@@ -61,6 +61,7 @@ public:
|
||||
virtual Statement operator()(Break const&) = 0;
|
||||
virtual Statement operator()(Continue const&) = 0;
|
||||
virtual Statement operator()(Block const& _block) = 0;
|
||||
virtual Statement operator()(Comment const& _comment) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -88,6 +89,7 @@ public:
|
||||
Statement operator()(Break const&) override;
|
||||
Statement operator()(Continue const&) override;
|
||||
Statement operator()(Block const& _block) override;
|
||||
Statement operator()(Comment const& _comment) override;
|
||||
|
||||
virtual Expression translate(Expression const& _expression);
|
||||
virtual Statement translate(Statement const& _statement);
|
||||
|
||||
@@ -59,6 +59,7 @@ public:
|
||||
virtual void operator()(Break const&) {}
|
||||
virtual void operator()(Continue const&) {}
|
||||
virtual void operator()(Block const& _block);
|
||||
virtual void operator()(Comment const&) {}
|
||||
|
||||
virtual void visit(Statement const& _st);
|
||||
virtual void visit(Expression const& _e);
|
||||
@@ -96,6 +97,7 @@ public:
|
||||
virtual void operator()(Break&);
|
||||
virtual void operator()(Continue&);
|
||||
virtual void operator()(Block& _block);
|
||||
virtual void operator()(Comment&) {}
|
||||
|
||||
virtual void visit(Statement& _st);
|
||||
virtual void visit(Expression& _e);
|
||||
|
||||
@@ -181,6 +181,11 @@ bool SyntacticallyEqual::statementEqual(Block const& _lhs, Block const& _rhs)
|
||||
});
|
||||
}
|
||||
|
||||
bool SyntacticallyEqual::statementEqual(Comment const& _lhs, Comment const& _rhs)
|
||||
{
|
||||
return _lhs.text == _rhs.text;
|
||||
}
|
||||
|
||||
bool SyntacticallyEqual::visitDeclaration(TypedName const& _lhs, TypedName const& _rhs)
|
||||
{
|
||||
if (_lhs.type != _rhs.type)
|
||||
|
||||
@@ -58,6 +58,7 @@ public:
|
||||
bool statementEqual(Break const&, Break const&) { return true; }
|
||||
bool statementEqual(Continue const&, Continue const&) { return true; }
|
||||
bool statementEqual(Block const& _lhs, Block const& _rhs);
|
||||
bool statementEqual(Comment const& _lhs, Comment const& _rhs);
|
||||
private:
|
||||
bool statementEqual(Instruction const& _lhs, Instruction const& _rhs);
|
||||
bool statementEqual(Label const& _lhs, Label const& _rhs);
|
||||
|
||||
Reference in New Issue
Block a user