-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
inline assembly to AST in json export #7537
Conversation
0110af0
to
7489e46
Compare
3fc863d
to
9d1d7fc
Compare
6a17696
to
22e4d69
Compare
HELP NEEDED: All test that fail are related to the fuzzer testing soljson. I don't really know how to debug that or make sense of it. any pointers? UPDATE: All solved |
@djudjuu I didn't take a look at all failures. One failure that I spent some time on is from the
What I tried to do is the following
One option to debug this specific failure further is to copy paste the highlighted solidity test case into a standalone file and run it against solfuzzer. My guess is that the run should failure with an internal compiler error, and then you can debug the issue further. Hope this helps you :) |
7f3ae64
to
1883b69
Compare
Please retarget to 0.6.0 - I think this might break some tools. |
I retargeted it, but I can't retrigger the tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Why does it sometimes use
(*this)(...)
and sometimesboost::apply_visitor(*this, ...);
? - It would be nice to have some smaller tests also. It's impossible to review 1000 lines of JSON output.
libsolidity/ast/ASTJsonConverter.cpp
Outdated
@@ -24,6 +24,7 @@ | |||
#include <libsolidity/ast/AST.h> | |||
#include <libyul/AsmData.h> | |||
#include <libyul/AsmPrinter.h> | |||
#include <libsolidity/ast/AsmJsonConverter.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be moved two lines up.
int sourceIndex{-1}; | ||
if (_location.source && m_sourceIndices.count(_location.source->name())) | ||
sourceIndex = m_sourceIndices.at(_location.source->name()); | ||
size_t sourceIndex = sourceIndexFromLocation(_location); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before, if the condition was false, sourceIndex == -1
. Now it asserts. Why is the latter true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can be rather sure to have a source, but better to not assert, I think.
libsolidity/ast/AsmJsonConverter.h
Outdated
*/ | ||
|
||
#include <libyul/AsmDataForward.h> | ||
#include <liblangutil/SourceLocation.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This include should be moved up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing: I think liblangutil is more basic than libyul.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, got confused
libsolidity/ast/AsmJsonConverter.h
Outdated
using TypedNameList = std::vector<yul::TypedName>; | ||
|
||
/** | ||
* Converter of the yul AST into JSON format |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this converts Yul to JSON, shouldn't it go into libyul
instead of libsolidity
?
libsolidity/ast/AsmJsonConverter.h
Outdated
/** | ||
* Converter of the yul AST into JSON format | ||
*/ | ||
class AsmJsonConverter : public boost::static_visitor<Json::Value> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class AsmJsonConverter : public boost::static_visitor<Json::Value> | |
class AsmJsonConverter: public boost::static_visitor<Json::Value> |
libsolidity/ast/AsmJsonConverter.h
Outdated
private: | ||
Json::Value createAstNode(langutil::SourceLocation const& _location, std::string _nodeType) const; | ||
template <class T> | ||
Json::Value vectorOfVariantsToJson(std::vector<T> const& vec ) const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Json::Value vectorOfVariantsToJson(std::vector<T> const& vec ) const; | |
Json::Value vectorOfVariantsToJson(std::vector<T> const& vec) const; |
libsolidity/ast/AsmJsonConverter.cpp
Outdated
#include <libsolidity/ast/AsmJsonConverter.h> | ||
#include <libyul/AsmData.h> | ||
#include <liblangutil/Exceptions.h> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra blank line.
libsolidity/ast/AsmJsonConverter.cpp
Outdated
|
||
#include <libsolidity/ast/AsmJsonConverter.h> | ||
#include <libyul/AsmData.h> | ||
#include <liblangutil/Exceptions.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line should be moved one up. It should still come after AsmJsonConverter.h
, since that's the header of this cpp.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't liblangutil more basic than libyul?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah sorry, that's correct
libsolidity/ast/AsmJsonConverter.cpp
Outdated
namespace solidity | ||
{ | ||
|
||
Json::Value AsmJsonConverter::createAstNode(langutil::SourceLocation const& _location, string _nodeType) const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this and the next function should go to the end of the file to follow the same order as the header.
Why does it sometimes use (*this)(...) and sometimes boost::apply_visitor(*this, ...);?: Depends on whether the argument is a variant (then you have to use apply_visitor), or a specific type (then |
3d7b9b3
to
641c4c0
Compare
"statements": | ||
[ | ||
{ | ||
"AST": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually what's this AST
key?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a node-type-specific key for the node type "InlineAssembly".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually - it would probably be better to prefix all the Yul AST node types by Yul
wouldn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It sounds quite generic. Why not call it something closer to InlineAssembly
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually - it would probably be better to prefix all the Yul AST node types by
Yul
wouldn't it?
Yea I agree
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the keys that depend on the node type are always "generic" because they are only seen in the context of the node type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm ok
Description
resolves #2419
creates different kinds of Json nodes for each kind of AsmData-struct.
similar to the solidityAST, there is a "nodeType" field and a "src"-location.
Goal: It should be possible to recreate the AsmData from the Json.
TEST added: I added a contract with a bunch of inlineAssembly (assebly.sol from the syntaxTests) to
/test/libsolidity/ASTJSON
Then I ran the testsuite and used its output from the error-message to create
assembly.json
andassembly_legacy.json
.Checklist
-> left a note on [DOCS] Add AST output #7387